pub struct Schema {
pub manifest: SchemaManifest,
pub version: Version,
pub types: HashMap<String, Arc<TypeDefinition>>,
}Expand description
A validated, in-memory schema — the product of the loader.
Holds the parsed manifest, the resolved semver version, and the set of
fully-validated type definitions with edge_weights precomputed.
Fields§
§manifest: SchemaManifest§version: Version§types: HashMap<String, Arc<TypeDefinition>>Implementations§
Source§impl Schema
impl Schema
pub fn get_type(&self, name: &str) -> Option<Arc<TypeDefinition>>
pub fn relationship_known(&self, name: &str) -> bool
Sourcepub fn relationship_acyclic(&self, name: &str) -> bool
pub fn relationship_acyclic(&self, name: &str) -> bool
Returns true iff name is declared with acyclic: true in this
schema. Undeclared names resolve to false (permissive): the write
path already rejects undeclared names in strict mode via
relationship_known, and open mode is explicitly opt-in to cycles.
Sourcepub fn type_refuses_self_loop(&self, source_type: &str, rel_type: &str) -> bool
pub fn type_refuses_self_loop(&self, source_type: &str, rel_type: &str) -> bool
Returns true iff source_type’s no_self_loop_relationships
list declares rel_type — the engine then refuses a SELF-LOOP
(from == to) on that pair, independent of the rel-type’s
acyclic flag (which governs longer cycles, a different
concern). That refusal is the declaration’s only effect —
nothing propagates (the historical “weight-bomb” rationale was
backed by no weight code anywhere; agent-trust plan 06 renamed
the field and this predicate to match reality). Unknown
source_type returns false (permissive — the type’s
existence is checked elsewhere).
Returns the schema-declared manual-authoring posture for a
rel-type. Unknown names resolve to Allow (permissive — the
validator path already rejects unknown rel-types in strict
mode). The
explicit-author boundary (memstead_relate, memstead_create’s
relations: inline list, memstead_update’s declare_relations)
gates on this; the body-link → relation alias machinery does
NOT — the alias path is the intended way schema-emitted
rel-types (e.g. REFERENCES) appear on entities.
Sourcepub fn relationship_when_to_use(&self, name: &str) -> Option<String>
pub fn relationship_when_to_use(&self, name: &str) -> Option<String>
when_to_use description for a rel-type, returned as the
recovery hint on RELATION_MANUAL_AUTHORING_FORBIDDEN
envelopes. None when the rel-type is unknown or the schema
author didn’t author the field.
pub fn mode(&self) -> RelationshipMode
pub fn id(&self) -> (String, Version)
pub fn suggest_type(&self, name: &str) -> Option<String>
Sourcepub fn relationship_def(&self, name: &str) -> Option<&RelationshipDef>
pub fn relationship_def(&self, name: &str) -> Option<&RelationshipDef>
Look up a relationship definition by name. None for unknown
names; the _default sentinel is reachable but never a real
edge’s rel_type.
Sourcepub fn relationship_cardinality(&self, name: &str) -> Option<Cardinality>
pub fn relationship_cardinality(&self, name: &str) -> Option<Cardinality>
Cardinality hint declared on name. None for unknown names or
for relationships with no declared cardinality (the default —
shape-free).
pub fn suggest_relationship(&self, name: &str) -> Option<String>
Sourcepub fn alias_target_rel_type(&self) -> Option<&str>
pub fn alias_target_rel_type(&self) -> Option<&str>
Schema-level alias_target_rel_type pointer — names the rel-type
that body wiki-links [[target]] should auto-emit as
engine-synthesised relations. None means the schema is opt-out
of alias synthesis (unbacked body wiki-links continue to refuse
with WIKILINK_WITHOUT_RELATION). The loader has already
validated that the named rel-type is declared.
Sourcepub fn cross_mem_entry(
&self,
target_name: &str,
) -> Option<&CrossMemRelationshipEntry>
pub fn cross_mem_entry( &self, target_name: &str, ) -> Option<&CrossMemRelationshipEntry>
Look up the cross-mem entry whose to_schema matches the
target schema’s name. Returns None when this schema declares
no outbound entry for that domain.
Eligibility is name-based: a schema names a domain, and a
version is one iteration of describing it. The target mem’s
pinned version never participates in the match, so a version
bump on the target side cannot invalidate the declaration. The
loader guarantees to_schema is a validated bare schema name,
so plain string equality is exact here.
Sourcepub fn cross_mem_entries(
&self,
target_name: &str,
) -> Vec<&CrossMemRelationshipEntry>
pub fn cross_mem_entries( &self, target_name: &str, ) -> Vec<&CrossMemRelationshipEntry>
Every cross-mem entry applicable to target_name, in priority
order: the exact-name entry first, then the to_schema: "*"
wildcard entry (loader-bound to this schema’s
alias_target_rel_type). Consumers resolve a rel-type by
first hit across the returned entries, so an exact declaration
for a destination schema never SHADOWS the wildcard for the
alias rel-type — a schema carrying structural declarations for
one destination keeps its wildcarded alias links to that same
destination. Empty when neither entry exists. This is the ONE
matcher behind edge validation, the load-path edge filter, and
the per-edge-description posture lookup — a wildcard honoured
in one place is honoured in all three.
Sourcepub fn builtin_default() -> Arc<Schema> ⓘ
pub fn builtin_default() -> Arc<Schema> ⓘ
Load the embedded default builtin schema.
Backed by the embedded YAML bundle under builtins/schemas/default/
that ships with every binary. Cached via OnceLock so repeated
calls are cheap.