@gate-forge/cli 0.7.1 → 0.8.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 (254) hide show
  1. package/README.md +499 -47
  2. package/dist/adapter-audit.d.ts +154 -0
  3. package/dist/adapter-audit.d.ts.map +1 -0
  4. package/dist/adapter-audit.js +531 -0
  5. package/dist/adapter-audit.js.map +1 -0
  6. package/dist/adapter-scaffold.d.ts +66 -0
  7. package/dist/adapter-scaffold.d.ts.map +1 -0
  8. package/dist/adapter-scaffold.js +353 -0
  9. package/dist/adapter-scaffold.js.map +1 -0
  10. package/dist/adopted-baseline.d.ts +10 -0
  11. package/dist/adopted-baseline.d.ts.map +1 -1
  12. package/dist/adopted-baseline.js +18 -1
  13. package/dist/adopted-baseline.js.map +1 -1
  14. package/dist/args.d.ts +15 -0
  15. package/dist/args.d.ts.map +1 -1
  16. package/dist/args.js +59 -2
  17. package/dist/args.js.map +1 -1
  18. package/dist/behavior-setup.d.ts +239 -0
  19. package/dist/behavior-setup.d.ts.map +1 -0
  20. package/dist/behavior-setup.js +738 -0
  21. package/dist/behavior-setup.js.map +1 -0
  22. package/dist/broker.d.ts.map +1 -1
  23. package/dist/broker.js +28 -2
  24. package/dist/broker.js.map +1 -1
  25. package/dist/cache-exclusions.d.ts +45 -0
  26. package/dist/cache-exclusions.d.ts.map +1 -0
  27. package/dist/cache-exclusions.js +205 -0
  28. package/dist/cache-exclusions.js.map +1 -0
  29. package/dist/candidate-tree.d.ts +86 -14
  30. package/dist/candidate-tree.d.ts.map +1 -1
  31. package/dist/candidate-tree.js +236 -62
  32. package/dist/candidate-tree.js.map +1 -1
  33. package/dist/ci-witnessed-template.d.ts +43 -0
  34. package/dist/ci-witnessed-template.d.ts.map +1 -0
  35. package/dist/ci-witnessed-template.js +283 -0
  36. package/dist/ci-witnessed-template.js.map +1 -0
  37. package/dist/cli.d.ts +1 -1
  38. package/dist/cli.d.ts.map +1 -1
  39. package/dist/cli.js +31 -4
  40. package/dist/cli.js.map +1 -1
  41. package/dist/commands/adapters.d.ts +15 -0
  42. package/dist/commands/adapters.d.ts.map +1 -0
  43. package/dist/commands/adapters.js +284 -0
  44. package/dist/commands/adapters.js.map +1 -0
  45. package/dist/commands/adopt.d.ts.map +1 -1
  46. package/dist/commands/adopt.js +9 -1
  47. package/dist/commands/adopt.js.map +1 -1
  48. package/dist/commands/baseline.d.ts.map +1 -1
  49. package/dist/commands/baseline.js +42 -1
  50. package/dist/commands/baseline.js.map +1 -1
  51. package/dist/commands/blocking.d.ts +81 -2
  52. package/dist/commands/blocking.d.ts.map +1 -1
  53. package/dist/commands/blocking.js +336 -53
  54. package/dist/commands/blocking.js.map +1 -1
  55. package/dist/commands/check.d.ts +36 -0
  56. package/dist/commands/check.d.ts.map +1 -1
  57. package/dist/commands/check.js +1008 -62
  58. package/dist/commands/check.js.map +1 -1
  59. package/dist/commands/classify.d.ts +2 -1
  60. package/dist/commands/classify.d.ts.map +1 -1
  61. package/dist/commands/classify.js +143 -5
  62. package/dist/commands/classify.js.map +1 -1
  63. package/dist/commands/enforce.d.ts +4 -4
  64. package/dist/commands/enforce.d.ts.map +1 -1
  65. package/dist/commands/enforce.js +41 -9
  66. package/dist/commands/enforce.js.map +1 -1
  67. package/dist/commands/enforcement.d.ts +13 -1
  68. package/dist/commands/enforcement.d.ts.map +1 -1
  69. package/dist/commands/enforcement.js +800 -30
  70. package/dist/commands/enforcement.js.map +1 -1
  71. package/dist/commands/history.d.ts +12 -0
  72. package/dist/commands/history.d.ts.map +1 -0
  73. package/dist/commands/history.js +45 -0
  74. package/dist/commands/history.js.map +1 -0
  75. package/dist/commands/init-presets.d.ts +148 -0
  76. package/dist/commands/init-presets.d.ts.map +1 -0
  77. package/dist/commands/init-presets.js +194 -0
  78. package/dist/commands/init-presets.js.map +1 -0
  79. package/dist/commands/init.d.ts +7 -12
  80. package/dist/commands/init.d.ts.map +1 -1
  81. package/dist/commands/init.js +610 -69
  82. package/dist/commands/init.js.map +1 -1
  83. package/dist/commands/keys.d.ts.map +1 -1
  84. package/dist/commands/keys.js +29 -13
  85. package/dist/commands/keys.js.map +1 -1
  86. package/dist/commands/next.d.ts.map +1 -1
  87. package/dist/commands/next.js +744 -15
  88. package/dist/commands/next.js.map +1 -1
  89. package/dist/commands/pre-commit.d.ts +25 -0
  90. package/dist/commands/pre-commit.d.ts.map +1 -1
  91. package/dist/commands/pre-commit.js +91 -6
  92. package/dist/commands/pre-commit.js.map +1 -1
  93. package/dist/commands/quarantine.d.ts +16 -0
  94. package/dist/commands/quarantine.d.ts.map +1 -0
  95. package/dist/commands/quarantine.js +213 -0
  96. package/dist/commands/quarantine.js.map +1 -0
  97. package/dist/commands/run.d.ts +39 -0
  98. package/dist/commands/run.d.ts.map +1 -0
  99. package/dist/commands/run.js +196 -0
  100. package/dist/commands/run.js.map +1 -0
  101. package/dist/commands/test-gates.d.ts +284 -2
  102. package/dist/commands/test-gates.d.ts.map +1 -1
  103. package/dist/commands/test-gates.js +3619 -186
  104. package/dist/commands/test-gates.js.map +1 -1
  105. package/dist/commands/tests.d.ts +1 -1
  106. package/dist/commands/tests.d.ts.map +1 -1
  107. package/dist/commands/tests.js +225 -22
  108. package/dist/commands/tests.js.map +1 -1
  109. package/dist/endpoint-compiler.d.ts.map +1 -1
  110. package/dist/endpoint-compiler.js +29 -8
  111. package/dist/endpoint-compiler.js.map +1 -1
  112. package/dist/engine-browser.d.ts +183 -0
  113. package/dist/engine-browser.d.ts.map +1 -0
  114. package/dist/engine-browser.js +381 -0
  115. package/dist/engine-browser.js.map +1 -0
  116. package/dist/engine-identity.d.ts +100 -0
  117. package/dist/engine-identity.d.ts.map +1 -0
  118. package/dist/engine-identity.js +182 -0
  119. package/dist/engine-identity.js.map +1 -0
  120. package/dist/evaluate.d.ts +89 -0
  121. package/dist/evaluate.d.ts.map +1 -1
  122. package/dist/evaluate.js +137 -16
  123. package/dist/evaluate.js.map +1 -1
  124. package/dist/execution.d.ts +253 -9
  125. package/dist/execution.d.ts.map +1 -1
  126. package/dist/execution.js +309 -12
  127. package/dist/execution.js.map +1 -1
  128. package/dist/git-hooks.d.ts +17 -0
  129. package/dist/git-hooks.d.ts.map +1 -1
  130. package/dist/git-hooks.js +119 -0
  131. package/dist/git-hooks.js.map +1 -1
  132. package/dist/git-objects.d.ts +60 -0
  133. package/dist/git-objects.d.ts.map +1 -0
  134. package/dist/git-objects.js +152 -0
  135. package/dist/git-objects.js.map +1 -0
  136. package/dist/history.d.ts +52 -0
  137. package/dist/history.d.ts.map +1 -0
  138. package/dist/history.js +116 -0
  139. package/dist/history.js.map +1 -0
  140. package/dist/host-load.d.ts +49 -0
  141. package/dist/host-load.d.ts.map +1 -0
  142. package/dist/host-load.js +78 -0
  143. package/dist/host-load.js.map +1 -0
  144. package/dist/input-snapshot.d.ts +63 -9
  145. package/dist/input-snapshot.d.ts.map +1 -1
  146. package/dist/input-snapshot.js +195 -17
  147. package/dist/input-snapshot.js.map +1 -1
  148. package/dist/io.d.ts +36 -0
  149. package/dist/io.d.ts.map +1 -1
  150. package/dist/io.js +21 -0
  151. package/dist/io.js.map +1 -1
  152. package/dist/mapping.d.ts +84 -1
  153. package/dist/mapping.d.ts.map +1 -1
  154. package/dist/mapping.js +276 -5
  155. package/dist/mapping.js.map +1 -1
  156. package/dist/native-freeze.d.ts +217 -0
  157. package/dist/native-freeze.d.ts.map +1 -0
  158. package/dist/native-freeze.js +332 -0
  159. package/dist/native-freeze.js.map +1 -0
  160. package/dist/pipeline.d.ts +52 -1
  161. package/dist/pipeline.d.ts.map +1 -1
  162. package/dist/pipeline.js +141 -3
  163. package/dist/pipeline.js.map +1 -1
  164. package/dist/playwright-browsers.d.ts +210 -0
  165. package/dist/playwright-browsers.d.ts.map +1 -0
  166. package/dist/playwright-browsers.js +364 -0
  167. package/dist/playwright-browsers.js.map +1 -0
  168. package/dist/plugins.d.ts +15 -5
  169. package/dist/plugins.d.ts.map +1 -1
  170. package/dist/plugins.js +59 -9
  171. package/dist/plugins.js.map +1 -1
  172. package/dist/progress.d.ts +148 -0
  173. package/dist/progress.d.ts.map +1 -0
  174. package/dist/progress.js +263 -0
  175. package/dist/progress.js.map +1 -0
  176. package/dist/providers.d.ts +26 -1
  177. package/dist/providers.d.ts.map +1 -1
  178. package/dist/providers.js +39 -0
  179. package/dist/providers.js.map +1 -1
  180. package/dist/receipts.d.ts +1 -0
  181. package/dist/receipts.d.ts.map +1 -1
  182. package/dist/receipts.js +35 -7
  183. package/dist/receipts.js.map +1 -1
  184. package/dist/repo-scan.d.ts +8 -1
  185. package/dist/repo-scan.d.ts.map +1 -1
  186. package/dist/repo-scan.js +221 -27
  187. package/dist/repo-scan.js.map +1 -1
  188. package/dist/reseal-chain.d.ts +184 -0
  189. package/dist/reseal-chain.d.ts.map +1 -0
  190. package/dist/reseal-chain.js +735 -0
  191. package/dist/reseal-chain.js.map +1 -0
  192. package/dist/reseal-evidence.d.ts +241 -0
  193. package/dist/reseal-evidence.d.ts.map +1 -0
  194. package/dist/reseal-evidence.js +319 -0
  195. package/dist/reseal-evidence.js.map +1 -0
  196. package/dist/reseal.d.ts +181 -0
  197. package/dist/reseal.d.ts.map +1 -0
  198. package/dist/reseal.js +1620 -0
  199. package/dist/reseal.js.map +1 -0
  200. package/dist/response-field-guidance.d.ts +82 -0
  201. package/dist/response-field-guidance.d.ts.map +1 -0
  202. package/dist/response-field-guidance.js +184 -0
  203. package/dist/response-field-guidance.js.map +1 -0
  204. package/dist/run-cache.d.ts +260 -0
  205. package/dist/run-cache.d.ts.map +1 -0
  206. package/dist/run-cache.js +771 -0
  207. package/dist/run-cache.js.map +1 -0
  208. package/dist/run-preflight.d.ts +77 -0
  209. package/dist/run-preflight.d.ts.map +1 -0
  210. package/dist/run-preflight.js +774 -0
  211. package/dist/run-preflight.js.map +1 -0
  212. package/dist/run-recipe.d.ts +107 -0
  213. package/dist/run-recipe.d.ts.map +1 -0
  214. package/dist/run-recipe.js +295 -0
  215. package/dist/run-recipe.js.map +1 -0
  216. package/dist/run-reliability.d.ts +126 -0
  217. package/dist/run-reliability.d.ts.map +1 -0
  218. package/dist/run-reliability.js +221 -0
  219. package/dist/run-reliability.js.map +1 -0
  220. package/dist/runtime.d.ts +15 -0
  221. package/dist/runtime.d.ts.map +1 -1
  222. package/dist/runtime.js +11 -1
  223. package/dist/runtime.js.map +1 -1
  224. package/dist/secret-guard.d.ts +36 -0
  225. package/dist/secret-guard.d.ts.map +1 -0
  226. package/dist/secret-guard.js +63 -0
  227. package/dist/secret-guard.js.map +1 -0
  228. package/dist/singleton-guidance.d.ts +73 -0
  229. package/dist/singleton-guidance.d.ts.map +1 -0
  230. package/dist/singleton-guidance.js +118 -0
  231. package/dist/singleton-guidance.js.map +1 -0
  232. package/dist/staged-candidate.d.ts +17 -0
  233. package/dist/staged-candidate.d.ts.map +1 -1
  234. package/dist/staged-candidate.js +50 -0
  235. package/dist/staged-candidate.js.map +1 -1
  236. package/dist/state-artifacts.d.ts +70 -0
  237. package/dist/state-artifacts.d.ts.map +1 -0
  238. package/dist/state-artifacts.js +215 -0
  239. package/dist/state-artifacts.js.map +1 -0
  240. package/dist/state.d.ts +170 -2
  241. package/dist/state.d.ts.map +1 -1
  242. package/dist/state.js +248 -8
  243. package/dist/state.js.map +1 -1
  244. package/dist/verifier-keys.d.ts +33 -2
  245. package/dist/verifier-keys.d.ts.map +1 -1
  246. package/dist/verifier-keys.js +95 -9
  247. package/dist/verifier-keys.js.map +1 -1
  248. package/guides/CONNECT-YOUR-PROJECT.md +367 -0
  249. package/guides/QUICKSTART.md +259 -24
  250. package/guides/RUNNER-NEUTRAL-EVIDENCE.md +199 -0
  251. package/guides/TEST-ENVIRONMENT.md +1041 -6
  252. package/guides/UPGRADE-0.6-to-0.7.md +3 -3
  253. package/guides/UPGRADE-0.7-to-0.8.md +114 -0
  254. package/package.json +10 -9
