Skip to content

Commit 2e3daed

Browse files
test: verify canonical wire-format.json vectors byte-for-byte in CI (LAB-423)
Vendors protocol test-vectors/wire-format.json (sha256-pinned, from cachekit-io/protocol@b0270b9) and asserts, for every vector: - retrieve() decodes to the exact payload bytes, format, and size - store() re-encodes to the exact envelope bytes (full-path byte identity) - StorageEnvelope msgpack codec round-trips byte-identically (localizes a re-encode failure to the envelope layout vs the LZ4 block encoding) - fixture security limits match the implementation constants Replaces the permanently-#[ignore]d, Blake3-era tests/compatibility_test.rs and its stale tests/compatibility/test_vector.json (dead regeneration path to a long-gone machine). The two live tests in that file were redundant with byte_storage.rs unit tests. sha2 added to dev-dependencies so the fixture pin verifies under every feature set (the existing sha2 dep is optional, encryption-gated); it was already in the dependency tree. Found by the LAB-272 protocol-adherence audit: these byte-canonical vectors were verified by no CI anywhere in the org. Co-authored-by: multica-agent <github@multica.ai>
1 parent 5736660 commit 2e3daed

6 files changed

Lines changed: 260 additions & 173 deletions

File tree

‎Cargo.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ proptest = "1.4"
7171
serde_json = "1.0"
7272
blake2 = "0.10"
7373
hex = "0.4"
74+
# Unconditional for tests: the optional sha2 above only exists under `encryption`,
75+
# but the wire-format vector fixture pin must verify under every feature set.
76+
sha2 = "0.10"
7477
aes-gcm = { version = "0.10", features = ["zeroize"] }
7578
criterion = { version = "0.5", features = ["html_reports"] }
7679

‎README.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,17 @@ cd fuzz && cargo fuzz run byte_storage_corrupted_envelope
331331

332332
See [`fuzz/README.md`](fuzz/README.md) for comprehensive fuzzing documentation.
333333

334+
### Protocol wire-format vectors
335+
336+
`tests/wire_format_vectors.rs` byte-verifies this crate against the canonical
337+
ByteStorage envelope vectors from
338+
[`cachekit-io/protocol`](https://github.com/cachekit-io/protocol)
339+
(`test-vectors/wire-format.json`): every vector must decode to the exact
340+
payload bytes and re-encode to the exact envelope bytes. The fixture is
341+
vendored at `tests/vectors/wire-format.json` and integrity-pinned by sha256 —
342+
to update it, re-copy from the protocol repo and change the pinned hash in the
343+
same commit.
344+
334345
---
335346

336347
## Minimum Supported Rust Version

‎tests/compatibility/test_vector.json‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎tests/compatibility_test.rs‎

Lines changed: 0 additions & 164 deletions
This file was deleted.

‎tests/vectors/wire-format.json‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"checksum": "xxHash3-64, 8 bytes big-endian, computed on uncompressed input",
3+
"compression": "LZ4 block format (NOT frame)",
4+
"envelope_format": "MessagePack positional array (rmp_serde::to_vec): [compressed_data, checksum, original_size, format]; byte fields encode as msgpack arrays of integers, not bin",
5+
"generator": "cachekit-core v0.2.0",
6+
"limits": {
7+
"max_compressed_size": 536870912,
8+
"max_compression_ratio": 1000,
9+
"max_uncompressed_size": 536870912
10+
},
11+
"vectors": [
12+
{
13+
"description": "Zero-length payload",
14+
"envelope_hex": "949100982d06cc800538ccd3cc94ccc200a76d73677061636b",
15+
"envelope_size": 25,
16+
"format": "msgpack",
17+
"input_hex": "",
18+
"input_size": 0,
19+
"name": "empty"
20+
},
21+
{
22+
"description": "Short ASCII text",
23+
"envelope_hex": "94dc0012ccf00168656c6c6f2c2063616368656b697421986dcc8a34ccb63a3c52ccd310a76d73677061636b",
24+
"envelope_size": 44,
25+
"format": "msgpack",
26+
"input_hex": "68656c6c6f2c2063616368656b697421",
27+
"input_size": 16,
28+
"name": "simple_string"
29+
},
30+
{
31+
"description": "64 bytes derived from pi (deterministic, low compressibility)",
32+
"envelope_hex": "94dc0042ccf031243f6acc88cc85cca308ccd31319cc8a2e03707344cca409382229cc9f31ccd0082eccfacc98ccec4e6ccc89452821cce638ccd01377ccbe5466cccf34cce90c6cccc0ccac29ccb7ccc97c50ccdd3fcc84ccd5ccb5ccb5470917982d016e0411ccedcc9e3440a76d73677061636b",
33+
"envelope_size": 117,
34+
"format": "msgpack",
35+
"input_hex": "243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89452821e638d01377be5466cf34e90c6cc0ac29b7c97c50dd3f84d5b5b5470917",
36+
"input_size": 64,
37+
"name": "binary_data"
38+
},
39+
{
40+
"description": "1024 bytes of repeated 'A' (high compression ratio)",
41+
"envelope_hex": "949f1f410100ccffccffccffcce960414141414141984d35ccad08cce9ccd77c0dcd0400a76d73677061636b",
42+
"envelope_size": 44,
43+
"format": "msgpack",
44+
"input_hex": "41414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141",
45+
"input_size": 1024,
46+
"name": "large_compressible"
47+
},
48+
{
49+
"description": "JSON-like payload (common real-world pattern)",
50+
"envelope_hex": "94dc004cccf03b7b22757365725f6964223a31323334352c226e616d65223a22416c696365222c22656d61696c223a22616c696365406578616d706c652e636f6d222c22616374697665223a747275657d98cc87673661cc9c4bcca8204aa76d73677061636b",
51+
"envelope_size": 102,
52+
"format": "msgpack",
53+
"input_hex": "7b22757365725f6964223a31323334352c226e616d65223a22416c696365222c22656d61696c223a22616c696365406578616d706c652e636f6d222c22616374697665223a747275657d",
54+
"input_size": 74,
55+
"name": "json_like"
56+
},
57+
{
58+
"description": "Single byte 0xFF (minimum non-empty payload)",
59+
"envelope_hex": "949210ccff98ccd6ccbcccec3c6b29ccd72e01a76d73677061636b",
60+
"envelope_size": 27,
61+
"format": "msgpack",
62+
"input_hex": "ff",
63+
"input_size": 1,
64+
"name": "single_byte"
65+
}
66+
],
67+
"version": "1.0.0"
68+
}

0 commit comments

Comments
 (0)