Answer the architect's first round

This commit is contained in:
2026-10-01 23:19:10 +02:00
parent f385b563f0
commit 00446be689
12 changed files with 188 additions and 150 deletions
+5 -4
View File
@@ -13,7 +13,8 @@ T = typing.TypeVar("T")
# A field change stops a running loop at its next reload: the new script rejects the old fields.
@dataclasses.dataclass(frozen=True)
class LoopState:
class LoopRun:
"""One loop-claude run; a reload hands it to the new script as JSON on argv."""
cycle_number: int
root: str
task: str
@@ -43,15 +44,15 @@ def fingerprint(launcher) -> str:
return digest.hexdigest()
def exec_if_edited(launcher, baseline, state, effects: Effects) -> Stop | None:
def exec_if_edited(launcher, baseline, loop_run, effects: Effects) -> Stop | None:
if fingerprint(launcher) == baseline:
return None
try:
trial = effects.run([sys.executable, launcher, "--help"], capture_output=True, text=True)
trial = effects.python([str(launcher), "--help"])
if trial.returncode != 0:
print(f"keeping the running script: {trial.stderr.strip() or f'exit {trial.returncode}'}", file=sys.stderr)
return None
effects.execv(sys.executable, [sys.executable, str(launcher), RELOAD_FLAG, json.dumps(dataclasses.asdict(state))])
effects.execv(sys.executable, [sys.executable, str(launcher), RELOAD_FLAG, json.dumps(dataclasses.asdict(loop_run))])
except OSError as failure:
return Stop(1, f"could not reload loop-claude: {failure.strerror}; rerun loop-claude <task>")
return None