retro: suggest an existing problem when a new name looks like it

Content-word overlap (stemmed, filler dropped), threshold 0.3 picked on
12 labelled real pairs (11/12) with 12/12 held out. The retro always
records as given; the suggestion is one line, never a refusal. The
report listing annotates the top lookalike pair. Product 2426->2454 lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-12-01 16:49:23 -07:00
1 parent 1e1f26616e
commit 4b0326ba7c
3 files changed
+66 -3

No files matched your search

+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()