Skip to main content

Schema

Struct Schema 

Source
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

Source

pub fn get_type(&self, name: &str) -> Option<Arc<TypeDefinition>>

Source

pub fn relationship_known(&self, name: &str) -> bool

Source

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.

Source

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).

Source

pub fn relationship_manual_authoring(&self, name: &str) -> ManualAuthoring

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.

Source

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.

Source

pub fn mode(&self) -> RelationshipMode

Source

pub fn id(&self) -> (String, Version)

Source

pub fn suggest_type(&self, name: &str) -> Option<String>

Source

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.

Source

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).

Source

pub fn suggest_relationship(&self, name: &str) -> Option<String>

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Schema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.