Shorter README with nothing that goes stale; honest rulebook budget; complete cycle instructions
ci / tests (macos-latest, python 3.10) (push) Canceled after 0s
ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.10) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s

README cut by about 40 percent, with tests that refuse version numbers,
counts, years and a word ceiling. The rulebook budget now counts characters
as well as lines. Folded lessons no longer count as loose notes, reading a
lesson no longer invalidates a cycle, and the cycle brief answers the twenty
gaps the first real cycle reported. Adds `sisi cycle check`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-23 03:16:06 -07:00
1 parent 4a2905ba80
commit e5b603486b
12 files changed
+1026 -317

No files matched your search

+244
View File
@@ -980,5 +980,249 @@ class ImproveFromUseTests(LearningCase):
self.assertEqual(self.lesson(lid)["strength"], 3)
RECIPE_TEXT = """---
id: curated-record-change
title: Editing a curated record
applies_to: Editing a sourced record in a curated dataset.
---
## Done means
- The record is edited and its source is cited.
## Checks
- Show the edited record matches its source.
## Common false finishes
- Editing without checking the source.
"""
class CycleGapTests(LearningCase):
def test_gap01_brief_full_text_and_show_hint(self):
lid = self.mk(change="Parser readiness probes beat fixed sleeps for servers always",
moment="the parser server waited at step 4")
out = cycle.brief_text()
self.assertIn("Parser readiness probes beat fixed sleeps", out)
self.assertIn("sisi lessons show ID", out) # reading instruction present
old = cycle.BRIEF_TEXT_BUDGET
cycle.BRIEF_TEXT_BUDGET = 10
try:
out2 = cycle.brief_text()
finally:
cycle.BRIEF_TEXT_BUDGET = old
self.assertIn("`sisi lessons show %d`" % lid, out2)
self.assertIn("text budget", out2)
def test_gap02_reading_does_not_stale_base_and_stale_is_precise(self):
lid = self.mk()
base = cycle.base_version()
self.sisi("lessons", "show", str(lid)) # a read: counters only
retro.record_shown([lid], "done-for", "s")
doc = self.cycle_doc(notes=[{"lesson": lid, "action": "keep"}])
# cycle_doc recomputes base; rebuild with the original base
d = {"version": 1, "base": base, "summary": "x", "notes": [{"lesson": lid, "action": "keep"}]}
p = os.path.join(self.tmp, "g2.json")
with open(p, "w") as f:
json.dump(d, f)
self.assertEqual(self.sisi("cycle", "apply", p).returncode, 0)
# now a real change stales a fresh brief, precisely
lid2 = self.mk(change="Second parser readiness lesson for stale check", moment="second wait at step 2")
base2 = cycle.base_version()
con = retro.connect()
con.execute("UPDATE lessons SET status='retired' WHERE id=?", (lid2,))
con.commit(); con.close()
d2 = {"version": 1, "base": base2, "summary": "x", "notes": [{"lesson": lid2, "action": "keep"}]}
p2 = os.path.join(self.tmp, "g2b.json")
with open(p2, "w") as f:
json.dump(d2, f)
r = self.sisi("cycle", "apply", p2)
self.assertEqual(r.returncode, 1, r.stdout)
self.assertIn("lesson #%d changed" % lid2, r.stdout)
self.assertNotIn("likely another cycle", r.stdout)
def test_gap03_new_lesson_does_not_block_apply(self):
lid = self.mk()
base = cycle.base_version()
self.mk(change="Brand new parser lesson arriving mid cycle", moment="new wait at step 5")
d = {"version": 1, "base": base, "summary": "x", "notes": [{"lesson": lid, "action": "keep"}]}
p = os.path.join(self.tmp, "g3.json")
with open(p, "w") as f:
json.dump(d, f)
self.assertEqual(self.sisi("cycle", "apply", p).returncode, 0)
def test_gap04_create_entry_and_keep_as_draft(self):
lid = self.mk(change_kind="recipe", target="curated-record-change",
change="Add a recipe 'curated-record-change' for editing a sourced record in a curated dataset")
doc = self.cycle_doc(notes=[{"lesson": lid, "action": "create-entry", "into": "curated-record-change",
"entry_kind": "recipe", "entry_text": RECIPE_TEXT}])
r = self.sisi("cycle", "apply", doc)
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
self.assertTrue(os.path.exists(paths.overlay_dir("done", "curated-record-change.md")))
from sisi import verifiers as V
self.assertIn("curated-record-change", [e["id"] for e in V.load_recipes()])
lid2 = self.mk(change="A draft-only parser readiness lesson", moment="draft wait at step 2")
bad = self.sisi("cycle", "apply", self.cycle_doc(
notes=[{"lesson": lid2, "action": "keep-as-draft"}]))
self.assertEqual(bad.returncode, 1)
self.assertIn("needs a reason", bad.stdout)
self.assertIn("create-entry", cycle.brief_text())
self.assertIn("keep-as-draft", cycle.HELP_TEXT)
def test_gap05_fold_into_entry_appends_field_note(self):
lid = self.mk(change="Parser recipes need a readiness probe before server work",
moment="server wait at step 3")
doc = self.cycle_doc(notes=[{"lesson": lid, "action": "fold-into-entry", "into": "parser-or-codec"}])
self.assertEqual(self.sisi("cycle", "apply", doc).returncode, 0)
text = open(os.path.join(self.notes, "parser-or-codec.md")).read()
self.assertIn("readiness probe", text)
self.assertIn("lesson %d" % lid, text)
self.assertIn("field-note bullet", cycle.HELP_TEXT)
def test_gap06_into_list_and_split(self):
self.put("prove/other.md", vfile("other"))
lid = self.mk(change="Compound parser lesson about probes and fuzz corpus seeding",
moment="compound wait at step 3")
doc = self.cycle_doc(notes=[
{"lesson": lid, "action": "fold-into-entry", "into": "parser-or-codec", "note": "Use a readiness probe before parser server work"},
{"lesson": lid, "action": "fold-into-entry", "into": "fuzz", "note": "Seed the fuzz corpus from golden files"}])
r = self.sisi("cycle", "apply", doc)
self.assertEqual(r.returncode, 0, r.stdout)
self.assertIn("readiness probe", open(os.path.join(self.notes, "parser-or-codec.md")).read())
self.assertIn("Seed the fuzz corpus", open(os.path.join(self.notes, "fuzz.md")).read())
lid2 = self.mk(change="Multi target parser readiness lesson", moment="multi wait at step 2")
doc2 = self.cycle_doc(notes=[{"lesson": lid2, "action": "fold-into-entry", "into": ["parser-or-codec", "fuzz"]}])
self.assertEqual(self.sisi("cycle", "apply", doc2).returncode, 0)
def test_gap07_unknown_id_suggests_closest_and_brief_lists_ids(self):
lid = self.mk()
r = self.sisi("cycle", "apply", self.cycle_doc(
notes=[{"lesson": lid, "action": "fold-into-entry", "into": "parser-or-code"}]))
self.assertEqual(r.returncode, 1, r.stdout)
self.assertIn("Closest valid", r.stdout)
self.assertIn("parser-or-codec", r.stdout)
out = cycle.brief_text()
self.assertIn("parser-or-codec", out)
self.assertIn("fuzz", out)
def test_gap08_brief_gives_recipe_applies_to(self):
out = cycle.brief_text()
self.assertIn("applies-to", out)
# a real recipe's applies_to line from the library
from sisi import verifiers as V
rec = [e for e in V.load_recipes() if e["id"] == "parser-or-codec"][0]
self.assertIn(rec["applies_to"][:40], out)
def test_gap09_tool_lesson_refused_in_cycle(self):
lid = self.mk(change_kind="tool", change="Make sisi cycle print faster for large stores")
r = self.sisi("cycle", "apply", self.cycle_doc(
notes=[{"lesson": lid, "action": "fold-into-entry", "into": "fuzz"}]))
self.assertEqual(r.returncode, 1, r.stdout)
self.assertIn("tool lessons cannot be done in a cycle", r.stdout)
self.assertIn("sisi backlog", cycle.brief_text())
def test_gap10_merge_keeps_survivor_text_and_count(self):
a = self.mk(change="Parser readiness probes beat fixed sleeps for servers", moment="merge a at step 1")
b = self.mk(change="Fixed sleeps waste time for parser servers", moment="merge b at step 2")
before = self.lesson(a)
doc = self.cycle_doc(notes=[{"lesson": b, "action": "merge", "merged_into": a}])
self.assertEqual(self.sisi("cycle", "apply", doc).returncode, 0)
after = self.lesson(a)
self.assertEqual((after["change"], after["count"]), (before["change"], before["count"]))
self.assertEqual(self.lesson(b)["status"], "superseded")
self.assertIn("SAME change", cycle.HELP_TEXT)
self.assertIn("Superseded", cycle.HELP_TEXT)
def test_gap11_retire_definition_in_brief_and_help(self):
self.assertIn("fully folded and quiet", cycle.brief_text())
self.assertIn("20", cycle.HELP_TEXT)
self.assertIn("does not make it quiet", cycle.HELP_TEXT)
def test_gap12_set_when_only(self):
lid = self.mk()
doc = self.cycle_doc(notes=[{"lesson": lid, "action": "set-when", "when": PARSER_WHEN}])
self.assertEqual(self.sisi("cycle", "apply", doc).returncode, 0)
l = self.lesson(lid)
self.assertIn("readiness probe", l["when_terms"])
self.assertEqual(l["status"], "open")
def test_gap14_shortens_required_when_book_grows(self):
pre, base = overlay.base_rules()
title = next(r["title"] for r in base if r["id"] == "know-done")
long_body = ("Before work, write a contract. " * 40) + "\n\nWhy: a request says what is wanted."
doc = self.cycle_doc(rules=[{"id": "know-done", "title": title, "body": long_body, "action": "replace"}])
r = self.sisi("cycle", "apply", doc)
self.assertEqual(r.returncode, 1, r.stdout)
self.assertIn("shortens", r.stdout)
doc2 = self.cycle_doc(rules=[{"id": "know-done", "title": title, "body": long_body, "action": "replace",
"shortens": "know-done: the old preamble is removed"}])
# with shortens it may still fail the hard char budget, but not for missing shortens
r2 = self.sisi("cycle", "check", doc2)
if r2.returncode != 0:
self.assertNotIn("add `shortens`", r2.stdout)
def test_gap15_char_budget_rewrap_and_canon_cost(self):
self.sisi("build-canon")
self.assertIn("characters (budget %d)" % overlay.MAX_CHARS, self.sisi("canon", "cost").stdout)
pre, base = overlay.base_rules()
title = next(r["title"] for r in base if r["id"] == "know-done")
body = ("Before non-trivial work write a contract listing the checks that decide success "
"and draft it yourself from the request and the project in front of you today.\n\n"
"Why: a request says what is wanted, rarely how success is measured.")
doc = self.cycle_doc(rules=[{"id": "know-done", "title": title, "body": body, "action": "replace"}])
self.assertEqual(self.sisi("cycle", "apply", doc).returncode, 0)
gen = open(paths.generated()).read()
section = gen.split("Know how you will know you are done")[1].split("## 2.")[0]
self.assertTrue(all(len(l) <= 101 for l in section.splitlines()), [l for l in section.splitlines() if len(l) > 101][:3])
self.assertTrue(all(len(l) <= 101 for l in open(paths.overlay_dir("rules", "know-done.md")).read().splitlines()))
def test_gap16_rule_numbers_map_to_ids(self):
out = cycle.brief_text()
self.assertIn("1. know-done", out)
self.assertIn("rule 5", out)
def test_gap17_enforced_help_fields_and_examples(self):
out = self.sisi("cycle", "help").stdout
self.assertIn("contract-requirement", out)
self.assertIn("require_kind", out)
self.assertIn("max_rung", out)
self.assertIn("below strength 3", out)
self.assertIn("timeout_s", out)
def test_gap18_notes_chars_exclude_folded(self):
ids = [self.mk(change="Loose parser readiness lesson number %d with enough text to count here" % i,
moment="loose wait %d at step 2" % i) for i in range(3)]
before = cycle.due_state()["notes_chars"]
self.assertGreater(before, 0)
doc = self.cycle_doc(notes=[{"lesson": ids[0], "action": "fold-into-entry", "into": "parser-or-codec"}])
self.assertEqual(self.sisi("cycle", "apply", doc).returncode, 0)
after = cycle.due_state()["notes_chars"]
self.assertLess(after, before)
self.assertIn("do not count", cycle.brief_text())
def test_gap19_brief_names_cycle_file_path(self):
out = cycle.brief_text()
self.assertIn(cycle.cycle_file_path(), out)
self.assertIn("sisi cycle check FILE", out)
def test_gap20_help_is_detailed_and_brief_points_to_it(self):
self.assertIn("sisi cycle help", cycle.brief_text())
out = self.sisi("cycle", "help").stdout
self.assertIn("create-entry", out)
self.assertIn("fold-into-entry", out)
def test_also_cycle_check_dry_run_changes_nothing(self):
lid = self.mk()
before = self.overlay_bytes()
doc = self.cycle_doc(notes=[{"lesson": lid, "action": "retire"}])
for args in (("cycle", "check", doc), ("cycle", "--dry-run", doc)):
r = self.sisi(*args)
self.assertEqual(r.returncode, 0, r.stdout)
self.assertIn("nothing was changed", r.stdout)
self.assertIn("retire", r.stdout)
self.assertEqual(self.overlay_bytes(), before)
self.assertEqual(self.lesson(lid)["status"], "open")
self.assertEqual(cycle.cycle_records(), [])
if __name__ == "__main__":
unittest.main()
+61
View File
@@ -38,6 +38,34 @@ _ALLOWED_HOME_USERS = {"alice", "bob", "user", "you", "name", "username", "examp
HOME_RE = re.compile(r"(?<![\w.])/(?:home|Users)/([A-Za-z0-9_.-]+)")
EMAIL_RE = re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}")
# Values that change under the text and make it go stale: a release number, a count of things in the
# library or the tool list, a year, or words tied to when the sentence was written. A reader who needs
# such a fact is pointed at the command or file that gives the live answer (`sisi --version`,
# `sisi status`, `sisi doctor`, `sisi verifiers`, CHANGELOG.md) instead. Two-part versions (the
# minimum Python) and rung numbers do not match these patterns.
THREE_PART_VERSION_RE = re.compile(r"(?<![\w.])v?\d+\.\d+\.\d+\b")
YEAR_RE = re.compile(r"\b(?:19|20)\d{2}\b")
COUNT_RE = re.compile(r"(?<![\w.-])\d[\d,]*\s+(?:[A-Za-z-]+\s+)?"
r"(?:techniques|verifiers|recipes|tests|lessons|tools|harnesses)\b", re.I)
STALE_WORDS_RE = re.compile(r"\b(?:currently|today|as of)\b", re.I)
# A tool version quoted as evidence says what a fact was checked on, so it stays: for example a line
# in docs/harnesses.md naming the OpenCode version a limit was checked against.
VERSION_EVIDENCE_RE = re.compile(r"\b(?:verified on|checked against|on\s+[A-Z][\w-]*\s+v\d+\.\d+\.\d+)\b", re.I)
README_WORD_CEILING = 1790 # about a tenth above the README when set; raise it deliberately
def _stale_value_findings(text, rel, allow_version_evidence=False):
findings = []
for lineno, line in enumerate((text or "").splitlines(), 1):
evidence = allow_version_evidence and VERSION_EVIDENCE_RE.search(line)
for name, pattern in (("three-part version", THREE_PART_VERSION_RE), ("year", YEAR_RE),
("count", COUNT_RE), ("stale word", STALE_WORDS_RE)):
if name == "three-part version" and evidence:
continue
for m in pattern.finditer(line):
findings.append("%s:%d: %s %r" % (rel, lineno, name, m.group(0)))
return findings
class PublishableTree(unittest.TestCase):
def test_no_home_paths(self):
@@ -116,5 +144,38 @@ class ReadmeIsHonest(SisiCase):
self.assertTrue(os.path.exists(os.path.join(base, target)), "%s -> %s" % (doc, target))
class NoStaleValues(unittest.TestCase):
def test_readme_has_no_stale_values(self):
text = open(os.path.join(REPO, "README.md"), encoding="utf-8").read()
self.assertEqual(_stale_value_findings(text, "README.md"), [],
"hardcoded values that will go stale in the README")
def test_docs_have_no_stale_values(self):
rels = ["CONTRIBUTING.md", "SECURITY.md"]
rels += [os.path.join("docs", n) for n in sorted(os.listdir(os.path.join(REPO, "docs")))
if n.endswith(".md")]
findings = []
for rel in rels:
findings += _stale_value_findings(_text(rel), rel, allow_version_evidence=True)
self.assertEqual(findings, [], "hardcoded values that will go stale in the docs")
def test_readme_word_count_stays_under_ceiling(self):
words = len(open(os.path.join(REPO, "README.md"), encoding="utf-8").read().split())
self.assertLessEqual(words, README_WORD_CEILING,
"README has %d words, ceiling %d; cut or raise it deliberately"
% (words, README_WORD_CEILING))
def test_the_stale_scan_can_fail(self):
bad = _stale_value_findings(
"Version 0.1.0 had 140 verification techniques and 20 recipes in 2026; today it grows.",
"sample")
self.assertGreaterEqual(len(bad), 5, bad)
self.assertTrue(_stale_value_findings("checked on Foo v1.2.3", "sample"))
allowed = "Python 3.9 or newer; rung 1, rung 2, rung 3, rung 4, rung 5, rung 6."
self.assertEqual(_stale_value_findings(allowed, "sample"), [])
evidence = "no delivery could be confirmed on Foo v1.2.3 in headless runs"
self.assertEqual(_stale_value_findings(evidence, "sample", allow_version_evidence=True), [])
if __name__ == "__main__":
unittest.main()