diff --git a/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index 34f92e82..1eeced61 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -12,7 +12,7 @@ from claude_code.transcript import Typed # Where the judge may quote an answer from, named as the human and the worker see them; of the goals file the judge sees only the premises. QUOTE_SOURCES = listed(("the goals file's Goals and Audience", *RECORD_FILES, *HUMAN_RULE_NAMES), "or") # Where the worker may write an answer the human typed, so it counts as recorded. -ANSWER_DESTINATIONS = "the goals file's Goals or Audience, " + ", ".join(RECORD_FILES) + ", todo.md or a comment" +ANSWER_DESTINATIONS = "the goals file's Goals or Audience, " + ", ".join(RECORD_FILES) + ", the plan or a comment" ANSWERS_RECORDED = f"every answer the human typed in it that a later chunk could need is recorded in {ANSWER_DESTINATIONS} at the one place it governs" # How review_launches names the reviews: "each reviewer" covers every pass with an agent. EACH_REVIEWER = "each reviewer" diff --git a/bin/loop_claude/loop/chunk_start.py b/bin/loop_claude/loop/chunk_start.py index 9105e720..bf7b61a4 100644 --- a/bin/loop_claude/loop/chunk_start.py +++ b/bin/loop_claude/loop/chunk_start.py @@ -57,8 +57,8 @@ def archived_route(archive_folder: pathlib.Path, loop: Loop) -> Route | None: def chunk_start(loop: Loop) -> tuple[str, DefaultPlan | Failure]: """The facts for a fresh worker's prompt, empty where the session is open, and what the default branch holds, read once for the cycle: it routes the chunk, through plan_item, and scores the items the worker names, through scored_plan. It reads the default branch as last fetched: for a fresh chunk, by the preflight that runs first; for an open session, which runs none, by whatever fetched last.""" - facts = "" if session_open(loop.session) else chunk_facts(loop) - return facts, fetched_plan(loop) + fresh = not session_open(loop.session) + return chunk_facts(loop) if fresh else "", fetched_plan(loop, fresh) def chunk_facts(loop: Loop) -> str: @@ -70,12 +70,12 @@ def chunk_facts(loop: Loop) -> str: return facts + (prompts.held_by_others(held) if held else "") -def fetched_plan(loop: Loop) -> DefaultPlan | Failure: - """What the default branch, as last fetched, holds for routing; the plan and the changelog as they stand where the project's config puts them outside the checkout. It says UNSEEN_RELEASES for such a plan.""" +def fetched_plan(loop: Loop, announce: bool = True) -> DefaultPlan | Failure: + """What the default branch, as last fetched, holds for routing; the plan and the changelog as they stand where the project's config puts them outside the checkout. Where announce is True, as when a chunk starts, it says UNSEEN_RELEASES for such a plan, so the human reads it once per chunk, not every cycle.""" config = located(loop.root, loop.paths.home) if isinstance(config, Failure): return config - if config.tracked("plan") is None: + if announce and config.tracked("plan") is None: say(UNSEEN_RELEASES, loop.effects) ref = default_ref(loop.root, ORIGIN_TIMEOUT, run=loop.effects.git) return ref if isinstance(ref, Failure) else project_plan(config, ref, loop.root, loop.effects.git) diff --git a/bin/loop_claude/loop/usage.py b/bin/loop_claude/loop/usage.py index b069173c..9c0b5f99 100644 --- a/bin/loop_claude/loop/usage.py +++ b/bin/loop_claude/loop/usage.py @@ -14,7 +14,7 @@ end, the premises, and the records: the project's AGENTS.md and docs/decisions.m the project's config sets, where they exist. It rules whether the chunk, the work of one PR, is finished. A chunk stays unfinished until each answer the human typed in it that a later chunk could need is recorded: the premises or the records hold it, or the transcript shows the worker writing it -into the premises, AGENTS.md, docs/decisions.md, todo.md or a code comment. A choice the worker made +into the premises, AGENTS.md, docs/decisions.md, the plan or a comment. 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 @@ -104,7 +104,7 @@ each review's rung in bin/model_routing/review_choice.py, and the prompts' wordi bin/loop_claude/cycle/prompts.py. Each verdict, interrupt, quoted answer, stop and step-up in the archive ends with a Worker: line, the route as JSON (Route.worker_line in bin/model_routing/route.py); a rerun resumes an open chunk on the latest route named there. A -todo.md or an archive that cannot be read or parsed is said on stderr, and the chunk is routed +plan or an archive that cannot be read or parsed is said on stderr, and the chunk is routed without it. The ladder is a JSON file, each rung a model's full name and an effort of low, medium, high, xhigh diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 9e4f2a28..0f2f2d80 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1173,7 +1173,8 @@ class RouteSources(unittest.TestCase): with unittest.mock.patch.object(chunk_start, "session_open", return_value=True), unittest.mock.patch.object(chunk_start, "fetched_plan", return_value=plan) as fetched: loop = a_loop(FakeEffects().effects()) self.assertEqual(chunk_start.chunk_start(loop), ("", plan)) - fetched.assert_called_once_with(loop) + # An open session is no fresh chunk, so the human isn't told again of releases the plan cannot show. + fetched.assert_called_once_with(loop, False) unreadable = Failure("git show origin/main:todo.md printed text that is not UTF-8") for plan, said in ((DefaultPlan(plan_of(TODO.replace("| 4 | 2 | 3 |", "| x | 2 | 3 |")), NO_CUT), "routing on the project's rung: item 3's L 'x' is not a whole number from 1 to 4\n"), (DefaultPlan(unreadable, NO_CUT), f"routing on the project's rung: {unreadable.reason}\n"), (Failure("no origin remote"), "routing on the project's rung: no origin remote\n")): with self.subTest(said=said): @@ -1218,6 +1219,10 @@ class RouteSources(unittest.TestCase): held = chunk_start.fetched_plan(standing) self.assertEqual((held.plan, held.cut.todos_since, held.cut.changelog), (plan_of(TODO), [], ""), "the plan as it stands, whatever git answers") self.assertEqual(stderr.getvalue(), f"{STAMP} {UNSEEN_RELEASES}\n", "a release review loop-claude cannot call due is never skipped silently") + quiet = a_loop(FakeEffects(git=["origin\n", "origin/main\n", unread, unread, unread, unread]).effects(), root=root, paths=paths.paths_from(folder.parents[1])) + with contextlib.redirect_stderr(io.StringIO()) as stderr: + chunk_start.fetched_plan(quiet, announce=False) + self.assertEqual(stderr.getvalue(), "", "said once per chunk, as it starts") config.unlink() with contextlib.redirect_stderr(io.StringIO()) as stderr: self.assertIn("no config names the checkout", chunk_start.scored_plan(chunk_start.fetched_plan(loop), loop.effects).reason)