From 0a2a2711dc8f6aa46cd76cf8fa402ae995df2fb7 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 4 Oct 2026 17:53:29 +0200 Subject: [PATCH] Answer architecture round 2: the judge's contract owns the sentences naming where answers are quoted from and recorded, records.py only reads; the cycle's vocabulary names CLAUDE.md as a quote source --- CLAUDE.md | 2 +- bin/loop_claude/cycle/judge_reply.py | 11 ++++++++--- bin/loop_claude/cycle/run.py | 3 +-- bin/loop_claude/cycle/worker.py | 3 +-- bin/loop_claude/project/records.py | 7 +------ 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 29767fb2..9cfb7b34 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -152,7 +152,7 @@ The rules every project follows, compose-not-entangle first: `~/.claude/principl ## Vocabulary - **chunk** — the unit of work, shipped as one PR; "Working loop" says what it holds. -- **cycle** — in `loop-claude`, worker runs and the judge's verdict on each, until the chunk closes or is left for the next cycle. In between, the human answers any interrupt, or the worker resumes with an answer the judge quoted from `README.md`, `AGENTS.md` or `docs/decisions.md`. +- **cycle** — in `loop-claude`, worker runs and the judge's verdict on each, until the chunk closes or is left for the next cycle. In between, the human answers any interrupt, or the worker resumes with an answer the judge quoted from `README.md`, `AGENTS.md`, `docs/decisions.md` or `~/.claude/CLAUDE.md`. - **gate** — the merge gate: the checks a PR passes before it merges. - **interrupt** — `loop-claude` handing the terminal to the human, `claude --resume`, for a decision that is theirs. - **judge** — the headless claude that reads a worker's transcript each cycle and decides whether to interrupt and whether the chunk is finished. diff --git a/bin/loop_claude/cycle/judge_reply.py b/bin/loop_claude/cycle/judge_reply.py index 5c147ebf..7b3bec81 100644 --- a/bin/loop_claude/cycle/judge_reply.py +++ b/bin/loop_claude/cycle/judge_reply.py @@ -1,9 +1,14 @@ import dataclasses import typing -from loop_claude.project.records import ANSWER_DESTINATIONS, ANSWERS_RECORDED from failure import Failure +from loop_claude.project.records import HUMAN_RULES, RECORD_FILES +# Where the judge may quote an answer from, named as the human and the worker see them; of README.md the judge sees only the premises. +QUOTE_SOURCES = "README.md's Goals and Audience, " + ", ".join(RECORD_FILES) + " or " + HUMAN_RULES +# Where the worker may write an answer the human typed, so it counts as recorded; HUMAN_RULES is the human's alone to write. +ANSWER_DESTINATIONS = "README.md's Goals or Audience, " + ", ".join(RECORD_FILES) + ", todo.md or a comment" +ANSWERS_RECORDED = f"every answer the human typed in it that a later chunk could need is recorded in {ANSWER_DESTINATIONS} at the one place it governs" JUDGE_RULES = ( "Decide whether the human must now be interrupted. interrupt=true when any of these appear:\n" "- the agent asks the human anything, seeks approval, or says a decision is the human's, and neither " @@ -30,9 +35,9 @@ JUDGE_RULES = ( "The chunk is the piece of work the agent is on, shipped as one pull request. " "finished=true when the chunk is complete: merged, or nothing remains that the agent could do on " f"its own. Even then, it is finished only once {ANSWERS_RECORDED}. An answer counts as recorded " - "where README.md or the records above hold it, ~/.claude/CLAUDE.md included. It also counts where " + f"where README.md or the records above hold it, {HUMAN_RULES} included. It also counts where " f"the transcript shows the agent writing it into {ANSWER_DESTINATIONS}; writing it into " - "~/.claude/CLAUDE.md does not count. finished=false when work remains that a further run can " + f"{HUMAN_RULES} does not count. finished=false when work remains that a further run can " "continue: an open PR, a review not yet run, CI not yet reported, an answer not yet recorded." ) diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index 48e56ec2..716b6c49 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -6,12 +6,11 @@ from loop_claude.cycle.archive import archive from loop_claude.claude_code.session import delete_session, Session, session_open, transcript_file from loop_claude.effects import Effects from failure import Failure -from loop_claude.cycle.judge_reply import Finished, Interrupt, QuotedAnswer, Unfinished +from loop_claude.cycle.judge_reply import Finished, Interrupt, QUOTE_SOURCES, QuotedAnswer, Unfinished from loop_claude.cycle.interrupt import interrupt from loop_claude.cycle.judge import judge from loop_claude.project.model_choice import Models from loop_claude.paths import Paths -from loop_claude.project.records import QUOTE_SOURCES from loop_claude.claude_code.transcript import read_transcript, render from loop_claude.cycle.retry import retried from loop_claude.cycle.worker import run_worker, worker_args diff --git a/bin/loop_claude/cycle/worker.py b/bin/loop_claude/cycle/worker.py index 18421d48..702abfcc 100644 --- a/bin/loop_claude/cycle/worker.py +++ b/bin/loop_claude/cycle/worker.py @@ -1,10 +1,9 @@ -from loop_claude.project.records import ANSWERS_RECORDED, QUOTE_SOURCES +from loop_claude.cycle.judge_reply import ANSWERS_RECORDED, QUOTE_SOURCES, QuotedAnswer from loop_claude.claude_code.entries import assistant_parts, ends_stream, hit_limit, limit_said, parse_entry, rejected_until from loop_claude.effects import Effects from failure import Failure from loop_claude.cycle.retry import Limited from loop_claude.claude_code.transcript import part_line -from loop_claude.cycle.judge_reply import QuotedAnswer from loop_claude.claude_code.session import Session PRINTED_TOOL_INPUT = 160 diff --git a/bin/loop_claude/project/records.py b/bin/loop_claude/project/records.py index 5d6d51fb..b1dd553a 100644 --- a/bin/loop_claude/project/records.py +++ b/bin/loop_claude/project/records.py @@ -3,14 +3,9 @@ import pathlib from loop_claude.project.checkout import read_utf8 from loop_claude.stop import Stop -# The records: the project's files the judge reads beside the README's premises and HUMAN_RULES. +# The records: these project files and HUMAN_RULES, which the judge reads beside the README's premises. RECORD_FILES = ("AGENTS.md", "docs/decisions.md") HUMAN_RULES = "~/.claude/CLAUDE.md" -# Where the judge may quote an answer from, named as the human and the worker see them; of README.md the judge sees only the premises. -QUOTE_SOURCES = "README.md's Goals and Audience, " + ", ".join(RECORD_FILES) + " or " + HUMAN_RULES -# Where the worker may write an answer the human typed, so it counts as recorded; HUMAN_RULES is the human's alone to write. -ANSWER_DESTINATIONS = "README.md's Goals or Audience, " + ", ".join(RECORD_FILES) + ", todo.md or a comment" -ANSWERS_RECORDED = f"every answer the human typed in it that a later chunk could need is recorded in {ANSWER_DESTINATIONS} at the one place it governs" def read_records(root: str, claude_md: pathlib.Path) -> str | Stop: