Prove a Change with Tests
Use this guide for a pull request that changes user-visible behavior. The pull
request records evidence for numbered acceptance criteria. Pass --org <org>
on every write to select the organization.
Feedback. Tell Cofactor the moment a step in this guide is wrong, unclear or missing; a command fails in a way the guide did not predict; you took a detour or had to guess; or a tool you needed does not exist. Send it when it happens, not only at the end: one sentence on what happened and what would have helped. Run cofactor feedback "<what happened; what would have helped>" --topic instructions --command "cofactor proofs guide <section>", or call the cofactor_feedback_submit MCP tool with the same text, topic and command. Never include secrets, customer data, real names or URLs; use neutral examples (Acme, example.com).
CHOOSING PROOFS
Pick the proof that fits the change; one change can need several.
-
Functional change: a native Workflow or external test run that passes at the pushed commit. The procedure below covers native Workflow evidence.
-
Performance-sensitive change: a perf run. Read
cofactor perf guide. A query change, for example, needs both a functional proof and a perf proof. -
UI change: a Workflow with
visual_checkpointnodes. Readcofactor workflow guide visual-checkpoints, and step 7 below for how attaching runs the test at the PR base and shows the checkpoint diffs. For sandbox-only tests, prepare visual data with the test's own SQL fixture through the app's generic loader. That guide covers adding it and API/UI setup for tests that must also run against staging or prod. When the organization uses visual regression (its Workflows already carryvisual_checkpointnodes, or its admin says Visual checkpoints are on), a change that alters what a screen looks like must carry UI-test evidence: run a Workflow with avisual_checkpointon that screen, adding or extending one if none exists. A manual screenshot does not replace it. With visual regression off, skip this and say so in the--assertedtext of another item, or mark the criterion not proved with that reason (see below). -
Agent behavior: evals. Read
cofactor eval guide, then attach a full passing eval run with--eval-run(see step 6).
Repository-owned external test evidence requires CLI 0.59.0 or later.
Repository-owned Playwright tests
An external test proves a criterion with its stable test identity and a complete, settled result from the pushed Application head. Passed and flaky results are attachable; report flaky honestly. Skipped, absent, incomplete, canceled, running and failed results cannot be attached. A different failed test in the same settled run does not invalidate the selected test's result.
Follow the repository's test-suite guide for its declaration, discovery, fresh
Sandbox claim and exact test selection. For the proof lifecycle, attach the
extest_… ID and its extrun_… result ID with product-language steps and
assertion. External attachments reject Workflow-only --node, --base and
--tree options; visual checkpoint comparison is not part of this route.
External test changes are reviewed and merged in their source repository;
Cofactor does not archive or promote them. Native Workflow evidence
in a mixed proof keeps its existing promotion behavior.
cofactor test-suite guide cofactor proofs attach --pr <n> --application <app> --criterion <n> --text "<criterion>" --test <extest_…> --run <extrun_…> --asserted "<what was checked>" --org Acme
After each push, attach or detach, render the updated proof block again. A successful citation at an older head remains a stale success. Re-run on the proof page explicitly evaluates it at the current head; no automatic pull-request run is added. A failed refresh records failure instead of retaining green evidence. The external suite guide also explains that a proof rerun retains an independent test repository's cited revision.
THE PROCEDURE
-
Find coverage before writing a Workflow:
bashcofactor workflow list --search "<words>" cofactor workflow get <wf_...> --format markdown
Read the candidate assertions. If a test already walks the journey, use it. Never add near-duplicates or a new test for a changed filter, column or field.
-
Choose the Workflow:
- If a Workflow in Regression already proves the criterion without changes (the journey must still work, for example after a query or refactor change), run it as is and attach its run. It is cited as an existing test: it proves the journey still works, it is not new coverage, and it is never promoted (it is already in Regression). It cannot prove new behavior: a new filter, column or field needs a fork that asserts it. A fork is never an existing test; to cite one, attach the Regression test itself, not a fork of it.
- Fork an existing Workflow with
cofactor workflow fork fork <wf_...> --org <org>and edit the fork. Never edit the original. - Create a new draft only when no existing journey fits or it needs its own
data or role (see
cofactor workflow guide write-a-test).
Whichever you choose, the Workflow drives the changed behaviour the way a user or caller reaches it (pages, routes, CLI, or a real flow whose steps reach the change) and asserts what they observe. For example, to prove a Notification step can use a value an earlier step captured, run a flow that captures it and sends the email, then read the received email back. A sandbox action only sets up state (seeds data, configures, turns a flag on). It never asserts the change and never runs the repository's own tests: that re-runs your checks and does not exercise the product. An exact claim about a value the run captured (an email's body, a header, an API field) is asserted with a check step: a condition with a typed predicate and
"failOnFalse": true(cofactor workflow guide assertions, Exact checks over run variables). Never with a sandbox action that raises an error. If the sandbox cannot reach the behaviour, improve the sandbox in its own pull request or mark the criterion not proved with the reason. -
Configure promotion on the fork or new draft before attaching evidence:
bashcofactor workflow set-promotion <workflowId> --promote-on merge|never --org <org>
mergeadds a new test to Regression when the pull request merges, and merges a fork into its original, which joins Regression if it is not already there.neverarchives the test at merge instead of adding it to any suite; use it when the proof is about the change itself (see Curating the suite). Promotion has no effect on an existing test. -
Prove the change at the exact pushed commit. Start from a clean checkout, commit and push the application change, then use the pushed commit from
git rev-parse HEADas<sha>in--at <sha>. Claim that SHA and sync it:bashcofactor sandbox claim --application <app> --at <sha> --wait --org <org> cofactor sandbox sync <sandboxId> [--build] --org <org> cofactor workflow run <workflowId> --sandbox <sandboxId> --stream --org <org>
Keep the sandbox id. If you lose it,
cofactor sandbox claims --org <org>lists your live claims, andcofactor sandbox destroy <sandboxId>tears one down when you are done. The run uses the claimed sandbox's own environment, so do not pass--environment. Iterate until it passes, then run it once more after the last application or Workflow test change and use that passing run ID. An existing test is run the same way, at the pushed commit and on its current revision. For application edits, commit and push, then sync and rerun. Leave the checkout clean. Attach refuses dirty checkouts or missing commit evidence. If the run records a synced tree, it must equalHEAD^{tree}; otherwise its recorded source SHA must equalHEAD. The run must exist, belong to the cited Workflow, pass, and use its current revision. Attach requires a GitHub-delivered application; upload-delivered applications cannot supply this proof. -
After proving, commit any remaining changes and push the branch. If those commits change the application or Workflow tests, return to step 4 and prove them before proceeding. Open a DRAFT pull request and note its number
<n>; attach needs that PR number. -
Write concise numbered acceptance criteria. A criterion is one user-visible outcome in plain product language, at most 15 words, for example "An external run started with triage off stays off". Write the criterion,
--textand--assertedin product language a reviewer understands: what the user sees or what the product does. Leave out field names, column names, flags, IDs, UUIDs, SHAs and code identifiers; the reviewer reads them in the PR and cannot interpret them. For example:textBad: an API-launched external run reads back triageEnabled=false Good: An external run launched with triage turned off stays off.
A criterion states what the user can now do or see, never what was removed. "The old Apply button is gone" and "the page no longer shows Y" describe the change, not lasting behaviour, so do not write them as criteria in a test that will be promoted. State what is there now:
textBad: The old Apply button is gone from Settings Good: Settings shows one Save button, and saving applies the change
If a reviewer needs to see a removal, use a screenshot in the pull request body (no criterion), or give the absence assertions their own Workflow set to
--promote-on never, so they are discarded. Never put them in the same Workflow as lasting assertions. One run may support several criteria; multiple runs may support one criterion. For each evidence item, use the most specific node or assertion ID available and state what it checked in--asserted, without an "Asserted that" prefix. Omit optional--nodeonly when there is no specific ID. A performance run can prove a criterion too, and one criterion can mix kinds: for a query change, attach a Workflow run for the behavior and a performance run for the speed on the same criterion number. Run it at the pushed head SHA and attach it with--perf-run <prun_...>; one criterion can carry several runs, and every attached item must pass. A performance run must be completed, compare different base and head commits, and be at the commit you attach; a slower result is refused. Attach a new run at the current head, then detach an older stale item when the criterion should become proved again.An agent eval run can prove a criterion as well (a change to an agent's behavior): attach it with
--eval-run <aerun_...>. It must be a full run (every case at its repeats), completed, passing its pass bar, and measured at the commit you attach; a partial, failing or other-commit run is refused. One criterion can carry any number of eval runs, each with its own model, and every one must pass. -
After the draft PR exists, attach evidence. The server refuses a new criterion number without
--text; reuse the same text for additional evidence on that number.--detailis no longer needed or shown. The same product language applies to--textand--assertedhere (step 6):bashcofactor proofs attach --pr <n> --application <app> --criterion <n> --text "<criterion>" --test <wf_...> --run <wrun_...> [--node <most-specific-id>] [--base <sha>] --asserted "<what was checked>" --org <org>
For performance evidence, use
--perf-runinstead of--testand--run:bashcofactor proofs attach --pr <n> --application <app> --criterion <n> --perf-run <prun_...> --asserted "<what was checked>" --org <org>
For an eval run, use
--eval-runin the same place:bashcofactor proofs attach --pr <n> --application <app> --criterion <n> --eval-run <aerun_...> --asserted "<what was checked>" --org <org>
An existing test (a Regression Workflow that is not a fork) is attached the same way; the result says
"existing": true.When
--text,--asserted,--notesor--not-provedcontains something that looks like a code identifier or an id (a name liketriageEnabled=false, a UUID, awf_…orwrun_…id, or a commit SHA), attach still records the evidence and prints awarning:line naming the token. Reword the text in product language and attach again.Attach exactly one evidence subject per command. A test containing any
visual_checkpointnode is a UI test, including a test that also has other steps. Attaching it runs the same test at the PR base commit and the proof page shows each checkpoint's base, head, and diff. When--baseis omitted, the CLI usesgit merge-base HEAD origin/<default>when that ref is available. Put checkpoints before steps that depend on the new behavior so the base run can reach them. -
Push first, then render the criteria block:
bashcofactor proofs render --pr <n> --org <org>
The output already includes the markers. Paste the entire output into the PR description, verbatim, replacing any existing proof block. Never hand-format or edit it, and do not add a prose "Proof notes" section that restates it. It looks like this:
markdown<!-- cofactor:proof --> **Proof of acceptance criteria** · [View all proofs in Cofactor](<proof page>) 🟢 2 proved (1 stale) · ⚪ 1 checked another way · 🟡 1 not proved · as of [`a1b2c3d`](<commit page>) | | Criterion | Evidence | | --- | --- | --- | | 🟢 | The saved filter stays selected after a reload | [Filter bar keeps its selection](<run page>) · E2E in a sandbox — the Status filter still shows "Open" after a reload.<br>[Filter survives a page refresh](<run page>) · E2E in a sandbox — the filter is still applied after a hard refresh. | | 🟢 stale | The list query is no slower | [Performance run (prod)](<perf run page>) — no slower than base.<br>Stale: proved at [`9f8e7d6`](<commit page>) | | ⚪ manual | The desktop client shows the badge | Checked another way — opened the desktop build and checked the badge. | | 🟡 not proved | Very large exports finish | No data set is large enough here; the nightly load job covers it. | _🟢 proved · ⚪ checked another way · 🟡 not proved · 🔴 failed. A snapshot; the live verdict is the `cofactor / proofs` check._ <!-- /cofactor:proof -->
The block is one table, and every criterion is in exactly one state: 🟢 proved by Cofactor (a passing run, visual diff, perf or eval; "Stale" means it was proved at an earlier commit), ⚪ checked another way (you say how, with links), 🟡 not proved (you say why), or 🔴 failed. The check passes on proved and checked another way; not proved is a warning, not a failure, so say so honestly. A criterion is one row: its dot, the criterion, and one evidence line per item (the test's user goal as the link to its run, how it ran, then what was checked). Write the criterion as one short sentence of user-visible outcome and
--assertedas one sentence saying what was observed on screen or in the response, without repeating the criterion and without an "Asserted that" prefix; the block adds the join. Keep each criterion at most 15 words. The block is a snapshot as of the commit in its header: it goes stale after a push, and the live verdict is thecofactor / proofscheck and the proof page. After every push, attach, or detach, render again and replace the block. Context for a reviewer goes in the--assertedtext, not in a paragraph in the PR body. -
Inspect or revise the proof:
bashcofactor proofs status --repo <owner/repo> --pr <n> --org <org>
The repo is inferred from
GITHUB_REPOSITORYorgit remote get-url originand can be overridden with--repo. Detaching removes a criterion and all evidence attached to it:bashcofactor proofs detach --pr <n> --criterion <n> --org <org>
Remove just one item with
--test <wf_...>,--perf-run <prun_...>or--manual:bashcofactor proofs detach --pr <n> --criterion <n> --perf-run <prun_...> --org <org>
--eval-run <aerun_...>removes one eval run the same way.Render again and replace the PR proof block after every attach or detach.
WRITING REVIEWERS CAN SCAN
A criterion names one user-visible outcome, at most 15 words. Use plain product
language with no file, function, flag or implementation names. --asserted is
one sentence saying what was observed on screen or in the response. --steps
uses short imperative sentences, at most 12 words each, that a non-engineer can
follow. Name the visible control and result; avoid explaining code.
Good example 1:
- Criterion: Saved filters stay selected after a reload.
- Asserted: The Status filter still shows Open after reloading the page.
- Steps: Select Open in Status. Save the filter. Reload the page. Check Status shows Open.
Good example 2:
- Criterion: Acme members can download their invoices.
- Asserted: The downloaded invoice shows the selected month and total.
- Steps: Open Billing. Select an invoice. Choose Download. Check the month and total.
Bad example 1:
- Criterion: FilterState.tsx hydrates useFilterState with persistFilters enabled.
- Asserted: The implementation is correct and all the changes work.
- Steps: I exercised the complete persistence implementation and confirmed everything looked good.
Bad example 2:
- Criterion: invoiceDownloadHandler calls serializeInvoice and returns the new payload.
- Asserted: Asserted that the new endpoint implementation passes.
- Steps: Inspect the service internals and execute the appropriate helper functions.
KEY MOMENTS
For each native test, pick 2–5 key moments when attaching evidence: the action that matters and the visible result proving the criterion. Inspect the run's ordered steps and look at each screenshot before you choose:
cofactor proofs moments <wrun_…> --org <org> cofactor proofs moments <wrun_…> --json --org <org>
Each moment cites a node with a screenshot from that run. Reviewers see the moments as numbered screenshots in a row, each with your one-sentence caption, and open any of them full size. Write one present-tense sentence describing what the screen shows, at most 20 words and 140 characters. Good: "The saved filter shows only open requests after a reload." Bad: "Executed the persistence code path and validated the implementation."
cofactor proofs attach --pr <n> --application <app> --criterion <n> --text "Saved filters stay selected after a reload" --test <wf_…> --run <wrun_…> --asserted "Status still shows Open after a reload." --moment "<save-node>=The saved filter shows Open." --moment "<reload-node>=Status still shows Open after a reload." --org <org>
The API accepts 1–5 moments. Repeat --moment "<nodeId>=<sentence>" for each.
Attaching the same test again replaces its moments, so repeat every moment you
want to keep. Reattaching without --moment clears all previously attached
moments. Old evidence without moments keeps its video. The full video stays
behind "Watch full video" on the proof page.
OVERVIEW
After attaching the first criterion, write a proof overview: 1–3 sentences (600 characters maximum) explaining what changed for the user. Avoid implementation details and do not restate every criterion. Example: "Acme members can save a request filter and return to the same view after a reload. Shared links keep the selected status so teammates see the same requests."
cofactor proofs overview --repo <owner/repo> --pr <n> --summary "Members can save a filter and return to the same view after a reload." --org <org>
The proof page renders a Mermaid diagram under the summary. You write it and
attach it with --diagram <file.mmd>. Add one only when a picture explains the
change faster than the sentence does, at most 12 nodes. Start the file with the
diagram type that fits:
flowchartfor a user journey or a branching decision.sequenceDiagramfor an interaction between the user, the app and a service.stateDiagram-v2for a status or lifecycle change.erDiagramfor a data model change.
graph (the older flowchart), stateDiagram and journey are also accepted;
prefer the four above.
flowchart LR Choose[Choose a status] --> Save[Save the filter] Save --> Reload[Reload the page] Reload --> Selected[The saved status stays selected]
sequenceDiagram participant Member as Acme member participant App as Acme app participant Billing as Billing service Member->>App: Choose Download on an invoice App->>Billing: Request the invoice Billing-->>App: Invoice for the selected month App-->>Member: Download starts
stateDiagram-v2 [*] --> Draft Draft --> Sent: Send invoice Sent --> Paid: Payment received Sent --> Overdue: Due date passes Overdue --> Paid: Payment received Paid --> [*]
erDiagram
CUSTOMER ||--o{ INVOICE : receives
INVOICE ||--|{ LINE_ITEM : lists
INVOICE {
string status
date due_date
}
Rules:
- Write node labels in product language, as a user would say them. No file, function or class names.
- Do not add colours,
classDef,styleor%%{init}directives. The page applies the brand styling, and your overrides would fight it. - If the diagram cannot be rendered, the page shows its source instead, so check that it parses before you attach it.
cofactor proofs overview --repo <owner/repo> --pr <n> --summary "Saved filters survive a reload." --diagram filter.mmd --org <org>
Running again replaces the summary and diagram; omitting --diagram clears the
previous diagram. Until an agent writes it, the overview is absent. Mermaid
source is limited to 8000 characters, starts with a supported diagram keyword,
and cannot contain HTML comment markers.
STEPS FOR EXTERNAL TESTS
For a native Workflow run, reviewers see the key moments you pick (KEY MOMENTS),
not a list of steps. --steps is shown only on external test evidence, under
the test's result, so pass it there and rely on --moment for Workflows.
When you attach an external test result, also pass --steps: what the test
does, in plain sentences, one per line, written by you from the run you
watched. Write short imperative sentences, at most 12 words each. One step per
action or check, in the order it happened, in the language of the product:
cofactor proofs attach ... --steps @steps.txt --org <org>
where steps.txt holds:
Open the cart. Add two items. Check that the total reads $40.
Pass the text directly instead of a file if it is short. Attaching again
replaces the evidence, steps included, so pass --steps again whenever you
re-attach. A re-run from the proof page keeps your steps.
WHEN COFACTOR CANNOT PROVE A CRITERION
A criterion Cofactor cannot prove is either checked another way or not proved. Checked another way (manual evidence) is for a criterion Cofactor cannot exercise at all (for example it needs a desktop client, real hardware or a third-party console). If the criterion is plainly outside a browser or a sandbox, go straight to it; otherwise try a Cofactor test first. A failing, flaky or hard-to-write test is never a reason for manual evidence: fix the test or the change, and never detach failing evidence to replace it with manual evidence.
Say what you did and why Cofactor could not prove it, from a clean checkout at the pushed commit:
cofactor proofs attach --pr <n> --application <app> --criterion <n> --text "<criterion>" --manual --notes <text|@file> [--artifact <https-url>]... --org <org>
Notes (up to 10,000 characters) and links (up to 20) are shown to everyone
who can read the proof: keep notes to what you did and why, and redact
secrets, tokens and customer data from anything you link. Links must be
https URLs reviewers can open, never signed or tokenized links and never
with credentials (an image attached to the pull request works; where your
organization has Cofactor utilities, cofactor utilities object upload <file> --public --json returns one).
A criterion holds one manual item, and attaching again replaces its notes
and links, so pass the same --notes and every --artifact again. A
criterion whose only evidence is manual passes the check with 📝 and
[manual], renders ⚪ Checked another way in the block, and shows your notes
on the proof page; a criterion that mixes manual with other kinds
keeps its stoplight and is decided by its other items. Manual evidence never promotes
anything and reads stale after a push; attach it again at the new head.
When you did not check a criterion at all, or could not, say why instead of leaving it out or inventing evidence:
cofactor proofs attach --pr <n> --application <app> --criterion <n> --text "<criterion>" --not-proved "<why it is not proved>" --org <org>
It renders 🟡 Not proved with your reason and is a warning on the check, never a failure. Use it only on a criterion with no evidence (detach evidence first); attaching evidence to the criterion later replaces it. Write the reason in product language, like the criterion.
CHECKS AND STALE EVIDENCE
The App publishes cofactor / proofs; the Actions job reports the same server
verdict. Diagnose with a body file:
cofactor proofs check --pr <n> --sha <head> --body-file <file> --org <org>
Or pass --body - for stdin. The App queues a refreshed check after attach
or detach. In the Actions path, rerun the check job after attaching or
detaching. Successful stale evidence remains successful and is
marked stale. Use Re-run on the Cofactor proof page for stale E2E evidence at
the PR head. For stale performance evidence, run it at the new head, attach
that run and detach the old item. Cofactor does not rerun automatically. Server and CI own promotion
triggers; cofactor trigger is not your job.
No block means no proof check; a block with no criteria fails. When the pull request has no observable acceptance criterion at all (for example a dependency bump or a docs-only change), print the neutral block and paste it in place of any proof block:
cofactor proofs render --none "<why this pull request has no criterion to prove>"
It reports a neutral result. A criterion that only Cofactor cannot exercise gets manual evidence instead (above).
CURATING THE SUITE
Every promoted test runs from then on, so keep the suite worth running:
- Reuse first: attach the run of an existing test or eval that already proves the criterion before creating one.
- Extend an existing test instead of duplicating its journey with a new one.
- One test per user goal, named for that goal (what the user accomplishes, not the component or the ticket).
- Promote lasting behaviour whose regression would matter.
- Set a Workflow to
--promote-on neverwhen its proof is about the change itself: a one-time migration, backfill, redirect or flag rollout step, behaviour about to be removed, or a one-off visual before/after of a redesign, or assertions that something was removed ("X is gone", "no longer shows Y"). - Never mix absence assertions into a Workflow that will be promoted: it
would carry them into the regression suite. Keep them in their own
--promote-on neverWorkflow. - Perf and eval runs never join a suite through proofs: a perf A/B or an eval experiment for one decision stays a run. Save a perf test only for a hot path (see the perf guide).
- Don't keep a test nobody would miss if it disappeared.
WHAT GOES IN THE PULL REQUEST
Paste the output of proofs render and nothing that restates it: no "Proof
notes" section. If a reviewer needs to know why a Workflow was forked or what
stays uncovered, say it once in the --asserted text, or make it a
criterion that is checked another way or not proved.
Use neutral example names and never include customer names, domains, or credentials. Merging the pull request applies each Workflow's promotion setting; do not add the Workflows to Regression yourself.