Skip to the lesson
CivOps AI Academy · F17Prove It Works: the Complete Testing Protocol, Journeys and Conformance
0%

Chapter 1 · Session 19

One protocol for every gate

By now the platform has tests in many places: the schema tests from Session 5, the access tests from Session 8, the security suite from Session 18 and more. This chapter writes them down as one protocol, gate by gate, and then checks that each test proves what it claims, because a test that cannot fail is worse than no test at all.

35 min2 stepsdocs/testing-protocol.md

By the end of this chapter you can

  • Say why a written protocol, not "all tests pass", is the evidence that the platform works.
  • Have Claude Code draft docs/testing-protocol.md from what exists: every gate, what it proves, how to run it, when, who signs.
  • Audit the tests: rewrite any that only check a word is present, and show a sample of them failing.

Why one written protocol

"All tests pass" is a claim, and claims are cheap. We recorded an agent run that printed npm: not found, and ten minutes later the same job reported 1,326 tests passing. A protocol replaces the claim with a list anyone can check: each gate, what it proves, the exact command or workflow that runs it, when it runs, where its latest result is on GitHub, and who signs it. It is also what IT reads in Session 21, and what lets someone else run the platform in Session 23.

Every gate below exists because we, or the CivOps platform before us, shipped without it once. Most of them you have already built; this session writes them into one page, adds the few that are missing, and proves each one can fail [1].

GateWhat it provesBuilt inRuns
Schema protocolThe migrations alone rebuild the database; every table has a primary key and row-level security; bad rows are refused; history cannot change; names follow the standardSession 5Every pull request (schema)
Seed is current and correctMade-up data is shifted onto today, marked synthetic, never in productionSession 6Every pull request
Access tests per matrix cellOne allowed and one refused test for every role and table, plus another siteSession 8Every pull request (schema)
Default deny on every route, both waysSigned out and forged cookies refused, each role allowed exactly what the matrix gives, public pages still open, an unlisted route failsSessions 9 and 18Every pull request (security)
Refused role for every destructive or admin actionDelete, approve, release and settings refused for every role the matrix does not name, wherever the code livesSessions 8 and 9Every pull request
Lint, type check and unit testsNo type error or failed unit test reaches mainSessions 3 and 10Before every commit and every pull request (ci)
The ten clamps, required checks, CODEOWNERSNothing merges red; sensitive folders need a named reviewerSession 10Every pull request (clamps)
Production has every migrationThe live database matches mainSession 11On merge, and daily
Backups, and a restore drillA backup restored to a copy works, counts within 1%, timed, signed by a second personSessions 11 and 23Nightly; drill quarterly and before each customer install
Security suite (OWASP Top 10)Every risk in docs/owasp.md has a test; demo switches dead in production; no secret in the browserSession 18Every pull request, and weekly with the live site checked signed out
Show it red firstEvery new test was seen failing with its protection removedSession 18Every pull request that adds a test
Screens at phone sizeEvery screen works at 360 and 390 px, 44 px targetsSession 12Every pull request
End-to-end journeys and failure pathsA lot goes from first piece to release on a phone; each thing that goes wrong ends in a clear message and the right recordThis sessionEvery pull request (e2e)
Whole-site sweep, per roleEvery page opens for every role with no crash, failed call or dead linkThis sessionNightly
Nightly production check with a must-not-exist addressLive pages exist, protected pages refuse, a fake address is 404, the alarm reaches a personSessions 11 and 18, finished hereNightly
ConformanceEvery line of the intent and every role has a criterion, a test and today's resultThis sessionEvery pull request; signed by the decision-maker
Step 1

Draft the protocol from what exists

15 minutes

Why

Claude Code can read every test file and workflow in minutes; you cannot. Asking it to write the protocol from what is really there, gate by gate, with the latest result taken from GitHub rather than from its own memory, gives you an honest page: what is proven, what is missing, and what could not be measured. The gaps it finds are the work for the rest of this session.

Do this

Paste into Claude Code
Read every file in .github/workflows/, supabase/tests/, tests/, every other test file, package.json's scripts, .claude/settings.json, docs/clamps.md, docs/owasp.md and docs/runbook.md. Do not change any code.

On a new branch tests/protocol, write docs/testing-protocol.md: the complete testing protocol of this platform, for someone who does not write code. One row per gate, in this order: the schema protocol (rebuild from nothing, row-level security on every table, primary keys, bad rows refused, history unchangeable, names to the standard); seed current and correct; access tests per matrix cell and another site; default deny on every route both ways; refused role for every destructive or admin action; lint, type check and unit tests; the clamps, required checks and CODEOWNERS; production has every migration; backups and the restore drill; the security suite; show it red first; screens at phone size; end-to-end journeys and failure paths; whole-site sweep per role; nightly production check with a must-not-exist address; conformance; and, marked "not needed yet, and when to add it", email honesty and build memory headroom. Also check that .claude/settings.json still denies db push, db reset, push to main and vercel --prod, and list that as a gate.

