Trace replay
Record a run once. Persist it. Reload it later and re-assert the substrate's rules — without re-executing.
Record a run once. Persist it. Reload it later and re-assert the substrate’s rules — without re-executing.
from decimal import Decimal
from entorin.replay import TraceRecorder, assert_all, load_trace_json
# Record:
recorder = TraceRecorder(bus) # subscribes to "*" by default
await run_qa(...) # any substrate-driven workload
Path("trace.json").write_text(recorder.dump_json(indent=2))
# Replay (later, possibly in a different process):
loaded = load_trace_json(Path("trace.json").read_text())
assert_all(loaded, budget_cap=Decimal("5.00"))
assert_all runs every shipped invariant: payload-schema conformance, *.call.pre paired with *.call.post|error per identifier, exactly one run.start followed by one terminal event, and cumulative cost_usd within cap. Each check raises InvariantViolation (an AssertionError subclass) on failure.
Why this is the P7 demonstrator
P7 — testing / evals weak — is the pain that bites every team running agents in production. The fix isn’t more eval suites; it’s making the substrate’s own rules into the regression substrate. A trace either obeys the invariants or it doesn’t, and that’s a property you can assert in CI without re-running the model.