Context
A live REM run pushed the local graph model beyond its usable context window while processing Memory Core REM graph work. Fresh V-B-A showed this was not a missing primitive: the turn-aligned sessionChunker from #13513 already exists, and #12073 remains the broader Tri-Vector chunk-map/reduce authority.
This ticket exists as the narrow PR close target for the newly-proven topology side path, so the fix does not incorrectly auto-close #12073.
Release classification: boardless P0 runtime hardening; the fix is already scoped to the active REM over-cap burn path.
Live latest-open sweep: checked latest 20 open issues on 2026-06-24; no equivalent narrow topology/chunker bypass ticket found. Recent A2A sweep: only active overlapping claim was @neo-gpt's #12073 lane claim.
The Problem
DreamService.processUndigestedSessions() now fetches complete raw memory documents for a session, but it joins them into one session.document. TopologyInferenceEngine.extractTopology() then receives that joined full-session document and calls the graph provider directly.
That bypasses the turn-boundary chunker, the ConsumerFriction guardrail, structured output bounding, and no-think graph generation settings. A long session can therefore spend minutes in topology/ticket mining and grow the model's generated-token counter far beyond the intended safe band.
The Architectural Reality
ai/services/graph/sessionChunker.mjs is the deterministic whole-turn chunking primitive from #13513.
ai/daemons/orchestrator/services/DreamService.mjs has access to rawMemories.documents before it joins them.
ai/services/graph/TopologyInferenceEngine.mjs is a REM graph consumer separate from SemanticGraphExtractor, and currently uses a full-session prompt path.
- ADR 0019 applies: topology inference must read resolved
AiConfig leaves at the use site and fail loud when required leaves are stale or malformed.
The Fix
Thread the complete raw memory document array from DreamService into TopologyInferenceEngine, then make topology inference:
- chunk on whole memory-turn boundaries via
sessionChunker;
- subtract the topology prompt envelope from the chunk budget before invoking the model;
- route every chunk through
invokeWithGuardrail;
- use graph-provider structured output with the existing no-think config leaf;
- bound topology conflicts to the existing compact handoff cap;
- emit chunk counts into REM phase/per-session state for diagnostics.
Contract Ledger Matrix
| Target Surface |
Source of Authority |
Proposed Behavior |
Fallback / Edge Case |
Docs |
Evidence |
DreamService.processUndigestedSessions() topology handoff |
#12073, #13513, current raw-memory fetch path |
Preserve rawMemories.documents as session.turnDocuments and pass it to topology inference. |
If raw memory documents cannot be fetched, fall back to the existing joined session.document as one turn. |
Inline JSDoc/comments where topology state is emitted. |
Unit test proves raw turns are passed to topology. |
TopologyInferenceEngine.extractTopology(contextText, sessionId, options) |
This ticket, #12073 adjacency |
Accept optional turnDocuments, chunk them deterministically, and guard every provider call. |
Oversized single turns remain intact and are skipped by the guardrail; no arbitrary string split. |
Method JSDoc. |
Unit test proves chunk activation and schema-bounded provider options. |
| Topology provider options |
ADR 0019 + graph provider dispatch |
Read AiConfig.localModels.chat.* leaves at the topology use site and fail loud when missing/malformed. |
No hidden defaults and no new deployment config leaf. |
Helper JSDoc + thrown error text. |
Unit test verifies no-think/schema options are passed. |
| REM diagnostics |
#13624, #13835 |
Surface chunk totals/skips/processed counts in topology state. |
Topology remains non-blocking like current behavior when provider is offline. |
Run-state details. |
Unit coverage for returned topology details. |
Decision Record impact
Aligned with ADR 0019. No ADR change required.
Acceptance Criteria
Out of Scope
- Full Tri-Vector map/reduce integration remains under #12073.
- No arbitrary string splitting.
- No new cloud/deployment environment variable.
- No change to the public MCP surface.
Avoided Traps
- Do not close #12073 from this PR; that ticket still owns the broader Tri-Vector map/reduce contract.
- Do not create a provider-specific LMS-only fix; the topology path must work for both supported graph providers.
- Do not hide missing config with optional chaining or fallback math.
Related
#12073
#13513
#13624
#13835
Retrieval Hint: query_raw_memories("REM topology full-session burn sessionChunker turnDocuments TopologyInferenceEngine #12073").
Context
A live REM run pushed the local graph model beyond its usable context window while processing Memory Core REM graph work. Fresh V-B-A showed this was not a missing primitive: the turn-aligned
sessionChunkerfrom #13513 already exists, and #12073 remains the broader Tri-Vector chunk-map/reduce authority.This ticket exists as the narrow PR close target for the newly-proven topology side path, so the fix does not incorrectly auto-close #12073.
Release classification: boardless P0 runtime hardening; the fix is already scoped to the active REM over-cap burn path.
Live latest-open sweep: checked latest 20 open issues on 2026-06-24; no equivalent narrow topology/chunker bypass ticket found. Recent A2A sweep: only active overlapping claim was @neo-gpt's #12073 lane claim.
The Problem
DreamService.processUndigestedSessions()now fetches complete raw memory documents for a session, but it joins them into onesession.document.TopologyInferenceEngine.extractTopology()then receives that joined full-session document and calls the graph provider directly.That bypasses the turn-boundary chunker, the ConsumerFriction guardrail, structured output bounding, and no-think graph generation settings. A long session can therefore spend minutes in topology/ticket mining and grow the model's generated-token counter far beyond the intended safe band.
The Architectural Reality
ai/services/graph/sessionChunker.mjsis the deterministic whole-turn chunking primitive from #13513.ai/daemons/orchestrator/services/DreamService.mjshas access torawMemories.documentsbefore it joins them.ai/services/graph/TopologyInferenceEngine.mjsis a REM graph consumer separate fromSemanticGraphExtractor, and currently uses a full-session prompt path.AiConfigleaves at the use site and fail loud when required leaves are stale or malformed.The Fix
Thread the complete raw memory document array from
DreamServiceintoTopologyInferenceEngine, then make topology inference:sessionChunker;invokeWithGuardrail;Contract Ledger Matrix
DreamService.processUndigestedSessions()topology handoffrawMemories.documentsassession.turnDocumentsand pass it to topology inference.session.documentas one turn.TopologyInferenceEngine.extractTopology(contextText, sessionId, options)turnDocuments, chunk them deterministically, and guard every provider call.AiConfig.localModels.chat.*leaves at the topology use site and fail loud when missing/malformed.Decision Record impact
Aligned with ADR 0019. No ADR change required.
Acceptance Criteria
DreamServicepreserves complete raw memory documents for topology inference.TopologyInferenceEnginechunks topology input by memory-turn boundary when safe-band pressure requires it.AiConfigleaves fail loud when missing or malformed.Out of Scope
Avoided Traps
Related
#12073 #13513 #13624 #13835
Retrieval Hint:
query_raw_memories("REM topology full-session burn sessionChunker turnDocuments TopologyInferenceEngine #12073").