feat(versioning): snapshot corpus per spec version
mdBook / build (push) Canceled after 0s
mdBook / deploy (push) Canceled after 0s

A frozen spec is only meaningful if it's paired with the corpus
that was current at release time — otherwise a v0.1.0 reader
follows "see corpus/payloads/ack/" and lands on a file whose
test vectors may have changed since v0.1.0 was cut.

Three changes:

1. `cut-version` now copies BOTH src/ AND corpus/ into the
   snapshot directory. A release is the pair, not just the text.

2. The corpus URL rewriting in cut-version now retargets
   /tree/main/corpus -> /tree/main/versions/<v>/corpus (and the
   blob variant). This lets the link resolve on GitHub from main
   alone — no git tag required, since the frozen copy is a real
   path under main. Downgrades the "tag is REQUIRED" message from
   last commit back to "optionally tag the commit".

3. The frozen corpus's spec_ref fields get rewritten too: from
   `src/04-payload-ack.md` to `versions/<v>/04-payload-ack.md`,
   so a reader following a test vector lands on the spec text the
   vector was paired with at release time.

versions/v0.1.0/ regenerated from scratch via `just cut-version v0.1.0`
to pick up the corpus snapshot + the new sed patterns. The release
is now self-consistent: v0.1.0 spec links go to v0.1.0 corpus, which
links back to v0.1.0 spec.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Opus 4.7 committed 2026-05-12 10:38:02 -06:00
1 parent f83d4088e3
commit 9232c16f7c
71 files changed
+5924 -28

No files matched your search

