navid/veins / 1be23d6281091c85418ea433cd09f4a380de2516ae9638a78e8baf5f2779d9da / docs/test-vectors/M0.adoc
M0.adoc
← docs/test-vectors · 7616 bytes · raw · download
Showing source. View rendered.
= vein Format Test Vectors: Milestone 0
:revnumber: 1
:revdate: 2026-11-25
This document publishes the format-version-1 test vectors for milestone M0:
BLAKE3, canonical varints, FastCDC chunk boundaries, object IDs and bodies,
and the pack/index container. They were generated with an independent Python
implementation using the reference `blake3` package and are checked by
`vn self-test`.
Object IDs use the domain separator from the specification:
[source,text]
----
object_id = BLAKE3("vein/1" 0x00 || type_byte || body)
type_byte: chunk=1 blob=2 tree=3 commit=4 conflict=5 operation=6 view=7
----
The hex encodings below are lowercase and contain no separators. Integer
fields are little-endian.
== BLAKE3
[cols="1,2,2",options="header"]
|===
| Input | Bytes | BLAKE3-256
| empty | (none) | `af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262`
| `abc` | `616263` | `6437b3ac38465133ffb63b75273a8db548c558465d79db03fd359c6cd5bd9d85`
| `hello world` | `68656c6c6f20776f726c64` | `d74981efa70a0c880b8d8c1985d075dbcbf679b99a5f9914e5aaf96b831a9e24`
|===
Chunker test input (used below):
[source,text]
----
length = 300000
seed = 2
byte[i] = (i * 31 + seed * 17) mod 251
----
Chunking that input produces exactly two chunks:
[cols="1,2,2",options="header"]
|===
| Chunk | Length | Object ID
| 0 | `262144` | `a6a4efd6c6330d328e0a3e2a97fb6202771433ffeeea099a93f8df08399b44fd`
| 1 | `37856` | `4c899670c3ec130e9ce03b5061d2593c2fa4f66661c6285f470e57dc65284444`
|===
The manifest for this file is a single leaf node (form 1) with those two
entries. Its blob ID is:
[source,text]
----
34bb8e7c00665b61c882fe1cae0a51a44d6ad1719fd44a1b22c991ae6a3c24bc
----
== FastCDC gear table
`docs/test-vectors/fastcdc_gear.txt` contains the 256 frozen `u64` entries.
Each entry is derived reproducibly:
[source,text]
----
gear[i] = u64le( BLAKE3("vein/fastcdc/gear/v1" || u8(i))[0..8] )
i = 0..255
----
For convenience, the BLAKE3 of the concatenated 2048-byte little-endian gear
table is:
[source,text]
----
52097d05a1f8eefb70604af851826bea02cf3f47f46aa129a661d630a40972da
----
Parameters: minimum 16 KiB, average 64 KiB, maximum 256 KiB, normalization
level 2. The rolling hash is `fp = (fp >> 1) + gear[byte]` (wrapping `u64`).
A boundary is taken when `fp & 0x3ffff == 0` before the average size and
`fp & 0x3fff == 0` from the average size onward, never before 16 KiB and never
past 256 KiB.
== Canonical varints
[cols="1,2",options="header"]
|===
| Value | Encoding
| 0 | `00`
| 127 | `7f`
| 128 | `80 01`
| 300 | `ac 02`
| 18446744073709551615 | `ff ff ff ff ff ff ff ff ff 01`
|===
A decoder rejects a multi-byte varint whose final group is zero, any encoding
longer than ten bytes, and any tenth byte other than `00` or `01`.
== Object bodies and IDs
[cols="1,2,2,2",options="header"]
|===
| Object | Body hex | ID | Notes
| empty tree | `00` | `01fd6e74c2454903e76762c71e9f22f7418e5d36f6149c48eeee734ec2e3dc41` | empty list
| inline blob `hello` | `000568656c6c6f` | `aecaf09bed6d5bd166cf9f24e88f73081460ec292f4a5eeb7daf4a1078e33d7c` | form 0 + bytes
|===
The following vectors use these three inline blobs:
[source,text]
----
base = "base" -> 000462617365 -> c11596e0f11881620de9b26e54c4c1233e4d9545c09b7a677f0011121a9b56b6
ours = "ours" -> 00046f757273 -> a77d538ccdf102fc33a4f20dfd0a67e9aa16a996bee763f2a14a3fd512d20e75
theirs = "theirs" -> 0006746865697273 -> 4a1f7bff6488363e0902d1c71bb7eb514bcee359ca4fcd2fb3099e152389275f
----
=== Conflict
Two file adds (`ours`, `theirs`) and one file remove (`base`):
[source,text]
----
body = 02
01 || ours_id
01 || theirs_id
01
01 || base_id
id = d6d530d1e90142531d26d6db8489b0c42654b312d27b56f74b45d97f2b00e7a9
----
Full body hex:
[source,text]
----
0201a77d538ccdf102fc33a4f20dfd0a67e9aa16a996bee763f2a14a3fd512d20e75014a1f7bff6488363e0902d1c71bb7eb514bcee359ca4fcd2fb3099e152389275f0101c11596e0f11881620de9b26e54c4c1233e4d9545c09b7a677f0011121a9b56b6
----
=== Commit
Fields: version 1, no parents, root tree = empty tree,
change ID = `0b0c0d0e0f101112131415161718191a`,
author = committer = `Alice <alice@example.com>` at 1700000000 +0000,
message `initial commit`, `renames_state = 1`, no renames, no extra headers.
[source,text]
----
body = 0100
01fd6e74c2454903e76762c71e9f22f7418e5d36f6149c48eeee734ec2e3dc41
0b0c0d0e0f101112131415161718191a
05416c696365 11616c696365406578616d706c652e636f6d 00f153650000000000 0000
05416c696365 11616c696365406578616d706c652e636f6d 00f153650000000000 0000
0e696e697469616c20636f6d6d6974
01 00 00
id = c6a60eba55e527a7b746aee77e66fc5e8e60ef31c5c407d57eaceaeececebb3c
----
Full body hex:
[source,text]
----
010001fd6e74c2454903e76762c71e9f22f7418e5d36f6149c48eeee734ec2e3dc410b0c0d0e0f101112131415161718191a05416c69636511616c696365406578616d706c652e636f6d00f1536500000000000005416c69636511616c696365406578616d706c652e636f6d00f153650000000000000e696e697469616c20636f6d6d6974010000
----
=== View
heads = `[commit]`; bookmark `main` resolves to `[commit]`; no tags or
remote refs; working copy `default` at `commit`.
[source,text]
----
body = 01 || commit_id
01 || 046d61696e || 01 || 01 || commit_id || 00
00
00
01 || 0764656661756c74 || commit_id
id = 9ba517b0693bd2016b9662f18fb54ca0ceaadc2ab08c4d87d9c4c9e42e689eed
----
Full body hex:
[source,text]
----
01c6a60eba55e527a7b746aee77e66fc5e8e60ef31c5c407d57eaceaeececebb3c01046d61696e0101c6a60eba55e527a7b746aee77e66fc5e8e60ef31c5c407d57eaceaeececebb3c000000010764656661756c74c6a60eba55e527a7b746aee77e66fc5e8e60ef31c5c407d57eaceaeececebb3c
----
=== Operation
No parents; view above; start = end = 1700000000000 +0000; hostname `host`,
username `alice`, description `self-test operation`; no tags.
[source,text]
----
body = 00 || view_id
0068e5cf8b01000000 0000
0068e5cf8b01000000 0000
04686f7374 05616c696365 1273656c6674657374206f7065726174696f6e
00
id = 99a9dea611815d7320e8481495227bf62e8a224ec873f3cd1daca5b4e2ece4f1
----
Full body hex:
[source,text]
----
009ba517b0693bd2016b9662f18fb54ca0ceaadc2ab08c4d87d9c4c9e42e689eed0068e5cf8b01000000000068e5cf8b010000000004686f737405616c6963651273656c6674657374206f7065726174696f6e00
----
== Pack and index
A pack containing exactly the empty tree object above, stored uncompressed
(compression byte 0), is 85 bytes:
[source,text]
----
magic 56504b31
version 01000000
count 0100000000000000
record tree_id (32 bytes)
type_byte 03
compression 00
raw_length 01
stored_length 01
body 00
trailer 294c1017488cc29fd32a67b299e998e7d995f5636ef245e1a5bc47be5c1e1042
----
Full pack hex:
[source,text]
----
56504b3101000000010000000000000001fd6e74c2454903e76762c71e9f22f7418e5d36f6149c48eeee734ec2e3dc410300010100294c1017488cc29fd32a67b299e998e7d995f5636ef245e1a5bc47be5c1e1042
----
Its index is 1136 bytes. The index contains the fanout, sorted IDs, the
record offset (16), the pack trailer, and the index trailer. Instead of
reproducing 1136 bytes here, the published checks are:
[cols="1,2",options="header"]
|===
| Property | Value
| Length | `1136`
| BLAKE3 of the complete index | `64bae9db19aa5bf84e4fe72e9cfe38e9563c5baa04abb4a4ca887dbdc94e4b1a`
| Index trailer (last 32 bytes) | `786a72638bd8cfe021cc57f54977ff76ed0e760f48e787e7735cbf9f571f4f9e`
| Record offset | `16`
|===
== Verification
`vn self-test` checks every vector in this document, including the exact pack
bytes and the index checksum, and then runs `vn fsck` on a repository
constructed from the vectors.