From 6bd150c820ef3ed62a9ce7d2770f92695369c71e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 09:11:11 +0200 Subject: [PATCH] Answer the architecture pass's second round --- bin/loop_claude/stop.py | 3 ++- bin/test_loop_claude.py | 57 ++++++++++++++++++++--------------------- docs/decisions.md | 2 +- todo.md | 14 +++------- 4 files changed, 34 insertions(+), 42 deletions(-) diff --git a/bin/loop_claude/stop.py b/bin/loop_claude/stop.py index a8ae0e05..44be1929 100644 --- a/bin/loop_claude/stop.py +++ b/bin/loop_claude/stop.py @@ -1,10 +1,11 @@ import dataclasses +import typing @dataclasses.dataclass(frozen=True) class Stop: """loop-claude exits with code, printing reason.""" - code: int + code: typing.Literal[0, 1, 2, 130] reason: str diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index de30a426..0eb9a1ff 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -370,52 +370,51 @@ class ExitContract(unittest.TestCase): def test_every_exit_1_stop_has_its_clause_in_help(self): read, git, premises_ = "a transcript cannot be read or archived", "git cannot start or finds no checkout", "README.md holds no premises" models_ = "the models file cannot be read or written" - # Each Stop with an exit code other than 0, 2 or 130, in source order, by the start of its reason, with its --help clause. + # Each Stop with an exit code other than 0, 2 or 130, in source order, by its code and the start of its reason, with its --help clause. clauses = [ - ("cycle/interrupt.py", "interrupt", "entries.reason", read), - ("cycle/interrupt.py", "interrupt", "f'could not start claude for the interrupt:", "claude cannot start for an interrupt"), - ("cycle/interrupt.py", "interrupt", "f'could not tell whether you typed anything:", read), - ("cycle/retry.py", "retried", "f'the {who} failed three times running:", "the worker or the judge fails three times running"), - ("cycle/run.py", "work", "f'claude left no transcript for session", "claude leaves no transcript"), - ("cycle/run.py", "rule", "entries.reason", read), - ("cycle/run.py", "ask", "failure.reason", read), - ("cycle/run.py", "close", "failure.reason", read), - ("cycle/run.py", "close", "failure.reason", "a finished chunk's session cannot be deleted"), - ("loop/main.py", "loop_run_from", "__doc__.strip()", "no task is given"), - ("loop/main.py", "loop_run_from", "f'the reload cannot read the cycle number,", "a reload cannot read the cycle number, checkout root and task"), - ("loop/reload.py", "exec_if_edited", "f'could not reload loop-claude:", "python cannot start for a reload"), - ("project/checkout.py", "checkout_root", "f'could not start git:", git), - ("project/checkout.py", "checkout_root", "found.stderr.strip()", git), - ("project/model_choice.py", "get_or_ask_model", "f'could not save the model in", models_), - ("project/model_choice.py", "read_models_file", 'f"could not read {saved}: {getattr(', models_), - ("project/model_choice.py", "read_models_file", "f'could not read {saved}: not an object", models_), - ("project/premises.py", "read_premises", "f'README.md in {root}:", premises_), - ("project/premises.py", "read_premises", "f'README.md is not UTF-8", premises_), - ("project/premises.py", "read_premises", "f'README.md has no ##", premises_), - ("project/premises.py", "read_premises", "f'README.md has ## {name} more than once", premises_), - ("project/premises.py", "read_premises", "f'README.md has nothing under", premises_), + ("cycle/interrupt.py", "interrupt", "1", "entries.reason", read), + ("cycle/interrupt.py", "interrupt", "1", "f'could not start claude for the interrupt:", "claude cannot start for an interrupt"), + ("cycle/interrupt.py", "interrupt", "1", "f'could not tell whether you typed anything:", read), + ("cycle/retry.py", "retried", "1", "f'the {who} failed three times running:", "the worker or the judge fails three times running"), + ("cycle/run.py", "work", "1", "f'claude left no transcript for session", "claude leaves no transcript"), + ("cycle/run.py", "rule", "1", "entries.reason", read), + ("cycle/run.py", "ask", "1", "failure.reason", read), + ("cycle/run.py", "close", "1", "failure.reason", read), + ("cycle/run.py", "close", "1", "failure.reason", "a finished chunk's session cannot be deleted"), + ("loop/main.py", "loop_run_from", "0 if task else 1", "__doc__.strip()", "no task is given"), + ("loop/main.py", "loop_run_from", "1", "f'the reload cannot read the cycle number,", "a reload cannot read the cycle number, checkout root and task"), + ("loop/reload.py", "exec_if_edited", "1", "f'could not reload loop-claude:", "python cannot start for a reload"), + ("project/checkout.py", "checkout_root", "1", "f'could not start git:", git), + ("project/checkout.py", "checkout_root", "1", "found.stderr.strip()", git), + ("project/model_choice.py", "get_or_ask_model", "1", "f'could not save the model in", models_), + ("project/model_choice.py", "read_models_file", "1", 'f"could not read {saved}: {getattr(', models_), + ("project/model_choice.py", "read_models_file", "1", "f'could not read {saved}: not an object", models_), + ("project/premises.py", "read_premises", "1", "f'README.md in {root}:", premises_), + ("project/premises.py", "read_premises", "1", "f'README.md is not UTF-8", premises_), + ("project/premises.py", "read_premises", "1", "f'README.md has no ##", premises_), + ("project/premises.py", "read_premises", "1", "f'README.md has ## {name} more than once", premises_), + ("project/premises.py", "read_premises", "1", "f'README.md has nothing under", premises_), ] root = pathlib.Path(main.__file__).parents[1] found = [] for path in sorted(root.rglob("*.py")): functions = [node for node in ast.walk(ast.parse(path.read_text())) if isinstance(node, ast.FunctionDef)] - stops = [(call.lineno, function.name, ast.unparse(call.args[1])) for function in functions for call in ast.walk(function) if isinstance(call, ast.Call) and getattr(call.func, "id", None) == "Stop" and not (isinstance(call.args[0], ast.Constant) and call.args[0].value in (0, 2, 130))] - found += [(str(path.relative_to(root)), function, reason) for _, function, reason in sorted(stops)] + stops = [(call.lineno, function.name, ast.unparse(call.args[0]), ast.unparse(call.args[1])) for function in functions for call in ast.walk(function) if isinstance(call, ast.Call) and getattr(call.func, "id", None) == "Stop" and not (isinstance(call.args[0], ast.Constant) and call.args[0].value in (0, 2, 130))] + found += [(str(path.relative_to(root)), function, code, reason) for _, function, code, reason in sorted(stops)] self.assertEqual(len(found), len(clauses), found) - for (path, function, reason), (want_path, want_function, reason_start, _) in zip(found, clauses): - self.assertEqual((path, function), (want_path, want_function)) + for (path, function, code, reason), (want_path, want_function, want_code, reason_start, _) in zip(found, clauses): + self.assertEqual((path, function, code), (want_path, want_function, want_code)) self.assertTrue(reason.startswith(reason_start), f"{path} {function}: {reason}") help_exit_1 = main.__doc__[main.__doc__.index("Exit 1"):main.__doc__.index("Exit 2")] self.assertEqual([clause for *_, clause in clauses if f"- {clause}" not in help_exit_1], []) -class Checkouts(unittest.TestCase): +class Worktrees(unittest.TestCase): def test_lists_the_root_alone_when_git_cannot_start(self): fake = FakeEffects(git=[FileNotFoundError(2, "No such file or directory")]) self.assertEqual(checkout.worktrees("/r", fake.effects()), ["/r"]) - class ReplaceFile(unittest.TestCase): def test_removes_what_it_staged_when_the_replace_fails(self): with tempfile.TemporaryDirectory() as root: diff --git a/docs/decisions.md b/docs/decisions.md index 766f486e..d678debe 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -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. The 2026-10-01 run on PR #182 (the loop state machine) scored 7.5, 6.5, 6.88, 6.25, 6.38; lilleman shipped that PR under the floor and below `rebuild`'s best run the same day, its places filed in `todo.md` under 0.1.0. The 2026-10-02 run on PR #187 (`loop_claude`'s names, the exit contract) scored 7.75, 7.25, 7.38, 6.88, 7.25 at 70362d0, the best run on every dimension and the overall, every seat naming larv-review §3 under Self-sufficiency; lilleman shipped it under the floor the same day, its place filed in `todo.md` under 0.1.0. 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 PR #182 (the loop state machine) scored 7.5, 6.5, 6.88, 6.25, 6.38; lilleman shipped that PR under the floor and below `rebuild`'s best run the same day, its places filed in `todo.md` under 0.1.0. The 2026-10-02 run on PR #187 (`loop_claude`'s names, the exit contract) scored 7.75, 7.25, 7.38, 6.88, 7.25 at 70362d0, every seat naming larv-review §3 under Self-sufficiency, and 7.63, 7.13, 7.38, 7.0, 7.13 at 1971dba later that day, the first run at the floor, with no dimension or the overall below its best run on `rebuild`. Valid until the next scoring run, which uses the same four seats. ## loop-claude: each project's model lives in `~/.claude/loop-claude-models.json`, which only loop-claude writes diff --git a/todo.md b/todo.md index c8876173..00a82e11 100644 --- a/todo.md +++ b/todo.md @@ -2,14 +2,6 @@ ## 0.1.0 -### Under the comprehension floor - -The 2026-10-02 panel on PR #187 named this under Self-sufficiency, the one dimension under the floor. Scores: `docs/decisions.md` → "comprehension floor". - -- **Make larv-review §3 readable without another file open.** Applying one rule of "Round cap", "Re-entry" or "Findings" takes `review-findings.md`, `CLAUDE.md` → "Vocabulary" and the decision log open beside it. The rules cite each other by number ("Round cap" rule 6), so a renumbering breaks a citation silently. Nothing says where a pass's round count is recorded, so a resumed or compacted session loses it. Goal 4.1. - -### The rest - - **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_key` 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. @@ -27,7 +19,7 @@ The 2026-10-02 panel on PR #187 named this under Self-sufficiency, the one dimen - Prefix each diagnostic `loop-claude` prints with its level, `warning:` at the least, so a run's output can be grepped for what needs fixing. - Have `make_private` return a `Failure` like `replace_file` beside it. - Check the catalog `name` in `newest_catalog_models` as well as `id`. - - Sort `worker_args`' flags and the globs in `catalog.py` and `session.py`. + - Sort `worker_args`' flags and the globs in `model_catalog.py` and `session.py`. - Write `"bypassPermissions"` once for every claude `loop-claude` starts. - Keep the judge's evidence and model in each archived `.verdict.md`. - Move the test helpers `ROOT` and `readme_floor` out of `test_python_floor.py`, which two other tests import them from, and have `test_citations.py` use that `ROOT`. @@ -41,7 +33,7 @@ The 2026-10-02 panel on PR #187 named this under Self-sufficiency, the one dimen - **Give each cycle phase one name across its state, step and event.** Today `Judging` runs `rule` and yields `Ruled`, and `Finishing` runs `close`, which also deletes the session, and yields `Archived`. Goal 4.1. - **Copy the transcript archive off the machine, or say in README how it is backed up.** It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost disk loses every unattended run's record. Goal 2. - **Inject output and storage into `Effects`, and test what each step prints.** `print` and `open` are called directly across `bin/loop_claude/`, so the stderr lines of the CLI contract can be checked only through the black-box tests. Goal 4.1. -- **Read transcript and stream entries into typed values where they are read.** `transcript.read` and `run_worker` pass raw `dict`s, so about ten accessors in `entries.py` re-check shapes deep inside and mypy cannot check `render`, `human_turns` or `run_worker`. Goal 4.1. +- **Read transcript and stream entries into typed values where they are read.** `read_transcript` and `run_worker` pass raw `dict`s, so about ten accessors in `entries.py` re-check shapes deep inside and mypy cannot check `render`, `human_turns` or `run_worker`. Goal 4.1. - **Measure test coverage in the suite, and fail on a drop.** Nothing measures it, so "Test coverage should not decline" cannot be held. Goal 4.1. - **Give the reviewer agents only the tools they need.** `systems-architect.md`, `product-owner-reviewer.md` and `stability-reviewer.md` have no `tools:` line, so each can edit the branch it reviews; `review-findings.md` says a reviewer edits nothing. Goal 4.1. - **Add a test that `.gitignore` keeps credentials, transcripts and memory files out.** `test_gitignore.py` checks only that every tracked file is allowlisted; a widened negation such as `!*.json` would un-ignore `.credentials.json`. Goal 3. @@ -58,5 +50,5 @@ The 2026-10-02 panel on PR #187 named this under Self-sufficiency, the one dimen - **Write a `workflow-review` skill that reads the stats and files each change it proposes to the workflow as a plan item, and have `AGENTS.md` run it on the chunk shipping a release's last item.** The workflow is `CLAUDE.md`, `principles/`, the skills, the agents and `loop-claude`. The skill's signals: findings outside the chunk's diff and comprehension scores per release, both from the stats; fixes after merge, from git; and the human's corrections, from the archived transcripts. Goal 4.4. - **Bench about one chunk in ten against an open PR that changes the workflow, and have a blind claude rule which run better serves this repo's goal 4.** Redo the chunk under the PR, from the commit it started from. The ruling claude is not told which run is which. `loop-claude` picks the chunk at random, small diffs and big ones alike; with no such PR open, no bench runs. The same outcome with less code and prose, in the chunk or in the workflow, also counts as better. The PR merges only once three benches rule it better. A bench that rules it worse closes the PR and records, in `docs/workflow-learnings.md`, what the PR changed and why it lost. The ruling and both runs' numbers go on the chunk's stats line. Start from `workflow-bench/`, written for the 2026-09-30 bench's four fixed cases. Needs the stats line. Goals 4.1 and 4.4. - **Put the scoring run's four seat prompts in `skills/comprehension-panel/`.** Each run copies them from the last run's handoff folder outside the repo, so another machine cannot rerun a comparable panel. Goal 1. -- **Bring the project to the comprehension floor on the four-seat panel.** Every dimension and the overall must reach 7.0, and none may fall below its best run on `rebuild`. A dimension under the floor gets its places filed under "Under the comprehension floor". +- **Make larv-review §3 readable without another file open.** Applying one rule of "Round cap", "Re-entry" or "Findings" takes `review-findings.md`, `CLAUDE.md` → "Vocabulary" and the decision log open beside it. The rules cite each other by number ("Round cap" rule 6), so a renumbering breaks a citation silently. Nothing says where a pass's round count is recorded, so a resumed or compacted session loses it. Goal 4.1. - **Wait out a usage limit and retry however long it lasts, without counting it as a failed run.** Today a worker or judge that hits a usage limit fails three times a minute apart, and the loop exits 1, so an unattended loop dies at every limit. The transcript line Claude Code writes for it, marked `"error":"rate_limit"`, holds the reset time: `You've hit your session limit · resets 7:40pm (Europe/Stockholm)`. Sleep until 2 minutes past it. The judge runs without a transcript, so find what its JSON reply carries on a limit. Where no reset time can be read, retry every 10 minutes: a retry before the reset fails (https://platform.claude.com/docs/en/api/rate-limits), so polling sooner only spends requests. Print when the next try is due, and update `--help`'s exit 1. Goal 4.