Replay testing before deployments: what it catches and when you need it
Replay testing runs recorded workflow event histories against the workflow code you are about to deploy, and fails the build if the new code would issue commands in a different order or of a different type than the history shows. The Temporal documentation describes replay as the mechanism that reconstructs workflow state: when a worker picks up a workflow, it re-executes the workflow code from the start and checks each decision against the stored history. A change that adds an activity call before an existing one, renames an activity, or alters a timer can make that check fail. The failure appears as a non-determinism error on workflows that were already running, often long after the deployment that caused it, so catching it in CI is far cheaper than finding it in production.
Teams need replay testing for any change to workflow code, including small edits that look harmless. It is also needed after SDK upgrades, because a new SDK release can change how commands are generated, and after dependency changes that touch workflow code paths, such as a library that workflow code imports for time, serialization or identifiers. When a change requires patching or versioning, replay tests are how you confirm that the patched branch keeps existing histories on the original path. A practical first step is to list each workflow type and the code it depends on, then make a passing replay run a required check for any pull request that touches that code.
Before relying on this approach, confirm three things with your own environment. First, how histories will be collected from the namespace and stored, since histories contain workflow inputs and results and may hold sensitive data that needs the same controls as the rest of your Temporal data. Second, which SDK and Temporal Server versions you run, because the replay APIs, the behavior of versioning features and the documented limits depend on those versions. Third, how often your histories are replayed against new code, meaning whether the test set covers long-running executions that predate the change. Check the replay and versioning documentation for your SDK before writing the pipeline.
Which replay test approach fits your change
Use this approach when the workflow type is new and no executions of it have run yet. There is no production history to replay, so the test input is a set of histories your team generates by running the new code on a development or staging Temporal Service with representative inputs. These tests run in CI alongside unit and integration tests and confirm that the recorded histories replay cleanly against the code that produced them.
- Test input: histories exported from runs that cover each branch, timer, child workflow and signal in the design.
- Where it runs: a CI job that replays the exported histories against the current build of the worker.
- What it proves: the workflow code is deterministic with respect to its own recorded histories, so the first deployment does not fail on those executions.
- What it cannot prove: compatibility with earlier versions, since none exist, or behavior with inputs and payload shapes the sample never used.
- Coverage gap to watch: failures, retries and cancellations often take paths that happy-path runs skip, so include them in the sample.
Check that the generated set covers every branch in the workflow, because replay only checks the paths that were actually recorded.
Use this approach for edits to a workflow type that already has open or recently closed executions, such as changed activity options, added logging or business logic that leaves the order of commands intact. The test input is a sample of histories from production or a production-like environment, handled under your data policy. The replay job runs on every pull request that touches workflow code.
- Test input: histories from open and recently closed executions, chosen to include older start dates, newer start dates and the longest histories available.
- Data handling: histories carry workflow inputs and results, so redact or encrypt payloads according to your rules before they reach CI.
- Codec access: if payloads are encrypted with a custom codec, confirm that the replay job can decrypt them without exposing keys to developers.
- Where it runs: a pull request check that fails the build on the first non-determinism error.
- What it cannot prove: behavior of executions outside the sample, or branches the sample never reached, so a rare path can still fail after release.
Confirm how the sample is selected and keep the selection reproducible, so any failure can be traced to a specific history.
Use this approach when a change alters the command sequence of a workflow that has open executions started under the old code. Those executions must continue down the old path, while new executions take the new one. The test input has two sets: histories from executions started before the change, and histories generated by the new code. The test confirms that the version or patch check sends each set down the correct branch.
- Test input: pre-change histories from open executions, plus freshly generated histories that exercise the new branch.
- Where it runs: CI, against the build that contains the version or patch markers, and again before the old branch is removed.
- What it proves: old histories replay through the old branch and new histories through the new one, so open executions are not left stranded.
- What it cannot prove: that the marker can be removed safely later, because that depends on whether any execution in your environment still needs the old branch.
- Ask your team: how the SDK's versioning API records markers, what retained markers cost in code complexity, and the removal criteria in the SDK documentation for your language.
Record when the last pre-change execution closes, because that point is the only safe trigger for removing the old branch.
Use this approach when the SDK version or worker runtime changes while the workflow code stays the same. The replay test checks that the new SDK interprets existing histories the same way the old one did. The input is histories recorded by workers on the current SDK version, replayed by a staging worker pool that runs the target SDK before rollout.
- Test input: histories recorded by current workers, covering each workflow type in use.
- Where it runs: a staging worker pool on the target SDK version, pointed at the same histories used for the baseline run.
- What it proves: the upgraded SDK replays the sampled histories without non-determinism errors.
- What it cannot prove: server-side compatibility, which depends on the Temporal Server version and the upgrade order in the server documentation, or behavior under production load.
- Release notes: review the SDK release notes for changes to replay or determinism behavior, and check whether the upgrade also requires a server change that needs its own verification.
Run the staging check on the same histories before and after the upgrade, so any difference points directly to the SDK change.
Replay test inputs and when each fits
This table compares the three ways to supply event histories to a replay test: exported from a live namespace, captured from staging or canary, or hand-built or generated. Read each row against your data controls and how much real execution behavior you need to cover. The main takeaway is that live histories give the best coverage but carry the most data risk, so most teams combine a small governed set of real histories with fixtures for edge cases.
| Input source | Coverage of real executions | Data sensitivity | Effort to maintain |
|---|---|---|---|
| Exported from a live namespace | Highest. Reflects the exact versions, timing and branches your production workflows took | High. Histories contain workflow inputs, results and activity payloads, so they fall under your data handling and retention controls | Moderate. Needs a repeatable export job, selection rules and a refresh cadence as workflows change |
| Captured from staging or canary | Good when staging traffic resembles production. Coverage depends on what load and scenarios staging actually runs | Medium. Often uses synthetic or masked data, but confirm that no production data reaches staging before relying on this | Moderate. Requires staging to run the workflow versions you intend to test and a capture step in the pipeline |
| Hand-built or generated fixtures | Limited to the scenarios someone thought to write. Good for specific branches, timers and signals that are rare in production | Low. Built from invented inputs, so little or no real data is involved | Highest per scenario. Each fixture must be written, reviewed and updated when the workflow intentionally changes |
| Histories from a previous deployment version | Covers executions started under older code, which is where non-determinism usually appears | High when taken from production, the same as live exports | Moderate. Keep versioned copies and record which code version produced each history |
| Mixed approach with a curated corpus | Broad when real histories cover common paths and fixtures cover rare ones | Controlled, because only a reviewed subset of real histories is stored outside production | Highest overall. Needs ownership, a naming convention and a rule for retiring stale histories |
| Illustrative example: a payment workflow with a timer added in a new release | A live export shows in-flight workflows that started before the change, which is the case that breaks replay | Contains account identifiers and amounts, so store and redact under your financial data controls | Export only executions still open or recently closed, and keep the set small enough to review |
How to set up replay tests in CI
This sequence moves a team from no replay coverage to a CI gate that replays real workflow histories against every candidate build before merge. The output is a versioned fixture set, a working CI job, and a merge rule that a failed replay blocks.
Confirm SDK and replay utility versions
The platform engineering lead and the workflow owners confirm the Temporal SDK version the service runs and the replay utility their language SDK provides for reading and replaying event histories. Pin both versions in the repository and record them with the fixtures. Check the SDK release notes for the replay API, because the function names and arguments differ between languages and can change between releases. Done when a developer can run one local replay of a known history on the current code and get a clean result.
Export representative histories from a non-production namespace
Engineers export event histories for workflow types that represent the business paths in use, including long-running workflows, workflows that use timers, signals, child workflows, and any versioning markers already in production code. Use a non-production namespace and remove or mask sensitive payload data before the files leave the namespace, since payloads may contain personal or regulated data. Done when each workflow type has at least one history from a run that completed and one from a run that was still open, and the export log lists the workflow IDs and the code version that produced them.
Confirm histories replay on unchanged code
Before any change is tested, the team replays every exported history against the current release of the workflow code with no edits. This baseline check separates problems in the fixtures or the replay setup from problems introduced by a new change. If a history fails on unchanged code, the team investigates the fixture, the SDK version, or the export before continuing. Done when every fixture passes on the unchanged code and the result is saved as the baseline for comparison.
Store histories as versioned fixtures
The team commits the sanitized histories to the test directory of the workflow repository, or to a dedicated fixtures repository with the same review rules, and names each file by workflow type and the code version it was recorded against. Fixtures are treated as test data: changes go through review, and the team records why a fixture was added or replaced. Done when the fixtures live in version control, a script can list them by workflow type, and a fresh clone replays them successfully.
Add a CI job that replays fixtures against the candidate build
The engineering team adds a CI job that builds the candidate workflow code, loads every fixture, and runs the replay for each history through the SDK replay utility. The job should fail with a clear message that names the workflow ID, the fixture, and the first event where the command sequence diverged. Run it on every pull request that touches workflow code, and include it in the main branch pipeline so drift is caught after merge as well. Done when a deliberately reordered workflow call in a test branch makes the job fail with that diagnostic.
Define the merge gate and the exception path
The engineering lead and the security or compliance owner agree that a failed replay job blocks merge through a required status check, not a warning. They also define the exception path for changes that intentionally alter workflow history, which usually means adding a versioning branch or a patch marker and recording the new fixture. Owners of the exception path should be named in the repository rules. Done when the required check is enabled in the repository settings and a test change that breaks replay cannot merge without a reviewed fixture or versioning change.
Verify the gate before relying on it
Before the gate is treated as a control, the team runs a short drill: one change that is safe, one that adds a versioning branch correctly, and one that breaks determinism. The safe change should pass, the versioned change should pass with its new fixture, and the breaking change should fail the job and block merge. Record the results with the pinned SDK version and the fixture set. Confirm with the SDK documentation that the chosen replay API behaves as the team assumes for your language. Done when the drill results are saved in the team's runbook and the owners sign off.
How a replay test moves from production history to CI gate
The flow starts in the production namespace, where Temporal records each workflow's event history. Histories are exported, passed through a redaction step, and stored as fixtures that the CI environment can read, but the production namespace itself is never called from CI. The CI job loads the candidate worker code, replays every stored history against it, and fails the build if any replay diverges. Check that the export path crosses the trust boundary only once and that redaction runs before any history leaves production.
Production histories reach CI only through export and redaction, then gate the build.
When replay tests must drive patching or versioning decisions
A failing replay test means the new code would issue a different sequence of commands than the one recorded for an execution that is still open, so the replay cannot match its history. Treat that failure as a decision point, not a test to silence. The change either has to be reverted or reshaped, or it has to be wrapped in a patching or versioning mechanism so that old histories follow the code path they originally took while new executions follow the new one. Before merging, decide which of these applies to each affected workflow type, and record the decision in the pull request so reviewers can see why the history is still valid.
The patching and versioning options differ by SDK, and the API names, default behavior and the way a patch marker is recorded are not the same across languages. Confirm the exact function or method, its argument shape, and how it interacts with replay in the SDK documentation for your language before writing code. Plan the cleanup as well: a marker can usually be retired only after no open execution still carries the old path, so confirm how the SDK and the Temporal Service let you determine that. Replay tests are the check that the chosen approach works. Rerun the recorded histories for the affected workflow type against the patched code, and confirm that both the old branch and the new branch replay cleanly, with the old histories still matching.
Protecting workflow histories and the replay pipeline
Replay tests are only as safe as the histories they run on. Event histories can carry business data, and the server, CI runners and fixture stores around them each need explicit controls before real histories leave production. The cards below cover the data, access, retention and review decisions to settle before the pipeline starts.
Treat histories as regulated data
Workflow histories record every activity input, result and signal payload, so they often contain personal or regulated data even when the workflow code looks harmless. Before exporting a history as a replay fixture, decide which fields must leave production at all. Use redaction for fields replay does not need, or encrypt payloads with a custom codec so the fixture holds ciphertext. Confirm with your privacy and compliance leads which fields count as regulated in your environment.
Self-hosted security docsLimit who can export histories
Exporting a history is a read of production data, so the people and systems allowed to run the export should be a short, named list. Restrict export rights to a small operator group and keep the exporter separate from the team that writes workflow code. Log each export with who requested it, which workflow ID was pulled and where the file was stored. Review that log on a fixed schedule.
Keep production credentials out of CI
CI runners that run replay tests need to read fixtures and build workers, not reach the production Temporal namespace. Give pipelines a fixture bucket or repository they can read, and no credentials for production frontend endpoints, client certificates or namespace admin roles. Where a live history must be fetched, do it through a separate, approved job with its own short-lived access rather than a standing pipeline secret.
Verify the server authorizer before export
If histories are pulled through the Temporal API, the server's authorization setup decides who can read them. When no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. Confirm that an Authorizer, a ClaimMapper and mTLS are configured on the frontend before any export job is allowed to call it, and that the frontend is not reachable from the public internet.
Security settingsSet fixture retention rules
Fixtures copied out of production tend to outlive the change that needed them, and old copies become an unmanaged data store. Define how long each fixture class is kept, such as fixtures for a merged change versus fixtures kept as regression cases, and record an owner for each. Delete expired copies automatically and check that backups of the fixture store follow the same rules. Ask your compliance team to confirm the retention periods against your data policy.
Review fixtures like code
A fixture changes what the pipeline proves, so a fixture edit can hide a regression as easily as a code edit can introduce one. Store fixtures in version control, require a second reviewer for new or changed fixtures, and check that no secrets, personal values or internal hostnames were copied in. Record which fixture set a release was tested against, so an auditor or incident responder can trace a deployment back to the evidence used to approve it.
Questions teams ask before running replay tests
How much effort does replay testing take, and what drives it up?
Replay testing is mostly a one-time build of a test harness plus a smaller recurring effort to keep it current. The build covers collecting representative workflow histories, storing them as fixtures, writing a replay test per workflow type and wiring it into CI. Effort rises with the number of workflow types, the number of SDKs and services involved, how many versions of workflow code are still running, and how much history data must be sanitized before it can leave production. Recurring effort comes from adding fixtures for new workflow changes and reviewing failures. Ask a partner for the list of workflow types in scope, the history sources, and who maintains the harness after handover.
How long does a first replay test setup usually take?
The duration depends on how many workflow types exist, how easily histories can be exported from your Temporal Service, and how quickly your team can approve sanitized data for test use. A small service with one or two workflow types and an existing CI pipeline is quicker to cover than a platform with many namespaces and mixed SDK languages. Ask for a written timeline that separates history collection, harness build, CI integration and handover, and name the approvals each step waits on. Any duration should appear in the signed scope, not in a sales estimate.
What does the work need from our team?
Replay testing needs three things from your side. First, read access to real event histories from the namespaces in scope, usually through an approved export path, plus a decision on how sensitive payload data is masked. Second, a named owner in CI who can add a required check and decide what blocks a merge. Third, engineers who know the SDK your workflows use and understand determinism rules well enough to judge whether a failure is a real break or a test artifact. Confirm these owners before the engagement starts, because most delays come from access approvals and unclear merge rights.
Can our team set up replay testing without outside help?
Yes, a team with SDK expertise and CI ownership can build replay tests internally, and the Temporal SDK documentation covers the replay API for each language. Teams usually struggle with the parts around the test: exporting histories safely, deciding which histories represent production traffic, handling versioning and patching decisions, and keeping fixtures current as workflows change. An outside partner adds most value on those points and on documenting the process for handover. Whichever route you choose, write down who owns fixtures, who approves a history export, and what the rollback path is for a failed check.
How do replay tests relate to unit and integration tests?
Unit tests check the logic of workflow and activity code in isolation, and integration tests run workflows against a test server to confirm they complete. Neither reliably shows that a code change keeps existing executions deterministic, because they do not replay histories that were recorded under older code. Replay tests fill that gap by feeding real recorded histories into the new worker code and failing the build if the commands no longer match. Run all three layers, with replay tests as a required gate before deployment of workflow code changes. Your partner should confirm which layers already exist before adding new ones.
What risks should a written scope cover for replay testing?
The main risks are histories containing personal or regulated data that leave production without approval, fixtures that drift from current workflow versions, and checks that teams learn to bypass because failures are noisy. A written scope should name the data masking method, the namespaces and workflow types covered, the CI gate and its owner, the process for handling a non-determinism failure, and the test for patched or versioned code. It should also state what is excluded, such as activity-level behavior or Temporal Server upgrades, which are covered elsewhere. Ask for these items explicitly in the quote.
What should we ask a partner for in a written replay testing scope?
Ask for a scope that lists the SDK and language versions, the workflow types and namespaces covered, the history sources and sanitization approach, the CI systems and required checks, and the patching or versioning tests included. Request the deliverables in writing: the harness repository, fixture process, runbook for failures, and a handover session for your engineers. Ask how retesting works after the first handover and who approves changes to the fixture set. Fixed scope agreed in writing before work starts gives both sides a clear basis for acceptance.
What a replay testing engagement covers at DeployOpen
A replay testing engagement starts with a review of how your team currently writes, deploys and changes workflow code. DeployOpen looks at the workflow and activity code, the worker build and release pipeline, the namespaces and task queues that carry production traffic, and the point in your process where a workflow change could be deployed. The output of this review is a written inventory of workflow types, the Temporal SDK and version each service uses, and the places where a non-deterministic change could slip through today. That inventory sets the scope that is agreed in writing before any build work begins.
The second part of the scope defines how event histories leave production. DeployOpen works with your team to decide which namespaces and workflow types are exported, how often exports are taken, and how histories are redacted so that payloads containing personal or regulated data do not reach CI runners. The team also documents where exported histories are stored, who can read them, and how long they are kept. Payload encryption and codec decisions made for your self-hosted or Temporal Cloud service affect what a replay can read, so these are confirmed with your security team before export is designed. The CI replay job is then built to run the exported histories against the proposed code and fail the build on a non-determinism error.
The last deliverable is a written patching and versioning procedure for your engineers. It explains when a change needs a patch marker or a versioning mechanism, how to retire old branches once no open executions depend on them, and how the replay job is used during that process. DeployOpen can hand over the job, runbooks and procedure documentation, and provide a training session for the engineers who will own them. Engagements are fixed-scope, so deliverables and timelines are agreed before work starts. Ongoing support, updates to the replay job as the SDK changes, and periodic reviews of new workflow types are available as a retainer.
How DeployOpen scopes and delivers Temporal replay testing
DeployOpen approaches Temporal replay testing as a scoped engagement: we agree which workflow code, event histories and pipelines are covered, build the replay test harness inside your CI, and hand over the runbooks your team needs for patching and versioning decisions. Engagements are fixed-scope, with ongoing support available as a retainer.
How we scope
- Inventory the workflow types, SDK languages and worker repositories that need replay coverage before any test is written.
- Agree in writing which Temporal namespaces and history sources will be used, and who approves exporting real event histories.
- Define which pipeline stages must block a release on a non-determinism failure, and which only report.
How we build
- Build a repeatable process for exporting workflow histories from your namespace into a controlled test fixture set.
- Wire replay tests into your CI so new workflow code runs against captured histories on every proposed change.
- Document how replay failures map to patching or versioning changes, with examples drawn from your own workflow code.
How we hand over
- Deliver the replay test suite, CI configuration and fixture-handling procedure in your own source control.
- Provide a runbook covering how engineers read non-determinism errors, reproduce them locally and choose a fix.
- Walk your platform and workflow engineers through the suite and record the open items that remain with your team.
How we support
- Review new workflow changes and replay results when your team adds workflows or changes the Temporal SDK version.
- Retest the replay pipeline after Temporal Server upgrades or changes to your history retention settings.
- Offer continuous testing and retainer-based support for teams that want replay coverage maintained over time.

