List every running loop in loop-inbox, with the ID and tagline of each item its chunk takes

This commit is contained in:
2026-10-29 19:57:11 +01:00
parent 8bddfdc282
commit 9bcfaebb83
16 changed files with 389 additions and 50 deletions
+7 -4
View File
@@ -67,6 +67,8 @@ class Reply:
highest_likelihood_taken_in: int = dataclasses.field(metadata={"description": "The highest L the worker states for a todo.md item it took into this chunk; 0 when it states none."})
# Routes the next cycle's judge and reviewers, as highest_likelihood_taken_in routes the worker.
highest_escape_and_impact_taken_in: int = dataclasses.field(metadata={"description": "The highest E + I the worker states for a todo.md item it took into this chunk; 0 when it states none."})
# Lists the chunk's items in loop-inbox: running_loops.py. A string, since the schema's types are JSON_TYPES.
items_taken_in: str = dataclasses.field(metadata={"description": "The IDs of the todo.md items the worker states this chunk takes, the one it was routed on included, separated by commas, such as `12, 14`; empty when it states none."})
# Routes the worker one rung up, as the judge interrupts or quotes an answer, or on the next cycle: loop_claude/escalation_mark.py.
escalation: str = dataclasses.field(metadata={"description": "Empty unless the chunk is unfinished, interrupt is true or answer quotes a passage, and the worker's run ends asking loop-claude for a higher rung, citing an escalation trigger. Then: a verbatim quote, without elisions, of the transcript passage where the trigger fired, such as a review round's commit title or the worker's report of the finding or failing test. " + escalation_mark.QUOTE_AFTER_STEP + " Never a later mention of the trigger, and never the request itself."})
evidence: str = dataclasses.field(metadata={"description": "A verbatim quote of the one transcript passage the verdict rests on, without elisions: what triggers the interrupt; for a quoted answer, the worker's question; else what shows the chunk finished or the work remaining."})
@@ -112,18 +114,19 @@ def verdict_from(output: object) -> Verdict | Failure:
return Failure(f"the judge's reply has no {name} of type {JSON_TYPES[kind]}")
# An L taken in off its scale counts as none: holding the rung is safe, and three failures would stop an unattended loop.
likelihood = output["highest_likelihood_taken_in"] if 0 <= output["highest_likelihood_taken_in"] <= HIGHEST_L else 0
items = tuple(dict.fromkeys(item for item in map(int, re.findall(r"[0-9]+", output["items_taken_in"])) if item))
if output["interrupt"]:
if not output["question"].strip():
return Failure("the judge interrupted without a question")
return Interrupt(output["evidence"], output["question"], escalation=output["escalation"], highest_likelihood_taken_in=likelihood, release_ready=output["release_ready"])
return Interrupt(output["evidence"], output["question"], escalation=output["escalation"], highest_likelihood_taken_in=likelihood, release_ready=output["release_ready"], items_taken_in=items)
if output["answer"].strip():
if not output["question"].strip():
return Failure("the judge quoted an answer without a question")
return QuotedAnswer(output["evidence"], output["question"], output["answer"], escalation=output["escalation"], highest_likelihood_taken_in=likelihood)
return QuotedAnswer(output["evidence"], output["question"], output["answer"], escalation=output["escalation"], highest_likelihood_taken_in=likelihood, items_taken_in=items)
if output["finished"]:
return Finished(output["evidence"])
escape_and_impact = output["highest_escape_and_impact_taken_in"] if on_its_scale(output["highest_escape_and_impact_taken_in"]) else 0
return Unfinished(output["evidence"], escalation=output["escalation"], highest_likelihood_taken_in=likelihood, highest_escape_and_impact_taken_in=escape_and_impact)
return Unfinished(output["evidence"], escalation=output["escalation"], highest_likelihood_taken_in=likelihood, highest_escape_and_impact_taken_in=escape_and_impact, items_taken_in=items)
def judge(root: str, task: str, premises: str, records: str, entries: list[dict], escalated_at: int, rung: Rung, effects: Effects, keep: typing.Callable[[Rejected], Stop | None]) -> Verdict | Stop:
@@ -164,7 +167,7 @@ def run_judge(root: str, args: list[str], prompt: str, grounds: Grounds, effects
def quotes_checked(verdict: Verdict, grounds: Grounds) -> Verdict:
"""The verdict with its quoted answer and its escalation checked. A quoted answer that neither README.md's premises nor the records hold goes to the human as an interrupt, which keeps the escalation the answer carried. Neither misquote is a Failure, which would otherwise exit an unattended loop."""
if isinstance(verdict, QuotedAnswer) and not verbatim(verdict.answer, grounds.quotable):
verdict = Interrupt(verdict.evidence, verdict.question, escalation=verdict.escalation, highest_likelihood_taken_in=verdict.highest_likelihood_taken_in)
verdict = Interrupt(verdict.evidence, verdict.question, escalation=verdict.escalation, highest_likelihood_taken_in=verdict.highest_likelihood_taken_in, items_taken_in=verdict.items_taken_in)
return escalation_mark.checked(verdict, since=grounds.since_step, shown=grounds.shown)
+18 -2
View File
@@ -42,13 +42,18 @@ class Cycle:
project: Rung | None
# Empty when the previous cycle's verdict was not Unfinished.
unfinished_evidence: str
# The IDs of the items the judge has found the chunk takes, as LoopRun.taken_in.
taken_in: tuple[int, ...]
# Lists taken_in in loop-inbox, as it grows.
show: typing.Callable[[tuple[int, ...]], None]
@dataclasses.dataclass(frozen=True)
class Concluded:
"""How a cycle ended: its verdict, and the route it ended on, which an interrupt's or a quoted answer's escalation may have stepped up from the route it began on."""
"""How a cycle ended: its verdict, the route it ended on, which an interrupt's or a quoted answer's escalation may have stepped up from the route it began on, and the items the judge has found the chunk takes."""
verdict: Finished | Unfinished
route: Route
taken_in: tuple[int, ...] = ()
def run_cycle(cycle: Cycle) -> Stop | Concluded:
@@ -61,10 +66,21 @@ def run_cycle(cycle: Cycle) -> Stop | Concluded:
# Only a ruling's step-up changes the route within a cycle. No transition reads the current route, so Cycle holds it, not the states.
if isinstance(event, Ruled) and event.step_up:
cycle = dataclasses.replace(cycle, route=event.step_up.after)
if isinstance(event, Ruled) and not isinstance(event.verdict, Finished):
cycle = taken_in(cycle, event.verdict.items_taken_in)
state = transition(state, event)
except KeyboardInterrupt:
return stopped(cycle, Stop(130, ""), "Ctrl-C")
return Concluded(state.verdict, cycle.route)
return Concluded(state.verdict, cycle.route, cycle.taken_in)
def taken_in(cycle: Cycle, items: tuple[int, ...]) -> Cycle:
"""cycle with items among those the chunk takes, shown in loop-inbox where any is new."""
grown = tuple(dict.fromkeys(cycle.taken_in + items))
if grown == cycle.taken_in:
return cycle
cycle.show(grown)
return dataclasses.replace(cycle, taken_in=grown)
def ruling_step_up(cycle: Cycle, verdict: Verdict) -> StepUp | None: