From 0ea296e9bacc01b521f49e5dbb34e169a4bdd20d Mon Sep 17 00:00:00 2001 From: ayushcodes10 Date: Mon, 14 Sep 2026 22:42:21 +0530 Subject: [PATCH] Add end to end regression test for the issue own repro shape Runs deduplicate_entities on the defining and referencing Korean node pair in both arrival orders and asserts the defining file own node survives either way, matching the concrete case the issue reports: a page whose filename equals the concept name losing its own node to a page that merely mentions it in passing. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh (cherry picked from commit 852c61098f761dc5b71365eb4009c37923e7c6c6) --- tests/test_dedup.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_dedup.py b/tests/test_dedup.py index 6abcd09fc..b8b8041f0 100644 --- a/tests/test_dedup.py +++ b/tests/test_dedup.py @@ -557,6 +557,21 @@ def test_defines_id_recognizes_a_non_latin_path(): assert not _defines_id(_KOREAN_REFERENCING) +@pytest.mark.parametrize("nodes", [ + [_KOREAN_DEFINING, _KOREAN_REFERENCING], + [_KOREAN_REFERENCING, _KOREAN_DEFINING], +], ids=["definition-first", "reference-first"]) +def test_korean_defining_file_wins_over_referencing_file(nodes): + """The issue's own repro shape: the page that defines a concept must keep + its own node instead of losing it to a page that merely mentions it.""" + result_nodes, _ = deduplicate_entities(list(nodes), [], communities={}) + + assert len(result_nodes) == 1 + assert result_nodes[0]["source_file"] == ( + "concepts/작업 단위 폴더 + README 진입점 컨벤션.md" + ) + + def test_same_file_relabel_is_noted(capsys): """Two labels for one ID from one file: the loser's label is discarded, which is the one drop that used to be silent. It is a note, not a collision warning."""