mixle.experimental.typed_runtime.transaction module¶

Versioned transactional proposal commit with canaries and verified rollback.

class CanaryVerdict(accepted, reason, objective_before=None, objective_after=None, lower_confidence_gain=None, confidence_level=None, sample_count=0, metrics=<factory>, proposal_objectives=<factory>)[source]

Bases: object

Measured acceptance evidence after proposals have been tentatively applied.

Parameters:
  • accepted (bool)

  • reason (str)

  • objective_before (float | None)

  • objective_after (float | None)

  • lower_confidence_gain (float | None)

  • confidence_level (float | None)

  • sample_count (int)

  • metrics (dict[str, float])

  • proposal_objectives (dict[str, ObjectiveGateEvidence])

property objective_gain: float | None

Measured objective difference when both values are available.

as_dict()[source]

Return a JSON-compatible canary receipt.

Return type:

dict[str, Any]

class CommitReceipt(commit_id, batch_id, proposal_ids, status, reason, versions_before, versions_after, invalidated_nodes=(), canary=None, participant_fingerprints_before=<factory>, participant_fingerprints_after=<factory>, rollback_verified=None, error_type=None, error_message=None, run_id='', model_id='', elapsed_seconds=0.0)[source]

Bases: object

Coordinator decision, state fingerprints, and version transition.

Parameters:
  • commit_id (str)

  • batch_id (str)

  • proposal_ids (tuple[str, ...])

  • status (CommitStatus)

  • reason (str)

  • versions_before (dict[str, Any])

  • versions_after (dict[str, Any])

  • invalidated_nodes (tuple[str, ...])

  • canary (CanaryVerdict | None)

  • participant_fingerprints_before (dict[str, str])

  • participant_fingerprints_after (dict[str, str])

  • rollback_verified (bool | None)

  • error_type (str | None)

  • error_message (str | None)

  • run_id (str)

  • model_id (str)

  • elapsed_seconds (float)

property accepted: bool

Whether this transaction advanced the model version.

as_dict()[source]

Return a JSON-compatible commit receipt.

Return type:

dict[str, Any]

class CommitStatus(*values)[source]

Bases: StrEnum

Terminal result of one commit attempt.

class ObjectiveGateEvidence(objective_before, objective_after, lower_confidence_gain=None)[source]

Bases: object

Proposal-specific objective evidence used for mixed or multi-update gates.

Parameters:
  • objective_before (float)

  • objective_after (float)

  • lower_confidence_gain (float | None)

as_dict()[source]

Return a JSON-compatible objective gate.

Return type:

dict[str, float | None]

class RuntimeVersions(model_version, node_versions)[source]

Bases: object

Coordinator-owned global and per-node versions.

Parameters:
classmethod for_graph(graph, *, model_version=0)[source]

Create a zero-node-version vector for a compiled graph.

Parameters:
  • graph (UpdateGraph)

  • model_version (int)

Return type:

RuntimeVersions

as_dict()[source]

Return a detached JSON-compatible version vector.

Return type:

dict[str, Any]

class TransactionParticipant(name, semantics, snapshot_fn, restore_fn, fingerprint_fn, artifacts=frozenset({}))[source]

Bases: object

Snapshot/restore adapter for one mutable state domain.

Parameters:
snapshot()[source]

Capture state before applying a proposal.

Return type:

Any

restore(snapshot)[source]

Restore a previously captured snapshot.

Parameters:

snapshot (Any)

Return type:

None

fingerprint()[source]

Return a deterministic current-state fingerprint.

Return type:

str

class TransactionalCoordinator(graph, apply_proposal, canary, *, run_id, model_id, participants=(), versions=None, objective_tolerance=1.0e-9, enforce_monotone_objective=True)[source]

Bases: object

Serialize proposal commits through preflight, snapshot, canary, and commit.

Parameters:
  • graph (UpdateGraph)

  • apply_proposal (ApplyProposalFn)

  • canary (CanaryFn)

  • run_id (str)

  • model_id (str)

  • participants (Iterable[TransactionParticipant])

  • versions (RuntimeVersions | None)

  • objective_tolerance (float)

  • enforce_monotone_objective (bool)

property receipts: tuple[CommitReceipt, ...]

Every terminal commit receipt this coordinator produced, oldest first.

A detached tuple: the receipts themselves are frozen and sealed, and the sequence they form is the coordinator’s own record, not a caller-editable list (MXR-080-1905).

property proposal_receipts: tuple[dict[str, Any], ...]

Serialized proposals seen by this coordinator, in arrival order.

Each row is a fresh as_dict() payload built at commit time, so the tuple shares no structure a caller can reach (MXR-080-1905).

property poisoned: bool

Whether an unverified rollback has disabled further commits.

Read-only: this was a plain attribute, so coordinator.poisoned = False un-poisoned a coordinator whose rollback could not be verified and let it accept commits on top of state nothing had confirmed was restored (MXR-080-1905). Only commit() sets it, from the rollback verification itself.

commit(batch, *, commit_id=None)[source]

Attempt one atomic commit and always return a terminal receipt.

Parameters:
  • batch (ProposalBatch | ProposalPacket)

  • commit_id (str | None)

Return type:

CommitReceipt

ledger_fingerprint()[source]

Fingerprint receipt metadata for deterministic replay comparisons.

Return type:

str