From 0eb97e9e88f489558b48d9ac65343329c6659646 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 01:49:33 +0200 Subject: [PATCH] Answer the prose pass: name README.md beside the records, one idea per sentence in --help and the judge's rules, date the decision's revision --- AGENTS.md | 2 +- CHANGELOG.md | 4 ++-- CLAUDE.md | 2 +- bin/loop_claude/cycle/judge.py | 10 +++++----- bin/loop_claude/cycle/run.py | 2 +- bin/loop_claude/cycle/states.py | 8 ++++---- bin/loop_claude/loop/main.py | 26 +++++++++++++------------- bin/test_loop_claude.py | 9 ++++----- docs/decisions.md | 6 ++++-- 9 files changed, 35 insertions(+), 34 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 52e5174b..8c449c13 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,7 +3,7 @@ Decisions live in `docs/decisions.md`: - larv-review: a project under the comprehension floor is fixed at the capping dimension -- loop-claude: a judge decides each interrupt from the transcript, the README's premises and the project's records; the worker's own account of which goal settles a choice decides nothing +- loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md` and `docs/decisions.md`; the worker's own account of which goal settles a choice decides nothing - loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it - loop-claude: before an interrupt, it marks the checkout and each of its worktrees trusted in `~/.claude.json` - bin/: the tests rerun themselves on a `uv`-fetched Python at README Install's floor diff --git a/CHANGELOG.md b/CHANGELOG.md index 597fa3c3..a2026dd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,8 @@ ## Unreleased - Unless another Exempt reason fits, larv-review marks a `todo.md` item filed from a 🟡 finding against `~/.claude/principles/` with `principle`, an Exempt reason that keeps it whatever its score. -- `loop-claude`'s judge reads the project's `AGENTS.md` and `docs/decisions.md` beside the README's goals and audience, and does not interrupt for a choice they settle. When the worker asks a question they answer, the worker resumes with the judge's quote of the answer, which `loop-claude` prints, up to three times a cycle; a question asked again after its answer goes to you, and a fourth goes to you with the quote. A quote the records do not hold word for word is dropped, and the question goes to you. The judge reads as much of the transcript's end as fits a 400,000-character prompt, up from the last 40,000 characters. `loop-claude` exits 1 when `AGENTS.md` or `docs/decisions.md` cannot be read or is not UTF-8. -- A project's decision log is `docs/decisions.md` alone, the one file the judge, `rank_todo.py` and the reviewers read; `CLAUDE.md` no longer allows splitting it into `docs/decisions/`. +- `loop-claude`'s judge reads the project's `AGENTS.md` and `docs/decisions.md` beside the README's goals and audience, and does not interrupt for a choice they settle. When the worker asks a question that the README or those files answer, the worker resumes with the judge's quote of the answer, which `loop-claude` prints. A quote they do not hold word for word is dropped, and the question goes to you. So does a question asked again after its answer, and the fourth question they answer in one cycle, with the quote. The judge reads as much of the transcript's end as fits a 400,000-character prompt, up from the last 40,000 characters. `loop-claude` exits 1 when `AGENTS.md` or `docs/decisions.md` cannot be read or is not UTF-8. +- A project's decision log is `docs/decisions.md` alone, the one file the judge, `rank_todo.py` and the reviewers read. - `loop-claude` waits out a usage limit and retries: 2 minutes past the reset, or every 10 minutes when the reset time is unknown. A limit is not a failure, and restarts the count of three failures in a row. It prints what claude said about the limit and when the next try is due. - Add the official plugin marketplace and install every plugin `settings.json` enables (README → Install): `claude-security`, `code-review` and `rust-analyzer-lsp`, which needs `rust-analyzer` on `PATH` for Rust projects. With `claude-security`, larv-review's full security scan runs once you confirm its cost; an unattended larv-review reports the scan as not run. `settings.json` silences the plugin's scan tip after `git push`. - systems-architect and product-owner-reviewer can no longer edit what they review; stability-reviewer keeps its shell to run tests, and loses Claude Code's file-editing tools. diff --git a/CLAUDE.md b/CLAUDE.md index fb771bd5..47a333e9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -151,7 +151,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 verdicts on them, with any interrupts, and any answers the judge quoted from the project's records, in between, until the chunk closes or continues next cycle. +- **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`. - **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.py b/bin/loop_claude/cycle/judge.py index 2d3f02af..c1fd0a12 100644 --- a/bin/loop_claude/cycle/judge.py +++ b/bin/loop_claude/cycle/judge.py @@ -14,8 +14,8 @@ from loop_claude.stop import Stop JUDGE_PROMPT_CHARS = 400000 JUDGE_RULES = ( - "Decide whether the agent has something open that the human, or README.md and the project's records, " - "must answer. interrupt=true when any of these appear:\n" + "Decide whether the agent has something open that the human must answer, or that README.md or the " + "project's records answer. interrupt=true when any of these appear:\n" "- the agent asks the human anything, seeks approval, or says a decision is the human's\n" "- it carried on under an assumption that decides the deliverable, that the human could " "reasonably reject and that neither README.md nor the project's records settle; a caveat about " @@ -28,12 +28,12 @@ JUDGE_RULES = ( "interrupt=false otherwise. Bookkeeping the agent settled silently - what to document, wording, " "where a note goes - is not on its own a reason to interrupt. The human may have replied inside the transcript, on a [human] line: judge only what " "is still open, never a question they already answered there. A [loop] line is what loop-claude told " - "the agent, such as an answer quoted from README.md or the project's records; a question it answered " - "is no longer open, unless the agent asks it again: then it is the human's, with answer empty.\n" + "the agent, such as an answer quoted from README.md or the project's records. A question a [loop] " + "line answered is no longer open. If the agent asks it again, put it to the human, with answer empty.\n" "Where the agent asked or flagged something itself, the question is that one, in the agent's own " "wording; never construct another from facts it stated.\n" "Where README.md or the project's records answer that question, quote the passage that answers it " - "in answer, verbatim; the agent is then given that passage in place of the human's reply.\n" + "in answer, verbatim, with interrupt=true; the agent is then given that passage in place of the human's reply.\n" "finished=true when the chunk is complete: merged, or nothing remains that the agent could do on " "its own. finished=false when work remains that a further run can continue: an open PR, a review " "not yet run, CI not yet reported." diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index 0c8d63e6..d2a49450 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -66,7 +66,7 @@ def step(cycle: Cycle, state: Active) -> Event | Stop: def work(cycle: Cycle, answered: AnsweredFromRecords | None) -> WorkerRan | Stop: if answered is not None: - print(f"\n=== the records answered: {answered.question} ===\n{answered.answer}", flush=True) + print(f"\n=== README.md or the records answered: {answered.question} ===\n{answered.answer}", flush=True) # session_open runs inside the lambda: a failed attempt may have opened the session. if stop := retried("worker", lambda: run_worker(cycle.root, worker_args(cycle.task, cycle.session, cycle.models.worker, session_open(cycle.session), answered), cycle.effects), cycle.effects): return stop diff --git a/bin/loop_claude/cycle/states.py b/bin/loop_claude/cycle/states.py index e0417c58..d0d60729 100644 --- a/bin/loop_claude/cycle/states.py +++ b/bin/loop_claude/cycle/states.py @@ -2,20 +2,20 @@ import dataclasses from loop_claude.cycle.verdicts import AnsweredFromRecords, Finished, Interrupt, Unfinished, Verdict -# A backstop for what the judge misses, such as a reworded repeat, so the worker cannot loop unattended on the records' answers. +# A backstop for what the judge misses, such as a reworded repeat, so the worker cannot loop unattended on answers quoted from README.md or the records. RECORDS_ANSWERS_PER_CYCLE = 3 @dataclasses.dataclass(frozen=True) class Working: - """The worker runs, resumed with the records' answer when there is one.""" + """The worker runs, resumed with an answer quoted from README.md or the records when there is one.""" answered: AnsweredFromRecords | None = None records_answers: int = 0 @dataclasses.dataclass(frozen=True) class Judging: - """The judge rules; records_answers counts the questions the records answered this cycle.""" + """The judge rules; records_answers counts the questions README.md or the records answered this cycle.""" transcript_path: str records_answers: int = 0 @@ -72,7 +72,7 @@ def transition(state: State, event: Event) -> State: case Judging(_, records_answers), Ruled(AnsweredFromRecords() as answered) if records_answers < RECORDS_ANSWERS_PER_CYCLE: return Working(answered, records_answers + 1) case Judging(transcript_path, records_answers), Ruled(AnsweredFromRecords(question=question, answer=answer)): - return Interrupting(transcript_path, f"{question}\n\nREADME.md or the project's records say:\n{answer}\n\nThe records answered {records_answers} questions this cycle, so this one comes to you.", records_answers) + return Interrupting(transcript_path, f"{question}\n\nREADME.md or the project's records say:\n{answer}\n\nREADME.md or the records answered {records_answers} questions this cycle, so this one comes to you.", records_answers) case Judging(transcript_path, records_answers), Ruled(Interrupt(question=question)): return Interrupting(transcript_path, question, records_answers) case Judging(transcript_path, _), Ruled(Finished() | Unfinished() as verdict): diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 1d13fdd5..afa8a7a2 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -3,13 +3,14 @@ usage: loop-claude Run it anywhere inside a project checkout whose README.md has ## Goals and ## Audience, the -premises; the task runs at the checkout root. Each cycle a worker runs the task; a judge then reads -as much of the transcript's end as fits a 400,000-character prompt against the premises and the -project's records, AGENTS.md and docs/decisions.md where they exist, and rules whether the chunk, -the work of one PR, is finished. A choice the worker made that the premises or the records settle is -not asked about. When the worker asks a question they answer, the judge quotes the answer, printed -on stdout, and the worker resumes with it, up to three times a cycle; a question asked again after -its answer goes to the human, and a fourth with the quote. +premises; the task runs at the checkout root. Each cycle a worker runs the task. A judge then reads +the transcript's end, the premises, and the project's records: AGENTS.md and docs/decisions.md, +where they exist. It rules whether the chunk, the work of one PR, is finished. A choice the worker +made that the premises or the records settle is not asked about. When the worker asks a question +they answer, the judge quotes the answer, loop-claude prints it, and the worker resumes with it. A +quote they do not hold word for word is dropped, and the question goes to the human. So does a +question asked again after its answer, and the fourth question they answer in one cycle, with the +quote. A question only the human can answer, or a release ready to cut, is an interrupt: `claude --resume` on the terminal, every worktree first marked trusted in ~/.claude.json. An unfinished chunk resumes its session next cycle; the next chunk starts a fresh session. @@ -51,12 +52,11 @@ Exit 1, saying why, when: - the worker or the judge fails three times running, retried a minute apart within the cycle. A worker fails when claude cannot start, exits non-zero, is killed, or ends without a result event; a judge when claude cannot start or exits non-zero, or its reply misses or mistypes a field, - interrupts without a question, or quotes a line the transcript does not hold; an answer it quotes - that the premises and the records do not hold is dropped, and the question goes to the human. A - usage limit is not a failure, and restarts the count of three: the worker or the judge is retried - 2 minutes after the limit resets, or every 10 minutes when the reset time is unknown or more than - 2 minutes past. The judge's reply gives its reset time only as text, so the judge is always - retried every 10 minutes. stderr says when the next try is due. + interrupts without a question, or quotes a line the transcript does not hold. A usage limit is not + a failure, and restarts the count of three: the worker or the judge is retried 2 minutes after the + limit resets, or every 10 minutes when the reset time is unknown or more than 2 minutes past. The + judge's reply gives its reset time only as text, so the judge is always retried every 10 minutes. + stderr says when the next try is due. Exit 2, when the human is needed and cannot answer: - stdin or stdout is not a terminal, when a model must be picked or an interrupt answered diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 999afe79..c5c0a0c2 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -135,7 +135,7 @@ class Transitions(unittest.TestCase): (states.Judging("/t", 3), states.Ruled(Interrupt("e", "Which one?")), states.Interrupting("/t", "Which one?", 3)), (states.Judging("/t"), answered, states.Working(AnsweredFromRecords("e", "Which one?", "A."), 1)), (states.Judging("/t", 2), answered, states.Working(AnsweredFromRecords("e", "Which one?", "A."), 3)), - (states.Judging("/t", 3), answered, states.Interrupting("/t", "Which one?\n\nREADME.md or the project's records say:\nA.\n\nThe records answered 3 questions this cycle, so this one comes to you.", 3)), + (states.Judging("/t", 3), answered, states.Interrupting("/t", "Which one?\n\nREADME.md or the project's records say:\nA.\n\nREADME.md or the records answered 3 questions this cycle, so this one comes to you.", 3)), (states.Judging("/t"), states.Ruled(Finished("e")), states.Closing("/t", Finished("e"))), (states.Judging("/t", 3), states.Ruled(Finished("e")), states.Closing("/t", Finished("e"))), (states.Judging("/t"), states.Ruled(Unfinished("e")), states.Closing("/t", Unfinished("e"))), @@ -252,8 +252,8 @@ class Cycles(unittest.TestCase): resumed = fake.made("stream_claude")[1] self.assertEqual(resumed[resumed.index("-p") + 1], "Your question: Which one?\n\nREADME.md or the project's records answer it:\n\nUse *A*.\n\nContinue the task.") self.assertEqual(len(fake.made("stream_claude")), 4) - self.assertEqual(printed.getvalue().count("=== the records answered: Which one? ===\nUse *A*."), 3) - self.assertIn("Which one?\n\nREADME.md or the project's records say:\nUse *A*.\n\nThe records answered 3 questions this cycle", said.getvalue()) + self.assertEqual(printed.getvalue().count("=== README.md or the records answered: Which one? ===\nUse *A*."), 3) + self.assertIn("Which one?\n\nREADME.md or the project's records say:\nUse *A*.\n\nREADME.md or the records answered 3 questions this cycle", said.getvalue()) def test_an_answer_the_records_do_not_hold_is_dropped_and_the_question_goes_to_the_human(self): fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("interrupt", answer="Use B.")], on_terminal_claude=[0], git=[ran()]) @@ -534,8 +534,7 @@ class LoopRuns(unittest.TestCase): class HelpLimits(unittest.TestCase): def test_help_states_the_limits_the_code_holds(self): - self.assertIn(f"a {judge.JUDGE_PROMPT_CHARS:,}-character prompt", main.__doc__) - self.assertIn(f"up to {['one', 'two', 'three', 'four'][states.RECORDS_ANSWERS_PER_CYCLE - 1]} times a cycle", main.__doc__) + self.assertIn(f"the {['second', 'third', 'fourth', 'fifth'][states.RECORDS_ANSWERS_PER_CYCLE - 1]} question they answer in one cycle", main.__doc__.replace("\n", " ")) class ExitContract(unittest.TestCase): diff --git a/docs/decisions.md b/docs/decisions.md index 16ea9c1a..7eafd6b7 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -4,9 +4,11 @@ 2026-09-20, lilleman. Serves goal 4. Across six projects scored with the four seats, Locality or Self-sufficiency capped every seat and Navigation capped none, so a layout fix would not lift a project under the floor. Valid while the scoring run keeps those four seats. -## loop-claude: a judge decides each interrupt from the transcript, the README's premises and the project's records; the worker's own account of which goal settles a choice decides nothing +## loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md` and `docs/decisions.md`; the worker's own account of which goal settles a choice decides nothing -2026-09-21, lilleman. Serves goal 4. Asked to name the goal behind each choice, the worker cites a real goal for a choice that goal does not settle, and under-reports its own decisions; the judge's bar is whether the README discriminates between the alternatives. On 2026-10-01 lilleman decided the judge is to read `docs/decisions.md` and `AGENTS.md` too, so an answer recorded there is not asked again (goal 4.2). A question the worker asks that the records answer is answered by the judge's verbatim quote of them, which the judge then sees as a `[loop]` line; the worker asking it again shows the record did not settle it, and the judge sends it to the human. A backstop of three records answers per cycle bounds what the judge misses, such as a reworded repeat or a worker asking without end, so it cannot loop unattended (goal 4.4); a fourth goes to the human with the judge's quote, so the cost is one interrupt. Valid while the worker's self-report stays unreliable. +2026-09-21, lilleman. Serves goal 4. Asked to name the goal behind each choice, the worker cites a real goal for a choice that goal does not settle, and under-reports its own decisions; the judge's bar is whether the README discriminates between the alternatives. Valid while the worker's self-report stays unreliable. + +2026-10-01, lilleman: the judge reads `docs/decisions.md` and `AGENTS.md` too, so an answer recorded there is not asked again (goal 4.2); its bar becomes whether the README or those files discriminate. 2026-10-03, implemented: a question the worker asks that they answer is answered by the judge's verbatim quote, which the judge then sees as a `[loop]` line. The worker asking it again shows the quote did not settle it, and the judge sends it to the human. A backstop of three quoted answers per cycle bounds what the judge misses, such as a reworded repeat or a worker asking without end, so the worker cannot loop unattended (goal 4.4); the fourth question they answer in one cycle goes to the human with the judge's quote, so the cost is one interrupt. ## loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it