test(cache): lock in byte-stability of MCP and protocol payloads#8
Closed
jhonatanjunio wants to merge 1 commit into
Closed
test(cache): lock in byte-stability of MCP and protocol payloads#8jhonatanjunio wants to merge 1 commit into
jhonatanjunio wants to merge 1 commit into
Conversation
Claude's prompt cache uses tools -> system -> messages invalidation. Anything squeez emits into the cacheable layers must be byte-stable across calls, or the cache (~10x cost reduction) silently dies. Adds `tests/test_cache_stability.rs` with regression-guard assertions on: - `protocol::full_payload()` byte-identical across 100 invocations - `protocol::SQUEEZ_PROTOCOL` + `SQUEEZ_MARKERS_SPEC` compose deterministically - `persona::text(...)` returns the same &'static str (pointer-equal) - MCP `tools/list` response identical apart from the JSON-RPC `id` - MCP `initialize` response identical apart from `id` - MCP `tools/call` for `squeez_protocol` byte-stable across 20 invocations Also documents the cache-stability requirement inline on each audited surface so future contributors know which strings must stay deterministic. Audit findings: no regressions; all cacheable surfaces already stable. This PR is preventive — tests fail loudly if anyone introduces drift later. Closes claudioemmanuel#131 Signed-off-by: Jhonatan Junio <jhonatanjuniocp@gmail.com>
b2af1d6 to
4f6d43b
Compare
Owner
Author
|
Superseded by upstream PR — moved to claudioemmanuel/squeez. See README of this fork for the upstream link. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7
Summary
Adds regression-guard tests that lock in byte-stability of every squeez surface that lands in Claude's cacheable prefix. With a warm cache the same session costs ~10× less; a silent drift in one of these payloads can quietly destroy that. Now any breaking change must explicitly break a test.
Audit findings
protocol::full_payload()&'static strconcatenations)mcp_server::tools_list_responseidmcp_server::initialize_responseidpersona::text(...)include_str!constants — pointer-identicalwrapheader (# squeez […])elapsed_mscorrectly variesNo code changes were needed — every audited surface is already cache-friendly. This PR is preventive: it ships the tests and doc comments so the next refactor can't silently regress us.
What changed
tests/test_cache_stability.rs(179 lines) — 7 byte-equality assertions plus a tinystrip_idhelper test.src/commands/protocol.rs::full_payload— doc comment naming the cache-stability requirement.src/commands/mcp_server.rs::tools_list_responseandinitialize_response— same doc comments referencing the test file.Test output
Out of scope
init's session-start stdout) — those are message content, not part of the cached prefix; per-session variation is expected.