List every running loop in loop-inbox, with the ID and tagline of each item its chunk takes
This commit is contained in:
@@ -33,6 +33,9 @@ A release ready to cut opens that session on the terminal at once, since only th
|
||||
loop-inbox lists it too. Before claude opens, the checkout and each of its worktrees are marked
|
||||
trusted in ~/.claude.json. While claude is open, Ctrl-C reaches it alone, and the loop goes on.
|
||||
|
||||
While it runs, loop-claude also lists itself in loop-inbox, with the todo.md items its chunk takes:
|
||||
the item it was routed on, then those the judge finds the worker took in.
|
||||
|
||||
As a chunk starts, before it is routed, loop-claude runs bin/chunk-preflight (bin/chunk_preflight/),
|
||||
which finds the chunk's facts and makes its worktree; chunk-preflight --help lists them, and
|
||||
prompts.preflight_facts in bin/loop_claude/cycle/prompts.py quotes them in the first prompt. A
|
||||
@@ -130,6 +133,7 @@ from transcript_archive.location import archive_root, project_archive
|
||||
from loop_claude.cycle.run import archived_stop, Concluded, Cycle, run_cycle
|
||||
from loop_claude.loop.routing_check import check_routing
|
||||
from loop_claude.project.checkout import checkout_root
|
||||
from loop_claude.running_loops import chunk_items, Show, shown_running, Taken
|
||||
from loop_claude.loop.reload import decode_handed, exec_if_edited, fingerprint, LoopRun, RELOAD_FLAG
|
||||
from chunk_pick import default_plan, DefaultPlan
|
||||
from git_repo import default_ref
|
||||
@@ -137,7 +141,7 @@ from loop_claude.effects import Effects, say
|
||||
from failure import Failure
|
||||
from loop_claude.verdicts import Finished, Unfinished
|
||||
from loop_claude.project.model_choice import get_or_ask_models
|
||||
from todo_table import Item
|
||||
from todo_table import Item, items
|
||||
from transcript_archive.read import latest_worker
|
||||
from loop_claude.stop import needs_human, Stop
|
||||
from transcript_archive import outcomes
|
||||
@@ -175,6 +179,12 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc
|
||||
archive_folder = project_archive(loop_run.root, paths.home, env)
|
||||
# "A " is the human's cue in the session picker that the session is the loop's.
|
||||
session = session_named(f"A {key} loop-claude", paths.claude_code_transcripts)
|
||||
with shown_running(paths.waiting, str(session.id), loop_run.root, effects) as show:
|
||||
return cycles(loop_run, env, paths, launcher, baseline, key, archive_folder, session, show, effects)
|
||||
|
||||
|
||||
def cycles(loop_run: LoopRun, env: typing.Mapping[str, str], paths: Paths, launcher: pathlib.Path, baseline: str, key: str, archive_folder: pathlib.Path, session: Session, show: Show, effects: Effects) -> Stop:
|
||||
"""Runs cycles until one stops the loop, listing in loop-inbox, through show, the items each chunk takes."""
|
||||
while True:
|
||||
if stop := exec_if_edited(launcher, baseline, loop_run, effects):
|
||||
return stop
|
||||
@@ -193,7 +203,9 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc
|
||||
project = project_rung(models.worker)
|
||||
route = routed(loop_run.route, project, models.worker, lambda: archived_route(archive_folder, session, effects), item)
|
||||
say(f"\n=== cycle {loop_run.cycle_number}, worker on {route.rung} ===", effects, stdout=True)
|
||||
concluded = run_cycle(Cycle(effects=effects, facts=facts, judge_model=models.judge, paths=paths, premises=premises, project=project, project_archive=archive_folder, records=records, root=loop_run.root, route=route, session=session, task=loop_run.task, unfinished_evidence=loop_run.unfinished_evidence))
|
||||
show_taken = shown_items(show, loop_run.root, route.item)
|
||||
show_taken(loop_run.taken_in)
|
||||
concluded = run_cycle(Cycle(effects=effects, facts=facts, judge_model=models.judge, paths=paths, premises=premises, project=project, project_archive=archive_folder, records=records, root=loop_run.root, route=route, session=session, show=show_taken, taken_in=loop_run.taken_in, task=loop_run.task, unfinished_evidence=loop_run.unfinished_evidence))
|
||||
if isinstance(concluded, Stop):
|
||||
return concluded
|
||||
closed = closed_cycle(loop_run, project, concluded, archive_folder, session, effects)
|
||||
@@ -204,6 +216,18 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc
|
||||
return stop
|
||||
|
||||
|
||||
def shown_items(show: Show, root: str, routed: int) -> typing.Callable[[tuple[int, ...]], None]:
|
||||
"""What lists in loop-inbox the items a chunk takes: routed, the item it was routed on, 0 for none, then those taken in, each with its tagline."""
|
||||
return lambda taken_in: show(taken_items(fetched_plan(root), chunk_items(routed, taken_in)))
|
||||
|
||||
|
||||
def taken_items(plan: DefaultPlan | Failure, ids: tuple[int, ...]) -> tuple[Taken, ...]:
|
||||
"""Each item of ids with its tagline on the default branch, as last fetched; empty where that todo.md cannot be read or doesn't hold the item."""
|
||||
found = items(plan.todo) if isinstance(plan, DefaultPlan) and isinstance(plan.todo, str) else []
|
||||
taglines = {item.id: item.tagline.removeprefix("**").removesuffix("**") for item in found} if isinstance(found, list) else {}
|
||||
return tuple(Taken(id_, taglines.get(id_, "")) for id_ in ids)
|
||||
|
||||
|
||||
def routed(route: Route | None, project: Rung | None, model: str, archived: typing.Callable[[], Route | None], item: typing.Callable[[], Item | None]) -> Route:
|
||||
"""The route the cycle runs on. project is the project's rung, and model the project's model.
|
||||
|
||||
@@ -234,12 +258,12 @@ def reached_limit(loop_run: LoopRun) -> Stop | None:
|
||||
|
||||
|
||||
def after_verdict(loop_run: LoopRun, project: Rung | None, concluded: Concluded) -> LoopRun:
|
||||
"""The loop run the next cycle starts from. A finished chunk drops its route and its run of unfinished verdicts. An unfinished one takes the route stepped_route makes, the evidence the judge gave for the verdict, and counts the verdict."""
|
||||
"""The loop run the next cycle starts from. A finished chunk drops its route, its run of unfinished verdicts and the items it took in. An unfinished one takes the route stepped_route makes, the evidence the judge gave for the verdict and the items its cycle ended with, and counts the verdict."""
|
||||
verdict = concluded.verdict
|
||||
if isinstance(verdict, Finished):
|
||||
return dataclasses.replace(loop_run, route=None, unfinished_evidence="", unfinished_run=0)
|
||||
return dataclasses.replace(loop_run, route=None, unfinished_evidence="", unfinished_run=0, taken_in=())
|
||||
route = stepped_route(project, concluded.route, verdict)
|
||||
return dataclasses.replace(loop_run, route=route, unfinished_evidence=verdict.evidence, unfinished_run=loop_run.unfinished_run + 1)
|
||||
return dataclasses.replace(loop_run, route=route, unfinished_evidence=verdict.evidence, unfinished_run=loop_run.unfinished_run + 1, taken_in=concluded.taken_in)
|
||||
|
||||
|
||||
def stepped_route(project: Rung | None, ended_on: Route, verdict: Unfinished) -> Route:
|
||||
|
||||
Reference in New Issue
Block a user