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:
2026-10-29 18:33:29 +01:00
parent 74a4a90b10
commit bf78fedc54
7 changed files with 25 additions and 26 deletions
+5 -6
View File
@@ -1,8 +1,7 @@
"""The lock a loop-claude holds on its worker's session while loop-inbox lists its question, which tells loop-inbox the loop still runs.
"""The lock a loop-claude holds on its worker's session while loop-inbox lists the session's question. loop-inbox reads a held lock as a loop that still runs.
The lock is <session>.lock, held with flock. The kernel frees it however the loop ends, killed included, where a process
id the system may hand out again cannot tell a loop that runs from one that was killed. The lock file stays once the
loop ends: docs/decisions.md → `loop-inbox: …` says why.
The lock is <session>.lock, held with flock, which the kernel frees however the loop ends, killed included. The lock
file stays once the loop ends: docs/decisions.md → `loop-inbox: …` says why.
"""
import contextlib
import fcntl
@@ -19,7 +18,7 @@ def lock_file(folder: pathlib.Path, session: str) -> pathlib.Path:
@contextlib.contextmanager
def locked(folder: pathlib.Path, session: str) -> typing.Iterator[Failure | None]:
"""Holds the session's lock while the with block runs; a Failure where it cannot. loop-inbox holds it for a moment where it finds the session's question still listed, so a loop starting after another was killed may meet it held."""
"""Holds the session's lock while the with block runs, or yields a Failure where it cannot. loop-inbox's drop_ended takes the lock for a moment on each ask still on disk, so a loop may find it held."""
try:
make_private(folder)
except OSError as failure:
@@ -44,7 +43,7 @@ def locked(folder: pathlib.Path, session: str) -> typing.Iterator[Failure | None
def running(folder: pathlib.Path, session: str) -> bool:
"""Whether a loop holds the session's lock; False also where the lock cannot be read."""
"""Whether a loop holds the session's lock; False also where the lock file cannot be opened or locked."""
try:
with open(lock_file(folder, session)) as handle:
fcntl.flock(handle, fcntl.LOCK_SH | fcntl.LOCK_NB)