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:
@@ -5,9 +5,11 @@ usage: loop-claude <task>
|
||||
Run it anywhere inside a project checkout whose README.md has ## Goals and ## Audience, the
|
||||
premises; the task runs at the checkout root. Each cycle a worker runs the task. A chunk's first
|
||||
worker prompt also quotes the premises, which choose between ways to deliver the chunk's todo.md
|
||||
items, or else the task, and never widen them. Before that first worker, loop-claude runs
|
||||
bin/chunk-preflight at the checkout root, which finds the chunk's mechanical facts and makes its
|
||||
worktree; the prompt quotes what it printed, or why it could not run. A judge then reads the transcript's end, the premises, and the records: the project's AGENTS.md and docs/decisions.md,
|
||||
items, or else the task, and never widen them. As a chunk starts, before it is routed, loop-claude
|
||||
runs bin/chunk-preflight (bin/chunk_preflight/), which fast-forwards the checkout and finds the
|
||||
chunk's facts; chunk-preflight --help lists them, and prompts.preflight_facts in
|
||||
bin/loop_claude/cycle/prompts.py quotes them in the first prompt. A judge then reads the
|
||||
transcript's end, the premises, and the records: the project's AGENTS.md and docs/decisions.md,
|
||||
and the human's ~/.claude/CLAUDE.md, ~/.claude/rules/*.md and
|
||||
~/.claude/skills/larv-review/standards/*.md, where they exist. It rules whether the chunk, the work
|
||||
of one PR, is finished. A chunk stays unfinished until each answer the human typed in it that a
|
||||
@@ -46,8 +48,9 @@ run, is asked for one. LOOP_CLAUDE_JUDGE_MODEL overrides it for the judge, LOOP_
|
||||
for the worker and the interrupt; with both set, nothing is asked.
|
||||
|
||||
Where that model is on the routing ladder (bin/model_routing/ladder.py), the worker and the
|
||||
interrupt run on one of the ladder's rungs: a model at an effort. As a chunk starts, todo.md's top
|
||||
item in the next release that does not wait routes it: an item waits while it is marked question,
|
||||
interrupt run on one of the ladder's rungs: a model at an effort. As a chunk starts, the checkout's
|
||||
todo.md, read once chunk-preflight has run, routes it, so routing and the preflight's facts name one
|
||||
item: the next release's top item that does not wait. An item waits while it is marked question,
|
||||
or while an item that blocks it is still in the table. The item's L picks the worker's rung,
|
||||
stepping from the model's cheapest rung by WORKER_STEPS in bin/model_routing/ladder.py, below it
|
||||
for a low L; without such an item, or with its L, E or I unscored, the chunk runs on the model's
|
||||
@@ -55,9 +58,9 @@ cheapest rung. The
|
||||
item's E + I picks the reviewers' rung, stepping up from the cheapest rung by REVIEW_STEPS there,
|
||||
never below the worker's rung. The worker's first prompt names the rung and the item, and asks the
|
||||
worker to name each item the chunk takes, with its L and E + I, and to count the item's size again
|
||||
once it has read the code: a re-score whose L picks a higher rung is an escalation trigger. The prompt names the rung of each
|
||||
review that runs on a rung other than the worker's: the reviewers' rung for the reviewers, and the
|
||||
cheapest rung for each comprehension seat and the security pass. It also names the reviewers' rung
|
||||
once it has read the code (prompts.recount). The prompt names the rung of each review that runs on
|
||||
a rung other than the worker's: the reviewers' rung for the reviewers, and the cheapest rung for
|
||||
each comprehension seat and the security pass. It also names the reviewers' rung
|
||||
each higher E + I picks, so the worker reviews an item it takes in on that rung in the same run.
|
||||
When the worker runs below the cheapest rung, the prompt has it launch each subagent that files or
|
||||
scores todo.md items on the rung subagent-rung --plan prints. The prompt after
|
||||
@@ -161,10 +164,11 @@ from transcript_archive import outcomes
|
||||
from loop_claude.paths import Paths
|
||||
from project_key import project_key
|
||||
from model_routing.ladder import project_rung, Rung
|
||||
from loop_claude.cycle import prompts
|
||||
from loop_claude.project.premises import read_premises
|
||||
from loop_claude.project.records import read_records
|
||||
from model_routing.route import Route, route_from
|
||||
from claude_code.session import Session, session_named, transcript_file
|
||||
from claude_code.session import Session, session_named, session_open, transcript_file
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
|
||||
@@ -191,6 +195,8 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc
|
||||
if stop := exec_if_edited(launcher, baseline, loop_run, effects):
|
||||
return stop
|
||||
loop_run = dataclasses.replace(loop_run, cycle_number=loop_run.cycle_number + 1)
|
||||
# First, so the premises, the records and the plan item routing reads are the checkout's as the preflight fast-forwarded it.
|
||||
facts = "" if session_open(session) else chunk_facts(launcher.with_name("chunk-preflight"), loop_run.root, effects)
|
||||
premises = read_premises(loop_run.root)
|
||||
if isinstance(premises, Stop):
|
||||
return premises
|
||||
@@ -205,7 +211,7 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc
|
||||
loop_run = routed(loop_run, anchor, lambda: archived_route(archive_folder, session), lambda: plan_item(root))
|
||||
route = loop_run.route or Route(Rung(models.worker))
|
||||
print(f"\n=== cycle {loop_run.cycle_number}, worker on {route.rung} ===", flush=True)
|
||||
verdict = run_cycle(Cycle(anchor=anchor, effects=effects, judge_model=models.judge, paths=paths, premises=premises, project_archive=archive_folder, records=records, root=loop_run.root, route=route, session=session, task=loop_run.task, unfinished_evidence=loop_run.unfinished_evidence))
|
||||
verdict = run_cycle(Cycle(anchor=anchor, effects=effects, facts=facts, judge_model=models.judge, paths=paths, premises=premises, project_archive=archive_folder, records=records, root=loop_run.root, route=route, session=session, task=loop_run.task, unfinished_evidence=loop_run.unfinished_evidence))
|
||||
if isinstance(verdict, Stop):
|
||||
return verdict
|
||||
before, loop_run = loop_run.route, after_verdict(loop_run, anchor, verdict)
|
||||
@@ -250,8 +256,19 @@ def archived_route(archive_folder: pathlib.Path, session: Session) -> Route | No
|
||||
return route_from(worker) if worker else None
|
||||
|
||||
|
||||
def chunk_facts(preflight: pathlib.Path, root: str, effects: Effects) -> str:
|
||||
"""What chunk-preflight printed at the checkout root, for a fresh worker's prompt, or why it could not run."""
|
||||
try:
|
||||
done = effects.python([str(preflight)], 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 plan_item(root: str) -> Item | None:
|
||||
"""The item that routes a chunk; None without one, so the chunk runs on the project's rung."""
|
||||
"""The item that routes a chunk, from the checkout's todo.md: the file chunk-preflight reads, and the pick, todo_table.next_item, it makes. None without one, so the chunk runs on the project's rung."""
|
||||
try:
|
||||
item = routed_item(pathlib.Path(root, "todo.md").read_text(encoding="utf-8"))
|
||||
except FileNotFoundError:
|
||||
|
||||
Reference in New Issue
Block a user