Skip to main content

morphir_core/metadata/
mod.rs

1//! Pure, expanded linked-metadata facts and their authored assertions.
2//!
3//! This module models the default graph after context expansion. It does not
4//! interpret authored keys, resolve declarations, or load documents.
5
6pub mod admission;
7mod assertion;
8mod context;
9mod graph;
10mod provider;
11mod term;
12
13pub(crate) use context::expand_property_objects;
14
15pub use assertion::{Assertion, AssertionKey, AssertionSource, Carrier, DocumentId, SourceRecord};
16pub use context::{
17    Coercion, ContextError, ContextResources, EffectiveContext, ExpandedKey, expand_object,
18    expand_properties, inline_document_contexts, resolve_context,
19};
20pub use graph::{GraphIndex, GraphMapError};
21pub use provider::ProviderDeclarationError;
22pub use term::{Fact, GraphName, ObjectTerm, TypedValue};
23
24/// A metadata model or first-increment graph-execution error.
25#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
26pub enum MetadataError {
27    /// A document identity cannot be empty.
28    #[error("document identity must not be empty")]
29    EmptyDocumentId,
30    /// A node-local carrier must describe its enclosing node.
31    #[error("node-local carrier does not match the fact subject")]
32    CarrierSubjectMismatch,
33    /// Document provenance comes only from the assertion owner.
34    #[error("document provenance is implicit and cannot be added as detail")]
35    DocumentProvenanceIsImplicit,
36    /// An explicit source list must contain at least one source.
37    #[error("assertion source override must not be empty")]
38    EmptyAssertionSources,
39    /// A document source tag must name the assertion owner.
40    #[error("document source does not match the assertion owner")]
41    DocumentSourceOwnerMismatch,
42    /// One table must not select the same assertion twice.
43    #[error("duplicate assertion source selector: {0:?}")]
44    DuplicateSourceSelector(Box<AssertionKey>),
45    /// The selector must name an assertion authored by this document.
46    #[error("assertion source selector has no matching authored assertion: {0:?}")]
47    UnmatchedSourceSelector(Box<AssertionKey>),
48    /// The table's owner and the selector's owner must agree.
49    #[error("assertion source selector names another document: {0:?}")]
50    SourceSelectorOwnerMismatch(Box<AssertionKey>),
51    /// Document-level source tables cannot override sidecar assertions.
52    #[error("assertion source selector cannot name a sidecar: {0:?}")]
53    SourceSelectorCarrierUnsupported(Box<AssertionKey>),
54    /// The old assertion must exist before an atomic rewrite.
55    #[error("assertion to rewrite was not found")]
56    AssertionNotFound,
57    /// Rewriting into another authored assertion would merge distinct ownership.
58    #[error("replacement collides with an existing assertion: {0:?}")]
59    AssertionCollision(Box<AssertionKey>),
60    /// Duplicate assertions cannot merge known and unknown source ownership.
61    #[error("duplicate assertion has conflicting source knowledge: {0:?}")]
62    SourceKnowledgeConflict(Box<AssertionKey>),
63    /// Source-dependent edits require explicit ownership for every assertion in scope.
64    #[error("assertion source ownership is unknown")]
65    UnknownSourceOwnership,
66    /// Named graph identity is modeled but cannot be inserted into this executor.
67    #[error("named graphs are not supported by the first metadata graph executor")]
68    NamedGraphUnsupported,
69}