Skip to content

docs: Gate an agent's tools, synth --invalid negative tests, what DataContractGate is not - #466

Merged
nightmoose merged 4 commits into
stagingfrom
docs/gate-agent-tools
Nov 26, 2026
Merged

nightmoose merged 4 commits into
stagingfrom
docs/gate-agent-tools

Conversation

@nightmoose

Copy link
Copy Markdown
Owner

What

Docs only, plus one line in the existing docs drift test.

  • New page docs/integrations/gate-agent-tools.md: checking an agent's tool arguments and tool results against a contract (AISchemaGate and DataContractGate, same engine). Worked example with two contracts (an operation allowlist with compliance_mode, and a result contract with a mask, a drop and leakage strip), HTTP, Python, TypeScript and MCP snippets, evidence via X-Batch-Id and /quarantine/summary, and honest limits.
  • Negative-test recipe using contractgate synth --invalid: a script that fails unless every invalid row is rejected, and rejected for the rule it was built to break, plus a hand-written must-reject file. --invalid exists (RFC-117) and behaves as documented; the page also states what it cannot catch (a rule deleted from the contract, transforms and leakage).
  • What DataContractGate is not section: not a post-load check, not a data catalog, not authorization, not an MCP gateway, not an intent check, not an undo, and so on, each grounded in existing repo docs.
  • Linked from docs/integrations/README.md, docs/llms.txt, docs/llm-output-validation.md and the README integrations line.
  • tests/llm_docs_test.rs: the new page is added to the route drift gate (every METHOD /path it cites must exist in src/main.rs).

No pricing, no plan numbers, no "Patent Pending", no em dashes. cg diff is not mentioned (it is in the separate PR #465).

Verified by running it

Against staging (contractgate-api-staging.fly.dev, 0.4.2), with the contracts deployed to the demo org as crm_lookup_args and crm_lookup_result:

  • contractgate validate, synth (valid and --invalid), test, deploy-contract.
  • The page's script and contract blocks were extracted from the page and run: 100 of 100 invalid rows rejected for their labeled rule on both contracts, 4 of 4 must-reject cases rejected. Deleting the enum and compliance_mode makes the script fail.
  • POST /egress allowed (200), refused (422, enum_violation plus undeclared_field), and result shaping (email masked, ssn dropped, internal_notes stripped).
  • Python aischemagate and TypeScript @nightmoose/aischemagate snippets, dry_run.
  • MCP server @nightmoose/contractgate-mcp-server egress_validate over stdio.
  • GET /quarantine/summary with a run id.
  • cargo test --test llm_docs_test.

Not run: the CI workflow snippet on GitHub, live (dry_run=false) gated calls (they would write audit rows into the shared database).

Found while verifying (not fixed here): contractgate test --format json without --quiet prints per-record lines to stdout before the JSON, so the output does not parse. The page tells readers to use --quiet.

…lid negative tests, what DataContractGate is not)
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
contractgate Ready Ready Preview Nov 26, 2026 7:52pm UTC

Request Review

@nightmoose
nightmoose merged commit 32ced08 into staging Nov 26, 2026
25 checks passed

This branch was successfully deployed

1 active deployment
Preview — 5f5a75f3 Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant