Faultgate 0.5.0, Faultgate-Zero 0.2, Trace-to-Fixture 0.1 and Fault-Contract 0.1 are on PyPISee products →

What is fault-contract?

A contract is one small JSON file per tool. It specifies what the agent may send as request arguments and what it relies on receiving back as response data, using JSON Schema 2020-12 or Pydantic models.

Checks read data that was already sent and received: nothing calls a tool, a backend, or the network. When installed alongside faultgate-zero, pytest tests automatically evaluate tool contracts.

Known limit: trace-to-fixture 0.1.0 needs faultgate-zero below 0.2 and fault-contract needs 0.2 or newer, so the two cannot be installed in the same environment yet.

INSTALL & QUICKSTART

pip install fault-contract
pip install pydantic              # only if a contract points at a Pydantic model
EXAMPLE CONTRACT FILE (.faultline/contracts/issue_refund.contract.json)
{
  "contract": 1,
  "tool": "issue_refund",
  "owner": "billing",
  "request": {
    "schema": {
      "type": "object",
      "properties": {
        "order_id":    {"type": "string", "pattern": "^[0-9]{4,}$"},
        "amount":      {"type": "number", "exclusiveMinimum": 0},
        "customer_id": {"type": "string"}
      },
      "required": ["order_id", "amount", "customer_id"],
      "additionalProperties": false
    }
  },
  "response": {
    "schema": {
      "type": "object",
      "properties": {
        "refunded": {"type": "number"},
        "order_id": {"type": "string"}
      },
      "required": ["refunded", "order_id"]
    }
  }
}
EXAMPLE CHECK OUTPUT (fault-contract check runs.json)
format     otlp (detected)   traces 7   tool calls 17   with a contract 17

issue_refund   request   1 of 2 calls
  100%  $.amount    expected number, got string  e.g. trace 7418fc74… step 3
issue_refund   response  1 of 2 results
  100%  $.refunded  expected number, got string  e.g. trace 7418fc74… step 3

FAIL  2 violations in 1 tool
2020-12
JSON SCHEMA OR PYDANTIC
IN & OUT
REQUEST & RESPONSE CHECKS
0
NETWORK TRAFFIC
MIT
ALPHA v0.1.0

01 / THREE SCHEMA SOURCES

Flexible contract definitions per tool.
SourceConfigurationWhen to use
schema{"schema": {"type": "object", ...}}Inline JSON Schema 2020-12 definition.
schema_file{"schema_file": "../../api/openapi.json#/components/schemas/RefundRequest"}Local JSON Schema or OpenAPI JSON file relative to the contract file.
pydantic{"pydantic": "billing.api.models:RefundRequest", "strict": true}Backend Pydantic model. Notice: importing a Pydantic model runs that module's import-time code.

02 / COMMANDS

CLI tools for initialization, checking, and definition audit.
CommandWhat it doesExit codes
fault-contract initDraft contracts from tool definitions, Pydantic models, or trace exports.0 / 2
fault-contract check PATH...Validates tool calls in exports and fixture folders against active contracts.0 clean, 1 violations, 2 input error
fault-contract defsCompares definitions against contracts (D1-D7 checks for missing fields and type drift).0 / 1
fault-contract explain PATH --trace IDStep-by-step trace inspection with schema paths and Pydantic strict/lax outcomes.0 / 2
fault-contract contractsLists loaded contracts, their schema sources, and unchecked formats.0 / 2

03 / CONTRACT VS POLICY VS DEFINITION

Where shape constraints belong compared to business limits.
DimensionTool definitionContract (fault-contract)Policy (faultgate-zero)
Question answeredWhat does the model think this tool takes?What exact shape must the data have, in and out?What is the agent allowed to do?
Covers resultsNoYes (validates response shape)Only "an earlier call succeeded"
Exampleamount: numberamount is number > 0; customer_id required; no extra fieldsissue_refund.amount <= 500; only after verify_identity
File locationAgent code.faultline/contracts/*.contract.json.faultline/policy.json

RULE: DATA SHAPE BELONGS IN THE CONTRACT. BUSINESS BOUNDS BELONG IN POLICY.

04 / PRIVACY

Redacted error output and offline operation.

Payload values appear only as redacted previews of 40 characters or fewer, and only in explain and the JSON and Markdown reports. The terminal output of check prints paths, messages, and locations without values. Locations are a hashed trace id and a step number.

Field names in paths are redacted too because dictionary keys can contain private data. Contract verification runs locally. Nothing leaves the machine.

05 / DEBUGGING

Common contract resolution symptoms and remedies.
SymptomLikely causeFix
"no contract" for a tool that has oneNames differ: matching is exact and case-sensitive.check lists the names actually called. Make tool match.
Exit 2 "invalid schema"The schema violates JSON Schema 2020-12 metaschema.The message names the file and schema path. Then run fault-contract contracts.
Exit 2 "cannot import billing.api.models"The backend package is not installed here.Install it, or init --pydantic ... --snapshot.
Many additionalProperties violations right after initThe model sends fields the definitions never listed, or a framework wraps the arguments.explain shows the real keys. Add them, or allow extra on that object.

06 / LIMITS

Version requirements and runtime boundaries.
  • Requires faultgate-zero 0.2.x or newer (installed automatically via dependencies).
  • Importing a Pydantic model executes that module's import-time code; snapshot models if imports carry side effects.
  • Known limit: trace-to-fixture 0.1.0 needs faultgate-zero below 0.2 and fault-contract needs 0.2 or newer, so the two cannot be installed in the same environment yet.

07 / THE FAULTLINE SUITE

How FAULTLINE tools fit together across testing and release.
TESTING

faultgate-zero

Agent failure checks inside your existing pytest tests.

Open product →
TESTING

trace-to-fixture

Real agent runs become safe, small, repeatable fixtures.

Open product →
CONTRACT (ACTIVE)

fault-contract

Tool-call shape checks for request arguments and response results.

Current product →
RELEASE GATE

faultgate

Release gate over recorded traces with noise-aware statistical bands.

Open product →
FIREWALL

mcp-guard

Local firewall and integrity monitor for MCP tool calls.

Open product →

Need help checking agent tool contracts?

FAULTLINE offers fixed-scope diagnostic and production reliability audits. Production audits install and configure these tools when compatible.