Hand-built events give you precise control over the inputs and make the test easier to reason about, but they require more scripting effort and deeper knowledge of the data structures. A trace captures more of the original runtime state automatically, which improves realism, but it also brings sanitisation and review requirements.
Why replaying a trace feels closer to the original system
Replaying a trace is useful when you want the test to reflect the runtime conditions that actually occurred. The trace preserves more of the original sequence, timing, and surrounding state, so it is often a better fit for reproducing behaviour that depends on interactions you did not want to model manually.
That realism is the main advantage, but it is also the main constraint. The more you preserve from the original execution, the more you inherit whatever was present in that data, including noise, irrelevant fields, and potentially sensitive material that should not be carried into a test environment without review.
Why hand-built events give you more control
Constructing events by hand is the opposite trade-off. You decide exactly which fields exist, which values matter, and which edge cases to emphasise, so the test is easier to reason about and easier to keep small. That makes hand-built events especially useful when you are trying to isolate a single decision path or prove a specific hypothesis.
The cost is effort. You need enough knowledge of the data structures to build valid events, and you have to maintain that construction logic yourself. If the structure is complex or changes often, the scripting burden can become the dominant part of the test.
In practice, the choice is usually between realism and precision. A trace is often better for reproducing observed behaviour, while hand-built events are better for controlled experiments, minimal repro cases, and assertions that should be obvious to another reviewer.
How to choose between them in practice
Use a trace when the thing you care about depends on the original runtime context and you want to preserve as much fidelity as possible. Use hand-built events when you need deterministic inputs, tight control over variations, or a test case that should survive long after the original trace is no longer available.
Many teams get the best result by combining both approaches. Start with a trace to understand what happened, then distil it into a smaller hand-built event set once you know which fields, transitions, or ordering constraints actually matter.
That workflow keeps the realism of the trace without making every regression test depend on a large captured payload. It also makes it easier to sanitise the data, because you can decide which portions of the original trace are essential and which should be removed before reuse.
Risk and Threat Considerations
Traces can carry more than just behaviour, they can also carry copied secrets, identifiers, user data, or environmental details that were present during the original run. If those artefacts are replayed without sanitisation, a test harness can become an unintended data leakage path or a source of misleading results.
Failure mechanism: Replay preserves original fields and ordering, so sensitive or environment-specific values may be injected into a new context unless someone reviews and strips them before use.
Impact: The test may expose confidential material, reproduce production-only assumptions, or validate behaviour against stale state instead of the scenario you intended to test.
Practitioner Guidance
What to verify: Before trusting a replayed trace, confirm which fields are essential to the behaviour under test and which should be redacted, normalised, or replaced with safe placeholders. For hand-built events, verify that the minimal field set still exercises the same path as the trace.
Decision rule: If your goal is fidelity to a real incident or workflow, start from a trace; if your goal is clarity, repeatability, or a narrow assertion, build the event by hand. If both matter, use the trace as the source of truth and then compress it into a cleaner manual fixture.
Common mistake: Treating a trace as automatically safer because it is more realistic. Realism is useful, but it also means you inherit more review burden, more potential contamination, and more assumptions that should be made explicit before the test is shared or automated.
Practitioner takeaway: Choose the method that matches the question you are asking, not the one that is easiest to generate; trace replay is for faithful reproduction, hand-built events are for controlled explanation.
Related resources from NHI Mgmt Group
- What is the difference between strategic identity events and technical identity events?
- What is the difference between test-driven and trace-driven evaluation?
- What is the difference between model governance and trace logging?
- What is the difference between blocking source code leaks and using education for low-risk exfiltration events?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 22, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org