fix(agentdb): add delete API — closes #150 (ruflo#1784 / RuVector#427 chain)#151
Merged
fix(agentdb): add delete API — closes #150 (ruflo#1784 / RuVector#427 chain)#151
Conversation
…y.deleteEpisode (#150) Closes the agentdb-side gap from ruvnet/ruflo#1784 and ruvnet/RuVector#427: the GraphDatabaseAdapter wraps @ruvector/graph-node which exposes only create/search primitives, but its query() method accepts arbitrary Cypher — so we can implement delete via DETACH DELETE today without waiting for binding-level methods to be republished. New on GraphDatabaseAdapter: - deleteNode(id, { cascade?: boolean }): { deletedNode, deletedEdges } Counts incident edges before delete so the caller gets an accurate edge-removal count regardless of binding stats. cascade: false refuses when incident edges exist (matches RuVector#427 spec). - deleteEdge(id): { deleted } - deleteHyperedge(id): { deleted } — scopes the match with :HYPEREDGE - deleteEdgesByEndpoints(from, to, label?): { deleted } — saves callers from materialising every edge id before scrubbing a tuple - escapeId / escapeLabel: Cypher-injection guards for ids that may carry user-supplied content. Labels are validated against /^[A-Za-z_][A-Za-z0-9_]*$/ so something like 'evil; DROP' throws instead of slipping into the query. New on ReflexionMemory: - deleteEpisode(id: number | string): boolean Mirrors the dual-write pattern from #128 in reverse — routes through graph adapter / generic graph backend / vector backend (when present) and ALSO purges SQL episodes / episode_embeddings rows so durable storage stays in sync. Best-effort across backends; returns true if any backend acknowledged the delete. Tests (10): tests/unit/controllers/ReflexionMemory-delete.test.ts - 3 ReflexionMemory.deleteEpisode tests against in-memory SQL fake - 7 GraphDatabaseAdapter Cypher-emission tests against a CypherSpy that records every query() call: covers DETACH DELETE wiring, cascade refusal, edge-by-id, hyperedge label scoping, endpoint-tuple delete, label injection guard, id escaping for embedded quotes/backslashes. Verified: cd packages/agentdb && npx vitest run tests/unit/controllers/ReflexionMemory-delete.test.ts Test Files 1 passed (1) Tests 10 passed (10) cd agentic-flow && npx vitest run tests/issue-fixes.test.ts Test Files 1 passed (1) Tests 23 passed (23) (still passing — no regressions) Closes #150 Co-Authored-By: claude-flow <ruv@ruv.net>
ruvnet
added a commit
that referenced
this pull request
May 6, 2026
Ships the delete API from PR #151 (#150) to npm: agentdb 3.0.0-alpha.12 → 3.0.0-alpha.13 agentic-flow 2.0.9 → 2.0.10 dependencies.agentdb: ^3.0.0-alpha.13 Live-verified via fresh npm install agentic-flow@2.0.10: └─┬ agentic-flow@2.0.10 └── agentdb@3.0.0-alpha.13 ✓ deleteNode / deleteEdge / deleteHyperedge / deleteEdgesByEndpoints compiled into published agentdb/dist/src/backends/graph/GraphDatabaseAdapter.js ✓ deleteEpisode compiled into published agentdb/dist/src/controllers/ReflexionMemory.js ✓ npm dist-tags: agentdb latest=3.0.0-alpha.13, agentic-flow latest=2.0.10 Closes the agentdb side of: - ruvnet/ruflo#1784 (downstream MCP-tool layer) - ruvnet/RuVector#427 (binding-level — still pending native publish) ruflo PR #1789 can now re-target bridgeDeleteCausalNode / bridgeDeleteCausalEdge at graphAdapter.deleteNode / .deleteEdge. Co-Authored-By: claude-flow <ruv@ruv.net>
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.
Summary
Closes the agentdb-side gap from this chain:
agentdb_hierarchical-store/agentdb_causal-edgeMCP tools have no delete tools, breaking/adr-indexre-runs after ADR file deletion.@ruvector/graph-node@2.0.4.The native
@ruvector/graph-nodebinding exposes onlycreateNode/createEdge/createHyperedge/searchHyperedgesas documented methods, butGraphDatabase.prototype.query(cypher)is also live. We implement delete by routing through Cypher so consumers get a delete API today without waiting for binding-level methods.What ships
New on
GraphDatabaseAdapter(packages/agentdb/src/backends/graph/GraphDatabaseAdapter.ts)deleteNode(id, { cascade?: boolean }): { deletedNode, deletedEdges }cascade: falserefuses with a typed error when edges exist (matches RuVector#427 spec).deleteEdge(id): { deleted }deleteHyperedge(id): { deleted }:HYPEREDGEto disambiguate from regular relationships.deleteEdgesByEndpoints(from, to, label?): { deleted }(source, target, label)tuple.escapeId/escapeLabel/^[A-Za-z_][A-Za-z0-9_]*$/so'evil; DROP'throws instead of slipping into the query.New on
ReflexionMemorydeleteEpisode(id: number \| string): boolean— mirrors the dual-write pattern from reflexion.storeEpisode() does not INSERT into episodes/episode_embeddings SQL tables #128 in reverse. Routes through graph adapter / generic graph backend / vector backend (when present) AND always purges SQLepisodesandepisode_embeddingsrows so durable storage stays in sync.Tests
packages/agentdb/tests/unit/controllers/ReflexionMemory-delete.test.ts— 10 tests, all passing:ReflexionMemory.deleteEpisodetests against an in-memory SQL fakeGraphDatabaseAdapterCypher-emission tests against aCypherSpythat records everyquery()call:DETACH DELETEwiring + accurate edge countcascade: falserefusal with edge count:HYPEREDGElabel scopingThe existing 23-test verification suite for the prior issue fixes (#145, #146, #102, #110, #118/119, #128, #129) is also still passing — no regressions.
Why Cypher and not bind-level
The native binding doesn't expose
deleteNode/deleteEdge/deleteHyperedgeeven on the latest published@ruvector/graph-node@2.0.4. RuVector#427 is closed but those methods aren't on the registry yet. Rather than block on republishing the binding, we route through Cypher (MATCH (n {id: $id}) DETACH DELETE n RETURN count(n)) — same end result, no upstream-publish dependency. When the binding ships native methods, this adapter can switch to those without breaking the public API.Downstream
Once this is published as
agentdb@3.0.0-alpha.13, ruvnet/ruflo#1789's stub branches atbridgeDeleteCausalNode/bridgeDeleteCausalEdgecan re-target their primary path atgraphAdapter.deleteNode/.deleteEdge. The SQL fallback then becomes a true fallback — only fires when the graph backend isn't loaded.Closes #150
🤖 Generated with claude-flow