@gate-forge/cli 0.7.1 → 0.9.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 (296) hide show
  1. package/README.md +91 -704
  2. package/dist/adapter-audit.d.ts +208 -0
  3. package/dist/adapter-audit.d.ts.map +1 -0
  4. package/dist/adapter-audit.js +579 -0
  5. package/dist/adapter-audit.js.map +1 -0
  6. package/dist/adapter-scaffold.d.ts +91 -0
  7. package/dist/adapter-scaffold.d.ts.map +1 -0
  8. package/dist/adapter-scaffold.js +474 -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 +61 -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 +751 -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 +355 -0
  44. package/dist/commands/adapters.js.map +1 -0
  45. package/dist/commands/adopt.d.ts +7 -0
  46. package/dist/commands/adopt.d.ts.map +1 -1
  47. package/dist/commands/adopt.js +44 -2
  48. package/dist/commands/adopt.js.map +1 -1
  49. package/dist/commands/baseline.d.ts.map +1 -1
  50. package/dist/commands/baseline.js +42 -1
  51. package/dist/commands/baseline.js.map +1 -1
  52. package/dist/commands/blocking.d.ts +105 -2
  53. package/dist/commands/blocking.d.ts.map +1 -1
  54. package/dist/commands/blocking.js +395 -53
  55. package/dist/commands/blocking.js.map +1 -1
  56. package/dist/commands/check.d.ts +36 -0
  57. package/dist/commands/check.d.ts.map +1 -1
  58. package/dist/commands/check.js +1068 -64
  59. package/dist/commands/check.js.map +1 -1
  60. package/dist/commands/classify.d.ts +2 -1
  61. package/dist/commands/classify.d.ts.map +1 -1
  62. package/dist/commands/classify.js +188 -5
  63. package/dist/commands/classify.js.map +1 -1
  64. package/dist/commands/enforce.d.ts +4 -4
  65. package/dist/commands/enforce.d.ts.map +1 -1
  66. package/dist/commands/enforce.js +41 -9
  67. package/dist/commands/enforce.js.map +1 -1
  68. package/dist/commands/enforcement.d.ts +13 -1
  69. package/dist/commands/enforcement.d.ts.map +1 -1
  70. package/dist/commands/enforcement.js +880 -33
  71. package/dist/commands/enforcement.js.map +1 -1
  72. package/dist/commands/explain.d.ts +1 -1
  73. package/dist/commands/explain.d.ts.map +1 -1
  74. package/dist/commands/explain.js +162 -3
  75. package/dist/commands/explain.js.map +1 -1
  76. package/dist/commands/history.d.ts +12 -0
  77. package/dist/commands/history.d.ts.map +1 -0
  78. package/dist/commands/history.js +45 -0
  79. package/dist/commands/history.js.map +1 -0
  80. package/dist/commands/init-presets.d.ts +155 -0
  81. package/dist/commands/init-presets.d.ts.map +1 -0
  82. package/dist/commands/init-presets.js +203 -0
  83. package/dist/commands/init-presets.js.map +1 -0
  84. package/dist/commands/init.d.ts +7 -12
  85. package/dist/commands/init.d.ts.map +1 -1
  86. package/dist/commands/init.js +987 -99
  87. package/dist/commands/init.js.map +1 -1
  88. package/dist/commands/keys.d.ts.map +1 -1
  89. package/dist/commands/keys.js +29 -13
  90. package/dist/commands/keys.js.map +1 -1
  91. package/dist/commands/next.d.ts.map +1 -1
  92. package/dist/commands/next.js +846 -19
  93. package/dist/commands/next.js.map +1 -1
  94. package/dist/commands/pre-commit.d.ts +25 -0
  95. package/dist/commands/pre-commit.d.ts.map +1 -1
  96. package/dist/commands/pre-commit.js +91 -6
  97. package/dist/commands/pre-commit.js.map +1 -1
  98. package/dist/commands/quarantine.d.ts +16 -0
  99. package/dist/commands/quarantine.d.ts.map +1 -0
  100. package/dist/commands/quarantine.js +213 -0
  101. package/dist/commands/quarantine.js.map +1 -0
  102. package/dist/commands/run.d.ts +39 -0
  103. package/dist/commands/run.d.ts.map +1 -0
  104. package/dist/commands/run.js +196 -0
  105. package/dist/commands/run.js.map +1 -0
  106. package/dist/commands/test-gates.d.ts +284 -2
  107. package/dist/commands/test-gates.d.ts.map +1 -1
  108. package/dist/commands/test-gates.js +3620 -187
  109. package/dist/commands/test-gates.js.map +1 -1
  110. package/dist/commands/tests.d.ts +1 -1
  111. package/dist/commands/tests.d.ts.map +1 -1
  112. package/dist/commands/tests.js +264 -29
  113. package/dist/commands/tests.js.map +1 -1
  114. package/dist/docs-exclusions.d.ts.map +1 -1
  115. package/dist/docs-exclusions.js +18 -3
  116. package/dist/docs-exclusions.js.map +1 -1
  117. package/dist/endpoint-compiler.d.ts.map +1 -1
  118. package/dist/endpoint-compiler.js +78 -9
  119. package/dist/endpoint-compiler.js.map +1 -1
  120. package/dist/engine-browser.d.ts +183 -0
  121. package/dist/engine-browser.d.ts.map +1 -0
  122. package/dist/engine-browser.js +381 -0
  123. package/dist/engine-browser.js.map +1 -0
  124. package/dist/engine-identity.d.ts +100 -0
  125. package/dist/engine-identity.d.ts.map +1 -0
  126. package/dist/engine-identity.js +182 -0
  127. package/dist/engine-identity.js.map +1 -0
  128. package/dist/evaluate.d.ts +105 -1
  129. package/dist/evaluate.d.ts.map +1 -1
  130. package/dist/evaluate.js +149 -18
  131. package/dist/evaluate.js.map +1 -1
  132. package/dist/execution.d.ts +253 -9
  133. package/dist/execution.d.ts.map +1 -1
  134. package/dist/execution.js +309 -12
  135. package/dist/execution.js.map +1 -1
  136. package/dist/gateforge-owned.d.ts +78 -0
  137. package/dist/gateforge-owned.d.ts.map +1 -0
  138. package/dist/gateforge-owned.js +254 -0
  139. package/dist/gateforge-owned.js.map +1 -0
  140. package/dist/git-hooks.d.ts +35 -0
  141. package/dist/git-hooks.d.ts.map +1 -1
  142. package/dist/git-hooks.js +140 -1
  143. package/dist/git-hooks.js.map +1 -1
  144. package/dist/git-ignored.d.ts +27 -0
  145. package/dist/git-ignored.d.ts.map +1 -0
  146. package/dist/git-ignored.js +102 -0
  147. package/dist/git-ignored.js.map +1 -0
  148. package/dist/git-objects.d.ts +60 -0
  149. package/dist/git-objects.d.ts.map +1 -0
  150. package/dist/git-objects.js +152 -0
  151. package/dist/git-objects.js.map +1 -0
  152. package/dist/glob.d.ts +33 -14
  153. package/dist/glob.d.ts.map +1 -1
  154. package/dist/glob.js +96 -5
  155. package/dist/glob.js.map +1 -1
  156. package/dist/history.d.ts +52 -0
  157. package/dist/history.d.ts.map +1 -0
  158. package/dist/history.js +116 -0
  159. package/dist/history.js.map +1 -0
  160. package/dist/host-load.d.ts +49 -0
  161. package/dist/host-load.d.ts.map +1 -0
  162. package/dist/host-load.js +78 -0
  163. package/dist/host-load.js.map +1 -0
  164. package/dist/index.d.ts +4 -1
  165. package/dist/index.d.ts.map +1 -1
  166. package/dist/index.js +2 -1
  167. package/dist/index.js.map +1 -1
  168. package/dist/input-snapshot.d.ts +63 -9
  169. package/dist/input-snapshot.d.ts.map +1 -1
  170. package/dist/input-snapshot.js +195 -17
  171. package/dist/input-snapshot.js.map +1 -1
  172. package/dist/io.d.ts +49 -0
  173. package/dist/io.d.ts.map +1 -1
  174. package/dist/io.js +22 -0
  175. package/dist/io.js.map +1 -1
  176. package/dist/mapping.d.ts +84 -1
  177. package/dist/mapping.d.ts.map +1 -1
  178. package/dist/mapping.js +276 -5
  179. package/dist/mapping.js.map +1 -1
  180. package/dist/native-freeze.d.ts +217 -0
  181. package/dist/native-freeze.d.ts.map +1 -0
  182. package/dist/native-freeze.js +332 -0
  183. package/dist/native-freeze.js.map +1 -0
  184. package/dist/pipeline.d.ts +67 -1
  185. package/dist/pipeline.d.ts.map +1 -1
  186. package/dist/pipeline.js +164 -6
  187. package/dist/pipeline.js.map +1 -1
  188. package/dist/planes-inference.d.ts +12 -5
  189. package/dist/planes-inference.d.ts.map +1 -1
  190. package/dist/planes-inference.js +13 -15
  191. package/dist/planes-inference.js.map +1 -1
  192. package/dist/playwright-browsers.d.ts +210 -0
  193. package/dist/playwright-browsers.d.ts.map +1 -0
  194. package/dist/playwright-browsers.js +364 -0
  195. package/dist/playwright-browsers.js.map +1 -0
  196. package/dist/plugins.d.ts +15 -5
  197. package/dist/plugins.d.ts.map +1 -1
  198. package/dist/plugins.js +59 -9
  199. package/dist/plugins.js.map +1 -1
  200. package/dist/progress.d.ts +148 -0
  201. package/dist/progress.d.ts.map +1 -0
  202. package/dist/progress.js +263 -0
  203. package/dist/progress.js.map +1 -0
  204. package/dist/providers.d.ts +26 -1
  205. package/dist/providers.d.ts.map +1 -1
  206. package/dist/providers.js +39 -0
  207. package/dist/providers.js.map +1 -1
  208. package/dist/receipts.d.ts +1 -0
  209. package/dist/receipts.d.ts.map +1 -1
  210. package/dist/receipts.js +35 -7
  211. package/dist/receipts.js.map +1 -1
  212. package/dist/repo-scan.d.ts +15 -1
  213. package/dist/repo-scan.d.ts.map +1 -1
  214. package/dist/repo-scan.js +329 -34
  215. package/dist/repo-scan.js.map +1 -1
  216. package/dist/reseal-chain.d.ts +184 -0
  217. package/dist/reseal-chain.d.ts.map +1 -0
  218. package/dist/reseal-chain.js +735 -0
  219. package/dist/reseal-chain.js.map +1 -0
  220. package/dist/reseal-evidence.d.ts +241 -0
  221. package/dist/reseal-evidence.d.ts.map +1 -0
  222. package/dist/reseal-evidence.js +319 -0
  223. package/dist/reseal-evidence.js.map +1 -0
  224. package/dist/reseal.d.ts +181 -0
  225. package/dist/reseal.d.ts.map +1 -0
  226. package/dist/reseal.js +1620 -0
  227. package/dist/reseal.js.map +1 -0
  228. package/dist/response-field-guidance.d.ts +82 -0
  229. package/dist/response-field-guidance.d.ts.map +1 -0
  230. package/dist/response-field-guidance.js +184 -0
  231. package/dist/response-field-guidance.js.map +1 -0
  232. package/dist/route-plane-proposals.d.ts +100 -0
  233. package/dist/route-plane-proposals.d.ts.map +1 -0
  234. package/dist/route-plane-proposals.js +213 -0
  235. package/dist/route-plane-proposals.js.map +1 -0
  236. package/dist/run-cache.d.ts +260 -0
  237. package/dist/run-cache.d.ts.map +1 -0
  238. package/dist/run-cache.js +771 -0
  239. package/dist/run-cache.js.map +1 -0
  240. package/dist/run-preflight.d.ts +77 -0
  241. package/dist/run-preflight.d.ts.map +1 -0
  242. package/dist/run-preflight.js +774 -0
  243. package/dist/run-preflight.js.map +1 -0
  244. package/dist/run-recipe.d.ts +107 -0
  245. package/dist/run-recipe.d.ts.map +1 -0
  246. package/dist/run-recipe.js +295 -0
  247. package/dist/run-recipe.js.map +1 -0
  248. package/dist/run-reliability.d.ts +126 -0
  249. package/dist/run-reliability.d.ts.map +1 -0
  250. package/dist/run-reliability.js +221 -0
  251. package/dist/run-reliability.js.map +1 -0
  252. package/dist/runtime.d.ts +15 -0
  253. package/dist/runtime.d.ts.map +1 -1
  254. package/dist/runtime.js +11 -1
  255. package/dist/runtime.js.map +1 -1
  256. package/dist/scope.d.ts +20 -0
  257. package/dist/scope.d.ts.map +1 -1
  258. package/dist/scope.js +26 -5
  259. package/dist/scope.js.map +1 -1
  260. package/dist/secret-guard.d.ts +36 -0
  261. package/dist/secret-guard.d.ts.map +1 -0
  262. package/dist/secret-guard.js +63 -0
  263. package/dist/secret-guard.js.map +1 -0
  264. package/dist/singleton-guidance.d.ts +82 -0
  265. package/dist/singleton-guidance.d.ts.map +1 -0
  266. package/dist/singleton-guidance.js +138 -0
  267. package/dist/singleton-guidance.js.map +1 -0
  268. package/dist/staged-candidate.d.ts +17 -0
  269. package/dist/staged-candidate.d.ts.map +1 -1
  270. package/dist/staged-candidate.js +50 -0
  271. package/dist/staged-candidate.js.map +1 -1
  272. package/dist/state-artifacts.d.ts +70 -0
  273. package/dist/state-artifacts.d.ts.map +1 -0
  274. package/dist/state-artifacts.js +215 -0
  275. package/dist/state-artifacts.js.map +1 -0
  276. package/dist/state.d.ts +170 -2
  277. package/dist/state.d.ts.map +1 -1
  278. package/dist/state.js +248 -8
  279. package/dist/state.js.map +1 -1
  280. package/dist/unmatched-routes.d.ts +60 -0
  281. package/dist/unmatched-routes.d.ts.map +1 -0
  282. package/dist/unmatched-routes.js +131 -0
  283. package/dist/unmatched-routes.js.map +1 -0
  284. package/dist/verifier-keys.d.ts +33 -2
  285. package/dist/verifier-keys.d.ts.map +1 -1
  286. package/dist/verifier-keys.js +95 -9
  287. package/dist/verifier-keys.js.map +1 -1
  288. package/guides/CONNECT-YOUR-PROJECT.md +425 -0
  289. package/guides/QUICKSTART.md +306 -26
  290. package/guides/REFERENCE.md +1710 -0
  291. package/guides/RUNNER-NEUTRAL-EVIDENCE.md +199 -0
  292. package/guides/TEST-ENVIRONMENT.md +1044 -6
  293. package/guides/UPGRADE-0.6-to-0.7.md +3 -3
  294. package/guides/UPGRADE-0.7-to-0.8.md +114 -0
  295. package/guides/UPGRADE-0.8-to-0.9.md +104 -0
  296. package/package.json +10 -9
