Skip to content

8.2 Guardrails (binding)

Every guardrail names where it is enforced and how a violation shows. Log events carry internal IDs only — an extraction or run ID, later the document or case ID of the domain model — plus non-identifying facts such as field name, verdict, counts and lengths; never contract content (G-6). The events below are the target vocabulary; which of them are emitted is TD-11.

Nothing is released without a person. G-4 states it as a guardrail; the case model makes it a property of the model, not of the screen — Publish has one entry, the completion of Release findings, a HumanTask (from the case model, 6.3 Child case Fee reconciliation). A customer model that offers a path around it is rejected before deployment (W-6 in spec 15 (docs/specs/15-workflow-module.md)).

The reference for these guardrails is OWASP LLM06:2025 Excessive Agency (docs/architecture/owasp-llm06-2025-excessive-agency.md), kept in docs/architecture/ as a fixed text so that reviews of FeeCheck's own LLM calls can cite it (from that file's header; also cited by ADR-0012 (docs/adr/adr-0012-model-provider-and-extraction-shape.md)).

Rule Kind Enforced where Detected in the log as
G-1 The contract is untrusted input; its text is never treated as an instruction injection protection today: prompt rule 9 and the document markers (ExtractionPrompt); anchor escaping in Rendition.markdown(); target: intake gate 2 (8.19.2) guardrail.injection-neutralised documentId=<id> page=<n>; negative test QS-4 (NFR-5), not yet written
G-2 PII is minimised before the LLM call data boundary the PoC processes synthetic data only (C8); the procedure follows from a catalogue of personal and other sensitive data and a detailed policy, neither written yet (OQ-8) guardrail.prompt-field-blocked extractionId=<id> field=<name>
G-3 The MCP tool has minimal permissions and serves released findings only; no database access for agents autonomy limit planned: the MCP tool get_reconciliation_findings (FR-5); not built; the endpoint's own access check is planned (ADR-0011 (docs/adr/adr-0011-mcp-server-placement.md)) guardrail.mcp-denied callerId=<id> cause=<cause> correlationId=<id>; negative test for unauthorised MCP access (NFR-5)
G-4 Never without human release: confirming a contract value as settlement-relevant human-in-the-loop planned: the workflow's human release task (spec 15, W-3, W-6, W-7); not built release.recorded caseId=<id> findingId=<id> userId=<id>; a publication without it is guardrail.release-without-person caseId=<id>
G-5 Every LLM call records model, prompt and eval version, latency, tokens and cost operating limit LlmCallTelemetry, a call advisor inside the schema validation of the extraction loop (ExtractionLoop): one line per model call, each re-ask and each tool round included, and one per extraction for the outcome; also one line per tool call and one for a loop a guard stopped, and the same advisor enforces the loop's turn cap and token budget; the prompt version is a digest of the prompt text (ExtractionPrompt.version()). Not yet: the eval version (no evaluation set exists) and the cost (tokens are recorded, the price is not); Spring AI's own observations stay off llm.call extractionId=<id> turn=<n> provider=<p> model=<name> promptVersion=<v> latencyMs=<n> promptTokens=<n> completionTokens=<n> tokens=<n>, with failure=<type> in place of the tokens for a call that failed; extraction.outcome extractionId=<id> grounded=<n> unsupported=<n> notFound=<n> ambiguous=<n> complete=<bool>; extraction.tool extractionId=<id> tool=<name> argumentLength=<n> resultLength=<n> latencyMs=<n> outcome=<o>; extraction.loop.stopped extractionId=<id> reason=<r> turns=<n> tokens=<n>; extraction.reask extractionId=<id> unsupported=<n> notFound=<n>; extraction.model.retry extractionId=<id> provider=<p> failure=<kind> retry=<n> of <n> exception=<type>, one per retry of an outage
G-6 No contract content in any log, at any level; log internal IDs instead data boundary every logger; ExtractionLogTest captures the extraction path's log a failing captured-log test — a log line cannot report itself at runtime
G-7 Every model response is validated before it reaches domain code injection protection StructuredOutputValidationAdvisor (schema, re-asks) and ExtractionResponseParser (fallback, citation check) extraction.schema-retry extractionId=<id> attempt=<n>; extraction.fallback extractionId=<id> reason=<empty\|not-json\|not-object>