Metadata-Version: 2.5
Name: claim-check-ci
Version: 1.1.0
Summary: Every number you publish is a claim. Bind it to the artifact it came from and prove it in CI -- no LLM, no network, no dependencies.
Project-URL: Homepage, https://github.com/tonydzi/claim-check
Project-URL: Repository, https://github.com/tonydzi/claim-check
Project-URL: Issues, https://github.com/tonydzi/claim-check/issues
Project-URL: Changelog, https://github.com/tonydzi/claim-check/blob/main/CHANGELOG.md
Author: Palo Alto AI Research Lab
License: MIT License
        
        Copyright (c) 2026 Palo Alto AI Research Lab
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: benchmarks,ci,claims,documentation,drift,github-actions,reproducibility,verification
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Documentation
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.8
Provides-Extra: yaml
Requires-Dist: pyyaml>=5.1; extra == 'yaml'
Description-Content-Type: text/markdown

# claim-check

Fails your build when a number in your README no longer matches the file it came from.

**Who it's for:** anyone who publishes numbers in docs ("44 tests", "12,000 req/s") and wants them to stay true.
**What you get:** a green or red check in GitHub CI. Red tells you which number is stale, where, and what it should say.

## Quick start
1. Wrap the number in your README: `<!--claim:tests-->44<!--/claim-->`.
2. Create `.github/claims.yml` that says where the true value lives, for example `json: report.json` and `path: results.tests`.
3. Add a workflow step: `- uses: tonydzi/claim-check@v1` with `claims-file: .github/claims.yml`.

**Done when:** the "claims" check in your pull request is green, and turns red if you change the number by hand.

> Want an AI agent to do it for you? Paste this to Claude Code / Codex / Cursor:
> "Read the 'For AI agents' section of https://github.com/tonydzi/claim-check and set it up for me."

## For AI agents

### Preconditions
- Python 3.8 or newer on the machine or CI runner. No other dependency (PyYAML is optional).
- A repo with a doc containing numbers, and a file (JSON, log, or command output) that produces each number.
- Ask the human: which numbers to bind, and which file or JSON path is the source of truth for each.

### Install
Pick one. They run the same `claim_check.py`.
```bash
# CI (GitHub Action), nothing to install: add to a workflow
#   - uses: actions/checkout@v4
#   - uses: tonydzi/claim-check@v1
#     with:
#       claims-file: .github/claims.yml
# Local command
pip install "git+https://github.com/tonydzi/claim-check"
# Optional full YAML support
pip install "claim-check[yaml] @ git+https://github.com/tonydzi/claim-check"
```
The package name has a hyphen. `claimcheck` on PyPI is a different project.

### Configure
1. In the doc, mark each number: `<!--claim:<id>-->VALUE<!--/claim-->` (marker mode), or set `pattern: "pass rate of {value}%"` in the claim (pattern mode).
2. Write `.github/claims.yml`:
```yaml
defaults:
  doc: README.md
  json: benchmarks/latest.json
claims:
  - id: throughput
    path: results.requests_per_second
    format: comma
```
3. Working copy to start from: `examples/claims.yml`. Sources can be `json:`, `text:` or `cmd:`.
4. `cmd:` sources run shell and are off by default. Enable only with `--allow-commands` (CLI) or `allow-commands: true` (Action), and only for configs you trust.

### Verify
```bash
claim-check --version
claim-check --config .github/claims.yml --no-annotations
echo $?
```
Expected: last line like `CLAIM-CHECK: 1 claims - 1 ok - 0 drift - 0 errors -> OK`, exit code `0`. Exit `1` = DRIFT (a number is stale), exit `2` = ERROR (the check could not run). To prove the check can go red, change one bound number by hand and rerun: expect exit `1` and a DRIFT line. Without installing, from a clone: `python claim_check.py --config examples/claims.yml --no-annotations` gives `6 claims - 6 ok` and exit `0`.

