qualiow-exploratory-testing 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/.claude-plugin/plugin.json +22 -0
  2. package/.env.example +27 -0
  3. package/CHANGELOG.md +194 -0
  4. package/README.md +428 -179
  5. package/agents/qa-gather-agent.md +24 -0
  6. package/{scripts → bin}/doctor-mobile.sh +57 -18
  7. package/bin/mcli +15 -9
  8. package/bin/mobile-cli.mjs +574 -286
  9. package/{scripts → bin}/setup-mobile.sh +56 -19
  10. package/bin/wadb +10 -4
  11. package/bin/wk-ios +29 -17
  12. package/bin/wkeval.mjs +7 -1
  13. package/data/domains/_default.yml +1 -1
  14. package/data/domains/identity.yml +138 -0
  15. package/data/knowledge/changelog.yml +104 -0
  16. package/data/knowledge/learned-patterns.md +172 -86
  17. package/data/knowledge/manifest.yml +481 -70
  18. package/data/knowledge/releases/v0.1.0/entries/technique-business-logic-race-conditions.yml +1 -1
  19. package/data/knowledge/releases/v0.1.0/release.yml +8 -1
  20. package/data/knowledge/releases/v0.2.0/entries/technique-contract-narrowing.yml +150 -0
  21. package/data/knowledge/releases/v0.2.0/entries/technique-test-suite-audit.yml +116 -0
  22. package/data/knowledge/releases/v0.2.0/release.yml +20 -0
  23. package/data/knowledge/releases/v0.3.0/entries/technique-functional-diff-analysis.yml +119 -0
  24. package/data/knowledge/releases/v0.3.0/entries/technique-llm-output-verification.yml +102 -0
  25. package/data/knowledge/releases/v0.3.0/entries/technique-verification-mode-selection.yml +153 -0
  26. package/data/knowledge/releases/v0.3.0/release.yml +25 -0
  27. package/data/knowledge/releases/v0.4.0/entries/technique-authenticated-api-probing.yml +137 -0
  28. package/data/knowledge/releases/v0.4.0/entries/technique-environment-fingerprinting.yml +113 -0
  29. package/data/knowledge/releases/v0.4.0/entries/technique-silent-failure-audit.yml +86 -0
  30. package/data/knowledge/releases/v0.4.0/entries/technique-ui-api-differential.yml +97 -0
  31. package/data/knowledge/releases/v0.4.0/release.yml +28 -0
  32. package/data/knowledge/releases/v0.5.0/entries/technique-config-surface-verification.yml +77 -0
  33. package/data/knowledge/releases/v0.5.0/entries/technique-derived-value-verification.yml +81 -0
  34. package/data/knowledge/releases/v0.5.0/entries/technique-expected-behaviour-specification.yml +97 -0
  35. package/data/knowledge/releases/v0.5.0/entries/technique-presentation-integrity.yml +78 -0
  36. package/data/knowledge/releases/v0.5.0/entries/technique-release-readiness-verification.yml +110 -0
  37. package/data/knowledge/releases/v0.5.0/release.yml +33 -0
  38. package/data/knowledge/releases/v0.6.0/entries/technique-async-callback-contracts.yml +98 -0
  39. package/data/knowledge/releases/v0.6.0/entries/technique-exactly-once-verification.yml +116 -0
  40. package/data/knowledge/releases/v0.6.0/release.yml +30 -0
  41. package/data/security/SECURITY-POLICY.md +273 -0
  42. package/data/targets/_default.yml +1 -1
  43. package/data/targets/_example-api-only.yml +80 -0
  44. package/data/targets/_example-backend.yml +123 -0
  45. package/data/targets/_example-mobile-emulation.yml +2 -2
  46. package/data/targets/_example-native-mobile.yml +2 -2
  47. package/data/targets/_example-sim-android-chrome.yml +1 -1
  48. package/data/targets/_example-sim-ios-safari.yml +1 -1
  49. package/data/templates/api-probe-matrix.md +99 -0
  50. package/data/templates/bug-report.md +29 -151
  51. package/data/templates/coverage-map.md +23 -6
  52. package/data/templates/expected-behaviour.md +94 -0
  53. package/data/templates/session-charter.md +3 -0
  54. package/data/templates/session-report.md +57 -80
  55. package/dist/cli/index.js +1500 -739
  56. package/dist/index.d.ts +673 -75
  57. package/dist/index.js +1664 -270
  58. package/docs/BACKEND-VERIFICATION.md +307 -0
  59. package/docs/GETTING-STARTED.md +188 -128
  60. package/docs/MOBILE-SETUP.md +149 -18
  61. package/package.json +32 -16
  62. package/skills/qa-explore/SKILL.md +31 -25
  63. package/skills/qa-explore/phases/00-setup.md +67 -41
  64. package/skills/qa-explore/phases/01-auth.md +32 -15
  65. package/skills/qa-explore/phases/02-charter.md +16 -5
  66. package/skills/qa-explore/phases/03-discovery.md +50 -26
  67. package/skills/qa-explore/phases/04-journeys.md +2 -2
  68. package/skills/qa-explore/phases/05-features.md +39 -24
  69. package/skills/qa-explore/phases/06-edge-cases.md +24 -13
  70. package/skills/qa-explore/phases/07-reporting.md +79 -140
  71. package/skills/qa-explore/references/context-integration.md +1 -1
  72. package/skills/qa-explore/references/output-contract.md +187 -0
  73. package/skills/qa-explore/references/paths.md +84 -0
  74. package/skills/qa-explore/references/playwright-agents-integration.md +61 -84
  75. package/skills/qa-explore/references/security-rules.md +66 -25
  76. package/skills/qa-explore/references/severity-guide.md +31 -4
  77. package/skills/qa-explore-cleanup/SKILL.md +17 -6
  78. package/skills/qa-explore-feedback/SKILL.md +18 -5
  79. package/skills/qa-explore-mobile/SKILL.md +86 -64
  80. package/skills/qa-explore-mobile/phases/00-setup.md +71 -62
  81. package/skills/qa-explore-mobile/phases/01-auth.md +28 -31
  82. package/skills/qa-explore-mobile/phases/02-charter.md +8 -4
  83. package/skills/qa-explore-mobile/phases/03-discovery.md +17 -11
  84. package/skills/qa-explore-mobile/phases/04-journeys.md +6 -6
  85. package/skills/qa-explore-mobile/phases/05-features.md +9 -9
  86. package/skills/qa-explore-mobile/phases/06-edge-cases.md +35 -40
  87. package/skills/qa-explore-mobile/phases/07-reporting.md +82 -56
  88. package/skills/qa-explore-mobile/references/mobile-edges.md +26 -26
  89. package/skills/qa-explore-quick/SKILL.md +60 -25
  90. package/skills/qa-explore-report/SKILL.md +40 -34
  91. package/skills/qa-gather/SKILL.md +17 -2
  92. package/skills/qa-knowledge-add/SKILL.md +20 -9
  93. package/skills/qa-knowledge-list/SKILL.md +12 -3
  94. package/skills/qa-target-setup/SKILL.md +63 -41
  95. package/skills/qa-verify-backend/SKILL.md +172 -0
  96. package/skills/qa-verify-backend/phases/00-setup.md +142 -0
  97. package/skills/qa-verify-backend/phases/01-ac-decomposition.md +58 -0
  98. package/skills/qa-verify-backend/phases/02-static-review.md +71 -0
  99. package/skills/qa-verify-backend/phases/03-live-verification.md +62 -0
  100. package/skills/qa-verify-backend/phases/03b-api-verification.md +170 -0
  101. package/skills/qa-verify-backend/phases/04-e2e-trigger.md +82 -0
  102. package/skills/qa-verify-backend/phases/05-reporting.md +163 -0
  103. package/skills/qa-verify-backend/references/api-probes.md +168 -0
  104. package/skills/qa-verify-backend/references/aws-readonly-probes.md +156 -0
  105. package/skills/qa-verify-backend/references/environment-fingerprinting.md +104 -0
  106. package/skills/qa-verify-backend/references/payload-verification.md +112 -0
  107. package/skills/qa-verify-backend/references/release-readiness.md +97 -0
  108. package/skills/qa-verify-backend/references/safety-rules.md +95 -0
  109. package/dist/cli/index.d.ts +0 -1
  110. package/dist/cli/index.js.map +0 -1
  111. package/dist/index.js.map +0 -1