@@ -1,5 +1,7 @@
1
1
  # Quickstart
2
2
 
3
+ > Connecting a second project, or the whole flow including evidence adapters, the test map, and the first green commit? Read [Connect your project](CONNECT-YOUR-PROJECT.md) first; this guide stays the shortest path.
4
+
3
5
  This guide takes a project from install to a blocking gate. Gateforge does not create your app, database, seed data, logins, or test services. Your team or agent provides those first. See [Test environment](TEST-ENVIRONMENT.md).
4
6
 
5
7
  You need Node.js 20 or newer and an existing Playwright suite that can run against a disposable app.
@@ -12,26 +14,73 @@ Example for a React frontend, FastAPI backend, and SQLAlchemy data layer:
12
14
 
13
15
  ```sh
14
16
  npm i -D \
15
- @gate-forge/cli@0.7.1 \
16
- @gate-forge/pack-playwright@0.7.1 \
17
- @gate-forge/pack-http@0.7.1 \
18
- @gate-forge/pack-fastapi@0.7.1 \
19
- @gate-forge/pack-sqlalchemy@0.7.1
17
+ @gate-forge/cli@0.9.0 \
18
+ @gate-forge/pack-playwright@0.9.0 \
19
+ @gate-forge/pack-http@0.9.0 \
20
+ @gate-forge/pack-fastapi@0.9.0 \
21
+ @gate-forge/pack-sqlalchemy@0.9.0
20
22
  ```