### Uninstall / rollback
- Local: `pip uninstall claim-check`.
- CI: delete the `uses: tonydzi/claim-check@v1` step and `.github/claims.yml`. Remove the `<!--claim:...-->` markers from the doc (they are invisible HTML comments, harmless if left).
- `--fix` rewrites docs in place. Run it on a clean git tree and review the diff, or `git checkout` the doc to roll back.

### Rules for the agent
- Never set `allow-commands` or `trust-fork-commands` unless the human asks. A `cmd:` source on a fork pull request hands the runner to a stranger.
- Do not use `fail-on-drift: false` to make a red build green. It is only for a warning-only rollout, and it cannot hide exit `2`.
- Do not edit a number in the doc to match a wrong artifact. Fix the artifact or ask the human.
- Do not commit `--fix` output without showing the human the diff.

## Details

**Every number you publish is a claim. Prove it in CI.**

[![selftest](https://github.com/tonydzi/claim-check/actions/workflows/selftest.yml/badge.svg)](https://github.com/tonydzi/claim-check/actions/workflows/selftest.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/tonydzi/claim-check/blob/main/LICENSE)
[![Python 3.8+](https://img.shields.io/badge/python-3.8%2B-blue.svg)](#requirements)
[![deps: none](https://img.shields.io/badge/dependencies-none-lightgrey.svg)](#requirements)
[![no LLM](https://img.shields.io/badge/LLM-not%20used-lightgrey.svg)](#what-this-is-not)

A README says *"handles 12,000 req/s"*, *"44 tests"*, *"0 known CVEs"*, *"61% autonomous"*.
The benchmark was rerun in March, the suite grew to 96 checks, a CVE landed in May.
Nothing in CI noticed, because nothing in CI knew the number was ever tied to anything — which is the gap [claim_check.py](claim_check.py) closes.

`claim-check` binds each published number to the artifact it came from — a JSON file, a
log, a command's output — and recomputes it on every run. When the doc and the artifact disagree, [claim_check.py](claim_check.py) fails the build and names both sides.

```
| claim            | doc                | status    | doc says | source says |
|------------------|--------------------|-----------|----------|-------------|
| `unique-events`  | examples/REPORT.md | **DRIFT** | 700      | 744         |
| `autonomous-rate`| examples/REPORT.md | **DRIFT** | 61.9     | 61.97       |
| `tier2-total`    | examples/REPORT.md | **PASS**  | 17       | 17          |

what went wrong:
  DRIFT    unique-events    doc says 700, source says 744  (examples/REPORT.md:4)
  DRIFT    autonomous-rate  doc says 61.9, source says 61.97  (examples/REPORT.md:7)

CLAIM-CHECK: 6 claims - 4 ok - 2 drift - 0 errors -> DRIFT
```

[claim_check.py](claim_check.py) uses no LLM, no API key, no network and no dependencies. The verdict is an exit code.

## Install

Two ways to run the same gate, and they share one file: [claim_check.py](claim_check.py).

**In CI, as a GitHub Action** defined by [action.yml](action.yml) — nothing to install:

```yaml
- uses: tonydzi/claim-check@v1
  with:
    claims-file: .github/claims.yml
```

**On your machine, as a command** — for checking a doc before you push it:

```bash
pip install "git+https://github.com/tonydzi/claim-check"
claim-check --config .github/claims.yml
```

<!-- pypi-install-marker -->

> **Note the hyphen.** `claimcheck` (no hyphen) on PyPI is an unrelated project
> about retrieval-based fact-checking of prose. This one is `claim-check`, and it
> only ever asks whether a number still comes out of the artifact you bound it to.

The command and the Action run the same `claim_check.py` and honour the same
[exit-code contract](#exit-code-contract). PyYAML is optional in both, as [pyproject.toml](pyproject.toml) declares
(`pip install "claim-check[yaml] @ git+…"` if your claims file needs full YAML);
without it a small strict parser handles the file and refuses, by line number,
anything it does not understand.

## Quickstart (three files)

**1. `.github/workflows/claims.yml`**

```yaml
name: claims
on: [push, pull_request]

jobs:
  claim-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: tonydzi/claim-check@v1
        with:
          claims-file: .github/claims.yml
```

**2. `.github/claims.yml`** — what each number is bound to

```yaml
defaults:
  doc: README.md
  json: benchmarks/latest.json

claims:
  - id: throughput
    path: results.requests_per_second
    format: comma

  - id: pass-rate
    path: suite.pass_rate
    format: percent:1
    tolerance: 0.1
    pattern: "pass rate of {value}%"
```

**3. `README.md`** — the numbers themselves

```markdown
Handles <!--claim:throughput-->12,000<!--/claim--> req/s
at a pass rate of 99.4%.
```

That is the whole setup, and [examples/claims.yml](examples/claims.yml) is a working copy of it. `throughput` is checked through its marker, `pass-rate` through the sentence it lives in.

## Two ways to bind a number

| | how the doc looks | when to use it |
|---|---|---|
| **marker mode** (default) | `<!--claim:id-->12,000<!--/claim-->` | you control the doc; unambiguous, survives rewording |
| **pattern mode** (`pattern:`) | `pass rate of 99.4%` | you want the doc free of markup; the sentence is the anchor |

Both modes support `--fix`. Both report the exact line number.

One rule worth knowing before you write a pattern, and [claim_check.py](claim_check.py) enforces it: **a claim binds every occurrence of its marker or pattern in the doc.** Three sentences matching `"pass rate of {value}%"`
are three copies of one claim — they must all agree with the source, and `--fix` sets all
three. If two sentences share a skeleton but mean different numbers, make the patterns more specific or give each its own marker, the way [examples/claims.yml](examples/claims.yml) does.

## Sources

Exactly one per claim:

| key | reads | needs |
|---|---|---|
| `json: path.json` | a value out of JSON | `path:` — dotted, with `[i]` indices (`runs[0].passed`) |
| `text: build.log` | a value out of any text | `regex:` with one capture group |
| `cmd: "..."` | a command's stdout | `allow-commands` — see [security](#security-cmd-and-forks) |
| `value: 17` | a constant you pin by hand | — |

`cmd:` also accepts `path:` (parses stdout as JSON) or `regex:`, and is killed after
60 seconds unless the claim raises it with `timeout: 300`.

## Formats and tolerance

The source is the truth; the doc is allowed to be readable, and [claim_check.py](claim_check.py) is what keeps the two in step.

| `format:` | `0.6197` becomes | | |
|---|---|---|---|
| *(none)* | `0.6197` | `comma` | `1,234,567` |
| `round:2` | `0.62` | `percent:1` | `62.0` |
| `{:.3f}` (any Python format spec) | `0.620` | | |

`percent:N` in [claim_check.py](claim_check.py) multiplies by 100, so it expects a fraction. If your artifact already stores `62.0` — as [examples/metrics.json](examples/metrics.json) does — use `round:1` and keep the `%` in the surrounding text.

Formatting differences are forgiven by [claim_check.py](claim_check.py) — `1234` in the artifact matches `1,234` in the doc.
Arithmetic differences are not, unless you allow them explicitly:

```yaml
tolerance: 0.5     # absolute
tolerance: "2%"    # relative
```

## Exit-code contract

```
0  every claim reproduces
1  DRIFT   -- a number no longer matches its source, or vanished from the doc
2  ERROR   -- the check itself could not run: missing config, missing source, bad path
```

The last line of stdout is always a one-line verdict, as [examples/REPORT.md](examples/REPORT.md) shows, so a wrapper can read it without parsing anything.

`fail-on-drift: false` in [action.yml](action.yml) downgrades **1** to **0** when you want a warning-only rollout.
It cannot downgrade **2**: a checker that could not read its source must never look like a clean result, and [claim_check.py](claim_check.py) refuses to. That is the whole point of the tool applied to itself, in [.github/claims.yml](.github/claims.yml).

## Fixing instead of failing

```yaml
      - uses: tonydzi/claim-check@v1
        with:
          fix: 'true'
          fail-on-drift: 'false'
      - uses: peter-evans/create-pull-request@v6   # or commit it yourself
        with:
          commit-message: 'docs: refresh published numbers'
```

`--fix` in [claim_check.py](claim_check.py) rewrites only the claimed values — every occurrence, in place. [selftest.py](selftest.py) asserts the rest of the file comes out byte-identical.

## Security: `cmd:` and forks

`cmd:` runs arbitrary shell, and on `pull_request` [action.yml](action.yml) checks the claims file out **from the fork**. So `cmd:` is refused unless you pass `allow-commands: true` to [action.yml](action.yml), and the refusal says why. Recommended split:

- `pull_request` workflows: leave `allow-commands` off, use `json:` / `text:` sources;
- `push` on your own branches: turn it on if you need it.

Even with `allow-commands: true`, [action.yml](action.yml) **refuses to run commands when the pull request comes from a fork** — that combination is a shell handed to a stranger. Override
it with `trust-fork-commands: true` only if you have read the sentence before this one
twice.

Two more things follow from the claims file being attacker-controlled on a fork PR:

- **every path is confined to the checkout.** `doc: ../../etc/passwd` or any absolute
  path is refused by name in [claim_check.py](claim_check.py), so `--fix` cannot write outside the workspace;
- **a command cannot idle the runner.** `cmd:` is killed after 60 seconds (`timeout:`
  per claim) and a killed command is an ERROR, not a pass.

Nothing else in this action touches the network, and it never needs a token.

## Unbacked numbers (experimental)

`strict-unbacked: true` also flags numbers that are bound to *nothing* — the house rule
that a figure without a source is a guess. It ignores versions, years, times, issue
references and fenced code, and it only warns; it never fails the build. It is noisy on
purpose. Tune it with:

```yaml
unbacked_ignore:
  - "\\b\\d+ms\\b"
```

## Running it locally

```bash
git clone https://github.com/tonydzi/claim-check
cd claim-check
python3 selftest.py                                  # 108 checks, every one broken by a mutant first
python3 claim_check.py --config examples/claims.yml  # the worked example
```

The selftest count above is itself a claim: `selftest.py` writes
`selftest-report.json`, [`.github/claims.yml`](https://github.com/tonydzi/claim-check/blob/main/.github/claims.yml) binds this README to
it, and CI runs the gate on its own repository. If someone adds a check and forgets this
line, the build goes red.

## What this is not

- **Not an LLM documentation reviewer.** Tools that ask a model *"does this prose still
  describe the code?"* answer a broader question, cost tokens, and answer differently on
  Tuesday. `claim-check` answers one narrow question deterministically: *does this exact
  number still come out of that exact artifact?* The two sit well together.
- **Not a metrics collector.** It does not run your benchmark. It checks that what you
  published matches what your benchmark last wrote down.
- **Not a linter.** It has no opinion about your prose.

## Where it came from

The lab publishes measurements about its own agent fleet, and it runs on one rule:
*a number is a claim, and a claim without a reproducible source is a guess.* The first
version of this was a frozen ledger snapshot with a `verify_claims.py` shipped next to
the report — ten headline numbers that either reproduced or printed `DRIFT`. Every number
in the writeup had to survive it before publication.

This action is that pattern generalized, so it can sit in anyone's CI.

Related gates from the same practice:

- [verified-ops-starter](https://github.com/tonydzi/verified-ops-starter) —
  your scheduled job says `exit 0`; prove it did the work.
- [verbatim-citation-gate](https://github.com/tonydzi/verbatim-citation-gate) —
  catch fabricated RAG citations before they reach the user.

## Roadmap

**Now — [v1.0.1](https://github.com/tonydzi/claim-check/releases).** The action
itself: bind a number in prose to the artifact that produced it, `cmd:` and file sources, tolerance
and format handling, an exit-code contract, fix-instead-of-fail, and the experimental unbacked-number
pass.

**Next**, in the order we would take them:

- **The Marketplace listing.** The action works and is public; it is *not* listed, because listing
  needs a legal agreement and 2FA that only the account owner can complete. "Not listed" and "not
  working" are different things, and this is the first.
- **More source kinds.** Today a claim binds to a file or a command. JSON pointers into a results
  file are the most-asked next one.
- **A quieter first run.** The unbacked-number pass is experimental precisely because on a real
  README it finds more than you want on day one.

Versioning is semver and **every noticeable change ships as a new release** — for an action that
gates other people's CI, the release feed is the only honest way to see what changed under you
before you bump the tag you depend on.

## Requirements

Python 3.8+ on the runner. Nothing else. PyYAML is used if it happens to be installed;
otherwise a small strict parser handles the claims file and refuses, by line number,
anything it does not understand.

## When it breaks

| symptom | cause | fix |
|---|---|---|
| `ERROR ... source file not found` | the artifact is generated, not committed | generate it in a step **before** this one, or commit a snapshot |
| `MISSING ... no marker in README.md` | the marker was reworded or deleted | restore `<!--claim:id-->…<!--/claim-->`, or switch that claim to `pattern:` |
| `ERROR ... path 'a.b': no key 'b'` | the artifact's schema changed | update `path:` — the number moved, the claim did not |
| `ERROR ... cmd: is disabled` | `cmd:` source without opt-in | set `allow-commands: true`, having read [security](#security-cmd-and-forks) |
| `ERROR ... duplicate claim id` | two claims aim at one place in one doc | give them separate ids, or one claim and one marker |
| `ERROR ... path escapes the repository` | a `doc:` / `json:` / `text:` path leaves the checkout | keep every path relative and inside the repo |
| `ERROR ... cmd exceeded 60s` | the command hangs (waiting on a prompt, a lock, the network) | fix the command, or raise `timeout:` on that claim |
| passes locally, fails in CI | local artifact is newer than the committed one | regenerate the artifact in the workflow before the gate |

## License

MIT — see [LICENSE](https://github.com/tonydzi/claim-check/blob/main/LICENSE).

---

<!--ecosystem-map:start-->

## 🧩 One piece of a working system

This repository is one piece lifted out of a live operation: one engineer running a fleet of
machines, built with Claude as implementation collaborator; the machines reach consensus with
each other and wake the human only for money or the irreversible. It was extracted after it
survived production, not written as a demo — and it runs on its own: nothing here phones home
to the rest.

**See how the whole thing fits together → [SYSTEM.md](https://github.com/tonydzi/tonydzi/blob/main/SYSTEM.md)**

Its closest neighbours in the **gates** layer: [`verified-ops-starter`](https://github.com/tonydzi/verified-ops-starter) · [`oss-publish`](https://github.com/tonydzi/oss-publish) · [`agent-runtime-integrity-bench`](https://github.com/tonydzi/agent-runtime-integrity-bench)

<!--ecosystem-map:end-->

## AI contributors

This project is built by a human + AI team, and the git log says so under the rules in [AI-CONTRIBUTORS.md](https://github.com/tonydzi/.github/blob/main/AI-CONTRIBUTORS.md): Claude writes most of the code, Codex and Grok review it, Gemini feeds the research. Each is credited on a commit
**only if its output changed that commit's content** — no decorative credits. Lab-wide
policy, one source for every repo: [AI-CONTRIBUTORS.md](https://github.com/tonydzi/.github/blob/main/AI-CONTRIBUTORS.md).

<!-- READ-WITH-AI:START (generated by read_with_ai.py - do not hand-edit) -->

### READ THIS WITH AI

One click and an agent reads the repo, pulls out the patterns and helps you apply them to your own work.

<a href="https://chatgpt.com/codex?prompt=Read%20this%20repo%3A%20https%3A%2F%2Fgithub.com%2Ftonydzi%2Fclaim-check%20%28%E2%80%9Cclaim-check%E2%80%9D%20-%20Every%20number%20you%20publish%20is%20a%20claim.%20Prove%20it%20in%20CI%3A%20bind%20each%20figure%20in%20your%20README%20to%20the%20artifact%20it%20came%20from%20and%20fail%20the%20build%20when%20they%20drift.%20No%20LLM%2C%20no%20API%20key%2C%20no%20dependencies%29.%20Work%20out%20what%20problem%20it%20actually%20solves%2C%20pull%20out%20the%20reusable%20patterns%20and%20help%20me%20apply%20them%20to%20my%20own%20setup.%20Start%20by%20asking%20what%20I%20am%20working%20on."><img alt="Codex - open" src="https://img.shields.io/badge/Codex-open-000000?style=for-the-badge&logo=openai&logoColor=white"></a> <a href="https://chatgpt.com/?q=Read%20this%20repo%3A%20https%3A%2F%2Fgithub.com%2Ftonydzi%2Fclaim-check%20%28%E2%80%9Cclaim-check%E2%80%9D%20-%20Every%20number%20you%20publish%20is%20a%20claim.%20Prove%20it%20in%20CI%3A%20bind%20each%20figure%20in%20your%20README%20to%20the%20artifact%20it%20came%20from%20and%20fail%20the%20build%20when%20they%20drift.%20No%20LLM%2C%20no%20API%20key%2C%20no%20dependencies%29.%20Work%20out%20what%20problem%20it%20actually%20solves%2C%20pull%20out%20the%20reusable%20patterns%20and%20help%20me%20apply%20them%20to%20my%20own%20setup.%20Start%20by%20asking%20what%20I%20am%20working%20on."><img alt="ChatGPT - open" src="https://img.shields.io/badge/ChatGPT-open-10a37f?style=for-the-badge&logo=openai&logoColor=white"></a> <a href="https://claude.ai/new?q=Read%20this%20repo%3A%20https%3A%2F%2Fgithub.com%2Ftonydzi%2Fclaim-check%20%28%E2%80%9Cclaim-check%E2%80%9D%20-%20Every%20number%20you%20publish%20is%20a%20claim.%20Prove%20it%20in%20CI%3A%20bind%20each%20figure%20in%20your%20README%20to%20the%20artifact%20it%20came%20from%20and%20fail%20the%20build%20when%20they%20drift.%20No%20LLM%2C%20no%20API%20key%2C%20no%20dependencies%29.%20Work%20out%20what%20problem%20it%20actually%20solves%2C%20pull%20out%20the%20reusable%20patterns%20and%20help%20me%20apply%20them%20to%20my%20own%20setup.%20Start%20by%20asking%20what%20I%20am%20working%20on."><img alt="Claude - open" src="https://img.shields.io/badge/Claude-open-d97757?style=for-the-badge&logo=anthropic&logoColor=white"></a>

<details>
<summary>Copy the prompt (works in any agent: Gemini, Grok, a local model, your own CLI)</summary>

```text
Read this repo: https://github.com/tonydzi/claim-check (“claim-check” - Every number you publish is a claim. Prove it in CI: bind each figure in your README to the artifact it came from and fail the build when they drift. No LLM, no API key, no dependencies). Work out what problem it actually solves, pull out the reusable patterns and help me apply them to my own setup. Start by asking what I am working on.
```

</details>

<sub>— TonyDzi, Palo Alto AI Research Lab · second brain, agent coordination, persistent memory: github.com/tonydzi</sub>

<!-- READ-WITH-AI:END -->
