diff --git a/CHANGELOG.md b/CHANGELOG.md index 72cca699..597fa3c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 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, 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. The judge reads the transcript's last 400,000 characters, up from 40,000. `loop-claude` exits 1 when `AGENTS.md` or `docs/decisions.md` cannot be read or is not UTF-8. +- `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` 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`. diff --git a/CLAUDE.md b/CLAUDE.md index cc6ded35..fb771bd5 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 records answers in between, until the chunk closes or continues next cycle. +- **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. - **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 b44c125c..2eaa8860 100644 --- a/bin/loop_claude/cycle/judge.py +++ b/bin/loop_claude/cycle/judge.py @@ -10,8 +10,8 @@ from loop_claude.failure import Failure from loop_claude.limited import Limited from loop_claude.stop import Stop -# About 100,000 tokens, half a 200,000-token context; the largest session rendered here was 364,000 characters on 2026-10-03. -JUDGED_TRANSCRIPT_TAIL = 400000 +# At 3 to 4 characters a token, 100,000 to 133,000 tokens, which leaves a 200,000-token context room for the reply; the largest session rendered here was 364,000 characters on 2026-10-03. +JUDGE_PROMPT_CHARS = 400000 JUDGE_RULES = ( "Decide whether the agent has something open that the human, or README.md and the project's records, " @@ -88,20 +88,22 @@ def run_judge(root: str, args: list[str], prompt: str, rendered_transcript: str, return Failure(f"{verdict.reason}; it replied: {proc.stdout.strip() or 'nothing'}") if not grounded(verdict.evidence, rendered_transcript): return Failure(f"the judge quoted {verdict.evidence!r}, which is not in the transcript" + (f", for the question: {verdict.question}" if isinstance(verdict, Interrupt | AnsweredFromRecords) else "")) + # An answer the records do not hold verbatim is dropped, and the question goes to the human. if isinstance(verdict, AnsweredFromRecords) and not grounded(verdict.answer, recorded): - return Failure(f"the judge answered {verdict.question!r} with {verdict.answer!r}, which README.md and the project's records do not hold") + return Interrupt(verdict.evidence, verdict.question) return verdict def judge_prompt(task: str, premises: str, records: str, rendered_transcript: str) -> str: - return ( + head = ( f"From README.md:\n{premises}\n\n" f"The project's records, its working rules and decisions:\n{records or 'none'}\n\n" f"The task an agent was given:\n{task}\n\n" - # The tail, where an interrupt or a finish lands; the session's transcript grows cycle over cycle. - f"What the agent did and said, what the human typed on [human] lines and what loop-claude told it on [loop] lines, latest last:\n{rendered_transcript[-JUDGED_TRANSCRIPT_TAIL:]}\n\n" - f"{JUDGE_RULES}" + "What the agent did and said, what the human typed on [human] lines and what loop-claude told it on [loop] lines, latest last:\n" ) + room = max(0, JUDGE_PROMPT_CHARS - len(head) - len(JUDGE_RULES) - 2) + # The tail, where an interrupt or a finish lands; the session's transcript grows cycle over cycle. + return f"{head}{rendered_transcript[max(0, len(rendered_transcript) - room):]}\n\n{JUDGE_RULES}" def verdict_from(output: object) -> Verdict | Failure: @@ -110,8 +112,6 @@ def verdict_from(output: object) -> Verdict | Failure: for name, kind in REPLY_TYPES.items(): if not isinstance(output.get(name), kind): return Failure(f"the judge's reply has no {name} of type {JSON_TYPES[kind]}") - if output["answer"].strip() and not output["interrupt"]: - return Failure("the judge answered without interrupting") # An interrupt outranks finished: the human answers before the chunk can close. if output["interrupt"]: if not output["question"].strip(): diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index 47c1e8a4..0c8d63e6 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -8,7 +8,7 @@ from loop_claude.cycle.interrupt import interrupt from loop_claude.cycle.judge import judge from loop_claude.cycle.retry import retried from loop_claude.cycle.states import Active, Archived, Closing, Ended, Event, HumanAnswered, Interrupting, Judging, Ruled, State, WorkerRan, Working, transition -from loop_claude.cycle.verdicts import Finished, Unfinished +from loop_claude.cycle.verdicts import AnsweredFromRecords, Finished, Unfinished from loop_claude.cycle.worker import run_worker, worker_args from loop_claude.effects import Effects from loop_claude.failure import Failure @@ -52,8 +52,8 @@ def stopped(cycle: Cycle, stop: Stop, why: str) -> Stop: def step(cycle: Cycle, state: Active) -> Event | Stop: match state: - case Working(answer, _): - return work(cycle, answer) + case Working(answered, _): + return work(cycle, answered) case Judging(transcript_path, _): return rule(cycle, transcript_path) case Interrupting(transcript_path, question, _): @@ -64,9 +64,11 @@ def step(cycle: Cycle, state: Active) -> Event | Stop: typing.assert_never(state) -def work(cycle: Cycle, answer: str | None) -> WorkerRan | 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) # 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), answer), cycle.effects), cycle.effects): + 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 path = transcript_file(cycle.session) return WorkerRan(path) if path is not None else Stop(1, f"claude left no transcript for session {cycle.session.id}") diff --git a/bin/loop_claude/cycle/states.py b/bin/loop_claude/cycle/states.py index 7abb04e8..e0417c58 100644 --- a/bin/loop_claude/cycle/states.py +++ b/bin/loop_claude/cycle/states.py @@ -9,7 +9,7 @@ RECORDS_ANSWERS_PER_CYCLE = 3 @dataclasses.dataclass(frozen=True) class Working: """The worker runs, resumed with the records' answer when there is one.""" - answer: str | None = None + answered: AnsweredFromRecords | None = None records_answers: int = 0 @@ -69,10 +69,10 @@ def transition(state: State, event: Event) -> State: match state, event: case Working(_, records_answers), WorkerRan(transcript_path): return Judging(transcript_path, records_answers) - case Judging(_, records_answers), Ruled(AnsweredFromRecords(answer=answer)) if records_answers < RECORDS_ANSWERS_PER_CYCLE: - return Working(answer, records_answers + 1) + 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}", records_answers) + 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) 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/cycle/worker.py b/bin/loop_claude/cycle/worker.py index 27cfffab..d053fdd7 100644 --- a/bin/loop_claude/cycle/worker.py +++ b/bin/loop_claude/cycle/worker.py @@ -1,6 +1,7 @@ from loop_claude.claude_code.entries import assistant_parts, ends_stream, hit_limit, limit_said, parse_entry, rejected_until from loop_claude.claude_code.session import Session from loop_claude.claude_code.transcript import part_line +from loop_claude.cycle.verdicts import AnsweredFromRecords from loop_claude.effects import Effects from loop_claude.failure import Failure from loop_claude.limited import Limited @@ -37,10 +38,11 @@ def worker_outcome(code: int, result: dict | None, resets: list[int]) -> Failure return None if result is not None else Failure("claude exited 0 without a result event") -def worker_args(task: str, session: Session, model: str, resuming: bool, answer: str | None = None) -> list[str]: - if resuming: - prompt = f"README.md or the project's records answer your question:\n\n{answer}\n\nContinue the task." if answer is not None else "Continue the task; the previous run stopped before it was finished." - start = ["-p", prompt, "--resume", str(session.id)] +def worker_args(task: str, session: Session, model: str, resuming: bool, answered: AnsweredFromRecords | None = None) -> list[str]: + if answered is not None: + start = ["-p", f"Your question: {answered.question}\n\nREADME.md or the project's records answer it:\n\n{answered.answer}\n\nContinue the task.", "--resume", str(session.id)] + elif resuming: + start = ["-p", "Continue the task; the previous run stopped before it was finished.", "--resume", str(session.id)] else: start = ["-p", f"{task}\n\nContinue any open draft PR or worktree for the chunk before creating a new one.", "--name", session.name, "--session-id", str(session.id)] return [ diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 8d35e331..cbda1ea9 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -4,11 +4,12 @@ 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 -the transcript's last 400,000 characters 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 and the worker resumes with it, up to three -times a cycle; a question asked again after its answer, or a fourth, goes to the human. +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. 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. @@ -50,9 +51,9 @@ 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, answers without interrupting, quotes a line the transcript does - not hold, or quotes an answer the premises and the records do not hold. A usage limit is not a - failure, and restarts the count of three: the worker or the judge is retried 2 minutes + 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. diff --git a/bin/loop_claude/project/checkout.py b/bin/loop_claude/project/checkout.py index fb787d0b..de5f057d 100644 --- a/bin/loop_claude/project/checkout.py +++ b/bin/loop_claude/project/checkout.py @@ -36,4 +36,4 @@ def read_checkout_file(root: str, name: str, consequence: str) -> str | Stop: return Stop(1, f"{name} in {root}: {failure.strerror} - {consequence}.") except UnicodeDecodeError as failure: line = failure.object.count(b"\n", 0, failure.start) + 1 - return Stop(1, f"{name} is not UTF-8 on line {line} - {consequence}.") + return Stop(1, f"{name} in {root} is not UTF-8 on line {line} - {consequence}.") diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 5f5a3030..999afe79 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -130,12 +130,12 @@ class Transitions(unittest.TestCase): answered = states.Ruled(AnsweredFromRecords("e", "Which one?", "A.")) legal = ( (states.Working(), states.WorkerRan("/t"), states.Judging("/t")), - (states.Working("A.", 3), states.WorkerRan("/t"), states.Judging("/t", 3)), + (states.Working(AnsweredFromRecords("e", "Which one?", "A."), 3), states.WorkerRan("/t"), states.Judging("/t", 3)), (states.Judging("/t"), states.Ruled(Interrupt("e", "Which one?")), states.Interrupting("/t", "Which one?")), (states.Judging("/t", 3), states.Ruled(Interrupt("e", "Which one?")), states.Interrupting("/t", "Which one?", 3)), - (states.Judging("/t"), answered, states.Working("A.", 1)), - (states.Judging("/t", 2), answered, states.Working("A.", 3)), - (states.Judging("/t", 3), answered, states.Interrupting("/t", "Which one?\n\nREADME.md or the project's records say:\nA.", 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"), 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"))), @@ -147,7 +147,7 @@ class Transitions(unittest.TestCase): for state, event, after in legal: with self.subTest(state=state, event=event): self.assertEqual(states.transition(state, event), after) - every_state = (states.Working(), states.Working("A.", 3), states.Judging("/t"), states.Judging("/t", 3), states.Interrupting("/t", "q"), states.Interrupting("/t", "q", 3), states.Closing("/t", Finished("e")), states.Ended()) + every_state = (states.Working(), states.Working(AnsweredFromRecords("e", "Which one?", "A."), 3), states.Judging("/t"), states.Judging("/t", 3), states.Interrupting("/t", "q"), states.Interrupting("/t", "q", 3), states.Closing("/t", Finished("e")), states.Ended()) every_event = (states.WorkerRan("/t"), states.Ruled(Interrupt("e", "Which one?")), answered, states.Ruled(Finished("e")), states.Ruled(Unfinished("e")), states.HumanAnswered(), states.Archived()) for state in every_state: for event in every_event: @@ -247,18 +247,21 @@ class Cycles(unittest.TestCase): def test_a_question_the_records_answer_resumes_the_worker_with_the_answer_three_times_a_cycle(self): answered = judged("interrupt", answer="Use *A*.") fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)] * 4, claude=[answered] * 4, on_terminal_claude=[0], git=[ran()]) - with contextlib.redirect_stderr(io.StringIO()) as said: + with contextlib.redirect_stderr(io.StringIO()) as said, contextlib.redirect_stdout(io.StringIO()) as printed: self.assertEqual(run.run_cycle(self.cycle(fake, records="From AGENTS.md:\nUse A.")), Stop(2, "the human is needed to answer the question above, but the interrupt ended with nothing typed")) resumed = fake.made("stream_claude")[1] - self.assertEqual(resumed[resumed.index("-p") + 1], "README.md or the project's records answer your question:\n\nUse *A*.\n\nContinue the task.") + 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.assertIn("Which one?\n\nREADME.md or the project's records say:\nUse *A*.", said.getvalue()) + 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()) - def test_the_judge_fails_on_an_answer_the_records_do_not_hold(self): - invented = judged("interrupt", answer="Use B.") - fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[invented] * 3) - with contextlib.redirect_stderr(io.StringIO()): - self.assertEqual(run.run_cycle(self.cycle(fake, records="From AGENTS.md:\nUse A.")), Stop(1, "the judge failed three times running: the judge answered 'Which one?' with 'Use B.', which README.md and the project's records do not hold")) + 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()]) + with contextlib.redirect_stderr(io.StringIO()) as said: + self.assertEqual(run.run_cycle(self.cycle(fake, records="From AGENTS.md:\nUse A.")), Stop(2, "the human is needed to answer the question above, but the interrupt ended with nothing typed")) + self.assertEqual(len(fake.made("stream_claude")), 1) + self.assertIn("\nWhich one?\n", said.getvalue()) + self.assertNotIn("Use B.", said.getvalue()) @unittest.skipIf(os.geteuid() == 0, "root writes into a read-only directory") def test_stops_keeping_the_transcript_when_the_finished_chunks_session_cannot_be_deleted(self): @@ -388,7 +391,7 @@ class Records(unittest.TestCase): pathlib.Path(root, "docs", "decisions.md").mkdir(parents=True) self.assertEqual(records.read_records(root), Stop(1, f"docs/decisions.md in {root}: Is a directory - the judge cannot read the project's records.")) pathlib.Path(root, "AGENTS.md").write_bytes(b"# Rules\n\xff\n") - self.assertEqual(records.read_records(root), Stop(1, "AGENTS.md is not UTF-8 on line 2 - the judge cannot read the project's records.")) + self.assertEqual(records.read_records(root), Stop(1, f"AGENTS.md in {root} is not UTF-8 on line 2 - the judge cannot read the project's records.")) class Sections(unittest.TestCase): @@ -500,7 +503,7 @@ class Verdict(unittest.TestCase): self.assertEqual(judge.verdict_from({"answer": "", "interrupt": False, "evidence": "e", "finished": False, "question": "ignored"}), Unfinished("e")) 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": True, "evidence": "e", "finished": False, "question": "Which one?"}), AnsweredFromRecords("e", "Which one?", "A.")) - self.assertEqual(judge.verdict_from({"answer": "A.", "interrupt": False, "evidence": "e", "finished": False, "question": ""}), Failure("the judge answered without interrupting")) + self.assertEqual(judge.verdict_from({"answer": "ignored", "interrupt": False, "evidence": "e", "finished": False, "question": ""}), Unfinished("e")) 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")) @@ -531,8 +534,8 @@ class LoopRuns(unittest.TestCase): class HelpLimits(unittest.TestCase): def test_help_states_the_limits_the_code_holds(self): - self.assertIn(f"last {judge.JUDGED_TRANSCRIPT_TAIL:,} characters", main.__doc__) - self.assertIn(f"up to {['one', 'two', 'three', 'four'][states.RECORDS_ANSWERS_PER_CYCLE - 1]}\ntimes a cycle", main.__doc__) + 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__) class ExitContract(unittest.TestCase): @@ -558,7 +561,7 @@ class ExitContract(unittest.TestCase): ("project/checkout.py", "checkout_root", "1", "f'could not start git:", git), ("project/checkout.py", "checkout_root", "1", "found.stderr.strip()", git), ("project/checkout.py", "read_checkout_file", "1", "f'{name} in {root}:", unreadable), - ("project/checkout.py", "read_checkout_file", "1", "f'{name} is not UTF-8", unreadable), + ("project/checkout.py", "read_checkout_file", "1", "f'{name} in {root} is not UTF-8", unreadable), ("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_), diff --git a/bin/test_loop_claude_black_box.py b/bin/test_loop_claude_black_box.py index 58a7ca9a..8c9f0209 100644 --- a/bin/test_loop_claude_black_box.py +++ b/bin/test_loop_claude_black_box.py @@ -282,7 +282,7 @@ class Premises(unittest.TestCase): self.assertIn("not a git repository", run.stderr) readmes = { None: "README.md in {root}: No such file or directory - no premises.", - b"# P\n## Goals\n1. g\xff\n## Audience\nme\n": "README.md is not UTF-8 on line 3 - no premises.", + b"# P\n## Goals\n1. g\xff\n## Audience\nme\n": "README.md in {root} is not UTF-8 on line 3 - no premises.", b"# P\n## Audience\nme\n": "README.md has no ## Goals heading - no premises.", b"# P\n## Goals\n1. g\n": "README.md has no ## Audience heading - no premises.", b"# P\n## Goals\n\n## Audience\nme\n": "README.md has nothing under ## Goals - no premises.", @@ -433,7 +433,8 @@ class Cycles(unittest.TestCase): checkout = Checkout(self) run = checkout.run([worker(say="early " * 80000 + "LATE")]) self.assertIn("LATE", run.calls[1]["stdin"]) - self.assertEqual(run.calls[1]["stdin"].count("early"), (400000 - len("LATE")) // len("early ")) + self.assertEqual(len(run.calls[1]["stdin"]), 400000) + self.assertLess(run.calls[1]["stdin"].count("early"), 80000) self.assertTrue(run.calls[1]["stdin"].rstrip().endswith("an open PR, a review not yet run, CI not yet reported.")) def test_skips_a_malformed_transcript_or_stream_line(self):