pub enum ConstraintDef {
RequiresWhen {
field: String,
when_field: String,
when_value: String,
severity: ConstraintSeverity,
},
Unique {
fields: Vec<String>,
severity: ConstraintSeverity,
},
EnumFromNeighbour {
field: String,
rel_type: String,
section: String,
severity: ConstraintSeverity,
},
StatusPropagation {
field: String,
value: String,
rel_type: Option<String>,
rel_types: Option<Vec<String>>,
direction: PropagationDirection,
severity: ConstraintSeverity,
},
TransitionRequiresChecks {
field: String,
to_value: String,
relationships: Vec<String>,
direction: PropagationDirection,
severity: ConstraintSeverity,
},
}Expand description
One declared keep-health constraint on a type — the constraint
vocabulary (agent-toolbox plan 07). Declarations travel sealed with
the schema package and are rendered on the memstead_schema
response at BOTH verbosity levels (a hidden legality condition is a
defect class of its own). The kind tag is closed: an unknown kind
fails deserialization, so no declaration can load and be silently
ignored. Forms land vertically — a form is only declarable once the
engine evaluates it.
Variants§
RequiresWhen
Form 1 — conditional requirement: field (a metadata field or
section key of this type) is required whenever when_field
holds when_value (“status: checked requires checked_by”).
Fields
when_value: StringThe triggering value (validated against when_field’s
enum, when it declares one).
severity: ConstraintSeverityUnique
Form 2 — uniqueness: the tuple of metadata-field values named
in fields is unique among entities of this type within one
mem. Entities missing any of the fields carry no tuple and are
not compared. Defaults to block — the whole point of the
declaration is preventing the duplicate at write time.
Fields
fields: Vec<String>The metadata fields forming the unique tuple (each must be a declared metadata field of this type).
severity: ConstraintSeverityEnumFromNeighbour
Form 3 — enum-from-neighbour: the legal values of field are
the bullet-list entries (- value lines) of the section
section on the entity reached from this one via a rel_type
edge. A set value with no backing entry in any reached
neighbour’s section — including the no-neighbour and
missing-section cases, where nothing can back it — is a
violation.
Fields
severity: ConstraintSeverityStatusPropagation
Form 5 — status propagation: when field on an entity of this
type holds value (the terminal value), every entity reaching
it — transitively — via rel_type edges in direction is
tainted; tainted entities surface as health findings naming
their tainting ancestor. Always warn-tier: the taint arises
from the ancestor’s later change, so it can never refuse the
descendant’s historical write (the loader refuses a block
declaration on this form rather than accepting a promise the
engine will not keep).
Fields
value: StringThe terminal value that starts the taint (validated
against field’s enum, when it declares one).
rel_type: Option<String>The single rel-type the taint travels along. Exactly one
of rel_type / rel_types per declaration — the loader
refuses both-present and neither-present.
rel_types: Option<Vec<String>>The relation SET the taint travels along — the union subgraph, so a taint crosses rel-type boundaries. Inline list of declared names, per the bundle-wide convention.
direction: PropagationDirectionWhich direction reaches the dependents: incoming taints
the entities whose edges point at the terminal entity (and
their dependents, transitively); outgoing the entities
the terminal entity points at.
severity: ConstraintSeverityTransitionRequiresChecks
Form 6 — gated transition: a write that lands field holding
to_value requires every entity related via relationships
edges in direction to carry a fresh confirming check record
(derived verification state checked_ok — the engine’s checks
substrate; a stale or failed check does not confirm). Generic
by construction: any schema, any enum field, any relation set —
no type semantics baked in. Evaluated at write time in the
shared declared-constraints pass (block refuses, warn warns)
and reported by the health constraints include as a standing
violation when a check goes stale after the transition. An
empty related set satisfies the rule (universal quantification
over nothing); pair with required_outgoing where at least one
related entity must exist. On an engine without a check ledger
(no workspace root) every related entity derives
never_checked, so a declared gate refuses rather than
silently passing.
Fields
field: StringThe metadata field whose value gates (must declare
enum_values; validated by the loader).
relationships: Vec<String>Edge names whose related entities must be checked (each validated against the relationship vocabulary).
direction: PropagationDirectionWhich side of the edges holds the entities to check:
incoming — entities whose edges point at this one;
outgoing — entities this one points at.
severity: ConstraintSeverityDefaults to block — the declaration exists to refuse the
unverified transition at write time.
Implementations§
Source§impl ConstraintDef
impl ConstraintDef
Sourcepub fn propagation_rel_types(&self) -> Option<Vec<String>>
pub fn propagation_rel_types(&self) -> Option<Vec<String>>
The effective relation set of a status_propagation
declaration: the single rel_type as a one-element list, or
the declared rel_types. The loader guarantees exactly one of
the two is present. Returns None for other constraint forms.
Trait Implementations§
Source§impl Clone for ConstraintDef
impl Clone for ConstraintDef
Source§fn clone(&self) -> ConstraintDef
fn clone(&self) -> ConstraintDef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConstraintDef
impl Debug for ConstraintDef
Source§impl<'de> Deserialize<'de> for ConstraintDef
impl<'de> Deserialize<'de> for ConstraintDef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for ConstraintDef
impl JsonSchema for ConstraintDef
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more