Summary
In CausalMemoryGraph.addCausalEdge() (bundled agentdb@3.0.0-alpha.16), when NodeIdMapper.getNodeId() returns undefined for a numeric memory id that was never registered, the code constructs a fallback string ${memoryType}-${memoryId} (e.g. episode-123) and silently creates the edge — even if no node with that id exists in the graph. Surfaced by ruvnet/ruflo#2246 §3.
Where (per the reporter's read of alpha.16's dist)
// dist/controllers/CausalMemoryGraph.js — addCausalEdge()
const mapper = NodeIdMapper.getInstance();
const fromNodeId = typeof edge.fromMemoryId === 'string'
? edge.fromMemoryId
: (mapper.getNodeId(edge.fromMemoryId) || `${edge.fromMemoryType}-${edge.fromMemoryId}`);
// ...same for toNodeId, then createCausalEdge(graphEdge)
The || ... fallback path runs with no console.warn, no validation, no rejection. The edge is created against an id the graph never registered → dangling/orphan edge.
Impact (from the reporter)
"We hit this as recurring causal-edge deprecation noise with no actionable guidance about required id formats (e.g. entity: / mem: prefixes)."
Silent orphans corrupt graph topology — pagerank, shortest-path, and similar traversals will encounter dangling endpoints with no diagnostic trail.
Reproduction
Call addCausalEdge() with a numeric fromMemoryId that was never registered via NodeIdMapper.register(). Observe: edge created against episode-<id> with no warning. Run a graph traversal: orphan endpoint encountered.
Suggested fix (any one)
- Reject the edge when the mapper returns undefined, with an actionable error message naming the missing id + the registration call.
- Emit
console.warn documenting what id format was expected and how to register it (e.g. NodeIdMapper.register(rawId, 'entity:foo')).
- Validate at the end of
addCausalEdge that both endpoints actually exist as nodes in the graph; reject otherwise.
Reporter's preference (#2246): "emit one actionable warning ... or reject the edge, instead of constructing an unvalidated id."
Cross-references
- Upstream report: ruvnet/ruflo#2246 (§3 of a 4-finding bug report)
- Bundled version that hit this: agentdb 3.0.0-alpha.16
Happy to PR if useful — start a thread.
Summary
In
CausalMemoryGraph.addCausalEdge()(bundledagentdb@3.0.0-alpha.16), whenNodeIdMapper.getNodeId()returnsundefinedfor a numeric memory id that was never registered, the code constructs a fallback string${memoryType}-${memoryId}(e.g.episode-123) and silently creates the edge — even if no node with that id exists in the graph. Surfaced by ruvnet/ruflo#2246 §3.Where (per the reporter's read of alpha.16's dist)
The
|| ...fallback path runs with noconsole.warn, no validation, no rejection. The edge is created against an id the graph never registered → dangling/orphan edge.Impact (from the reporter)
Silent orphans corrupt graph topology — pagerank, shortest-path, and similar traversals will encounter dangling endpoints with no diagnostic trail.
Reproduction
Call
addCausalEdge()with a numericfromMemoryIdthat was never registered viaNodeIdMapper.register(). Observe: edge created againstepisode-<id>with no warning. Run a graph traversal: orphan endpoint encountered.Suggested fix (any one)
console.warndocumenting what id format was expected and how to register it (e.g.NodeIdMapper.register(rawId, 'entity:foo')).addCausalEdgethat both endpoints actually exist as nodes in the graph; reject otherwise.Reporter's preference (#2246): "emit one actionable warning ... or reject the edge, instead of constructing an unvalidated id."
Cross-references
Happy to PR if useful — start a thread.