Skip to main content

qualia_core_db/container_10d/
mod.rs

1//! `.10d` living-container v1 — the normative header, axis-role taxonomy, and
2//! metric-completeness descriptor that serialize the 10-D tensor runtime.
3//!
4//! This is the **P0.1 barrier task**: the surface every later P0 task (section
5//! table, CRC-32C integrity, quantized-mesh section, Tensor10D node section,
6//! renderer upload path, conformance vectors, WASM parity) consumes. It lands
7//! alone first; no swarm fan-out on P0.1 itself.
8//!
9//! Scope of P0.1 (what is implemented-in-code here vs. spec-reserved):
10//!
11//! - **Implemented:** `AxisRole` taxonomy + the proposed (not-yet-frozen)
12//!   Option A table; `MetricCompletenessDescriptor` + the
13//!   `verify_descriptor_against_reality` gate that introspects
14//!   `Tensor10D::full_distance`; `Container10dHeader` POD (64 bytes, repr(C),
15//!   zero padding asserted) with `encode`/`parse` running every P0.1
16//!   acceptance gate (bad magic / unknown version / undefined axis role /
17//!   non-zero padding / metric-completeness divergence).
18//! - **Spec-reserved (NOT yet implemented — do not report as working):**
19//!   `header_crc32c` (P0.3 wires the shared CRC-32C delegated from
20//!   `q42/p64_weight.rs`); the section table, tiered alignment, and
21//!   per-section CRC (P0.2); the quantized-mesh section (P0.4); the Tensor10D
22//!   node section (P0.5); the renderer upload path (P0.6); conformance
23//!   vectors (P0.7); WASM parity build gate (P0.8).
24//!
25//! Two ⚑ format decisions were resolved by Timothy Charles Holborn on
26//! 2026-07-04 and are encoded here as the not-yet-frozen defaults:
27//!
28//! 1. **Axis-role taxonomy (Option A):** `q,v,w` = `Selector`; `x,y,z,t,α,σ`
29//!    = `Coordinate`; `μ` = `CoordinateCarrier` (dual-role: a coordinate that
30//!    is also the in-band provenance carrier).
31//! 2. **Metric-completeness (option b — document the limitation):** the header
32//!    encodes the current `full_distance` reality. `v=0` Euclidean folds all
33//!    seven COORDINATEs; `v=1` Cyclic and `v=2` Hyperbolic fold `x,y,z` only;
34//!    `v>=3` Boundary clique folds no coordinate axes (byte-equality on `v`).
35//!    P7.9 (making the non-Euclidean metrics axis-complete via product /
36//!    warped-product manifolds and a weighted clique-graph) is deferred as
37//!    future geometry design work — see the progress log.
38//!
39//! Reference: `docs/plans/native-computational-geometry.md` §4.1,
40//! `docs/plans/native-computational-geometry-EXECUTION.md` P0.1, and the
41//! cross-cutting gate "Honest axis-role taxonomy & metric-completeness
42//! (queryability claim == code)".
43
44pub mod axis_role;
45pub mod conformance;
46pub mod crc32c;
47pub mod header;
48pub mod integrity;
49pub mod mesh_section;
50pub mod metric_check;
51pub mod node_section;
52pub mod provenance_section;
53pub mod section;
54// `topology_section` and `spatial_index_section` depend on
55// `crate::specialized_libs::computational_geometry`, which is itself gated
56// `#[cfg(any(not(target_arch = "wasm32"), feature = "wasm-scientific"))]` at
57// `lib.rs`. The slim `--features portal` WASM build (no `wasm-scientific`)
58// configures `specialized_libs` out, so these two section modules must carry
59// the same gate or the crate fails to compile for wasm32. Their only external
60// consumers (`tool.rs`, `query_frontend.rs`) live inside `specialized_libs`
61// and carry the same gate, so this is symmetric — no portal-path regression
62// (the portal renderer upload path uses `mesh_section`, which has no
63// `specialized_libs` dependency).
64#[cfg(any(not(target_arch = "wasm32"), feature = "wasm-scientific"))]
65pub mod spatial_index_section;
66#[cfg(any(not(target_arch = "wasm32"), feature = "wasm-scientific"))]
67pub mod topology_section;
68
69pub use axis_role::{
70    AxisRole, AXIS_ORDER, COORDINATE_AXES, MU_AXIS, PROPOSED_AXIS_ROLES, SELECTOR_AXES,
71};
72pub use crc32c::{crc32c, crc32c_update};
73pub use header::{
74    Container10dHeader, HeaderParseError, FLAG_DEFAULT_DISPOSITION_REFUSE, HEADER_BYTE_SIZE,
75    HEADER_VERSION, MAGIC_10D, MAX_SECTION_COUNT,
76};
77pub use integrity::{
78    compute_whole_file_crc32c, seal_whole_file_crc32c, verify_whole_file_crc32c, IntegrityError,
79};
80pub use mesh_section::{
81    decode_mesh_section, encode_mesh_section, parse_mesh_header, MeshMiniHeader, MeshSectionError,
82    FLAG_U16_INDICES, MAX_TRIANGLE_COUNT, MAX_VERTEX_COUNT, MESH_MINI_HEADER_SIZE,
83};
84pub use metric_check::{
85    proposed_metric_descriptor, verify_descriptor_against_reality, MetricBranchDescriptor,
86    MetricCompletenessDescriptor, MetricDivergence, MetricKind, BOUNDARY_CLIQUE_BRANCH_INDEX,
87    METRIC_BRANCH_COUNT,
88};
89pub use node_section::{
90    parse_node_header, read_node, read_node_aos, read_node_soa, read_node_soa_lane,
91    transpose_aos_to_soa, transpose_soa_to_aos, write_node_q_at, write_node_section_aos,
92    write_node_section_soa, NodeMiniHeader, NodeSectionError, AXIS_COUNT, LAYOUT_AOS, LAYOUT_SOA,
93    MAX_NODE_COUNT, NODE_MINI_HEADER_SIZE, TENSOR10D_SIZE,
94};
95pub use provenance_section::{
96    decode_provenance_section, encode_provenance_section, encoded_len as provenance_encoded_len,
97    validate_provenance, ProvenanceMiniHeader, ProvenanceSectionError, ProvenanceSidecar,
98    ProvenanceSidecarView, FLAG_HAS_VC, PROVENANCE_MAGIC, PROVENANCE_MINI_HEADER_SIZE,
99    PROVENANCE_SECTION_VERSION,
100};
101pub use section::{
102    encode_container, parse_section_table, AlignmentTier, SectionDescriptor, SectionInput,
103    SectionTableError, SectionType, SECTION_DESCRIPTOR_SIZE,
104};
105#[cfg(any(not(target_arch = "wasm32"), feature = "wasm-scientific"))]
106pub use spatial_index_section::{
107    decode_spatial_index_section, encode_spatial_index_section, DecodedSpatialIndex,
108    SpatialIndexMiniHeader, SpatialIndexSectionError, SPATIAL_INDEX_MINI_HEADER_SIZE,
109};
110#[cfg(any(not(target_arch = "wasm32"), feature = "wasm-scientific"))]
111pub use topology_section::{
112    decode_topology_section, encode_topology_section, TopologyMiniHeader, TopologySectionData,
113    TopologySectionError, TOPOLOGY_MINI_HEADER_SIZE,
114};
115
116/// Versioned `.10d` container ABI. Increment only when public POD layouts or
117/// caller-buffer contracts change. P0.1 sets this to 1; P0.2/P0.3 may raise it
118/// when the section table + CRC lands.
119pub const CONTAINER_10D_ABI_VERSION: u32 = 1;