fix(algorithms): use declared primary key instead of hardcoded node.id#1
Open
timothyEastridge wants to merge 1 commit into
Open
fix(algorithms): use declared primary key instead of hardcoded node.id#1timothyEastridge wants to merge 1 commit into
timothyEastridge wants to merge 1 commit into
Conversation
GraphAlgorithms hardcoded `RETURN node.id AS node_id` (and `{id: $x}` matches),
raising "Cannot find property id for node" on any table whose PK isn't literally
`id` (Store(store_key), Identity(identity_id), CustomerRecord(record_id), ...).
This broke run_algorithm for the agent on real schemas.
- Add _pk(node_label): resolve the declared PK via table_info (the Python binding
reports the flag as "primary key" with a space); fall back to first column, "id".
- Use node.<pk> in wcc/pagerank/louvain/scc/k_core and {<pk>: $x} matches in
degree_centrality + shortest_path.
- k_core returned the wrong column too: `core` -> `k_degree AS core_number`
(verified against the engine's K_CORE_DECOMPOSITION output).
Verified in-container on the seeded retail graph: louvain over
CustomerRecord/SPLINK_DB now returns non-null node_id (record_id values).
(_build_adjacency spans all tables with heterogeneous PKs — left for a separate change.)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GraphAlgorithmshardcodedRETURN node.id AS node_id(and{id: $x}MATCH filters), which raises "Cannot find property id for node" on any table whose primary key isn't literallyid— i.e. essentially all real schemas (Store(store_key),Identity(identity_id),CustomerRecord(record_id),RetailOrder(order_id), …). This brokerun_algorithmfor the Bridgr agent on the seeded demo and any customer data.Fix
_pk(node_label)— resolves the declared PK viatable_info(the Python binding reports the flag as"primary key", with a space); falls back to the first column, thenid.node.<pk>inweakly_connected_components,pagerank,louvain,strongly_connected_components,k_core; use{<pk>: $x}indegree_centralityandshortest_path.k_corealso returned the wrong column —core→k_degree AS core_number(verified againstK_CORE_DECOMPOSITIONoutput).Verification
In-container against the seeded retail graph: Louvain over
CustomerRecord/SPLINK_DBnow returns non-nullnode_id(realrecord_idvalues); the agent's segmentation paints and traversal works.Note
_build_adjacency(custom cross-label algos) still assumesidacross heterogeneous PKs — left for a separate change; it isn't on the agent's run_algorithm path.bridgr-platform/bridgr-mono pins this commit; merging here keeps fresh clones + CI green.🤖 Generated with Claude Code