pub enum Provenance {
Derived,
Authored,
Inferred,
ExternalDerived,
ExternalAuthored,
ExternalInferred,
}Expand description
How an edge or node in the graph was produced.
§Six tokens, because “external” is a modifier and not a class
Three of these describe work this graph did: deterministic extraction, human authorship, heuristic inference. The other three describe the same three claims made by someone else, imported from a peer repository’s Open Knowledge Format bundle ([[docs/adr/0021-open-knowledge-format-bundle.md]]).
The peer’s tier is carried rather than collapsed, and that is the whole point
of the shape. crate::Provenance is matched exhaustively by
rto_render::okf::origin_for to produce OKF trust tiers, so a single flat
External would force one arm — and therefore one answer for everything
imported. Either it maps to unverified, which downgrades a peer’s
human-reviewed concept, or it maps to machine-confirmed, which upgrades
their similarity guess. render okf then re-emits that flattened tier
outward to the next consumer: laundering by round-trip, in a format adopted
specifically because it can express the distinction.
§Externality does not nest
A fact we imported from B, which B had imported from C, is external-* —
not doubly external. Provenance::externalise is idempotent for exactly
that reason. Which repository the fact came from is not a property of the
fact: it is the import layer’s src_ref, which names B.
§What “external” does not modify
An external-inferred edge carries no confidence, where a local
Provenance::Inferred one must (see crate::Edge::is_valid). A
confidence is a number we computed; OKF carries none for a relationship, so
adopting one would mean inventing it. That asymmetry is deliberate and is
enforced by the store’s own CHECK as well as by Rust.
§Compatibility
This enum had three variants up to and including 5.0.0; the three
External* variants arrived in 5.1.0. It is pub, re-exported from
the crate root, and deliberately not #[non_exhaustive]
([[docs/adr/0001-build-roteiro-unified-codebase-knowledge-graph.md]] v1.3
argues why that is the right shape), so the addition is technically
breaking for anyone who matches it exhaustively.
It shipped as a minor, deliberately and per policy: AGENTS.md treats
the rto-* crates’ public surface as internal, since they publish only so
that cargo install roteiro resolves and roteiro is their sole reverse
dependency. This note is the record that posture asks for, not a dissent
from it.
If you do depend on this crate directly, two concrete consequences:
- An exhaustive
matchover the old three variants stops compiling. Add the three arms, or match with a wildcard if you only care about the local classes. A match that already had one is unaffected. - The serialized tokens are additive, so a
5.0.0consumer reading a document written by5.1.0or later rejectsexternal-derived,external-authoredandexternal-inferredas unknown variants.Provenancerides every edge of everyroteiro.query/v1document. On disk the guard for this is migration 14, which makes an older build report such a store as written by a newer Roteiro rather than as corrupt ([[docs/adr/0021-open-knowledge-format-bundle.md]]).
Variants§
Derived
Deterministically extracted from source ASTs (tree-sitter). The default: the overwhelmingly common node/edge, and the correct value when a legacy cached fact set (serialized before nodes carried provenance) omits it.
Authored
Authored by a human or agent in an ADR, blueprint, or annotation.
Inferred
Heuristically inferred (docs, embeddings); carries a confidence score.
ExternalDerived
A peer’s Provenance::Derived fact, imported from their bundle.
They could re-derive it from their AST; we cannot, because we do not have their tree. So this asserts they say it is deterministic, and nothing about our ability to check.
ExternalAuthored
A peer’s Provenance::Authored fact, imported from their bundle.
Someone confirmed it in their repository. Importing it as
Provenance::Authored would assert that this graph human-authored it,
which is the laundering the whole variant exists to refuse.
ExternalInferred
A peer’s Provenance::Inferred fact, imported from their bundle — or
any imported fact taken at acknowledge rather than trust: their
information without their confirmation.
Implementations§
Source§impl Provenance
impl Provenance
Sourcepub fn from_token(s: &str) -> Option<Self>
pub fn from_token(s: &str) -> Option<Self>
Parse a provenance from its stable string token, returning None for an
unrecognised value.
Two things produce one: a corrupt database row, and a store written by a
newer Roteiro that knows a token this build does not. The second is
not hypothetical — this build added three — and it is diagnosed before
a row is decoded, by crate::Store::schema_ahead: every widening of
this set ships with a migration, so a store carrying an unknown token
necessarily records a migration this build has never heard of.
Deliberately not tolerant of an unknown token. A fallback value would
have to be one of the six, and every choice is a claim: assuming
derived upgrades an unknown to machine-confirmed, assuming inferred
downgrades a confirmed fact. That is the same laundering the external
variants exist to prevent, arriving through the error path instead.
Sourcepub fn tokens() -> &'static [&'static str]
pub fn tokens() -> &'static [&'static str]
Every token, in the order the enum declares them — the exact set
Provenance::from_token accepts and the store’s CHECK permits.
Exists so an error message, a schema and a test can each name the vocabulary without writing a fourth copy of it down.
Sourcepub fn is_external(self) -> bool
pub fn is_external(self) -> bool
Whether this fact came from another repository’s bundle rather than from this graph’s own work.
Sourcepub fn tier(self) -> Self
pub fn tier(self) -> Self
The tier this provenance claims, with externality stripped: what kind of claim it is, ignoring whose claim it is.
Use it where the question is genuinely about the tier — rendering a trust
level, ranking a fact’s strength. Do not use it to decide whether a
fact may be rewritten, re-derived or asserted as this graph’s own: those
questions are about ownership, and Provenance::is_external answers
them.
Sourcepub fn externalise(self) -> Self
pub fn externalise(self) -> Self
This provenance as a peer’s claim: the external variant carrying the same tier.
Idempotent, and that is the decision rather than a convenience.
Externality flattens to one level: a fact imported from B that B imported
from C is external-*, not doubly external, because the fact is external
exactly once and which repository it arrived from is the import layer’s
src_ref, not the fact’s class.
Trait Implementations§
Source§impl Clone for Provenance
impl Clone for Provenance
Source§fn clone(&self) -> Provenance
fn clone(&self) -> Provenance
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Provenance
Source§impl Debug for Provenance
impl Debug for Provenance
Source§impl Default for Provenance
impl Default for Provenance
Source§fn default() -> Provenance
fn default() -> Provenance
Source§impl<'de> Deserialize<'de> for Provenance
impl<'de> Deserialize<'de> for Provenance
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>,
impl Eq for Provenance
Source§impl PartialEq for Provenance
impl PartialEq for Provenance
Source§impl Serialize for Provenance
impl Serialize for Provenance
impl StructuralPartialEq for Provenance
Auto Trait Implementations§
impl Freeze for Provenance
impl RefUnwindSafe for Provenance
impl Send for Provenance
impl Sync for Provenance
impl Unpin for Provenance
impl UnsafeUnpin for Provenance
impl UnwindSafe for Provenance
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.