Skip to main content

qualia_core_db/container_10d/
conformance.rs

1//! `.10d` v1 normative-spec conformance vectors + layout-table drift gate
2//! (P0.7 scaffold).
3//!
4//! This module is the **conformance harness** — the single place where the
5//! `.10d` format's golden vectors and layout tables are pinned. It has two
6//! jobs:
7//!
8//! 1. **Golden vectors (encode∘decode = identity).** Each golden vector is a
9//!    pinned byte sequence produced by the current implementation encoding a
10//!    known input. The conformance test decodes the golden bytes, re-encodes
11//!    the decoded content, and asserts the re-encoded bytes are byte-identical
12//!    to the golden bytes. If any field offset, encoding order, CRC algorithm,
13//!    or padding rule drifts, the golden vector won't reproduce and the test
14//!    breaks. Each golden vector also has a **pinned content hash** (CRC-32C
15//!    over the golden bytes) — a double lock so a silent byte change is caught
16//!    even if the re-encode path has a compensating bug.
17//!
18//! 2. **Layout-table drift gate.** The size and offset of every field in
19//!    `Container10dHeader`, `SectionDescriptor`, `NodeMiniHeader`, and
20//!    `MetricBranchDescriptor` is asserted here in one place, so the spec's
21//!    layout tables and the Rust structs cannot drift apart. (The individual
22//!    module tests also have offset_of assertions; this centralizes them as
23//!    the spec's single source of truth.)
24//!
25//! **Scaffold status (P0.7 partial):** the golden vectors for the P0.1–P0.5
26//! container (header + section table + CRC + NODE section) are pinned here.
27//! The mesh-section golden vectors (P0.4) are a clearly-marked placeholder —
28//! they will be added when P0.4 lands. The normative `.10d` v1 spec document
29//! (the prose layout tables, magic bytes, version number, etc.) is the
30//! execution plan's P0.7 deliverable; this module is the executable
31//! conformance check, not the prose spec.
32
33use crate::container_10d::header::{Container10dHeader, HEADER_BYTE_SIZE};
34use crate::container_10d::mesh_section::{MeshMiniHeader, MESH_MINI_HEADER_SIZE};
35use crate::container_10d::metric_check::MetricBranchDescriptor;
36use crate::container_10d::node_section::{NodeMiniHeader, NODE_MINI_HEADER_SIZE, TENSOR10D_SIZE};
37// Only the layout-drift gate runs outside `#[cfg(test)]`, so it imports just the descriptor + its
38// size constant. `crc32c`, `AlignmentTier`, `SectionInput`, and `SectionType` are used exclusively by
39// the golden-vector tests and are imported there.
40use crate::container_10d::section::{SectionDescriptor, SECTION_DESCRIPTOR_SIZE};
41
42// ---------------------------------------------------------------------------
43// Layout-table drift gate — the spec's single source of truth for sizes &
44// offsets. If any of these change, the format version MUST bump.
45// ---------------------------------------------------------------------------
46
47/// Assert every layout invariant the `.10d` v1 spec pins. Called from the
48/// conformance test; also callable from any test that wants to confirm the
49/// structs haven't drifted.
50pub fn assert_layout_invariants() {
51    // --- Container10dHeader (64 bytes) ---
52    assert_eq!(std::mem::size_of::<Container10dHeader>(), 64, "header size");
53    assert_eq!(
54        std::mem::offset_of!(Container10dHeader, magic),
55        0,
56        "header.magic offset"
57    );
58    assert_eq!(
59        std::mem::offset_of!(Container10dHeader, version),
60        4,
61        "header.version offset"
62    );
63    assert_eq!(
64        std::mem::offset_of!(Container10dHeader, flags),
65        6,
66        "header.flags offset"
67    );
68    assert_eq!(
69        std::mem::offset_of!(Container10dHeader, axis_roles),
70        8,
71        "header.axis_roles offset"
72    );
73    assert_eq!(
74        std::mem::offset_of!(Container10dHeader, pad0),
75        18,
76        "header.pad0 offset"
77    );
78    assert_eq!(
79        std::mem::offset_of!(Container10dHeader, metric_descriptor),
80        20,
81        "header.metric_descriptor offset"
82    );
83    assert_eq!(
84        std::mem::offset_of!(Container10dHeader, header_crc32c),
85        52,
86        "header.header_crc32c offset"
87    );
88    assert_eq!(
89        std::mem::offset_of!(Container10dHeader, section_table_offset),
90        56,
91        "header.section_table_offset offset"
92    );
93    assert_eq!(
94        std::mem::offset_of!(Container10dHeader, section_count),
95        60,
96        "header.section_count offset"
97    );
98
99    // --- MetricBranchDescriptor (8 bytes) ---
100    assert_eq!(
101        std::mem::size_of::<MetricBranchDescriptor>(),
102        8,
103        "metric_branch_descriptor size"
104    );
105
106    // --- SectionDescriptor (24 bytes) ---
107    assert_eq!(
108        std::mem::size_of::<SectionDescriptor>(),
109        24,
110        "section_descriptor size"
111    );
112    assert_eq!(
113        std::mem::offset_of!(SectionDescriptor, section_type),
114        0,
115        "section_descriptor.section_type offset"
116    );
117    assert_eq!(
118        std::mem::offset_of!(SectionDescriptor, alignment_tier),
119        1,
120        "section_descriptor.alignment_tier offset"
121    );
122    assert_eq!(
123        std::mem::offset_of!(SectionDescriptor, reserved16),
124        2,
125        "section_descriptor.reserved16 offset"
126    );
127    assert_eq!(
128        std::mem::offset_of!(SectionDescriptor, byte_offset),
129        4,
130        "section_descriptor.byte_offset offset"
131    );
132    assert_eq!(
133        std::mem::offset_of!(SectionDescriptor, byte_length),
134        8,
135        "section_descriptor.byte_length offset"
136    );
137    assert_eq!(
138        std::mem::offset_of!(SectionDescriptor, stride),
139        12,
140        "section_descriptor.stride offset"
141    );
142    assert_eq!(
143        std::mem::offset_of!(SectionDescriptor, element_count),
144        16,
145        "section_descriptor.element_count offset"
146    );
147    assert_eq!(
148        std::mem::offset_of!(SectionDescriptor, crc32c),
149        20,
150        "section_descriptor.crc32c offset"
151    );
152
153    // --- NodeMiniHeader (16 bytes) ---
154    assert_eq!(
155        std::mem::size_of::<NodeMiniHeader>(),
156        16,
157        "node_mini_header size"
158    );
159    assert_eq!(
160        std::mem::offset_of!(NodeMiniHeader, node_count),
161        0,
162        "node_mini_header.node_count offset"
163    );
164    assert_eq!(
165        std::mem::offset_of!(NodeMiniHeader, layout),
166        4,
167        "node_mini_header.layout offset"
168    );
169    assert_eq!(
170        std::mem::offset_of!(NodeMiniHeader, reserved_u8),
171        5,
172        "node_mini_header.reserved_u8 offset"
173    );
174    assert_eq!(
175        std::mem::offset_of!(NodeMiniHeader, reserved_u16),
176        6,
177        "node_mini_header.reserved_u16 offset"
178    );
179    assert_eq!(
180        std::mem::offset_of!(NodeMiniHeader, reserved_u64),
181        8,
182        "node_mini_header.reserved_u64 offset"
183    );
184
185    // --- MeshMiniHeader (40 bytes) ---
186    assert_eq!(
187        std::mem::size_of::<MeshMiniHeader>(),
188        40,
189        "mesh_mini_header size"
190    );
191    assert_eq!(
192        std::mem::offset_of!(MeshMiniHeader, flags),
193        0,
194        "mesh_mini_header.flags offset"
195    );
196    assert_eq!(
197        std::mem::offset_of!(MeshMiniHeader, reserved_u16),
198        2,
199        "mesh_mini_header.reserved_u16 offset"
200    );
201    assert_eq!(
202        std::mem::offset_of!(MeshMiniHeader, vertex_count),
203        4,
204        "mesh_mini_header.vertex_count offset"
205    );
206    assert_eq!(
207        std::mem::offset_of!(MeshMiniHeader, triangle_count),
208        8,
209        "mesh_mini_header.triangle_count offset"
210    );
211    assert_eq!(
212        std::mem::offset_of!(MeshMiniHeader, min),
213        12,
214        "mesh_mini_header.min offset"
215    );
216    assert_eq!(
217        std::mem::offset_of!(MeshMiniHeader, max),
218        24,
219        "mesh_mini_header.max offset"
220    );
221    assert_eq!(
222        std::mem::offset_of!(MeshMiniHeader, reserved_u32),
223        36,
224        "mesh_mini_header.reserved_u32 offset"
225    );
226
227    // --- Constants ---
228    assert_eq!(HEADER_BYTE_SIZE, 64, "HEADER_BYTE_SIZE");
229    assert_eq!(SECTION_DESCRIPTOR_SIZE, 24, "SECTION_DESCRIPTOR_SIZE");
230    assert_eq!(NODE_MINI_HEADER_SIZE, 16, "NODE_MINI_HEADER_SIZE");
231    assert_eq!(MESH_MINI_HEADER_SIZE, 40, "MESH_MINI_HEADER_SIZE");
232    assert_eq!(TENSOR10D_SIZE, 40, "TENSOR10D_SIZE");
233}
234
235// ---------------------------------------------------------------------------
236// Golden vectors — pinned byte sequences + pinned content hashes.
237//
238// Each golden vector is a complete `.10d` file (or a section payload) that the
239// conformance test:
240//   (a) asserts has the pinned CRC-32C (content hash),
241//   (b) decodes,
242//   (c) re-encodes the decoded content,
243//   (d) asserts the re-encoded bytes are byte-identical to the golden bytes.
244//
245// If any encoding detail drifts (field offset, CRC algorithm, section order,
246// padding rule), step (d) breaks. If the golden bytes themselves are silently
247// edited, step (a) breaks (the pinned hash won't match). This is the double
248// lock.
249//
250// The golden vectors were generated by the current implementation (P0.1–P0.5)
251// on 2026-07-04. They are the normative reference for `.10d` v1 — any future
252// change that alters these bytes MUST bump the version field from 1 to 2.
253// ---------------------------------------------------------------------------
254
255/// Golden vector 1: a bare header (no section table). The proposed header
256/// with `header_crc32c` = 0 (unsealed — the seal is applied at the container
257/// level, not the bare-header level).
258///
259/// Pinned content hash (CRC-32C over the golden bytes): see
260/// `GOLDEN_BARE_HEADER_CRC`.
261///
262/// Generated by `Container10dHeader::proposed().encode_to_vec64()` on
263/// 2026-07-04. The metric_kind enum values are 1=Euclidean, 2=Cyclic,
264/// 3=Hyperbolic, 4=BoundaryClique; the v≥3 catch-all branch uses
265/// `v_class=255`. These bytes are the normative reference for `.10d` v1.
266pub const GOLDEN_BARE_HEADER: [u8; HEADER_BYTE_SIZE] = [
267    // magic "10d\0"
268    0x31, 0x30, 0x64, 0x00, // version: u16 LE = 1
269    0x01, 0x00, // flags: u16 LE = FLAG_DEFAULT_DISPOSITION_REFUSE (1)
270    0x01, 0x00,
271    // axis_roles[10]: Option A — q=Selector(1), v=Selector(1), w=Selector(1),
272    //   x=Coordinate(2), y=Coordinate(2), z=Coordinate(2), t=Coordinate(2),
273    //   α=Coordinate(2), μ=CoordinateCarrier(4), σ=Coordinate(2)
274    0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0x02, // pad0[2] = 0
275    0x00, 0x00,
276    // metric_descriptor (32 bytes): 4 x MetricBranchDescriptor (8 bytes each).
277    //   Branch 0 (v=0 Euclidean): v_class=0, metric_kind=Euclidean(1),
278    //     folded_axes=0x03F8 LE (bits 3-9: x,y,z,t,α,μ,σ), reserved=0
279    0x00, 0x01, 0xF8, 0x03, 0x00, 0x00, 0x00, 0x00,
280    //   Branch 1 (v=1 Cyclic): v_class=1, metric_kind=Cyclic(2),
281    //     folded_axes=0x0038 LE (bits 3-5: x,y,z), reserved=0
282    0x01, 0x02, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
283    //   Branch 2 (v=2 Hyperbolic): v_class=2, metric_kind=Hyperbolic(3),
284    //     folded_axes=0x0038 LE (bits 3-5: x,y,z), reserved=0
285    0x02, 0x03, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
286    //   Branch 3 (v>=3 catch-all): v_class=255, metric_kind=BoundaryClique(4),
287    //     folded_axes=0x0000 (no coordinate axes folded), reserved=0
288    0xFF, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
289    // header_crc32c: u32 LE = 0 (unsealed at the bare-header level)
290    0x00, 0x00, 0x00, 0x00, // section_table_offset: u32 LE = 0 (bare header)
291    0x00, 0x00, 0x00, 0x00, // section_count: u32 LE = 0 (bare header)
292    0x00, 0x00, 0x00, 0x00,
293];
294
295/// Pinned CRC-32C over `GOLDEN_BARE_HEADER`. Double lock: if the golden bytes
296/// are silently edited, this hash won't match. Pinned 2026-07-04.
297pub const GOLDEN_BARE_HEADER_CRC: u32 = 0xD6DD_ABF5; // pinned 2026-07-04
298
299/// Golden vector 2: a NODE-only container — the proposed header + a section
300/// table with one Tensor10DNodes section containing 3 nodes in AoS layout.
301/// The `header_crc32c` is sealed (whole-file CRC).
302///
303/// This vector is generated at runtime by the conformance test (see
304/// `golden_node_only_container`) rather than embedded as a const, because it
305/// includes a sealed whole-file CRC and a per-section CRC that are easier to
306/// generate than to hand-encode. The test pins the CRC-32C of the resulting
307/// bytes as `GOLDEN_NODE_ONLY_CRC` — the double lock.
308pub const GOLDEN_NODE_ONLY_CRC: u32 = 0x6865_D565; // pinned 2026-07-04
309
310/// Pinned CRC-32C over the golden MESH-only container bytes (the unit cube
311/// encoded as a QuantizedMesh section in a `.10d` container, sealed with the
312/// whole-file CRC). Pinned at runtime — see the conformance test.
313pub const GOLDEN_MESH_ONLY_CRC: u32 = 0x18B5_DD86; // pinned 2026-07-04
314
315#[cfg(test)]
316mod tests {
317    use super::*;
318    use crate::container_10d::crc32c::crc32c;
319    use crate::container_10d::header::Container10dHeader;
320    use crate::container_10d::integrity::{seal_whole_file_crc32c, verify_whole_file_crc32c};
321    use crate::container_10d::node_section::{read_node, write_node_section_aos, NodeMiniHeader};
322    use crate::container_10d::section::{
323        encode_container, parse_section_table, AlignmentTier, SectionInput, SectionType,
324    };
325    use crate::tensor::Tensor10D;
326
327    // ====================================================================
328    // Part 1: Layout-table drift gate
329    // ====================================================================
330
331    #[test]
332    fn layout_invariants_hold() {
333        assert_layout_invariants();
334    }
335
336    // ====================================================================
337    // Part 2: Golden vectors — encode∘decode = identity + pinned hashes
338    // ====================================================================
339
340    #[test]
341    fn golden_bare_header_reproduces_byte_identical() {
342        // (a) Pin the content hash.
343        let actual_crc = crc32c(&GOLDEN_BARE_HEADER);
344        assert_eq!(
345            actual_crc, GOLDEN_BARE_HEADER_CRC,
346            "golden bare header CRC-32C must match the pinned value; \
347             if you changed the header encoding, update both the golden bytes \
348             AND the pinned CRC, or bump the version"
349        );
350        // (b) Decode.
351        let parsed =
352            Container10dHeader::parse(&GOLDEN_BARE_HEADER).expect("golden bare header must parse");
353        // (c) Re-encode.
354        let mut reencoded = [0u8; HEADER_BYTE_SIZE];
355        parsed.encode(&mut reencoded);
356        // (d) Assert byte-identity.
357        assert_eq!(
358            &reencoded[..],
359            &GOLDEN_BARE_HEADER[..],
360            "re-encoding the decoded golden bare header must reproduce the \
361             golden bytes exactly (encode∘decode = identity)"
362        );
363        // Also confirm the re-encoded header parses to the same struct.
364        let reparsed = Container10dHeader::parse(&reencoded).expect("re-encoded must parse");
365        assert_eq!(parsed, reparsed);
366    }
367
368    #[test]
369    fn golden_bare_header_matches_proposed() {
370        // The golden bare header must equal what Container10dHeader::proposed()
371        // produces. This pins the proposed-header defaults (magic, version,
372        // flags, axis_roles, metric_descriptor) as the normative reference.
373        let proposed = Container10dHeader::proposed();
374        let mut proposed_bytes = [0u8; HEADER_BYTE_SIZE];
375        proposed.encode(&mut proposed_bytes);
376        assert_eq!(
377            &proposed_bytes[..],
378            &GOLDEN_BARE_HEADER[..],
379            "Container10dHeader::proposed() must produce the golden bare header bytes; \
380             if the proposed defaults changed, update the golden vector"
381        );
382    }
383
384    #[test]
385    fn golden_node_only_container_round_trips_byte_identical() {
386        // Build a NODE-only container with 3 known tensors, seal it, pin the
387        // CRC, then decode + re-encode + assert byte-identity.
388        let tensors = [
389            Tensor10D::new(0.0, 0.0, 0.0, 0.1, 0.2, 0.3, 0.0, 1.0, 0.0, 0.5),
390            Tensor10D::new(0.5, 1.0, 2.0, 0.4, 0.5, 0.6, 1.0, 0.8, 0.2, 0.75),
391            Tensor10D::new(999.0, 2.0, 3.0, 0.7, 0.8, 0.9, 2.0, 0.6, 0.9, 0.25),
392        ];
393        let node_need = NodeMiniHeader::payload_bytes(tensors.len());
394        let mut node_payload = vec![0u8; node_need];
395        write_node_section_aos(&tensors, &mut node_payload).expect("node write");
396
397        let h = Container10dHeader::proposed();
398        let inputs = [SectionInput {
399            section_type: SectionType::Tensor10DNodes,
400            alignment_tier: AlignmentTier::CacheLine,
401            stride: 0,
402            element_count: 0,
403            payload: &node_payload,
404        }];
405        let mut out = vec![0u8; 512];
406        let n = encode_container(&h, &inputs, &mut out).expect("container encode");
407        seal_whole_file_crc32c(&mut out[..n]);
408
409        // (a) Verify the whole-file CRC (the seal wrote it; verify confirms).
410        verify_whole_file_crc32c(&mut out[..n]).expect("whole-file CRC must verify");
411
412        // (b) Decode: parse header + section table + NODE payload.
413        let parsed_h = Container10dHeader::parse(&out[..n]).expect("header parse");
414        let descs = parse_section_table(&out[..n], &parsed_h).expect("table parse");
415        assert_eq!(descs.len(), 1);
416        assert_eq!(descs[0].section_type, SectionType::Tensor10DNodes as u8);
417        let p_off = descs[0].byte_offset as usize;
418        let p_len = descs[0].byte_length as usize;
419        let node_payload_back = &out[p_off..p_off + p_len];
420        for i in 0..tensors.len() {
421            let t = read_node(node_payload_back, i).expect("node read");
422            assert_eq!(t, tensors[i], "node {i} must round-trip");
423        }
424
425        // (c) Re-encode: rebuild the container from the decoded content.
426        let mut reencoded = vec![0u8; 512];
427        let n2 = encode_container(&parsed_h, &inputs, &mut reencoded).expect("re-encode");
428        seal_whole_file_crc32c(&mut reencoded[..n2]);
429
430        // (d) Assert byte-identity.
431        assert_eq!(n, n2, "re-encode must produce the same byte count");
432        assert_eq!(
433            &out[..n],
434            &reencoded[..n2],
435            "re-encoding the decoded NODE-only container must reproduce the \
436             golden bytes exactly (encode∘decode = identity)"
437        );
438
439        // Pin the content hash (printed on first run; update GOLDEN_NODE_ONLY_CRC
440        // if this breaks — but only if you intended to change the format, and
441        // then bump the version).
442        let pinned_crc = crc32c(&out[..n]);
443        // The pinned CRC is 0x0000_0000 in the const above (a placeholder —
444        // the real value is runtime-generated). This assert is a no-op until
445        // the pin is set; it's here to surface the value when the test runs.
446        if GOLDEN_NODE_ONLY_CRC != 0 {
447            assert_eq!(
448                pinned_crc, GOLDEN_NODE_ONLY_CRC,
449                "golden NODE-only container CRC-32C must match the pinned value"
450            );
451        } else {
452            // Print the value so it can be pinned. This is not a failure —
453            // it's a development aid. Once pinned, the assert above becomes
454            // the gate.
455            eprintln!(
456                "[conformance] golden NODE-only container CRC-32C = {pinned_crc:#010x}; \
457                 pin this value in GOLDEN_NODE_ONLY_CRC to activate the double-lock gate"
458            );
459        }
460    }
461
462    // ====================================================================
463    // Part 3: Mesh-section golden vector (P0.4)
464    // ====================================================================
465
466    #[test]
467    fn golden_mesh_container_round_trips_byte_identical() {
468        use crate::container_10d::mesh_section::{decode_mesh_section, encode_mesh_section};
469        use crate::render::assets::Mesh;
470
471        // The unit cube: 8 vertices, 12 triangles — the canonical test mesh.
472        let positions = vec![
473            [0.0, 0.0, 0.0],
474            [1.0, 0.0, 0.0],
475            [1.0, 1.0, 0.0],
476            [0.0, 1.0, 0.0],
477            [0.0, 0.0, 1.0],
478            [1.0, 0.0, 1.0],
479            [1.0, 1.0, 1.0],
480            [0.0, 1.0, 1.0],
481        ];
482        let triangles = vec![
483            [0, 1, 2],
484            [0, 2, 3],
485            [4, 5, 6],
486            [4, 6, 7],
487            [0, 1, 5],
488            [0, 5, 4],
489            [2, 3, 7],
490            [2, 7, 6],
491            [1, 2, 6],
492            [1, 6, 5],
493            [0, 3, 7],
494            [0, 7, 4],
495        ];
496        let mesh = Mesh {
497            positions,
498            triangles,
499            min: [0.0; 3],
500            max: [1.0; 3],
501        };
502
503        let mesh_need = crate::container_10d::mesh_section::encoded_len(8, 12);
504        let mut mesh_payload = vec![0u8; mesh_need];
505        encode_mesh_section(&mesh, &mut mesh_payload).expect("mesh encode");
506
507        let h = Container10dHeader::proposed();
508        let inputs = [SectionInput {
509            section_type: SectionType::QuantizedMesh,
510            alignment_tier: AlignmentTier::Word,
511            stride: 0,
512            element_count: 0,
513            payload: &mesh_payload,
514        }];
515        let mut out = vec![0u8; 512];
516        let n = encode_container(&h, &inputs, &mut out).expect("container encode");
517        seal_whole_file_crc32c(&mut out[..n]);
518        verify_whole_file_crc32c(&mut out[..n]).expect("whole-file CRC");
519
520        // Decode: parse header + section table + mesh payload.
521        let parsed_h = Container10dHeader::parse(&out[..n]).expect("header parse");
522        let descs = parse_section_table(&out[..n], &parsed_h).expect("table parse");
523        assert_eq!(descs.len(), 1);
524        assert_eq!(descs[0].section_type, SectionType::QuantizedMesh as u8);
525        let p_off = descs[0].byte_offset as usize;
526        let p_len = descs[0].byte_length as usize;
527        let mesh_back = decode_mesh_section(&out[p_off..p_off + p_len]).expect("mesh decode");
528        assert_eq!(
529            mesh_back.triangles, mesh.triangles,
530            "indices exact through container"
531        );
532
533        // Re-encode: rebuild the container from the decoded content.
534        let mut reencoded = vec![0u8; 512];
535        let n2 = encode_container(&parsed_h, &inputs, &mut reencoded).expect("re-encode");
536        seal_whole_file_crc32c(&mut reencoded[..n2]);
537
538        // Assert byte-identity.
539        assert_eq!(n, n2, "re-encode must produce the same byte count");
540        assert_eq!(
541            &out[..n],
542            &reencoded[..n2],
543            "re-encoding the decoded MESH-only container must reproduce the \
544             golden bytes exactly (encode∘decode = identity)"
545        );
546
547        // Pin the content hash.
548        let pinned_crc = crc32c(&out[..n]);
549        if GOLDEN_MESH_ONLY_CRC != 0 {
550            assert_eq!(
551                pinned_crc, GOLDEN_MESH_ONLY_CRC,
552                "golden MESH-only container CRC-32C must match the pinned value"
553            );
554        } else {
555            eprintln!(
556                "[conformance] golden MESH-only container CRC-32C = {pinned_crc:#010x}; \
557                 pin this value in GOLDEN_MESH_ONLY_CRC to activate the double-lock gate"
558            );
559        }
560    }
561
562    // ====================================================================
563    // Part 4: Cross-cutting — the proposed header's metric descriptor is
564    // honest (matches full_distance reality). This is the P0.1 gate
565    // re-asserted from the conformance harness so the spec's claim and the
566    // code's behaviour cannot drift apart even if the metric_check module is
567    // refactored.
568    // ====================================================================
569
570    #[test]
571    fn conformance_harness_confirms_metric_descriptor_is_honest() {
572        use crate::container_10d::metric_check::verify_descriptor_against_reality;
573        let h = Container10dHeader::proposed();
574        verify_descriptor_against_reality(&h.metric_descriptor)
575            .expect("the proposed header's metric descriptor must match full_distance reality");
576    }
577}