Expand description
Formal, verifiable prompt-cache safety for proxy request rewrites.
A provider can reuse a prompt-cache entry only while its cached prefix stays byte-identical. This module makes that invariant observable: it canonicalizes cache-relevant messages, hashes their frozen prefix, and writes compact audit records for offline verification.
Structs§
- Determinism
Audit Report - A machine-readable audit summary for
lean-ctx audit determinism. - Determinism
Guard - Verifies transformations under one proxy trace id.
- Determinism
Proof - A cryptographic proof that a provider-cached message prefix was preserved.
Functions§
- apply_
response_ headers - Applies the public verification headers to a proxied response.
- audit_
report - Reads the recent determinism audit records and summarizes cache safety.
- cache_
relevant_ messages - Extracts the fields whose order and content determine prompt-cache reuse.
- ensure_
response_ headers - Adds deterministic defaults for responses that never enter the shared forwarder (health, auth refusals, local APIs, and WebSocket handshakes).
- message_
hashes - Content hash of each message as the provider caches it (
cache_controlmarkers left out), in order. The determinism guard compares these against what a previous turn forwarded (prefix_replay::SentPrefix). - record_
audit - Persists a compact, newline-delimited proof record for offline audit.
- verify_
determinism - Verifies that
afterleaves the provider-cached prefix ofbeforeintact.