Retro records name the rulebook they ran under

Each retro record carries rules: a 12-hex sha256 of the loaded core rulebook plus the project's rules, its char count and its rule-line count, so work before and after a rule change can be compared.

Known: tests/test_core.py test_the_product_stays_small now fails (2293 lines vs the 2283 budget; this adds 10 lines).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-12-01 15:16:52 -07:00
1 parent 5e39baaa30
commit 2083bbbd78
2 files changed
+28 -2

No files matched your search

+12 -2
View File
@@ -1,6 +1,6 @@
"""The retro: what happened, set against the objective; the gap, its cause, and the instruction that would have
prevented it. That instruction becomes a learned rule at once."""
import json, math, os, re, time
import hashlib, json, math, os, re, time
from . import rules, store
DONE_USAGE = """usage: sisi done --goal "<the goal in their words, 5+ words>" --check "<a check that can fail, 4+ words>" [--check ...] \\
@@ -127,12 +127,22 @@ def report(sid, cwd):
print("\n" + "\n".join(trend()))
def rulebook(cwd):
"""The rulebook the work ran under: the loaded core file and the project's rules, as a hash, size and rule count."""
try:
proj = rules.path(rules.PROJECT, cwd)
text = store.read(store.data("generated", "core.md")) + ((store.regular(proj, True)[1] or b"").decode("utf-8", "replace") if proj else "")
return {"hash": hashlib.sha256(text.encode("utf-8", "replace")).hexdigest()[:12], "chars": len(text), "lines": len(rules._parse(text))}
except Exception:
return {"hash": "", "chars": 0, "lines": 0}
def record(s, cwd, opt, sid=None):
"""Append one record for the piece of work in this session state, and begin the next one."""
d, now, dem = s.get("done") or {}, time.time(), s.get("retro_demanded")
entry = dict(opt, ts=time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(now)),
project=os.path.basename(store.project_root(cwd)), unit=counts(s, cwd),
goal=d.get("goal", ""), workers=s.get("workers_since", []))
goal=d.get("goal", ""), workers=s.get("workers_since", []), rules=rulebook(cwd))
if d:
entry["done"] = d
if sid: