mixle.epistemic.journal module¶
EpistemicJournal – an append-only, replayable decision log for a sequence of loop steps.
The program plan’s decision journal (§3.4: “timestamp, model version, belief snapshot hash, options
considered with their EIG/cost/risk scores, chosen action, rationale claims…”), following
mixle.evolve.ledger.EvolutionLedger’s existing shape (flat, JSON-serializable, append-only,
no model objects stored directly) rather than inventing a third bespoke logging pattern.
One deliberate refinement over a hash-only ledger: each record carries the full serialized belief
snapshot (portfolio_snapshot, from to_dict())
alongside its content-address (belief_snapshot_hash). A hash alone cannot be reversed back into a
portfolio, so “an auditor can reconstruct the full belief trajectory from the ledger alone” (program
plan §2) requires the snapshot content to actually be there; the hash is what lets verify()
catch tampering/corruption of that stored content, which is the property a bare append-only list
doesn’t get for free.
- class DecisionRecord(step_index, belief_snapshot_hash, portfolio_snapshot, surprise, action_considered=<factory>, action_chosen=None, action_eig=None, timestamp=None, rationale=None)[source]
Bases:
objectOne journaled decision: what was believed, what was considered, what was chosen, and why.
- class EpistemicJournal(records=None)[source]
Bases:
objectAn ordered, JSON-serializable, replayable log of
EpistemicSteps.- Parameters:
records (list[DecisionRecord] | None)
- append(step, *, action_considered=(), rationale=None, timestamp=None)[source]
Append one record for
stepand return it.timestampis caller-supplied, never sampled here.
- replay(portfolio0=None)[source]
Reconstruct the belief trajectory from the journal’s stored snapshots alone.
portfolio0is accepted for interface symmetry with the loop’s ownstep(portfolio, ...)signature but is not required for reconstruction here: every record already carries its own fullportfolio_snapshot, so replay is deserialization, not re-simulation (re-simulation would additionally need the original observations and likelihood callables, which are deliberately not journaled – they may not be JSON-serializable, and the snapshot is the thing an audit actually needs). If given,portfolio0is prepended to the returned trajectory.- Parameters:
portfolio0 (HypothesisPortfolio | None)
- Return type:
list[HypothesisPortfolio]