Answer prose round 1: 0 🔴, 5 🟡 (0 misread); drop the warning that loop-inbox may still list a question, and make the lock's docstrings, decision, test names and items 253 and 254 true and plain
This commit is contained in:
+10
-10
@@ -1,12 +1,12 @@
|
||||
"""The files by which a loop-claude shows its interrupt in loop-inbox, and takes an answer typed there.
|
||||
|
||||
A waiting loop keeps its ask in <session>.json in Paths.waiting: the question, with an id new for each question.
|
||||
<session> is the worker's session id, so a loop lists one question at a time. The loop holds the session's lock, as
|
||||
session_lock.py describes, while it lists the ask, and removes the ask once the question is answered or the loop stops.
|
||||
loop-inbox lists an ask only while its lock is held, and removes one whose lock is free. The ask's state says whether
|
||||
the loop waits for an answer, or has claude open for it, on the loop's own terminal or in loop-inbox. loop-inbox
|
||||
answers by replacing <session>.answer, which names the ask's id. So an answer meant for an earlier question, or sent as
|
||||
the loop took an answer on its terminal, never answers a later one.
|
||||
<session> is the worker's session id, so a loop lists one question at a time. The loop holds the session's lock while it
|
||||
lists the ask, and removes the ask once the question is answered or the loop stops. loop-inbox lists an ask only while
|
||||
its lock is held, and removes one whose lock is free. The ask's state says whether the loop waits for an answer, or has
|
||||
claude open for it, on the loop's own terminal or in loop-inbox. loop-inbox answers by replacing <session>.answer, which
|
||||
names the ask's id. So an answer meant for an earlier question, or sent as the loop took an answer on its terminal,
|
||||
never answers a later one.
|
||||
|
||||
/talk from loop-inbox goes in three steps, so that only one claude ever holds the worker's session:
|
||||
1. loop-inbox's claim_talk sends ClaudeOpening, with its pid.
|
||||
@@ -121,7 +121,7 @@ def shown(folder: pathlib.Path, ask: Ask, effects: Effects) -> None:
|
||||
|
||||
@contextlib.contextmanager
|
||||
def listed(folder: pathlib.Path, ask: Ask, effects: Effects) -> typing.Iterator[None]:
|
||||
"""Lists ask in loop-inbox while the with block runs, then takes it out, with any answer. A failure only warns: the question is still answered on the loop's terminal, and loop-inbox drops the ask once the loop's process ends."""
|
||||
"""Lists ask in loop-inbox while the with block runs, then takes it out, with any answer. A failure to list it only warns: the question is still answered on the loop's terminal."""
|
||||
with locked(folder, ask.session) as unlocked:
|
||||
if unlocked:
|
||||
say(f"loop-inbox cannot show this question: {unlocked.reason}", effects)
|
||||
@@ -131,8 +131,8 @@ def listed(folder: pathlib.Path, ask: Ask, effects: Effects) -> typing.Iterator[
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if unwithdrawn := withdraw(folder, ask.session):
|
||||
say(f"loop-inbox may still list this question: {unwithdrawn.reason}", effects)
|
||||
# An ask this fails to remove is left to loop-inbox, which stops listing it once the lock is let go, and removes it.
|
||||
withdraw(folder, ask.session)
|
||||
|
||||
|
||||
def waiting(folder: pathlib.Path) -> list[Ask]:
|
||||
@@ -209,7 +209,7 @@ def received(folder: pathlib.Path, ask: Ask) -> Message | None:
|
||||
match data:
|
||||
case {"kind": "Typed", "text": str(text)}:
|
||||
return Typed(text)
|
||||
# A pid of 0 or below would name a process group to the loop's alive.
|
||||
# alive is always True for a pid of 0 or below, which names a process group or every process, so the loop would wait for claude forever.
|
||||
case {"kind": "ClaudeOpening", "pid": int(pid)} if pid > 0:
|
||||
return ClaudeOpening(pid)
|
||||
case {"kind": "ClaudeEnded"}:
|
||||
|
||||
Reference in New Issue
Block a user