@@ -12,12 +12,31 @@
12
12
 
13
13
  ## Reset and seed before every run
14
14
 
15
- **Rule:** Reset to a known baseline before every run. Restore a baseline dump or run a seed script from the same checkout being tested.
15
+ **Rule:** Reset to a known clean state before every run. Restore a clean-state dump or run a seed script from the same checkout being tested.
16
16
 
17
17
  **Why:** Old data makes outcomes depend on run order or another developer's test.
18
18
 
19
19
  **Example:** `reset disposable database -> seed from this checkout -> run tests`.
20
20
 
21
+ ## Declare test-service environment variables
22
+
23
+ The supervised Playwright runner does not inherit the whole operator environment. Declare the names your native test helpers need in the existing runtime document:
24
+
25
+ ```yaml
26
+ # .gateforge.yml
27
+ runtime: .gateforge/runtime.yml
28
+ ```
29
+
30
+ ```yaml
31
+ # .gateforge/runtime.yml
32
+ schemaVersion: 1
33
+ envAllowlist: [API_BASE_URL, TEST_MAIL_URL]
34
+ ```
35
+
36
+ Export those values before `gateforge run` or `test-gates`. Only listed names reach the runner and its wired enumeration; values are never read from inline configuration. This document is part of the owner-approved policy digest, so adding a name requires the normal policy approval. Keep test registration independent of the values.
37
+
38
+ Engine `GATEFORGE_*` names and process-loader controls (`NODE_OPTIONS`, `NODE_PATH`, `LD_*`, `DYLD_*`, `PYTHONPATH`, `PYTHONHOME`, `BASH_ENV`, `ENV`) are refused even if listed. No list means no additional variables are forwarded. Supervised test-gates refuses these names with usage error 2 before its harness setup, plugin pipeline, or native test enumeration.
39
+
21
40
  ## Create login state against the app
22
41
 
23
42
  **Rule:** Mint the Playwright login state by connecting directly to the app, not through the witness proxy. Reuse one session file instead of repeatedly logging in. Set `GATEFORGE_SESSION_STATE` to that file for the supervised run.
@@ -26,6 +45,221 @@
26
45
 
27
46
  **Example:** Create `.cache/gateforge-session.json` against `http://app.example.test`, then set `GATEFORGE_SESSION_STATE=.cache/gateforge-session.json`.
28
47
 
