Answer stability round 1: 0 🔴, 6 🟡 (0 misread); slim chunk_figures, type a call's kind, keep the state through replace_json, add the missing state and raise tests

This commit is contained in:
2026-11-08 20:02:58 +01:00
parent 0c93614f4a
commit f0ff379251
9 changed files with 73 additions and 33 deletions
+6 -5
View File
@@ -1,4 +1,6 @@
"""What loop-claude keeps at the archive's root between measurements: the cycle it last measured at and each call it raised, as fields in STATE, and the calls raised as lines the human reads in RAISED, where a reset is written: docs/decisions.md → `routing:`."""
"""What loop-claude keeps at the archive's root between measurements: docs/decisions.md → `routing: loop-claude measures review rounds…`.
STATE holds, as fields loop-claude reads back, the cycle it last measured at and each call it raised. RAISED lists the raised calls for the human to read. A chunk appends a reset to RAISED by hand, as AGENTS.md says, and loop-claude reads the resets from there."""
import dataclasses
import json
import pathlib
@@ -6,7 +8,7 @@ import re
from routing_figures.calls import Call, SENTENCES
from failure import Failure
from file_writes import replace_file
from file_writes import replace_file, replace_json
from utc_stamp import STAMPED
CYCLES_PER_CHECK = 20
@@ -53,7 +55,7 @@ def read_state(root: pathlib.Path) -> State | Failure:
return State(0, ())
except (OSError, UnicodeDecodeError) as failure:
return Failure(f"could not read {root / STATE}: {failure}")
return decoded(text) or Failure(f"could not read {root / STATE}: not the shape its comment in routing_figures/state.py shows")
return decoded(text) or Failure(f"could not read {root / STATE}: not the shape the comment on STATE in bin/routing_figures/state.py shows")
def decoded(text: str) -> State | None:
@@ -77,8 +79,7 @@ def stamped(entry: object) -> Stamped | None:
def write_state(root: pathlib.Path, state: State) -> Failure | None:
text = json.dumps({"measured_at": state.measured_at, "raised": [{"at": entry.at, "kind": entry.call.kind, "subjects": list(entry.call.subjects)} for entry in state.raised]}, indent="\t")
unwritten = replace_file(root / STATE, (text + "\n").encode())
unwritten = replace_json(root / STATE, {"measured_at": state.measured_at, "raised": [{"at": entry.at, "kind": entry.call.kind, "subjects": list(entry.call.subjects)} for entry in state.raised]}, indent="\t")
return Failure(f"could not write {root / STATE}: {unwritten.reason}") if unwritten else None