Answer architecture round 2: 0 🔴, 3 🟡 (0 misread); the cycle's and the chunk run's suites sit beside their modules, and the claim rule and the model override have one home each
CI / tests (pull_request) Successful in 3m23s
CI / tests (pull_request) Successful in 3m23s
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
"""The chunks of one project that run at once, each in its own tmux window: which may start now, and how each starts (docs/decisions.md → `loop-claude: each chunk runs in its own tmux window`)."""
|
||||
import contextlib
|
||||
import dataclasses
|
||||
import fcntl
|
||||
import pathlib
|
||||
import re
|
||||
import typing
|
||||
|
||||
from touch_predictions.beside import Beside, chunks_beside
|
||||
from chunk_driver.claims import CHUNK_FLAG, CLAIMS, epic_chunks, HANDED, LOCK, project_lock, starting
|
||||
from chunk_driver.claims import CHUNK_FLAG, epic_chunks, HANDED, LOCK, loop_session, project_lock, starting
|
||||
from loop_claude.chunk import chunk_items
|
||||
from git_cli.git_repo import default_ref
|
||||
from loop_effects.effects import Effects, say
|
||||
@@ -115,7 +114,7 @@ def start_chunks(loop_run: LoopRun, leaving: bool, paths: Paths, env: typing.Map
|
||||
config = located(loop_run.root, paths.home)
|
||||
if isinstance(config, Failure):
|
||||
return config
|
||||
session = tmux.session_name(tmux.LOOP, project_key(loop_run.root, paths.home))
|
||||
session = loop_session(loop_run.root, paths.home)
|
||||
handed = {name: value for name, value in env.items() if name.startswith(HANDED)}
|
||||
lock = project_lock(loop_run.root, paths.home)
|
||||
try:
|
||||
@@ -159,13 +158,12 @@ def chunks_to_start(windows: list[tmux.Listed], loop_run: LoopRun, leaving: bool
|
||||
|
||||
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."""
|
||||
key = project_key(root, paths.home)
|
||||
wait_for_starts(paths.home, key)
|
||||
others = [window.name for window in tmux.listed(tmux.session_name(tmux.LOOP, key), effects.tmux) if window.name != chunk]
|
||||
return sorted(held_items(others, key, paths.claude_code_transcripts))
|
||||
wait_for_starts(root, paths.home)
|
||||
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(home: pathlib.Path, key: str) -> None:
|
||||
def wait_for_starts(root: str, home: pathlib.Path) -> None:
|
||||
"""Returns once no loop of the project is starting windows: start_chunks holds LOCK while it starts them. Where the lock cannot be taken, it returns at once."""
|
||||
with contextlib.suppress(OSError), starting(home / CLAIMS / key):
|
||||
with contextlib.suppress(OSError), starting(project_lock(root, home)):
|
||||
pass
|
||||
|
||||
@@ -6,7 +6,7 @@ from chunk_driver.cycle_start import announced_route, cycle_of, project_routing
|
||||
from transcript_archive.location import archive_root, project_archive
|
||||
from loop_claude.loop.routing_check import check_routing
|
||||
from loop_claude.loop.checkout import checkout_root
|
||||
from chunk_driver.claims import CHUNK_FLAG
|
||||
from chunk_driver.claims import CHUNK_FLAG, loop_session
|
||||
from loop_claude.chunk import chunk_items, fresh_prompt
|
||||
from loop_claude.loop.chunk_windows import chunk_session, item_of, start_chunks
|
||||
from loop_claude.loop.chunk_start import chunk_start, plan_item, scored_plan
|
||||
@@ -58,7 +58,7 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc
|
||||
return Stop(1, f"{CHUNK_FLAG} is how loop-claude starts itself in a tmux window; run loop-claude <task>")
|
||||
baseline = fingerprint(launcher)
|
||||
key = project_key(loop_run.root, paths.home)
|
||||
window = tmux.Window(tmux.session_name(tmux.LOOP, key), loop_run.chunk, pane)
|
||||
window = tmux.Window(loop_session(loop_run.root, paths.home), loop_run.chunk, pane)
|
||||
loop = Loop(root=loop_run.root, session=chunk_session(key, loop_run.chunk, paths.claude_code_transcripts), window=window, paths=paths, env=env, launcher=launcher, effects=effects)
|
||||
while True:
|
||||
if stop := exec_if_edited(loop, baseline, loop_run):
|
||||
@@ -86,7 +86,7 @@ def windows_opened(loop_run: LoopRun, env: typing.Mapping[str, str], paths: Path
|
||||
started = start_chunks(loop_run, False, paths, env, launcher, effects)
|
||||
if isinstance(started, Failure):
|
||||
return Stop(1, started.reason)
|
||||
session = tmux.session_name(tmux.LOOP, project_key(loop_run.root, paths.home))
|
||||
session = loop_session(loop_run.root, paths.home)
|
||||
say(f"started {', '.join(started)} in the tmux session {session}" if started else f"the tmux session {session} runs every chunk that may run now, so `{loop_run.task}` started in no new window", effects, stdout=True)
|
||||
if not effects.on_terminal():
|
||||
say(f"not on a terminal; see the chunks with `tmux attach -t ={session}`", effects, stdout=True)
|
||||
|
||||
Reference in New Issue
Block a user