Answer prose round 1: 0 🔴, 8 🟡 (0 misread); reword the running loops' docstrings, help and decision, widen the decision's title, keep filed items out of items_taken_in

This commit is contained in:
2026-10-29 20:42:37 +01:00
parent 0a9fe07084
commit ac9d107066
16 changed files with 37 additions and 36 deletions
+13 -13
View File
@@ -1,11 +1,11 @@
"""The files by which a loop-claude shows loop-inbox that it runs, and the todo.md items its chunk takes.
A running loop holds its session's lock (session_lock.py) in Paths.waiting for its whole run, and keeps <session>.running
beside it: its checkout, and the ID and tagline of each item its chunk takes. Those are the item it was routed on, then
the items the judge's latest ruling found the worker took in, each once, with its tagline on the default branch as last
fetched. loop-inbox lists a loop, and its questions (waiting.py), only while its lock is held, so a killed loop drops off
the list though its files stay. loop-inbox removes them: <session>.running through drop_ended_loops here, and the
question through waiting.drop_ended.
A running loop holds its session's lock (session_lock.py) in Paths.waiting for its whole run. Beside the lock it keeps
<session>.running, which holds the loop's checkout and each item its chunk takes, by ID and by its tagline on the default
branch as last fetched. The items are the one the chunk was routed on, then those the judge's latest ruling found the
worker took in, each listed once. loop-inbox lists a loop, and its question (waiting.py), only while the loop holds its
lock. So a killed loop drops off the list, though its files stay until loop-inbox removes them: <session>.running
through drop_ended_loops here, and the question through waiting.drop_ended.
"""
import contextlib
import dataclasses
@@ -20,7 +20,7 @@ from failure import Failure
from todo_table import items
from file_writes import replace_json
# How many times, 0.1 s apart, a loop tries to take its lock: loop-inbox takes it for a moment each time it looks whether the loop has ended.
# How many times, 0.1 s apart, a loop tries to take its lock: loop-inbox takes it for a moment each time it checks whether the loop has ended.
LOCK_TRIES = 10
@@ -28,7 +28,7 @@ LOCK_TRIES = 10
class Taken:
"""A todo.md item a chunk takes."""
id: int
# The item's tagline without its bold marks; empty where the default branch's todo.md holds no such item.
# The item's tagline without its bold marks; empty where the default branch's todo.md can't be read or holds no such item.
tagline: str
@@ -37,7 +37,7 @@ class RunningLoop:
session: str
# The checkout the loop runs in.
root: str
# The routed item first; empty before the chunk names one.
# The routed item first; empty until the chunk has an item.
items: tuple[Taken, ...]
@@ -46,8 +46,8 @@ Show = typing.Callable[[tuple[Taken, ...]], None]
@dataclasses.dataclass(frozen=True)
class Listed:
"""What a running loop shows loop-inbox through."""
# Where the loop keeps its questions: Paths.waiting while it holds its lock. Else a folder of its own, which loop-inbox doesn't read, so the loop never touches the questions of the loop that holds the lock.
"""How a running loop shows itself in loop-inbox."""
# Where the loop keeps its questions: Paths.waiting where it holds its session's lock. Where another loop on the session holds the lock, a folder of its own that loop-inbox doesn't read, so this loop never touches the other's questions.
folder: pathlib.Path
show: Show
@@ -81,7 +81,7 @@ def shown_running(folder: pathlib.Path, session: str, root: str, effects: Effect
def locked_soon(stack: contextlib.ExitStack, folder: pathlib.Path, session: str, effects: Effects) -> Failure | None:
"""Holds the session's lock until stack closes, trying LOCK_TRIES times; the last failure where every try failed."""
"""Holds the session's lock until stack closes, trying LOCK_TRIES times; returns None once it holds the lock, else the last try's failure."""
for _ in range(LOCK_TRIES):
attempt = contextlib.ExitStack()
unlocked = attempt.enter_context(held(folder, session))
@@ -130,7 +130,7 @@ def is_item(item: object) -> bool:
def taken_items(todo: str | Failure, routed: int, taken_in: tuple[int, ...]) -> tuple[Taken, ...]:
"""The items a chunk takes, as the module docstring says, with their taglines from todo, the default branch's todo.md. routed is 0 for none."""
"""The items a chunk takes, as the module docstring says, with their taglines from todo, the default branch's todo.md. routed, the item the chunk was routed on, is 0 for none."""
found = items(todo) if isinstance(todo, str) else []
taglines = {item.id: item.tagline.removeprefix("**").removesuffix("**") for item in found} if isinstance(found, list) else {}
ids = dict.fromkeys(([routed] if routed else []) + list(taken_in))