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: ContextKeyThe context key this proposal targets.
id: ProposalIdUnique identifier encoding origin and target.
provenance: ProvenanceProvenance information (e.g., model ID, prompt hash).
Implementations§
Source§impl ProposedFact
impl ProposedFact
Sourcepub fn new<T>(
key: ContextKey,
id: impl Into<ProposalId>,
payload: T,
provenance: impl Into<Provenance>,
) -> ProposedFactwhere
T: FactPayload + PartialEq,
pub fn new<T>(
key: ContextKey,
id: impl Into<ProposalId>,
payload: T,
provenance: impl Into<Provenance>,
) -> ProposedFactwhere
T: FactPayload + PartialEq,
Create a new draft proposal with explicit provenance.
Confidence defaults to 1.0. Override with with_confidence.
Sourcepub fn from_wire(
wire: WireProposedFact,
registry: &PayloadRegistry,
) -> Result<ProposedFact, PayloadError>
pub fn from_wire( wire: WireProposedFact, registry: &PayloadRegistry, ) -> Result<ProposedFact, PayloadError>
Materializes a proposal from the stable wire shape at an external border.
Sourcepub fn to_wire(&self) -> Result<WireProposedFact, PayloadError>
pub fn to_wire(&self) -> Result<WireProposedFact, PayloadError>
Converts this proposal to the stable wire shape.
Sourcepub fn to_context_fact(
&self,
id: impl Into<FactId>,
promotion_record: FactPromotionRecord,
created_at: impl Into<Timestamp>,
) -> ContextFact
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.
Sourcepub fn key(&self) -> ContextKey
pub fn key(&self) -> ContextKey
Returns the context key this proposal targets.
Sourcepub fn id(&self) -> &ProposalId
pub fn id(&self) -> &ProposalId
Returns the proposal identifier.
Sourcepub fn payload<T>(&self) -> Option<&T>where
T: FactPayload,
pub fn payload<T>(&self) -> Option<&T>where
T: FactPayload,
Returns the typed payload when the requested type matches the stored payload family/version.
Sourcepub fn require_payload<T>(&self) -> Result<&T, PayloadError>where
T: FactPayload,
pub fn require_payload<T>(&self) -> Result<&T, PayloadError>where
T: FactPayload,
Returns the typed payload or a mismatch error.
Sourcepub fn payload_family(&self) -> FactFamilyId
pub fn payload_family(&self) -> FactFamilyId
Returns the payload family.
Sourcepub fn payload_version(&self) -> PayloadVersion
pub fn payload_version(&self) -> PayloadVersion
Returns the payload version.
Sourcepub fn text(&self) -> Option<&str>
pub fn text(&self) -> Option<&str>
Returns the payload as text when this is a TextPayload.
Sourcepub fn validate_payload(&self) -> Result<(), PayloadError>
pub fn validate_payload(&self) -> Result<(), PayloadError>
Validates the stored payload.
Sourcepub fn provenance(&self) -> &str
pub fn provenance(&self) -> &str
Returns the proposal provenance string.
Sourcepub fn confidence(&self) -> f64
pub fn confidence(&self) -> f64
Returns the confidence value, always in [0.0, 1.0].
Sourcepub fn with_confidence(self, confidence: f64) -> ProposedFact
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.
Sourcepub fn adjust_confidence(self, delta: f64) -> ProposedFact
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 bonusPrefer 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
impl Clone for ProposedFact
Source§fn clone(&self) -> ProposedFact
fn clone(&self) -> ProposedFact
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProposedFact
impl Debug for ProposedFact
Source§impl PartialEq for ProposedFact
impl PartialEq for ProposedFact
Source§fn eq(&self, other: &ProposedFact) -> bool
fn eq(&self, other: &ProposedFact) -> bool
self and other values to be equal, and is used by ==.