Skip to content

ltl-mastra

Returns the same tools with their execute wrapped. See guarding tools.

GuardToolsOptions
source The trace source numbering this run. Share one across every guard on the run.
policy Overrides the mode per call.
onDecision Fires once per interception, including for refused calls.
onEvent Fires per committed event.
Type
GuardableTool The duck-typed shape a tool has to have.
GuardDecision { action, event, verdicts } — what onDecision receives.

guardWorkflow(monitor, workflow, options?)

Section titled “guardWorkflow(monitor, workflow, options?)”

Rewrites both the step map and the execution graph. See guarding workflows.

One step at a time.

guardedStepIds(workflow) What the guard actually stands in front of. Not every key in the step map.
isGuardedStep(step) Whether a step is already wrapped.
VIOLATION_KEY The key a violation travels under in a suspend or resume payload.
widenSchema(schema) Admits the extra variant alongside whatever a step already declared.
Type
GuardWorkflowOptions The options both workflow guards take.
GuardableStep, GuardableWorkflow The duck-typed shapes.
GuardedStepSource Where a guarded step reports it came from.
BlockedResult What deny returns in place of a tool’s output.
ViolationDetail The description a human is shown.
ViolationSuspendPayload, ViolationResumePayload The two halves of a suspension.

Fills what the guards cannot see: unguarded step boundaries and the run’s ending. See observing a run.

ObserveRunOptions
guardedSteps Steps a guard already covers, so nothing is recorded twice.
onEvent Per committed event.
onFinish End-of-run resolution — where unresolved appears.
Type
RunObservation What the observer returns.
fromWorkflowState(state) Reads a run’s outcome out of the engine’s own state.
policyFor(violations) The default decision: the strictest mode among the violated rules.
decide(violations, ctx, policy?) The whole decision, policy included.
violationsOf(verdicts) The violations in a verdict list.
violationResult(violations) The BlockedResult a denied tool returns.
violationMessage(violations) The one-line human form.
summarize(violations) A ViolationSummary for a report.
ViolationError What abort throws where the side effect would have been.
Type
Policy (violations, ctx) => Action | Promise<Action>. Throwing fails closed.
PolicyCtx The candidate event, the verdicts, the site (tool or step), and the abort signal.
Violation, ViolationResult, ViolationSummary The shapes above.
createTraceSource(options) Numbers and timestamps one run’s events.
payloadHash(value) The stable digest repetition checks key on.
Type
TraceSource Draft an event at the current position; commit advances.
TraceSourceOptions { runId } and the clock.
extractWorkflowGraph(workflow, options?) The declared step graph, for ltl analyze verify.
PARALLEL_ARMS_WARNING What the extractor says when a parallel block exists: arms are modelled without interleavings.
ExtractOptions Extraction options.

A separate entry point, so nothing that writes to disk is on the path a running system loads.

createJsonlRecorder({ dir, runId }) Appends each event as it happens, so a killed run still leaves its prefix.
readJsonlTrace(path) Reads one back.

See the corpus for what those files are for, and verdicts as telemetry for what to do in a deployment instead.