mixle.experimental.typed_runtime.context_ir module¶
Revisitable effective-context graph, provenance, and context action IR.
- class ContextAction(action_id, kind, expected_graph_version=None, input_nodes=(), query=None, source_scope=(), expected_information_gain=0.0, gain_standard_error=0.0, gain_sample_count=0, expected_latency_seconds=0.0, expected_tokens=0, expected_monetary_cost=0.0, expected_tool_calls=0, maximum_outputs=1, generated_output=False, resource_limits=None)[source]
Bases:
objectInspectable proposal for one context-construction operation.
- Parameters:
action_id (str)
kind (ContextActionKind)
expected_graph_version (int | None)
query (str | None)
expected_information_gain (float)
gain_standard_error (float)
gain_sample_count (int)
expected_latency_seconds (float)
expected_tokens (int)
expected_monetary_cost (float)
expected_tool_calls (int)
maximum_outputs (int)
generated_output (bool)
resource_limits (ContextActionLimits | None)
- class ContextActionKind(*values)[source]
Bases:
StrEnumOperation that may create, expand, verify, or materialize context.
- class ContextActionLimits(latency_seconds, materialized_tokens, monetary_cost, tool_calls)[source]
Bases:
objectFinite worst-case resources an adapter is permitted to consume.
- Parameters:
- class ContextActionReceipt(action, graph_version_before, graph_version_after, output_nodes, output_edges, latency_seconds, materialized_tokens, tool_calls, monetary_cost, measured_information_gain, outcome, rolled_back=False)[source]
Bases:
objectActual graph transition and cost for one context action.
- class ContextEdge(edge_id, source_node, target_node, kind, confidence=None, provenance=())[source]
Bases:
objectOne versionable typed relation in the context graph.
- Parameters:
- class ContextGraph[source]
Bases:
objectMutable, versioned evidence graph with deterministic snapshot/restore.
- add_node(node)[source]
Add an immutable node or accept an idempotent duplicate.
- Parameters:
node (ContextNode)
- Return type:
None
- add_edge(edge)[source]
Add an immutable edge after endpoint validation.
- Parameters:
edge (ContextEdge)
- Return type:
None
- verify(node_id, status, *, provenance=(), confidence=None)[source]
Replace verification fields without erasing generated provenance.
- remove_node(node_id)[source]
Remove one node and all incident edges as one versioned mutation.
- Parameters:
node_id (str)
- Return type:
None
- neighbors(node_id, *, kinds=None)[source]
Return both incoming and outgoing neighbors for revisitation.
- unresolved_nodes()[source]
Generated hypotheses/claims that still need verification.
- Return type:
tuple[ContextNode, …]
- snapshot()[source]
Capture graph state for transactional context actions.
- restore(snapshot)[source]
Restore an action snapshot after failure, or leave the graph untouched.
Validation happens on the candidate before anything is installed, so a rejected snapshot is a no-op rather than a half-applied state: this is the recovery path, and a restore that corrupts the graph it is restoring is worse than one that fails (MXR-080-1859).
- transaction()[source]
Exclude concurrent graph mutations while a staged transaction is prepared.
- Return type:
Iterator[None]
- replace_if_unchanged(expected, replacement)[source]
Install a staged state only when the complete base snapshot still matches.
Like
restore(), the replacement is validated before it is installed, so a rejected staging attempt leaves the live graph exactly as it was (MXR-080-1859).
- class ContextNode(node_id, kind, text, token_count, provenance=(), evidence_status=EvidenceStatus.UNVERIFIED, confidence=None, generated=False, source_horizon_position=None, metadata=<factory>, evidence_history=())[source]
Bases:
objectOne source, claim, generated artifact, summary, result, or memory unit.
- Parameters:
- property content_hash: str
Deterministic node-content fingerprint.
- class ContextNodeKind(*values)[source]
Bases:
StrEnumSemantic role of one bounded context artifact.
- class EvidenceTransition(graph_version, status, provenance=(), confidence=None)[source]
Bases:
objectOne immutable, graph-versioned evidentiary state.
- Parameters:
- class EvidenceStatus(*values)[source]
Bases:
StrEnumVerification status kept separate from model confidence.
- class FrozenMetadata(values=None)[source]
-
Deterministic, recursively immutable context metadata.
- Parameters:
values (Mapping[str, Any] | None)