From 4518bae439158488e12e78b288f3a99a2b769021 Mon Sep 17 00:00:00 2001 From: ayushcodes10 Date: Mon, 14 Sep 2026 17:26:16 +0530 Subject: [PATCH] Add regression test for the stale sidecar html export path Corrupts the analysis sidecar community node id set (the exact staleness signature the issue describes) and confirms export html still succeeds, still renders graph.html, and prints the new warning instead of silently exporting against the fossil. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh --- tests/test_cli_export.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_cli_export.py b/tests/test_cli_export.py index 956598d63..3754d81d2 100644 --- a/tests/test_cli_export.py +++ b/tests/test_cli_export.py @@ -659,6 +659,29 @@ def test_export_html_no_community_data_at_all_still_succeeds(tmp_path): assert r.returncode == 0, r.stderr +# ── #2386: sidecar exists but is STALE, not just absent ────────────────────── +# update/watch advance graph.json's per-node community attribute but never +# regenerate .graphify_analysis.json, so it can describe an earlier +# clustering pass while still being present. That looked identical to a +# fresh sidecar from the outside and kept winning over the correct data +# sitting in graph.json. + +def test_export_html_prefers_fresh_data_when_sidecar_is_stale(tmp_path): + out = _make_graph(tmp_path) + analysis_path = out / ".graphify_analysis.json" + analysis = json.loads(analysis_path.read_text(encoding="utf-8")) + # Simulate staleness the way the issue describes: the sidecar's node id + # set no longer matches graph.json's (a node the sidecar never saw, or + # one it references that graph.json no longer has). + analysis["communities"] = {"0": ["a_ghost_node_id_not_in_the_graph"]} + analysis_path.write_text(json.dumps(analysis)) + + r = _run(["export", "html"], tmp_path) + assert r.returncode == 0, r.stderr + assert "is stale" in r.stderr + assert (out / "graph.html").exists() + + def test_graph_json_node_ids_are_portable_across_checkout_paths(tmp_path): """#1789: the committed graph.json's node ids must be relative to the scan root — not embed the absolute path — so the same repo yields identical ids