diff --git a/AGENTS.md b/AGENTS.md index 9812f1f5..07ebf5e6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -28,4 +28,4 @@ Decisions live in `docs/decisions.md`: - loop-claude: the planned stats line goes in the transcript archive - workflow changes: a change merges only once three planned benches rule it better - chunk: as large as one purpose allows -- loop-claude: a cycle's state machine holds the paths that move it on, and a `Stop` leaves it +- loop-claude: a cycle's states cover only its progress, and a returned `Stop` ends the cycle diff --git a/bin/loop_claude/cycle/judge.py b/bin/loop_claude/cycle/judge.py index 52a6130a..acf07502 100644 --- a/bin/loop_claude/cycle/judge.py +++ b/bin/loop_claude/cycle/judge.py @@ -28,7 +28,6 @@ JUDGE_RULES = ( "not yet run, CI not yet reported." ) -# The reply's shape, which the schema below hands claude; verdict_from reads it into a Verdict. @dataclasses.dataclass(frozen=True) class Reply: evidence: str = dataclasses.field(metadata={"description": "A verbatim quote of the transcript line the verdict rests on: what triggers the interrupt, else what shows the chunk finished or the work remaining."}) diff --git a/bin/loop_claude/cycle/states.py b/bin/loop_claude/cycle/states.py index 8c316fcd..fe3443d0 100644 --- a/bin/loop_claude/cycle/states.py +++ b/bin/loop_claude/cycle/states.py @@ -5,7 +5,7 @@ from loop_claude.cycle.verdicts import Finished, Interrupt, Unfinished, Verdict @dataclasses.dataclass(frozen=True) class Working: - """The worker runs: opening the session, or resuming it while its transcript exists.""" + """The worker runs.""" @dataclasses.dataclass(frozen=True) @@ -26,7 +26,7 @@ class Finishing: @dataclasses.dataclass(frozen=True) class Ended: - """The cycle is over; the next one starts Working.""" + """The cycle is over.""" Active = Working | Judging | Interrupting | Finishing diff --git a/bin/loop_claude/cycle/steps.py b/bin/loop_claude/cycle/steps.py index 42d05ae8..c386395a 100644 --- a/bin/loop_claude/cycle/steps.py +++ b/bin/loop_claude/cycle/steps.py @@ -52,7 +52,7 @@ def step(cycle, state: Active) -> Event | Stop: def work(cycle) -> WorkerRan | Stop: - # Asked at each attempt: a failed one may have opened the session. + # 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)), cycle.effects), cycle.effects): return stop path = transcript_file(cycle.session) @@ -68,7 +68,7 @@ def rule(cycle, transcript_path) -> Ruled | Stop: def ask(cycle, transcript_path, question) -> Answered | Stop: - # The interrupt appends to this transcript, so it is archived at each question and judged anew after. + # The interrupt appends to this transcript, so it is archived at each question. if failure := archive(cycle.project, transcript_path, f"Task: {cycle.task}\n\nVerdict: interrupt\n\n{question}", cycle.paths): return Stop(1, failure.reason) return interrupt(cycle.root, cycle.session.id, cycle.models.worker, transcript_path, question, cycle.paths, cycle.effects) or Answered() @@ -82,5 +82,4 @@ def close(cycle, transcript_path) -> Archived | Stop: def session_open(session) -> bool: - """A run resumes the session only while its transcript exists.""" return bool(transcript_file(session)) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 6b3c8d81..52f932af 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -12,7 +12,7 @@ Cycles continue until an exit below or Ctrl-C. Words: ~/.claude/CLAUDE.md → "V Exit 1: no task, git cannot start or finds no checkout, no premises, a models file it cannot read or write, claude leaves no transcript or one it cannot read or archive, claude cannot start for an -interrupt, python cannot start for a reload, a reload with unreadable state, or the worker or the +interrupt, python cannot start for a reload, a reload whose loop run it cannot read, or 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 verdict misses or mistypes a field, interrupts without a question, diff --git a/docs/decisions.md b/docs/decisions.md index dc5b2926..34fcefc8 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -6,7 +6,7 @@ ## loop-claude: a judge decides interrupts, not the worker's self-report -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-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 also reads `docs/decisions.md` and `AGENTS.md`, so an answer recorded there is never asked again (goal 4.2); `todo.md`'s "Give the judge the project's recorded decisions" ends the README-only bar. Valid while the worker's self-report stays unreliable. ## loop-claude: one session per project, at a fixed id from its checkout's path @@ -30,7 +30,7 @@ ## comprehension floor: every dimension and the overall at 7.0 or above, and 0.1.0 waits on it -2026-09-27, lilleman, restating the 2026-09-24 target and extending it to the overall. Serves goal 4. The 2026-09-28 run, Junior A, Mid A, the maintainability senior and the inherited architect at depth 1 over every non-test file, blind to `todo.md` and this log, scored Navigation 7.25, Locality 6.0, Shape 6.5, Self-sufficiency 6.25, overall 6.25; on 2026-09-26 they were 7.75, 6.25, 7.0, 6.75, 6.75. Every seat scored Locality 6, and three of four named `run_cycle`'s three-way return and larv-review's re-entry rules, split across the passes on 2026-09-28. The same seats on `rebuild` scored 7.5, 6.63, 6.88, 6.5, 7.0 at 37edc9a, later that day, 7.5, 6.75, 6.88, 6.75, 7.0 at 7f9de5c, 7.38, 6.25, 6.88, 6.75, 6.88 at 2f9ab2f on 2026-09-29, Locality lowest again and every seat naming the reload state and the two retry counters, and 7.5, 7.0, 7.25, 6.75, 7.13 at 2c74bbc later that day, Self-sufficiency lowest and every seat naming the round's definition split across larv-review's two files, and 7.38, 6.75, 7.25, 6.5, 6.88 at 8585257 on 2026-10-01, lowering every dimension but Shape, and the overall, Self-sufficiency lowest and every seat naming larv-review §3's round rules; the places it named under Self-sufficiency and Locality are filed in `todo.md` under 0.1.0, and a later scoring run may not score any dimension or the overall below its best run on `rebuild`, 2026-10-01, lilleman. `rebuild` merged into main under the floor at 8585257's scores, 2026-10-01, lilleman. Valid until the next scoring run, which uses the same four seats. +2026-09-27, lilleman, restating the 2026-09-24 target and extending it to the overall. Serves goal 4. The 2026-09-28 run, Junior A, Mid A, the maintainability senior and the inherited architect at depth 1 over every non-test file, blind to `todo.md` and this log, scored Navigation 7.25, Locality 6.0, Shape 6.5, Self-sufficiency 6.25, overall 6.25; on 2026-09-26 they were 7.75, 6.25, 7.0, 6.75, 6.75. Every seat scored Locality 6, and three of four named `run_cycle`'s three-way return and larv-review's re-entry rules, split across the passes on 2026-09-28. The same seats on `rebuild` scored 7.5, 6.63, 6.88, 6.5, 7.0 at 37edc9a, later that day, 7.5, 6.75, 6.88, 6.75, 7.0 at 7f9de5c, 7.38, 6.25, 6.88, 6.75, 6.88 at 2f9ab2f on 2026-09-29, Locality lowest again and every seat naming the reload state and the two retry counters, and 7.5, 7.0, 7.25, 6.75, 7.13 at 2c74bbc later that day, Self-sufficiency lowest and every seat naming the round's definition split across larv-review's two files, and 7.38, 6.75, 7.25, 6.5, 6.88 at 8585257 on 2026-10-01, lowering every dimension but Shape, and the overall, Self-sufficiency lowest and every seat naming larv-review §3's round rules; the places it named under Self-sufficiency and Locality are filed in `todo.md` under 0.1.0, and a later scoring run may not score any dimension or the overall below its best run on `rebuild`, 2026-10-01, lilleman. `rebuild` merged into main under the floor at 8585257's scores, 2026-10-01, lilleman. The 2026-10-01 run on main at the loop state machine's PR scored 7.5, 6.5, 6.88, 6.25, 6.38; lilleman shipped that PR under the floor the same day, its places filed in `todo.md` under 0.1.0. Valid until the next scoring run, which uses the same four seats. ## vocabulary: the concept words are defined under `CLAUDE.md` → "Vocabulary" and cited by a bare link @@ -104,6 +104,6 @@ 2026-10-01, lilleman. Serves goal 4.4. Every review has a fixed cost: each reviewer reloads the rules and the files around the change. Purpose caps a chunk, never a line count. Tiny items are the exception: up to ten, a few lines each, share one chunk whatever their purposes and passes, since the review's fixed cost dwarfs them. Valid until the stats or a bench show that larger chunks lower what reviews catch. -## loop-claude: a cycle's state machine holds the paths that move it on, and a `Stop` leaves it +## loop-claude: a cycle's states cover only its progress, and a returned `Stop` ends the cycle -2026-10-01, larv-review. Applies "Always use explicit state machines". A `Stop` ends the process, so no later state could act on it; a `Stopped` state would add a case every step must pass through and nothing would read. Valid while every failure of a cycle ends the loop. +2026-10-01, larv-review. Applies "Always use explicit state machines". A `Stop` ends the process, so no later state could act on it. A `Stopped` state would add an event and a transition that nothing reads. Valid until a cycle must act after a `Stop`, as `todo.md`'s "Archive the transcript as each cycle ends" would. diff --git a/todo.md b/todo.md index 7f8875f2..4f663bf0 100644 --- a/todo.md +++ b/todo.md @@ -4,16 +4,17 @@ The rebuild's design sketches, the blind judges' verdicts on them and what to take from each: `~/code/claude-handoffs/claude-config_2026-09-28.md`. -The first two items are the places the panel on `rebuild` at 8585257 named under Self-sufficiency and Locality, the dimensions under the floor (scores: `docs/decisions.md` → "comprehension floor"). +The first six items are the places the panels on `rebuild` at 8585257 and on main on 2026-10-01 named under Self-sufficiency and Locality, the dimensions under the floor (scores: `docs/decisions.md` → "comprehension floor"). - **Split `written_by_human`'s boolean into one named check per entry shape.** `formats.py:42` packs three tests into one line, one seat learnt the cases only from `HumanTurns` in the tests, and another could not confirm them without `HumanTurns`. Three seats named it the unit they least wanted to modify, and the architect named it where the project rots first. - **Annotate the parameter types in `bin/loop_claude/`.** Whether `root` or `path` is a `str` or a `Path` is learnt by tracing callers back to `bin/loop-claude`. -- **Make a failed session delete stop the loop, and give the session one owner.** `delete_session` (`session.py:32`) only prints a failed removal, so `close` reports `Archived` and the next chunk resumes the finished chunk's session without its own task prompt. Return a `Failure` and stop on it; move `session_open` into `session.py`; have `transcript_file` return `str | None`. Raised by the 2026-10-01 panel's inherited architect and the logging and technical-principles audits. Goal 4.1. +- **Make a failed session delete stop the loop, and give the session one owner.** `delete_session` (`session.py:32`) only prints a failed removal, so `close` reports `Archived` and the next chunk resumes the finished chunk's session without its own task prompt. Return a `Failure` and stop on it; move `session_open` into `session.py`; have `transcript_file` return `str | None`. Goal 4.1. - **Give larv-review §3's rules one home per rule.** Every seat of the 2026-10-01 panel needed `SKILL.md`, `review-findings.md` and `CLAUDE.md` open to apply one rule of "Round cap" or "Re-entry". Goal 4.1. -- **Name `loop_claude`'s modules by what they hold.** The 2026-10-01 panel misread `formats.py` (it holds every Claude Code shape, `mark_trusted` and `models_in` included), `steps.py`, `outcome.py` and `human_needed.py`. "Project", "transcripts", "verdict" and "model" each name two or three things. Goal 4.1. +- **Name `loop_claude`'s modules and words by what each holds.** The 2026-10-01 panel misread `formats.py` (it holds every Claude Code shape, `mark_trusted` and `models_in` included), `steps.py`, `outcome.py` and `human_needed.py`. "Project", "transcripts", "verdict" and "model" each name two or three things. Goal 4.1. - **State in `reload.py` why a loop reloads its own script, and tie each exit-1 clause of `--help` to the `Stop` that produces it.** Two seats found the reload's purpose nowhere in the code, and one could keep the exit contract true only by grepping every `Stop(1`. Goal 4.1. -- **Archive the transcript as each cycle ends.** Today only an interrupt or a finished chunk archives it, so a failed exit or Ctrl-C loses the transcript. Goal 2. -- **Key a project on its checkout's full path, and refuse to start while another session uses that key.** The key names the project's session, archive folder and models entry. `checkout.py:28` drops the leading `/`, so `~/code/a` and `/a` share all three, and one loop can resume or delete the other's session. Goal 4.1. +- **Give the judge the project's recorded decisions, and ask it whether anything the project records settles a choice.** Today it reads only the README's Goals and Audience (`premises.py`) and cannot see an answer recorded in `docs/decisions.md` or `AGENTS.md`, so it can interrupt the human again for a question already answered. Revise the decision "a judge decides interrupts, not the worker's self-report" to match. Goal 4.2. +- **Archive the transcript as each cycle ends.** Today only an interrupt or a finished chunk archives it, so after a failed exit or Ctrl-C the transcript stays unarchived until the chunk finishes, and is never archived if it does not. Goal 2. +- **Key a project on its checkout's full path, and refuse to start while another session uses that key.** The key names the project's session, archive folder and models entry. `project_name` drops the leading `/`, so `~/code/a` and `/a` share all three, and one loop can resume or delete the other's session. Goal 4.1. - **Give principles-auditor and prose-reviewer a way to list the project's files.** In the 2026-09-30 audit run their `tools: Read, Grep, Glob` gave them only Read. Each read the files that imports and `.gitignore` named, and listed the files it could not reach. Goal 4.1. - **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** Claude Code owns that file and writes it. `trust` reads it, changes it and writes it back, so a write that lands in between is lost. Goal 4.1. - **Make the small changes filed against the review's rules.** Goals 4.1 and 4.4. @@ -48,7 +49,7 @@ The first two items are the places the panel on `rebuild` at 8585257 named under - **Rewrite `statusline.sh` in Python, and test it.** It needs `jq` and GNU `date` on every machine, `eval`s jq output, has three near-identical usage blocks and no test. Goal 1. - **Move what the plan and the decision log point at under `~/code/claude-handoffs/` into the repo.** The design sketches, the judges' verdicts and the bench scripts are unreachable from another machine's checkout. Goal 1. - **Say in `systems-architect.md` that a REST API's `/v1/` prefix is not versioning machinery to defer.** Its "defer the versioning story" can be read against `principles/rest-apis.md`, which requires the prefix from the start. Goal 4.3. -- **Judge a cycle on more than the transcript's last 40,000 characters.** `judge.py:82` cuts the transcript there. The session spans every cycle of the chunk, so a decision made early in a long run is never judged, and the human is not interrupted for it. Larger chunks make runs longer. Goal 4.2. +- **Judge a cycle on more than the transcript's last 40,000 characters.** `judge_prompt` cuts the transcript there. The session spans every cycle of the chunk, so a decision made early in a long run is never judged, and the human is not interrupted for it. Larger chunks make runs longer. Goal 4.2. - **Record each finished chunk's cost and review numbers on one stats line.** Goal 4.4. - Have `loop-claude` write the line to one file at the root of the transcript archive. The line names the project, the commit the chunk started from and the archived transcript's hash. It holds the worker's tokens from the transcript, the judge's from its JSON output, and the chunk's cycles and interrupts, which the loop counts. - End larv-review with a machine-readable summary, and have `loop-claude` copy it from the transcript onto the line: agents launched and rounds per pass; findings per pass by severity, inside the chunk's diff and outside it; and the comprehension scores when the panel ran.