@@ -0,0 +1,307 @@
1
+ # Backend & Infrastructure AC Verification
2
+
3
+ A guide to `/qa-verify-backend` — the lane for tickets whose acceptance criteria cannot be
4
+ seen in a browser.
5
+
6
+ ## Why this exists
7
+
8
+ `/qa-explore` drives a browser. A backend ticket — a stream, a table, an IAM policy, a queue
9
+ consumer, a webhook — has most of its acceptance criteria below the UI, where a browser cannot
10
+ reach. Those ACs get waved through on "it works in the dev env", and the gaps surface months
11
+ later during an incident.
12
+
13
+ Three failure modes this skill is built against, all subtler than a missed bug:
14
+
15
+ - **A confident `PASS` backed by a code reading** looks exactly like a `PASS` backed by a
16
+ measurement, and is worth far less. Refusing to fake that is what makes the other verdicts
17
+ credible.
18
+ - **A client-side guard is not the endpoint's behaviour.** "The button is disabled until you
19
+ type" describes the browser. Every other client — mobile, integration, script — sends the
20
+ request the guard was preventing, and that request is frequently the one that fails.
21
+ - **A verdict is a claim about code; a probe is an observation of an environment.** They
22
+ coincide only when that environment runs the change. One identical build can hold two
23
+ implementations of one feature with a flag choosing between them.
24
+
25
+ ## The workflow
26
+
27
+ ### 1. Analyse the ticket → `output/context/<TICKET>-context.md`
28
+
29
+ Run `/qa-gather` on the ticket, or write the context file by hand. The job is to turn prose
30
+ ACs into falsifiable claims **before** reading the implementation — doing it in that order is
31
+ what stops you rationalising whatever the code happens to do.
32
+
33
+ Flag **DoR gaps** while you are here: ACs with no observable falsifier, missing criteria for
34
+ behaviour the change clearly has, internal contradictions. Take each AC literally and ask what
35
+ observation would prove it false. An AC whose spec is wrong is worth finding before anyone
36
+ implements it.
37
+
38
+ ### 2. Create a target config
39
+
40
+ ```bash
41
+ cp data/targets/_example-backend.yml data/targets/local-my-service.yml # service behind a UI
42
+ cp data/targets/_example-api-only.yml data/targets/local-my-api.yml # HTTP API, no UI
43
+ ```
44
+
45
+ Both templates ship with the package, so the `cp` works from an installed copy as well as
46
+ from a checkout.
47
+
48
+ Fill in `base_url`, `environment.kind`, the `backend.resources` names, and `source.branch`.
49
+ For an API-only service most of that is empty: what matters is the `api:` block — its
50
+ `auth` mode, the env var holding the key, and the two allowlists. The `domain:` field names a
51
+ profile in `data/domains/` (`_default.yml`, `fintech.yml`, `identity.yml`, `saas.yml`,
52
+ `ecommerce.yml`, `marketing.yml`) — YAML only since 2.0.0 — which supplies the risk ranking
53
+ and integrity checks the session applies.
54
+
55
+ Two rules:
56
+
57
+ - **Credentials are referenced by env var NAME, never by value.** `aws_profile_env:
58
+ QA_AWS_PROFILE` — the value lives in `.env`, which is gitignored.
59
+ - **Name a private target `local-*.yml`.** That prefix is gitignored, so internal hostnames,
60
+ account ids and resource names stay on your machine. Add your own prefix to `.gitignore` if
61
+ you prefer a different convention.
62
+
63
+ ### 3. Verify
64
+
65
+ ```bash
66
+ /qa-verify-backend --target local-my-service --context output/context/TICKET-123-context.md
67
+ ```
68
+
69
+ All four flags:
70
+
71
+ | Flag | Effect |
72
+ |------|--------|
73
+ | `--static-only` | Branch review only — skip the live, API and end-to-end lanes. Use when you have no cloud credentials |
74
+ | `--api-only` | Skip the cloud lane and verify the HTTP surface |
75
+ | `--no-e2e` | Run everything except the write-path phase |
76
+ | `--parity <target-id>` | Run the same API matrix in a second environment and compare the two column by column |
77
+
78
+ ### 4. Explore the UI, if the ticket has one
79
+
80
+ ```bash
81
+ /qa-explore --target local-my-service --context output/context/TICKET-123-context.md
82
+ ```
83
+
84
+ ### 5. Hand off
85
+
86
+ `ac-matrix.md` is the headline deliverable. Bug reports land in `bugs/`, one per finding, each
87
+ with a Business Impact written in terms of consequence rather than mechanism — nobody funds a
88
+ fix for "StreamViewType is NEW_AND_OLD_IMAGES".
89
+
90
+ ## The four lanes
91
+
92
+ | Lane | Reads | Never |
93
+ |------|-------|-------|
94
+ | **Static** | The implementation branch via `git show <ref>:<path>` | Checks out, fetches without asking, or creates branches — you may have uncommitted work |
95
+ | **Live** | `describe-*`, `get-*`, `list-*`, `query`, `scan`, `simulate-principal-policy` | Mutates anything, or probes an account other than the one the target declares |
96
+ | **API** | The service's own endpoints, from the authenticated session — the cases a browser cannot send | Calls anything outside `api.probe_allowlist`, or anything that creates, mutates or deletes |
97
+ | **End-to-end** | The real write path in a non-production environment, then the data layer again | Runs against production, or writes directly to a data store (that bypasses the path under test and proves nothing) |
98
+
99
+ ### Before any lane: fingerprint the environment
100
+
101
+ A green result against an environment that does not run the changed code proves nothing, and a
102
+ red result there is not the ticket's bug. Phase 0 establishes, with evidence, which build is
103
+ deployed in **every** component of the request path, whether the changed path is *selected*
104
+ here (a flag, a config value, a routing rule), and whether the commit under test is genuinely
105
+ an ancestor of what is running.
106
+
107
+ > **Same build, different behaviour ⇒ configuration, not deploy lag.**
108
+
109
+ The consequence is a verdict: an environment that does not run the change gets
110
+ `NOT-REACHABLE`. And a fix that only lands behind a flag which is off in the environments
111
+ users are in has reached nobody — that is a finding in its own right, because flipping the
112
+ flag is a separate decision carrying its own risk.
113
+
114
+ ### The API lane, specifically
115
+
116
+ The request runs **inside the already-authenticated page**, so it carries the same session
117
+ cookie, CSRF token and interceptors the UI has. There is no token to obtain, nothing to store,
118
+ and it works with SSO and MFA that no scripted login can pass:
119
+
120
+ ```bash
121
+ playwright-cli -s=my-env open https://service.example.com/ --headed --profile .auth/my-env
122
+ playwright-cli -s=my-env eval "$(cat probes/search-cases.js)" --raw
123
+ ```
124
+
125
+ **When the service has no UI**, none of that applies: there is no page to run inside. Declare
126
+ `api.auth: api-key-env` with `token_env` naming the variable and `header_name` naming the
127
+ header, and the lane runs out of browser, reading the key from the environment at run time.
128
+ Two obligations come with it. Prove the credential is doing something before the first probe —
129
+ one call without the header must be rejected, one with it must succeed, both recorded — or a
130
+ `401` rendered as JSON will read like a passing case all session. And skip the differential
131
+ pass with the reason stated: with no second surface every finding is "API only", which is not
132
+ a downgrade but the whole contract, since there is no client guard in front of the endpoint
133
+ for anyone.
134
+
135
+ State-changing calls are limited to `api.write_allowlist` and belong to phase 4. Where a
136
+ service offers a workspace reset, it stays deliberate: it is the one call that erases the
137
+ evidence for everything already observed.
138
+
139
+ Cases come from the ACs plus the standard families — length boundaries, tokenisation,
140
+ metacharacters of whatever query language sits underneath, the four different kinds of
141
+ nothing (`""`, `null`, whitespace-only, field absent), enum values valid and invalid,
142
+ pagination bounds, type confusion, a second identity and a second scope.
143
+
144
+ If the ticket also has a screen, run the overlapping cases through it too and sort every
145
+ finding into **both** (the UI is faithful — fix it in the service), **API only** (a real
146
+ defect the client's guard is hiding, reachable by every other client), **UI only** (the client
147
+ invents or masks behaviour the service does not have) and **neither**.
148
+
149
+ ### A well-shaped `200` is not a correct answer
150
+
151
+ Once the contract holds, the values are still an open question. Every derived number — a
152
+ percentage, total, ratio, delta or aggregate — is recomputed from the raw figures in the same
153
+ response, using the formula from the **specification** rather than from the code under test,
154
+ with cases chosen to stress sign, zero, scale and cardinality, plus the structural invariants
155
+ that must hold regardless of magnitude.
156
+
157
+ Then the report says what that does not prove. When both sides of the check come from one
158
+ payload, the *derivation* is verified and the *inputs* are not — so the limitation is written
159
+ down and the **independent oracle** that would close it is named, along with whether it was
160
+ run. "Internal consistency verified; the outstanding oracle is X and has not been run" is an
161
+ honest, useful verdict. "The numbers are correct" is not.
162
+
163
+ And the payload is held next to the screen, because a correct response can still reach the
164
+ user as a wrong number — a formatter that guesses what a value is, a unit applied twice,
165
+ rounding that crosses a threshold, a truncated figure shown as a total. That defect is
166
+ invisible from either surface alone, and it usually belongs to a different change than the one
167
+ under test. See `skills/qa-verify-backend/references/payload-verification.md`.
168
+
169
+ ## Verdicts
170
+
171
+ | Verdict | Means |
172
+ |---------|-------|
173
+ | `PASS` | Verified, with cited evidence |
174
+ | `PARTIAL` | The intent is met but something material deviates from the stated spec |
175
+ | `FAIL` | The AC as written is not true |
176
+ | `BLOCKED` | Not verifiable with available access — the probe command is attached, ready to run |
177
+ | `NOT-REACHABLE` | This environment does not run the changed code path — a flag, a config value, or an undeployed commit. Not a pass and not a failure |
178
+ | `UNVERIFIABLE` | The AC has no falsifier as written — a DoR defect |
179
+
180
+ Every verdict names the observation mode that produced it **and the environment it holds in**.
181
+ `PASS (dev)` and `PASS` are different claims, and only one of them is honest when the change is
182
+ behind a flag that is off everywhere else. A row is never left at `PENDING`: if it was not
183
+ checked, it is `BLOCKED` and says why.
184
+
185
+ ## Choosing how to observe
186
+
187
+ Each AC is routed to the channel that can actually falsify it
188
+ (`technique-verification-mode-selection`):
189
+
190
+ - **API-behind-the-screen** — a user flow reaches the changed code, but you assert on the
191
+ network calls underneath, not the rendered screen. The UI is a lossy renderer: it hides
192
+ fields it does not display, coerces types, and swallows partial failures.
193
+ - **Direct request** — webhooks, internal endpoints, queue consumers, scheduled jobs, and the
194
+ inputs a screen's own guards prevent. Nothing in any product flow reaches these, so you fire
195
+ the request yourself and follow through to what it produced
196
+ (`technique-authenticated-api-probing`).
197
+ - **LLM / agent output** — a prompt, tool definition, model version or retrieval step changed.
198
+ Run a fixed input set against a written rubric; assert on properties and tool trajectory, not
199
+ on generated text (`technique-llm-output-verification`).
200
+ - **Needs a human** — a pure refactor, or something you lack the access to observe. Say so and
201
+ write out what someone with access should run.
202
+
203
+ ## Safety
204
+
205
+ The full policy is in
206
+ `skills/qa-verify-backend/references/safety-rules.md`. The parts worth knowing before
207
+ your first session:
208
+
209
+ - **Production hard stop.** If the account, profile, resource name or URL contains `prod`,
210
+ `prd` or `live`, probes are read-only and the end-to-end phase is skipped and reported as
211
+ skipped. If you cannot tell whether an environment is production, it is treated as production.
212
+ - **Account confirmation first.** `sts get-caller-identity` runs before the first probe and is
213
+ compared to the target's declared account. A probe fired at the wrong account is an access
214
+ event in someone else's environment.
215
+ - **Destructive runbooks are findings, not instructions.** A cleanup script with `delete-item`
216
+ commands found in a repo gets reported ("cleanup documented, no evidence of execution"), never
217
+ executed.
218
+ - **The API lane is read-only in every environment.** It calls only what
219
+ `api.probe_allowlist` declares. An endpoint whose verb is safe but whose effect is not —
220
+ billed per call, queues a job, rate-limited into an outage — needs explicit confirmation.
221
+ Matrix volume stays proportionate: a few dozen requests is verification, thousands is a load
222
+ test nobody agreed to.
223
+ - **Session credentials never leave the machine.** An authenticated browser profile and any
224
+ cookie taken from it are live credentials for a real account. They stay in `.auth/` and are
225
+ never inlined into a probe script, a committed file, a report or a message.
226
+ - **Redaction before disk.** Tokens, keys, real user emails, PII and any account id not already
227
+ in the target config become `[REDACTED]`. Raw probe output is the most common leak — it is
228
+ convenient to paste whole, and it is full of identifiers. API response bodies are the worst
229
+ offender: they are whole records, and an error body routinely carries the internal hostname,
230
+ the query that failed and a stack frame.
231
+ - **Session output is confidential and local.** It maps internal resources, effective
232
+ permissions and unfixed defects. It never goes to an external service.
233
+
234
+ ## The techniques behind it
235
+
236
+ Knowledge base entries loaded by the skill (`data/knowledge/`):
237
+
238
+ | Entry | Use it when |
239
+ |-------|-------------|
240
+ | `technique-verification-mode-selection` | Every session, at AC decomposition |
241
+ | `technique-functional-diff-analysis` | The static lane — eight passes that read a diff for behaviour, not style |
242
+ | `technique-contract-narrowing` | Any ticket that swaps a data source on a read path |
243
+ | `technique-test-suite-audit` | The change rewrites the tests meant to prove it works |
244
+ | `technique-llm-output-verification` | The change touches a prompt, tool, model or retrieval step |
245
+ | `technique-environment-fingerprinting` | Every session, before the first probe — which build and which implementation is actually running |
246
+ | `technique-authenticated-api-probing` | Any AC about an endpoint's own behaviour: validation, filters, pagination, error contract, payload shape |
247
+ | `technique-ui-api-differential` | The ticket has both a screen and an endpoint |
248
+ | `technique-silent-failure-audit` | Any read path with an error branch — failures rendered as ordinary-looking empty or zero results |
249
+ | `technique-derived-value-verification` | The AC concerns a calculated value — percentage, total, ratio, delta, aggregate |
250
+ | `technique-presentation-integrity` | The value is also shown on a screen |
251
+ | `technique-expected-behaviour-specification` | The session found behaviour no AC covers |
252
+ | `technique-config-surface-verification` | The change under test *is* the configuration mechanism |
253
+ | `technique-release-readiness-verification` | The ask is "is this release good to go" |
254
+ | `technique-exactly-once-verification` | Money moves, or any write that must land exactly once — assert the balance delta, not the status field, and attack redelivery and identity collision |
255
+ | `technique-async-callback-contracts` | A webhook or callback endpoint: what it owes its caller, and what it does with an event it cannot match |
256
+
257
+ Browse them with `/qa-knowledge-list`. The knowledge base ships 29 entries across releases
258
+ v0.1.0–v0.6.0.
259
+
260
+ ## Verifying a release rather than a ticket
261
+
262
+ When the ask is "is this release good to go" instead of "does this ticket meet its ACs", follow
263
+ `skills/qa-verify-backend/references/release-readiness.md`. It changes the shape of
264
+ the session:
265
+
266
+ - **The build table comes first, for everything.** Per ticket, is the commit it depends on
267
+ genuinely an ancestor of what is deployed? This reclassifies half the session before any
268
+ testing happens. A ticket whose backend is not deployed is **not testable here** — and testing
269
+ its UI anyway produces a convincing, meaningless result, because the frontend ships the
270
+ feature, the API does not answer, and it renders as dashes or zeros that look exactly like a
271
+ data bug.
272
+ - **A fixed result vocabulary** — clean pass · pass with caveats · fail · not testable here ·
273
+ not tested — so the last two stay visible instead of vanishing between passed and failed.
274
+ - **A coverage map with four states**, where 🔍 *code-verified only* is marked distinctly
275
+ because it is `UNVERIFIABLE`, not a pass. Plus the one sentence naming which untested item
276
+ carries the most risk.
277
+ - **Carry-overs in their own section** — pre-existing defects mixed into a release's results
278
+ inflate the apparent risk of shipping it and bury what belongs to it.
279
+ - **A disposition with its reversal condition**, and the scope of what was checked stated
280
+ explicitly when it is narrower than the question being asked.
281
+
282
+ ## Writing the spec where none exists
283
+
284
+ Most of what an API probe turns up has no acceptance criterion behind it, so there is nothing to
285
+ file it against and it becomes an argument rather than a fix.
286
+ `data/templates/expected-behaviour.md` is the artifact for that: observed against expected,
287
+ grouped by cause rather than by case, with the decisions the fix forces made explicit —
288
+
289
+ - **Reject, or clamp?** Reject. Silently serving something other than what was asked for breaks
290
+ every caller that trusts the value back.
291
+ - **An error, or an empty result?** An error. A silent zero is indistinguishable from a genuine
292
+ no-match and will be read as data.
293
+ - **Where does validation live?** At the layer covering every implementation of the feature —
294
+ never only in the client, which is not in the path for any other caller.
295
+
296
+ — ranked by what real users can reach *today* rather than by how bad each one reads, and closed
297
+ with the same content in plain English, ready to paste into a ticket comment. That last section
298
+ is what gets the work scheduled.
299
+
300
+ ## Templates
301
+
302
+ | Template | Use |
303
+ |----------|-----|
304
+ | `data/templates/api-probe-matrix.md` | The environment fingerprint, the case table with a column per environment, the four-bucket findings table, the evidence index. Copy it in at the start of the API lane |
305
+ | `data/templates/expected-behaviour.md` | The specification that should have existed, plus the plain-English reply |
306
+ | `data/templates/coverage-map.md` | Coverage with four states, including code-verified-only |
307
+ | `data/templates/bug-report.md` | One bug per report, with Business Impact |