rawContextTokens was only re-derived on ContextModel mutations, so a
fresh measurement left it stale until the next append (raw could read
below the projected size). contextTokens only carried the measured
prefix, lagging the unmeasured tail by a step and diverging from the
getStatus() caliber after resume.
Publish both gauges together on every live change to ContextModel or
ContextSizeModel, with contextTokens now reporting get().size
(measured prefix plus the tail estimate) — the same caliber getStatus()
already used. The op's toEvent channel is removed in favor of the
single publisher.
Spine made the stored history append-only while several paths still
assumed stored == projected:
- repair the spine tree when undo/clear truncates the history beneath
it (new spine.truncate_repair op): clamp straddling spans, void
truncated ones, re-anchor the epoch boundary and the observation
cursor, so post-undo messages are never folded away and the next
tree transition is never dropped
- estimate the folded view instead of the raw stored history for the
context-size gauge after undo and on resume, and for 413 overflow
heuristics; fixes spurious auto compaction after every undo
- summarize only the current spine epoch (chaining the previous
epoch summary) instead of the full append-only history
- pause auto compaction with a warning when the compacted shape
still exceeds the window; recalibrate on any model window change
- share the projected-estimate helper via
IAgentContextProjectorService.estimateProjectedTokens
Also records the undo/spine/compaction semantics in FormularDefTree/.