Skip to main content

qualia_core_db/topology/
header.rs

1//! Normative 64-byte cache-line-aligned headers (`PoetGeometryHeader`, `HarbouredGraphHeader`),
2//! 16-byte `CellAnchor`, morphological & geometric enums, and `TopologyInvariants` bitflags
3//! for the POET Geometry-Topology Complex ("Geometries Harbour Many Graphs").
4//!
5//! Tier-1 Zero-Heap (`AGENTS.md` §0 & §0-A): all binary descriptors are `#[repr(C)]`,
6//! `bytemuck::Pod + bytemuck::Zeroable`, with compile-time size and alignment assertions.
7
8use bytemuck::{Pod, Zeroable};
9use serde::{Deserialize, Serialize};
10
11/// Magic 4-byte tag (`"GTOP"`) identifying a Geometry-Topology Complex segment in `.q42` / `.10d`.
12pub const GTOP_MAGIC: [u8; 4] = *b"GTOP";
13
14/// Classification of the host Geometry Complex that harbours graphs.
15#[repr(u8)]
16#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
17pub enum GeometryComplexKind {
18    /// Pure metric point-cloud / 0-cell space in Tensor10D (induces ε-ball, Delaunay, c-kNN graphs).
19    #[default]
20    MetricPointCloud10D = 0x01,
21    /// 2D Planar subdivision / Doubly-Connected Edge List (`dcel_overlay::Dcel`, polygons with holes).
22    PlanarDcel2D = 0x02,
23    /// 2-Manifold surface mesh / Combinatorial 2-Map (`mesh_section`, `topology_section`, `combinatorial_map::Dart`).
24    SurfaceManifold2D = 0x03,
25    /// k-Simplicial / Cochain Complex with DEC operators (`ddg_operators::ChainTerm`, `HodgeSummary`, ∂∘∂=0).
26    SimplicialComplex = 0x04,
27    /// Mixed polyhedral volumetric complex: Triangles, Quads, Tetrahedra, Hexahedra (`mixed_cell_topology::MixedCell`).
28    MixedCellComplex3D = 0x05,
29    /// Constructive Solid Geometry & 3D surface arrangement (`csg_section::CSG1`, `arrangement_3d`, CAD B-Rep).
30    CsgArrangement3D = 0x06,
31    /// 2:1 Balanced Quadtree / Octree / Sparse Voxel DAG (`quad_octree_mesh`, `voxel_section::VOX0`).
32    HierarchicalTreeGrid = 0x07,
33    /// Statistical manifold / probability simplex Δ^{n-1} with Fisher-Rao & Bregman-KL geometry (`statistical_manifold`).
34    StatisticalSimplex = 0x08,
35    /// Periodic Toroidal / Lattice wave-field domain (`TopologyClass::Cyclic`, PDE/CFD grid).
36    ToroidalWaveLattice = 0x09,
37    /// POET HyperCanvas Multi-Strata Layout Geometry (2D/3D/10D container boxes, strata planes & portals).
38    HyperCanvasLayout = 0x0A,
39}
40
41impl GeometryComplexKind {
42    #[inline]
43    pub const fn from_u8(v: u8) -> Option<Self> {
44        match v {
45            0x01 => Some(Self::MetricPointCloud10D),
46            0x02 => Some(Self::PlanarDcel2D),
47            0x03 => Some(Self::SurfaceManifold2D),
48            0x04 => Some(Self::SimplicialComplex),
49            0x05 => Some(Self::MixedCellComplex3D),
50            0x06 => Some(Self::CsgArrangement3D),
51            0x07 => Some(Self::HierarchicalTreeGrid),
52            0x08 => Some(Self::StatisticalSimplex),
53            0x09 => Some(Self::ToroidalWaveLattice),
54            0x0A => Some(Self::HyperCanvasLayout),
55            _ => None,
56        }
57    }
58
59    #[inline]
60    pub fn from_name(name: &str) -> Option<Self> {
61        match name.trim() {
62            "MetricPointCloud10D" | "PointCloud" => Some(Self::MetricPointCloud10D),
63            "PlanarDcel2D" | "DCEL" => Some(Self::PlanarDcel2D),
64            "SurfaceManifold2D" | "SurfaceMesh" => Some(Self::SurfaceManifold2D),
65            "SimplicialComplex" => Some(Self::SimplicialComplex),
66            "MixedCellComplex3D" | "MixedCell" => Some(Self::MixedCellComplex3D),
67            "CsgArrangement3D" | "CSG" => Some(Self::CsgArrangement3D),
68            "HierarchicalTreeGrid" | "OctreeGrid" => Some(Self::HierarchicalTreeGrid),
69            "StatisticalSimplex" => Some(Self::StatisticalSimplex),
70            "ToroidalWaveLattice" | "ToroidalLattice" => Some(Self::ToroidalWaveLattice),
71            "HyperCanvasLayout" | "HyperCanvas" => Some(Self::HyperCanvasLayout),
72            _ => None,
73        }
74    }
75}
76
77/// Ambient metric law governing distance & curvature in the host Geometry.
78#[repr(u8)]
79#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
80pub enum GeometryMetricKind {
81    #[default]
82    Euclidean = 0x00,
83    ToroidalCyclic = 0x01,
84    HyperbolicPoincare = 0x02,
85    SphericalGeodesic = 0x03,
86    FisherRaoSimplex = 0x04,
87    LorentzianCausal = 0x05,
88}
89
90impl GeometryMetricKind {
91    #[inline]
92    pub const fn from_u8(v: u8) -> Option<Self> {
93        match v {
94            0x00 => Some(Self::Euclidean),
95            0x01 => Some(Self::ToroidalCyclic),
96            0x02 => Some(Self::HyperbolicPoincare),
97            0x03 => Some(Self::SphericalGeodesic),
98            0x04 => Some(Self::FisherRaoSimplex),
99            0x05 => Some(Self::LorentzianCausal),
100            _ => None,
101        }
102    }
103}
104
105/// How a HarbouredGraph relates to its host `GeometryComplexKind`.
106#[repr(u8)]
107#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
108pub enum GraphEmbedRole {
109    /// Primal 1-skeleton: 0-cells (vertices) connected by 1-cells (edges).
110    #[default]
111    Primal1Skeleton = 0x01,
112    /// Poincaré / Voronoi / Circumcentric Dual: k-cells (faces/volumes) connected across shared (k-1)-facets.
113    PoincareDual = 0x02,
114    /// Levi / Hasse Boundary Incidence Bipartite Graph: (k)-cells ↔ boundary (k-1)-cells (∂_k operator).
115    BoundaryIncidence = 0x03,
116    /// Combinatorial Dart Involution Graph: darts linked by β₁ (next-in-face), β₂ (twin), β₃ (adjacent-volume).
117    CombinatorialDartMap = 0x04,
118    /// Multigrid / Spatial Hierarchy Tree: parent-child subdivision + 2:1 balanced face-neighbour links.
119    SpatialHierarchy = 0x05,
120    /// Metric-Induced Proximity Graph: Geodesic kNN (`cknn_laplacian`), ε-ball, Delaunay, or Gabriel graph.
121    MetricProximity = 0x06,
122    /// Medial Axis / Curve Skeleton / Reeb Graph (`curve_skeleton`, `chordal_axis_2d`, Morse-Smale).
123    TopologicalSkeleton = 0x07,
124    /// Embedded Semantic / Ontological Graph: `NQuin` triples/hyperedges anchored to k-cells of the geometry.
125    SemanticOverlay = 0x08,
126    /// Deontic / Normative Governance Graph: permissions, obligations, prohibitions & consent boundaries over regions.
127    DeonticGovernance = 0x09,
128    /// Causal / Temporal / Flux Graph: CFD/hydrological flux, neural message-passing, or LTL state trace over cells.
129    CausalFlux = 0x0A,
130}
131
132impl GraphEmbedRole {
133    #[inline]
134    pub const fn from_u8(v: u8) -> Option<Self> {
135        match v {
136            0x01 => Some(Self::Primal1Skeleton),
137            0x02 => Some(Self::PoincareDual),
138            0x03 => Some(Self::BoundaryIncidence),
139            0x04 => Some(Self::CombinatorialDartMap),
140            0x05 => Some(Self::SpatialHierarchy),
141            0x06 => Some(Self::MetricProximity),
142            0x07 => Some(Self::TopologicalSkeleton),
143            0x08 => Some(Self::SemanticOverlay),
144            0x09 => Some(Self::DeonticGovernance),
145            0x0A => Some(Self::CausalFlux),
146            _ => None,
147        }
148    }
149
150    #[inline]
151    pub fn from_name(name: &str) -> Option<Self> {
152        match name.trim() {
153            "Primal1Skeleton" | "Primal" => Some(Self::Primal1Skeleton),
154            "PoincareDual" | "Dual" => Some(Self::PoincareDual),
155            "BoundaryIncidence" | "Incidence" => Some(Self::BoundaryIncidence),
156            "CombinatorialDartMap" | "DartMap" => Some(Self::CombinatorialDartMap),
157            "SpatialHierarchy" | "Hierarchy" => Some(Self::SpatialHierarchy),
158            "MetricProximity" | "Proximity" => Some(Self::MetricProximity),
159            "TopologicalSkeleton" | "Skeleton" => Some(Self::TopologicalSkeleton),
160            "SemanticOverlay" | "Semantic" => Some(Self::SemanticOverlay),
161            "DeonticGovernance" | "Deontic" => Some(Self::DeonticGovernance),
162            "CausalFlux" | "Causal" => Some(Self::CausalFlux),
163            _ => None,
164        }
165    }
166}
167
168/// Fundamental graph morphology of an individual `HarbouredGraph`.
169#[repr(u8)]
170#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
171pub enum GraphMorphology {
172    /// Unconstrained directed multigraph (standard semantic triples / general wiring).
173    #[default]
174    DirectedMultigraph = 0x01,
175    /// Strictly acyclic directed graph; enforced on edit/seal for proofs, calc DAGs, watersheds, and toolchains.
176    DeterministicDAG = 0x02,
177    /// RDF-Star / RDF 1.2 triple-terms (`TAG_EMBEDDED`) where edges are simultaneously vertices.
178    HyperGraph = 0x03,
179    /// Undirected symmetric graph (e.g. primal mesh 1-skeleton, dual face adjacency, c-kNN Laplacian).
180    SymmetricGraph = 0x04,
181    /// Bipartite / Factor / Incidence graph (e.g. Levi boundary graph C_k ↔ C_{k-1}, Petri net, REA flow).
182    BipartiteFactor = 0x05,
183    /// Involution / Permutation dart graph (Combinatorial Map β₁/β₂/β₃).
184    InvolutionMap = 0x06,
185}
186
187impl GraphMorphology {
188    #[inline]
189    pub const fn from_u8(v: u8) -> Option<Self> {
190        match v {
191            0x01 => Some(Self::DirectedMultigraph),
192            0x02 => Some(Self::DeterministicDAG),
193            0x03 => Some(Self::HyperGraph),
194            0x04 => Some(Self::SymmetricGraph),
195            0x05 => Some(Self::BipartiteFactor),
196            0x06 => Some(Self::InvolutionMap),
197            _ => None,
198        }
199    }
200
201    #[inline]
202    pub fn from_name(name: &str) -> Option<Self> {
203        match name.trim() {
204            "DirectedMultigraph" | "Multigraph" => Some(Self::DirectedMultigraph),
205            "DeterministicDAG" | "DAG" => Some(Self::DeterministicDAG),
206            "HyperGraph" | "Hypergraph" => Some(Self::HyperGraph),
207            "SymmetricGraph" | "Symmetric" | "SimplicialComplex" => Some(Self::SymmetricGraph),
208            "BipartiteFactor" | "Bipartite" => Some(Self::BipartiteFactor),
209            "InvolutionMap" | "ToroidalLattice" => Some(Self::InvolutionMap),
210            _ => None,
211        }
212    }
213}
214
215/// Dimension / domain of the geometric element a graph vertex is anchored to.
216#[repr(u8)]
217#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
218pub enum AnchorDomain {
219    /// Pure semantic entity (`entity_hash` = 64-bit `q_hash`, `did:q42`, or `TAG_EMBEDDED` Virtual ID).
220    #[default]
221    SemanticQuin = 0xFF,
222    /// 0-Cell: geometric vertex / point index in the host Geometry.
223    Cell0Vertex = 0,
224    /// 1-Cell: geometric edge / half-edge / dart / curve index in the host Geometry.
225    Cell1Edge = 1,
226    /// 2-Cell: geometric face / triangle / quad / DCEL polygon index in the host Geometry.
227    Cell2Face = 2,
228    /// 3-Cell: geometric volume / tetrahedron / hexahedron / CSG solid / octree leaf index.
229    Cell3Volume = 3,
230    /// Higher k-Simplex or sub-manifold chart index (k >= 4).
231    CellKSimplex = 4,
232}
233
234impl AnchorDomain {
235    #[inline]
236    pub const fn from_u8(v: u8) -> Option<Self> {
237        match v {
238            0 => Some(Self::Cell0Vertex),
239            1 => Some(Self::Cell1Edge),
240            2 => Some(Self::Cell2Face),
241            3 => Some(Self::Cell3Volume),
242            4 => Some(Self::CellKSimplex),
243            0xFF => Some(Self::SemanticQuin),
244            _ => None,
245        }
246    }
247
248    #[inline]
249    pub fn from_name(name: &str) -> Option<Self> {
250        match name.trim() {
251            "Cell0Vertex" | "Vertex" | "0" => Some(Self::Cell0Vertex),
252            "Cell1Edge" | "Edge" | "1" => Some(Self::Cell1Edge),
253            "Cell2Face" | "Face" | "2" => Some(Self::Cell2Face),
254            "Cell3Volume" | "Volume" | "3" => Some(Self::Cell3Volume),
255            "CellKSimplex" | "Simplex" | "4" => Some(Self::CellKSimplex),
256            "SemanticQuin" | "NQuin" | "Quin" => Some(Self::SemanticQuin),
257            _ => None,
258        }
259    }
260}
261
262/// Structural, modal, and homological invariants enforced on a `HarbouredGraph` and its host Geometry.
263#[repr(transparent)]
264#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, Pod, Zeroable, Serialize, Deserialize)]
265pub struct TopologyInvariants(pub u16);
266
267impl TopologyInvariants {
268    pub const EMPTY: Self = Self(0);
269    /// Reject cycle-forming edits in POET (`DeterministicDAG`).
270    pub const ACYCLIC: Self = Self(1 << 0);
271    /// Implicit reachability closure.
272    pub const TRANSITIVE: Self = Self(1 << 1);
273    /// Undirected / bidirectional edges (`u -> v` implies `v -> u`).
274    pub const SYMMETRIC: Self = Self(1 << 2);
275    /// Implicit self-loops (`u -> u`).
276    pub const REFLEXIVE: Self = Self(1 << 3);
277    /// Edges resolve to `.q42` `NQuin` IDs / RDF-Star `TAG_EMBEDDED` virtual IDs.
278    pub const REIFIED_EDGES: Self = Self(1 << 4);
279    /// Edge weights derived from `.10d` Euclidean / geodesic / Fisher-Rao distance.
280    pub const SPATIAL_METRIC: Self = Self(1 << 5);
281    /// Edges must advance monotonically along `Tensor10D.t` (`d_6`) and Lamport clock (`metadata[32..60]`).
282    pub const TEMPORAL_MONOTONIC: Self = Self(1 << 6);
283    /// Reject or gate edges carrying active `OP_FORBID` (`0x12`) without a valid `DEFEATER_BIT`.
284    pub const DEONTIC_GUARDED: Self = Self(1 << 7);
285    /// Contradictory `BelnapStatus::Both` (`0x32`) vertices/edges are isolated to quarantine sub-context.
286    pub const PARACONSISTENT_ISOLATED: Self = Self(1 << 8);
287    /// Closed manifold homology invariant (no unsealed boundary 1-cells: ∂² = 0).
288    pub const MANIFOLD_CLOSED: Self = Self(1 << 9);
289    /// Enforce non-increasing sensitivity class (`context[56..63]`) across directed edges (no classified leak).
290    pub const SENSITIVITY_MONOTONIC: Self = Self(1 << 10);
291    /// Enforce chain-complex boundary exactness (`∂_{k-1} ∘ ∂_k = 0`).
292    pub const CHAIN_BOUNDARY_EXACT: Self = Self(1 << 11);
293
294    #[inline]
295    pub const fn contains(self, other: Self) -> bool { (self.0 & other.0) == other.0 }
296    #[inline]
297    pub const fn union(self, other: Self) -> Self { Self(self.0 | other.0) }
298    #[inline]
299    pub const fn bits(self) -> u16 { self.0 }
300    #[inline]
301    pub const fn from_bits_truncate(bits: u16) -> Self { Self(bits) }
302
303    pub fn from_name(name: &str) -> Option<Self> {
304        match name.trim() {
305            "ACYCLIC" => Some(Self::ACYCLIC),
306            "TRANSITIVE" => Some(Self::TRANSITIVE),
307            "SYMMETRIC" => Some(Self::SYMMETRIC),
308            "REFLEXIVE" => Some(Self::REFLEXIVE),
309            "REIFIED_EDGES" => Some(Self::REIFIED_EDGES),
310            "SPATIAL_METRIC" => Some(Self::SPATIAL_METRIC),
311            "TEMPORAL_MONOTONIC" => Some(Self::TEMPORAL_MONOTONIC),
312            "DEONTIC_GUARDED" => Some(Self::DEONTIC_GUARDED),
313            "PARACONSISTENT_ISOLATED" => Some(Self::PARACONSISTENT_ISOLATED),
314            "MANIFOLD_CLOSED" => Some(Self::MANIFOLD_CLOSED),
315            "SENSITIVITY_MONOTONIC" => Some(Self::SENSITIVITY_MONOTONIC),
316            "CHAIN_BOUNDARY_EXACT" | "BOUNDARY_EXACT" => Some(Self::CHAIN_BOUNDARY_EXACT),
317            _ => None,
318        }
319    }
320}
321
322impl core::ops::BitOr for TopologyInvariants {
323    type Output = Self;
324    #[inline]
325    fn bitor(self, rhs: Self) -> Self::Output {
326        Self(self.0 | rhs.0)
327    }
328}
329
330impl core::ops::BitOrAssign for TopologyInvariants {
331    #[inline]
332    fn bitor_assign(&mut self, rhs: Self) {
333        self.0 |= rhs.0;
334    }
335}
336
337/// 16-byte cache-aligned anchor mapping a dense graph vertex `u in 0..V_g`
338/// to both its host geometric k-cell AND its 64-bit `NQuin` semantic identity.
339#[repr(C, align(16))]
340#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Pod, Zeroable, Serialize, Deserialize)]
341pub struct CellAnchor {
342    /// 64-bit semantic identity (`q_hash`, `did:q42`, or RDF-Star `TAG_EMBEDDED` virtual ID; 0 if pure geometric).
343    pub entity_hash: u64,
344    /// Index into the host Geometry's k-cell table (`vertices`, `half_edges`, `faces`, `mixed_cells`, `oct_nodes`).
345    pub cell_index: u32,
346    /// `AnchorDomain` discriminant (0=0-cell, 1=1-cell, 2=2-cell, 3=3-cell, 4=k-simplex, 0xFF=pure NQuin).
347    pub anchor_domain: u8,
348    /// Orientation / incidence sign (+1, -1, or 0) for DEC cochain / boundary coupling.
349    pub orientation_sign: i8,
350    /// Sub-layer / stratum / material group tag.
351    pub material_or_stratum: u16,
352}
353
354const _: () = assert!(core::mem::size_of::<CellAnchor>() == 16);
355const _: () = assert!(core::mem::align_of::<CellAnchor>() == 16);
356
357impl CellAnchor {
358    #[inline]
359    pub const fn domain(&self) -> Option<AnchorDomain> {
360        AnchorDomain::from_u8(self.anchor_domain)
361    }
362}
363
364/// 64-byte cache-line aligned Host Geometry Header.
365/// A single `PoetGeometryHeader` owns the cellular/metric space and harbours
366/// `harboured_graph_count` (`M`) `HarbouredGraphHeader` entries at `graph_dir_offset`.
367#[repr(C, align(64))]
368#[derive(Copy, Clone, Debug, PartialEq, Eq, Pod, Zeroable, Serialize, Deserialize)]
369pub struct PoetGeometryHeader {
370    pub geometry_id: u64,
371    pub construct_schema_hash: u64,
372    pub manifold_id: u32,
373    pub cell_0_count: u32,
374    pub cell_1_count: u32,
375    pub cell_2_count: u32,
376    pub cell_3_count: u32,
377    pub geometry_payload_offset: u32,
378    pub ddg_operators_offset: u32,
379    pub graph_dir_offset: u32,
380    pub harboured_graph_count: u16,
381    pub active_graph_slot: u16,
382    pub euler_characteristic: i32,
383    pub complex_kind: u8,
384    pub metric_kind: u8,
385    pub ambient_dim: u8,
386    pub intrinsic_dim: u8,
387    pub crc32c: u32,
388}
389
390const _: () = assert!(core::mem::size_of::<PoetGeometryHeader>() == 64);
391const _: () = assert!(core::mem::align_of::<PoetGeometryHeader>() == 64);
392
393impl Default for PoetGeometryHeader {
394    fn default() -> Self { Self::zeroed() }
395}
396
397impl PoetGeometryHeader {
398    #[inline]
399    pub const fn complex_kind_enum(&self) -> Option<GeometryComplexKind> { GeometryComplexKind::from_u8(self.complex_kind) }
400    #[inline]
401    pub const fn metric_kind_enum(&self) -> Option<GeometryMetricKind> { GeometryMetricKind::from_u8(self.metric_kind) }
402    #[inline]
403    pub const fn computed_euler_characteristic(&self) -> i32 {
404        (self.cell_0_count as i32).wrapping_sub(self.cell_1_count as i32)
405            .wrapping_add(self.cell_2_count as i32).wrapping_sub(self.cell_3_count as i32)
406    }
407}
408
409/// 64-byte cache-line aligned descriptor for one Graph harboured inside a `PoetGeometryHeader`.
410#[repr(C, align(64))]
411#[derive(Copy, Clone, Debug, PartialEq, Eq, Pod, Zeroable, Serialize, Deserialize)]
412pub struct HarbouredGraphHeader {
413    pub graph_id: u64,
414    pub parent_geometry_id: u64,
415    pub anchor_table_offset: u32,
416    pub csr_row_ptr_offset: u32,
417    pub csr_col_idx_offset: u32,
418    pub edge_anchor_offset: u32,
419    pub csc_col_ptr_offset: u32,
420    pub csc_row_idx_offset: u32,
421    pub edge_weight_offset: u32,
422    pub vertex_count: u32,
423    pub edge_count: u32,
424    pub context_and_state_mask: u32,
425    pub embed_role: u8,
426    pub morphology: u8,
427    pub invariants: TopologyInvariants,
428    pub crc32c: u32,
429}
430
431const _: () = assert!(core::mem::size_of::<HarbouredGraphHeader>() == 64);
432const _: () = assert!(core::mem::align_of::<HarbouredGraphHeader>() == 64);
433
434impl Default for HarbouredGraphHeader {
435    fn default() -> Self {
436        Self::zeroed()
437    }
438}
439
440impl HarbouredGraphHeader {
441    #[inline]
442    pub const fn embed_role_enum(&self) -> Option<GraphEmbedRole> {
443        GraphEmbedRole::from_u8(self.embed_role)
444    }
445
446    #[inline]
447    pub const fn morphology_enum(&self) -> Option<GraphMorphology> {
448        GraphMorphology::from_u8(self.morphology)
449    }
450
451    #[inline]
452    pub const fn max_sensitivity_class(&self) -> u8 {
453        (self.context_and_state_mask & 0xFF) as u8
454    }
455
456    #[inline]
457    pub const fn max_depth(&self) -> u8 {
458        ((self.context_and_state_mask >> 24) & 0xFF) as u8
459    }
460}
461
462/// Deterministic error enumeration for Tier-1 and Tier-2 Topology operations.
463#[derive(Copy, Clone, Debug, PartialEq, Eq)]
464pub enum TopologyError {
465    BufferTooSmall,
466    UnalignedBuffer,
467    InvalidHeaderSize,
468    InvalidComplexKind(u8),
469    InvalidMorphology(u8),
470    InvalidEmbedRole(u8),
471    GraphSlotOutOfRange { slot: u16, count: u16 },
472    VertexOutOfRange { vertex: u32, count: u32 },
473    CellOutOfRange { domain: u8, index: u32, count: u32 },
474    NonMonotonicRowPtr { vertex: u32 },
475    ChecksumMismatch { expected: u32, actual: u32 },
476    DeltaRingFull { capacity: usize },
477    CycleDetected { source: u32, target: u32 },
478    TemporalMonotonicityViolation { source: u32, target: u32 },
479    DeonticForbidViolation { edge_anchor_idx: u32 },
480    ParaconsistentContagion { edge_anchor_idx: u32 },
481    SensitivityEscalation { source_class: u8, target_class: u8 },
482    ChainBoundaryNotZero { non_zero_terms: usize },
483    BudgetExhausted { requested: usize, budget: usize },
484}
485
486impl core::fmt::Display for TopologyError {
487    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
488        write!(f, "{:?}", self)
489    }
490}
491
492impl std::error::Error for TopologyError {}