From ef00185bb2bb5e5ff1e098d008a4a945c3454d0a Mon Sep 17 00:00:00 2001 From: safishamsi Date: Tue, 25 Aug 2026 18:09:58 +0100 Subject: [PATCH] test(merge): pin same-order community-offset byte-reproducibility (#3014) Document that the per-input community-id offset is deterministic for a fixed input order (consumers rely on stable merged output), while noting the offsets are position-dependent by design. --- tests/test_merge_graphs_cli.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_merge_graphs_cli.py b/tests/test_merge_graphs_cli.py index 22948df8..643e29e0 100644 --- a/tests/test_merge_graphs_cli.py +++ b/tests/test_merge_graphs_cli.py @@ -287,3 +287,20 @@ def test_merge_graphs_offsets_communities_so_repos_do_not_fuse(tmp_path): assert len({n["community"] for n in data["nodes"]}) == 5 # the per-repo partition is preserved assert {n["local_community"] for n in b_nodes} == {0, 1, 2} + + +def test_merge_graphs_community_offset_is_byte_reproducible(tmp_path): + """For a FIXED input order, the offset assignment must be deterministic: + merging the same inputs twice produces byte-identical output. (Offsets are + position-dependent by design — reordering inputs may renumber — so this pins + only same-order reproducibility, which is what consumers rely on. #3014.)""" + a = tmp_path / "alpha" / "graphify-out" / "graph.json" + b = tmp_path / "beta" / "graphify-out" / "graph.json" + _write_with_communities(a, [("a0", 0), ("a1", 0), ("a2", 1)]) + _write_with_communities(b, [("b0", 0), ("b1", 1), ("b2", 2)]) + + out1 = tmp_path / "m1.json" + out2 = tmp_path / "m2.json" + assert _run(["merge-graphs", str(a), str(b), "--out", str(out1)], tmp_path).returncode == 0 + assert _run(["merge-graphs", str(a), str(b), "--out", str(out2)], tmp_path).returncode == 0 + assert out1.read_bytes() == out2.read_bytes(), "same-order merge is not byte-reproducible"