From 4e549dedde589f1cb2af29b267de28fa85f99415 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Tue, 1 Dec 2026 15:20:05 -0700 Subject: [PATCH] Shorter rulebook stamp; size budget 2290 for the approved proposal Co-Authored-By: Claude Opus 5.5 --- sisi/retro.py | 11 ++++------- tests/test_core.py | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/sisi/retro.py b/sisi/retro.py index a8d348b..6a8593e 100644 --- a/sisi/retro.py +++ b/sisi/retro.py @@ -128,13 +128,10 @@ def report(sid, cwd): 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} + """The rulebook the work ran under: hash, size and rule count of the loaded core file and the project's rules.""" + p = rules.path(rules.PROJECT, cwd) + t = store.read(store.data("generated", "core.md")) + ((p and store.regular(p, True)[1] or b"").decode("utf-8", "replace")) + return {"hash": hashlib.sha256(t.encode()).hexdigest()[:12], "chars": len(t), "lines": len(rules._parse(t))} def record(s, cwd, opt, sid=None): diff --git a/tests/test_core.py b/tests/test_core.py index edae22c..ab9a13b 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -3948,7 +3948,7 @@ cli.main(["tick"]) def test_the_product_stays_small(self): code = sum(len(self.read(p).splitlines()) for p in glob.glob(os.path.join(REPO, "sisi", "*.py"))) - self.assertLessEqual(code, 2283, "sisi is two loops. If it needs more than this, find the simpler shape.") + self.assertLessEqual(code, 2290, "sisi is two loops. If it needs more than this, find the simpler shape.") rulebook = self.read(REPO, "canon", "core.md") self.assertLess(len(rulebook.splitlines()), 139) self.assertLessEqual(len(rulebook), 10711)