From 16ba3217bc2c0a51596ab475720494daaf2cdd89 Mon Sep 17 00:00:00 2001 From: pingqiu-cpu Date: Thu, 3 Dec 2026 11:08:02 -0800 Subject: [PATCH] ci: preserve model trace deletions during merges (#1004) Merge note (batch b2r; pull_request_target spec-trace workflow has a startup_failure, so its checks run locally): - One Test run (47177109517) succeeded (go test (linux), process-level tests (real binaries)) on the integration tree f57965f8 = main f2bc730b + #1004 #1000 #995 #1001 in this order; these squash merges reproduce that tree, verified after the last one. - spec-trace-check.sh and public-text-check.sh, run with main's scripts against this head and body: both exit 0. - Code review ACCEPT on 26a0f300: the model trace file no longer uses a union merge (which silently brought back deleted rows); a checked-in real-git fixture shows a deletion next to an addition now conflicts and that the explicit resolution keeps the deletion; LF and sorted-unique checks stay. --- seaweed-block/.gitattributes | 2 +- .../.github/scripts/model-trace-check-test.py | 48 ++++++++++++++----- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/seaweed-block/.gitattributes b/seaweed-block/.gitattributes index 6afdc550c9..68dbe2f417 100644 --- a/seaweed-block/.gitattributes +++ b/seaweed-block/.gitattributes @@ -1,3 +1,3 @@ *.sh text eol=lf core/chunkkernel/chunk-kernel-2.tsv text eol=lf -.github/model-code-trace.tsv text eol=lf merge=union +.github/model-code-trace.tsv text eol=lf diff --git a/seaweed-block/.github/scripts/model-trace-check-test.py b/seaweed-block/.github/scripts/model-trace-check-test.py index 7020ea3a68..436a75f736 100644 --- a/seaweed-block/.github/scripts/model-trace-check-test.py +++ b/seaweed-block/.github/scripts/model-trace-check-test.py @@ -85,7 +85,7 @@ class ModelTraceTests(unittest.TestCase): with self.assertRaises(ValueError): checker.read_mapping(mapping) - def test_mapping_requires_sorted_unique_rows_after_a_union(self): + def test_mapping_requires_sorted_unique_rows_after_resolution(self): with tempfile.TemporaryDirectory() as tmp: mapping = Path(tmp) / "map.tsv" a = "core/a.go\tEngineAdapter.Begin\n" @@ -98,22 +98,44 @@ class ModelTraceTests(unittest.TestCase): mapping.write_text(a + b, encoding="utf-8") self.assertEqual(set(checker.read_mapping(mapping)), {"core/a.go", "core/b.go"}) - def test_union_merge_retains_concurrent_model_rows(self): + def test_model_trace_deletion_and_adjacent_addition_require_resolution(self): + attributes = (SCRIPT.parent.parent.parent / ".gitattributes").read_text(encoding="utf-8") with tempfile.TemporaryDirectory() as tmp: - paths = [Path(tmp) / name for name in ("ours", "base", "theirs")] + root = Path(tmp) + def git(*args, check=True): + return subprocess.run(["git", *args], cwd=root, capture_output=True, + check=check, text=True, timeout=15) + git("init", "-b", "base") + git("config", "user.name", "Example") + git("config", "user.email", "example@example.invalid") + git("config", "commit.gpgsign", "false") + (root / ".gitattributes").write_text(attributes, encoding="utf-8") + mapping = root / ".github" / "model-code-trace.tsv" + mapping.parent.mkdir() a = "core/a.go\tEngineAdapter.Begin\n" - b = "core/b.go\tMoveAdmission.Revoke\n" + removed = "core/b.go\tMoveAdmission.Revoke\n" + added = "core/b.go\tVolumeCreate.Claim\n" c = "core/c.go\tVolumeCreate.Claim\n" - for path, content in zip(paths, (a + b, a, a + c)): - path.write_text(content, encoding="utf-8") - merged = subprocess.run(["git", "merge-file", "--union", "-p", *map(str, paths)], - capture_output=True, check=True, text=True).stdout - self.assertEqual(set(merged.splitlines()), {a.strip(), b.strip(), c.strip()}) - paths[0].write_text("\n".join(sorted(set(merged.splitlines()))) + "\n", encoding="utf-8") - self.assertEqual(set(checker.read_mapping(paths[0])), {"core/a.go", "core/b.go", "core/c.go"}) + mapping.write_text(a + removed + c, encoding="utf-8") + git("add", ".") + git("commit", "-m", "base") + git("switch", "-c", "remove") + mapping.write_text(a + c, encoding="utf-8") + git("commit", "-am", "remove obsolete binding") + git("switch", "-c", "add", "base") + mapping.write_text(a + removed + added + c, encoding="utf-8") + git("commit", "-am", "add adjacent binding") + git("switch", "remove") + merged = git("merge", "--no-edit", "add", check=False) + self.assertEqual(merged.returncode, 1, merged.stdout + merged.stderr) + self.assertIn("<<<<<<<", mapping.read_text(encoding="utf-8")) + # Resolve deliberately: keep the new binding, preserve the deletion. + mapping.write_text(a + added + c, encoding="utf-8") + self.assertNotIn(removed, mapping.read_text(encoding="utf-8")) + self.assertEqual(checker.read_mapping(mapping)["core/b.go"], {"VolumeCreate.Claim"}) attr = subprocess.run(["git", "check-attr", "merge", "--", ".github/model-code-trace.tsv"], - cwd=SCRIPT.parent.parent.parent, capture_output=True, check=True, text=True) - self.assertEqual(attr.stdout.strip(), ".github/model-code-trace.tsv: merge: union") + cwd=SCRIPT.parent.parent.parent, capture_output=True, check=True, text=True, timeout=15) + self.assertEqual(attr.stdout.strip(), ".github/model-code-trace.tsv: merge: unspecified") if __name__ == "__main__":