From 4a397a03b91250df623901849eeed7fbdfddf738 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sat, 14 Nov 2026 05:24:56 -0400 Subject: [PATCH] registry_loss_check: demonstrate the squash premise instead of assuming it engine#2412 found that branch_stale_check's central claim -- 'a squash merge writes the branch's older copies over the base' -- did not reproduce: a three-way merge takes untouched paths from the base. My registry_loss_check makes the same kind of claim in the other direction (a class missing from a behind branch is 'not a loss' because the merge is what lands) and its seven tests only exercised the tool, never the git behaviour the tool's classification rests on. This runs the merge. It is built so the two answers differ: the branch is cut BEFORE the class exists, so a checkout of the branch loses it and a merge keeps it. My first version reused the setUp history, where the branch carried the class too -- and a mutant that swapped 'merge --squash' for 'checkout -- .' still passed, which is exactly the failure mode this test exists to prevent. The rebuilt version catches it: mutant: merge -> checkout -> FAIL test_a_squash_merge_keeps_the_class_the_base_added Eight tests, all OK; the tool is unchanged and still green on main. --- tests/registry_loss_check_test.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/registry_loss_check_test.py b/tests/registry_loss_check_test.py index 5d092aff1..94fa5f725 100644 --- a/tests/registry_loss_check_test.py +++ b/tests/registry_loss_check_test.py @@ -122,6 +122,33 @@ def test_a_class_missing_only_because_the_branch_is_behind_is_not_a_loss(self): self.assertIn("behind the base", result.stdout) self.assertNotIn("FAIL", result.stdout) + def test_a_squash_merge_keeps_the_class_the_base_added(self): + """The premise the behind-the-base classification rests on, demonstrated rather than assumed. + + `registry_loss_check` reports a class missing from a behind branch as *not a loss* because the merge is what + lands. This runs the merge, and it is built so the two answers differ: the branch is cut BEFORE the class + exists, so a checkout of the branch would lose it and a merge keeps it -- which is why the assertion can tell + them apart (a version of this test using the setUp history could not: the branch carried the class too, so a + mutant that swapped the merge for a checkout still passed). + """ + fork = self.repo + self.write("registry/significant.json", json.dumps({"classes": {"OmoikaneForCausalLM": {}}}, indent=1)) + commit(fork, "before the class exists") + cut = git(fork, "rev-parse", "HEAD").stdout.strip() + self.write("notes.txt", "branch work\n") + commit(fork, "the branch does something unrelated") + behind = git(fork, "rev-parse", "HEAD").stdout.strip() + git(fork, "checkout", "-q", cut) + self.write("registry/significant.json", + json.dumps({"classes": {"OmoikaneForCausalLM": {}, "Skylar2ForCausalLM": {}}}, indent=1)) + commit(fork, "the base adds a class after the branch was cut") + + merged = git(fork, "merge", "--squash", behind) + self.assertEqual(0, merged.returncode, merged.stdout + merged.stderr) + landed = json.loads(open(os.path.join(fork, "registry/significant.json"), encoding="utf-8").read()) + self.assertIn("Skylar2ForCausalLM", landed["classes"], + "a squash merge keeps the class the base added; the behind classification depends on this") + def test_a_dirty_tree_is_named_because_the_check_reads_commits(self): # It reads `git show HEAD:...`, so uncommitted work is invisible. A dirty tree must say so instead of # reading as a clean result.