For each gate give: what it proves in one sentence; the files and the workflow and job that run it; the exact command to run it by hand; when it runs (every pull request, before commit, nightly, weekly, quarterly); whether it is a required check on main; who signs (owner one, owner two, or the decision-maker); and its latest result with the link to the run on GitHub.

Rules:
- Take every result from GitHub (gh run list, gh run view), never from memory or a summary. If a gate has not run, or you cannot tell, write "could not measure" and why. Never "passed".
- A gate with no test yet is "missing", with one sentence on what the test must do.
- Never read a test's exit code through a pipe.

Open a pull request titled "Testing protocol" and give me the counts: gates proven, missing, could not measure.

You will see recreated screen

claude — acme-platform
⏺ Bash(gh run list --branch main --limit 40)
⎿ 40 runs: ci, schema, clamps, security, deploy, freshness, backup, security-weekly
1
⏺ Write(docs/testing-protocol.md)
+| Gate | Proves | Runs it | When | Required | Signs | Latest |
+| Schema protocol | migrations rebuild the database; bad rows refused | schema.yml / supabase test db | every PR | yes | owner two | passed, run 8851 |
+| Security suite | every OWASP risk has a test | security.yml / npm run test:security | every PR, weekly | yes | owner two | passed, run 8853 |
+| End-to-end journeys | a lot goes from first piece to release | missing | | | | missing |
+| Restore drill | a backup restores to a copy | docs/runbook.md, by hand | quarterly | no | second person | could not measure: never run |
2
⏺ Pull request #47 adds docs/testing-protocol.md: 19 gates. 13 proven by a green run on main, 4 missing (end-to-end journeys, failure paths, whole-site sweep, conformance), 2 could not measure (the restore drill has never been run; the nightly production check has no must-not-exist address). Email honesty and build memory headroom are not needed yet.3
Claude Code reads every workflow and test, takes each result from GitHub, and reports honest counts.
  1. Results come from GitHub's own record of runs, not from what Claude Code remembers.
  2. One row per gate: what it proves, how it runs, when, whether it is required, who signs, the latest result.
  3. Honest counts. The four missing gates are this session's work; the restore drill is Session 23's.

Check it worked

Pull request Testing protocol adds docs/testing-protocol.md with one row per gate, each with a command, a schedule, a signer and a latest result linked to a run on GitHub, or marked missing or could not measure.

Fastest path

Merge the draft protocol now, gaps and all. Every later step in this session updates a row, so the page always says what is true today.

If it goes wrong

The protocol says everything passed, with no links

Say: For every gate you marked passed, give me the link to the run on GitHub, the commit it ran on and how far that commit is behind main. Anything without a run on the latest main is "could not measure". A result about an old commit is not a result about today's code.

A result counts tests from a command piped into tail or head

The pipe's exit code is tail's, not the tests', so a red suite reads green. Our main branch went red for exactly this reason in a deploy script. Say: Run it without a pipe and give me the test command's own exit code. Add set -o pipefail to the top of every shell script in the repository.

It marks a gate passed because a workflow file exists

A workflow file is not a result. Say: Only a completed run on main counts. Show me the run.

A test must prove behaviour, and must be able to fail

Two kinds of test look like proof and are not. The first checks that a word appears in the code: our platform found three in one night's work that searched a file for a function's name, and passed while the feature they guarded was broken. The second can never fail: a probe of our live site reported 350 pages present and 0 absent, because the site answered 200 for every address, real or not. Both stay green for ever. The cure for both is the same check from Session 18: break the thing on purpose and watch the test go red [2].

A test that can failFour steps: test passes, break the rule, the test must fail, restore the rule; a test still green when the rule is broken is not testing it. Before you trust a test, watch it fail for the right reason1Test passesrule in place2Break the rulee.g. remove the role check3Test must failred proves it checks therule4Restoregreen again; commit nothingfrom step 2Still green at step 3? The test was not testing the rule.
A test that can fail. Red at step 3 proves the test is tied to its rule. Green there means it is not, and must be rewritten.
Step 2

Audit the tests themselves

20 minutes

Why

The protocol is only as good as its tests. Asking Claude Code what behaviour each test proves finds the ones that only check a word is present, and planting a few defects on a throwaway branch shows whether the rest can fail. Doing it for a sample of every gate takes one CI run; finding out the day a real fault slips past takes much longer.

Do this

Paste into Claude Code
Read docs/testing-protocol.md and every test it lists.

1. On a new branch tests/audit: for each test file, list in plain words what behaviour it proves. Any test that only checks that a name or word appears in a file, or only checks a response code without checking what was stored or shown, rewrite to call the code or the route and check the result (what the user sees, or what the database holds afterwards). Add set -o pipefail to every shell script. Push, open a pull request titled "Tests prove behaviour", wait for every check, and report what you rewrote and why.

