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: 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).
direction: PropagationDirectionWhich direction reaches the dependents: incoming taints
the entities whose rel_type edges point at the terminal
entity (and their dependents, transitively); outgoing
the entities the terminal entity points at.
severity: ConstraintSeverityTrait 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