Skip to main content

ProvenanceSource

Trait ProvenanceSource 

Source
pub trait ProvenanceSource:
    Copy
    + Send
    + Sync
    + 'static {
    // Required method
    fn as_str(&self) -> &'static str;

    // Provided method
    fn proposed_fact<T>(
        self,
        key: ContextKey,
        id: impl Into<ProposalId>,
        payload: T,
    ) -> ProposedFact
       where T: FactPayload + PartialEq { ... }
}
Expand description

Stable, audit-friendly identifier for an extension that emits facts into the convergence loop.

Implementors are typically zero-sized marker types declared by each fact-emitting crate. The trait gives them a single canonical as_str plus a default proposed_fact constructor that stamps the resulting ProposedFact with the right Provenance string.

§Migration from the per-crate ProvenanceSource enum

Earlier fact-emitting extensions each duplicated an 8-variant ProvenanceSource enum and a *_PROVENANCE constant. This trait replaces that pattern. Each crate now declares only its own marker and canonical provenance constant:

use converge_pack::{ProvenanceSource, ContextKey, TextPayload};

pub struct Arbiter;
impl ProvenanceSource for Arbiter {
    fn as_str(&self) -> &'static str { "arbiter" }
}
pub const ARBITER_PROVENANCE: Arbiter = Arbiter;

let fact = ARBITER_PROVENANCE.proposed_fact(
    ContextKey::Diagnostic,
    "decision-001",
    TextPayload::new("hello"),
);
assert_eq!(fact.provenance(), "arbiter");

Extensions no longer need to enumerate every sibling extension.

Required Methods§

Source

fn as_str(&self) -> &'static str

Canonical lowercase identifier carried on ProposedFact.provenance. Stable across the extension’s public API.

Provided Methods§

Source

fn proposed_fact<T>( self, key: ContextKey, id: impl Into<ProposalId>, payload: T, ) -> ProposedFact

Construct a ProposedFact stamped with this provenance and a typed payload.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ProvenanceSource for ConvergeCore

Source§

fn as_str(&self) -> &'static str

Source§

impl ProvenanceSource for ConvergeOptimization

Source§

fn as_str(&self) -> &'static str

Implementors§