Answer architecture round 1: 2 🔴, 4 🟡; route and preflight on the one checkout todo.md the preflight fast-forwards, split the preflight into gathering and a pure render, move bundle_candidates onto todo_table.waiting, run the preflight through the python effect with a timeout, give the re-score sentence its own function, and point loop-claude's help at the modules

This commit is contained in:
2026-10-17 01:03:15 +02:00
parent 8b3a5a32a3
commit ecbb7a7cda
17 changed files with 657 additions and 268 deletions
+5 -15
View File
@@ -25,6 +25,8 @@ from model_routing import worker_rungs
@dataclasses.dataclass(frozen=True)
class Cycle:
effects: Effects
# What chunk-preflight found, or why it could not run, for a fresh worker's prompt; empty when the session was open as the cycle began.
facts: str
judge_model: str
paths: Paths
premises: str
@@ -84,9 +86,8 @@ def work(cycle: Cycle, answered: QuotedAnswer | None) -> WorkerRan | Stop:
print(f"\n=== {prompts.QUOTE_SOURCES} answered: {answered.question} ===\n{answered.answer}", flush=True)
if stop := keep_answer(cycle, answered):
return stop
facts = preflight(cycle) if answered is None and not session_open(cycle.session) else ""
# worker_start runs inside the lambda: a failed attempt may have opened the session.
if stop := retried("worker", lambda: run_worker(cycle.root, worker_start(cycle, answered, facts), worker_environment(cycle), cycle.effects), cycle.effects):
if stop := retried("worker", lambda: run_worker(cycle.root, worker_start(cycle, answered), worker_environment(cycle), cycle.effects), cycle.effects):
return stop
path = transcript_file(cycle.session)
return WorkerRan(path) if path is not None else Stop(1, f"claude left no transcript for session {cycle.session.id}")
@@ -97,23 +98,12 @@ def worker_environment(cycle: Cycle) -> dict[str, str]:
return worker_rungs.environment(cycle.anchor, cycle.route)
def preflight(cycle: Cycle) -> str:
"""The facts chunk-preflight printed for a fresh worker, or why it could not run them; run once per chunk start, outside the worker's retries."""
try:
done = cycle.effects.preflight(cycle.root)
except OSError as failure:
return prompts.preflight_failed(str(failure))
if done.returncode:
return prompts.preflight_failed(done.stderr.strip() or f"it exited {done.returncode}")
return prompts.preflight_facts(done.stdout.strip())
def worker_start(cycle: Cycle, answered: QuotedAnswer | None, facts: str) -> list[str]:
def worker_start(cycle: Cycle, answered: QuotedAnswer | None) -> list[str]:
if answered is not None:
return worker_args(cycle.session, cycle.route.rung, prompts.answered(answered.question, answered.answer), resume=True)
if session_open(cycle.session):
return worker_args(cycle.session, cycle.route.rung, prompts.resumed(cycle.unfinished_evidence, cycle.route, cycle.anchor), resume=True)
return worker_args(cycle.session, cycle.route.rung, prompts.fresh(cycle.task, cycle.premises, cycle.route, cycle.anchor, facts), resume=False)
return worker_args(cycle.session, cycle.route.rung, prompts.fresh(cycle.task, cycle.premises, cycle.route, cycle.anchor, cycle.facts), resume=False)
def keep_answer(cycle: Cycle, answered: QuotedAnswer) -> Stop | None: