diff --git a/bin/loop_claude/cycle/judge.py b/bin/loop_claude/cycle/judge.py index b96f5072..b3756cd9 100644 --- a/bin/loop_claude/cycle/judge.py +++ b/bin/loop_claude/cycle/judge.py @@ -16,7 +16,7 @@ JUDGE_PROMPT_CHARS = 400000 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 " - "README.md nor the project's records settle the matter\n" + "README.md nor the project's records settle the matter, or a [loop] line already answered it\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 " "transient state it then handled is not one\n" @@ -43,7 +43,7 @@ JUDGE_RULES = ( @dataclasses.dataclass(frozen=True) class Reply: answer: str = dataclasses.field(metadata={"description": "With interrupt false, the passage of README.md or the project's records that answers the agent's question, quoted verbatim. Empty otherwise."}) - 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."}) + evidence: str = dataclasses.field(metadata={"description": "A verbatim quote of the transcript line the verdict rests on: what triggers the interrupt, what the agent asked for a quoted answer, else what shows the chunk finished or the work remaining."}) finished: bool interrupt: bool question: str = dataclasses.field(metadata={"description": "With interrupt true, the single question to put to the human. With a quoted answer, the agent's question that the answer field answers. Empty otherwise."}) @@ -118,7 +118,9 @@ def verdict_from(output: object) -> Verdict | Failure: if not output["question"].strip(): return Failure("the judge interrupted without a question") return Interrupt(output["evidence"], output["question"]) - if output["answer"].strip() and output["question"].strip(): + if output["answer"].strip(): + if not output["question"].strip(): + return Failure("the judge quoted an answer without a question") return QuotedAnswer(output["evidence"], output["question"], output["answer"]) return Finished(output["evidence"]) if output["finished"] else Unfinished(output["evidence"]) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index fe2dcfb5..305ec16e 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -52,7 +52,7 @@ 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. A usage limit is not + interrupts or quotes an answer 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. diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index cdf11d26..c78b3a6d 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -504,7 +504,7 @@ class Verdict(unittest.TestCase): self.assertEqual(judge.verdict_from({"answer": "", "interrupt": True, "evidence": "e", "finished": True, "question": "Which one?"}), Interrupt("e", "Which one?")) self.assertEqual(judge.verdict_from({"answer": "A.", "interrupt": False, "evidence": "e", "finished": False, "question": "Which one?"}), QuotedAnswer("e", "Which one?", "A.")) self.assertEqual(judge.verdict_from({"answer": "A.", "interrupt": True, "evidence": "e", "finished": False, "question": "Which one?"}), Interrupt("e", "Which one?")) - self.assertEqual(judge.verdict_from({"answer": "ignored", "interrupt": False, "evidence": "e", "finished": False, "question": ""}), Unfinished("e")) + self.assertEqual(judge.verdict_from({"answer": "A.", "interrupt": False, "evidence": "e", "finished": True, "question": ""}), Failure("the judge quoted an answer without a question")) self.assertEqual(judge.verdict_from({"answer": "", "interrupt": "no", "evidence": "", "finished": True, "question": ""}), Failure("the judge's reply has no interrupt of type boolean")) self.assertEqual(judge.verdict_from({"answer": "", "interrupt": False, "evidence": None, "finished": True, "question": ""}), Failure("the judge's reply has no evidence of type string")) self.assertEqual(judge.verdict_from({"answer": "", "interrupt": True, "evidence": "x", "finished": False, "question": " "}), Failure("the judge interrupted without a question")) diff --git a/docs/decisions.md b/docs/decisions.md index 20d2956c..c1c0cf15 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -8,7 +8,7 @@ 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: when README.md or those files answer the worker's question, the judge quotes the answer verbatim and the worker resumes with it. The judge then sees the quote 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 that README.md or those files answer in one cycle goes to the human with the judge's quote, so the cost is one interrupt. Valid while the worker writes records only in a worktree, as `CLAUDE.md` → "Working with the codebase" has it, so the records the judge reads from the checkout root are merged ones. +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: when the README's premises or those files answer the worker's question, the judge quotes the answer verbatim and the worker resumes with it. The judge then sees the quote 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 that the README's premises or those files answer in one cycle goes to the human with the judge's quote. The count holds through an interrupt, so each later such question that cycle costs one interrupt too. Valid while the worker writes records only in a worktree, as `CLAUDE.md` → "Working with the codebase" has it, so the records the judge reads from the checkout root are merged ones. ## loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it diff --git a/todo.md b/todo.md index 2330d235..5ef90c0e 100644 --- a/todo.md +++ b/todo.md @@ -24,11 +24,11 @@ | ID | Release | Exempt | Item | R | S | A | G | Goals | Score | |---|---|---|---|---|---|---|---|---|---| -| 41 | 0.1.0 | defect | **Ground a judge's quote that elides with an ellipsis, each fragment found in order, and tell the judge to quote one passage.** | 2 | 2 | 10 | 10 | 4, 4.2 | 30.9 | +| 41 | 0.1.0 | defect | **Accept a judge's quote that elides with an ellipsis when its fragments appear in the transcript in order, and tell the judge to quote one passage.** | 2 | 2 | 10 | 10 | 4, 4.2 | 30.9 | | 1 | 0.1.0 | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 3 | 5 | 8 | 9 | 2, 3 | 27.8 | | 13 | 0.1.0 | decision | **Make larv-review §3 applicable on its own, cite its rules by name, and say where a pass's round count is recorded.** | 3 | 5 | 6 | 7 | 4.1 | 15.6 | | 23 | 0.1.0 | | **Launch a principles auditor only for a principles file the project shows applies, and rerun only the reviewer whose finding a fix answers.** | 3 | 4 | 7 | 8 | 4.4 | 13.5 | -| 40 | 0.1.0 | | **Render tool input in the judged transcript with its non-ASCII characters as written, so the judge's quotes of it ground.** | 2 | 1 | 5 | 6 | 4.2 | 13.0 | +| 40 | 0.1.0 | | **Render tool input in the judged transcript with its non-ASCII characters as written, so the judge's quotes of it match the transcript.** | 2 | 1 | 5 | 6 | 4.2 | 13.0 | | 21 | 0.1.0 | | **Give `settings.json`'s model one writer, and sort its keys.** | 3 | 3 | 6 | 7 | 4.3 | 12.9 | | 36 | 0.1.0 | | **Ask the user once before a full security scan, folding larv-review's ask into the plugin's cost prompt.** | 2 | 2 | 5 | 5 | 4.2 | 11.9 | | 12 | 0.1.0 | | **Run the test suite in CI on every PR, or record in `docs/decisions.md` why the local run is enough.** | 2 | 4 | 4 | 6 | 4.1 | 11.7 | @@ -41,9 +41,9 @@ ## Details -### 41. Ground a judge's quote that elides with an ellipsis, each fragment found in order, and tell the judge to quote one passage. +### 41. Accept a judge's quote that elides with an ellipsis when its fragments appear in the transcript in order, and tell the judge to quote one passage. -On 2026-10-03 the log project's loop exited 1: "the judge failed three times running: the judge quoted \"**Decision for you:** security, … ... I recommend one more round of each ... I recommend skipping it: …\", which is not in the transcript". Each fragment the judge joined with " ... " is in the rendered transcript; `grounded` matches the evidence as one contiguous string, so a correct interrupt was rejected three times and the human was never asked. The archive is `loop-claude-transcripts/log/dbac9d70…/5d8c9152….verdict.md`. Fix both ends: `grounded` splits on `...` and `…` and finds the fragments in order, and the `evidence` description asks for one contiguous passage. +On 2026-10-03 the log project's loop exited 1: "the judge failed three times running: the judge quoted \"**Decision for you:** security, … ... I recommend one more round of each ... I recommend skipping it: …\", which is not in the transcript". Each fragment the judge joined with " ... " is in the rendered transcript; `grounded` matches the evidence as one contiguous string, so a correct interrupt was rejected three times and the human was never asked. The archive is `~/.claude/loop-claude-transcripts/log/dbac9d7096282d2bc6c38fc8c03cd74b50d29b75080b1f647c0f305a088db894/5d8c9152cdcd91e90dfd2773cd81c9e64bcd412ff148c5cf19e2a728ceee5028.verdict.md`. Fix both ends: `grounded` splits on `...` and `…` and finds the fragments in order, and the `evidence` description asks for one contiguous passage. ### 1. Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume. @@ -59,9 +59,9 @@ Applying one rule of "Round cap", "Re-entry" or "Findings" takes `review-finding On this repo the frontend, REST and logging auditors each read the whole project to report "does not apply", and one 🟢 fix reruns ten whole-project reads. -### 40. Render tool input in the judged transcript with its non-ASCII characters as written, so the judge's quotes of it ground. +### 40. Render tool input in the judged transcript with its non-ASCII characters as written, so the judge's quotes of it match the transcript. -`part_line` renders a tool call with `json.dumps(arguments)`, which escapes non-ASCII as `\uXXXX`. A judge quoting such a line with the characters as written, Swedish text say, fails `grounded` three times on one transcript, and the loop exits 1. Raised, unverified, by the 2026-10-03 scoring run on PR #202. +`part_line` renders a tool call with `json.dumps(arguments)`, which escapes non-ASCII as `\uXXXX`. A judge that quotes such a line with its characters as written, such as Swedish text, fails `grounded` three times on one transcript, and the loop exits 1. Raised, unverified, by the 2026-10-03 scoring run on PR #202. ### 21. Give `settings.json`'s model one writer, and sort its keys.