mechaharness.external_effect
Effect records, reconciliation actions, and crash probes used by
EffectfulGraphNodeRunner.
External-effect records, reconciliation, and crash probes (DR-03..07).
EffectfulGraphNodeRunner lives beside
GraphNodeRunner so the registry stays a single injectable type.
Effect identity is generic — Cursor (or any coding-job backend) is a host adapter detail, not a MechaHarness core type:
>>> from mechaharness.external_effect import (
... ArmedCrashProbe, EffectRecord, EffectState, InjectedProcessCrash,
... )
>>> effect = EffectRecord(
... effect_id="run:job:1",
... run_id="run",
... node_id="job",
... node_attempt=1,
... backend_id="host.coding_job",
... state=EffectState.UNCERTAIN,
... )
>>> effect.state.value
'uncertain'
>>> probe = ArmedCrashProbe("after_accept_before_record")
>>> probe.maybe_crash("before_intent") # not armed here
>>> try:
... probe.maybe_crash("after_accept_before_record", effect_id=effect.effect_id)
... except InjectedProcessCrash as crash:
... crash.boundary
'after_accept_before_record'
- class mechaharness.external_effect.ArmedCrashProbe(location: Literal['before_intent', 'after_intent_before_call', 'after_accept_before_record', 'after_accept_recorded', 'after_reduce_before_checkpoint', 'after_final_commit'])[source]
Bases:
CrashProbeRaise once at a single crash location (for DR-10 / DR-12 matrices).
- class mechaharness.external_effect.CrashProbe[source]
Bases:
ABCOptional injectable that raises
InjectedProcessCrashat a boundary.
- class mechaharness.external_effect.EffectDispatchResult(*, external_handle: str, detail: dict[str, ~typing.Any]=<factory>, **extra_data: Any)[source]
Bases:
BaseModelReturn value of an external dispatch once the backend accepts it.
- detail: dict[str, Any]
- external_handle: str
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class mechaharness.external_effect.EffectReconciliation(*, action: EffectReconciliationAction, external_handle: str | None = None, outcome_payload: dict[str, ~typing.Any]=<factory>, outcome_evidence: dict[str, ~typing.Any]=<factory>, error: str | None = None, detail: dict[str, ~typing.Any]=<factory>, **extra_data: Any)[source]
Bases:
BaseModelResult of host-side reconcile (DR-06).
- action: EffectReconciliationAction
- detail: dict[str, Any]
- error: str | None
- external_handle: str | None
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- outcome_evidence: dict[str, Any]
- outcome_payload: dict[str, Any]
- class mechaharness.external_effect.EffectReconciliationAction(*values)[source]
Bases:
str,EnumHost adapter decision after inspecting an uncertain/accepted effect.
- COMPLETE = 'complete'
- DISPATCH = 'dispatch'
- FAIL = 'fail'
- NEEDS_ATTENTION = 'needs_attention'
- OBSERVE = 'observe'
- class mechaharness.external_effect.EffectRecord(*, effect_id: str = <factory>, run_id: str, node_id: str, node_attempt: int = 0, backend_id: str = '', external_handle: str | None = None, state: EffectState = EffectState.INTENDED, revision: int = 0, recovery_boundary: Literal['planning', 'dispatch', 'post_effect_pre_record', 'reduce', 'commit'] | None=None, detail: dict[str, ~typing.Any]=<factory>, created_at: str | None = None, updated_at: str | None = None, **extra_data: Any)[source]
Bases:
BaseModelPersisted external-effect identity (DR-03).
- backend_id: str
- created_at: str | None
- detail: dict[str, Any]
- effect_id: str
- external_handle: str | None
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- node_attempt: int
- node_id: str
- recovery_boundary: RecoveryBoundary | None
- revision: int
- run_id: str
- state: EffectState
- updated_at: str | None
- class mechaharness.external_effect.EffectState(*values)[source]
Bases:
str,EnumDurable lifecycle of an externally visible side effect.
Distinguishes (DR-04): 1. no record — dispatch was never intended; 2.
intended— intent committed, external call not started; 3.uncertain— call may have started; acceptance unknown; 4.accepted— external system accepted; handle recorded; 5.completed/failed— terminal; 6.needs_attention— host must decide; never silent redispatch.- ACCEPTED = 'accepted'
- COMPLETED = 'completed'
- FAILED = 'failed'
- INTENDED = 'intended'
- NEEDS_ATTENTION = 'needs_attention'
- UNCERTAIN = 'uncertain'
- exception mechaharness.external_effect.InjectedProcessCrash(boundary: str, *, detail: dict[str, Any] | None = None)[source]
Bases:
ExceptionSimulated process death at a recovery boundary (acceptance tests).
- class mechaharness.external_effect.NoopCrashProbe[source]
Bases:
CrashProbeDefault: never crash.