Answer architecture round 1: 0 🔴, 7 🟡 (0 misread); hold one lock per loop for its whole run, group the judge's readings of the items taken in, list them as given
This commit is contained in:
@@ -42,18 +42,15 @@ 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]
|
||||
# Lists in loop-inbox the IDs of the items each ruling finds the chunk takes.
|
||||
show_taken_in: typing.Callable[[tuple[int, ...]], None]
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Concluded:
|
||||
"""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."""
|
||||
"""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."""
|
||||
verdict: Finished | Unfinished
|
||||
route: Route
|
||||
taken_in: tuple[int, ...] = ()
|
||||
|
||||
|
||||
def run_cycle(cycle: Cycle) -> Stop | Concluded:
|
||||
@@ -67,20 +64,11 @@ def run_cycle(cycle: Cycle) -> Stop | Concluded:
|
||||
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)
|
||||
cycle.show_taken_in(event.verdict.taken_in.items)
|
||||
state = transition(state, event)
|
||||
except KeyboardInterrupt:
|
||||
return stopped(cycle, Stop(130, ""), "Ctrl-C")
|
||||
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)
|
||||
return Concluded(state.verdict, cycle.route)
|
||||
|
||||
|
||||
def ruling_step_up(cycle: Cycle, verdict: Verdict) -> StepUp | None:
|
||||
|
||||
Reference in New Issue
Block a user