21
23
 
22
24
  Use the project-local `gateforge` binary from your npm script or add `node_modules/.bin` to your shell `PATH`. If the scan recommends other packs, add only the ones your code uses, at the same version. A mismatched Gateforge package contract can stop the CLI with exit code 2 and `GATEFORGE_PACKAGE_INCOMPATIBLE`.
23
25
 
26
+ **Installing from tarballs** (a release that is not on the registry yet): install every `.tgz` of that release in ONE command. The CLI depends on shared packages and packs that are not in the list above, and npm resolves them from the files only when they are all in the same install; a partial set makes npm look for the rest on the registry and fail with `E404`.
27
+
28
+ ```sh
29
+ npm i -D ./gate-forge-*.tgz
30
+ ```
31
+
32
+ This installs every pack of the release; the scan still recommends the ones your code uses, and `.gateforge.yml` loads only those.
33
+
24
34
  **You should see:** npm installs the packages without a Gateforge compatibility error.
25
35
 
26
- **If not:** align every direct `@gate-forge/*` package to `0.7.1`, then install again. Do not work around the compatibility error.
36
+ **If not:** align every direct `@gate-forge/*` package to `0.9.0`, then install again. Do not work around the compatibility error.
37
+
38
+ ## 2. Pick a goal
39
+
40
+ Decide what Gateforge should do for you, then say so once:
41
+
42
+ ```sh
43
+ gateforge init --explain-presets # read what each goal writes
44
+ gateforge init --preset normal # or: light, or strict
45
+ ```
46
+
47
+ Or run `gateforge init` in a terminal and answer the one question it asks.
48
+
49
+ | Goal | What you get | What it writes |
50
+ | --- | --- | --- |
51
+ | `light` | untested code is listed, nothing blocks | `mode: warn` |
52
+ | `normal` | a commit that adds untested endpoints or models is refused (about a second, no test run) | `mode: changed`, pre-commit hook, CI job |
53
+ | `strict` | every push needs a real test run Gateforge watches (the *witness*) plus a *receipt*, the signed record of that run | `mode: strict`, staged gate, pre-push receipt check, CI job |
54
+
55
+ An *obligation* is one thing your policies say must be proven (for example
56
+ "this endpoint really stores what it receives"). A preset only chooses how
57
+ hard the gate blocks; it never waives an obligation and never hides code
58
+ from the scan.
27
59
 
28
- ## 2. Initialize the repository
60
+ An AI agent or CI run with no terminal and no `--preset` writes `light` only
61
+ and says so on ONE line, together with the flag that changes it:
62
+ `no terminal: writing the light preset (report everything, block nothing) — a
63
+ human must choose the goal: re-run with --preset <light|normal|strict>`. The
64
+ closing summary then reports what was written without naming the goal again.
65
+ Gateforge will not guess `normal` or `strict` for someone who is not there.
66
+
67
+ **You should see:** the goal you asked for, followed by a summary of what was
68
+ written and an `undo:` command.
69
+
70
+ **If not:** run `gateforge init --explain-presets`. To change the goal later,
71
+ edit the `mode:` key in `.gateforge.yml` (see
72
+ [Choose how strict the gate is](#choose-how-strict-the-gate-is)); re-running
73
+ `init` never rewrites an existing config.
74
+
75
+ ## 3. Initialize the repository
29
76
 
30
77
  ```sh
31
78
  gateforge init
32
79
  ```
33
80
 
34
- Gateforge scans the repository and prints recommended packs. By default, it writes:
81
+ Gateforge scans the repository and prints recommended packs, then applies the
82
+ goal you chose in step 2 (`--preset`, or the answer to the goal question).
83
+ It writes:
35
84
 
36
85
  - `.gateforge.yml`
37
86
  - `.gateforge/policies.yml`
@@ -40,13 +89,49 @@ Gateforge scans the repository and prints recommended packs. By default, it writ
40
89
  - `GATEFORGE.md`
41
90
  - `tests/e2e/gateforge/README.md` for the default overlay proof path
42
91
 
43
- It also creates `.gateforge/adapters/` and `.gateforge/waivers/`. It preserves existing files. A chosen documentation exclusion adds `.gateforge/docs-exclusions.yml`.
92
+ It also creates `.gateforge/adapters/` and `.gateforge/waivers/`, and adds
93
+ `.gateforge/test-gates/` (Gateforge's own run state: catalog, caches,
94
+ receipts, history) to `.gitignore` so `git add -A` never stages it. It
95
+ preserves existing files. A chosen documentation exclusion adds
96
+ `.gateforge/docs-exclusions.yml`.
44
97
 
45
- **You should see:** a scan summary, recommended packages, and a `skeleton ready` message.
98
+ **You should see:** a scan summary, recommended packages, the goal summary
99
+ with its `undo:` lines, and a `skeleton ready` message.
46
100
 
47
101
  **If not:** read the first error. Fix invalid or missing project configuration, install a recommended pack, then run `gateforge init` again. Existing files are not replaced by a normal rerun.
48
102
 
49
- ## 3. Find existing tests and suggestions
103
+ ### Already have code? Adopt what is there
104
+
105
+ If the repository already has an application, the next commit is not
106
+ green: `gateforge check` reports everything discovery finds as existing
107
+ debt, and debt blocks. Do not reach for `--no-verify` — there is a
108
+ command for exactly this situation, and `init` names it in its own output
109
+ whenever the repository already had code:
110
+
111
+ ```sh
112
+ gateforge adopt
113
+ ```
114
+
115
+ It records today's blocking findings as forgiven debt, in
116
+ `.gateforge/baselines/obligations.json` plus a dated receipt in
117
+ `.gateforge/baselines/adoption.json`, and then wires the blocking gate.
118
+
119
+ - The recorded set is **shrink-only**. It never forgives new work: new
120
+ unproven changes keep blocking. Resolve debt and shrink the set with
121
+ `gateforge baseline update`.
122
+ - Run it **once**. A second `adopt` is a no-op success; there is exactly
123
+ one sanctioned bulk-add per repository.
124
+ - Under `--preset strict` / `strictE2E`, an adopted E2E obligation is not
125
+ proof. It blocks with `ENFORCEMENT_UNTRUSTED` again as soon as a change
126
+ touches it — adoption forgives today's state, not the next edit.
127
+ - `gateforge adopt --help` prints this contract, and
128
+ `gateforge baseline diff <before> <after>` compares two adopted sets by
129
+ obligation ID.
130
+
131
+ Adopting forgives; it does not prove. The work of proving obligations
132
+ starts in step 4 and is unchanged.
133
+
134
+ ## 4. Find existing tests and suggestions
50
135
 
51
136
  First inventory the test suite:
52
137
 
@@ -62,11 +147,11 @@ gateforge tests suggest
62
147
 
63
148
  Discovery writes a derived catalog under `.gateforge/test-gates/`. Suggestions are for inspection; they do not create declarations or prove a test.
64
149
 
65
- **You should see:** discovered test keys and suggestions with obligation IDs and any mapping problems.
150
+ **You should see:** discovered test keys and suggestions with obligation IDs and any mapping problems. Candidates are ranked by the evidence their own row carries, so the strongest match is `#1`; each candidate prints the `why:` lines that produced its rank, the text surface shows the top five, and `gateforge tests suggest --json` returns the full ranked list. With a candidate in hand, the next action is to declare that existing test `observed-e2e` and run it under the witness — the overlay-test instruction appears only when no existing test fits (`new test needed: yes`). After a declaration, `gateforge check` prints `mapped to: <test> (not yet witnessed)` for obligations whose mapping exists but whose evidence has not been collected yet.
66
151
 
67
152
  **If not:** fix Playwright installation, configuration, or test enumeration first. Do not treat an empty or failed inventory as proof that no tests exist. If a test does not fit, the suggestion report explains what is missing.
68
153
 
69
- ## 4. Declare which existing tests cover claims
154
+ ## 5. Declare which existing tests cover claims
70
155
 
71
156
  Use either a Playwright annotation or the tracked map file. Declarations tell the gate which test is relevant; they are not proof by themselves.
72
157
 
@@ -97,35 +182,60 @@ gateforge tests mark \
97
182
 
98
183
  **If not:** rerun discovery, copy the exact test key and obligation ID, and resolve any mapping contradiction. Do not use a declaration to silence a blocker.
99
184
 
100
- ## 5. Prepare a verifier key and the app
185
+ ## 6. Prepare a verifier key and the app
101
186
 
102
187
  Keep the key outside the repository and run-state folder:
103
188
 
104
189
  ```sh
105
- mkdir -p "$HOME/.config/gateforge"
106
- gateforge key create --file "$HOME/.config/gateforge/keys.json" --confirm
107
- export GATEFORGE_WITNESS_VERIFIER_KEY_FILE="$HOME/.config/gateforge/keys.json"
190
+ gateforge key create --confirm
108
191
  ```
109
192
 
193
+ That is the whole ceremony: with no `--file` the CLI creates the key ring at
194
+ `"${XDG_CONFIG_HOME:-$HOME/.config}/gateforge/verifier-keyring.json"` (parent
195
+ directory included, owner-only, mode `0600`) and reads that same path on every
196
+ later command, so nothing has to be exported. Keep a key ring somewhere else
197
+ only on purpose: pass `--file <path>` to the ceremony AND export
198
+ `GATEFORGE_WITNESS_VERIFIER_KEY_FILE=<path>` for the runs that must read it —
199
+ one source, never both.
200
+
110
201
  The command prints a key ID, not the secret. Set the app URL and any session state the suite needs. The application and test environment must already be running; see [Test environment](TEST-ENVIRONMENT.md).
111
202
 
112
203
  **You should see:** `verifier key ring created` and an active key ID.
113
204
 
114
- **If not:** create the parent directory, check file permissions, and keep the key file outside `.gateforge/test-gates/` and the repository.
205
+ **If a ring already exists:** the command says so — it names the ring, the active
206
+ key ID and `gateforge key rotate --confirm` — and exits `2` without changing
207
+ anything. That is not a failure to fix: there is nothing to do while that key is
208
+ active.
209
+
210
+ **If not:** check file permissions, and keep the key file outside `.gateforge/test-gates/` and the repository. `gateforge enforcement doctor` names the ring it resolves (`verifier-key-location`) or the command that creates one.
115
211
 
116
- ## 6. Run the supervised tests
212
+ ## 7. Run the supervised tests
117
213
 
118
214
  ```sh
119
215
  gateforge test-gates --changed
120
216
  ```
121
217
 
122
- Gateforge supervises the selected suite and writes an authenticated receipt only after a complete successful run.
218
+ Gateforge supervises the full relevant mapped suite and writes an authenticated receipt only after a complete successful run. To run only the tests affected by your change, add `--scope changed` (see [How much runs?](#how-much-runs)).
219
+
220
+ **Once per machine, install the browsers the runner pins:**
221
+
222
+ ```sh
223
+ cd <the directory holding your Playwright config>
224
+ npx playwright install chromium
225
+ ```
226
+
227
+ On a Linux machine without the browser's system libraries — a container, a CI
228
+ image, WSL — use `npx playwright install --with-deps chromium` instead (it
229
+ installs them too, and needs root or sudo). `gateforge enforcement doctor`
230
+ names whichever case you are in: a missing build names `npx playwright install`,
231
+ and a build that is installed but cannot start names the loader's own line and
232
+ `npx playwright install-deps chromium`.
123
233
 
124
234
  **You should see:** the selected tests pass and the run seals a receipt.
125
235
 
126
236
  **If not:** use the first typed blocker. Check the changed-file base, mapping, app readiness, seed data, and verifier key. A test declaration or a plain passing test run is not a receipt.
127
237
 
128
- ## 7. Check the changed code
238
+ ## 8. Check the changed code
129
239
 
130
240
  ```sh
131
241
  gateforge check --changed --require-e2e
@@ -133,6 +243,10 @@ gateforge check --changed --require-e2e
133
243
 
134
244
  This checks the changed scope and requires a current receipt for the exact inputs. Do not edit files between the witnessed run and this check; changed bytes make the receipt stale.
135
245
 
246
+ New receipt JSON includes an authenticated `engine` identity. If present,
247
+ `check --require-e2e` blocks when the installed CLI version differs; older
248
+ receipts without this additive key retain their existing behavior.
249
+
136
250
  **You should see:** a clean report for the changed scope.
137
251
 
138
252
  **If not:** ask Gateforge for one next action:
@@ -143,25 +257,191 @@ gateforge next
143
257
 
144
258
  Follow its `do:` line, then run the check again. See [Test environment](TEST-ENVIRONMENT.md) if the block is caused by setup or test state.
145
259
 
146
- ## 8. Install the blocking hook and CI wiring
260
+ The first real `next` on a FastAPI repository asks which data plane owns a
261
+ route's records. That is an owner decision, so Gateforge explains the
262
+ question before asking it and prints one runnable command per answer. For
263
+ `DELETE /items/{}` on tenant-scoped records, the answer is `tenant`:
264
+
265
+ ```sh
266
+ gateforge init --planes # once: create the owner-reviewed planes file
267
+ gateforge classify plane 'app/main.py' tenant \
268
+ --reason 'Owner review confirms the tenant plane for DELETE /items/{}.' --confirm
269
+ ```
270
+
271
+ `classify plane` takes one file, one FOLDER, or one glob — a folder answer
272
+ is written as `match: 'app/routes/**'`, so a repository with hundreds of
273
+ routers needs one reviewed rule per router directory rather than one per
274
+ file:
275
+
276
+ ```sh
277
+ gateforge classify plane 'app/routes' tenant \
278
+ --reason 'Every router in this folder serves tenant-scoped records.' --confirm
279
+ ```
280
+
281
+ Then run `gateforge next` again: the same block must not reappear. A route
282
+ that is genuinely internal is the other answer, and it stays owner-only (an
283
+ `internalRules` entry in `.gateforge/classification-policy.yml`).
284
+
285
+ To verify a specific commit tree (for example, the tip of a pushed ref)
286
+ instead of the current worktree or index:
287
+
288
+ ```sh
289
+ gateforge check --candidate-commit <full-commit-sha> --require-e2e
290
+ ```
291
+
292
+ Add `--changed` to evaluate only that commit's first-parent diff. The command
293
+ uses an isolated checkout of the immutable commit tree.
294
+
295
+ ## 8a. Enable behavior cases
296
+
297
+ Behavior cases are the strongest evidence Gateforge can grade: the ENGINE
298
+ drives the request, the app's own state is read back, and the record is
299
+ sealed. They are opt-in, and the setup is printed rather than guessed.
300
+
301
+ `gateforge init` reads the repository and names the behavior packs it
302
+ finds — the code that decides a webhook signature, an authorization
303
+ outcome, a state transition, or a request schema. A non-interactive run
304
+ (an agent, a CI job) enables **nothing** and prints the exact flag for
305
+ each pack it found; in a terminal it asks per pack. Either way:
306
+
307
+ ```sh
308
+ gateforge init --behavior-packs webhook
309
+ ```
310
+
311
+ That writes `.gateforge/behavior.yml` — a scaffold, not approval: one
312
+ commented example case per enabled pack — and prints the exact
313
+ `behaviorPolicy: .gateforge/behavior.yml` line to add to an existing
314
+ `.gateforge.yml`. `--behavior` enables every pack the scan found,
315
+ `--behavior-packs webhook,auth` names them yourself, and `--no-behavior`
316
+ keeps the run silent. A repository with no behavior pack is byte-identical
317
+ to before.
318
+
319
+ `gateforge next` then prints the whole remaining setup for a route it
320
+ found but cannot prove, and every block is finished work rather than a
321
+ template:
322
+
323
+ * the `endpoints:` entry for that exact route, with the case ids, the
324
+ adapter-backed entity the case is graded against, and the recipe the
325
+ repository declares under `fixtures/`;
326
+ * the proof test that asks the ENGINE to drive each case;
327
+ * the `.gateforge/test-map.yml` entries that map every case to its test;
328
+ * the command that runs the gate.
329
+
330
+ Paste the blocks as printed, run the gate command, and run
331
+ `gateforge next` again. `example/webhook` is exactly this flow: a fresh
332
+ copy, `gateforge init --behavior-packs webhook`, the printed steps, and a
333
+ green `test-gates --changed` + `check --require-e2e`.
334
+
335
+ When a declaration needs a fact the repository has not declared (an
336
+ entity with no reviewed adapter, a recipe that does not say what a
337
+ delivery records), `next` prints that fact instead of a block that could
338
+ not pass: the case is never printed as if it were provable.
339
+
340
+ ## 9. Install the blocking hook and CI wiring
147
341
 
148
342
  ```sh
149
343
  gateforge init --blocking
150
344
  ```
151
345
 
152
- This installs and verifies an active pre-commit hook and adds CI wiring. Review the output and generated files:
346
+ `gateforge init --preset strict` does the same wiring plus the strict E2E
347
+ enforcement block, and `--preset normal` writes the fast static pre-commit
348
+ lane plus the CI job without the receipt lane. The explicit flags below keep
349
+ working exactly as before and always win over a preset.
350
+
351
+ This installs a static pre-commit lane and (for a new config) a pre-push
352
+ receipt lane, then adds strict CI wiring. Review the output and generated files:
153
353
 
154
354
  - `.git/hooks/pre-commit` (or the configured Git hooks path)
355
+ - `.git/hooks/pre-push` (verifies each pushed commit tip)
155
356
  - `.gateforge/hooks/gateforge-staged.sh`
156
- - `.gateforge/ci/gitlab-gateforge.yml`
157
- - `.gitlab-ci.yml` include
357
+ - `.gateforge/ci/gitlab-gateforge.yml` and `.gitlab-ci.yml` by default
358
+
359
+ The pre-commit lane checks staged bytes without requiring a receipt. The
360
+ pre-push lane runs `check --candidate-commit <sha> --require-e2e`; a missing
361
+ or stale receipt blocks the push. Existing configs without
362
+ `enforcement.receiptStage` retain their previous hook behavior.
363
+
364
+ `init --blocking` prints GitHub and GitLab branch-protection commands for an
365
+ owner to review and run; Gateforge never changes server settings itself.
366
+ For GitHub Actions, use `gateforge enforce --ci github` in an initialized
367
+ repository. It writes `.github/workflows/gateforge.yml`, which runs
368
+ `test-gates --changed` and verifies the exact commit with
369
+ `check --changed --candidate-commit "$GITHUB_SHA" --require-e2e`. Configure
370
+ the verifier key and policy pin as protected secrets. A local hook alone is
371
+ not server enforcement.
372
+
373
+ The generated GitHub workflow installs the published `@gate-forge/cli` from
374
+ the registry. To gate a release that is not on the registry yet (a local
375
+ `.tgz` or a directory), declare where CI must install it from and
376
+ regenerate:
158
377
 
159
- The hook and CI gate block changes that lack the required evidence. Configure protected CI secrets and require the generated CI job to pass on the protected branch; a local hook alone is not server enforcement.
378
+ ```sh
379
+ GATEFORGE_CI_ENGINE_SOURCE=vendor/gate-forge-cli-0.9.0.tgz \
380
+ gateforge enforce --ci github
381
+ ```
382
+
383
+ The workflow then installs that one specifier instead of the registry
384
+ release, so the file it must reach has to be committed with the repository.
385
+ Unset the variable and rerun the generator for the registry install. The
386
+ GitLab template needs no variable: it installs the repository's own declared
387
+ `@gate-forge/cli` dependency.
388
+
389
+ If your repository already had a `.pre-commit-config.yaml`, the wiring
390
+ appends to it and says so on one line, with the exact way back
391
+ (`undo: git restore -- .pre-commit-config.yaml`). Check that line before
392
+ you commit. Then put the `gateforge-check` entry FIRST: hooks that rewrite
393
+ files must not run after the gate, or they invalidate its receipt —
394
+ `enforcement doctor` reports those hooks as `hook-mutation` and names
395
+ those files.
160
396
 
161
397
  **You should see:** `installed:`, `updated:`, `verified:`, or a framework-managed hook message, followed by `blocking gate wired`.
162
398
 
163
399
  **If not:** follow the exact `required action` printed for an incomplete installation. Resolve hook-manager conflicts, then rerun `gateforge init --blocking` and verify the active hook.
164
400
 
401
+ ## How much runs?
402
+
403
+ | Command | Runs |
404
+ | --- | --- |
405
+ | `gateforge test-gates --changed` | every mapped test relevant to the repository (full scope) |
406
+ | `gateforge test-gates --changed --scope changed` | only tests mapped to obligations affected by the changed files |
407
+
408
+ "Changed files" come from `changed.provider`: the staged index locally, or the pull/merge request diff against its base in CI. No earlier receipt or full run is needed first, and commits already on the base branch are not re-tested.
409
+
410
+ A changed slice that affects no obligation (for example, only a log constant changed) does not seal a receipt, because "nothing affected" is not proof. Run full scope in that case. Documentation-only edits avoid this when their folders are approved with `gateforge init --docs-exclude`.
411
+
412
+ `check --changed --require-e2e` accepts a slice receipt only when it covers every currently changed obligation.
413
+
414
+ ## Choose how strict the gate is
415
+
416
+ `.gateforge.yml` takes one optional key:
417
+
418
+ ```yaml
419
+ mode: warn # evaluate and report everything, exit 0 (wouldBlock says what was found)
420
+ mode: changed # block only on debt this change touches; the full debt is still reported
421
+ mode: strict # today's behavior — also the default when the key is absent
422
+ ```
423
+
424
+ The key changes the GATE, never the evidence: verdicts, counts and cause
425
+ codes are identical in every mode, the active mode is printed in every
426
+ report, and `gateforge enforcement doctor` reports a non-strict mode as
427
+ `WARN`. A config/usage error still exits 2 in every mode. The key lives
428
+ inside the pinned trusted policy, so changing it is an owner decision.
429
+
430
+ ## Quarantine a flaky test
431
+
432
+ ```bash
433
+ gateforge quarantine 'playwright:chromium:tests/e2e/orders.spec.js:Orders>lists orders' \
434
+ --owner team-orders --approver lead@example.invalid \
435
+ --reason 'flaky in CI: seeded clock race' --expires 2026-04-30
436
+ ```
437
+
438
+ The test key is the catalog's logical key (`gateforge tests discover`
439
+ prints them). The quarantine removes that test from the required set for
440
+ at most 14 days. It proves nothing (an obligation only it covered stays
441
+ `missing`) and never blocks. An expired quarantine is ignored and BLOCKS
442
+ until it is renewed or deleted. Only the owner can write one, and the
443
+ file is part of the pinned trusted policy.
444
+
165
445
  ## Coming next
166
446
 
167
447
  - `gateforge tests sync` will generate test-map entries from annotations.