Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix: match whole memory ids in the causal-chain cycle check - #70

Open
shaikn6 wants to merge 1 commit into
ruvnet:mainfrom
shaikn6:fix/causal-chain-substring-cycle
Open

shaikn6 wants to merge 1 commit into
ruvnet:mainfrom
shaikn6:fix/causal-chain-substring-cycle

Conversation

@shaikn6

@shaikn6 shaikn6 commented Dec 5, 2026

Copy link
Copy Markdown

The cycle check in the recursive causal-chain query used chain.path NOT LIKE '%' || ce.to_memory_id || '%', which is a substring match on the path string. A node id that is a substring of an id already on the path (for example node 2 against path 1->12) was treated as a cycle and the edge was dropped, so valid chains were missing from the results.

The path is built by joining ids with ->, so the check now wraps the path in the same separator and matches the whole id token:

AND ('->' || chain.path || '->') NOT LIKE '%->' || ce.to_memory_id || '->%'

Applied to all four copies: getCausalChain and getCausalChainWithAttention in CausalMemoryGraph.ts, the causal_chains view in frontier-schema.sql, and the generated inline.ts (regenerated with scripts/inline-schemas.mjs, one line changed).

Checked against a throwaway SQLite database with edges 1->12, 12->2, 2->1 and the real CTE text from before and after the change:

  • before: only 1->12; the 1->12->2 chain is dropped
  • after: 1->12 and 1->12->2; the real cycle back to node 1 is still blocked
  • the causal_chains view from the schema file returns 1->12->2, 12->2->1 and 2->1->12 after the change

Fixes #69

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getCausalChain drops valid nodes: cycle check uses substring LIKE on the path string

1 participant