48
+ ### Or let a setup project save its own state
49
+
50
+ **Rule:** A Playwright project that declares `use.storageState` is handed
51
+ that file for its own tests only. Nothing else about the consumer config
52
+ is honored, and the state a project does not declare is never inherited
53
+ from another project.
54
+
55
+ **Why:** The supervised run never loads your config — it runs a
56
+ synthesized one, because a consumer config is arbitrary code in the
57
+ runner's main process. Before this, the standard auth pattern therefore
58
+ stopped at that boundary: the `setup` project signed in and saved
59
+ `playwright/.auth/user.json`, the dependent project that reads the file
60
+ was handed nothing, and every assertion on a signed-in page failed
61
+ against a run that was otherwise green. Declaring the state is what
62
+ crosses the boundary, and it crosses as a path — never as code, and
63
+ never as an inline cookie document.
64
+
65
+ **Example:** the upstream pattern, unchanged:
66
+
67
+ ```js
68
+ // playwright.config.ts
69
+ export default defineConfig({
70
+ projects: [
71
+ { name: 'setup', testMatch: /.*\.setup\.ts/ },
72
+ {
73
+ name: 'chromium',
74
+ dependencies: ['setup'],
75
+ use: { storageState: 'playwright/.auth/user.json' },
76
+ },
77
+ ],
78
+ });
79
+ ```
80
+
81
+ ```ts
82
+ // e2e/auth.setup.ts — runs FIRST and with no session of its own
83
+ import { mkdirSync } from 'node:fs';
84
+ import { test as setup } from '@playwright/test';
85
+
86
+ setup('authenticate', async ({ page }) => {
87
+ await page.goto('/login');
88
+ await page.locator('#name').fill('Ada');
89
+ await page.locator('button[type=submit]').click();
90
+ mkdirSync('playwright/.auth', { recursive: true });
91
+ await page.context().storageState({ path: 'playwright/.auth/user.json' });
92
+ });
93
+ ```
94
+
95
+ Four rules decide what a run does with a declared state:
96
+
97
+ - **The file must be inside the repository.** Containment is checked on
98
+ the real filesystem, not on the spelling: a path that resolves outside
99
+ it, one that escapes through a symlink, a link that leads nowhere, a
100
+ URL and an empty value all stop the run before anything is spawned and
101
+ name the project, the value and the fix. None of them is ever dropped,
102
+ because a dropped state is a logged-out run that still reports green.
103
+ - **A relative path is relative to the runner's working directory** —
104
+ the directory holding the playwright config the run uses. That is the
105
+ repository root for a root-level config and the project's own
106
+ directory for a config one level down, which is exactly the directory
107
+ your setup test wrote the file from: the artifact the dependent project
108
+ reads is the artifact the setup project saved, wherever the config
109
+ lives. The file need not exist before the run; the setup project creates
110
+ it. Containment still covers the WHOLE repository, so a
111
+ `../shared/user.json` that lands back inside it is accepted while
112
+ anything reaching outside it stops the run.
113
+ - **The setup project keeps no state**, so a stale file from an earlier
114
+ run can never make it start signed in and skip the sign-in it exists to
115
+ perform.
116
+ - **`GATEFORGE_SESSION_STATE` outranks every project declaration.** An
117
+ operator who sets it gets the whole-run session in every project,
118
+ exactly as before; the declarations it outranks are then not read, not
119
+ checked and not embedded anywhere in the run. Leave it unset to let the
120
+ projects use their own.
121
+
122
+ Everything else about a run keeps the repository root as its anchor, even
123
+ while the suite runs from the project directory: the files and test
124
+ identities a run reports stay repository-relative, so the keys your
125
+ catalog, your expected set and your receipt speak do not change with the
126
+ directory the config lives in, and a relative `GATEFORGE_SESSION_STATE`
127
+ path still means the repository root rather than the project directory.
128
+ There is nothing to configure: a supervised run simply resolves the
129
+ suite's own relative paths the way you resolve them when you run the
130
+ suite yourself.
131
+
132
+ ### One prepared candidate for the whole native run
133
+
134
+ **Rule:** In a Playwright run whose planned projects are named, and with no
135
+ operator-set whole-run session state, the run freezes ONE prepared candidate
136
+ between the preparation stages and the bodies. Every preparation stage runs
137
+ first — genuinely, with its own outcome, retained as a witnessed
138
+ prerequisite — and every body test then executes against the prepared bytes
139
+ and is gated on the freeze releasing. Unnamed or empty projects take no part,
140
+ a non-Playwright runner never enters this path, and an operator-set
141
+ whole-run session state bypasses it exactly as before.
142
+
143
+ **Why:** A setup project saves its session into the working tree, so the
144
+ bytes a body reads only exist once that stage has run. Before this, the
145
+ candidate was frozen before native setup. A run then correctly refused to
146
+ seal when genuine setup changed the counted session-state bytes, even if
147
+ every test passed. Declared native dependencies already put each setup
148
+ ahead of its own dependent body; what was missing was a place where
149
+ genuine generated output could be admitted at all, and a guarantee that
150
+ no INDEPENDENT body starts before ALL preparation. One freeze supplies
151
+ both.
152
+
153
+ What the freeze admits, and nothing else:
154
+
155
+ - **Only a declared session file may be written.** The difference between
156
+ the pre-run baseline and the prepared candidate may hold additions and
157
+ modifications to an untracked, non-input, non-excluded, physically
158
+ contained regular file that a project declares as its `storageState` —
159
+ and no removal, no symlink, and no other change to any candidate file. A
160
+ tracked file, or one the run's input snapshot binds, is read state and
161
+ never a write target: a `use.storageState` declaration says where a
162
+ project READS a session, never that preparation owns it. The engine's own
163
+ run artifacts — the spool, the synthesized config, the generated
164
+ controller — are written to the excluded run-state directory and are not
165
+ candidate files at all.
166
+ - **Source, trusted policy and the input digest stay frozen** for the run.
167
+ A change to any of them after the freeze is not preparation output and
168
+ is never carried as such.
169
+ - **Only a signature opens the barrier.** The private key lives in the
170
+ CLI process's memory and is never written to disk; the controller
171
+ receives the public key and verifies the release against the run, the
172
+ invocation, the nonce, the prepared tree and the exact bytes of its own
173
+ spec. A refusal document is failure-only: it can end the controller's
174
+ wait sooner, never let a body through.
175
+ - **Your projects' environment behaves as it does without the freeze.** A
176
+ runner unions each dependency's produced environment into its
177
+ dependents, so a project still sees its own dependency chain's
178
+ assignments over the baseline; the controller restores the trusted
179
+ baseline inside its own worker before any body starts, so a
180
+ prerequisite's variable reaches the projects that depend on it and
181
+ nothing further.
182
+
183
+ **Not a sandbox.** The freeze is a signed, checked boundary inside your
184
+ run, not an isolation boundary around your machine. Ordinary local files
185
+ are not OS-immutable: another process running as the same user can modify
186
+ or restore those bytes, and tampering with the CLI's own memory is beyond
187
+ what a signature can prove. What the freeze does establish is that each
188
+ body executed against the prepared candidate the receipt names, and that
189
+ only the declared candidate-file changes above could have produced it.
190
+
191
+ **Nothing to configure.** The same freeze runs whether your root
192
+ `package.json` is CommonJS, declares `"type": "module"`, or your specs
193
+ live in a nested directory with their own manifest: the generated
194
+ controller is plain ESM JavaScript whose module kind comes from its own
195
+ `.mjs` name rather than from your package manifest. A run that plans no
196
+ named project, a non-Playwright runner, and a run with an operator-set
197
+ whole-run session state each behave exactly as they did before.
198
+
199
+ ### Per-session login identity (why a test may hand the witness its own tenant)
200
+
201
+ **Rule:** A test that creates a new tenant — or any row that only exists
202
+ inside a tenant it just made — registers THAT tenant's login with the
203
+ witness for ITS OWN session, through the session-authenticated
204
+ `evidence.registerSessionIdentity({ seat, values })` call (the witness
205
+ endpoint is `POST /sessions/identity`). The values are keyed by the same
206
+ witness environment variable names the adapter's seat already declares;
207
+ the seat name is the one the adapter reads through.
208
+
209
+ **Why — the trust argument.** A registration is a statement about
210
+ *who the engine reads as*, for one session. That is the whole of its
211
+ authority:
212
+
213
+ - **The engine still performs every read.** Nothing about a
214
+ registration lets the suite answer for itself. The adapter's GET, the
215
+ persistence echo and the record are the engine's own work; the
216
+ registered credential only chooses the account those GETs are made
217
+ with. A test that supplies data instead of a credential produces no
218
+ record at all, exactly as before.
219
+ - **A wrong tenant makes the row unfound.** The credential can only
220
+ change which rows the app is willing to return. If the registered
221
+ login belongs to another tenant, the app answers 403/404 (or returns
222
+ that tenant's rows), and the engine records what the app said: the
223
+ created entity reads as **absent** and the create is graded
224
+ **failed**, not passed. The failure mode of a wrong identity is a
225
+ closed door, never an open verdict.
226
+ - **It can never affect another session.** The endpoint authenticates
227
+ the caller as the session it names (`sessionId` + `sessionToken`), so
228
+ a test cannot register an identity for a foreign session; the identity
229
+ is keyed by that session id alone, is dropped when the session closes
230
+ or is released, and never outlives it.
231
+ - **It can never affect a record it did not cause.** A record is issued
232
+ by the engine for its own read, stamped with the session's
233
+ supervisor-registered test identity. A registration neither issues,
234
+ edits, nor transfers a record, and the run manifest, state directory
235
+ and report contain no credential value at all — the credential lives
236
+ in witness memory for the length of the session and nowhere else.
237
+
238
+ Without a registration the engine reads as the process-global seat
239
+ credentials in the environment, byte-identically to today's behavior.
240
+
241
+ **Example:** A per-tenant singleton table (`unique (contractor_id,
242
+ ledger_id, kind)` — see the `RESOURCE_SINGLETON_PER_TENANT` advisory)
243
+ cannot be proven by a read that uses the fixed seat: that seat's tenant
244
+ already has its row. The test creates the tenant first, registers that
245
+ tenant's login, then performs the read:
246
+
247
+ ```js
248
+ test('creates the first ledger entry for a fresh contractor', async ({ evidence }) => {
249
+ await createContractorAndLogin({ evidence }); // your own fixture step
250
+ await evidence.registerSessionIdentity({
251
+ seat: 'contractor',
252
+ values: {
253
+ GATEFORGE_ADAPTER_CONTRACTOR_USER: contractorUser,
254
+ GATEFORGE_ADAPTER_CONTRACTOR_PASSWORD: contractorPassword,
255
+ },
256
+ });
257
+ const receipt = await evidence.ui.create({ fields: { ledger: 'opening', kind: 'debit' } });
258
+ await evidence.persistence.verify(receipt);
259
+ await evidence.finalize();
260
+ });
261
+ ```
262
+
29
263
  ## Run containers as your user
30
264
 
31
265
  **Rule:** Give containers your user and group IDs.
@@ -93,11 +327,18 @@ The final comparison must pass. If it fails, find and disable or prewarm the wri
93
327
  **Example:**
94
328
 
95
329
  ```sh
96
- mkdir -p "$HOME/.config/gateforge"
97
- gateforge key create --file "$HOME/.config/gateforge/keys.json" --confirm
98
- export GATEFORGE_WITNESS_VERIFIER_KEY_FILE="$HOME/.config/gateforge/keys.json"
330
+ gateforge key create --confirm
99
331
  ```
100
332
 
333
+ With no `--file` the CLI creates the key ring at
334
+ `"${XDG_CONFIG_HOME:-$HOME/.config}/gateforge/verifier-keyring.json"`
335
+ (parent directory included, owner-only, mode `0600`) and reads that same
336
+ path on every later command, so no `GATEFORGE_WITNESS_VERIFIER_KEY_FILE`
337
+ export is needed — an export pointing elsewhere is what made a documented
338
+ key ring unreadable on any machine with a non-default `XDG_CONFIG_HOME`.
339
+ Use `--file <path>` together with that export only when the ring really
340
+ lives somewhere else.
341
+
101
342
  The CLI does not print the secret. Keep backups private too.
102
343
 
103
344
  ## Register the same tests in every mode
@@ -131,6 +372,71 @@ changed:
131
372
 
132
373
  For a GitHub Actions pull request, set `GITHUB_BASE_REF`. For a GitLab merge request, set `CI_MERGE_REQUEST_DIFF_BASE_SHA`.
133
374
 
375
+ **Missing base in a merge-request pipeline?** `test-gates --scope changed` and `check --changed` now stop in seconds with exit 2 and say so. Before that, `auto` fell back to the local staged diff, which in a CI job is empty: the slice graded nothing and the job failed an hour later on debt nobody changed.
376
+
377
+ ## Let the CI job show progress
378
+
379
+ **Rule:** Leave the progress stream on (`--progress stderr`, or `file:<path>` when the job console is not writable) and do not re-print the runner log to make the screen move.
380
+
381
+ **Why:** The runner log carries the app env, the request bodies and the seed credentials, so it must stay private. Gateforge's own stream is built from witness-side facts — how many tests were registered, which test is open, its catalog title, its outcome — and never from runner output, so it can be shown without screening. A filter over secret text is not secret-free; not reading the log at all is.
382
+
383
+ **Example:**
384
+
385
+ ```bash
386
+ gateforge test-gates --changed --progress stderr
387
+ # or, with a job console that cannot be written to:
388
+ gateforge test-gates --changed --progress file:.gateforge/test-gates/progress.log
389
+ ```
390
+
391
+ Under `CI=true` the default is already `stderr`; locally it is off, and a local run's output is byte-identical either way. When a test fails, its error message and a short `file:line` stack land in `.gateforge/test-gates/failures.json` behind the same credential guard — publish THAT artifact, not the runner log.
392
+
393
+ **Reading the numbers:** `repository debt: N known (baselined), M new blocking` names the two numbers separately, and only the gate prints them. `N` is the debt the adopted baseline forgave; `M` is what this run's exit code blocks on — a full run's whole surface, a `--changed` or `--test` run's own slice, never a subtraction that can reach zero while blockers remain. Debt outside a slice run is real and still reported, in its own words: `not graded by this changed-scope run: 96 blocking obligation(s) — this run never observed them; a full run grades them`. The in-runner reporter prints `repository debt: graded by gateforge after the run`: it grades claims only, so it has no waivers, scope or baseline to split debt with, and one run can never show two different counts.
394
+
395
+ ## Install the browsers YOUR Playwright pins
396
+
397
+ **Rule:** Run `npx playwright install` from the directory that holds your Playwright config, for the browsers your projects name — before the first witnessed run. `gateforge enforcement doctor` reports the exact builds the runner it will launch needs; a `FAIL` there names the command and that directory.
398
+
399
+ **Why:** Every Playwright release pins its own browser revisions. A machine that already installed a DIFFERENT release's browsers has a full-looking browser cache, and the run still dies on every test with `Executable doesn't exist at .../chromium_headless_shell-<revision>/…`. The fix is per release, not per machine.
400
+
401
+ **Example:** With your config in `e2e/`, run `cd e2e && npx playwright install chromium` (add `firefox`/`webkit` if your projects use them).
402
+
403
+ **On a Linux machine without the browser's system libraries** — a container, a
404
+ CI image, WSL — the download alone is not enough: the build is installed, the
405
+ dynamic loader fails before the browser's `main`, and every test dies with
406
+ `Target page, context or browser has been closed`. Install both in one command
407
+ (`--with-deps` needs root or sudo):
408
+
409
+ ```bash
410
+ cd e2e && npx playwright install --with-deps chromium
411
+ ```
412
+
413
+ `gateforge enforcement doctor` names this case rather than reporting the cache
414
+ ready: the `runner` line then reads `the browser build '<cache>/chromium-<revision>'
415
+ is installed but cannot start on this machine: <the loader's line>` and prints
416
+ `npx playwright install-deps chromium` in the config's own directory.
417
+
418
+ **A cache you choose:** if you set `PLAYWRIGHT_BROWSERS_PATH` (a common way to keep browsers in a CI cache mount), install into THAT directory and leave the variable set for the run. The supervised Playwright child receives it, so `enforcement doctor` and the run read the same cache — the doctor never reports one directory ready while the tests launch from another.
419
+
420
+ ## Install the browsers the ENGINE pins
421
+
422
+ **Rule:** Before the first witnessed run, make sure the Chromium that `@gate-forge/pack-playwright` pins is installed too. `gateforge enforcement doctor` reports it on its own `engine-browser` line and prints the exact command; the run preflight refuses the run on the same line.
423
+
424
+ **Why:** Your tests and the engine do not share a browser. Gateforge drives its OWN Chromium for every `evidence.ui.action`, `evidence.visible.confirm` and `evidence.persistence.verify` receipt, and for every behavior case on the `engine-browser` channel — that browser comes from the Playwright release the evidence pack pins, which is usually a different release from the one you installed. Your runner's readiness can be fully green while the engine's build is absent, and then the run dies inside the witness with `Executable doesn't exist` instead of failing where you could fix it.
425
+
426
+ **Example:** Run the command the `engine-browser` line prints, verbatim:
427
+
428
+ ```text
429
+ engine-browser: the engine-owned browser (playwright 1.58.2 pinned by @gate-forge/pack-playwright) is NOT ready:
430
+ its pinned builds chromium-1208, chromium_headless_shell-1208 are missing from '<cache>' — your test runner's own
431
+ Chromium is a different Playwright release and cannot serve it, so every engine-browser case fails with
432
+ "Executable doesn't exist"; fix: run `PLAYWRIGHT_BROWSERS_PATH='<cache>' PLAYWRIGHT_SKIP_BROWSER_GC=1 node
433
+ '<repo>/node_modules/playwright/cli.js' install chromium`
434
+ ```
435
+
436
+ Two details in that command are load-bearing. It names the engine's OWN `cli.js` by absolute path because `npx playwright install` resolves the Playwright your command's directory reaches — YOURS — and would install the revision your cache already holds, leaving the engine exactly as broken. And `PLAYWRIGHT_SKIP_BROWSER_GC=1` is required: Playwright's installer otherwise garbage-collects every build its own registry does not list, so it would DELETE your Chromium out of a shared cache and trade one broken run for another.
437
+
438
+ **Which repositories need it:** only those that actually open the engine browser — a Playwright runner (its evidence receipts are all engine-driven) or a behavior policy declaring an `engine-browser` case. A pytest or API-only repository is told `engine browser not required` and is never asked to install anything.
439
+
134
440
  ## Keep the runner quiet
135
441
 
136
442
  **Rule:** Keep concurrent work below the machine's CPU count. Prefer a quiet runner for witnessed tests.
@@ -159,7 +465,25 @@ For a GitHub Actions pull request, set `GITHUB_BASE_REF`. For a GitLab merge req
159
465
  gateforge test-gates --changed --scope changed --result-only
160
466
  ```
161
467
 
162
- For an authoritative run, use `gateforge test-gates --changed` without `--result-only`, then run `gateforge check --changed --require-e2e` on the same inputs.
468
+ For an authoritative slice, run `gateforge test-gates --changed --scope changed` without `--result-only`. `gateforge test-gates --changed` alone runs the full relevant mapped suite. Then run `gateforge check --changed --require-e2e` on the same inputs.
469
+
470
+ A changed file can affect obligations that have no test at all. Those
471
+ still block the slice, one blocker each, with the reason:
472
+
473
+ ```text
474
+ changed-scope planning: obligation 'tenant.orders:persistence:read' is affected by the changed files but no declared mapping (sidecar entry or native annotation) resolves to a test the current catalog still enumerates — narrower selection is never guessed; map a test or run full scope
475
+ ```
476
+
477
+ When the repository adopted its existing debt with `gateforge adopt`,
478
+ those obligations are forgiven exactly as the full run forgives them, so
479
+ they do not block the slice — the run says so in one line instead, and
480
+ they stay inside the sealed covered set, so `check --require-e2e` still
481
+ demands what the full path grades. An obligation the baseline never
482
+ adopted still blocks, and strict E2E forgives nothing at all.
483
+
484
+ ```text
485
+ 1 affected obligation(s) have no declared mapping and are forgiven by the adopted baseline; they stay uncovered by this slice
486
+ ```
163
487
 
164
488
  ## Write witnessed tests for observable behavior
165
489
 
@@ -169,6 +493,717 @@ For an authoritative run, use `gateforge test-gates --changed` without `--result
169
493
 
170
494
  **Example:** Use a unique name such as `profile-${randomToken}`, wait for the form's data request, then enter only adapter-supported fields.
171
495
 
496
+ ## Maintain test data with features
497
+
498
+ Keep shared seed data small: logins, one base tenant, and required roles. Store its seed script in the repository and configure it as `harness.seed`, which runs after migrations. Avoid large SQL dumps that must be rewritten for every schema change.
499
+
500
+ Tests own the rest of their data. Each test creates only the rows it needs and uses a unique token in names or keys; do not depend on shared rows left by another test.
501
+
502
+ Carry each feature, its tests, and any base-seed change together in the same merge request. This keeps seed maintenance alongside the schema and behavior it supports.
503
+
504
+ Local runs and CI should invoke the same configured `harness` commands and seed script. Because configured harness scripts are part of the input snapshot, changing one invalidates prior evidence.
505
+
506
+ ## Run cheap checks before the suite
507
+
508
+ Put fast checks such as formatting, lint, and import checks in `prepare.preflight`. They run before preparation and the suite. Prefer checks that do not write to the workspace; any input drift still prevents a reliable receipt.
509
+
510
+ Run suite containers as the invoking user, avoid swapping mounted `.env` files or creating temporary workspace symlinks during the run, and warm or disable caches before sealing evidence.
511
+
512
+ ## Re-check one failing test without a full run
513
+
514
+ When two tests fail and you only need to know whether your fix worked,
515
+ do not spend a whole suite on it. Name the tests instead:
516
+
517
+ ```bash
518
+ # One test: a logical key, or any unique substring of one.
519
+ gateforge test-gates --test 'backend/tests/test_outbox.py::test_commits' --result-only
520
+
521
+ # Two or more: --test repeats.
522
+ gateforge test-gates --test UC-53 --test UC-51 --result-only
523
+ ```
524
+
525
+ The run is still fully witnessed — same supervisor, same run token,
526
+ same server-side evidence — it just executes the named tests instead of
527
+ the whole suite, so it finishes in seconds.
528
+
529
+ Two rules keep this safe to run any time:
530
+
531
+ - It is only accepted with `--result-only`. A hand-picked list never
532
+ seals a receipt, so it can never stand in for the gate.
533
+ - It never reads, writes, or clears `.gateforge/test-gates/receipt.json`.
534
+ Your existing receipt is byte-identical afterwards, and
535
+ `gateforge check --require-e2e` still reports exactly what it did
536
+ before.
537
+
538
+ If a selector matches nothing, or more than one planned test, the
539
+ command exits 2 and lists the candidate logical keys instead of
540
+ guessing:
541
+
542
+ ```bash
543
+ gateforge test-gates --test 'session proxy' --result-only || true
544
+ ```
545
+
546
+ To find the exact keys, read them off the additive `selectors` field of
547
+ any named run, or from `.gateforge/test-gates/test-catalog.json`
548
+ (`gateforge tests discover`).
549
+
550
+ Because selection works from the plan rather than from changed files,
551
+ this is also the way to re-check a fix that touched a `.env`, a helper,
552
+ or a fixture: no test links to those files, so a changed-file slice
553
+ cannot select them.
554
+
555
+ ### What a named run grades (and how it exits)
556
+
557
+ A named run grades **only the tests it named** — the obligations those
558
+ tests declare. Debt elsewhere in the repository is still printed (under
559
+ `repositoryDebt`, and as `not graded in a named run: N obligation(s)`),
560
+ but it does not block: this run never observed it, and it never becomes
561
+ a verdict. Only the run's own honesty still blocks: a red named test, an
562
+ obligation the selection declares but cannot prove, an incomplete run, or
563
+ a workspace that changed underneath it.
564
+
565
+ | Exit | Meaning |
566
+ | --- | --- |
567
+ | `0` | the whole selection is green and every claim it declares is satisfied |
568
+ | `1` | a red selected test, an unproven claim, or a run that was not complete/honest |
569
+ | `2` | the selector matched no planned test, or more than one (nothing ran) |
570
+
571
+ So a green named run is a statement about your selection, never about the
572
+ repository: it says nothing about the other 500 obligations your branch
573
+ still owes. Use `gateforge test-gates --changed` (or `--changed --scope
574
+ changed`) for those.
575
+
576
+ Playwright, pytest and vitest are handed the exact location of each named
577
+ test, so only those tests execute. Cypress has no trustworthy way to
578
+ filter below a spec, so the whole spec runs and the report tells you so:
579
+ `also ran N other test(s) in the same file — not graded`. Those extra
580
+ tests' results are dropped before grading — they are never evidence.
581
+
582
+ ## Fix one test without a full run
583
+
584
+ When a whole-suite run fails on one test, fixing that test changes the
585
+ candidate, so the run you just paid for no longer describes it — and the
586
+ default answer is another whole suite. If the only thing you changed is
587
+ test code, you can re-run just the tests the change can affect and carry
588
+ the rest forward, if you ask for it.
589
+
590
+ **Rule:** turn the path on once, then use `--changed --scope changed`.
591
+
592
+ ```yaml
593
+ # .gateforge.yml
594
+ enforcement:
595
+ reseal: true
596
+ ```
597
+
598
+ ```sh
599
+ # Fix one failing test, then:
600
+ gateforge test-gates --changed --scope changed
601
+ ```
602
+
603
+ ```text
604
+ only test files changed: re-ran 1 test(s), kept 562 from the previous receipt
605
+ ```
606
+
607
+ The path is **off by default in every gate mode**, and
608
+ `enforcement.reseal: true` turns it on in any mode, `strict` included.
609
+ Without the key, every run behaves exactly as before.
610
+
611
+ **What may be re-run.** Gateforge never takes the change set on trust. It
612
+ diffs the two sealed trees itself, classifies every changed path from the
613
+ runner's own catalog and the repository import graph, and re-runs the
614
+ affected tests witnessed, like any other run. Eligible:
615
+
616
+ - **test files** — paths the runner's own enumeration lists as tests;
617
+ - **test helpers** — files under the test roots that test files import.
618
+ The importers re-run too: a changed spec can export a shared fixture or
619
+ a `test.extend`, so every spec that imports a changed file re-runs,
620
+ transitively.
621
+
622
+ Everything else — app code, runner config, `package.json`, lockfiles,
623
+ seed data, `.env`, `.gateforge/**`, generated files, docs — is not
624
+ eligible, and neither is a setup or dependency-stage test file (it
625
+ changes every dependent test without an import edge) or any import the
626
+ graph cannot resolve. A **literal** dynamic import is an ordinary
627
+ import edge, not a computed one: `import('./x.mjs')`, `import("./x.mjs")`,
628
+ `` import(`./x.mjs`) ``, `require('./x')`, `importlib.import_module('x')`
629
+ and `__import__('x')` all resolve like a static import, so the file that
630
+ loads the module is an ordinary importer. Imports are read from the
631
+ syntax tree, so an import call named in a comment or a string is never
632
+ one. A **computed** specifier — a variable, a concatenation, a template
633
+ with `${…}` — refuses the re-seal, wherever it sits in the repository:
634
+ Gateforge cannot tell which file it loads, so it cannot prove the
635
+ change reaches no other test or app code. Imports never cross the
636
+ language boundary, so a computed Python import only matters when a
637
+ Python file changed, and a computed JS/TS import only when a non-Python
638
+ file changed. To re-seal in a repository that has one, write each
639
+ module it can load as a literal import, for example a map
640
+ `{ accounts: () => import('./tenant.accounts.mjs'), … }` instead of
641
+ `` import(`./tenant.${table}.mjs`) ``.
642
+
643
+ ### Declaring runtime state the run itself rewrites
644
+
645
+ Some repositories write into the workspace **during** the run: a
646
+ witnessed login stage saves its storage state, a runner writes a cache.
647
+ Those files are normally gitignored, and a sealed candidate tree covers
648
+ the workspace's untracked and ignored bytes too — so the parent tree and
649
+ this run's tree differ in them on **every** run. The re-seal sees those
650
+ differences as unknown app files and refuses, however test-only your
651
+ change is:
652
+
653
+ ```text
654
+ app file changed: e2e/.auth/contractor.json → changed-scope run
655
+ ```
656
+
657
+ Gateforge cannot guess which ignored files are disposable: an ignored
658
+ `.env.test` can flip an outcome, and hiding it silently would be a hole
659
+ in the check, not a fix. So the owner declares them:
660
+
661
+ ```yaml
662
+ # .gateforge.yml
663
+ enforcement:
664
+ reseal: true
665
+ resealRuntimeFiles:
666
+ - 'e2e/.auth/*.json'
667
+ ```
668
+
669
+ Entries are repo-root-relative POSIX globs. An absolute path, a
670
+ backslash, or a `..` segment fails the config load rather than quietly
671
+ matching nothing. Without the key nothing changes, byte for byte.
672
+
673
+ **The tracked-files rule.** A matching path is disregarded **only when
674
+ neither sealed commit tracks it** — when it exists purely as untracked
675
+ or ignored workspace bytes. The moment the same path is committed, it is
676
+ source: a declaration can never hide a source change, whatever the glob
677
+ reads. The rule is the owner's assertion about the repository, exactly
678
+ like the documentation exclusions, and the config digest binds it.
679
+
680
+ **What it prints, and what the receipt records.** One plain line, so the
681
+ ignored bytes are visible rather than inferred:
682
+
683
+ ```text
684
+ test-gates: re-seal disregards 2 declared runtime file(s): e2e/.auth/contractor.json, e2e/.auth/employee.json
685
+ ```
686
+
687
+ The re-sealed receipt keeps `changedPaths` as the **real** tree
688
+ difference and adds `resealDisregarded` with exactly the paths the
689
+ declaration removed from the classification. `check --require-e2e` and
690
+ the broker recompute the list from the same globs and the two commit
691
+ trees; a receipt that names a different list is `EVIDENCE_STALE`.
692
+
693
+ **When to declare it.** Only for files the run itself rewrites, every
694
+ run, with no bearing on any test's outcome — storage state, a scratch
695
+ cache, a coverage report. Not for anything a test reads to decide what
696
+ to assert, and not as a way around an `app file changed` line about
697
+ code.
698
+
699
+ A file that does not parse refuses too (`… does not parse as a
700
+ script`): an unread file cannot be shown to declare nothing computed.
701
+
702
+
703
+ A refused re-seal prints **one plain reason line** naming the path and
704
+ the step that actually follows: the run takes the ordinary
705
+ **changed-scope** path (the only scope in which a re-seal is attempted),
706
+ so every line ends in `→ changed-scope run`. The lines are verbatim:
707
+
708
+ ```text
709
+ app file changed: backend/app/invoices.py → changed-scope run
710
+ app file changed: e2e/support/fixtures.ts is imported by no test file, so it is not a test helper → changed-scope run
711
+ app file changed: e2e/support/fixtures.ts imports the changed test helper e2e/support/api.ts → changed-scope run
712
+ app file deleted: e2e/journeys/legacy.spec.ts → changed-scope run
713
+ setup test changed: e2e/global-setup.spec.ts → changed-scope run
714
+ setup test changed: e2e/accounts.spec.ts (the runner config declares a dependency project whose tests cannot be resolved) → changed-scope run
715
+ unresolvable import: e2e/accounts.spec.ts → ./load-fixture → changed-scope run
716
+ unresolvable import: e2e/support/api.ts loads a module through a computed specifier → changed-scope run
717
+ the sealed trees could not be diffed (a1b2c3d → e4f5a6b) → changed-scope run
718
+ the sealed trees are identical, so there is nothing to classify → changed-scope run
719
+ the re-seal path is off (`enforcement.reseal` is not true) → changed-scope run
720
+ the run state already retains 5 consecutive re-seals, the bound this path may chain to → changed-scope run
721
+ ```
722
+
723
+ **The run that failed.** A complete whole-suite supervised run seals a
724
+ receipt only when it is clean, so the case you care about — 563 tests,
725
+ 562 passed, one failure caused by a race *in the test* — has no receipt
726
+ to carry from. That run leaves `.gateforge/test-gates/run-record.json`
727
+ instead: a MAC'd, digest-bound record of the execution result, the
728
+ attestation, the candidate tree, the inputs, the policy, the engine
729
+ bundle, the execution boundary and the per-test outcomes, with no
730
+ verdict. It is never accepted as a receipt by `check` or the broker. Fix
731
+ only the failing test and run the same command; the record is the parent
732
+ and the report says `kept 562 from the previous run`. Two rules keep that
733
+ honest: every test that did **not** pass in the recorded run must be
734
+ inside the affected set (the change must have touched it) and must pass
735
+ now. Otherwise:
736
+
737
+ ```text
738
+ the previous run's test playwright:chromium:e2e/checkout.spec.ts:checks out failed outside the affected set → changed-scope run
739
+ the previous run's test playwright:chromium:e2e/legacy.spec.ts:old journey no longer exists and no changed file explains it → changed-scope run
740
+ the previous receipt sealed a slice, not a whole-suite run → changed-scope run
741
+ the previous receipt graded 561 obligation(s) while this candidate declares 563 → changed-scope run
742
+ ```
743
+
744
+
745
+ **When the previous run cannot be the parent.** A parent is only usable
746
+ when it is bound to this run: the commit **its own document names**, the
747
+ same approved policy, engine bundle and execution boundary, an intact
748
+ signature, and a sealed tree that really is the tree of that commit. No
749
+ CI variable is consulted — see **Consecutive re-seals** below. When the
750
+ run state holds such a document and no parent qualifies, the run says so
751
+ in **one plain line** naming the first binding that failed, instead of
752
+ falling through to the changed-scope path in silence (which looks exactly
753
+ like a run that never had a parent):
754
+
755
+ ```text
756
+ test-gates: the previous run cannot be re-sealed from: its sealed tree is not the tree of commit 9c8a3b7 (uncommitted changes were tested) → changed-scope run
757
+ ```
758
+
759
+ So commit everything the run tests: a run over uncommitted changes can
760
+ never be a re-seal parent. Sign every run with the same verifier key
761
+ (`gateforge key create` once, or one `GATEFORGE_WITNESS_VERIFIER_KEY`
762
+ secret in CI): a run signed with a one-off key reads `it was signed with
763
+ a different verifier key` and can never be a parent either. The other bindings read the same way — `it
764
+ was sealed at commit 1a2b3c4, which is not an ancestor of HEAD`, `the
765
+ approved policy changed`, `the engine changed`, `the execution boundary
766
+ changed`, `its execution result was replaced by a later run`, `its
767
+ signature does not verify with this keyring`, `the test inventory
768
+ is incomplete`, `a named/result-only run never re-seals` — and each is
769
+ followed by `→ changed-scope run`. With the path off, or when the run
770
+ state holds no parent document at all, nothing is printed and the run is
771
+ byte-identical to before.
772
+
773
+ **Consecutive re-seals.** A re-seal is itself a whole-suite proof: it
774
+ names the parent it carried from and seals a
775
+ `coveredObligationFingerprints` list covering the whole repository, so the
776
+ **next** re-seal carries from exactly the same coverage. Fix one test,
777
+ commit, run; fix the next, commit, run — each re-seal's parent is the
778
+ previous re-seal, and each printed line counts what the whole chain
779
+ carries:
780
+
781
+ ```text
782
+ only test files changed: re-ran 1 test(s), kept 562 from the previous receipt
783
+ ```
784
+
785
+ The chain is retained hop by hop in `.gateforge/test-gates/reseal-chain/`,
786
+ each hop holding its parent receipt, that parent's execution result, the
787
+ catalog the classification used, and the witness evidence every
788
+ contributing run issued. A test carries when **no** hop re-ran it, so a
789
+ spec untouched across the whole chain keeps its original evidence, and
790
+ the receipt of record states the chain's total in `carriedTests`.
791
+
792
+ **At most five in a row.** Each re-seal carries its parent, so the
793
+ evidence can be walked back at most five hops before it has drifted too
794
+ far to recompute honestly. The sixth consecutive re-seal prints
795
+
796
+ ```text
797
+ test-gates: the run state already retains 5 consecutive re-seals, the bound this path may chain to → changed-scope run
798
+ ```
799
+
800
+ and takes its own changed-scope run; `check --require-e2e` rejects a
801
+ longer chain the same way.
802
+
803
+ **The parent is the previous run in the state dir.** No CI variable is
804
+ involved: the parent must be a document in
805
+ `.gateforge/test-gates/` — `receipt.json` from a clean run, or
806
+ `run-record.json` from a failed one — whose own `gitSha` names a commit
807
+ that **exists in this checkout and is an ancestor of HEAD**, and whose
808
+ sealed tree really is the tree of that commit. A merge-base variable is
809
+ the wrong thing to bind to (no CI sets it to the commit the previous
810
+ pipeline tested), so the re-seal path ignores
811
+ `CI_MERGE_REQUEST_DIFF_BASE_SHA` and `GITHUB_BASE_REF` entirely. What
812
+ that means for a pipeline is simple: **the state directory must persist
813
+ from one pipeline to the next** — cache or restore it, keyed by branch.
814
+ With a cold cache the state dir holds no parent, the run is the ordinary
815
+ run, and nothing is printed.
816
+
817
+ **What a carried test brings with it.** A carried test brings its
818
+ **outcomes and the evidence those outcomes were witnessed with**: the
819
+ parent run's `records.json` and `claims.json`, **retained by the parent
820
+ run itself the moment it sealed** — into
821
+ `.gateforge/test-gates/reseal-parent/`, so the runs a pipeline does in
822
+ between (a materialization pre-step that rewrites `manifest.json`, a
823
+ hand-picked `--result-only` selection) cannot take the witness envelope
824
+ away from the re-seal — and bound to the parent run's
825
+ attestation — the envelope must carry the parent document's own run id
826
+ and input digest, hash to the `evidenceAttestationDigest` that document
827
+ seals, and verify with your keyring, or the re-seal is refused like any
828
+ other parent binding. In a **chain** there is more than one contributing
829
+ run, so there is more than one envelope: every retained hop's records are
830
+ authorized only by the envelope **that run** issued, and nobody's
831
+ envelope vouches for anybody else's records. A hop whose envelope does
832
+ not verify takes the whole re-seal with it.
833
+
834
+ Attribution is by the witness-issued test id, and only the records and
835
+ claims whose test **no hop of the chain** re-ran are carried: a re-run
836
+ test's parent record never survives, so a test that stopped proving
837
+ anything after the fix leaves its obligation unproven. The graded
838
+ evidence is the **union** of the carried half and the re-run's own, it is
839
+ what the report and the receipt's `verdictSummary` grade, and it is what
840
+ stands in the run state afterwards — so the next
841
+ `check --changed --require-e2e` grades the same evidence this run did.
842
+ The receipt binds the union in `carriedEvidenceDigest`, MAC-covered like
843
+ the other re-seal fields.
844
+
845
+ **CI and the broker recompute all of it.** A re-sealed receipt is never
846
+ believed. `check --require-e2e` and `broker commit` walk the retained
847
+ chain **hop by hop, outward** with their **own** keyring and object store
848
+ and redo the work: each parent authenticates, the two sealed trees are
849
+ re-diffed, the claimed changed paths are compared with the real diff, the
850
+ change set is re-classified from that hop's retained catalog, the
851
+ affected set is recomputed and matched against the fresh outcomes, and
852
+ the parent must carry exactly the rest — reduced by what an inner hop
853
+ already re-ran, so the chain's carried total is checked once, against the
854
+ receipt of record, after every hop has been seen. Each hop's retained
855
+ evidence is authenticated against **every** contributing run's envelope
856
+ with that same keyring, and the state evidence must equal the recomputed
857
+ union. Any mismatch is a typed `EVIDENCE_STALE` with the exact reason, for
858
+ example:
859
+
860
+ ```text
861
+ the re-sealed receipt names parent 9f2c… but the run state retains no parent receipt (fail closed)
862
+ re-seal hop 1 claims a receipt parent but the run state retains a run-record (fail closed)
863
+ re-seal hop 1's parent receipt does not authenticate with this keyring: … (fail closed)
864
+ re-seal hop 2's parent receipt does not authenticate with this keyring: … (fail closed)
865
+ re-seal hop 1's retained evidence does not recompute: its evidence attestation does not verify with this keyring (fail closed)
866
+ re-sealed receipt claims 561 carried test(s) but its chain holds 560 carried outcome(s)
867
+ the re-sealed receipt carries 6 consecutive re-seals, past the bound of 5 — run the full suite
868
+ this consumer has no verifier keyring or object store, so the re-seal cannot be recomputed (fail closed)
869
+ ```
870
+
871
+ **Residual risk.** Tests that pass or fail depending on what ran beside
872
+ them are the honest limit of any partial re-run: a test that shares data
873
+ or ordering with another can pass in a partial run and fail in the full
874
+ one, or the reverse. The re-seal never claims more than the diff proves,
875
+ but a partial run is not a substitute for a periodic full run — keep
876
+ running the whole suite on the merge request, and use this to shorten
877
+ the fix loop.
878
+
879
+ ## Let Gateforge drive the whole run: `gateforge run`
880
+
881
+ The script above is the shape of a managed run. `gateforge run` performs it
882
+ for you, in that order, and stops at the first failure:
883
+
884
+ 1. **preflight** (strict) — the managed-run preconditions, see below;
885
+ 2. **recipe** — `prepare`, `reset`, `seed`, `services_up`, `healthcheck`;
886
+ 3. **`gateforge test-gates`** — supervised, with the flags you passed
887
+ (`gateforge run -- --changed`);
888
+ 4. **`gateforge check --require-e2e`** — the strict receipt check; a scoped
889
+ run (`gateforge run -- --changed --scope changed`) seals a receipt for the
890
+ changed slice only, so it is checked at that scope with
891
+ `check --changed --require-e2e`;
892
+ 5. **`services_down`** — always, after success, after a failing gate, and
893
+ after a failing recipe step.
894
+
895
+ It adds no authority: each step is an existing command with its existing
896
+ verdict. What you gain is order, one plain line per step with its duration,
897
+ and an exit code that names the first failing step.
898
+
899
+ ### Exit codes
900
+
901
+ | Step | Code |
902
+ | --- | --- |
903
+ | usage, config, or recipe error | 2 |
904
+ | preflight FAIL | 1 |
905
+ | recipe step | the command's own code; 124 when the step exceeded its `timeoutSeconds`, 127 when it could not start |
906
+ | `test-gates` | its own code (1 obligations unresolved or the suite failed, 2 config) |
907
+ | `check --require-e2e` | its own code (1 no verifying receipt, 2 config) |
908
+ | success | 0 |
909
+
910
+ ### The recipe: `.gateforge/runtime.yml`
911
+
912
+ Optional and additive: with no such document, `gateforge run` starts and
913
+ stops nothing and behaves exactly like the commands it sequences. The
914
+ document is the same one the witnessed pre-commit staged runtime uses, with
915
+ the `gateforge run` lifecycle keys added; a repository can declare either,
916
+ or both.
917
+
918
+ ```yaml
919
+ schemaVersion: 1
920
+ env_files: # paths only — never an inline value
921
+ - .gateforge/test.env
922
+ prepare:
923
+ commands: [['./scripts/install.sh']] # argv lists, never a shell string
924
+ runTimeoutSeconds: 900
925
+ reset:
926
+ commands: [['./scripts/reset-db.sh']]
927
+ timeoutSeconds: 300
928
+ seed:
929
+ commands: [['./scripts/seed.sh']]
930
+ retries: 1 # extra attempts after a failure
931
+ services_up:
932
+ commands: [['./scripts/start-stack.sh']]
933
+ healthcheck:
934
+ commands: [['./scripts/health.sh']]
935
+ timeoutSeconds: 60
936
+ retries: 5
937
+ services_down:
938
+ commands: [['./scripts/stop-stack.sh']]
939
+ ```
940
+
941
+ Rules the recipe lives under:
942
+
943
+ - **paths, never secrets.** `env_files` entries must be existing files; an
944
+ entry carrying `NAME=value` is a schema error. The values are loaded into
945
+ the step environment and are never printed, never logged by Gateforge, and
946
+ never included in a message.
947
+ - **no shell strings.** Every command is an argv list, so nothing is
948
+ word-split or re-interpreted. If you need a pipeline, put it in your own
949
+ script.
950
+ - **one line per step, output off the console.** Command output is appended
951
+ to `.gateforge/test-gates/run-recipe/<step>-log.txt`; the console only
952
+ receives the step line and, on failure, the log path.
953
+ - **unknown keys fail closed.** A typo, a malformed step, or a missing env
954
+ file is a plain error with exit 2 — Gateforge never runs a recipe it did
955
+ not fully understand.
956
+
957
+ ## Run that same proof in CI: the witnessed job template
958
+
959
+ The same run belongs in CI, and the glue around it (job-scoped names, a
960
+ private workspace, base-sha forwarding, verdict extraction, artifacts) is
961
+ generic. Generate it instead of hand-writing it a second time:
962
+
963
+ ```sh
964
+ gateforge enforce --ci gitlab --witnessed # .gateforge/ci/gitlab-witnessed.yml
965
+ gateforge enforce --ci github --witnessed # .github/workflows/gateforge-witnessed.yml
966
+ ```
967
+
968
+ The generated job is a plain file you review and edit. An existing file is
969
+ never overwritten (`exists, leaving untouched: <path>`), and without the
970
+ flag every generated file is byte-identical to what it always was. The
971
+ static job keeps its own file: the witnessed lane is additive.
972
+
973
+ What the job does, in order:
974
+
975
+ 1. installs the pinned `@gate-forge/cli` from the repository's lockfile
976
+ (or manifest) and refuses to continue on another version;
977
+ 2. creates a **private, job-scoped workspace** and exports
978
+ `GATEFORGE_CI_JOB_SCOPE`, `GATEFORGE_CI_STACK_NAME`,
979
+ `GATEFORGE_CI_IMAGE_NAME` and `GATEFORGE_CI_WORKSPACE`, all derived from
980
+ the CI job id — your recipe may use them for a compose stack or a volume,
981
+ and two concurrent jobs of one project can never collide;
982
+ 3. **forwards the merge-request base sha** into the environment both
983
+ supervised commands run in (GitLab: `CI_MERGE_REQUEST_DIFF_BASE_SHA`;
984
+ GitHub: the fetched base ref plus its merge base). This is the one step
985
+ worth checking in review: without it the `auto` scope provider falls back
986
+ to a local diff, which in CI selects zero changed files and quietly
987
+ narrows what the run grades;
988
+ 4. runs `gateforge run -- --changed --scope full`, so your recipe owns
989
+ reset/seed/services and the engine still owns every verdict. **Full scope
990
+ is the default**: narrowing the run is your edit, not the template's. The
991
+ run prints straight into the job log, so the progress stream shows each
992
+ test as it finishes;
993
+ 5. reads the verdict out of `report.json` (never out of a parsed log line);
994
+ 6. uploads `report.json`, `receipt.json`, `execution-result.json` and
995
+ `failures.json` as artifacts, `when: always` / `if: always()`. The
996
+ suite's raw output is never written to a file or uploaded: it passes
997
+ through the run and can carry your app's secrets.
998
+
999
+ You fill in two things: the recipe (`.gateforge/runtime.yml`, above) and the
1000
+ secret variables. On GitLab they are protected, masked CI variables; on
1001
+ GitHub they are the repository secrets `GATEFORGE_WITNESS_VERIFIER_KEY` and
1002
+ `GATEFORGE_APPROVED_POLICY_DIGEST`, passed as environment values on the run
1003
+ step only. The job never echoes a secret variable, and the recipe log
1004
+ (`.gateforge/test-gates/run-recipe/`) is deliberately **not** an artifact:
1005
+ your own commands may print your own secrets. Add it only if you know your
1006
+ recipe logs are clean.
1007
+
1008
+ ## Read the preconditions before a long run
1009
+
1010
+ `gateforge enforcement doctor` prints a `run preconditions` block: one
1011
+ read-only line per precondition with the exact fix command.
1012
+
1013
+ | Line | What it means | Fix it with |
1014
+ | --- | --- | --- |
1015
+ | `verifier-key` | an active key resolves outside the repository (a run cannot seal a verifying receipt without one) | `gateforge key create --confirm` |
1016
+ | `approved-policy` | the owner-approved policy pin is provisioned from a trusted channel and matches this candidate | export `GATEFORGE_APPROVED_POLICY_DIGEST=<digest>` outside the candidate |
1017
+ | `runner` | the configured runner's binary resolves and reports a version | `npm install --save-dev <runner>` |
1018
+ | `interpreter` | every configured suite's `argv[0]` exists AND runs | correct `diagnostics.suites.argv[0]` (e.g. `.venv/bin/python`) |
1019
+ | `bytecode-safety` | the run cannot rewrite `__pycache__` bytes into the candidate tree | `PYTHONDONTWRITEBYTECODE=1 gateforge run`, or pre-compile outside the run |
1020
+ | `target` | the configured target base URL answers (only probed when one is configured; never with `--witness-url`, because a probe through an external witness's proxy counts as an exchange before the run binds it) | start the app, then export `GATEFORGE_TARGET_BASE_URL` |
1021
+ | `app-healthcheck` | the recipe's own healthcheck passes (only when a recipe declares one) | make the app healthy, or fix the declared healthcheck |
1022
+ | `host-load` | advisory only: load average and free disk | never fails a run |
1023
+ | `candidate-tree` | the tree can be hashed; uncommitted changes are reported | commit or stash before the run |
1024
+
1025
+ By default the doctor is report-only and still exits 0 — today's behavior is
1026
+ unchanged. `gateforge enforcement doctor --strict-preflight` exits 1 at the
1027
+ first failing precondition, which is exactly what `gateforge run` does before
1028
+ it starts.
1029
+
1030
+ ## Find timing bugs on purpose
1031
+
1032
+ **Rule:** When a test passes but the product has shipped a stale-response
1033
+ race, do not wait for a loaded machine to find it again. Re-run the
1034
+ test with `--chaos <seed> --result-only` and keep the seed.
1035
+
1036
+ **Why:** A race — an older list response landing after a newer one, so
1037
+ the UI shows the wrong tab's rows — only shows up when the older request
1038
+ happens to be slower. On a fast network it never appears, and on a busy
1039
+ one it appears at random, which makes it impossible to reproduce, hand
1040
+ over, or prove fixed. The witness already sits on the request path of
1041
+ every witnessed test, so it can make the timing uneven deliberately
1042
+ instead of waiting for luck. Only timing moves: the bytes, the status,
1043
+ the headers and the evidence semantics are exactly what the app sent.
1044
+
1045
+ **Example:**
1046
+
1047
+ ```bash
1048
+ # One named test, with its response timing perturbed from a seed.
1049
+ gateforge test-gates --test 'specs/tabs.spec.js#tab B rows win' \
1050
+ --result-only --chaos 4 --progress stderr
1051
+
1052
+ # The run names the seed it used, and the seed replays the schedule:
1053
+ # timing chaos: seed 4 (max delay 400 ms, reorder on) - replay with --chaos 4
1054
+ ```
1055
+
1056
+ The same seed always produces the same schedule, so the run that failed
1057
+ is the run you can re-run. The report and the sealed execution result
1058
+ carry it: `chaos: { seed, maxDelayMs, reorder, schedule }`, where every
1059
+ entry names the route key (method + pathname, query stripped — never a
1060
+ credential), the request index, how long the response was held, and
1061
+ whether it went out before its predecessor. A second run with the same
1062
+ seed records the same schedule; that is what makes the finding a finding
1063
+ instead of a ghost.
1064
+
1065
+ Two rules keep it safe to run at any time:
1066
+
1067
+ - It is only accepted with `--result-only`, exactly like `--test`. A run
1068
+ whose timing was perturbed on purpose finds races; it never proves a
1069
+ commit, never seals a receipt and never writes the run record.
1070
+ - Bounds are yours to tune in `.gateforge.yml` and never switch it on:
1071
+
1072
+ ```yaml
1073
+ run:
1074
+ chaos:
1075
+ maxDelayMs: 400 # default; the ceiling for every applied delay
1076
+ reorder: true # default; may a later response go out first
1077
+ ```
1078
+
1079
+ Without `--chaos`, that configuration changes nothing: a repository
1080
+ that declares `run.chaos` and never passes the flag runs, reports and
1081
+ seals byte-identically. A seed that is not a non-negative integer is
1082
+ refused with exit 2 and one plain line, before a witness or a browser
1083
+ is started.
1084
+
1085
+ ### When your repository starts the witness itself
1086
+
1087
+ A repository whose own script starts the witness and hands
1088
+ `test-gates --witness-url` the origin needs **nothing on the witness
1089
+ side**: the run hands the whole plan to the witness with the run
1090
+ context, before the first test opens a session.
1091
+
1092
+ ```bash
1093
+ # 1. The repository's own script starts a plain witness, as always.
1094
+ ./scripts/start-witness.sh & # prints the origin and the run token
1095
+
1096
+ # 2. The run names the seed; the witness is never reconfigured.
1097
+ gateforge test-gates --test 'specs/tabs.spec.js#tab B rows win' \
1098
+ --result-only --chaos 4 \
1099
+ --witness-url "$WITNESS_URL" --run-token "$RUN_TOKEN" --out "$RUN_STATE"
1100
+ ```
1101
+
1102
+ The bounds are still yours, in `run.chaos` under `.gateforge.yml` — the
1103
+ same two keys, the same defaults, the same ceiling. What changed is
1104
+ only who applies them: a witness `test-gates` starts gets them in its
1105
+ environment, and one you start gets them in the binding. Either way the
1106
+ report labels the plan that actually ran.
1107
+
1108
+ Two rules keep it honest, and both cost seconds rather than a suite:
1109
+
1110
+ - A **normal** run against a witness that was itself started with
1111
+ `GATEFORGE_CHAOS_SEED` is refused before any test runs (exit 2, one
1112
+ line, naming the variable to unset). A witness that perturbs timing
1113
+ can never serve a run that seals.
1114
+ - A witness too old to accept run options is refused for `--chaos` (it
1115
+ would apply no schedule while reporting as if it had) and says one
1116
+ plain line for twin coverage. Neither failure is ever silent.
1117
+
1118
+ Keep a race-free twin next to the racy test — the same requests against
1119
+ a page that renders by request id. It must stay green under the same
1120
+ seed; when it does not, the timing is not the finding.
1121
+
1122
+ ## Keep raw and witnessed twins honest
1123
+
1124
+ **Rule:** When a raw test and a witnessed test are meant to cover the
1125
+ same thing, link them and switch twin coverage on, so the run compares
1126
+ the requests each side actually made.
1127
+
1128
+ **Why:** The reported bug was GREEN. A raw test and its witnessed twin
1129
+ shared a helper whose parameter defaults sent them down different paths
1130
+ — the list call carried `?tab=all` in one and `?tab=open` in the other —
1131
+ so "green three times" proved nothing about the path the witnessed twin
1132
+ covered, and nothing in the run said so. Both tests were correct; they
1133
+ were not testing the same thing. Twin coverage records the REQUEST SHAPE
1134
+ each twin exercised (a method, a route template, and the values of the
1135
+ query keys YOU allowlist) and reports `TWIN_PATH_DIVERGENT` when the two
1136
+ sides disagree, naming both tests and the exact differing value.
1137
+
1138
+ **Example:**
1139
+
1140
+ ```yaml
1141
+ # .gateforge.yml
1142
+ enforcement:
1143
+ twinPaths: advisory # or: block (then the finding fails the run)
1144
+ twinQueryKeys: [tab] # values of THESE keys may appear in a finding
1145
+ ```
1146
+
1147
+ Link the pair in one of two ways, both read only when `twinPaths` is set:
1148
+
1149
+ - the test map, when the link should survive a rename of either test —
1150
+ `twinOf: <the raw twin's logical key>` on the witnessed test's entry
1151
+ in `.gateforge/test-map.yml`;
1152
+ - the title convention: `X [witnessed]` next to `X raw`, else next to the one
1153
+ `X raw: <description>` (so `UC-7 [witnessed]: …` pairs with `UC-7 raw: …`),
1154
+ else next to a bare `X`. Two described raw tests under one label link
1155
+ nothing: name the pair with `twinOf`.
1156
+
1157
+ Both tests must send their requests through the witness, so the raw twin
1158
+ runs with the Gateforge test fixture too (`test` from
1159
+ `@gate-forge/pack-playwright`); it then opens an observation-only session
1160
+ and issues nothing. A raw twin written as a plain Playwright test sends
1161
+ nothing through the witness: the pair is not compared, and the run says
1162
+ so on one line (`test-gates: twin pair not compared: the raw test '…'
1163
+ sent no request through the witness`), never as "the twins agree".
1164
+
1165
+ ```bash
1166
+ # A run with the pair linked reports the divergence and keeps its verdict:
1167
+ gateforge test-gates --changed --format json
1168
+ # advisories: [ { cause: "TWIN_PATH_DIVERGENT",
1169
+ # detail: "GET /api/items?tab=open is exercised by '…:lists open items
1170
+ # [witnessed]' and never by '…:lists open items raw'" } ]
1171
+ ```
1172
+
1173
+ Four rules keep it honest:
1174
+
1175
+ - The raw twin proves nothing, and the engine enforces it: its session
1176
+ is marked OBSERVATION-ONLY from the registered test identity, and
1177
+ every submission from it is refused with 403. What it contributes is
1178
+ its request shapes.
1179
+ - A shape never carries a URL, a body or a value you did not
1180
+ allowlist. With no `twinQueryKeys` a shape says a parameter was sent
1181
+ and never what it said, so a report is safe to paste into a bug.
1182
+ - With `twinPaths` absent — or set, with no pair linked — nothing is
1183
+ wired, nothing is recorded, no state file is written, and the report
1184
+ is byte-identical to a run that never heard of twins.
1185
+ - The comparison is by the runner's REGISTERED IDENTITY (project, file,
1186
+ title path), never by a runner-assigned test id, because a supervised
1187
+ run drives its own trusted config and the ids it runs tests under are
1188
+ not the ids the repository's config enumerates.
1189
+
1190
+ - **Your own witness needs no twin environment.** When the repository
1191
+ starts the witness itself and passes `--witness-url`, the run hands it
1192
+ the allowlist and the route inventory with the run context, so the
1193
+ pair is compared with nothing configured on the witness side:
1194
+
1195
+ ```bash
1196
+ ./scripts/start-witness.sh &
1197
+ gateforge test-gates --changed --format json \
1198
+ --witness-url "$WITNESS_URL" --run-token "$RUN_TOKEN" --out "$RUN_STATE"
1199
+ ```
1200
+
1201
+ A witness too old to accept run options cannot record shapes, and the
1202
+ run says so in one line (`twin path coverage needs a witness that
1203
+ accepts run options — this witness does not; pairs were not
1204
+ compared`) instead of reporting twins that agree because nobody
1205
+ looked.
1206
+
172
1207
  ## Reusable run script
173
1208
 
174
1209
  Replace the reset and seed comments with durable commands for your disposable stack. The seed must come from this checkout. `test-gates` starts and supervises the witness for the run.
@@ -177,7 +1212,7 @@ Replace the reset and seed comments with durable commands for your disposable st
177
1212
  #!/usr/bin/env bash
178
1213
  set -euo pipefail
179
1214
 
180
- # Reset the disposable database from a baseline dump or reset script.
1215
+ # Reset the disposable database from a clean-state dump or reset script.
181
1216
  # <your reset command>
182
1217
 
183
1218
  # Seed it from this checkout.