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
+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: