Files
hx/docs/adr/0009-cache-stable-context-shaping.md
johannesandClaude Sonnet 5.5 a94632ea3d chore: delete code comments, add ratchet lint and ADRs
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>
2026-11-21 13:37:32 +01:00

784 B

Context shaping must keep the cached prefix stable

Status: accepted

Context

Prompt caching keys on the request prefix. Any change to earlier bytes invalidates the cache from that point on.

Decision

  • Observation masking is a pure function of the message list and a boundary, so the prefix is byte-stable while the boundary stays put. Moving the boundary rewrites the cache from the first changed result, so the agent moves it rarely, in steps of a fixed number of assistant turns. The session file keeps the originals.
  • The batching nudge is injected at turn end so the cached prefix is untouched.

Consequences

Masking lags behind the ideal point in exchange for cache hits.

Code: crates/hx-core/src/mask.rs (module, boundary, apply), crates/hx-core/src/nudge.rs