The corpus
A corpus is a set of recorded runs, committed beside the rules, re-checked whenever the rules change. It is a regression suite, and its traces are fixtures in the same sense a golden file is.
The question it answers
Section titled “The question it answers”Not “did my agent misbehave”. A running system answers that live, at the moment the guard decides, and verdicts as telemetry is where that answer belongs. A violation the guard prevented never became an event, so there is nothing in a production trace for a build to find.
The corpus answers a question about the rules: does this edit still catch what it caught, and still pass what it passed. A rule set is code, and code that decides whether side effects happen deserves a regression suite.
Where fixtures come from
Section titled “Where fixtures come from”Integration tests, which is the main one. Capture with the recorder and keep the runs worth keeping:
import { createJsonlRecorder } from '@rhysbalevicius/ltl-mastra/testing'
const recorder = createJsonlRecorder({ dir: 'traces', runId: 'run-1' })const guarded = guardTools(monitor, allTools, { source, onEvent: recorder.record })Events are appended per event rather than buffered, so a run killed mid-flight still leaves the prefix it reached — which is the case a trace is most wanted for.
ltl analyze witness, which synthesises the shortest trace that breaks one rule while every
other rule holds. That is a fixture generated rather than found, and it is the fastest way to get a negative case for a
rule you have just written.
Occasionally, a real run, curated into the corpus after an incident. That is harvesting one fixture — not piping a deployment into a build.
Capture while the rules are observing
Section titled “Capture while the rules are observing”A refused call leaves no event. So a run recorded while a rule was enforcing has nothing left in it for that rule to catch, and a corpus captured from an enforcing system is a corpus of runs where everything went fine by construction.
The runs worth keeping are the ones captured while the rules were only observing — which is also how a rule earns trust before it is switched on. The two practices are the same practice.
Why the recorder is behind /testing
Section titled “Why the recorder is behind /testing”Because writing JSONL to disk is a test-time concern and a deployment should never load the code that does it. The subpath makes that structural rather than a convention:
import { createJsonlRecorder, readJsonlTrace } from '@rhysbalevicius/ltl-mastra/testing'Nothing in @rhysbalevicius/ltl-mastra itself touches the filesystem.