@acentric/replay
v0.1.1
Published
Runs an agent's pure half with no runner: delivers messages to step as a runner would, and replays a session's journal.
Maintainers
Readme
@acentric/replay
Runs an agent's pure half with no runner. It is what runners and the CLI use to replay and fork sessions; for tests, use @acentric/testing, which re-exports it.
simulate(agent, config)creates a session in memory and delivers messages tostepone at a time, matching effects as a runner does. It runs no handlers: the caller reports their outcomes withok,failandinterrupt, and plays the clock withadvance.upgrade(next)moves the session to another version through itsmigrate.replay(journal, agents)delivers a session's journal again. Faithful replay, the default, runs each entry on the version that ran it and checks that it gives the answer and digest the journal recorded. What-if replay,{ mode: 'what-if' }, runs every entry on one agent frominit, to see what that code would have done. Either way the result says which entries differ.journalDigest(snapshot, config, appended)computes a journal entry's digest: SHA-256 of the RFC 8785 canonical JSON of the three, as every runner computes it.
import { forReplay, replay } from '@acentric/replay';
const result = replay(journal, [forReplay(v1), forReplay(v2)]);
if (result.differs !== null) console.log(`entry ${result.differs} differs`);forReplay erases an agent's types, so versions with different snapshots
replay together. The journal format and digest are in
the runner specification; the design is in
docs/reference/replay.md.
