Count a dated CHANGELOG heading as cut without a tag, read only regular files in rule-hook, stamp asks in ISO UTC, give workers the reading rule, and record the 200k window's measurement

This commit is contained in:
2026-11-04 21:11:09 +01:00
parent b1bbc2490a
commit 5b1f903471
19 changed files with 176 additions and 81 deletions
+8 -5
View File
@@ -7,6 +7,7 @@ import pathlib
import typing
from loop_claude.hand_over import ClaudeCommand
from utc_stamp import seconds
if typing.TYPE_CHECKING:
from _typeshed import DataclassInstance
@@ -45,20 +46,22 @@ class Ask:
# The checkout the loop runs in.
root: str
question: str
# When the loop asked, in seconds since the epoch.
asked: float
# When the loop asked, as utc_stamp.utc writes it: an ISO UTC datetime.
asked: str
state: AskState
def read_ask(path: pathlib.Path) -> Ask | None:
"""The ask in path; None where a field has the wrong type, or names another session than path does."""
"""The ask in path; None where a field has the wrong type, asked is no stamp utc_stamp.utc writes, or the ask names another session than path does."""
try:
data = json.loads(path.read_text(encoding="utf-8"))
ask = Ask(**{**data, "state": ask_state(data["state"])})
if not all(isinstance(text, str) for text in (ask.id, ask.session, ask.root, ask.question, ask.asked)) or ask.session != path.stem:
return None
seconds(ask.asked)
except (OSError, ValueError, TypeError, KeyError):
return None
texts = all(isinstance(text, str) for text in (ask.id, ask.session, ask.root, ask.question))
return ask if texts and ask.session == path.stem and isinstance(ask.asked, int | float) else None
return ask
def ask_state(data: object) -> AskState: