refactor(compact): align compact/summary and CompactionResult on shadowed* naming

This commit is contained in:
Hypatia May
2026-06-23 16:51:20 +08:00
parent 894653763e
commit 442f85469e
5 changed files with 12 additions and 12 deletions

View File

@@ -11,7 +11,7 @@ Compaction extends [`SessionEventMap`](session.md) with three event types via de
| Event | Payload | Role |
|---|---|---|
| `compact/start` | `{ turn }` | acquires the log-recorded lock |
| `compact/summary` | `{ summary, compactedRange, compactedEventSeqs, tokenCount }` | provenance: the summary blocks, the shadowed seq range, and the estimated token count |
| `compact/summary` | `{ summary, shadowedRange, shadowedSeqs, shadowedTokenCount }` | provenance: the summary blocks, the shadowed seq range, and the estimated token count |
| `compact/end` | `{ turn, error? }` | releases the lock (`error` set when summarization threw) |
The lock brackets the **whole** operation: `compact/start` is appended first, then summarization, the `compact/summary` provenance record, and the `user/message` replacement all land, and only then `compact/end`. Releasing the lock last turns a crash mid-operation into a detectable orphaned lock (a `compact/start` with no matching `compact/end`) rather than a `compact/end` that falsely claims compaction finished.
@@ -37,7 +37,7 @@ interface CompactionResult {
/** The seq numbers of all shadowed surface nodes. */
shadowedSeqs: number[]
/** Estimated token count of the shadowed content. */
compactedTokenCount: number
shadowedTokenCount: number
}
```