LearnNewsExamplesServices
Frontmatter
id10152
titleSemanticGraphExtractor: emit typed edges to Memory + Session nodes
stateClosed
labels
enhancementaiarchitecturecore
assigneestobiu
createdAtApr 21, 2026, 11:31 AM
updatedAtApr 22, 2026, 2:00 PM
githubUrlhttps://github.com/neomjs/neo/issues/10152
authortobiu
commentsCount0
parentIssue10143
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[x] 10151 DreamService: deterministic ingestion phase for Memory + Session graph nodes
blocking[]
closedAtApr 21, 2026, 9:25 PM

SemanticGraphExtractor: emit typed edges to Memory + Session nodes

Closed v13.0.0/archive-v13-0-0-chunk-5 enhancementaiarchitecturecore
tobiu
tobiu commented on Apr 21, 2026, 11:31 AM

SemanticGraphExtractor: emit typed edges to Memory + Session nodes

Context

Parent sub-epic (#10143) phase 2. After Memory + Session are nodes (phase 1), extractor attaches extracted entities (concepts/classes/methods/tickets) to those nodes via typed edges instead of sessionId-scalar metadata.

The Problem

Extractor today produces entity nodes with only sessionId scalar metadata — no graph edge to the anchoring Session or Memory. Consumers can't traverse from a concept back to its source memory or from a ticket-reference back to the authoring session via the graph.

The Architectural Reality

  • ai/daemons/services/SemanticGraphExtractor.mjs runs Gemma 4-31B (via Ollama) with a Zod-validated tri-vector schema.
  • Current emission is node-only; provenance encoded (if at all) as metadata properties.
  • Post-phase-1, Memory and Session nodes exist as edge targets.

The Fix

  • Extend Gemma4 extraction prompt to emit provenance edges alongside entities:
    • MENTIONED_IN(Concept → Memory)
    • DISCUSSED_IN(Class | Method → Session)
    • REFERENCED_BY(Issue → Memory)
  • Update Zod schema to validate the new edge shapes
  • Post-processing maps emitted edges to graph addEdge calls
  • Backward compat: if Memory/Session nodes don't exist yet (pre-migration), edges queue for lazy back-fill rather than drop

Acceptance Criteria

  • Gemma4 extraction prompt updated with provenance edge emission examples
  • Zod schema validates new edge types; rejections surface in tri-vector-errors telemetry
  • Edges land in graph: integrity check confirms extracted entities have provenance edges to Memory/Session (when source is post-phase-1)
  • Existing extracted-entity emission unchanged (no regression beyond additive edges)
  • Telemetry: REM cycle comparison pre- vs post-shipping shows edge growth proportional to entity count

Out of Scope

  • Changing which entities are extracted
  • Retroactively attaching edges to historical nodes (via lazy back-fill)
  • Human review of extracted edges for correctness (validation via integrity checks + telemetry)

Avoided Traps

  • Scalar metadata for provenance instead of edges. Rejected. Metadata strings can't be traversed; edges can.
  • Hardcoded edge emission in post-extractor code. Rejected. Gemma4 has per-extraction context to pick which memory sourced which entity; post-extractor would re-derive. Emission-from-LLM is a small prompt change with high semantic fidelity.

Related

  • Parent: #10143
  • Blocked by: phase 1 (Memory + Session ingestion)
  • Files: ai/daemons/services/SemanticGraphExtractor.mjs, extraction prompt templates, Zod schema

Origin Session ID: 71dc3cd8-d39d-48e1-ac62-e240ca67d1a5

tobiu added the enhancement label on Apr 21, 2026, 11:31 AM
tobiu added the ai label on Apr 21, 2026, 11:31 AM
tobiu added the architecture label on Apr 21, 2026, 11:31 AM
tobiu added the core label on Apr 21, 2026, 11:31 AM
tobiu added parent issue #10143 on Apr 21, 2026, 11:33 AM
tobiu marked this issue as being blocked by #10151 on Apr 21, 2026, 11:33 AM
tobiu cross-referenced by #10143 on Apr 21, 2026, 3:06 PM
tobiu cross-referenced by #10158 on Apr 21, 2026, 3:23 PM
tobiu cross-referenced by PR #10161 on Apr 21, 2026, 4:36 PM
tobiu cross-referenced by #9999 on Apr 21, 2026, 7:03 PM
tobiu assigned to @tobiu on Apr 21, 2026, 8:19 PM
tobiu cross-referenced by PR #10165 on Apr 21, 2026, 8:27 PM
tobiu referenced in commit aafc8bc - "feat(ai): extract Gemma4 provenance edges (#10152) (#10165) on Apr 21, 2026, 9:25 PM
tobiu closed this issue on Apr 21, 2026, 9:25 PM
tobiu cross-referenced by PR #10167 on Apr 21, 2026, 11:18 PM
tobiu cross-referenced by PR #10171 on Apr 22, 2026, 12:47 AM
tobiu cross-referenced by #10172 on Apr 22, 2026, 1:19 AM
tobiu referenced in commit 3dbea00 - "feat(ai): lazy back-fill for Memory + Session graph nodes (#10153) (#10171) on Apr 22, 2026, 1:21 AM