
okproof
io.github.okproof/okproof
Proves agent-written pull requests against their acceptance criteria with passing tests.
Documentation
An auditor that tries to disprove "done".
Every acceptance criterion is proven by a passing test, or reported as unproven.
Docs ·
Quick start ·
Why ·
Discussions ·
Contribute ·
Security
okproof
Your agent says it's done. okproof proves it, criterion by criterion.
Browser agents act. Test frameworks run. CI reports. okproof proves. Why okproof · Project · Contributing · Security
okproof checks a pull request against the acceptance criteria in its issue and fails the merge check until each one is backed by a passing test. It is for teams that let coding agents (or people) open pull requests and want evidence, not a claim, that the work does what the issue asked.
Docs: okproof.github.io/okproof
What we are building toward
An agent saying "done" should never be enough to merge. The aim is an auditor that tries to disprove done: every criterion in the issue either has evidence behind it or is reported as unproven, with no model's opinion in the verdict.
- Today: proof files, a ledger and a merge gate; Playwright, JUnit and CTRF ingest; weak-test detection; differential proof and a revert check; an MCP server so agents can check their own work; signed ledgers from the Action.
- Next: more runner coverage and more zero-token attacks in the verifier.
- Later, not built yet: a hosted proof page with history, "Harden" (commit passing verifier runs as tests), and Firefox and WebKit in the driver.
The full, ordered list is in the roadmap. Reviewers and contributors are wanted: see CONTRIBUTING and reviewers wanted.
"Proves" is the promise; here is exactly what is checked. okproof compares a
pull request with the acceptance criteria in its issue. The criteria go in a
proof file in the repo. Tests claim criteria by tag. The run ends with a ledger
that marks each criterion met, failed, unproven or untested. A
criterion is met only when a test tagged to it passed and, as far as okproof can
tell, made a real assertion. That judgement rests on the assertion counts your
runner reports and on okproof's own static lint of the test source, which is a
heuristic (see Weak and unrelated tests): it
catches the common empty and trivial assertions, not every way to fool a test.
Untested, flaky and assertion-less tests never count. If you run the optional
verifier, a bug it finds counts only when it reproduces on a model-free replay.
okproof does not judge whether a test is a good test, and committed ledgers are
not signed. The Action can sign the ledgers it builds in CI (attest: true, see
Signed ledgers); that proves which workflow wrote them, not that the tests are good.
okproof doesn't run your tests. It works with Playwright Test directly, and with any runner that writes JUnit XML: Jest, Vitest, pytest, JUnit, Cypress, Go and more. It has no runtime dependencies.
Quick start (30 seconds)
npx okproof init --agents --workflow --runner playwright
That one command, in your repo:
- creates
.okproof/with an example proof file (use--issue 142 --title "Pro upgrade"for a real one); - writes
.github/workflows/okproof.yml: it runs your tests with a JUnit reporter, thenokproof/okproofingests the results and gates the merge (--runneris one ofplaywright,junit,ctrf,vitest,jest,pytest). In a published release the Action is pinned to the release's full commit SHA with the version in a comment; a build that does not know its commit writes@v0plus a comment telling you to pin (see Pin the Action by commit SHA); - teaches coding agents the loop: it adds an okproof section to
AGENTS.mdandCLAUDE.md, copies the skill to.claude/skills/okproof/SKILL.md, and adds the okproof server to.mcp.jsonwithout touching your other servers. Everythinginitwrites that runs okproof names the exact version (npx -y okproof@<version> mcp,npx okproof@<version> gate), so an agent session never runs whatever the registry serves that day. - with
--hooks(not part of the one command above) it also writes Claude Code hooks that block an agent from finishing while the gate fails and from editing.okproof/(docs/agent-hooks.md).
Then edit the proof file, tag your tests with [okproof:<id>], and push. The
pull request gets one okproof comment, and the check fails until every criterion
is met. init never overwrites a file; it prints what it skipped. Run it again
and nothing changes.
How okproof thinks
okproof is an auditor that tries to disprove "done", not to confirm it. "Done" stands only if the audit fails to knock it down. The principles (more in WHY.md):
- The criterion is the unit, not the test. Verdicts are per acceptance criterion.
- Silence counts against you. Untested, flaky, assertion-less or untagged tests are not met.
- The auditor is never the author. An independent verifier attacks; only model-free replay-confirmed bugs count.
- Graded evidence, not pass/fail. Evidence levels: E0 claimed, E1 tagged test passed, E2 real relevant assertion, E3 survived adversarial attack, E4 verified in CI from the base branch (all shipped; see Evidence levels). An optional Sigstore attestation of the ledgers is separate: see Signed ledgers.
- Neutral across vendors. It audits runs from any agent or runner through open JUnit and CTRF formats.
Works with
Write JUnit XML (or CTRF JSON), then npx okproof ingest <file>.
| Runner | Reporter flag | Then |
|---|---|---|
| Playwright | npx playwright test --reporter=junit (set PLAYWRIGHT_JUNIT_OUTPUT_NAME=junit.xml). Playwright's JUnit file shows a test that passed on retry as a plain pass, so use the okproof reporter or CTRF if you need flaky to be detected. | npx okproof ingest junit.xml |
| Vitest | npx vitest run --reporter=junit --outputFile=junit.xml | npx okproof ingest junit.xml |
| Jest | npx jest --reporters=default --reporters=jest-junit (needs jest-junit) | npx okproof ingest junit.xml |
| pytest | python -m pytest --junitxml=junit.xml | npx okproof ingest junit.xml |
| Cypress | npx cypress run --reporter junit --reporter-options mochaFile=results/junit-[hash].xml (one file per spec) | npx okproof ingest --results 'results/*.xml' |
| Go | gotestsum --junitfile junit.xml ./... (needs gotestsum) | npx okproof ingest junit.xml |
| Anything with CTRF | a CTRF reporter writing ctrf-report.json | npx okproof ingest ctrf-report.json |
How okproof knows a test made an assertion differs by input: see What counts as an assertion, runner by runner.
Several results files, several proof folders
Sharded Playwright runs, Cypress (one file per spec), Jest projects and monorepos write more than one results file.
--results takes repeated values and globs (quote the glob so your shell does not expand it):
npx okproof ingest --results 'results/*.xml' --results extra/ctrf.json
npx okproof gate --results 'results/*.xml' --require-issues 142
- The original form
okproof ingest <file> [dir]still works, and its file may be a glob. A glob that matches nothing is an error. - Outcomes are merged. The same test (file, classname, suite and name) reported by two different files counts once, and the worse status and the lower assertion count win, so a failure in one shard is never hidden by a pass in another. Identical outcomes inside one file are kept.
- Each ledger records
results: [{path, sha256}]andrun: {id, sha, timestamp}(fromGITHUB_RUN_ID,GITHUB_SHA).results_sha256is the hash of the one file, or of the sortedpath:sha256lines. - Monorepo:
--diris repeatable (okproof ingest --results 'r/*.xml' --dir packages/a/.okproof --dir packages/b/.okproof). Each folder is gated on its own ledgers, an issue may have a proof file in only one folder, and the PR comment has one section per folder. The Action takes the same list in theproof-dirsinput (one folder per line). - Test names that claim a criterion no proof file lists are reported as warnings by
ingestandgate.
Flaky tests
A criterion whose claiming tests pass only after a retry has its own verdict, flaky. It is not met (the gate fails), and it is shown apart from failed so a flaky test is not mistaken for a real regression. A failed test still wins over a flaky one.
To keep a known flaky test from blocking merges while it is fixed, list it in <proof folder>/quarantine.json:
[{ "test": "checkout totals [okproof:142.2]", "owner": "payments-team", "expires": "2026-12-31" }]
testis the exact title the runner reports.ownerandexpires(an ISO date or datetime) are both required.- Quarantine applies only with
--allow-quarantined(Action inputallow-quarantined), on bothingestandgate --results, so the comment and the gate always agree. - Only flaky tests can be quarantined. A quarantined test is set aside: it never counts as evidence, so a criterion still needs another clean, asserting passing test. It stays listed in the ledger and the comment with its owner and expiry.
- Entries that are past their date, or whose date does not parse, are ignored and reported.
- Protect this file with CODEOWNERS, like the proof files. It decides what the gate may ignore; if a pull request can edit it, the pull request can quarantine its own flaky failures.
A skipped test is still "not met". If a test is legitimately skipped on one platform, tag a different test for that criterion rather than expecting the skip to count.
Runner and language guides
A test claims a criterion by carrying [okproof:<id>] in the title the runner reports. Runners report the leaf test title, so tag the test, not its describe block (okproof lint warns about a tag that is only on a describe or suite). If your runner reports suite or class names and you want a tag there, pass --tag-scope suite: tags in the JUnit classname, the testsuite name or the CTRF suite then also claim the tests inside. It is off by default.
| Stack | How to tag and export |
|---|---|
| pytest | The tag must be in the test id. Use @pytest.mark.parametrize("x", [...], ids=["case a [okproof:1.1]", ...]), or a function name with the tag in a pytest.param(..., id="... [okproof:1.1]"). A tag only in a docstring or comment is not in the JUnit name. Set junit_family=xunit1 (in pytest.ini) so classname and file are written. |
| Go | gotestsum --junitfile junit.xml ./... and t.Run("works [okproof:1.1]", ...); subtests report as Test/works_[okproof:1.1] and still carry the tag. |
| JUnit 5 (Java, Kotlin) | @DisplayName("signs in [okproof:1.1]") (the Surefire report shows the display name; enable reportNameFormat or use the Gradle JUnit XML). Kotlin may name the method in backticks. |
| .NET | dotnet test --logger "junit;LogFilePath=junit.xml" (the JUnit logger package) or convert a .trx file with a JUnit converter first. [Fact(DisplayName = "signs in [okproof:1.1]")]. |
| RSpec | rspec --format RspecJunitFormatter --out junit.xml (the rspec_junit_formatter gem); put the tag in the it "..." string. |
| Cypress | --reporter junit --reporter-options mochaFile=results/junit-[hash].xml, then --results 'results/*.xml'. A single mochaFile=junit.xml is overwritten by each spec. |
| Playwright | Shards write one file each; ingest them with a glob. The okproof reporter counts expect steps. |
okproof lint scans JavaScript, TypeScript, Python, Go, Java, Kotlin and C# test files (*.test.*, *.spec.*, *.e2e.*, Cypress *.cy.*, files under __tests__/, and the Python, Go, Java, Kotlin and C# conventions). It does not read Ruby, PHP or Rust tests: their criteria are judged on the runner's results alone. For Java, Kotlin and C# the tag normally sits in an annotation or attribute; lint judges the next method body. A method with no block body (an abstract method, a Kotlin or C# expression body) is not judged. Assertion words it recognises: assertEquals, assertThat, Assert., Assertions., .Should() and the other assertion words listed above.
Limits worth knowing
- The Playwright reporter counts
expectsteps only. Assertions made withnode:assertor chai inside a Playwright test are not steps, so such a test reports 0 assertions (it can be unproven with strict assertions). Passes cannot be counted from them; useexpect, or let lint find the assertion. - Relevance matching (lint,
suggest) stems English words only. Criteria and test names in other languages get weaker relevance signals. okproof suggestis advisory. It never edits a test.
Command output as JSON
okproof check, gate, lint, explain and suggest accept --json: stdout is exactly one JSON document and everything else goes to stderr. Every document has schemaVersion (currently 1) and command. Fields are documented in docs/json-output.md; new fields may be added, existing ones keep their meaning within a schema version.
okproof explain 142.3 [--results 'results/*.xml'] shows the tests that claim a criterion, what each one did and why the criterion is in its state (also the read-only okproof_explain MCP tool). okproof suggest ranks existing untagged tests for each untested criterion (also the okproof_suggest MCP tool).
Check run
With --checks (Action input checks, default true) okproof gate publishes one check run named okproof on the pull request head commit: a summary table and annotations on the test file and line (or the proof file line) of every criterion that is not met, plus dangling tags. It is built from the same problem list that decides the exit code. It needs checks: write; when the token cannot write checks (a fork's read-only token, a missing permission) okproof falls back to the job summary with a one-line note and never fails the run. The pull request comment stays controlled by comment. Evidence cells in the comment and summary link to the CI run.
Install
npm i -D okproof
npx okproof check
okproof has no runtime dependencies. The core (proof files, ledger, gate,
ingest, MCP server, Playwright reporter) runs on Node 20 or later. The browser
driver and the verifier use Node's built-in WebSocket and need Node 22 or later;
on Node 20 they stop with a message that says so (engines can only say >=20).
The repository's CI runs the browser and verifier tests on Node 22 only.
See it in action
An agent says "All 5 acceptance criteria are implemented and tested. Done." okproof checks the claim against the criteria in the issue:
Agent says: Done (5/5)
okproof: 3 met · 1 failed · 1 untested — NOT PROVEN
Three criteria pass in a real browser. One fails, and a verifier refutation is confirmed by replaying it with no model. One has no test at all. The gate exits
| Before reload | After reload |
|---|---|
![]() | ![]() |
1. Write a proof file
.okproof/142.md:
## #142 Pro upgrade
- [ ] A member can upgrade the workspace to Pro from Billing
- [ ] Invoice preview shows a prorated amount before confirming
- [ ] A viewer (non-admin) cannot see the upgrade button
Run npx okproof check to print the tag for each criterion.
One proof file covers one issue. After the ## #142 heading, another ## heading is allowed only as a plain notes
section: its text is ignored. If checkboxes (- [ ] / - [x]) follow it, okproof check fails and names the line, because
they would silently become criteria of the first issue. Write ## #<id> Title in its own file for another issue, drop the
brackets to make plain list items, or move them under the first heading. ### headings and code fences are not affected.
2. Claim criteria in test names
test('member upgrades to Pro [okproof:142.1] [okproof:142.2]', async ({ page }) => {
// ...
});
Use stable ids for anything that will live longer than one pull request. Ids are
positional by default (142.3 is the third line), so deleting or inserting a line above a
criterion re-points every tag below it at a different requirement, and the tests keep
passing. Give each criterion a stable id with a {#id} prefix, for example
- [ ] {#sign-in} A user can sign in, and tag tests [okproof:142.sign-in]. A stable id
does not move when lines are added, removed or reordered. See docs/stable-ids.md.
3. Build the ledger
Playwright Test: add the reporter.
// playwright.config.ts
export default defineConfig({
reporter: [['list'], ['okproof/playwright']],
});
A test that passes only after a retry counts as flaky, which is not proven. When Playwright records a trace, the ledger links it as evidence.
Any other runner: write JUnit XML, then ingest it.
npx vitest run --reporter=junit --outputFile=junit.xml
npx okproof ingest junit.xml
Or use CTRF (Common Test Report Format, ctrf.io). Many runners have a CTRF
reporter; ingest the JSON it writes. A test with flaky: true or retries that
passes is flaky, which is not proven.
npx okproof ingest ctrf-report.json
ingest picks the format from the file (.json is CTRF, otherwise JUnit XML).
Force it with --format junit or --format ctrf.
Both write .okproof/ledger-<issue>.json and .md. In GitHub Actions they also
write the ledger to the job summary and post it as one pull request comment
that reruns update. Give the job pull-requests: write, or pass
{ github: false } to turn this off.
4. Gate the merge
npx okproof gate exits 1 unless every criterion is met. Make it a required
check. The gate re-reads the proof files, so a stale ledger, a missing ledger or
stale verifier results fail it; the Action's proven output, the PR comment and
the MCP okproof_status verdict all use the same function.
A committed ledger is only a claim, so in CI gate from the job's own results:
npx okproof gate --results junit.xml --require-issues 142,143 rebuilds the
ledgers in memory and ignores committed ones (the Action does this when its
results input is set). Do not commit .okproof/ledger-*. See
docs/trust.md. What one source-only security pass found, fixed and left alone is in
docs/security-audit-notes.md.
Protect .okproof/ with CODEOWNERS
Nothing in okproof stops an agent (or anyone with write access) from editing a
proof file to weaken a criterion. Make that a reviewed change: add a
CODEOWNERS entry for the folder and turn on required code-owner review.
# .github/CODEOWNERS
/.okproof/ @your-org/reviewers
Then in the repository settings (Branch protection or a ruleset for your
default branch) enable "Require a pull request before merging" and "Require
review from Code Owners", and make the okproof gate a required status check. A
pull request that touches .okproof/*.md now needs a human owner's approval, so
criteria cannot be silently removed or reworded by the author of the change.
Use a team or a person who is not the agent's account.
Run npx okproof doctor to check this setup. It is read-only: it looks at
.github/CODEOWNERS (does a rule cover .okproof/ with an owner), .gitignore
(are ledgers ignored), your workflows (does the Action get results, and
fetch-depth when differential checks are on) and, for the repository in
origin or --repo owner/name, branch protection and rulesets through the GitHub
API (the okproof check is required, code-owner review is required). A token
(GITHUB_TOKEN or GH_TOKEN) is optional; anything it cannot read is a warning,
never a failure. It exits 1 when a check fails. --no-network skips GitHub.
A proof file can also demand verification. Put {verify} at the end of its
heading (## #142 Pro upgrade {verify}), or pass --require-verify to the gate:
then verify-<issue>.json must exist. Independently, a saved repro under
.okproof/repro/<issue>.*.json with no verify-<issue>.json fails the gate, so
deleting the verifier file cannot hide a refutation.
Refutations persist in CI. verify-*.json is a local result and is git-ignored,
so a bug found on a laptop would not block a merge on its own. Commit the model-free
repro scripts instead (.okproof/repro/*.json, never verify-*.json) and replay them
in the job: okproof verify --replay-only --url <preview> --json replays.json, then
okproof gate --replays replays.json (the Action input replays does this). With
--replays (or --require-replays) every repro file is a problem unless this job
replayed that exact file and the bug no longer reproduces; a replay that was refused,
stopped early or hit a file changed since it ran also fails. When the bug is fixed,
delete the repro file in the same pull request. A repro that leaves the app origin is
refused, and with --header, --storage-state or --login the replay needs --url
and refuses a repro recorded against another origin.
Evidence levels
"Met" is not all the same. okproof grades the evidence behind each criterion on a scale from E0 to E4, records it in the ledger, and lets a proof file say how much a criterion needs.
| Level | Name | What it takes |
|---|---|---|
| E0 | claimed | The criterion exists. Nothing else. (A failing tagged test, or a verifier refutation, puts a criterion back here.) |
| E1 | a tagged test passed | At least one test tagged [okproof:<id>] passed. |
| E2 | solid test | Every tagged test passed cleanly (no flake, no skip), at least one made a real, non-trivial assertion, and okproof lint does not call that test unrelated to the criterion. |
| E3 | survived adversarial verification | E2, and okproof verify ended held for the criterion, or a diff or revert file marks it proven-by-change or covered (below). |
| E4 | proven in CI | E3, produced in CI by okproof gate --results <file> from this job's own results, on a commit whose .okproof/ folder is identical to the base branch's. |
Requiring a level. Put tokens in one {...} block at the start of the
criterion line, separated by spaces:
- [ ] {E3} Payments are charged once
- [ ] {#pay E3} Payments are charged once (stable id "pay" and a required level)
- [ ] {#pay E3 pre} Existing payments still work (all three)
| Token | Meaning |
|---|---|
#id | A stable id (lowercase letters, digits, -, with at least one letter), as in docs/stable-ids.md. |
E0 to E4 | The level this criterion requires. Upper case E, one digit. |
pre | Marks a criterion that already held before the change. It has no effect on the level; okproof diff accepts it as not-differential (see "Differential proof"). |
The tokens may come in any order, each at most once (one id, one level). A block
with no recognised token, such as {JSON} responses are valid, is ordinary text.
Once a block has a recognised token, an unknown or malformed one ({E5}, {e3},
{#pay urgent}) is an error, so a typo never silently weakens a criterion.
Default level. A criterion that names no level needs E2. Change it with
--min-level E3 (on ingest, gate, or the Action's min-level input) or
OKPROOF_MIN_LEVEL. A line's own {E..} always wins, so --min-level raises or
lowers only the lines that name nothing. E0 and E1 never loosen the test
rules: a criterion is met only when the tests make it met (a clean pass with a
real assertion) and its level reaches the requirement. {E1} is the way to
accept a test that lint calls unrelated.
What you see. Ledger entries carry level, required and gaps. The
markdown ledger and the PR comment add a Level column with a bar as long as the
requirement, for example E2/E3 ▰▰▱. A criterion with passing tests but too
little evidence has the verdict INSUFFICIENT EVIDENCE, and the gate says exactly
what is missing:
#142 criterion 142.pay has E2 evidence but requires E3: survive adversarial
verification: run okproof verify until it holds for 142.pay, or add
.okproof/diff-142.json or revert-142.json marking it proven-by-change or covered.
The MCP okproof_status tool shows the same levels and a "Raise the evidence"
list with the next step for each criterion.
Adversarial evidence (E3). okproof reads three optional files next to the
proof file <n>.md:
verify-<n>.json, written byokproof verify: a result with verdictheld.diff-<n>.jsonandrevert-<n>.json:{"criteriaHash"?: "...", "results": [{"criterionId": "142.1", "verdict": "proven-by-change"}]}, or"results": {"142.1": "covered"}. The verdictsproven-by-changeandcoveredcount. This format is provisional until the commands that write these files ship.
A file whose criteriaHash does not match the proof file's criteria is stale and
ignored. A malformed file supplies no evidence.
E4 and the Action. Only the gate can attest E4, and only for a ledger it
rebuilds in memory from --results; a ledger read from disk is credited with at
most E3, so committing one never counts. The GitHub Action compares .okproof/
with the base branch (base-ref input, default the pull request base) and passes
--proof-matches-base when it is identical; outside the Action pass the flag
yourself, or set OKPROOF_PROOF_MATCHES_BASE=1. Because the whole folder must
match, a pull request that adds or edits proof or verifier files cannot reach E4:
land them first, then later pull requests can. A ledger written before evidence
levels counts as E2.
Limits: levels are only as good as their inputs. E2 trusts the runner's assertion
counts and lint's heuristics, E3 trusts committed verify, diff and revert
files (CODEOWNERS protects them, see above), and with --lint a test it flags as
unrelated now holds its criterion at E1, which fails the default E2 until the test
is fixed or the line says {E1}.
Weak and unrelated tests
A tag is a claim; an assertion is evidence. A tagged test that passes but makes zero assertions proves nothing, so okproof will not call its criterion met. Silence is not proof.
A criterion gets one of four verdicts:
failed: any claiming test failed, was flaky, skipped or timed out.unproven(shown as "UNPROVEN (no assertions)"): the claiming tests passed, but every one of them is weak. The ledger lists the weak test titles.met: all claiming tests passed and at least one made a real assertion.untested: no test claims it.
A test is weak when its assertion count is exactly 0. On the command line an
unknown count (the runner did not say) is not weak, so runners without counts
keep working. Pass --strict-assertions (or set OKPROOF_STRICT_ASSERTIONS=1) to
okproof ingest, or strictAssertions: true to the reporter, to treat unknown as
weak. The GitHub Action does this by default (strict-assertions: false relaxes
it); with lint on, a real assertion lint finds in the test source replaces an
unknown count, so node:test, Vitest and Jest users are not punished.
How each runner reports counts (the full table, with what happens when the count is unknown and what is not guaranteed, is in What counts as an assertion, runner by runner):
- Playwright reporter: counts
expectsteps in the result's step tree, nested ones andexpect.softincluded. A result with no step list is unknown. - JUnit: the
assertions="N"attribute on<testcase>(PHPUnit style). Absent means unknown. A testcase that passed only after a retry isflaky, so never met:<flakyFailure>/<flakyError>(Maven Surefire),<rerunFailure>/<rerunError>, or arerun/reruns/rerun_countproperty that is not0. - CTRF:
extra.assertionson a test, when it is a number. Otherwise unknown.
A confirmed verifier refutation still makes a criterion failed.
okproof lint
A static check that needs no test run:
npx okproof lint # scan the working directory
npx okproof lint --tests tests/ui # limit to a path, file or glob such as "tests/**/*.spec.ts"
It finds tests whose title has [okproof:<id>] and reports the ones with no
assertion in the body (expect(, assert, .should(, t.Error, t.Fatal,
require., toBe, toEqual, toHave, ...), or whose only assertions are
trivial: expect(true).toBe(true), expect(1).toBe(1), expect(true).toBeTruthy(),
assert.ok(true), assert.equal(1, 1), assert True, assert 1 == 1,
self.assertTrue(True) and the like. It also treats as not asserting anything:
constant-only comparisons (expect(2 + 2).toBe(4), assert 2 + 2 == 4),
toBeDefined(), toBeTruthy() or not.toBeNull() on a fixture such as page,
browser, context, driver or app (also !!page), expect.assertions(0),
assertions only inside if (false) or after a return, only inside a local
function the test never calls, or only inside a try { } catch { } that swallows
the failure. One real assertion next to a trivial one is enough to pass this
check. A test that claims more criteria than --max-claims (default 3) is
reported OVERCLAIM: advisory, and a failure with --strict-relevance. It also reports tags naming a
criterion that no proof file lists, and criteria no tagged test claims. It
exits 1 on a weak test or a dangling tag. Untested criteria are listed but do
not fail the run. Also available as lintTests() and the okproof_lint MCP tool.
It scans *.test.*, *.spec.*, *.e2e.*, test_*.py, *_test.py and
*_test.go, skipping node_modules, dist and .git, files over 1 MB and
anything past 5000 files. It is a heuristic with no parser: it follows
brackets while skipping strings, comments and regex literals (JS, TS, Go) or
reads the indented block (Python). Put the tag in the test title. A test
that only calls a helper which asserts is reported weak, and a tag in a comment
above a test is not followed. Treat a hit as a prompt to look, not a verdict.
The ledger counts from your runner are the authority.
Some runners report no assertion counts at all (JUnit from node --test, for
example), so a test with no assertion would be marked met. Feed lint into the
ledger to close that gap:
npx okproof ingest junit.xml --lint # scan every test file under the working directory
npx okproof ingest junit.xml --lint tests/ui # or a path or glob (`--lint=<path>` also works)
npx okproof gate --results junit.xml --lint
A test lint finds weak (no assertion, or only trivial ones) is counted as having
asserted nothing, so its criterion is unproven. Lint findings are matched to
results by the [okproof:<id>] tag plus the test title. A count your runner
does report stands, except for tests lint calls trivial. A test lint calls
unrelated does not fail ingest, but it keeps its criterion at evidence level E1,
which fails the default E2 (see Evidence levels); add
--strict-relevance to make ingest and the gate fail outright. After a bare --lint, a
following word is read as the path; write --lint= to put the proof folder
after it. gate --lint needs --results.
Possibly unrelated tests
A tag is a claim, and an agent optimising for a green gate can tag a test that checks something else. For every tagged test that does assert, lint compares the claimed criterion with the test body and reports:
possibly unrelated: test 'login works' claims 5.1 ('A user can reset their password by email') but never mentions password, email, reset
okproof lint itself only prints warnings and exits 0 (when its findings feed a
ledger with --lint, an unrelated test caps its criterion at E1; see
Evidence levels). Add --strict-relevance
(strictRelevance: true for lintTests() and the MCP tool) to make each one a
failure (exit 1).
How it works: the criterion is lowercased and split on non-letters, a small
built-in stopword list and words shorter than 3 characters are dropped (so are
"user"/"users", which start nearly every criterion), and simple stems are
compared (s, es, ed, ing). The test body contributes its identifiers,
split on camelCase and snake_case, and its string literals. The test's own title
and (in Python) function name do not count, because they are the easiest thing to
copy from the criterion. If none of the criterion's key words appear in the
body, the test is reported. One shared word is enough to stay quiet.
Known limits, so you can weigh a hit:
- Synonyms are out of scope. A test that calls
changePass()for "reset the password" is reported (false positive). - Compound words such as
signupagainst "sign up" do not match. - Helpers hide intent. A test that only calls
runScenario()mentions nothing; the words live in the helper. - Page objects and fixtures (
loginPage.submit()) can carry the meaning outside the test body. - False negatives are easy. A test can mention the right words and still check nothing relevant; one shared word passes, and a common word in the criterion (such as "list") matches almost anything.
- It checks wording, not behaviour. It cannot tell that a test is wrong, only that it never talks about the thing it claims.
- Code identifiers such as
expect,test,pageandassertare ignored as body words, but the same words in a string literal count.
Treat it as a prompt to open the test, not a verdict.
Differential proof (zero tokens)
A test that passes before the change and after it proves nothing about the change. It would have been green with or without the work. okproof can check this without a model, just by running your tests twice:
okproof diff --base origin/main --test "npm test" --results junit.xml
okproof diff finds the merge base of --base (default origin/main) and
HEAD, and creates a temporary git worktree at each. Into both it copies the
current .okproof/ folder and the test files that differ from the base, so the
tests are the PR's tests and the code is the base's code. It then runs your
--test command in each (through the shell, with OKPROOF_SIDE=base or
OKPROOF_SIDE=head in the environment), reads --results (JUnit XML, or CTRF
with --format ctrf) from each, and compares them per criterion:
| Status | Meaning |
|---|---|
proven-by-change | its tagged tests fail or do not exist on the base, and pass on HEAD |
not-differential | they pass on both: the test does not depend on this change |
regressed | they pass on the base and fail on HEAD |
failing | they fail on both |
The result is written to .okproof/diff-<issue>.json, with the base and head
commits and a hash of the criteria. okproof ingest and okproof gate read it:
a not-differential criterion is not met and regressed fails the gate. A
criterion that was already true before the PR is fine; say so on its line with a
pre token in the leading block ({pre}, or {#id E3 pre}; see "Evidence
levels"). A bare {pre} anywhere in an older proof file's criterion text still
works:
- [ ] {pre} Existing users can still sign in
or pass --allow-preexisting to okproof diff (or okproof gate) to accept all
of them. --timeout <seconds> limits each side (default 600).
Your working tree, index, branches and git config are never touched, and the
worktrees are removed even when the test command fails or times out. The
repository's node_modules is linked into each worktree, so install
dependencies first. Only committed code at HEAD is tested.
In the GitHub Action, set differential: on and test-command (and check out
with fetch-depth: 0, so the base branch and merge base exist):
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: okproof/okproof@v0
with:
results: junit.xml
differential: 'on'
test-command: npx vitest run --reporter=junit --outputFile=junit.xml
The command is passed to the shell through an environment variable, never spliced into the workflow script.
Revert check
okproof diff asks whether the tests fail without the change. The revert
check asks the reverse: do they notice the change being undone?
okproof revert-check --base origin/main --test "npm test" --results junit.xml
It lists the source files changed between the merge base and HEAD (tests,
.okproof/, docs, lockfiles and images are left out). In a temporary worktree at
HEAD it reverts each one to its base version, re-runs the tests, and records
which criteria flip from pass to fail. Then it reverts all of them at once, to
catch a criterion that depends on two files together. A criterion whose tests
stay green no matter what is reverted is uncovered: its tests do not exercise
the change. Each covered criterion lists the files that cover it.
--max-runs <n> (default 20) caps the per-file runs; with more files, they are
grouped by directory. --issue <n> limits it to one proof file. The result is
.okproof/revert-<issue>.json. The gate treats uncovered as not met, unless
you pass --allow-uncovered to okproof revert-check or okproof gate.
Limitations: both checks only see what your tests report. If reverting a file
(or running on the base) breaks the whole test run, every criterion counts as
failing there, which can look like coverage; the run log says when a run wrote no
results. They need a deterministic test suite, a checkout with history
(fetch-depth: 0), and a test command that works in a fresh checkout apart from
node_modules. Only the root node_modules is linked.
Mutation mode
okproof revert-check --mutate [--max-mutants 20] [--allow-survivors] also mutates
the lines the PR added or changed (flipped comparisons and booleans, +/-,
return values) and re-runs the tests per mutant. A criterion whose tests let a
mutant survive in code it depends on is weakly-covered, and the gate fails
unless --allow-survivors. Result: .okproof/mutate-<issue>.json. See
docs/mutation-and-revert-check.md, which also
says how to use Stryker or PIT instead.
Reviewing a pull request
okproof judges a pull request against the proof files in the pull request, so a change that removes a
criterion, rewords it to be easier, lowers its evidence level, adds pre, drops {verify}, or moves a
positional id would be judged against the weakened file. Three commands close that gap and give a reviewer
something to read. None of them runs your tests.
-
okproof criteria-diff --base origin/mainlists what the pull request did to each criterion and which changes weaken the proof. It exits 1 on a weakening change,--jsonfor scripts. -
okproof gate --base origin/mainadds the same check to the gate. A weakened criterion fails the gate even when every remaining test passes.--allow-criteria-changeis for a reviewer who has read the change. The comparison is against the merge base (or the base ref itself in a shallow clone). -
okproof review --results <junit.xml|ctrf.json> --base origin/mainprints one table: each criterion, what changed in it, its result and evidence level, the tests that claim it (file and line, and whether that test file changed in this pull request) and any weak or quarantined tests.--jsonis available. -
okproof matrix --results <junit.xml|ctrf.json> [--dir d]...answers a repository-wide question: which criteria, across every issue and every proof folder, have no linked passing test right now? It prints a summary line, then each issue with its unmet criteria first and the met ones after. Exit 1 when any criterion is not met, so a criterion nobody tests cannot slip by;--report-onlyalways exits 0 (for dashboards),--jsonprints one document,--html <file>writes a static page.
In the Action this is on by default: criteria-guard fails the gate on a weakening change, and a reviewer
approves one by adding the okproof-criteria-change label to the pull request. The label is read from the
event, so the workflow must also run when labels change: on: pull_request: types: [opened, synchronize, reopened, labeled, unlabeled]
(okproof init --workflow writes that). If base-ref is set but the base branch cannot be fetched, the gate fails instead of skipping the guard; reviewer-table writes the table
to the job summary. Both need the base branch (base-ref). More for reviewers: docs/reviewing-prs.md.
The same diff also shows what a pull request did to the tests. okproof tamper-check --base origin/main (and
gate --base, which runs it too) fails on changes that can make a criterion pass without proving it: a test deleted
(one whose title is declared nowhere else, so moving a test to another file is fine, but renaming its title is reported as a removal), .skip, xit, @Disabled, @pytest.mark.skip
and similar added, .only or fit added (the rest of the run is skipped), a snapshot file rewritten, or a
process.exit(0) / sys.exit(0) added. Fewer assertions than before is a warning, never a failure. A reviewer allows a
deliberate change with the okproof-test-change label (the Action's tamper-guard, on by default) or
--allow-test-change. This reads the diff: it knows test titles in JavaScript, TypeScript, Python and Go, and the
skip, only, snapshot and exit checks work on any language's test files; it is a heuristic that says "look here", not a
proof, and a reviewer decides. A marker inside a string or a trailing comment is data and is ignored (a test of a tool
like this one is full of them); it reads one line at a time, so a template literal that was opened on an earlier line is
not known to be open. --skip-tamper-check and --skip-criteria-check turn either comparison off for gate --base.
An issue that keeps its cases in a table (ID, case, expected) works too:
okproof sync --issue 142 --table "Test cases" --id-col ID --text-col Expected makes each row a criterion whose stable
id is the case id, so a test tagged [okproof:142.s1] keeps pointing at case S1 whatever happens to the row order.
A spec file works the same way: okproof sync --issue 142 --from ears --body-file requirements.md (formats ears, openspec, speckit, spec) turns its acceptance criteria, scenarios or requirements into criteria with ids taken from the spec's structure, and --check fails when the spec changes. See docs/spec-adapters.md for each format and what it does not read.
Keep criteria in sync with the issue
The GitHub issue is the source of truth. Instead of copying its checkboxes by hand:
npx okproof sync --issue 142 # needs GITHUB_REPOSITORY (or --repo owner/name) and GITHUB_TOKEN/GH_TOKEN
npx okproof sync --issue 142 --body-file issue.md [--title "Pro upgrade"] # offline
npx okproof sync --issue 142 --check # CI: change nothing, exit 1 on drift
This writes .okproof/142.md (or the [dir] you pass; it must be inside the current directory). Rules:
- [ ],- [x]and* [ ]lines count; checkboxes inside fenced code blocks do not.- If the issue has a heading named "Acceptance criteria" (any level), only the checkboxes under it count, up to the next heading of the same or higher level. Otherwise all checkboxes count.
- On an existing file, criteria already there keep their order and ids, new ones are appended, deleted ones are removed. Reordering in the issue alone is not drift.
- Ids are positional (
142.<n>), so removing a middle criterion renumbers the later ones. okproof prints a warning listing[okproof:142.3] -> [okproof:142.2]so you can re-tag those tests. - The file is rewritten from the issue, so hand-added notes in it are lost. An edited checkbox counts as one removed and one added.
- With
--body-filethe title comes from--title, else the first heading that is not "Acceptance criteria", else the file's current title. --checkfails with "proof file is out of date with issue #n; run okproof sync", and says why: the issue changed since the last sync, the proof file was edited locally, both, or (for a file written before this existed) that it cannot tell.- Provenance.
syncwrites one comment line under the heading,<!-- okproof:issue updated_at=... sha256=... proof_sha256=... -->.sha256is a digest of the issue's title and criteria at the sync,proof_sha256a digest of the proof file itself, andupdated_atis the issue's timestamp for people to read.--checkcompares the recorded digests with the issue and the file, so it can tell "the issue changed" from "someone edited the proof file".updated_atis never compared (labels and comments change it). Files without the line behave as before; the nextsyncadds it, keeping any notes in a file that is already in step. Not built yet:sync --push(writing criteria back to the issue; it would needissues: write) and a text hash in the tag ([okproof:142.3#a1b2]). - A
--resultsgate rebuilds its ledger from this job's tests, so it cannot see that a positional id was re-pointed since the tests were tagged. Where a committed ledger exists, the gate fails it as STALE (naming the edited ids). Stable ids avoid the problem.
okproof sync --issue 142 --push (opt-in) first appends criteria that only the
proof file has to the issue body (append only; needs issues: write), then syncs.
Tags may carry a text hash, [okproof:142.3#a1b2] (okproof tag-hash 142.3 prints
it). If the criterion text is edited later, the gate and okproof lint report
"criterion text changed since this test was tagged". Tags without a hash work as before.
In the Action, sync: check (the default) does this on every run. It uses the issue input, or else the issues the PR body closes ("Closes #N", "Fixes #N", "Resolves #N" in the same repo, ignoring code blocks and HTML comments) that already have a proof file in dir. sync: write only rewrites the files in the workspace; committing them is up to your workflow. sync: off skips it.
GitHub Action
okproof ships as a composite action. Run your tests so they write JUnit XML, then call it:
name: okproof
on: pull_request
jobs:
prove:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write # lets okproof post and update its one PR comment
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- run: npx vitest run --reporter=junit --outputFile=junit.xml
- id: okproof
uses: okproof/okproof@v0
with:
results: junit.xml
- run: echo "proven=${{ steps.okproof.outputs.proven }}"
Inputs: results (JUnit XML or CTRF path; required unless allow-committed-ledgers: true,
because without it the gate would trust ledger files anyone can commit), dir (default .okproof),
gate (default true, fail unless proven), comment (default true),
issue (issue number to sync from; default: detected from the PR body),
sync (check default, write or off),
min-level (default E2, see Evidence levels), base-ref (branch the proof folder is compared with to allow E4; default the PR base),
differential (off default, or on, with test-command; see Differential proof),
lint (auto default scans your test files, marks assertion-less tests weak and counts a real assertion lint finds; a path or glob limits the scan; off disables it),
strict-assertions (default true: an unknown assertion count is weak unless lint found a real assertion),
strict-relevance (default true: a test that never mentions its criterion, or claims more than max-claims, fails),
max-claims (default 3),
require-linked (default true), require-linked-proof (default: same as require-linked; fails when the PR adds or changes a proof file whose issue it does not link, and always warns),
require-verify (default false), allow-empty (default false), node-version (default 22), github-token (default ${{ github.token }}).
For a required check that must run on every pull request, set allow-empty: true
so a PR with no proof file passes (linked issues still need theirs), and do not
filter the workflow with on.pull_request.paths: a required check that is skipped
blocks the merge. A paths: filter is fine for a check that is not required.
Outputs: proven (true or false) and summary (one line per proof file).
Set comment: false to skip the PR comment and job summary (for forks, or
when you only want the gate). The CLI honours the same switch as
OKPROOF_NO_COMMENT=1.
Pin the Action by commit SHA
Releases are tagged v0.x.y, and a moving v0 tag points at the latest one.
Tags are mutable: v0 is moved on every release, and a v0.x.y tag can be
re-pointed by anyone who can push tags. A full commit SHA cannot. Pin the Action
the way you pin your other third-party actions:
- uses: okproof/okproof@<full 40-character commit sha> # v0.4.0
okproof init --workflow does this for you in a published release (the release
workflow stamps its own commit into the package). A build that does not know its
commit writes @v0 plus a comment asking you to pin, never a made-up SHA. Let
Dependabot (package-ecosystem: github-actions) propose the next SHA.
What runs: the published, attested package
By default (runtime: published) the Action does not build okproof from source on
your runner. It reads its own version from the package.json of the commit you
pinned, installs exactly that version from npm into a temporary folder (scripts
off, registry fixed to https://registry.npmjs.org/), runs npm audit signatures
there (the registry signature and the build-provenance attestation), and then uses
that same verified copy. If the version is not on npm, or the check fails, or npm
is unreachable, the job fails: it never falls back to a source build. There is no
npm ci of dev dependencies and no compile step on your runner.
Set runtime: source only for a ref that is not a release (a fork, a branch under
test, this repository's own self-test); it runs npm ci and tsc as before.
Signed ledgers
Set attest: true and give the job id-token: write and attestations: write:
permissions:
contents: read
id-token: write
attestations: write
steps:
- uses: okproof/okproof@<full commit sha> # v0.4.0
with:
results: junit.xml
attest: true
After the gate, the Action writes an in-toto Statement (okproof-attestation.statement.json) and
its predicate (type https://okproof.dev/attestation/ledger/v1) next to the ledgers, and signs them
with actions/attest (Sigstore, keyless, GitHub OIDC). The subjects are the ledger files by sha256
(the Statement also lists the git commit); the predicate holds the result (proven or
not-proven), every criterion's verdict and level, the commit and the run URL. A job without
OIDC, and any pull request from a fork, skips signing with a notice and the gate is unaffected.
(The attestation action's own README also lists artifact-metadata: write; that is for storage
records of container images and is not needed here.)
Verify a ledger you downloaded from the run's okproof-ledgers artifact:
npx okproof attestation verify ledger-142.json --repo owner/name
# or directly:
gh attestation verify ledger-142.json --repo owner/name --predicate-type https://okproof.dev/attestation/ledger/v1
What a valid attestation proves, and what it does not. It proves that a workflow in that
repository produced exactly these ledger bytes. It does not prove the criteria were met: a
failed gate is signed too, with result: not-proven. okproof attestation verify exits 0 only when
the signature verifies, the predicate lists the file's digest and the result is proven; a deploy
step that wants the evidence should require the same. It also does not say the tests are good
tests, and a checkout that is not the signing workflow's run is not covered.
Ledger artifact and report
By default (upload-ledgers: true) every run, including a failed gate, uploads the ledger JSON files
and a static okproof-report.html as the okproof-ledgers artifact (set artifact-name when you
call the action more than once per workflow run, such as a matrix). A failed upload never fails the
job. Build a report yourself from one or more ledgers, oldest first, for a history per issue:
npx okproof report --out report.html run1/ledger-142.json run2/ledger-142.json
npx okproof report .okproof # every ledger-*.json in a folder
The report is one file: inline CSS, no script, no external asset, a CSP that allows nothing else, and every criterion text and test title escaped. It shows per issue the verdict counts, flaky test results and each criterion's tests, and re-judges nothing.
Fork pull requests
Use the pull_request trigger. On a pull request from a fork GitHub gives the job a
read-only token and no secrets: the gate still runs and still fails the check, and
okproof skips the PR comment (it writes the job summary instead). Never switch the
workflow to pull_request_target to get comments on fork PRs. That trigger runs
with a write token and secrets while your job checks out and runs the fork's code,
which is how repositories get taken over. Nothing in okproof needs it; to see the
ledger on a fork PR, read the job summary or download the ledger artifact.
If the pull request's own code must not share a job with a write token (outside
contributors, or branch authors you do not fully trust), run
okproof init --workflow --split. It writes a pull_request tests workflow with a
read-only token and a workflow_run gate that judges the results as data and publishes
the check run, never running the pull request's code. It does not stop a dishonest
results file. See docs/fork-pull-requests.md.
Browser driver
okproof ships its own Chrome driver with zero runtime dependencies. It speaks the DevTools Protocol directly over Node's built-in WebSocket (Node 22 or later) and is built for agents: it returns short text snapshots of the accessibility tree and acts by ref.
import { Browser } from 'okproof/driver';
const browser = await Browser.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com');
const { text } = await page.snapshot(); // - link "More information..." [ref=e1]
await page.click('e1');
console.log(await page.title(), page.problems());
} finally {
await browser.close();
}
Set OKPROOF_CHROME to use a specific Chrome, Chromium or Edge binary. Refs are
only valid until the next snapshot.
Verifier
okproof verify points an adversarial QA agent at your running app (a preview
deployment, say) and tells it to prove each criterion false. It tries other
roles, bad and huge input, double submit, reload mid-flow, back, keyboard-only,
a 375px viewport and offline. It acts only through the driver above.
Models guess, so a claim is never trusted on its own. Every action is recorded as plain JSON. A violation counts only if its assertion fails again when the recorded actions are replayed with no model, in a fresh browser. Otherwise it is listed as unconfirmed and does not fail the criterion.
export OKPROOF_ANTHROPIC_API_KEY=... # explicit key, see below
npx okproof verify --url https://preview.example.com --issue 142
Options: --dir .okproof, --max-steps 15, --budget-tokens 20000,
--model claude-opus-5-5, --effort medium (see Keeping verifier cost low). For an app behind a login use --storage-state <file>,
--header 'Name: value' or --login <script.mjs>; --strict-detectors turns off
per-detector attribution of findings (see docs/trust.md). It writes:
.okproof/verify-<issue>.json: a verdict per criterion (refuted,heldorinconclusive), findings, and the recorded actions.okproof/repro/<criterion>.json: a model-free regression script.okproof/screenshots/: a screenshot of each confirmed failure
okproof ingest then reads verify-<issue>.json: a criterion with a confirmed
refutation becomes failed with the evidence refuted by verifier: <title> (repro: .okproof/repro/<id>.json), whatever the tests said.
Replay for free. okproof verify --replay-only [--url ...] re-runs the saved
repro scripts with no model and no key. It exits 1 while a bug still
reproduces, so a fixed bug becomes a free regression check in CI. A replay never
leaves the app origin: a goto to another host is refused (exit 1, REFUSED), and
--header, --storage-state and --login credentials are sent to the app origin only.
With any of them, --replay-only needs --url and refuses a repro recorded against
another origin. Without --url, the base URL comes from the repro file: it must be http or https,
and a loopback, link-local or private host recorded in a repro is refused unless you pass --url
yourself (a repro committed to a repository is data from whoever committed it). --url must be
http or https for every verify run. The base URL stored in repro/*.json and verify-*.json
keeps only the origin and path (no query string, fragment or credentials; a --url that has any prints
a warning). --json [file] writes the results for okproof gate --replays.
Cost and safety flags for verify.
--dry-runprints the planned criteria, which probes would go first, and a rough token ceiling. It starts no browser and no model and needs no key.--read-onlyrefuses clicks on controls named like delete, remove, destroy, drop, pay, purchase, transfer, cancel subscription, confirm, yes, ok, checkout, submit or place order, and refuses pressing Enter inside a form or typing text that contains a newline. It is on by default whenCI=true;--allow-destructiveturns it off (use a disposable environment). The check reads the control's name, so it is a guard rail, not a sandbox.--allow-external-navigationlets the run keep acting after a click, redirect or history step has taken the page off the app origin. By default the next action is refused and the run reportsREFUSED. The request that caused the navigation is still sent; see docs/trust.md.--max-steps nmust be an integer from 1 to 200 and--budget-tokens na non-negative integer; both are checked before anything starts, also with--dry-run. The token budget is checked before each model call (the previous call's cost is counted) as well as after.--confirm 2of3replays each finding three times and counts it only when two replays show it (default1of1). Also applies to--replay-only.--concurrency ntries up to n criteria at once with--no-probes(default 1).--check-linksturns on the broken-link detector (same origin by parsed URL, at most 20 links; redirects to another origin are not followed; with--read-onlyonlyHEADis sent and links that look state-changing, such as/logout,/deleteor/unsubscribe, are skipped).- On Linux as root, Chrome starts with
--no-sandbox(containers need it) and okproof prints a warning: point it only at apps you trust, or run it as a non-root user.
Deterministic detectors run after every action, with no model: console errors, uncaught exceptions, failed requests and HTTP 4xx/5xx, interactive elements with no accessible name, horizontal overflow, and (opt in, same origin, at most 20 links) broken links. They are confirmed the same way, by reappearing on replay. A confirmed finding of severity 3 or more refutes the criterion. Unnamed controls and overflow are severity 2: reported, not failing.
Zero-token probes
Most adversarial checks need no model. okproof verify first runs deterministic
probes: scripted attacks that drive the same driver, record plain actions and end
in an assertion that fails when the bug is present. Each finding is replay-confirmed
exactly like a model's claim: the recorded actions are run again with no model in a
fresh browser, and only a finding that reproduces counts. A confirmed finding at
severity 3 or more refutes the criterion and writes the usual .okproof/repro/<id>.json.
| Probe | What it catches | Criterion words that select it |
|---|---|---|
persistence | fills the first form, submits, and the app says it saved (a success message or a new list item); a fresh page load no longer shows the value | save, persist, reload, refresh, stored, remember, "still there" |
back-forward | follows up to 3 same-origin links and goes Back; wrong URL, blank page, lost heading, uncaught exceptions | back button, go back, history |
double-submit | clicks each submit button (up to 3) twice in the same tick; the same write is sent twice, or the item is listed twice | submit, form, order, checkout, duplicate, twice |
narrow-viewport | 375x812: sideways scrolling, and controls that were usable at desktop width but now have zero size or sit off screen (fixed or transformed off-canvas menus are left alone) | mobile, phone, responsive, viewport, narrow, 375 |
keyboard | tabs through the page: clickable things Tab never lands on (a div with onclick, tabindex="-1" on a button) and focused controls with no visible change | keyboard, accessible, a11y, focus, tab order |
offline | goes offline, uses the page's buttons: uncaught exceptions or a blank page instead of a message | offline, lost connection, network failure |
hostile-input | submits empty, 10,000-character, unicode/right-to-left/emoji and <script> text: uncaught exceptions, 5xx responses, a blank page, or the text coming back as live markup (XSS) | input, field, validate, sanitize, escape, xss, injection |
Matching is by whole words, so "formatted" does not select double-submit. Console and
network hygiene (console errors, failed requests, 4xx/5xx) stays with the detectors.
npx okproof verify --url https://preview.example.com --probes-only # no key, zero tokens
npx okproof verify --url https://preview.example.com # probes first, then the model
--probes-only never reads a key and never calls a model. A criterion with no matching
probe is reported inconclusive (no-probe), and one the probes could not refute is also
inconclusive (probes-clean): a clean probe run does not prove the criterion holds.
By default the model runs only for criteria a probe did not refute, so the saving comes from
criteria probes refute: on an app with no bugs the probes find, the model still runs for every
criterion. The run ends with the saving, for example probes covered 4/6 criteria with 0 model tokens; model used for 2 (1 had no matching probe, 1 survived their probes). Without a key the probes still run and
the remaining criteria report why; --no-probes restores the model-only behaviour.
Probes act on the app: they type, click and submit, so point them at a preview or test
environment, as with the model. A probe that finds nothing to act on (no form, no link)
says so rather than passing silently.
Known limits: probes fill every text field with the same text and use the first submit-like button, so forms with validated fields (email, number) may reject the input; the persistence probe submits, then loads the page again with a fresh navigation (Chrome restores typed form values on Reload, which would hide the bug) and expects a visible sign of success before it expects the data back; the offline probe uses the page's buttons and never reloads, because without a service worker every site shows the browser's own error page offline; the keyboard probe covers the top-level document only (no iframes, no focus traps in modals).
Page load waits. --wait-until load|domcontentloaded|networkidle (and
page.goto(url, { waitUntil, timeoutMs }) in the driver) choose what a navigation waits
for; load is the default. networkidle waits for 500 ms with no requests. A page that
does not finish in time fails with the event it waited for and what to try instead.
Which account pays. The Anthropic adapter needs an explicit key, either
new AnthropicModel({ apiKey }) or OKPROOF_ANTHROPIC_API_KEY. It never falls
back to ANTHROPIC_API_KEY, auth tokens or CLI profiles, so you choose which
account pays. Without a key, okproof verify exits 2. @anthropic-ai/sdk is an
optional peer dependency (>=1.0.0 <2.0.0), loaded only when used: npm i @anthropic-ai/sdk. The
core stays dependency free, and any ModelClient works:
import { verify, AnthropicModel } from 'okproof/verify';
await verify({ baseUrl, model: new AnthropicModel({ apiKey }), dir: '.okproof' });
Status: the replay, detectors, agent loop and ledger integration are tested against a scripted fake model. The Anthropic adapter is not yet tested against the live API; its request and response shapes follow the SDK docs and are checked against a fake client only. Known limits: broken-link checks send no cookies; the key set is Enter, Tab, Escape, Backspace and arrows; one tab, no file uploads or dialogs.
--concurrency <1-8> (default 1) runs criteria in parallel on the probe-first path.
Each probe still runs once, the model is made once, and results, files and log keep
criterion order.
Keeping verifier cost low
Every step resends the conversation, so cost grows with the page. okproof does four things about it:
- Snapshot diffs. The first view of the page is a full accessibility snapshot.
After that each step sends only the lines that were added (
+|) or removed (-|) with two lines of context, or "unchanged" when nothing moved. A full snapshot is sent again when the diff would be as long as the page, every fifth view, and whenever the agent calls thesnapshottool. A typical step sends a small fraction of the characters. - A token budget per criterion.
--budget-tokens 20000(the default) caps input plus output tokens for one criterion, as the API reports them (cache reads are reported separately and not counted). When a run goes over, it stops cleanly with the verdictinconclusiveand the outcomebudget; it never counts as holding.--budget-tokens 0removes the cap. The tokens used and the budget are inverify-<issue>.json(tokens,budgetTokens,usage) and printed per criterion by the CLI. - Prompt caching. The system prompt and the tool list never change within a run, and the page content comes last, so the API can cache everything before it.
- A smaller model.
--model <id>picks any model your key can use; the default isclaude-opus-5-5. A smaller model makes cheaper runs, with fewer and shallower attacks. Lower--effortand--max-stepsalso cut cost.
Proof-first checks
An auditor should try to disprove "done", and silence is not proof. These checks, all deterministic and model-free, cover the ways a green run can still be wrong. Details, limits and schemas: docs/proof-first.md.
- Partial runs. A results file with fewer testcases than
--baseline, an abort marker, a summary that disagrees with its testcases, or a truncated end makes uncovered criteriapartial(never a pass), and a test cut off at the end of the file is not trusted. - Wrong build.
--expect-commit <sha>(the Action sets it by default;--expect-urloptional): results recorded against another commit, or none, make every criterionwrong-build. Have your test run writeokproof.commitinto its report (JUnit property, or CTRFextra.commit); theGITHUB_SHAfallback only shows where okproof ran. - Decision header. The ledger and PR comment open with counts, the one blocking reason, and the criteria that still need a live check after deploy (met at E1/E2 only).
- Root-cause variants. A confirmed failure is re-run with varied input, repeats, reload, back and forward, 375px and offline-then-online. The repro file records
variants;verify --replay-only --variantscalls a fix narrow if the exact example passes but variants still fail.--no-variantsskips it. - Sequence checks.
n-records(the second record must not overwrite the first),two-actors(two independent browser contexts: no lost data, no leaked values) andin-app-navigation, run when a criterion's words match.--no-sequencesskips them. okproof verify-findings <file>checks review findings against the code: confirmed, fixed, false-positive-suspect, outside-scope or unverified. Exit 1 on a confirmed blocking finding. docs/review-findings.mdokproof brief-check <brief.md>compares a brief's must/never/always/shall rules with the criteria: uncovered rules (warnings, errors with--strict) and contradictions (exit 1). Keyword-based and English-only.
Use with coding agents
okproof mcp runs an MCP server over stdio (no dependencies) so Claude Code,
Cursor and Codex can check the definition of done before they claim a task is
finished. For Claude Code, add this to .mcp.json:
{ "mcpServers": { "okproof": { "command": "npx", "args": ["-y", "okproof@0.4.0", "mcp"] } } }
Tools (all take an optional dir, default .okproof, which must stay inside the
working directory):
okproof_criterialists criteria and the[okproof:<issue>.<n>]tag for each test title.okproof_statussays "Done" or "Not done" and lists the unmet criteria. Call it before saying a task is finished.okproof_ingest_junitbuilds ledgers from a JUnit XML report.okproof_lintfinds tagged tests with no assertion or only trivial ones, tests that never mention their criterion ("possibly unrelated";okproof_lintitself only warns,strictRelevancemakes it fail), dangling tags and untested criteria.okproof_statusreports criteria whose tests passed without asserting as unproven and names the tests.okproof_add_criterionappends a criterion. Through this server agents can add criteria but not remove or edit them; that limit covers the MCP tools only, not direct file edits (see CODEOWNERS below).okproof_suggestranks existing untagged tests for each untested criterion (advisory; a similar name is not proof).okproof_explain(read-only) takes a criterion id such as142.3and optionalresultsfile(s), and returns whatokproof explainprints: which tests claim it, what each did and why it is in its state.okproof_verify_findingschecks review findings against the code with no model: confirmed, fixed, false-positive-suspect, outside-scope or unverified.
skills/okproof/SKILL.md is a Claude Code skill that tells agents to follow this
loop. okproof init --agents copies it to .claude/skills/okproof/SKILL.md.
A skill is a request, not a rule. To enforce the loop in Claude Code, run okproof init --hooks: it writes a
Stop hook that blocks the agent from finishing while okproof gate fails (it never blocks twice in a row) and a
PreToolUse hook that blocks Edit, Write and MultiEdit on files under .okproof/ (set
OKPROOF_ALLOW_PROOF_EDIT=1 to allow it). It merges into an existing .claude/settings.json only with --yes,
keeps your own hooks, and does nothing on a second run. The hooks do not cover shell commands that edit files, so
they are not a security boundary; docs/agent-hooks.md has the limits and how to remove them.
okproof init --agents also appends this section (marked <!-- okproof --> so
it is added once) to AGENTS.md and CLAUDE.md. You can paste it by hand:
<!-- okproof -->
## okproof: definition of done
This repo checks work against acceptance criteria in `.okproof/<issue>.md`.
1. Read `.okproof/<issue>.md` before you start. Each criterion has an id such as `142.1`.
2. Tag every test that covers a criterion with `[okproof:<id>]` in its title, for example
`test('member can upgrade [okproof:142.1]', ...)`.
3. Run the tests, then `npx okproof@0.4.0 ingest <results>` (JUnit XML or CTRF JSON) and
`npx okproof@0.4.0 gate` (or call the MCP tool `okproof_status`). Keep working until it says proven.
4. Never edit or remove existing criteria without telling the user exactly what you changed and why.
5. Add a real assertion to every tagged test. Untested, flaky and assertion-less tests never count.
An agent with file access can still edit .okproof/*.md. To stop that, protect
the folder with CODEOWNERS (for example /.okproof/ @your-team) and require
review, so criteria cannot change without a person approving.
Project
Status. Shipped: proof files, ledger, merge gate, PR comment, Playwright
reporter, JUnit and CTRF ingest, weak-test check, lint, issue sync, MCP server,
init, own Chrome driver, and the verifier with model-free replay. The
verifier's Anthropic adapter is tested against a fake client only, not the live
API.
Roadmap. Ordered by priority; dates are intentions, not promises. Open an issue to argue for a change.
- Next: more runner coverage.
- Later, not built yet: "Harden" (commit passing verifier runs as tests linked to criteria), a hosted proof page with history, and Firefox and WebKit in the driver.
Non-goals. Replacing your test runner or browser library, a browser-agent platform, visual diffing, load testing, monitoring, and grading pull requests with a model's opinion. See WHY.md for principles.
Maintenance and support. okproof is maintained independently. There is no guaranteed response time and no SLA:
issues and pull requests are looked at when time allows. Ask "how do I...?" questions in Discussions so Issues stay
about reproducible bugs. The scope is what this README describes, and a request outside it may be closed to keep the
project maintainable. Bug fixes are welcome; open an issue to agree the design before a large change. An issue labelled
needs-info that gets no reply for 30 days is marked stale and closed 14 days later
(stale.yml); anyone can reopen it by adding the details. Support routes are in
SUPPORT.md and security reports go through SECURITY.md.
Who decides. The maintainer and project lead is Rudra Kumar Pandey (@hexrkp). Small changes: a pull request with passing checks and maintainer approval. Larger changes (new commands, file formats, anything touching the principles in WHY.md): open an issue with a short proposal first and leave it open at least 5 days; the maintainer decides if there is no agreement and writes down why. Committers may be added later and are listed in CODEOWNERS.
Compatibility. The proof file format and ledger JSON are public interfaces; breaking them needs a major version and a migration note. Until 1.0, minor versions may break APIs, and the changelog says how.
Releases. Cut from main by the release workflow only, each npm version
with a provenance attestation linking it to the commit and workflow run. Builds
from anywhere else are not official releases. See RELEASING.md. To check that a release is the
official one, or what to do about a copy that claims to be okproof, see docs/provenance.md.
Cite
If okproof helps your research or writing, cite it with the metadata in CITATION.cff; GitHub shows a "Cite this repository" button from it.
License
Apache-2.0 for this package. Copyright © 2026 Rudra Kumar Pandey and contributors. "okproof" is a trademark of its author; see TRADEMARK.md. Contributions are made under the CLA and signed off under the DCO (see CONTRIBUTING.md).
okproofnpm install okproof
