docs(sidechat): compaction-tail seed plan; test: discriminate remap and interleave paths

- plan doc: measured problem, the surface-equivalence argument, the
  construction (surface-order head emission, tail rebase with honest
  degradation, foldSurface self-verification, full-copy fallback), the
  explicit non-goals, and the deployment e2e gate.
- spec: assert the trim fires in the remap case (a replace fully inside
  the tail must stay a REMAPPED replace, not degrade into the fallback
  copy) and pin the interleave fallback (a tail replace covering a
  surviving pre-cut node).
This commit is contained in:
NolanHo authored and Atlas Zeng committed 2026-10-16 16:14:41 +08:00
1 parent f2443445aa
commit b025331b99
3 files changed
+132 -11

No files matched your search

+15 -11
View File
@@ -4,17 +4,21 @@
* node test environment can import it.
*
* A side thread is a child session the plugin creates ITSELF with a custom
* seed — the parent session's FULL event log up to the click moment
* (completed turns, the unanswered user message, and — when the parent is
* mid-turn — the in-progress assistant output and tool activity). The log
* model forbids open-turn seeds, so an in-flight parent turn is copied
* verbatim and CLOSED with synthetic `step/end` + `turn/end{reason:
* 'interrupted'}` events: the child sees the partial turn as honestly
* frozen ("cut off"), never as a completed answer. The one case that cannot
* be closed honestly — a tool call still executing (no `tool/result` yet;
* providers reject dangling assistant calls) — falls back to cutting before
* the open turn and carrying the partial content as a structured text
* snapshot inside the boundary prompt.
* seed — the parent's model-visible history up to the click moment. When the
* parent has summarized (its last compaction checkpoint replaces the
* shadowed span on the surface), the seed is REBASED onto that checkpoint:
* surviving pre-cut surface nodes, the checkpoint, and the post-compaction
* tail — proven equivalent to a full-log fork by folding both (compactionTail)
* — instead of physically duplicating the whole log. Without a compaction,
* or whenever the rebasing cannot be proven, the seed is the parent's FULL
* event log verbatim. The log model forbids open-turn seeds, so an
* in-flight parent turn is copied verbatim and CLOSED with synthetic
* `step/end` + `turn/end{reason: 'interrupted'}` events: the child sees the
* partial turn as honestly frozen ("cut off"), never as a completed answer.
* The one case that cannot be closed honestly — a tool call still executing
* (no `tool/result` yet; providers reject dangling assistant calls) — falls
* back to cutting before the open turn and carrying the partial content as
* a structured text snapshot inside the boundary prompt.
*/
import type { SidebarHistoryEntry, SidebarSessionSummary } from './context-types.ts'
import type { AssistantLiveChunk } from './assistant-live.ts'