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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user