Answer architecture round 1: 0 🔴, 4 🟡 (0 misread); chunks_to_start and the epic's folder take the resolved paths; branch_summaries and reviewer_breaches wait for item 300
CI / tests (pull_request) Successful in 5m19s

This commit is contained in:
2026-12-03 19:45:15 +01:00
parent 55f87fb34e
commit a014e75101
15 changed files with 72 additions and 67 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ def chunk_facts(loop: Loop) -> str:
item = item_of(loop.window.name)
done = loop.effects.python([str(loop.launcher.with_name("chunk-preflight")), "--worktree", *([] if item is None else [ITEM, str(item)])], loop.root)
facts = fresh_prompt.preflight_failed(done.stderr.strip() or f"it exited {done.returncode}") if done.returncode else fresh_prompt.preflight_facts(done.stdout.strip())
held = held_beside(loop.window.name, loop.root, loop.paths, loop.env, loop.effects)
held = held_beside(loop.window.name, loop.root, loop.paths, loop.effects)
return facts + (fresh_prompt.held_by_others(held) if held else "")
+12 -14
View File
@@ -17,6 +17,7 @@ from plan.touches import overlaps, predicted, Touches
from loop_state.paths import Paths
from transcript_archive.project_key import project_key
from release_plan.release_standing import project_plan
from project_config.settings import ProjectConfig
from claude_code.transcript import read_transcript
from claude_code.session import Session, session_named, transcript_file
from agent_cycle import tmux
@@ -100,11 +101,8 @@ def clear_of(ours: Touches | Failure | None, theirs: list[Touches | Failure | No
return not theirs or (isinstance(ours, dict) and all(isinstance(touches, dict) and not overlaps(ours, touches) for touches in theirs))
def next_plan(root: str, home: pathlib.Path, env: typing.Mapping[str, str], effects: Effects) -> NextChunk | NoItem | Failure:
"""The plan on the default branch, fetched now where origin answers, with its next item, as chunk-preflight reads it."""
config = located(root, home, env)
if isinstance(config, Failure):
return config
def next_plan(root: str, config: ProjectConfig, effects: Effects) -> NextChunk | NoItem | Failure:
"""The plan config names, on the default branch of the checkout root, fetched now where origin answers, with its next item, as chunk-preflight reads it."""
# A chunk that just merged left the plan on origin. A fetch that fails leaves the plan as last fetched, which chunk-preflight then reads too.
effects.git("fetch", "--quiet", "origin", cwd=root, timeout=FETCH_TIMEOUT)
ref = default_ref(root, FETCH_TIMEOUT, run=effects.git)
@@ -121,13 +119,13 @@ def start_chunks(loop_run: LoopRun, leaving: bool, paths: Paths, env: typing.Map
return config
session = loop_session(loop_run.root, paths.home)
handed = {name: value for name, value in env.items() if name.startswith(HANDED)}
with starting(project_lock(loop_run.root, paths.home, env)) as unlocked:
with starting(project_lock(loop_run.root, paths)) as unlocked:
if unlocked:
return unlocked
windows = tmux.listed(session, effects.tmux)
if refused := refusal(session, windows, loop_run.root, effects.tmux):
return refused
chunks = chunks_to_start(windows, loop_run, leaving, config.parallel_chunks, paths, env, effects)
chunks = chunks_to_start(windows, loop_run, leaving, config, paths, effects)
if isinstance(chunks, AwaitedMerges):
return chunks
for chunk in chunks:
@@ -147,12 +145,12 @@ def refusal(session: str, windows: list[tmux.Listed], root: str, run: tmux.Tmux)
return None
def chunks_to_start(windows: list[tmux.Listed], loop_run: LoopRun, leaving: bool, limit: int, paths: Paths, env: typing.Mapping[str, str], effects: Effects) -> list[str] | AwaitedMerges:
def chunks_to_start(windows: list[tmux.Listed], loop_run: LoopRun, leaving: bool, config: ProjectConfig, paths: Paths, effects: Effects) -> list[str] | AwaitedMerges:
"""The chunks to start beside windows, the session's: the stopped ones room_of restarts, then those of the plan that may_start picks. A plan that cannot be read starts NO_ITEM, as a plan without an item does. AwaitedMerges where no chunk runs or restarts and every item left awaits a person's merge."""
room = room_of(windows, loop_run.chunk, leaving, limit)
room = room_of(windows, loop_run.chunk, leaving, config.parallel_chunks)
if not room.left:
return room.restart
plan = next_plan(loop_run.root, paths.home, env, effects)
plan = next_plan(loop_run.root, config, effects)
if isinstance(plan, Failure):
# Such as in a checkout without a default branch, where chunk-preflight fails too: the worker is told why and finds the facts itself.
say(f"starting a chunk without a plan item, since the plan cannot be read: {plan.reason}", effects)
@@ -164,14 +162,14 @@ def chunks_to_start(windows: list[tmux.Listed], loop_run: LoopRun, leaving: bool
return room.restart + [chunk for chunk in picked if chunk not in room.stopped]
def held_beside(chunk: str, root: str, paths: Paths, env: typing.Mapping[str, str], effects: Effects) -> list[int]:
def held_beside(chunk: str, root: str, paths: Paths, effects: Effects) -> list[int]:
"""The plan items that the project's other chunks hold now, running or stopped, which a chunk starting as `chunk` leaves to them. It waits for a loop that is starting windows, so chunks started together see each other. Where the lock cannot be taken, it reads the windows without it."""
wait_for_starts(root, paths.home, env)
wait_for_starts(root, paths)
others = [window.name for window in tmux.listed(loop_session(root, paths.home), effects.tmux) if window.name != chunk]
return sorted(held_items(others, project_key(root, paths.home), paths.claude_code_transcripts))
def wait_for_starts(root: str, home: pathlib.Path, env: typing.Mapping[str, str]) -> None:
def wait_for_starts(root: str, paths: Paths) -> None:
"""Returns once no loop of the project is starting windows: start_chunks holds the lock file `claims.LOCK` names while it starts them. Where the lock cannot be taken, it returns at once."""
with starting(project_lock(root, home, env)):
with starting(project_lock(root, paths)):
pass
+5 -2
View File
@@ -15,6 +15,7 @@ from release_plan.release_standing import DefaultPlan, LastCut, UNSEEN_RELEASES
from failure import Failure
from loop_effects.doubles import FakeEffects, ran, STAMP
from build_release.chunk import fresh_prompt
from project_config.main import located
from build_release.doubles import NO_CUT, TODO
from loop_state import paths
from plan_store.todo_md import plan_of
@@ -100,9 +101,11 @@ class RouteSources(unittest.TestCase):
self.assertEqual([(item.id, item.awaits_merge) for item in held.plan.items], [(7, ""), (3, "#12 https://github.com/o/r/pull/12"), (1, "")])
self.assertEqual(fake.made("forge")[0][:4], [root, "gh", "pr", "list"])
self.assertIsNone(chunk_start.plan_item(held, None, fake.effects()), "items 7 and 3 wait, so no item of the next release routes the chunk")
window = chunk_windows.next_plan(root, folder.parents[2], {}, dataclasses.replace(fake.effects(), git=git))
config = located(root, folder.parents[2], {})
assert not isinstance(config, Failure), config
window = chunk_windows.next_plan(root, config, dataclasses.replace(fake.effects(), git=git))
self.assertEqual((window.awaits_merge, fake.made("forge")[1][:4]), (True, [root, "gh", "pr", "list"]), "a window starts by the same pick")
stopped = chunk_windows.chunks_to_start([], reload.LoopRun(1, root, "do it", ""), False, 1, paths.paths_from(folder.parents[2], {}), {}, dataclasses.replace(fake.effects(), git=git))
stopped = chunk_windows.chunks_to_start([], reload.LoopRun(1, root, "do it", ""), False, config, paths.paths_from(folder.parents[2], {}), dataclasses.replace(fake.effects(), git=git))
self.assertEqual(stopped, chunk_windows.AwaitedMerges(window.why), "so the loop starts no chunk, and says which pull requests it waits on")
def test_reads_a_plan_outside_the_checkout_as_it_stands_and_stops_without_a_config(self):
+2 -2
View File
@@ -106,7 +106,7 @@ class ChunkWindows(unittest.TestCase):
(folder / f"{chunk_windows.chunk_session('r', 'item-8', held.claude_code_transcripts).id}.jsonl").write_text("".join(json.dumps(line) + "\n" for line in lines))
# Its own window, item-7, holds nothing for it; item-9's stopped chunk holds its item.
fake = FakeEffects(windows="item-7\t0\t@1\nitem-8 ?\t0\t@2\nitem-9\t1\t@3\nitem-10\t0\t@4\n")
self.assertEqual(chunk_windows.held_beside("item-7", "/r", held, {}, fake.effects()), [8, 9, 10, 11])
self.assertEqual(chunk_windows.held_beside("item-7", "/r", held, fake.effects()), [8, 9, 10, 11])
self.assertEqual(fake.tmux_calls, [["list-windows", "-t", "=loop-r", "-F", "#{window_name}\t#{pane_dead}\t#{window_id}"]])
@@ -271,7 +271,7 @@ class StartChunks(unittest.TestCase):
(self.home / ".local" / "state" / "build-release").mkdir(parents=True, exist_ok=True)
(self.home / ".local" / "state" / "build-release" / "claims").write_text("")
fake = FakeEffects(windows="item-7\t0\t@1\nitem-9\t1\t@3\n")
self.assertEqual(chunk_windows.held_beside("item-7", str(self.root), paths.paths_from(self.home, {}), {}, fake.effects()), [9])
self.assertEqual(chunk_windows.held_beside("item-7", str(self.root), paths.paths_from(self.home, {}), fake.effects()), [9])
def test_a_chunk_holds_its_own_item_and_those_on_its_latest_chunk_items_line(self):
with tempfile.TemporaryDirectory() as temp: