Repository navigation
Unify node-ID normalization into a single source of truth (#1) - #1378
danielnguyenfinhub wants to merge 4 commits into
Conversation
extract._make_id and build._normalize_id each carried a copy of the same NFKC -> \w -> underscore-collapse -> casefold recipe, kept in sync only by mirrored docstrings. That duplication is the root of the recurring ID-drift bug class (Graphify-Labs#811, Graphify-Labs#550, Graphify-Labs#1033, Graphify-Labs#1104): the AST extractor, the LLM subagents, and the graph builder must all produce identical node IDs or a single entity splits into disconnected ghost nodes. Move the recipe into a new graphify/ids.py (normalize_id + make_id). extract and build now both delegate to it, so they can no longer diverge. Behavior is unchanged — both copies were already identical. Add tests/test_id_normalization_contract.py: parametrized regression cases for the cited issues, plus hypothesis property tests asserting _make_id(s) == _normalize_id(s) and idempotency. The shared-implementation guard fails if a future change re-forks the normalization. Claude-Session: https://claude.ai/code/session_01UZZai31gG49fxtUf3onjN3 Co-authored-by: Claude <[email protected]>
…#2) The extraction-spec.md shown to semantic subagents documents node-ID construction with worked examples (`src/auth/session.py` + `ValidateToken` -> `auth_session_validatetoken`). Those examples are the LLM's ground truth and must reproduce exactly what the AST extractor emits, or the two producers generate different IDs for the same symbol and the graph splits it into disconnected ghost nodes — the same bug class (Graphify-Labs#811/Graphify-Labs#550/Graphify-Labs#1033/Graphify-Labs#1104) the new graphify/ids.py unification addressed on the code side. The prose is hand-maintained, so it can silently drift from the code. This adds tests/test_extraction_spec_ids.py, which parses every `path` + `entity` -> `id` example straight out of the 14 shipped specs (the shared skillgen fragment plus each per-host copy) and asserts extract._make_id(_file_stem(...), ...) reproduces it. It fails if a spec example is edited to a wrong value or if the ID functions change so the documented examples no longer hold, and also locks the spec's cautionary filename-only / full-path anti-examples to the code. Test-only; no runtime behavior change. Claude-Session: https://claude.ai/code/session_01UZZai31gG49fxtUf3onjN3 Co-authored-by: Claude <[email protected]>
…pose (#3) * Guard the LLM-facing node-ID spec against drift from the ID functions The extraction-spec.md shown to semantic subagents documents node-ID construction with worked examples (`src/auth/session.py` + `ValidateToken` -> `auth_session_validatetoken`). Those examples are the LLM's ground truth and must reproduce exactly what the AST extractor emits, or the two producers generate different IDs for the same symbol and the graph splits it into disconnected ghost nodes — the same bug class (Graphify-Labs#811/Graphify-Labs#550/Graphify-Labs#1033/Graphify-Labs#1104) the new graphify/ids.py unification addressed on the code side. The prose is hand-maintained, so it can silently drift from the code. This adds tests/test_extraction_spec_ids.py, which parses every `path` + `entity` -> `id` example straight out of the 14 shipped specs (the shared skillgen fragment plus each per-host copy) and asserts extract._make_id(_file_stem(...), ...) reproduces it. It fails if a spec example is edited to a wrong value or if the ID functions change so the documented examples no longer hold, and also locks the spec's cautionary filename-only / full-path anti-examples to the code. Test-only; no runtime behavior change. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Claude-Session: https://claude.ai/code/session_01UZZai31gG49fxtUf3onjN3 * fix(merge-graphs): normalise MultiGraph inputs to Graph before nx.compose When mixing an AST-only extraction (no multigraph header in graph.json, so networkx defaults to MultiGraph) with a full LLM extraction that explicitly sets multigraph=false (Graph), nx.compose raises: NetworkXError: All graphs must be graphs or multigraphs. Converts any MultiGraph to a simple Graph with nx.Graph(g) before the compose loop so merge-graphs works regardless of the source type. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Claude-Session: https://claude.ai/code/session_01UZZai31gG49fxtUf3onjN3 --------- Co-authored-by: Claude <[email protected]>
extract._make_id and build._normalize_id were copy-pasted forks of the same NFKC/casefold recipe kept in sync by mirrored docstrings -- the root of the recurring ID-drift ghost-node bug class (#811/#550/#1033/#1104). Move the recipe to graphify/ids.py and have all four producers delegate to it: extract, build, and (completing the migration) mcp_ingest and symbol_resolution, whose "avoid an import cycle" copies are moot now that ids.py is dependency-free. The contract test asserts all four resolve to the shared recipe, with hypothesis property tests for make_id == normalize_id and idempotency. Co-Authored-By: danielnguyenfinhub <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Merged to v8 in |
…abs#1378) extract._make_id and build._normalize_id were copy-pasted forks of the same NFKC/casefold recipe kept in sync by mirrored docstrings -- the root of the recurring ID-drift ghost-node bug class (Graphify-Labs#811/Graphify-Labs#550/Graphify-Labs#1033/Graphify-Labs#1104). Move the recipe to graphify/ids.py and have all four producers delegate to it: extract, build, and (completing the migration) mcp_ingest and symbol_resolution, whose "avoid an import cycle" copies are moot now that ids.py is dependency-free. The contract test asserts all four resolve to the shared recipe, with hypothesis property tests for make_id == normalize_id and idempotency. Co-Authored-By: danielnguyenfinhub <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
extract._make_id and build._normalize_id each carried a copy of the same NFKC -> \w -> underscore-collapse -> casefold recipe, kept in sync only by mirrored docstrings. That duplication is the root of the recurring ID-drift bug class (#811, #550, #1033, #1104): the AST extractor, the LLM subagents, and the graph builder must all produce identical node IDs or a single entity splits into disconnected ghost nodes.
Move the recipe into a new graphify/ids.py (normalize_id + make_id). extract and build now both delegate to it, so they can no longer diverge. Behavior is unchanged — both copies were already identical.
Add tests/test_id_normalization_contract.py: parametrized regression cases for the cited issues, plus hypothesis property tests asserting _make_id(s) == _normalize_id(s) and idempotency. The shared-implementation guard fails if a future change re-forks the normalization.
Claude-Session: https://claude.ai/code/session_01UZZai31gG49fxtUf3onjN3