Classify every comment as tautology, stale, excuse or decision record. Tautology/stale/excuse comments are deleted (excuses filed as issues #196-#236), decisions moved to docs/adr/0001-0034. - scripts/lint-comments.sh + .comment-baseline: per-file comment count may only go down; wired into tests/all.sh - .claude/skills/delete-comment: repeatable audit workflow - cargo fmt applied to touched crates Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1.4 KiB
Mask old tool results late and monotonically
Status: accepted
Context
Old, large tool results are replaced by one-line stubs in the request; the session file keeps originals. Every change of the masked prefix rewrites the provider prompt cache from the first changed result on. A reading of real token usage and the masking boundary each describe one specific history. With a 1M window, "a third of the compaction threshold" is about 300k tokens, far beyond the point where resending old results costs more than one cache rewrite. The 60k cap came from two real sessions (contexts of 72k and 105k).
Decision
The boundary only moves forward, and only once the context passes a third of the compaction threshold (at most MASK_FROM_MAX = 60k tokens). While it stays put the request prefix is byte-stable. reset drops both the reading and the boundary whenever history is replaced or rewritten (new session, fork, clear, compaction); until the next record the count is a pure estimate. The boundary is stored with each assistant reply so requests can be replayed (files written before that used a stepwise rule).
Consequences
Cache is rewritten rarely, so savings beat the rewrite cost. Callers must call reset on any history change and masked/next once per request after compaction. The 60k constant needs tuning from hx stats.
Code: crates/hx-core/src/window.rs:ContextWindow, MASK_FROM_MAX; session.rs:append_masked