Context
The DreamService REM pipeline (processUndigestedSessions()) currently executes 3 extraction vectors per undigested session:
- Tri-Vector Extraction (
executeTriVectorExtraction) — LLM-powered graph node/edge extraction from episodic memory
- Topological Conflicts (
extractTopology) — LLM-powered conflict detection (SUPERSEDES, OBSOLETES, DUPLICATE) → sandman_handoff.md
- Capability Gap Inference (
executeCapabilityGapInference) — Deterministic + LLM hybrid gap detection (DOC_GAP, TEST_GAP, GUIDE_GAP)
This ticket adds the 4th vector: executeNLActionDigest(), which reads successful Neural Link action sequences from the nl_action_log table (created by #9889) and uses them to close TEST_GAPs on graph nodes that have been verified through live agent interaction.
A2A Context (Fat Ticket)
Architectural Position
The 4th vector slots into processUndigestedSessions() after executeCapabilityGapInference() (line ~197) and before runGarbageCollection() (line ~211). It follows the exact same pattern as the existing three vectors:
- Accept session context
- Query a data source (
nl_action_log via better-sqlite3 handle on memory-core.sqlite)
- Perform deterministic analysis (group by
sequence_id, calculate success rate per component class)
- Upsert results into GraphService (TEST nodes with VALIDATES edges)
Key Design Decisions
- No Playwright scaffold synthesis in this ticket. The immediate value is closing TEST_GAPs automatically. Playwright synthesis is a follow-up concern.
- Success rate threshold. Only sequences where ≥80% of tool calls returned
success: true should qualify as "verified interactions."
- Component class extraction. The
nl_action_log.args JSON contains componentId and className fields from NL tool calls. These map directly to graph nodes of type CLASS.
- Gap closure mechanism. When a CLASS node has
[TEST_GAP] in its capabilityGap property AND nl_action_log contains successful sequences targeting that class, the gap severity should be downgraded (not fully removed — agent interaction is weaker evidence than a permanent Playwright test).
Prerequisite
- #9889 (NL Action Recorder) must be merged first — the
nl_action_log table must exist.
Files to Modify
| File |
Change |
ai/daemons/DreamService.mjs |
Add executeNLActionDigest(session) method; call it from processUndigestedSessions() |
Avoided Pitfalls
- The
nl_action_log SQLite handle must use the same WAL-mode connection pattern as DatabaseService.mjs to avoid SQLITE_BUSY contention during concurrent swarm operations.
- Do NOT attempt to embed NL action sequences as vectors — they are structured relational data, not semantic text. Keep them in the SQL domain.
Verification Plan
- Unit test following the
DreamService.spec.mjs pattern (isolated tmp/ SQLite DB)
- Mock
nl_action_log with synthetic successful + failed sequences
- Assert that TEST_GAP severity on corresponding graph nodes is downgraded after digest execution
Context
The
DreamServiceREM pipeline (processUndigestedSessions()) currently executes 3 extraction vectors per undigested session:executeTriVectorExtraction) — LLM-powered graph node/edge extraction from episodic memoryextractTopology) — LLM-powered conflict detection (SUPERSEDES, OBSOLETES, DUPLICATE) →sandman_handoff.mdexecuteCapabilityGapInference) — Deterministic + LLM hybrid gap detection (DOC_GAP, TEST_GAP, GUIDE_GAP)This ticket adds the 4th vector:
executeNLActionDigest(), which reads successful Neural Link action sequences from thenl_action_logtable (created by #9889) and uses them to close TEST_GAPs on graph nodes that have been verified through live agent interaction.A2A Context (Fat Ticket)
Architectural Position
The 4th vector slots into
processUndigestedSessions()afterexecuteCapabilityGapInference()(line ~197) and beforerunGarbageCollection()(line ~211). It follows the exact same pattern as the existing three vectors:nl_action_logviabetter-sqlite3handle onmemory-core.sqlite)sequence_id, calculate success rate per component class)Key Design Decisions
success: trueshould qualify as "verified interactions."nl_action_log.argsJSON containscomponentIdandclassNamefields from NL tool calls. These map directly to graph nodes of typeCLASS.[TEST_GAP]in itscapabilityGapproperty ANDnl_action_logcontains successful sequences targeting that class, the gap severity should be downgraded (not fully removed — agent interaction is weaker evidence than a permanent Playwright test).Prerequisite
nl_action_logtable must exist.Files to Modify
ai/daemons/DreamService.mjsexecuteNLActionDigest(session)method; call it fromprocessUndigestedSessions()Avoided Pitfalls
nl_action_logSQLite handle must use the same WAL-mode connection pattern asDatabaseService.mjsto avoid SQLITE_BUSY contention during concurrent swarm operations.Verification Plan
DreamService.spec.mjspattern (isolated tmp/ SQLite DB)nl_action_logwith synthetic successful + failed sequences