Merge branch 'p3-problem-suggest'

# Conflicts:
#	tests/test_core.py
This commit is contained in:
swaits committed 2026-12-01 16:50:48 -07:00
commit 2e3a114c8e
3 files changed
+66 -3

No files matched your search

+1 -1
View File
@@ -4499,7 +4499,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, 2444, "sisi is two loops. If it needs more than this, find the simpler shape.")
self.assertLessEqual(code, 2472, "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)
+35
View File
@@ -32,6 +32,12 @@ class Problems(unittest.TestCase):
def setUp(self):
before = tree()
self.addCleanup(lambda: self.assertEqual(tree(), before, "a test wrote into the product tree"))
book = os.path.join(os.path.expanduser("~"), ".claude", "CLAUDE.md")
def own():
with open(book, encoding="utf-8") as f:
return f.read()
mine = own() if os.path.exists(book) else None
self.addCleanup(lambda: self.assertEqual(own() if os.path.exists(book) else None, mine, "a test wrote the person's own rules file"))
self.tmp = tempfile.mkdtemp(prefix="sisi-prob-")
self.addCleanup(shutil.rmtree, self.tmp, True)
self.data = os.path.join(self.tmp, "data")
@@ -355,5 +361,34 @@ class Problems(unittest.TestCase):
self.assertTrue(any("bravo issue" in l for l in faults_lines), faults_lines)
def test_near_duplicate_new_name_suggests_but_still_records_and_real_pairs(self):
real = [("claimed tool behaviour or timing from memory in a question or fault brief",
"Unmeasured claims about tool behaviour", True),
("push not gated on the test run's exit code",
"a gating command's exit status was hidden by a display filter", True),
("a trial or test of sisi changed the real machine's sisi setup",
"setup for new machines validated only on the machine that already had everything", False)]
for old, new, alike in real: # the threshold on the three real pairs (0.75, 0.333 suggest; 0.286 does not)
self.assertEqual(retro._sim(old, new) >= retro.SIMILAR, alike, (old, new))
n = 0
for old, new, alike in real:
for name in (old, new):
n += 1
rc, out, _ = self.sisi("retro", *GAP, "--improve", "Suggestion test rule number %d here" % n, "--problem", name)
self.assertEqual(rc, 0, out) # never refused: every name records exactly as given
self.assertEqual(self.records()[-1]["problem"], name)
if name is new and alike:
self.assertIn("this looks like problem %d '%s'; if it is, record it with --problem %d next time"
% (n - 1, old, n - 1), out)
else:
self.assertNotIn("this looks like", out, name)
rc, out, _ = self.sisi("retro", *GAP, "--improve", "Suggestion test unrelated rule here",
"--problem", "export drops empty names")
self.assertEqual(rc, 0, out)
self.assertNotIn("this looks like", out)
self.assertEqual(self.records()[-1]["problem"], "export drops empty names")
self.assertIn("looks like #1", self.sisi("retro")[1]) # report listing names the top lookalike pair
if __name__ == "__main__":
unittest.main()