Skip to main content

Ratchet

Ratchet turns observed agent failures into tested, signed guard changes.

When an agent fails, Ratchet writes a guard: a small rule that checks each tool call before it runs. It adopts the guard only after a replay (rerunning recorded past conversations through it) and fresh tests on held-out cases (test cases the improver never sees). Each decision is a receipt, a signed record anyone can verify offline.

It is for teams running tool-using agents that touch money, accounts or tickets, and need a fix to a failing agent to be proven before it ships.

Install

git clone --branch probity-ratchet-v0.2.0 https://github.com/probityai/probity && cd probity/packages/ratchet
uv sync

Python 3.12 or later. The guard sandbox needs Linux.

pip install probity-ratchet-cases==0.2.0 && ratchet-cases selftest   # the case suite alone: probity-ratchet-cases/README.md

Try it in 30 seconds

No database, no model key. This guard stops force pushes to main. It is a single standard-library file, exported from an admitted guard, and it is a Claude Code hook (a script run before each tool call). It denies the call:

echo '{"hook_event_name": "PreToolUse", "tool_name": "Bash", "cwd": ".", "tool_input": {"command": "git push --force origin main"}}' \
  | python3 examples/claude-code/hooks/ratchet_no_force_push_main.py; echo "exit $?"
blocked by guard no-force-push-main: force push to main rewrites shared history; push a branch and open a pull request instead
{"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "deny", "permissionDecisionReason": "blocked by guard no-force-push-main: force push to main rewrites shared history; push a branch and open a pull request instead"}}exit 2

Before export, the guard was replayed over six recorded Claude Code sessions: it fired on the three calls it was written for and on none of the other twelve (examples/claude-code/replay.json). The hook's header names the receipt (the signed decision) that admitted it; uv run python -m ratchet.export.claude_code --verify examples/claude-code/hooks/ratchet_no_force_push_main.py checks that receipt.

A signed refusal you can check offline is in examples/refusal-v3-cell/: uv run python examples/refusal-v3-cell/verify.py regrades 80 executions and prints decision verified, candidate refused, reason: identity controls breached. "Decision verified" is not "candidate accepted": it says the signed record is genuine, and here the record is a refusal. It is single-cell evidence from one run by the operator.

What it does

A support agent works in a simulated company: a billing provider, tickets, approvals and mail. Its eight case families are seven kinds of trap, each with benign twins (matching cases where the action is allowed, so a rule that blocks them fails), plus ordinary requests that must succeed. Every case is graded on the final state of every system, never on the agent's words.

When the agent fails, the improver proposes a guard or a procedure (written steps for the agent). A change is adopted only if four checks pass: replay; fresh paired tests on held-out cases against the parent harness (the code around the model: prompt, tools and rules); no growth of the agent's authority; and a signed receipt, which verifies offline against a pinned public key. The gates are in docs/ADMISSION.md. Every version, trace, evaluation and decision, rejections included, lives in MongoDB Atlas.

Status

Version 0.2.0, built on 2026-10-11 at the MongoDB harness hackathon. The suite, graders and rule are frozen before each run. Measured results, with denominators, are in docs/RESULTS.md.

Docs

Page What is in it
Running Local Atlas, environment and every command
Admission rule The gates in plain words
k-session rule The replicated rule, runner and offline check
Architecture Packages, guard sandbox, storage
Verifying a decision Check a receipt offline
Results Every measured result and its records
Claude Code hook Prove a guard on your own sessions, then install it
Built today and reused What was written at the event and what is pinned
Signed refusal example Check a refused candidate offline
Build contract Types, lane interfaces and the full admission rule

Metadata

Release files for probity-ratchet 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for probity-ratchet 0.3.3
File Size Uploaded Provenance Actions
probity_ratchet-0.3.3.tar.gz 1.8 MB With provenance Details for probity_ratchet-0.3.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for probity-ratchet 0.3.3
File Interpreter ABI Platform Actions
probity_ratchet-0.3.3-py3-none-any.whl Python 3 none any Details for probity_ratchet-0.3.3-py3-none-any.whl

Total release size: 2.3 MB

Release files / probity_ratchet-0.3.3.tar.gz

Download URL probity_ratchet-0.3.3.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
3d9323b8d68c28e36015936151e71562e3fe1db36e88c0d9b4a9433f909d0fb2
BLAKE2b-256 checksum
How to use checksums
789185c3ad89a8f936f2f563697816fa6ca0507f337dad98f0eb996846722eed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / probity_ratchet-0.3.3-py3-none-any.whl

Download URL probity_ratchet-0.3.3-py3-none-any.whl
Size 485.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27dabb1bb2c17b182865f46b294a8e3c4a1904be5226fc43b82e40abaf3339cd
BLAKE2b-256 checksum
How to use checksums
c640f936f3555fe4721ec26fef2a10402dabaec65b2cb04c008f7ca8f6e714f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for probity-ratchet 0.3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for probity_ratchet-0.3.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page