Testing, Evidence, and Contracts
Guardrails are safe to roll out because every rule can be exercised before it blocks traffic, and every decision is recorded as bounded trace evidence. This page covers the testing tools, the trace event model, and the client-facing HTTP contracts.
Dry run and preview#
Two evaluation modes answer different questions:
| Mode | Question it answers | Semantics |
|---|---|---|
| Dry run | What does each rule think of this sample on its own? | Every rule receives the original sample independently; only steps within one rule share state. No cross-rule transformation or blocking short-circuit. |
| Preview | What would the live pipeline actually do? | Runs the real configured ordering, transformations, fresh samples, and blocking short-circuit, without side effects. |
Both accept optional endpoint and requestBody alongside the response sample. target can be
input, output, tool_call, or tool_result; tool targets require toolName. Missing
dependencies are reported as not_evaluated, never as passes, and runtime model failures retain
each rule's fail-open or fail-closed decision.
Test guardrails workflow#
In the Workbench Test guardrails view:
- Send normal samples with an expected allow to find false positives.
- Send restricted samples with an expected block to find missing coverage.
- Inspect the final checked content and the executed checks.
- Use the optional
expected: allow | blockfield to get a direct match/mismatch signal.
The preview never generates an answer or executes a tool, but configured model reviews are real calls. It validates configured rules, not live MCP authorization, upstream resource semantics, or SSE delivery — runtime integration tests verify those execution points.
Trace evidence#
Request Trace spans carry two guardrail event kinds:
provon.guard.check— execution facts: execution kind (immediateormodel), status (checked,not_evaluated,error), outcome, duration, cached verdict, fixed reason, policy id, and RFC 6901 field positions.provon.guard.match— decision facts: plugin id, action, direction, optional category, metric, observed value, limit, and would-action.
Records are bounded and contain no raw sample, policy text, or replacement value. Incremental streaming passes are sampled once per rule and direction. One request can produce one decision event per evaluated rule; the first blocking decision decides whether the exchange is intercepted.
Block contract#
An enforced block returns 409:
{
"error": {
"message": "Provon Gateway blocked this exchange because a guardrail was triggered.",
"type": "provon_gateway_guard",
"code": "PROVON_GATEWAY_GUARD_TRIGGERED",
"param": null,
"retryable": false,
"details": {
"pluginId": "provon.guard.secret-leak",
"action": "block",
"direction": "input",
"category": "openai_api_key",
"decisions": [
{
"pluginId": "provon.guard.secret-leak",
"action": "block",
"direction": "input",
"category": "openai_api_key",
"metric": "secret_match_count",
"value": 1,
"limit": 0,
"reason": "semantic_flagged"
}
]
}
}
}details.decisions lists every decision recorded for the exchange, in evaluation order and capped
at 20 entries, with enums and numeric measurements only — never matched text or model free text.
For semantic matches, details.category carries the policy id and the checker reason surfaces as
the decision reason.
Response headers:
x-provon-guard-triggered: true
x-provon-guard-plugin-id
x-provon-guard-action
x-provon-request-idA block discovered only after streaming started cannot become a clean 409; the runtime terminates
the in-progress stream instead. Segment buffering keeps the block zero-leak by holding bytes until
the scan completes; chunk mode favors latency and interrupts delivery as soon as a match is found.
Do not retry the same blocked payload — change the request or the project policy.
Rewrite signal contract#
A transform rule can allow an exchange after rewriting it — redacting PII or secrets, or capping
requested completion tokens. Successful (2xx) non-streaming responses and input rewrites known
before delivery carry machine-readable signal headers:
x-provon-guard-modified: true
x-provon-guard-redaction-count: 2The redaction count is the number of distinct values replaced (repeated occurrences of the same value count once) and is omitted when the rewrite involved no redaction. Incremental output rewrites cannot truthfully set final counts after headers are committed, so their results land in Trace events instead. Blocked responses never carry these headers, and audit-mode rules never rewrite bytes.
Performance controls#
| Mechanism | What it does |
|---|---|
| Verdict cache | Bounded LRU/TTL cache for model verdicts, keyed by content hash so prompts and policy text never enter the cache |
| Parallel checks | Opt-in: slow input judges run alongside the upstream call; a blocking verdict still wins the gate |
| Layered escalation | Local heuristics and regex settle clear cases; only suspicious or policy-backed content spends a model call |
| Detached audits | Non-blocking model audit checks run detached from the delivery path and never gate a response |
Action validation#
Each rule accepts only the actions it can execute. Unsupported pairs — for example transform on a
rule with no rewrite path — are rejected when settings are written (400), not reinterpreted at
request time. An unrecognized action is likewise rejected rather than downgraded to audit. Disabled
draft rules keep their stored config unvalidated until re-enabled.
Rollout layering#
Apply controls in this order:
- Application authentication and authorization for user actions.
- Restricted project API-key capabilities and independently rotated keys.
- API-key usage limits for hard resource boundaries.
- Guardrails for request, response, and tool-shape policy.
- Provider keys and model mappings restricted to approved upstream targets.
- Trace Capture retaining the evidence needed to audit decisions.
A request may be admitted by usage policy and still be blocked by a guardrail. A request may pass both and still fail provider authentication, capability checks, or upstream execution.
Security guidance#
- Give workloads Provon project keys, never upstream provider keys.
- Use a separate project key per environment or application boundary.
- Avoid raw secrets and unnecessary personal data in prompts and context headers.
- Use specific model mappings when a provider key must expose a strict allowlist.
- Treat header overrides and custom upstream URLs as privileged configuration.
- Review provider key, guardrail, and API-key changes as production policy changes.
- Apply project telemetry retention to captured prompts, responses, and tool arguments.