LearnNewsExamplesServices
Frontmatter
id9884
titleDreamService Architecture Hardening & Memory Core Enhancements
stateClosed
labels
enhancementairefactoringarchitecturecore
assigneestobiu
createdAtApr 11, 2026, 6:32 PM
updatedAtApr 12, 2026, 7:00 PM
githubUrlhttps://github.com/neomjs/neo/issues/9884
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtApr 11, 2026, 6:41 PM

DreamService Architecture Hardening & Memory Core Enhancements

Closedenhancementairefactoringarchitecturecore
tobiu
tobiu commented on Apr 11, 2026, 6:32 PM

Architectural Context

The Neo.mjs Memory Core and backend DreamService daemons require a deep refactoring to harden performance and inference reliability. Previous assumptions about Memory Core "context flooding" have been proven false: the episodic memory inherently stores dense cognitive data (prompt, thought, response) without raw boilerplate JSON streams, meaning structural token identifiers are properly maintained in the lowest levels.

Rationale

  • Synchronous Bottlenecks: FileSystemIngestor.mjs and DreamService.mjs utilize heavy synchronous I/O, which block the Node.js event loop during intensive extraction operations.
  • Tri-Vector Quality: DreamService currently synthesizes graph fragments from pre-summarized texts (via the summaryCollection), bleeding out precise framework identifiers (e.g., Neo.component.Base).
  • Capability Gap Inference Flaws: p.includes(term) allows inaccurate sub-string matches (e.g., "List" matches "api_listener" or "whitelist").
  • Race Conditions: sandman_handoff.md is updated synchronously without an atomic file swap, posing an application integrity risk if write operations clash.
  • Cognitive Complexity Feedback: To accurately calculate output complexity during REM sleep, MemoryService needs mathematical inputs natively tracking agent expenditure (e.g., amountToolCalls and toolsUsed), rather than relying on LLM estimations during session summarization.

Proposed Changes

  1. Async I/O: Refactor DreamService and FileSystemIngestor to utilize fs/promises.
  2. Atomic Swaps: Leverage .tmp intermediate files and POSIX rename() for safe sandman_handoff.md generation.
  3. Exact Matching: Migrate capability gap string checking to RegExp boundary assertions \b.
  4. Tri-Vector Reality Check: Pipe the raw aggregatedContent from MemoryCollection directly into executeTriVectorExtraction instead of reading the generic session.document summary.
  5. Memory Meta-Stats: Extend MemoryService.addMemory to natively accept amountToolCalls and an array of toolsUsed, enabling downstream SessionService productivity scoring.

Avoided Pitfalls

We explicitly avoid adding a mid-tier episodic summarization cascade before Tri-Vector ingestion, as doing so would actively destroy the localized structural Graph markers generated natively inside the agent's <thought> and response processes.

tobiu added the enhancement label on Apr 11, 2026, 6:32 PM
tobiu added the ai label on Apr 11, 2026, 6:32 PM
tobiu added the refactoring label on Apr 11, 2026, 6:32 PM
tobiu added the architecture label on Apr 11, 2026, 6:32 PM
tobiu added the core label on Apr 11, 2026, 6:32 PM
tobiu referenced in commit 7f5ec11 - "feat: Harden DreamService memory processing and filesystem ingestion (#9884)" on Apr 11, 2026, 6:35 PM
tobiu cross-referenced by PR #9885 on Apr 11, 2026, 6:35 PM
tobiu closed this issue on Apr 11, 2026, 6:41 PM
tobiu referenced in commit afa5736 - "feat: Harden DreamService memory processing and filesystem ingestion (#9884) (#9885) on Apr 11, 2026, 6:41 PM
tobiu referenced in commit 90f90b5 - "chore: Add AI attribution tracking instruction to ideation sandbox (#9884)" on Apr 11, 2026, 7:06 PM
tobiu referenced in commit 2204447 - "chore: Add AI attribution tracking instruction to ideation sandbox (#9884)" on Apr 11, 2026, 7:07 PM
tobiu assigned to @tobiu on Apr 12, 2026, 7:00 PM