@@ -0,0 +1,112 @@
{
"$schema": "../../schema/test-vector.schema.json",
"name": "SHA-256 ACK CRC Computation",
"spec_ref": "versions/v0.1.0/04-payload-ack.md",
"protocol_version": 0,
"description": "Tests MeshCore ACK CRC computation: SHA-256(timestamp_le || txt_type_attempt || text || sender_pub_key)[0..3]. Each vector presents the full ACK packet that would be returned, along with the crypto_context showing the plaintext fed to SHA-256. Vectors ack-crc-001..004 share timestamp/text/pub_key and differ only in the attempt nibble of txt_type_attempt, demonstrating that each retry produces a distinct ACK CRC.",
"vectors": [
{
"id": "ack-crc-001",
"description": "ACK CRC for TXT_MSG 'hello', ts=0x12345678, attempt=0, zero pubkey",
"type": "encode_decode",
"structured": {
"header": {
"version": 0,
"payload_type": "ack",
"route_type": "flood"
},
"path": {
"hash_size": 1,
"hash_count": 0,
"hashes": []
},
"payload": {
"ack_crc": "B2EC0C9E"
}
},
"binary": "0D 00 9E0CECB2",
"crypto_context": {
"plaintext": "78563412 00 68656C6C6F",
"sender_public_key": "0000000000000000000000000000000000000000000000000000000000000000"
},
"notes": "SHA-256(timestamp(4) || txt_type_attempt(1) || text || sender_pub_key(32))[0..3] = 9E0CECB2 (LE). Displayed ack_crc field is the uint32 value 0xB2EC0C9E."
},
{
"id": "ack-crc-002",
"description": "Same message as ack-crc-001 but attempt=1 — distinct CRC",
"type": "encode_decode",
"structured": {
"header": {
"version": 0,
"payload_type": "ack",
"route_type": "flood"
},
"path": {
"hash_size": 1,
"hash_count": 0,
"hashes": []
},
"payload": {
"ack_crc": "13F08151"
}
},
"binary": "0D 00 5181F013",
"crypto_context": {
"plaintext": "78563412 01 68656C6C6F",
"sender_public_key": "0000000000000000000000000000000000000000000000000000000000000000"
},
"notes": "txt_type_attempt=0x01 (TXT_TYPE_PLAIN<<2 | attempt=1). Confirms attempt increment changes ACK CRC."
},
{
"id": "ack-crc-003",
"description": "Same message as ack-crc-001 but attempt=2 — distinct CRC",
"type": "encode_decode",
"structured": {
"header": {
"version": 0,
"payload_type": "ack",
"route_type": "flood"
},
"path": {
"hash_size": 1,
"hash_count": 0,
"hashes": []
},
"payload": {
"ack_crc": "4AD71DDF"
}
},
"binary": "0D 00 DF1DD74A",
"crypto_context": {
"plaintext": "78563412 02 68656C6C6F",
"sender_public_key": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
{
"id": "ack-crc-004",
"description": "Same message as ack-crc-001 but attempt=3 — distinct CRC (max attempt)",
"type": "encode_decode",
"structured": {
"header": {
"version": 0,
"payload_type": "ack",
"route_type": "flood"
},
"path": {
"hash_size": 1,
"hash_count": 0,
"hashes": []
},
"payload": {
"ack_crc": "1A537B8F"
}
},
"binary": "0D 00 8F7B531A",
"crypto_context": {
"plaintext": "78563412 03 68656C6C6F",
"sender_public_key": "0000000000000000000000000000000000000000000000000000000000000000"
},
"notes": "attempt=3 is the maximum value representable in the 2-bit attempt field."
}
]
}
@@ -0,0 +1,84 @@
{
"$schema": "../../schema/test-vector.schema.json",
"name": "SHA-256 Basic",
"spec_ref": "versions/v0.1.0/14-crypto.md",
"protocol_version": 0,
"description": "Basic SHA-256 hash computation test vectors. MeshCore uses SHA-256 for packet hashing, channel hash derivation, and HMAC.",
"vectors": [
{
"id": "sha-001",
"description": "SHA-256 of empty string",
"type": "encode_decode",
"structured": {
"header": {
"version": 0,
"payload_type": "raw_custom",
"route_type": "flood"
},
"path": {
"hash_size": 1,
"hash_count": 0,
"hashes": []
},
"payload": {
"data": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"
}
},
"binary": "3D 00 E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
"crypto_context": {
"plaintext": ""
},
"notes": "SHA-256('') = E3B0C442...B855. Standard NIST test vector."
},
{
"id": "sha-002",
"description": "SHA-256 of 'abc'",
"type": "encode_decode",
"structured": {
"header": {
"version": 0,
"payload_type": "raw_custom",
"route_type": "flood"
},
"path": {
"hash_size": 1,
"hash_count": 0,
"hashes": []
},
"payload": {
"data": "BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD"
}
},
"binary": "3D 00 BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD",
"crypto_context": {
"plaintext": "616263"
},
"notes": "SHA-256('abc') = BA7816BF...15AD. Standard NIST test vector."
},
{
"id": "sha-003",
"description": "SHA-256 of 'MeshCore'",
"type": "encode_decode",
"structured": {
"header": {
"version": 0,
"payload_type": "raw_custom",
"route_type": "flood"
},
"path": {
"hash_size": 1,
"hash_count": 0,
"hashes": []
},
"payload": {
"data": "F4F17278283E082A4743CCA308285D601E0F9943E6D6F9271B5B8C7DFED09DC0"
}
},
"binary": "3D 00 F4F17278283E082A4743CCA308285D601E0F9943E6D6F9271B5B8C7DFED09DC0",
"crypto_context": {
"plaintext": "4D657368436F7265"
},
"notes": "SHA-256('MeshCore')."
}
]
}
@@ -0,0 +1,109 @@
{
"$schema": "../../schema/test-vector.schema.json",
"name": "SHA-256 Packet Hash",
"spec_ref": "versions/v0.1.0/16-packet-hash.md",
"protocol_version": 0,
"description": "Tests MeshCore packet hash computation: SHA-256(payload_type || payload)[0..7]. TRACE packets additionally include path_len in the hash input.",
"vectors": [
{
"id": "phash-001",
"description": "Packet hash for ACK with CRC 0xDEADBEEF",
"type": "encode_decode",
"structured": {
"header": {
"version": 0,
"payload_type": "raw_custom",
"route_type": "flood"
},
"path": {
"hash_size": 1,
"hash_count": 0,
"hashes": []
},
"payload": {
"data": "1BEE08540E8F7E5B"
}
},
"binary": "3D 00 1BEE08540E8F7E5B",
"crypto_context": {
"plaintext": "03 EFBEADDE"
},
"notes": "SHA-256(0x03 || EFBEADDE)[0..7] = 1BEE08540E8F7E5B. Input: type byte 0x03 (ACK) + CRC 0xDEADBEEF as LE."
},
{
"id": "phash-002",
"description": "Packet hash for TRACE (path_len=0): includes path_len in hash",
"type": "encode_decode",
"structured": {
"header": {
"version": 0,
"payload_type": "raw_custom",
"route_type": "flood"
},
"path": {
"hash_size": 1,
"hash_count": 0,
"hashes": []
},
"payload": {
"data": "C105C34E45E60009"
}
},
"binary": "3D 00 C105C34E45E60009",
"crypto_context": {
"plaintext": "09 00 01000000 02000000 00"
},
"notes": "SHA-256(0x09 || 0x00 || tag=1_LE || auth=2_LE || flags=0)[0..7]. TRACE special case: path_len byte (0x00) included after type byte."
},
{
"id": "phash-003",
"description": "Packet hash for TRACE (path_len=3): different hash due to path_len",
"type": "encode_decode",
"structured": {
"header": {
"version": 0,
"payload_type": "raw_custom",
"route_type": "flood"
},
"path": {
"hash_size": 1,
"hash_count": 0,
"hashes": []
},
"payload": {
"data": "B83FB2E0EE276404"
}
},
"binary": "3D 00 B83FB2E0EE276404",
"crypto_context": {
"plaintext": "09 03 01000000 02000000 00"
},
"notes": "Same TRACE payload but path_len=3 instead of 0. Different hash proves path_len is included in computation."
},
{
"id": "phash-004",
"description": "Packet hash for ADVERT (all-AA pubkey, ts=0, all-BB sig)",
"type": "encode_decode",
"structured": {
"header": {
"version": 0,
"payload_type": "raw_custom",
"route_type": "flood"
},
"path": {
"hash_size": 1,
"hash_count": 0,
"hashes": []
},
"payload": {
"data": "F73157720FB1B5E1"
}
},
"binary": "3D 00 F73157720FB1B5E1",
"crypto_context": {
"plaintext": "04 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 00000000 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
},
"notes": "SHA-256(0x04 || advert_payload)[0..7]. Type 0x04 = ADVERT. Not a TRACE, so path_len is NOT included."
}
]
}