LearnNewsExamplesServices
Frontmatter
id10089
title[docs] Document SQLite FK constraints on Graph Database.addEdge JSDoc
stateClosed
labels
documentationenhancementai
assigneesneo-gpt
createdAtApr 19, 2026, 12:32 PM
updatedAtJun 2, 2026, 11:24 AM
githubUrlhttps://github.com/neomjs/neo/issues/10089
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJun 2, 2026, 11:24 AM

[docs] Document SQLite FK constraints on Graph Database.addEdge JSDoc

Closed v13.0.0/archive-v13-0-0-chunk-4 documentationenhancementai
tobiu
tobiu commented on Apr 19, 2026, 12:32 PM

Context

During PR #10084 implementation, the first test run failed with SqliteError: FOREIGN KEY constraint failed when ConceptIngestor tried to insert edges whose target strings had no matching graph node. The FK constraint is enforced in ai/graph/storage/SQLite.mjs but not surfaced in the public Database.mjs#addEdge API docs. Future implementers will hit the same error unless they proactively read the storage layer's schema.

This is a small but real discoverability gap. The fix is minutes of work; the benefit is durable across every future agent or human who touches graph ingestion.

The Fix

Add to ai/graph/Database.mjs:

  1. addEdge(edge) — JSDoc @throws {SqliteError} tag with explicit note: "if edge.target is not already present as a node ID. The underlying SQLite schema enforces FOREIGN KEY(target) REFERENCES nodes(id). Caller is responsible for ensuring target nodes exist before edge insertion."
  2. (Optional) same note on the class-level JSDoc @summary so it's visible at a glance

Mirror pattern for addNode if similar constraints exist (likely no — nodes are the parent table).

Acceptance Criteria

  • Database.mjs#addEdge JSDoc includes @throws {SqliteError} with FK constraint explanation
  • Pattern follows existing Anchor-and-Echo JSDoc discipline in the file
  • No code changes — documentation only
  • Semantic reference: future ask_knowledge_base("can I add an edge to a non-existent node?") query returns the correct guidance after sync

Origin Session ID

62d6f155-e57f-4279-9b59-36c9e4ecbc5e — surfaced in PR #10084 self-review [TOOLING_GAP] tag

Related

  • Evidence of the friction: PR #10084 — the FK miss cost ~10 min of iteration + one test failure before the schema reality was surfaced
  • ConceptIngestor.ensureEdgeTargetsExist — the workaround pattern that emerged, now documented inline there
tobiu added the documentation label on Apr 19, 2026, 12:32 PM
tobiu added the ai label on Apr 19, 2026, 12:32 PM
tobiu cross-referenced by #10030 on Apr 19, 2026, 12:33 PM
tobiu referenced in commit 904f30a - "docs(ai): document graph edge FK constraint (#10089) (#12338) on Jun 2, 2026, 11:24 AM
tobiu closed this issue on Jun 2, 2026, 11:24 AM