aeat.core.observability._replay module¶
Deterministic read-only replay of a recorded RunTrace.
Replay loads a persisted trace, recomputes the current
corpus_sha256, refuses on drift, and re-enters the same Typer CLI
path reconstructed from captured ArgumentRecord values.
Replay also refuses recorded arguments containing the removed
--no-dry-run flag, so old traces cannot reintroduce an obsolete
CLI shape during argv reconstruction.
- replay_run(run_id, *, invoke=None, assert_envelope=False, assert_db_state=False)[source]¶
Replay a recorded run after gating on corpus drift.
When
assert_envelopeis set andinvokeis provided, the re-entered invocation’s emitted--format jsonenvelope is captured and asserted byte-identical (after the declared narrow mask) against the golden envelope persisted for the original run — closing the research F1 gap so replay proves “the same JSON came out”, not only “the same argv re-runs”. The capture/canonicalise/mask/compare logic lives in the shared substrate primitive (aeat.core.observability._golden); the operator golden gate reuses the same primitive.- Parameters:
run_id (
str) – Identifier of the recorded run to replay.invoke (
Callable[[list[str]],object] |None) – Optional callable that re-enters the CLI with the reconstructed argv. WhenNonethe function loads and validates the trace but does not re-execute it, returning the originalRunTracedirectly.assert_envelope (
bool) – WhenTrue(andinvokeis provided), load the original run’s persistedenvelope.json, capture the re-entered invocation’s emitted envelope, and assert they match after masking.assert_db_state (
bool) – WhenTrue(andinvokeis provided), the OPTIONAL post-state tier: recompute thevar/fingerprint after re-entry and assert it equals the recordeddb_sha256. This proves state-transition determinism (a retried write is a true no-op) and is meaningful only for a scenario that runs against a hermetic syntheticvar/root; the sharedvar/would flap it, which is why it is opt-in and never a hard gate for all replays.
- Return type:
- Returns:
The loaded
RunTraceof the original run.- Raises:
AeatObservabilityError – When the trace carries removed write-era flags, when
assert_envelopeis set but the re-entered invocation emitted no envelope to compare, or whenassert_db_stateis set and the post-statevar/fingerprint drifts from the recorded one.AeatCorpusDriftError – When the current corpus hash differs from the recorded one.
GoldenReplayMismatchError – When
assert_envelopeis set and the replayed envelope diverges from its captured expectation.