Expand description
Cache-prefix diagnostics (Task 12, spec §6.6) and the /context report.
§Canonicalization (documented approximations)
The tools-prefix / system-prefix / history-tail digests are keyed HMAC over canonical component bytes, derived from the same structural inputs the request builder used — the registered tool schemas, the caller-supplied system prompt, and the annotated message array:
- tools prefix: for each tool, in send order:
name ++ 0x1f ++ canonical-JSON(input_schema) ++ 0x1e. This matches stable-prefix semantics (a tool added, removed, reordered, or with a changed schema changes the digest) but is not the exact wire slice — provider-specific envelope keys and separators are excluded by design, so the digest is stable across cosmetic wire changes. - system prefix: the exact UTF-8 bytes of the system prompt string.
- history tail: for each message strictly after the last
message-level cache boundary (
cache_controlannotation this process applied),canonical-JSON(message) ++ 0x1e. When no boundary exists the tail is the whole history. Canonical JSON isserde_json::to_vecof the already-built message value — the same value the wire body was serialized from, but not byte-sliced out of the wire buffer.
None of these bytes are retained: only lengths and keyed digests
(installation-scoped HMAC key, see trace::key) leave this module.
§Session snapshot
CacheSnapshotStore keeps the previous emitted request’s component
digests (bounded metadata only — digests, byte lengths, tool IDs) inside
the session’s TraceContext. Compare-and-update is atomic under one
mutex, per emitted request: a retried identical request compares equal
(all segments Unchanged); an intentional tool order/schema change is
flagged with the precise tool IDs. No provider or prompt content is
ever stored.
Structs§
- Cache
Activity - Latest cache diagnostics, retained for the
/contextreport. Bounded metadata only (digests, byte lengths, enums, tool IDs). - Cache
Diagnostics - Computed diagnostics for one outgoing request.
- Cache
Snapshot Store - Session-scoped previous-component snapshot (see module docs). Shared via
ArcinsideTraceContext; all mutation is under one internal mutex so compare-and-update is atomic per emitted request. - Context
Report - Structured
/contextreport: counts, bytes, enums, and counters only — never prompt/tool/skill/memory content.
Enums§
- Report
Value - Why a
/contextline has no number: honest provenance, never a fabricated zero.
Functions§
- history_
tail_ bytes - Canonical history-tail bytes (see module docs).
- system_
prefix_ bytes - Canonical system-prefix bytes: the system prompt itself.
- tools_
prefix_ bytes - Canonical tools-prefix bytes (see module docs for the exact recipe).