mixle.substrate.belief module¶
Calibrated belief store: harvest claims from model output and assimilate them as CREDENCES.
A model’s output is a paragraph of assertions – some grounded, some not. This module turns each
assertion into a tracked belief with a probability (not a binary “fact” flag) that moves with the
STRENGTH of its evidence: a verifiable source (a document, an executable check, a held-out truth, a
real measurement) moves it strongly; the model’s own say-so moves it weakly and is capped low. Every
belief carries its full evidence_history so the current credence is always reproducible by
replaying it, and evidence can be revised or retract()-ed, cascading to whatever depended on it.
Anti-laundering is the load-bearing property: evidence that resolves back to the claim itself, or to another belief that has no independent (non-model-assertion) support of its own, contributes ZERO – a claim cannot bootstrap high credence by citing itself or an equally ungrounded peer.
A claimed tier is not itself evidence (MXR-080-0243): a strong tier only earns its full claimed
strength when source_id actually resolves to something real – a document, an artifact, another
belief, any genuine substrate item – checked once, at assimilation time, and recorded on the entry
(EvidenceEntry.verified) so replay never needs the substrate again. An unresolved or fabricated
source_id (missing, made up, or naming nothing in the store) is represented as unverified and earns
only MODEL_ASSERTION-strength credence, no matter what tier it claims: a bare string is never,
by itself, a receipt.
Resolution is scope-respecting, all the way down (MXR-080-0244): source_id is looked up through an
AccessPolicy-authorized view of the caller’s own scope, never a raw
global lookup, and every transitive hop of a multi-belief proof chain is resolved through that SAME
authorized view – a caller can neither borrow another scope’s private grounding to inflate its own
credence nor learn, by probing, whether some other scope’s belief happens to be grounded. An id that
exists but is not visible to the caller is indistinguishable from one that does not exist at all.
This is the write side of the knowledge substrate: harvest, credence
assimilation, and traceable history. The retrieval side is
mixle.substrate.retrieve.
- class Claim(text, produced_by=<factory>, quantity=None)[source]
Bases:
objectOne atomic proposition (or typed quantity) pulled from a model’s output.
- class EvidenceEntry(source_id, tier, direction='+', weight=1.0, time=<factory>, verified=True)[source]
Bases:
objectOne piece of evidence that moved a belief’s credence, in the order it was applied.
verifiedrecords whethersource_idresolved to something real, through an authorized scoped view, at the moment this entry was assimilated (MXR-080-0243/0244) – computed once, byassimilate(), and carried on the entry itself socredence_from_history()can replay it without ever touching the substrate again. Direct construction (tests, deserializing an already-decided entry) defaults toTrue, matchingdirection/weight/time’s own “already-legitimate input” defaults;assimilate()is the untrusted-input boundary and always computes and passes this explicitly rather than relying on the default.
- class BeliefItem(id, claim, credence, evidence_history=<factory>, scope='local')[source]
Bases:
objectA claim’s current credence plus the full evidence trail that produced it.
- harvest_knowledge(model_output, *, source, extract=None)[source]
Split
model_outputinto atomic claims, each stamped withsource(which model produced it, its confidence, etc). Default extraction is sentence-level (mixle.reason.llm.sentence_claims()); passextractfor a different atomic-proposition splitter.
- credence_from_history(evidence_history)[source]
The credence implied by an evidence history alone – a pure function, so replaying a belief’s stored
evidence_historythrough this always reproduces its currentcredenceexactly.An entry’s claimed
tieronly counts at its claimed strength whenEvidenceEntry.verifiedis True (MXR-080-0243); an unverified claim of a strong tier contributes atMODEL_ASSERTION-strength instead, and does not count towardhas_real_support(so it cannot, by itself, lift a belief pastMODEL_ASSERTION_CAP) – otherwise merely CLAIMING a strong tier would escape the cap even though its actual numeric contribution never did.
- assimilate(sub, claim, evidence, *, scope='local', policy=None)[source]
Bayesian-ish update of the belief in
claimfromevidence– never a binary write.Finds or creates the belief item (keyed on normalized claim text) and appends each evidence entry (
{"source_id", "tier", "direction": "+"/"-", "weight"});tiermust be one of_TIER_STRENGTH("model_assertion"plusmixle.doe.oracle.VERIFIABILITY_TIERS), anddirection, when given, must be"+"or"-"(MXR-080-0242).Verification (MXR-080-0243): a tier above
MODEL_ASSERTIONonly earns its claimed strength whensource_idresolves to a real substrate item through an authorized view ofscope(see_resolve()); an unresolved, fabricated, or omittedsource_idis recorded as unverified and contributes atMODEL_ASSERTION-strength regardless of what it claims.Anti-laundering (MXR-080-0244): an entry whose
source_idresolves back to THIS belief (a cycle) or to another belief item with no independent (non-model-assertion, verified) support of its own is stored with an effective weight of zero – it cannot move the credence, though it stays in the trail for audit. Resolution – both the verification check above and the laundering check – goes throughpolicy(a fresh, home-scope-plus-PUBLIC-onlyAccessPolicywhen omitted), never a raw global lookup, so citing another scope’s private belief is indistinguishable from citing something that does not exist at all: neither the credence it produces nor anything else observable here can be used to learn whether that other scope’s belief exists or is grounded.
- retract(sub, source_id, *, scope=None)[source]
Remove every evidence entry citing
source_id, recomputing credence, and CASCADE: if that removal causes a belief to lose its only independent support, also strip citations of THAT belief from whatever cited it, recursively. Returns every belief item touched by the cascade.
- retrieve_beliefs(sub, query, *, k=8, min_credence=None, scope=None)[source]
Beliefs relevant to
query, optionally thresholded onmin_credenceand re-ranked byrelevance * credence– so a caller can weight by, or hard-filter on, how much the store actually believes each item (never a “fact” vs “non-fact” partition, only credence).MXR-080-0245: the belief tag and
min_credenceare filtered over the FULL"record"-kind candidate domain, not a fixed-size prefetch – a store where ordinary (non-belief) records or low-credence beliefs rank higher by raw relevance can no longer crowd out qualifying beliefs that rank lower but still exist.sub.searchstill does the actual relevance scoring (this module never touches core.py’s ranking); the fix is asking it for every"record"-kind candidate in scope rather than an arbitrary3*kcut of them.