2. Then, from main, on a throwaway branch tests/red-first-do-not-merge, plant one defect per gate, one commit each, without changing any test:
   - a migration that lets the holds table be updated (schema);
   - a matrix role given a right it should not have in the generated policies (access);
   - lib/access/routes.ts marking /supervisor/review as public (default deny);
   - the release action accepting a release by the person who held the lot (failure paths, once they exist);
   - the dashboard's hold-time measure off by one hour (conformance, once it exists).
   Open it as a DRAFT pull request titled "DO NOT MERGE: red-first check of the protocol", wait for the checks, and give me a table: defect, the tests that failed, and any defect that turned nothing red. Then close it without merging and delete the branch here and on GitHub.

Update docs/testing-protocol.md with the date of this red-first check, and any gate whose defect turned nothing red as "cannot fail: fix".

You will see recreated screen

claude — acme-platform
⏺ tests/review.test.mjs "reject needs a reason" only checked that actions.ts contains requireReason(. It now submits a reject with no reason through the route and checks the record is still pending in the database.1
⏺ Red-first, draft pull request #49: holds updatable → schema: 3 failed (history cannot change) extra right for operator → schema: 2 failed (access cell operator/holds/insert) /supervisor/review public → security: 4 failed (default deny) release by holder, hold time off by an hour → not planted yet: the journeys and conformance tests come in Steps 4 and 6.2
⏺ Bash(gh pr close 49 --delete-branch)
⎿ ✓ Closed pull request #49 and deleted branch tests/red-first-do-not-merge
The audit finds a test that only checked a word, and the red-first run shows which gates can fail.
  1. A test that checked a word, rewritten to check behaviour: the route is called and the database is read afterwards.
  2. Every planted defect turned a gate red. The last two wait until their tests exist; they are planted again in Step 7.

Check it worked

Pull request Tests prove behaviour is merged; the red-first draft pull request showed each planted defect turning a gate red and is closed unmerged; docs/testing-protocol.md records the date.

If it goes wrong

A planted defect turned nothing red

That gate cannot fail as written. Say: Defect <n> turned no test red. Write the test that catches it, show it failing against that defect on a throwaway branch, and open a pull request with the test. Then mark the gate fixed in the protocol.

Claude Code changes a test on the red-first branch

Say: Do not change any test on this branch. Revert that and report the failures as they are. The point is to see the tests as they are on main.

Claude Code says it rewrote a test, and the old one is gone with no new one

Read the Files changed tab, not the summary. Say: List every test this branch removed or skipped, and why. Never remove, skip or loosen a test without asking me.

Knowledge check

Claude Code reports "1,326 tests passed". What makes that evidence?

Knowledge check

A test searches proxy.ts for the word 'deny' and passes. What is wrong with it?

References

  1. NIST SP 800-218, Secure Software Development Framework (SSDF) Version 1.1. https://csrc.nist.gov/pubs/sp/800/218/final
  2. Stryker Mutator: mutation testing (planting defects at scale). https://stryker-mutator.io/
  3. GitHub CLI manual: gh run. https://cli.github.com/manual/gh_run

Chapter 2 · Session 19

Journeys, and the things that go wrong

Each part of the platform has been tested on its own. A journey test drives the real app in a browser at phone size, through a whole decision, as each person in turn. Failure-path tests do the same for each thing that goes wrong on the floor, and check that it ends in a clear message and the right record.

40 min3 stepsPhone size, made-up data

By the end of this chapter you can

  • Have Claude Code write end-to-end journeys for the stamping plant's decision, at phone size, on a throwaway database.
  • Write a failure-path test for each thing that goes wrong, checking both the message and the database.
  • Add a nightly whole-site sweep per role and finish the nightly production check with a must-not-exist address.

The shape of the suite

Fast, small tests carry the detail; a few slow browser tests prove the journeys join up. Keep many of the first and few of the second, so the whole suite still runs on every pull request [1][2].

The test pyramidEnd to end (browser, phone sizes): 24 tests, ≈ 3 min; Integration (API + database + access rules): 70 tests, ≈ 40 s; Unit (rules, money, measures): 180 tests, ≈ 8 s An example suite for the plant platform: many fast tests at the bottom, a few slow ones on topEnd to end (browser, phone sizes)24 tests≈ 3 minper runIntegration (API + database + access rules)70 tests≈ 40 sper runUnit (rules, money, measures)180 tests≈ 8 sper runEvery layer runs on every pull request; the slow layer stays small by testing journeys, not every case
An example suite for the plant platform. The journeys and failure paths are the top layer: few, slow, and the only tests that see what a person sees.

The journeys

JourneyWho, in orderMust end with
Die changeOperator records first-piece results on a phone → a value outside the part's limits is flagged → quality lead holds the lot, with a reason → after a re-check, a different person releases it → manager view shows the lot released and the hold timelot_status released; two rows in holds; the hold time on the dashboard matches a hand-worked value
Hourly check, offlineOperator loses the network, saves an hourly gauge result, the network returnsThe result arrives exactly once
ReviewSupervisor rejects a record with a reason; the operator sees why and corrects itThe original and the correction both kept, the correction pointing at the original
Step 3

End-to-end journeys at phone size

15 minutes

Why

Every unit test can pass while the journey fails at a join: the operator's save never reaches the quality lead's list, or the release button works for the wrong person. A journey test drives the real app in a browser at 390 px, as each role in turn, on a throwaway database with made-up data, and checks the database at the end. Writing all three in one prompt, with the same sign-in helpers the security suite uses, gets them in one round.

Do this

Paste into Claude Code
Read docs/INTENT.md, docs/matrix.json, docs/measures.md and docs/testing-protocol.md, and look at how tests/security/setup.mjs prepares the CI database and signs in each role. Reuse it; do not copy it.

On a new branch tests/journeys, add end-to-end tests with Playwright in tests/e2e/, at a phone size of 390 by 844, on the CI database only (the local Supabase that GitHub Actions starts, with the seed; never acme-platform-prod or acme-platform-dev). Use made-up data relative to today, so the tests do not age.

1. Die change: an operator records first-piece results for a lot on press P-03; one value is outside the part's limits and is flagged; the quality lead holds the lot with a reason; a different person releases it after a re-check; the manager view shows the lot released and its hold time. At the end, check in the database: lot_status is released, holds has two rows with the right people and reasons, and the hold time shown matches the value worked by hand in docs/measures.md.
2. Hourly check, offline: the operator's browser goes offline, saves a gauge result, comes back online; the result is stored exactly once.
3. Review: the supervisor rejects a record with a reason; the operator sees the reason and corrects it; both rows are kept and the correction points at the original.

Each journey follows every message a person would see, and fails on any console error or failed request. Add .github/workflows/e2e.yml, with a job named e2e, on every pull request: start Supabase, prepare the data, build and start the app, run the journeys, and keep Playwright's report and screenshots as an artifact. Update docs/testing-protocol.md.

Push, open a pull request titled "End-to-end journeys", wait for the e2e check, and tell me in plain words what each journey did and how long it took.

You will see recreated screen

claude — acme-platform
⏺ Write(tests/e2e/die-change.spec.ts)
+await asRole(page, "operator");
+await page.getByRole("button", { name: "Record first piece" }).click();
+await page.getByLabel("Flange height (mm)").fill("12.31");
+await expect(page.getByText("Outside limits")).toBeVisible();
+// ... quality lead holds, a different person releases ...
+expect(await db.lotStatus(lot)).toBe("released");
1
⏺ Bash(gh pr checks --watch)
⎿ e2e pass 4m21s security pass 7m10s
⏺ Pull request #50 is green. Die change: 9 screens, operator to manager, 38 s; the hold time shown (2 h 14 min) matches the hand-worked value in docs/measures.md. Offline: the result was stored once after reconnecting. Review: the reject reason reached the operator and both rows are kept.2
Claude Code writes the three journeys and waits for GitHub to run them in a real browser.
  1. The test uses the screen as a person does: labels and buttons, at phone size, then checks the database.
  2. Each journey in plain words, with the database checked at the end, not just the last screen.

You will see recreated screen

github.com/acme-ops/acme-platform/actions/runs/8870
Summarye2esecurity
1
JourneyResultTime
die change: first piece to releasepassed38 s
hourly check offline, stored oncepassed21 s
review: reject with reason, correctedpassed26 s
Artifactsplaywright-report · screenshots-390
Playwright's report, downloaded from the e2e check: each journey and how long it took.
  1. Three journeys. The screenshots are what an operator saw at each step.

Check it worked

Pull request End-to-end journeys is green with an e2e check whose report shows the three journeys passed, and the die-change journey's hold time matches the hand-worked value.

If it goes wrong

A journey fails some days and passes on others

Usually time: the made-up data was dated, and as it ages the lots fall out of today's screens. We had a dashboard go blank this way. Say: Make every date in the journey's data relative to now, and give each test its own lot so order does not matter. Never mark a flaky test optional.

The journey passes, but the record is wrong in the database

A screen saying "Saved" is not a saved record. Say: After each action, read the row from the database and check its values, not just the message on screen.

The browser lands on the sign-in page in the middle of a journey

The test user's session was not set up for that role, or it expired. Say: Sign in each role with the helper from tests/security/setup.mjs at the start of its part, and fail with "could not sign in" instead of continuing.

The things that go wrong

Most real failures live on the unhappy path, and agents tend to test only the happy one. Each row below is something that happens on a stamping floor, or happened to us. Each test checks two things: the person sees a clear, true message, and the database holds the right record afterwards.

Failure pathMust seeWhy it is here
Reject or hold with no reasonRefused; the record stays as it wasThe rule from Session 5, now proven through the screen
Release by the person who held the lotRefused, with who may releaseThe quality lead's rule from Session 5
Double tap on SaveOne row, not twoGloves and slow networks
Session expires mid-entryThe entry is kept, sign in, saved onceA shift is longer than a session
Network drops during saveKept on the phone, sent once when backThe operator surface works offline (Session 12)
Another site's lot number typed inNot found, never the recordSession 18's changed-id test, from the screen
A key missing or wrong at start-upA plain message naming the setting, never its valueWe had a key whose value was its own name pasted in, and sign-in emails silently never arrived
A stand-in service in productionRefuses, never claims successWe had a Send button mark every recipient "sent" while no email left
No data for a measure"No data", never 0We had a chart grade twelve invented points "In control" on 87 screens
A server errorA page with a way back, no stack traceSession 18's A10 test, from the screen
Step 4

A test for each thing that goes wrong

15 minutes

Why

Each of these failures happens on the floor every week, and each one, untested, has a cheerful default: a duplicate row, a lost entry, a zero where nothing was measured, "sent" when nothing was. One prompt with the full list gets every failure-path test in one pull request, each checking both the message and the database, and fixes what they find with the test that proves it.

Do this

Paste into Claude Code
Read docs/testing-protocol.md and tests/e2e/. On a new branch tests/failure-paths, add Playwright tests in tests/e2e/failure-paths.spec.ts, at 390 by 844, on the CI database, one per failure below. Each checks the message the person sees AND the row in the database afterwards (or that no row was written):

1. A reject or a hold with no reason is refused; the record stays as it was.
2. A release by the person who held the lot is refused, and the message says who may release.
3. A double tap on Save writes one row, not two.
4. The session expires in the middle of an entry: the entry is kept, the person signs in again, and it is saved once.
5. The network drops during a save: the entry is kept on the phone and sent once when the network returns.
6. Another site's lot number typed into the lot search: "not found", never the record.
7. A missing or malformed key at start-up (run the app once with NEXT_PUBLIC_SUPABASE_URL blank, once with it set to its own name): a plain message naming the setting, never its value.
8. Any stand-in service (email, files, AI) in production refuses with a clear message instead of reporting success.
9. A measure with no data shows "No data", never 0.
10. A server error shows a page with a way back, and no stack trace or SQL.

If a test fails because the app really does the wrong thing, keep the test, fix the app in this pull request, and tell me what was wrong. Add the file to the e2e job, update docs/testing-protocol.md, push, open a pull request titled "Failure paths", wait for the checks and report each path's result.

You will see recreated screen

claude — acme-platform
⏺ Bash(gh pr checks --watch)
⎿ e2e pass 6m02s
⏺ Pull request #51 is green: 10 failure paths. Two found real problems, now fixed: a double tap on Save wrote two inspection rows (the button now disables and the insert carries a request id, so a repeat is ignored); and the hold-time widget showed 0 h when a lot had never been held. It now shows "No data".1
⏺ Each test checks the database afterwards. For path 4 the entry survived the expired session and was saved once, after sign-in.2
Ten failure paths; two found real problems, fixed with their tests.
  1. Real problems found by the tests, fixed in the same pull request, each now guarded.
  2. The database is checked, not just the screen. A message alone can lie.

Check it worked

Pull request Failure paths is green; its report lists ten failure paths, each passed; any problem found is fixed with its test in the same pull request.

If it goes wrong

A test checks only the message on screen

Say: For every failure path, also read the database afterwards and check what was or was not written. A button that claims success while nothing happened passes any test that only reads the screen.

Claude Code skips path 8 because there are no stand-ins

Good, if true. Ask: List every external service the app calls (email, file storage, AI, payments) and what it does when that service is not configured in production. Anything that returns success without doing the work is a stand-in.

Step 5

A nightly sweep, and a production check that can say "no"

10 minutes

Why

Journeys cover the main paths; a sweep opens every page, as every role, and records any crash, failed call or dead link. On our platform a sweep opened 424 static and 139 dynamic pages and found what no journey had: links that compiled and went nowhere, and shared services a redesign had dropped. The nightly production check from Session 11 needs one more thing: an address that must not exist, so it can tell "present" from "answers everything", and an alarm someone has heard.

Do this

Paste into Claude Code
On a new branch tests/sweep:

1. Add tests/e2e/sweep.spec.ts and a nightly workflow .github/workflows/nightly.yml (03:17 UTC, and by hand): on the CI database, sign in as each role in docs/matrix.json, open every page in lib/access/routes.ts that role may open, follow every link on each page, and record any console error, failed request, error page, 404 or page without styles. Fail with a list per role and page.

2. In the same nightly workflow, check the live site https://acme-platform.vercel.app signed out, changing nothing: the public pages answer 200 with their real content; every protected page lands on the sign-in page; /this-page-must-not-exist-7f3a answers 404; landing on the sign-in page where content was expected, a 5xx or a timeout is "could not measure" and fails the run.

3. If anything fails, open a GitHub issue labelled nightly, assigned to both owners, with the failing step, the run's link and the first 40 lines of its log. Add a workflow_dispatch input fire_alarm that fails one step on purpose with "alarm test".

Update docs/testing-protocol.md. Push, open a pull request titled "Nightly sweep and production check", wait for the checks and tell me the result.

After it merges, run it once with the alarm on and check the issue arrives; close it, and run it again with the alarm off:

Open

https://github.com/acme-ops/acme-platform/actions/workflows/nightly.yml

Choose Run workflow, set fire_alarm to true, and press Run workflow.

You will see recreated screen

github.com/acme-ops/acme-platform/actions/runs/8901
Summarysweepproduction
1
RolePagesLinks followedProblems
operator6410
supervisor9630
quality lead10700
manager7520
production: 4 public pages present, 17 protected pages → /sign-in
/this-page-must-not-exist-7f3a → 404 ✔ (absent, as it must be)
The nightly run, by hand with the alarm off: the sweep per role and the production check, with the fake address correctly absent.
  1. Every page each role can open, and every link on it.
  2. The must-not-exist address answered 404, so a "present" from this check means something.

Check it worked

The nightly workflow is on main; the alarm run opened an issue (now closed); the run with the alarm off is green, with the must-not-exist address reported absent.

If it goes wrong

The production check reports every page present, including the fake address

The site answers 200 for every address, or the check counts the sign-in page as the page it wanted. That check could only ever say "fine", and we had one. Say: Make the fake address fail the run unless it answers 404, and treat the sign-in page as "could not measure" where content was expected.

The sweep finds links to pages that do not exist

A link that compiles is not a link that resolves: we had 130 tool links pointing at an address that did not exist. Say: For each dead link, show me where it is and what it should point to, and fix it with the sweep as the test.

The alarm fails but no issue appears

Say: The alarm test failed and no issue was opened. Show me the issue step's log, give the workflow issues write permission if that is the cause, and run the alarm test again.

Knowledge check

A double tap on Save stores two inspection rows. The screen showed "Saved" once. Which test catches it?

Knowledge check

Why does the nightly production check include an address that must not exist?

References

  1. Martin Fowler: The Practical Test Pyramid. https://martinfowler.com/articles/practical-test-pyramid.html
  2. Google Testing Blog: Just Say No to More End-to-End Tests. https://testing.googleblog.com/2015/04/just-say-no-to-more-end-to-end-tests.html
  3. Playwright documentation: Getting started. https://playwright.dev/docs/intro
  4. Playwright documentation: Emulation (phone sizes, offline). https://playwright.dev/docs/emulation
  5. Google Testing Blog: Flaky Tests at Google and How We Mitigate Them. https://testing.googleblog.com/2016/05/flaky-tests-at-google-and-how-we.html

Chapter 3 · Session 19

Conformance, and the signed protocol

Secure and working is not yet enough: the platform must do what your intent promised. Conformance traces every line of the intent and every role in the matrix to a criterion, a test and today's result. Then the whole protocol is run once from main, and signed by the people who own it.

30 min2 stepsEnds with a gate

By the end of this chapter you can

  • Have Claude Code write docs/conformance.md: every intent line and role traced to a given-when-then criterion, a test and a result.
  • Keep hand-worked values as independent evidence that no agent may update.
  • Run the whole protocol from main, record the results from GitHub, and sign it.

From a line of intent to a green check

Your intent (Session 2) says what the platform is for and what it must never do by itself. The matrix (Session 7) says who may do what. Conformance means each of those promises has a test, and each test has a result. Written as a table in the repository, one row per promise, it is called a traceability matrix, and it is exactly what an auditor or IT reviewer wants to see [1].

Traceability from intent to evidenceFour linked boxes: an intent line, its acceptance criterion, the test file, and the passing CI run. IntentA hold always says whyCriterionGiven a lot, when anyoneholds it without a reason,then the hold is refusedTesttests/e2e/conformance.spec.tsEvidenceCI run on the pullrequest: passedEvery line of the intent traces to a criterion, a test and a result you can show ITA line with no test is a promise nobody checks; a test with no line is work nobody asked for
From a line of intent to a green check. The same chain, repeated for every promise, is docs/conformance.md.

Write each criterion as given (the starting situation), when (what someone does) and then (what must happen). It is plain enough for the quality lead to confirm and precise enough for Claude Code to turn into a test [2].

Intent line (stamping plant)Given · when · then
The quality lead decides at each die change whether to hold a lotGiven a first-piece result outside the limits, when the operator saves it, then the lot appears in the quality lead's hold list within one minute
A hold always says whyGiven a lot, when anyone holds it without a reason, then the hold is refused and the lot stays as it was
The system never releases a lot by itselfGiven a held lot and no person acting, when a day passes, then the lot is still held
Managers see hold time per press each shiftGiven the seeded shift for press P-03, when the manager opens the dashboard, then the hold time shows the value worked by hand in docs/measures.md
Step 6

Trace the intent: docs/conformance.md

15 minutes

Why

Every promise in the intent with no test is a promise nobody checks, and every test with no promise is work nobody asked for. Tracing them in one table shows both. Asking Claude Code to write the missing tests in the same pull request, against hand-worked values it may not touch, turns the table from a document into evidence; and the decision-maker signing it means the person who owns the decision agrees the platform does what they need.

Do this

Paste into Claude Code
Read docs/INTENT.md, docs/matrix.json, docs/measures.md and docs/testing-protocol.md, and the tests in tests/e2e/.

On a new branch tests/conformance, write docs/conformance.md: one row per line of the intent (including the "never by itself" rule and each thing it says we are not building), one per role in the matrix, and one per dashboard measure. Each row: the promise in the intent's own words; a criterion as "given ..., when ..., then ..."; the test that proves it (file and test name); its latest result with the link to the run on GitHub. For each allowed action, add the unhappy-path row that says what is refused.

Write any missing test in tests/e2e/conformance.spec.ts, on the CI database, at 390 by 844. For measures, assert the value worked by hand in docs/measures.md. Never change a hand-worked value: if the platform shows something different, stop and tell me both numbers.

Leave a line at the top: "Checked with <decision-maker's role> on <date>". Update docs/testing-protocol.md. Push, open a pull request titled "Conformance", wait for every check, and report: promises, criteria, tests passing, and anything you could not test and why.

Then sit with the decision-maker, read docs/conformance.md on GitHub together, and ask: is each criterion what you meant? Is any promise missing? Give their changes to Claude Code in their words, then fill in the sign-off line:

Paste into Claude Code, after replacing the <...> parts
The quality lead read docs/conformance.md and said: <paste their changes>. Update the criteria and tests to match, fill in the top line "Checked with the quality lead on <today's date>", and push to the same pull request. Wait for the checks.

You will see recreated screen

claude — acme-platform
⏺ Write(docs/conformance.md)
+| Promise | Given · when · then | Test | Latest |
+| Never releases a lot by itself | given a held lot and nobody acting, when a day passes, then it is still held | conformance.spec.ts › never auto-releases | passed, run 8915 |
+| Hold time per press | given the seeded shift for P-03, when the manager opens the dashboard, then 2 h 14 min | conformance.spec.ts › hold time P-03 | passed, run 8915 |
1
⏺ Pull request #53: 14 promises, 19 criteria including 5 unhappy paths, 19 tests passing. One thing for you: the first-pass yield measure shows 96.4% on the dashboard, but docs/measures.md has 96.8% worked by hand. I have not changed either. The dashboard counts re-checked parts twice; please decide which is right.2
The conformance table, with one disagreement Claude Code stopped on instead of hiding.
  1. Every promise traced to a criterion, a named test and a run on GitHub.
  2. It stopped on a mismatch instead of changing the hand-worked number. That is exactly the rule.

You will see recreated screen

github.com/acme-ops/acme-platform/blob/main/docs/conformance.md
docs/conformance.md
Checked with the quality lead on 2026-11-121
PromiseLatest
A hold always says whypassed
Never releases a lot by itselfpassed
Release by another personpassed
Hold time per presspassed
The table on GitHub, as the decision-maker reads it, signed.
  1. The person who owns the decision agrees the platform does what they need.

Check it worked

docs/conformance.md is merged, signed by the decision-maker, with every promise in the intent and every role traced to a criterion and a test passing on GitHub; any mismatch with a hand-worked value was decided by a person.

If it goes wrong

Claude Code updated a hand-worked value so the test passes

Say: Revert the change to docs/measures.md. Hand-worked values are only changed by a person. Show me both numbers and how each was worked out. Then decide with the decision-maker.

A promise in the intent cannot be tested

Usually it is too vague ("faster decisions"). Ask the decision-maker what they would see on the day it is true, write that as given-when-then, and test that. If it truly cannot be tested, the row says so and why.

Tests exist that no promise asks for

List them in the table under "Not in the intent". Some are protections (security, phone size) and stay; others are work nobody asked for, and the intent or the test should change.

Step 7

Run the whole protocol from main, and sign it

15 minutes

Why

Each gate has passed on its own pull request; the protocol is only true when every gate has run on the same commit of main and passed there. Running them together once, with results taken from GitHub, and two people signing (one who ran it, one who checked it) is the evidence IT asks for in Session 21 and the habit the platform runs on after you hand it over. Making the new e2e check required means the journeys protect every later change, too.

Do this

Paste into Claude Code, after replacing the <...> parts
Run the whole protocol in docs/testing-protocol.md on the latest commit of main. Start every workflow that does not run on its own with gh workflow run (including nightly, security-weekly and e2e), wait for each with gh run watch, and plant again, on a throwaway branch tests/red-first-2-do-not-merge, the two defects from the audit that waited for their tests (a release by the person who held the lot; the hold-time measure off by one hour). Show both turning a test red in a DRAFT pull request, then close it without merging and delete the branch.

On a new branch tests/protocol-run, update docs/testing-protocol.md: for every gate, the run link, the commit, the date and the result from GitHub. A gate with no run on this commit is "could not measure", never "passed". Add at the top: "Run by pat@acme.com on <date> at commit <short hash>. Checked by sam@acme.com on <date>. Next full run: <date three months from now>, and before each customer install." Open a pull request titled "Testing protocol: first full run" and wait for the checks.
Open

https://github.com/acme-ops/acme-platform/settings/rules

Open the ruleset protect main. Under Require status checks to pass, add e2e beside ci, schema, clamps and security. Save.

Owner two opens three of the run links at random, checks each is on the commit named at the top, and approves. Merge.

You will see recreated screen

claude — acme-platform
⏺ Bash(gh workflow run nightly.yml && gh run watch)
⎿ ✓ nightly completed: success (5m 38s)
⏺ All 19 gates ran on main at commit 4e1c9a2: 17 passed, 2 not needed yet (email honesty, build memory). The restore drill is marked "could not measure: first drill is Session 23". Draft pull request #55 showed both late defects red: release by the holder failed 2 tests; the hold time off by an hour failed 1. It is closed and the branch deleted.1
⏺ Write(docs/testing-protocol.md)
+Run by pat@acme.com on 2026-11-12 at commit 4e1c9a2. Checked by sam@acme.com on 2026-11-12.
+Next full run: 2027-02-12, and before each customer install.
2
The full run on one commit of main, with the two late defects shown red.
  1. Every gate on the same commit, with honest labels for what is not yet measurable.
  2. Two signatures: one who ran it, one who checked it.

You will see recreated screen

github.com/acme-ops/acme-platform/settings/rules
protect main
Require status checks to pass
1
Status checkSource
ciGitHub Actions
schemaGitHub Actions
clampsGitHub Actions
securityGitHub Actions
e2eGitHub Actions
The ruleset for main, now requiring the journeys too.
  1. e2e joins the required checks: a change that breaks a journey or a failure path cannot merge.

Check it worked

docs/testing-protocol.md on main names the commit every gate ran on, each with a run link and result, signed by both owners with the next run date; e2e is a required check.

Fastest path

Start all the workflows first and let them run side by side; waiting for each before starting the next triples the time.

If it goes wrong

A check is red for a reason that has nothing to do with the protocol

Ask first: Which commit did this run on, how far behind main is it, and has main fixed anything since? A verdict on an old commit, or a canceled deploy replaced by a newer one, is not a failure of today's code. Re-run on the latest main; only diagnose what is still red.

The summary says everything passed but a run link shows red

Trust the run. Say: Run <link> is red. Give me its exit code and the last 20 lines of its log, fix the cause or mark it failed in the protocol, and never report a gate passed without its run.

Owner two finds a run link on a different commit

The result is about other code. Say: Re-run <gate> on commit <hash> and update its row. Then check the others.

Before you go on · Session 19 is done whenTick each one

Knowledge check

The hold-time test fails after a formula change. What should happen?

Knowledge check

Why must every gate's result in the protocol come from a run on the same commit of main?

References

  1. NIST SP 800-218, Secure Software Development Framework (SSDF) Version 1.1. https://csrc.nist.gov/pubs/sp/800/218/final
  2. Cucumber: Gherkin reference (Given, When, Then). https://cucumber.io/docs/gherkin/reference/
  3. GitHub CLI manual: gh workflow run. https://cli.github.com/manual/gh_workflow_run
  4. GitHub Docs: Available rules for rulesets (require status checks). https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets

Chapter 4 · 12 questions · 80% passes

Final assessment

Twelve questions across the session. Score 80% (10 of 12) to pass. Your LMS records your score and each answer; you can review the chapters and try again.

15 min12 questions≈ 15 minutesRetake allowed

Choose one answer for each question, then submit. You will see the right answer and why for every question.

1. What does each row of docs/testing-protocol.md give?
2. A gate has never run on the current main. What does the protocol say?
3. Why must a test's exit code never be read through a pipe such as | tail?
4. A test passes by finding the word requireReason in a file. What is wrong?
5. How do you know a gate can fail?
6. Where do the journeys and failure paths run?
7. A double tap on Save stores two rows but the screen says "Saved" once. Which kind of test catches it?
8. A measure has no data. What must the screen show?
9. What does the must-not-exist address in the nightly production check prove?
10. Which part of 'given, when, then' states the result that must be seen?
11. The hold-time test fails because the dashboard shows a different value from docs/measures.md. What happens?
12. Who signs the first full run of the protocol?