LearnNewsExamplesServices
Frontmatter
id13513
titleDeterministic turn-aligned session chunker primitive (Sub 7a of #12073)
stateClosed
labels
enhancementaiarchitecture
assigneesneo-opus-grace
createdAtJun 19, 2026, 6:54 AM
updatedAtJun 19, 2026, 10:08 AM
githubUrlhttps://github.com/neomjs/neo/issues/13513
authorneo-opus-grace
commentsCount0
parentIssue12073
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJun 19, 2026, 10:08 AM

Deterministic turn-aligned session chunker primitive (Sub 7a of #12073)

Closed v13.1.0/archive-v13-1-0-chunk-4 enhancementaiarchitecture
neo-opus-grace
neo-opus-grace commented on Jun 19, 2026, 6:54 AM

Context

The foundation of #12073 (hierarchical-summarization for Tri-Vector extraction), split out as a safe, independently-landable primitive. The full sub requires a map→reduce refactor that separates extraction from graph-commit inside SemanticGraphExtractor.executeTriVectorExtraction (today the method interleaves LLM extraction with GraphService.upsertNode/linkNodes inline) — a sensitive core change. This leaf ships the pure, deterministic chunking primitive that the integration wraps, with zero change to the existing extraction path.

Live latest-open sweep: checked latest 20 open issues at ~2026-06-19T04:50Z; no equivalent — this is a clean sub of #12073.

Release classification: boardless (REM-pipeline epic lineage; post-v13).

The Problem

When session.document exceeds the local model's safeProcessingLimitTokens band, the consumer-friction guardrail in executeTriVectorExtraction skips invocation and extraction returns null — large sessions are silently lost. The map→reduce strategy needs a deterministic way to split a session into bounded, turn-aligned chunks first.

The Fix

New pure module ai/services/graph/sessionChunker.mjs (sibling of SemanticGraphExtractor.mjs; plain function module, no Neo import — same shape as consumerFrictionHelper):

  • chunkSession(turns, {sessionId, safeProcessingLimitTokens, estimate}) — greedy left-to-right turn-aligned packing; <sessionId>:chunk:<N> zero-indexed monotonic ids; turnIndices for source-coverage traceability; a single over-limit turn is kept intact and flagged oversizedTurn; small sessions return one chunk with chunked: false (single-pass preserved).
  • estimateTokens(text) — coarse, deterministic char-based estimate (no model round-trip → reproducible boundaries); injectable into chunkSession for guardrail parity.

Acceptance Criteria

  • Deterministic chunking strategy — greedy turn-aligned packing under the safe band. (#12073 AC1)
  • Deterministic boundaries — reproducible (byte-identical) across runs. (#12073 AC2)
  • Chunk metadata traces source coverage — chunkId + turnIndices. (#12073 AC3)
  • Small sessions preserved single-pass (chunked: false). (#12073 AC8)
  • A single over-limit turn is kept intact + flagged, never split mid-turn (Contract Ledger edge).
  • 11 unit specs green (small-session, chunk activation, deterministic ids/order/shape, oversized-turn, empty/defensive).

Out of Scope (remains in #12073)

  • The map→reduce integration into executeTriVectorExtraction: per-chunk extraction (AC4), deterministic reduce (AC5), cross-chunk (type,name) dedup (AC6), per-chunk failure → REM run-state (AC7). These require separating extraction from graph-commit in the core method — the sensitive change this leaf deliberately defers.

Related

  • Parent: #12073 (retains the integration + reduce/dedup/failure ACs).
  • Epic: #12065.

Origin Session ID

045a6048-1e1d-44c1-9738-7f09b62cc998