Skip to main content

Module integrity

Module integrity 

Source
Expand description

Integrity linter — read-time conformance findings.

The engine’s schema validation runs at write time as refusals on memstead_create / memstead_update / memstead_relate. This module runs the same checks in a read context over the entities already on disk, so memstead_health can report the conformance axis: which entities of a mem would a write refuse under a given schema, and why.

One validation truth, two contexts: every finding carries the same typed code (and the same recovery payload, via EngineError::code / EngineError::details) the corresponding write would refuse with. An entity that lints clean against schema S is accepted by a write under S, and vice versa — the linter never invents a parallel conformance vocabulary.

Determinism: same store state and schema produce the same findings in the same order, byte for byte. Entities are visited in lexical id order; within one entity, checks run in a fixed sequence (type, section keys, required sections, metadata, required fields, relationships) and map/list iteration follows the entity’s own deterministic on-disk order (IndexMap / Vec).

Structs§

IntegrityFinding
One per-entity integrity finding — the stable wire shape { id, axis, code, detail }.

Enums§

IntegrityAxis
Which integrity axis a finding belongs to. Consistency findings (graph coherence: orphans, stubs, dangling links) come from the pre-existing health categories; conformance findings (entity vs schema) come from this linter.

Functions§

conformance_findings
Run the conformance axis over every non-stub entity of mem, validating against schema (the mem’s current pin, or an arbitrary target schema — the caller chooses the effective schema).
consistency_findings
Run the consistency axis over mem, projecting the pre-existing graph-coherence checks into the integrity-finding shape: dangling wiki-links (DANGLING_LINK, on the linking entity) and stubs with their referrers (ORPHAN_STUB, on the stub). The category collectors are the same ones the dedicated health includes use — integrity is a projection, not a second implementation.
entity_conformance_findings
Conformance findings for a single entity — the per-entity slice of conformance_findings, exposed for callers that gate on one entity’s current conformance (the memstead_update repair-power gate). Empty result == the entity is conformant: a write of this entity under schema would be accepted.