Skip to main content

ProposedFact

Struct ProposedFact 

Source
pub struct ProposedFact {
    pub key: ContextKey,
    pub id: ProposalId,
    pub provenance: Provenance,
    /* private fields */
}
Expand description

An unvalidated suggestion from a non-authoritative source.

Proposed facts live in ContextKey::Proposals until a ValidationAgent promotes them to Fact. The proposal tracks its origin for audit trail.

Fields§

§key: ContextKey

The context key this proposal targets.

§id: ProposalId

Unique identifier encoding origin and target.

§provenance: Provenance

Provenance information (e.g., model ID, prompt hash).

Implementations§

Source§

impl ProposedFact

Source

pub fn new<T>( key: ContextKey, id: impl Into<ProposalId>, payload: T, provenance: impl Into<Provenance>, ) -> ProposedFact

Create a new draft proposal with explicit provenance.

Confidence defaults to 1.0. Override with with_confidence.

Source

pub fn from_wire( wire: WireProposedFact, registry: &PayloadRegistry, ) -> Result<ProposedFact, PayloadError>

Materializes a proposal from the stable wire shape at an external border.

Source

pub fn to_wire(&self) -> Result<WireProposedFact, PayloadError>

Converts this proposal to the stable wire shape.

Source

pub fn to_context_fact( &self, id: impl Into<FactId>, promotion_record: FactPromotionRecord, created_at: impl Into<Timestamp>, ) -> ContextFact

Creates a promoted context projection that preserves this proposal’s exact typed payload.

Promotion authority still belongs to the engine/gate. This method only avoids re-serializing or textifying a payload after that authority has already accepted the proposal.

Source

pub fn key(&self) -> ContextKey

Returns the context key this proposal targets.

Source

pub fn id(&self) -> &ProposalId

Returns the proposal identifier.

Source

pub fn payload<T>(&self) -> Option<&T>
where T: FactPayload,

Returns the typed payload when the requested type matches the stored payload family/version.

Source

pub fn require_payload<T>(&self) -> Result<&T, PayloadError>
where T: FactPayload,

Returns the typed payload or a mismatch error.

Source

pub fn payload_family(&self) -> FactFamilyId

Returns the payload family.

Source

pub fn payload_version(&self) -> PayloadVersion

Returns the payload version.

Source

pub fn text(&self) -> Option<&str>

Returns the payload as text when this is a TextPayload.

Source

pub fn validate_payload(&self) -> Result<(), PayloadError>

Validates the stored payload.

Source

pub fn provenance(&self) -> &str

Returns the proposal provenance string.

Source

pub fn confidence(&self) -> f64

Returns the confidence value, always in [0.0, 1.0].

Source

pub fn with_confidence(self, confidence: f64) -> ProposedFact

Set an explicit confidence baseline for this proposal.

Use this to establish a starting point, then accumulate criteria with adjust_confidence. The value is clamped to [0.0, 1.0]; non-finite values (NaN, infinity) are treated as 0.0.

For computed confidence (e.g. from a solver), pass the result directly.

Source

pub fn adjust_confidence(self, delta: f64) -> ProposedFact

Adjust confidence by a named step, clamped to [0.0, 1.0].

This is the recommended way to express confidence in suggestors and pack solvers. Use the CONFIDENCE_STEP_* constants as the vocabulary:

use converge_pack::{CONFIDENCE_STEP_MAJOR, CONFIDENCE_STEP_MINOR, CONFIDENCE_STEP_TINY, TextPayload};

let proposal = EXAMPLE_PROVENANCE.proposed_fact(key, id, TextPayload::new(content))
    .with_confidence(0.5)                        // baseline
    .adjust_confidence(CONFIDENCE_STEP_MAJOR)    // primary criterion met
    .adjust_confidence(CONFIDENCE_STEP_MINOR)    // supporting criterion met
    .adjust_confidence(CONFIDENCE_STEP_TINY);    // tiebreaker bonus

Prefer this over accumulating a local f64 and calling with_confidence at the end — the clamping is automatic and the intent is explicit at each step.

Trait Implementations§

Source§

impl Clone for ProposedFact

Source§

fn clone(&self) -> ProposedFact

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProposedFact

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ProposedFact

Source§

fn eq(&self, other: &ProposedFact) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ProposedFact

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more