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
A new first rule and a required design section in the contract for sizeable work, validated structurally and enforced by the end-of-turn check. Lessons and statements are tiered core, user or project; core items are queued for the product (sisi promote). The owner's statements take effect at once and form the principles document. Every retro names the general pattern behind its incident; learning rounds group lessons under patterns. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
97 lines
4.2 KiB
Python
97 lines
4.2 KiB
Python
"""`sisi rule`: every rule points at its own detail, and the enforcement column comes from code facts."""
|
|
import json, os, unittest
|
|
from support import *
|
|
from sisi import overlay, retro
|
|
|
|
|
|
class RuleTableTests(SisiCase):
|
|
def test_table_lists_every_rule_with_enforcement(self):
|
|
r = self.sisi("rule")
|
|
self.assertEqual(r.returncode, 0, r.stderr)
|
|
_, rules = overlay.base_rules()
|
|
for rule in rules:
|
|
self.assertIn(rule["id"], r.stdout)
|
|
self.assertIn(rule["title"], r.stdout)
|
|
self.assertIn("not enforced", r.stdout) # at least one rule is honestly only an intention
|
|
|
|
def test_every_base_rule_has_an_enforcement_entry(self):
|
|
from sisi import rulecmd
|
|
_, rules = overlay.base_rules()
|
|
for rule in rules:
|
|
self.assertIn(rule["id"], rulecmd.ENFORCEMENT, rule["id"])
|
|
self.assertTrue(rulecmd.enforcement_for(rule["id"]).strip())
|
|
|
|
def test_enforcement_wording_names_real_mechanisms(self):
|
|
from sisi import rulecmd
|
|
self.assertIn("end-of-turn", rulecmd.enforcement_for("know-done"))
|
|
self.assertIn("retro", rulecmd.enforcement_for("retro-every-time").lower())
|
|
ask = rulecmd.enforcement_for("decide-dont-ask").lower()
|
|
self.assertTrue("dialog" in ask or "asking" in ask, ask)
|
|
|
|
|
|
class RuleDetailTests(SisiCase):
|
|
def test_rule_by_number_and_by_id(self):
|
|
by_num = self.sisi("rule", "6")
|
|
by_id = self.sisi("rule", "decide-dont-ask")
|
|
self.assertEqual(by_num.returncode, 0, by_num.stderr)
|
|
self.assertEqual(by_id.returncode, 0, by_id.stderr)
|
|
for out in (by_num.stdout, by_id.stdout):
|
|
self.assertIn("Decide, do not ask", out)
|
|
self.assertIn("Why:", out)
|
|
self.assertIn("AskUserQuestion", out)
|
|
self.assertIn("base", out.lower())
|
|
|
|
def test_unknown_rule_fails(self):
|
|
self.assertEqual(self.sisi("rule", "no-such-rule").returncode, 1)
|
|
self.assertEqual(self.sisi("rule", "99").returncode, 1)
|
|
|
|
def test_folded_lessons_are_shown_with_show_command(self):
|
|
con = retro.connect()
|
|
try:
|
|
lid = retro.new_lesson(con, dict(
|
|
aim="hands-off", change_kind="rule", target=None,
|
|
moment="the agent buried a naming question at the end of a long report",
|
|
cause="asking in prose felt quicker than opening the dialog",
|
|
change="Ask naming questions through the dialog with options",
|
|
when="naming, question, dialog, options, ask the human, choice",
|
|
short="Ask through the dialog, with options."), self.proj, None)
|
|
con.execute("UPDATE lessons SET folded_into='decide-dont-ask', count=3 WHERE id=?", (lid,))
|
|
con.commit()
|
|
finally:
|
|
con.close()
|
|
r = self.sisi("rule", "decide-dont-ask")
|
|
self.assertEqual(r.returncode, 0, r.stderr)
|
|
self.assertIn("Ask through the dialog, with options.", r.stdout)
|
|
self.assertIn("sisi lessons show %d" % lid, r.stdout)
|
|
self.assertIn("buried a naming question", r.stdout) # the moment, as the example
|
|
|
|
def test_overlay_replacement_is_named_as_overlay(self):
|
|
d = os.path.join(self.data, "overlay", "rules")
|
|
os.makedirs(d, exist_ok=True)
|
|
with open(os.path.join(d, "deliver-quickly.md"), "w") as f:
|
|
f.write("## Deliver quickly\n\nReplacement body written by the owner.\n\nWhy: a test.\n")
|
|
r = self.sisi("rule", "deliver-quickly")
|
|
self.assertEqual(r.returncode, 0, r.stderr)
|
|
self.assertIn("Replacement body", r.stdout)
|
|
self.assertIn("overlay", r.stdout.lower())
|
|
|
|
|
|
class MoreLineTests(SisiCase):
|
|
def test_generated_rulebook_points_each_rule_at_its_detail(self):
|
|
text = overlay.render()
|
|
_, rules = overlay.effective()
|
|
for n, rule in enumerate(rules, 1):
|
|
self.assertIn("More: `sisi rule %d`" % n, text, rule["id"])
|
|
lines, chars = overlay.size(text)
|
|
self.assertLessEqual(lines, overlay.MAX_LINES)
|
|
self.assertLessEqual(chars, overlay.MAX_CHARS)
|
|
|
|
def test_help_names_rule_and_prompt(self):
|
|
out = self.sisi("help").stdout
|
|
self.assertIn("sisi rule", out)
|
|
self.assertIn("sisi prompt", out)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|