Answer architecture round 1: 4 🔴, 5 🟡 (0 misread); one-way plan packages with a plan core and an Atlassian client, one parse and print of an item's cells, a pure chunk-start decision, a settings table, one plan read and one standing per pick, one config load in chunk-pr, notifier backends in notifier, and the bin regroup filed as item 392
This commit is contained in:
@@ -28,15 +28,15 @@ from loop_effects.effects import Effects, PYTHON_TIMEOUT
|
||||
from claude_code import entries, reply, session
|
||||
from failure import Failure
|
||||
from loop_claude.verdicts import Finished, Interrupt, Judged, QuotedAnswer, TakenIn, Unfinished
|
||||
from chunk_preflight import gathered
|
||||
from git_cli.git_repo import git
|
||||
from loop_claude.cycle import interrupt, judge, prompts, retry, run, spend, states, worker
|
||||
from claude_code.reply import Limited
|
||||
from loop_claude.loop import main, reload, routing_check, this_loop, usage
|
||||
from machine_load import memory
|
||||
from release_plan import next_chunk
|
||||
from transcript_archive import outcomes, write
|
||||
from loop_state import paths
|
||||
from plan_store.stores import plan_of
|
||||
from plan_store.todo_md import plan_of
|
||||
from transcript_archive.location import project_archive
|
||||
from model_routing.ladder_file import read_ladder, SHIPPED
|
||||
from model_routing.route import Route, route_from, WorkerLine
|
||||
@@ -286,7 +286,7 @@ class Cycles(unittest.TestCase):
|
||||
self.archive = project_archive(str(self.home / "code" / "proj"), self.home, {})
|
||||
|
||||
def cycle(self, fake, records="", unfinished_evidence="", facts="- A preflight fact."):
|
||||
return run.Cycle(config=CONFIG, window=WINDOW, effects=fake.effects(), facts=facts, judge_model="judge-model", ladder=LADDER, premises="## Goals", project=None, project_archive=self.archive, records=records, root=str(self.home), route=Route(Rung("worker-model")), session=self.session, task="Do it.", todo=plan_of(""), unfinished_evidence=unfinished_evidence)
|
||||
return run.Cycle(config=CONFIG, window=WINDOW, effects=fake.effects(), facts=facts, judge_model="judge-model", ladder=LADDER, premises="## Goals", project=None, project_archive=self.archive, records=records, root=str(self.home), route=Route(Rung("worker-model")), session=self.session, task="Do it.", plan=plan_of(""), unfinished_evidence=unfinished_evidence)
|
||||
|
||||
def archived_outcomes(self):
|
||||
return sorted(path.read_text() for path in self.archive.glob("*/*.outcomes.md"))
|
||||
@@ -1165,22 +1165,15 @@ class RouteSources(unittest.TestCase):
|
||||
|
||||
def test_routes_a_window_named_for_an_item_on_that_item_whatever_the_plan_takes_next(self):
|
||||
plan = DefaultPlan(plan_of(TODO), LastCut("v0.1.0", "", 3, [TODO]))
|
||||
later = next(item.id for item in plan.todo.items if item.id != 3)
|
||||
later = next(item.id for item in plan.plan.items if item.id != 3)
|
||||
self.assertEqual(chunk_start.plan_item(plan, later, FakeEffects().effects()).id, later)
|
||||
# An item that left the plan, as once it shipped.
|
||||
self.assertIsNone(chunk_start.plan_item(plan, 999, FakeEffects().effects()))
|
||||
# A chunk start reads the default branch once, for routing and for scoring the items the worker names.
|
||||
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:
|
||||
for window, routed in ((tmux.Window("loop-proj", f"item-{later}", "%4"), later), (tmux.Window("loop-proj", "no-item", "%4"), 3)):
|
||||
with self.subTest(window=window.name):
|
||||
loop = a_loop(FakeEffects().effects(), window=window)
|
||||
facts, reader = chunk_start.chunk_start(loop)
|
||||
self.assertEqual((facts, reader().id), ("", routed))
|
||||
fetched.assert_called_with(loop)
|
||||
# Where the plan cannot be read, the reader says so through the loop's effects, and routes on the project's rung.
|
||||
fetched.return_value = Failure("no origin remote")
|
||||
with contextlib.redirect_stderr(io.StringIO()) as said:
|
||||
self.assertIsNone(chunk_start.chunk_start(a_loop(FakeEffects().effects()))[1]())
|
||||
self.assertIn("routing on the project's rung: no origin remote", said.getvalue())
|
||||
loop = a_loop(FakeEffects().effects())
|
||||
self.assertEqual(chunk_start.chunk_start(loop), ("", plan))
|
||||
fetched.assert_called_once_with(loop)
|
||||
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):
|
||||
@@ -1189,13 +1182,13 @@ class RouteSources(unittest.TestCase):
|
||||
self.assertTrue(stderr.getvalue().startswith(f"{STAMP} {said}"), stderr.getvalue())
|
||||
|
||||
def test_says_why_the_items_the_worker_names_lift_no_rung(self):
|
||||
fetched = ["origin\n", "origin/main\n", "", "todo.md\n"]
|
||||
for git, said in ((fetched + [TODO.replace("| 4 | 2 | 3 |", "| x | 2 | 3 |")], "the items the worker names lift no rung: item 3's L 'x' is not a whole number from 1 to 4\n"), ([Failure("no git")], "the items the worker names lift no rung: no git\n"), (fetched + [TODO], "")):
|
||||
with self.subTest(said=said), tempfile.TemporaryDirectory() as root:
|
||||
home = configured(self, pathlib.Path(root)).parents[1]
|
||||
unscored = plan_of(TODO.replace("| 4 | 2 | 3 |", "| x | 2 | 3 |"))
|
||||
for default, said in ((DefaultPlan(unscored, NO_CUT), "the items the worker names lift no rung: item 3's L 'x' is not a whole number from 1 to 4\n"), (Failure("no git"), "the items the worker names lift no rung: no git\n"), (DefaultPlan(plan_of(TODO), NO_CUT), "")):
|
||||
with self.subTest(said=said):
|
||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||
chunk_start.fetched_todo(a_loop(FakeEffects(git=git).effects(), root=root, paths=paths.paths_from(home)))
|
||||
scored = chunk_start.scored_plan(default, FakeEffects().effects())
|
||||
self.assertEqual(stderr.getvalue(), f"{STAMP} {said}" if said else "")
|
||||
self.assertEqual(scored, default.plan if isinstance(default, DefaultPlan) else default)
|
||||
|
||||
def test_reads_the_changelog_the_default_branch_holds_through_the_loops_git(self):
|
||||
def git(*args, **options):
|
||||
@@ -1219,16 +1212,15 @@ class RouteSources(unittest.TestCase):
|
||||
self.assertEqual(stderr.getvalue(), "", "a plan git tracks hides no release")
|
||||
config.write_text(config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"'))
|
||||
(folder / "todo.md").write_text(TODO)
|
||||
self.assertEqual(chunk_start.fetched_todo(loop), plan_of(TODO))
|
||||
unread = Failure("no git")
|
||||
standing = 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:
|
||||
held = chunk_start.fetched_plan(standing)
|
||||
self.assertEqual((held.todo, held.cut.todos_since, held.cut.changelog), (plan_of(TODO), [], ""), "the plan as it stands, whatever git answers")
|
||||
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")
|
||||
config.unlink()
|
||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||
self.assertIn("no config names the checkout", chunk_start.fetched_todo(loop).reason)
|
||||
self.assertIn("no config names the checkout", chunk_start.scored_plan(chunk_start.fetched_plan(loop), loop.effects).reason)
|
||||
self.assertIn("the items the worker names lift no rung: no config names the checkout", stderr.getvalue())
|
||||
self.assertIn("no config names the checkout", chunk_start.fetched_plan(loop).reason)
|
||||
|
||||
@@ -1330,7 +1322,7 @@ class ChunkWindows(unittest.TestCase):
|
||||
def plan(self, *touched):
|
||||
"""A plan of items 1, 2 and on, each predicted to touch the path given for it."""
|
||||
items = touch_plan(*((number, "1.0.0", "", f"- `{path}`") for number, path in enumerate(touched, 1)))
|
||||
return gathered.Plan(items=items, first=items[0], text="", branch_template="")
|
||||
return next_chunk.NextChunk(items=items, first=items[0], text="", branch_template="")
|
||||
|
||||
def test_starts_the_next_item_and_those_picked_beside_it_up_to_the_limit(self):
|
||||
# Item 2 overlaps item 1, so it waits for it; items 3 and 4 run beside it.
|
||||
@@ -1339,26 +1331,39 @@ class ChunkWindows(unittest.TestCase):
|
||||
self.assertEqual(chunk_windows.may_start(plan, [], set(), 2), ["item-1", "item-3"])
|
||||
self.assertEqual(chunk_windows.may_start(plan, [], set(), 9), ["item-1", "item-3", "item-4"])
|
||||
|
||||
def test_leaves_the_items_running_chunks_hold_and_counts_them_against_the_limit(self):
|
||||
def test_leaves_the_items_running_chunks_hold_and_starts_only_as_many_as_the_room_left(self):
|
||||
plan = self.plan("a.py", "a.py", "c.py", "d.py")
|
||||
self.assertEqual(chunk_windows.may_start(plan, ["item-1"], {1, 3}, 2), ["item-4"])
|
||||
self.assertEqual(chunk_windows.may_start(plan, ["item-1"], {1}, 3), ["item-3", "item-4"])
|
||||
self.assertEqual(chunk_windows.may_start(plan, ["item-1", "item-3"], {1, 3}, 2), [])
|
||||
self.assertEqual(chunk_windows.may_start(plan, ["item-1", "item-3", "item-4"], {1, 3, 4}, 2), [])
|
||||
self.assertEqual(chunk_windows.may_start(plan, ["item-1"], {1, 3}, 1), ["item-4"])
|
||||
self.assertEqual(chunk_windows.may_start(plan, ["item-1"], {1}, 2), ["item-3", "item-4"])
|
||||
self.assertEqual(chunk_windows.may_start(plan, ["item-1"], {1}, 0), [])
|
||||
|
||||
def test_counts_the_running_chunks_against_the_limit_and_restarts_stopped_ones_first(self):
|
||||
windows = [tmux.Listed("item-1", "", False), tmux.Listed("item-3", "", True), tmux.Listed("item-4", "", True)]
|
||||
self.assertEqual(chunk_windows.room_of(windows, "item-1", False, 3), chunk_windows.Room(["item-1"], ["item-3", "item-4"], ["item-3", "item-4"], 0))
|
||||
self.assertEqual(chunk_windows.room_of(windows, "item-1", False, 2), chunk_windows.Room(["item-1"], ["item-3", "item-4"], ["item-3"], 0))
|
||||
self.assertEqual(chunk_windows.room_of(windows, "item-1", False, 5), chunk_windows.Room(["item-1"], ["item-3", "item-4"], ["item-3", "item-4"], 2))
|
||||
|
||||
def test_a_loop_whose_chunk_finished_leaves_its_room_and_restarts_no_stopped_chunk(self):
|
||||
windows = [tmux.Listed("item-1", "", False), tmux.Listed("item-3", "", True)]
|
||||
self.assertEqual(chunk_windows.room_of(windows, "item-1", True, 2), chunk_windows.Room([], ["item-3"], [], 2))
|
||||
|
||||
def test_leaves_no_room_where_more_chunks_run_than_the_limit(self):
|
||||
windows = [tmux.Listed(f"item-{n}", "", False) for n in (1, 2, 3)]
|
||||
self.assertEqual(chunk_windows.room_of(windows, "item-1", False, 2).left, 0)
|
||||
|
||||
def test_starts_no_item_that_overlaps_a_running_chunks_items(self):
|
||||
# Item 1 merged, so 2 is the plan's next item; it overlaps item 3, which still runs, at c.py.
|
||||
items = touch_plan((2, "1.0.0", "", "- `a.py`\n- `c.py`"), (3, "1.0.0", "", "- `c.py`"), (4, "1.0.0", "", "- `d.py`"))
|
||||
plan = gathered.Plan(items=items, first=items[0], text="", branch_template="")
|
||||
self.assertEqual(chunk_windows.may_start(plan, ["item-3"], {3}, 3), ["item-4"])
|
||||
plan = next_chunk.NextChunk(items=items, first=items[0], text="", branch_template="")
|
||||
self.assertEqual(chunk_windows.may_start(plan, ["item-3"], {3}, 2), ["item-4"])
|
||||
# A running chunk's item without a prediction leaves no other item free to start beside it.
|
||||
unpredicted = touch_plan((2, "1.0.0", "", "- `a.py`"), (3, "1.0.0", "", None))
|
||||
self.assertEqual(chunk_windows.may_start(gathered.Plan(items=unpredicted, first=unpredicted[0], text="", branch_template=""), ["item-3"], {3}, 3), [])
|
||||
self.assertEqual(chunk_windows.may_start(next_chunk.NextChunk(items=unpredicted, first=unpredicted[0], text="", branch_template=""), ["item-3"], {3}, 2), [])
|
||||
# A held item that left the plan, as once it merged, overlaps nothing.
|
||||
self.assertEqual(chunk_windows.may_start(plan, ["item-9"], {9}, 3), ["item-2", "item-4"])
|
||||
self.assertEqual(chunk_windows.may_start(plan, ["item-9"], {9}, 2), ["item-2", "item-4"])
|
||||
|
||||
def test_a_plan_without_an_item_starts_one_chunk_and_only_alone(self):
|
||||
none = gathered.NoItem("release 1.0.0 has no items")
|
||||
none = next_chunk.NoItem("release 1.0.0 has no items")
|
||||
self.assertEqual(chunk_windows.may_start(none, [], set(), 3), ["no-item"])
|
||||
self.assertEqual(chunk_windows.may_start(none, ["item-1"], {1}, 3), [])
|
||||
|
||||
@@ -1501,7 +1506,7 @@ class StartChunks(unittest.TestCase):
|
||||
self.assertEqual(self.start(fake, chunk="item-7", leaving=True), ["item-3"])
|
||||
self.assertEqual([call for call in fake.tmux_calls if call[0] == "kill-window"], [])
|
||||
fake = FakeEffects(windows="item-7\t0\t@1\nno-item\t1\t@3\n")
|
||||
self.assertEqual(self.start(fake, chunk="item-7", leaving=True, plan=gathered.NoItem("release 1.0.0 has no items")), [])
|
||||
self.assertEqual(self.start(fake, chunk="item-7", leaving=True, plan=next_chunk.NoItem("release 1.0.0 has no items")), [])
|
||||
|
||||
def test_starts_the_chunk_without_a_plan_item_where_the_plan_cannot_be_read(self):
|
||||
fake = FakeEffects()
|
||||
@@ -1697,7 +1702,7 @@ class WorkerArgs(unittest.TestCase):
|
||||
def test_keeps_every_review_on_the_projects_rung_while_the_worker_runs_below_it(self):
|
||||
opus = Rung("claude-opus-5-5", "medium")
|
||||
below = prompts.fresh("Do it.", "## Goals", Route(Rung("claude-sonnet-5-5", "high"), 3, 2, 4), LADDER, opus, self.FACTS)
|
||||
self.assertIn(f"item 3's L of 2. Launch each reviewer, each comprehension seat and the security pass's subagent with the Agent tool set to model opus, effort medium, the project's rung.{self.SCAN} Your rung is below the project's: launch each subagent that files or scores todo.md items on the rung `~/.claude/bin/subagent-rung --plan claude-opus-5-5 <L>` prints. Where an item you take into the chunk has an E + I of 5 or more, launch each reviewer with the Agent tool set to `model fable, effort low` from 5, `model fable, effort medium` from 6, `model opus, effort xhigh` from 7 and `model fable, effort high` from 8. When an escalation trigger", below)
|
||||
self.assertIn(f"item 3's L of 2. Launch each reviewer, each comprehension seat and the security pass's subagent with the Agent tool set to model opus, effort medium, the project's rung.{self.SCAN} Your rung is below the project's: launch each subagent that files or scores plan items on the rung `~/.claude/bin/subagent-rung --plan claude-opus-5-5 <L>` prints. Where an item you take into the chunk has an E + I of 5 or more, launch each reviewer with the Agent tool set to `model fable, effort low` from 5, `model fable, effort medium` from 6, `model opus, effort xhigh` from 7 and `model fable, effort high` from 8. When an escalation trigger", below)
|
||||
self.assertNotIn("Launch each", prompts.fresh("Do it.", "## Goals", Route(opus, 3, 3, 4), LADDER, opus, self.FACTS))
|
||||
|
||||
def test_launches_reviewers_on_the_rung_the_items_e_plus_i_picks_above_the_workers(self):
|
||||
|
||||
Reference in New Issue
Block a user