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
- Async I/O: Refactor
DreamService and FileSystemIngestor to utilize fs/promises.
- Atomic Swaps: Leverage
.tmp intermediate files and POSIX rename() for safe sandman_handoff.md generation.
- Exact Matching: Migrate capability gap string checking to RegExp boundary assertions
\b.
- Tri-Vector Reality Check: Pipe the raw
aggregatedContent from MemoryCollection directly into executeTriVectorExtraction instead of reading the generic session.document summary.
- 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.
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
FileSystemIngestor.mjsandDreamService.mjsutilize heavy synchronous I/O, which block the Node.js event loop during intensive extraction operations.DreamServicecurrently synthesizes graph fragments from pre-summarized texts (via thesummaryCollection), bleeding out precise framework identifiers (e.g.,Neo.component.Base).p.includes(term)allows inaccurate sub-string matches (e.g., "List" matches "api_listener" or "whitelist").sandman_handoff.mdis updated synchronously without an atomic file swap, posing an application integrity risk if write operations clash.MemoryServiceneeds mathematical inputs natively tracking agent expenditure (e.g.,amountToolCallsandtoolsUsed), rather than relying on LLM estimations during session summarization.Proposed Changes
DreamServiceandFileSystemIngestorto utilizefs/promises..tmpintermediate files and POSIXrename()for safesandman_handoff.mdgeneration.\b.aggregatedContentfromMemoryCollectiondirectly intoexecuteTriVectorExtractioninstead of reading the genericsession.documentsummary.MemoryService.addMemoryto natively acceptamountToolCallsand an array oftoolsUsed, enabling downstreamSessionServiceproductivity 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>andresponseprocesses.