Skip to main content

Module node_section

Module node_section 

Source
Expand description

.10d Tensor10D NODE section — the 40-byte epistemic atom in the container (P0.5).

A NODE section wraps a set of Tensor10D records (the 40-byte [q,v,w,x,y,z,t,α,μ,σ] stride) as a self-describing .10d section. It supports two byte-equivalent layouts:

  • AoS (array-of-structs): N × Tensor10D records back-to-back — the natural Tensor10D layout, identical to what tensor/buffer_export.rs::write_tensor_buffer produces (minus its 32-byte Q42* header, which the .10d container header replaces).
  • SoA (structure-of-arrays): ten contiguous lanes, one per axis — lane 0 = all q values, lane 1 = all v values, …, lane 9 = all σ values. This is the “page-friendly” layout the design doc §4.1 names: “any single axis is a contiguous strided read.”

AoS↔SoA is byte-identical (lossless transpose): converting AoS→SoA→AoS (or SoA→AoS→SoA) reproduces the original bytes exactly, because the transpose is just a reordering of the same N×10 f32 values with no precision loss. Per-axis SoA lane reads match AoS field reads: reading axis i for node j from the SoA layout yields the same f32 as reading field i from the j-th Tensor10D in the AoS layout.

write_tensor_q_at semantics: the wavefunction-collapse write (setting q for one node, returning the previous q) works on the NODE section in either layout — for AoS it writes the first f32 of the j-th record; for SoA it writes lane 0 (q) at position j. The semantics match tensor/buffer_export.rs::write_tensor_q_at exactly (same return-the-prev-q contract), with the only difference being the byte offset (the NODE section has a 16-byte mini-header where buffer_export.rs has a 32-byte Q42* header).

Determinism + CRC: two encodes of the same tensor set in the same layout are byte-identical (the AoS/SoA transpose is deterministic). The per-section CRC-32C (P0.2) catches a flipped bit in the payload. The whole-file CRC-32C (P0.3) catches header corruption.

Spec-reserved (NOT yet implemented): the mini-header’s reserved bytes are reserved for future per-axis SoA lane offset table, a q-superposition render/export mask (the design doc’s “render/export default to a ground-truth-only mask; Sandbox nodes not citable as provenance until collapsed”), and a GSR-result back-pointer. These are governance/attestation concerns (the SpecReservedGovernance / SpecReservedTemporalIndex section types) and are NOT wired here — P0.5 is the atom, not the attestation layer.

Structs§

NodeMiniHeader
The 16-byte NODE-section mini-header. repr(C), naturally aligned, no padding.

Enums§

NodeSectionError
NODE-section read/write error.

Constants§

AXIS_COUNT
Number of axes (lanes).
LAYOUT_AOS
Layout tag: 0 = AoS (array-of-structs), 1 = SoA (structure-of-arrays).
LAYOUT_SOA
MAX_NODE_COUNT
Maximum node count the NODE section will accept. Bounds against a hostile/malformed file: the 42MB Sentinel ceiling / 40 bytes per node = ~1M nodes max; 1M is a comfortable upper bound for a single section while keeping the mini-header’s node_count field well within range.
NODE_MINI_HEADER_SIZE
Section payload mini-header size in bytes.
TENSOR10D_SIZE
Tensor10D record size in bytes (10 × f32).

Functions§

parse_node_header
Parse and validate the NODE-section mini-header. Returns the header and the total payload byte length it claims.
read_node
Read one Tensor10D by index from a NODE section payload (dispatches on layout). Zero-heap.
read_node_aos
Read one Tensor10D by index from an AoS-layout NODE section. Zero-heap.
read_node_soa
Read one Tensor10D by index from an SoA-layout NODE section (assembles from ten lane reads). Zero-heap.
read_node_soa_lane
Read one f32 lane value (axis axis, node index) from an SoA-layout NODE section. Zero-heap. This is the “per-axis SoA lane read” the P0.5 acceptance gate names.
transpose_aos_to_soa
Transpose an AoS-layout NODE section payload to SoA into a caller-supplied output buffer. The output buffer must be at least total bytes. Zero-heap. This is the primary AoS→SoA path.
transpose_soa_to_aos
Transpose an SoA-layout NODE section payload to AoS into a caller-supplied output buffer. The output buffer must be at least total bytes. Zero-heap.
write_node_q_at
Write the q field (axis 0) for one node in a NODE section — the wavefunction-collapse semantics matching tensor/buffer_export.rs:: write_tensor_q_at. Returns the previous q value. Works on either layout. Zero-heap.
write_node_section_aos
Write a tensor set as a NODE section in AoS layout into a caller-supplied buffer. Returns the bytes written. Zero-heap.
write_node_section_soa
Write a tensor set as a NODE section in SoA layout into a caller-supplied buffer. Returns the bytes written. Zero-heap.