ProofGate
# ProofGate
**Stop shipping AI changes you cannot re-prove.** ProofGate is the open-source release gate for agent and eval pipelines: four deterministic, fail-closed checks and a SHA-256 receipt you can verify later. The core is Python 3.10+ stdlib, AGPL-3.0, and local. Closed eval platforms that charge about $30K/yr sell the same job as a seat. ProofGate keeps the decision, the artifacts, and the hash on your machine and in your CI log.
Built by [SanFire (OPC) Private Limited](https://sanfire.in/proof.html). **Interactive simulator & Cloud/Managed tiers:** [sanfire.in/proofgate](https://sanfire.in/proofgate). Source: [github.com/realmpastai-web/proofgate](https://github.com/realmpastai-web/proofgate).
## 60-second quickstart
```bash
git clone https://github.com/realmpastai-web/proofgate.git
cd proofgate
python3 -m proofgate init --template ai-eval # or: default, healthcare-hipaa, ci-security
python3 -m proofgate check --config examples/proofgate.json --receipt receipt.json --markdown
python3 -m proofgate badge receipt.json --out proofgate-badge.svg
```
Exit code `0` means every gate passed and `receipt.json` matches what just ran. Any other exit code blocks the release. `proofgate badge` re-verifies the receipt and sealed bytes before emitting a deterministic flat SVG (`CERTIFIED <sha8>` green or `BLOCKED`/`TAMPERED` red). Re-check a stored receipt directly:
```bash
python3 -m proofgate verify receipt.json
```
List starter templates with `python3 -m proofgate init --list-templates` (`default`, `ai-eval`, `healthcare-hipaa`, `ci-security`), or write a starter config from an MCP client (`proofgate_init`). No API keys. No network calls inside the gate.
## Four fail-closed gates + SHA-256 code sealing
A release is certified (`status: "CERTIFIED"`, exit `0`) **only** when every configured gate passes. An unknown gate type, missing artifact, secret leak, unauthorized file edit, metric below threshold, or 1-byte post-check file edit fails closed (`status: "BLOCKED"`, exit `1`). There is no soft-pass mode.
| Gate type | What it enforces deterministically | On failure |
| --- | --- | --- |
| `command` | Runs your test/eval/lint script with timeout, checks exact exit code, optional `stdout_contains`, and numeric `json_metric` thresholds (`min_value` / `max_value`). | Exits non-zero (`BLOCKED`). |
| `json_artifact` | Verifies agent output JSON files exist, parse cleanly, contain all `required_keys`, satisfy `numeric_bounds`, and pass `non_empty_keys`. | Exits non-zero (`BLOCKED`). |
| `leak_guard` | Scans code/diffs/outputs for secret keys (OpenAI, Anthropic, xAI, GitHub, AWS, Google, PEM keys) plus custom `forbidden_patterns` regexes, redacting matched secrets. | Exits non-zero (`BLOCKED`). |
| `diff_scope` | Checks changed files against `max_files` and `forbidden_paths` so coding agents cannot touch protected folders. | Exits non-zero (`BLOCKED`). |
Every run hashes all `seal_paths` into `sealed_files` and binds the entire canonical JSON payload into `receipt_sha256`.
### Receipt example
```json
{
"schema_version": "1.0",
"status": "CERTIFIED",
"passed": true,
"timestamp_utc": "2026-12-02T13:20:00Z",
"config_path": "examples/proofgate.json",
"git_commit": "a1b2c3d4",
"gates": [
{"id": "leak-guard", "type": "leak_guard", "passed": true, "duration_ms": 4, "summary": "0 leaks across 6 files"},
{"id": "py-compile", "type": "command", "passed": true, "duration_ms": 38, "summary": "exit 0"}
],
"sealed_files": {
"proofgate/gates.py": "9b1c0e5a0d2f4c6e..."
},
"receipt_sha256": "c4e8f1a02b67d9e0aa11bb22cc33dd44ee55ff66778899aabbccddeeff001122"
}
```
Modify **one byte** of any sealed file or `proofgate-receipt.json` and `python3 -m proofgate verify proofgate-receipt.json` fails immediately (`code_untweaked: false`, exit `1`). Markdown from `--markdown` is what the GitHub Action appends to `$GITHUB_STEP_SUMMARY`.
## MCP
`python3 -m proofgate.mcp_server` speaks MCP over stdio (JSON-RPC 2.0, protocol `2024-11-05`).
Tools:
| Tool | Required arguments | Calls |
| --- | --- | --- |
| `proofgate_check` | `config_path` (optional `receipt_path`) | `proofgate.gates.run_check` |
| `proofgate_verify_receipt` | `receipt_path` (optional `base_dir`) | `proofgate.receipt.verify_receipt` |
| `proofgate_init` | `target_dir` (optional `filename`, default `proofgate.json`) | `proofgate.config.create_default_config` |
Invalid arguments, unknown tools, exceptions, and explicit gate failures return MCP `isError: true` with a JSON text body. The process stays up. The tool result does not look like success.
Use this server block in Antigravity, Claude Code, Grok Build, or Cursor:
```json
{
"mcpServers": {
"proofgate": {
"command": "python3",
"args": ["-m", "proofgate.mcp_server"],
"cwd": "/absolute/path/to/your/repo"
}
}
}
```
Install the package (`pip install -e .` from this repo) so `python3 -m proofgate.mcp_server` resolves. Set `cwd` to the project whose `proofgate.json` the agent should check.
## GitHub Action (+ SARIF v2.1.0 Code Scanning)
```yaml
name: Release gate
on:
pull_request:
jobs:
proofgate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: realmpastai-web/proofgate@v0.2.0
with:
config: proofgate.json
receipt: proofgate-receipt.json
sarif: proofgate.sarif # optional: upload via github/codeql-action/upload-sarif@v3
```
The composite action installs Python 3.12, installs this package, runs:
```bash
python -m proofgate check --config proofgate.json --receipt proofgate-receipt.json --sarif proofgate.sarif --markdown
```
and appends that Markdown to `$GITHUB_STEP_SUMMARY`. Passing `--sarif` exports a valid **SARIF v2.1.0** report (pinning exact redacted file + line locations for `leak_guard` and modified paths for `diff_scope`) ready for GitHub Code Scanning. A failed gate fails the job.
This repository's own CI (`.github/workflows/ci.yml`) runs `unittest` and dogfoods `python3 -m proofgate check --config examples/proofgate.json`.
## License and tiers
The engine in this repository outside `/ee` is [AGPL-3.0-or-later](LICENSE). Files under `/ee` use the commercial terms in `ee/LICENSE-EE.md`.
| Tier | Price | License | You get |
| --- | --- | --- | --- |
| Open source | $0 | AGPL-3.0 | Local gates, SHA-256 receipts, stdio MCP, GitHub Action, self-hosted CI |
| Cloud Pro | $39/mo | `/ee` commercial | Hosted PR dashboard, diff timeline, score charts, GitHub status checks |
| Team | $249/mo | `/ee` commercial | SSO/SAML, RBAC, 7-year receipt archive, multi-reviewer sign-off |
| Managed QA | $2,500+/mo | `/ee` commercial | Dedicated deployment, SLA, and SanFire's Cleaner + Confirmer QA desk for custom golden suites |
Interactive simulator, Cloud Early Access, and Managed Eval Sprint intake: [sanfire.in/proofgate](https://sanfire.in/proofgate) · `reachus@sanfire.in`.
## Development
```bash
PYTHONDONTWRITEBYTECODE=1 python3 -m py_compile proofgate/*.py
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s tests -v
PYTHONDONTWRITEBYTECODE=1 python3 -m proofgate check --config examples/proofgate.json --receipt /tmp/proofgate-receipt.json --markdown
PYTHONDONTWRITEBYTECODE=1 python3 -m proofgate verify /tmp/proofgate-receipt.json
```
Requires Python 3.10+. Runtime dependencies: none beyond the standard library.
TDQS
Scored across 3 tools
Each tool targets a distinct phase of the lifecycle: init creates config, check runs the gates, verify_receipt validates a receipt. There is no plausible way to confuse one for another, and fail-closed semantics are stated per tool.
All three share a consistent 'proofgate_' prefix and use verb or verb_noun forms (check, init, verify_receipt). Minor deviation: 'check' and 'init' lack an object noun while 'verify_receipt' has one, but the pattern is still predictable.
Three tools is narrow but each maps to a real, non-overlapping operation (init, run, verify) for a focused release-gate domain. It sits at the thin end of the ideal range, though nothing feels redundant.
The core lifecycle—create config, run gates, verify receipt—is fully covered with no dead ends. Minor gaps exist around inspecting existing configs or receipts (no list/read/update, only init defaults), which agents can work around via the returned check and receipt dicts.