@gate-forge/cli 0.8.0 → 0.9.1

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 (136) hide show
  1. package/README.md +85 -1145
  2. package/dist/adapter-audit.d.ts +54 -0
  3. package/dist/adapter-audit.d.ts.map +1 -1
  4. package/dist/adapter-audit.js +48 -0
  5. package/dist/adapter-audit.js.map +1 -1
  6. package/dist/adapter-scaffold.d.ts +28 -3
  7. package/dist/adapter-scaffold.d.ts.map +1 -1
  8. package/dist/adapter-scaffold.js +145 -24
  9. package/dist/adapter-scaffold.js.map +1 -1
  10. package/dist/args.d.ts.map +1 -1
  11. package/dist/args.js +2 -0
  12. package/dist/args.js.map +1 -1
  13. package/dist/behavior-setup.d.ts.map +1 -1
  14. package/dist/behavior-setup.js +18 -5
  15. package/dist/behavior-setup.js.map +1 -1
  16. package/dist/commands/adapters.d.ts.map +1 -1
  17. package/dist/commands/adapters.js +73 -2
  18. package/dist/commands/adapters.js.map +1 -1
  19. package/dist/commands/adopt.d.ts +9 -1
  20. package/dist/commands/adopt.d.ts.map +1 -1
  21. package/dist/commands/adopt.js +72 -5
  22. package/dist/commands/adopt.js.map +1 -1
  23. package/dist/commands/blocking.d.ts +45 -2
  24. package/dist/commands/blocking.d.ts.map +1 -1
  25. package/dist/commands/blocking.js +165 -11
  26. package/dist/commands/blocking.js.map +1 -1
  27. package/dist/commands/check.d.ts +34 -0
  28. package/dist/commands/check.d.ts.map +1 -1
  29. package/dist/commands/check.js +152 -8
  30. package/dist/commands/check.js.map +1 -1
  31. package/dist/commands/classify.d.ts +1 -1
  32. package/dist/commands/classify.d.ts.map +1 -1
  33. package/dist/commands/classify.js +63 -18
  34. package/dist/commands/classify.js.map +1 -1
  35. package/dist/commands/enforcement.d.ts.map +1 -1
  36. package/dist/commands/enforcement.js +263 -9
  37. package/dist/commands/enforcement.js.map +1 -1
  38. package/dist/commands/explain.d.ts +1 -1
  39. package/dist/commands/explain.d.ts.map +1 -1
  40. package/dist/commands/explain.js +162 -3
  41. package/dist/commands/explain.js.map +1 -1
  42. package/dist/commands/init-presets.d.ts +7 -0
  43. package/dist/commands/init-presets.d.ts.map +1 -1
  44. package/dist/commands/init-presets.js +10 -1
  45. package/dist/commands/init-presets.js.map +1 -1
  46. package/dist/commands/init.d.ts.map +1 -1
  47. package/dist/commands/init.js +579 -61
  48. package/dist/commands/init.js.map +1 -1
  49. package/dist/commands/next.d.ts.map +1 -1
  50. package/dist/commands/next.js +109 -6
  51. package/dist/commands/next.js.map +1 -1
  52. package/dist/commands/pre-commit.d.ts.map +1 -1
  53. package/dist/commands/pre-commit.js +62 -19
  54. package/dist/commands/pre-commit.js.map +1 -1
  55. package/dist/commands/test-gates.js +1 -1
  56. package/dist/commands/tests.d.ts.map +1 -1
  57. package/dist/commands/tests.js +46 -7
  58. package/dist/commands/tests.js.map +1 -1
  59. package/dist/docs-exclusions.d.ts.map +1 -1
  60. package/dist/docs-exclusions.js +18 -3
  61. package/dist/docs-exclusions.js.map +1 -1
  62. package/dist/endpoint-compiler.d.ts.map +1 -1
  63. package/dist/endpoint-compiler.js +49 -1
  64. package/dist/endpoint-compiler.js.map +1 -1
  65. package/dist/evaluate.d.ts +16 -1
  66. package/dist/evaluate.d.ts.map +1 -1
  67. package/dist/evaluate.js +12 -2
  68. package/dist/evaluate.js.map +1 -1
  69. package/dist/gateforge-owned.d.ts +103 -0
  70. package/dist/gateforge-owned.d.ts.map +1 -0
  71. package/dist/gateforge-owned.js +375 -0
  72. package/dist/gateforge-owned.js.map +1 -0
  73. package/dist/git-hooks.d.ts +18 -0
  74. package/dist/git-hooks.d.ts.map +1 -1
  75. package/dist/git-hooks.js +36 -1
  76. package/dist/git-hooks.js.map +1 -1
  77. package/dist/git-ignored.d.ts +27 -0
  78. package/dist/git-ignored.d.ts.map +1 -0
  79. package/dist/git-ignored.js +102 -0
  80. package/dist/git-ignored.js.map +1 -0
  81. package/dist/glob.d.ts +33 -14
  82. package/dist/glob.d.ts.map +1 -1
  83. package/dist/glob.js +96 -5
  84. package/dist/glob.js.map +1 -1
  85. package/dist/index.d.ts +4 -1
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +2 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/io.d.ts +18 -5
  90. package/dist/io.d.ts.map +1 -1
  91. package/dist/io.js +5 -4
  92. package/dist/io.js.map +1 -1
  93. package/dist/pipeline.d.ts +16 -1
  94. package/dist/pipeline.d.ts.map +1 -1
  95. package/dist/pipeline.js +23 -3
  96. package/dist/pipeline.js.map +1 -1
  97. package/dist/planes-inference.d.ts +12 -5
  98. package/dist/planes-inference.d.ts.map +1 -1
  99. package/dist/planes-inference.js +13 -15
  100. package/dist/planes-inference.js.map +1 -1
  101. package/dist/providers.d.ts +54 -0
  102. package/dist/providers.d.ts.map +1 -1
  103. package/dist/providers.js +101 -0
  104. package/dist/providers.js.map +1 -1
  105. package/dist/repo-scan.d.ts +7 -0
  106. package/dist/repo-scan.d.ts.map +1 -1
  107. package/dist/repo-scan.js +109 -8
  108. package/dist/repo-scan.js.map +1 -1
  109. package/dist/route-plane-proposals.d.ts +100 -0
  110. package/dist/route-plane-proposals.d.ts.map +1 -0
  111. package/dist/route-plane-proposals.js +213 -0
  112. package/dist/route-plane-proposals.js.map +1 -0
  113. package/dist/scope.d.ts +20 -0
  114. package/dist/scope.d.ts.map +1 -1
  115. package/dist/scope.js +26 -5
  116. package/dist/scope.js.map +1 -1
  117. package/dist/singleton-guidance.d.ts +15 -6
  118. package/dist/singleton-guidance.d.ts.map +1 -1
  119. package/dist/singleton-guidance.js +30 -10
  120. package/dist/singleton-guidance.js.map +1 -1
  121. package/dist/staged-candidate.d.ts.map +1 -1
  122. package/dist/staged-candidate.js +2 -1
  123. package/dist/staged-candidate.js.map +1 -1
  124. package/dist/trusted-policy.d.ts.map +1 -1
  125. package/dist/trusted-policy.js +3 -2
  126. package/dist/trusted-policy.js.map +1 -1
  127. package/dist/unmatched-routes.d.ts +60 -0
  128. package/dist/unmatched-routes.d.ts.map +1 -0
  129. package/dist/unmatched-routes.js +131 -0
  130. package/dist/unmatched-routes.js.map +1 -0
  131. package/guides/CONNECT-YOUR-PROJECT.md +93 -20
  132. package/guides/QUICKSTART.md +81 -16
  133. package/guides/REFERENCE.md +1756 -0
  134. package/guides/TEST-ENVIRONMENT.md +8 -5
  135. package/guides/UPGRADE-0.8-to-0.9.md +112 -0
  136. package/package.json +10 -10
@@ -6,6 +6,16 @@ This guide takes a project from install to a blocking gate. Gateforge does not c
6
6
 
7
7
  You need Node.js 20 or newer and an existing Playwright suite that can run against a disposable app.
8
8
 
9
+ ## The setup order
10
+
11
+ `gateforge init` → answer the plane questions → `gateforge adopt` (only when the repository already has code) → adapters and runtime → pin the owner-approved policy digest → commit.
12
+
13
+ - Install the CLI and packs, then commit the install (package.json + lockfile) on its own before `gateforge init` — no gate is wired yet. The setup commit must contain only Gateforge's own files (plus the `.gitignore` block init writes) to count as product-behavior-neutral; mixing in dependency or product changes makes it a normal gated change, which under strictE2E re-grades the adopted E2E debt as blocking. Commit product changes (for example a Playwright config rename) separately, after the setup commit.
14
+ - Answer the plane questions with `gateforge classify plane <folder> <tenant|master|global> --reason "<why>" --confirm` (run `gateforge init --planes` once first to create the owner-reviewed `.gateforge/planes.json`).
15
+ - Adopt comes after the plane answers because a plane answer changes a resource's identity, so the debt set `adopt` records would not match the repository if it were captured before the answer.
16
+ - Declare the dependency directories the staged commit gate may link (`prepare: { reuse: [node_modules] }` in `.gateforge/runtime.yml`): the gate runs on a checkout of the staged files only.
17
+ - Pin the owner-approved policy digest LAST, right before the first strict commit: read the full value from `gateforge enforcement doctor` and set it as `GATEFORGE_APPROVED_POLICY_DIGEST`. It changes whenever a policy input changes — `.gateforge.yml`, the policies, the classification policy, `planes.json`, adapters, `runtime.yml`, waivers, hooks — so re-pin after every such edit. Stage every policy file first (`git add`) — the commit gate digests the staged bytes, and `enforcement doctor` warns when they differ from the working tree.
18
+
9
19
  ## 1. Install the CLI and the packs you use
10
20
 
11
21
  Install the CLI, Playwright pack, and only the detector packs that fit your app. Keep every direct `@gate-forge/*` package on the same release.
@@ -14,11 +24,11 @@ Example for a React frontend, FastAPI backend, and SQLAlchemy data layer:
14
24
 
15
25
  ```sh
16
26
  npm i -D \
17
- @gate-forge/cli@0.8.0 \
18
- @gate-forge/pack-playwright@0.8.0 \
19
- @gate-forge/pack-http@0.8.0 \
20
- @gate-forge/pack-fastapi@0.8.0 \
21
- @gate-forge/pack-sqlalchemy@0.8.0
27
+ @gate-forge/cli@0.9.1 \
28
+ @gate-forge/pack-playwright@0.9.1 \
29
+ @gate-forge/pack-http@0.9.1 \
30
+ @gate-forge/pack-fastapi@0.9.1 \
31
+ @gate-forge/pack-sqlalchemy@0.9.1
22
32
  ```
23
33
 
24
34
  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`.
@@ -33,7 +43,7 @@ This installs every pack of the release; the scan still recommends the ones your
33
43
 
34
44
  **You should see:** npm installs the packages without a Gateforge compatibility error.
35
45
 
36
- **If not:** align every direct `@gate-forge/*` package to `0.8.0`, then install again. Do not work around the compatibility error.
46
+ **If not:** align every direct `@gate-forge/*` package to `0.9.1`, then install again. Do not work around the compatibility error.
37
47
 
38
48
  ## 2. Pick a goal
39
49
 
@@ -89,13 +99,48 @@ It writes:
89
99
  - `GATEFORGE.md`
90
100
  - `tests/e2e/gateforge/README.md` for the default overlay proof path
91
101
 
92
- It also creates `.gateforge/adapters/` and `.gateforge/waivers/`. It preserves existing files. A chosen documentation exclusion adds `.gateforge/docs-exclusions.yml`.
102
+ It also creates `.gateforge/adapters/` and `.gateforge/waivers/`, and adds
103
+ `.gateforge/test-gates/` (Gateforge's own run state: catalog, caches,
104
+ receipts, history) to `.gitignore` so `git add -A` never stages it. It
105
+ preserves existing files. A chosen documentation exclusion adds
106
+ `.gateforge/docs-exclusions.yml`.
93
107
 
94
108
  **You should see:** a scan summary, recommended packages, the goal summary
95
- with its `undo:` line, and a `skeleton ready` message.
109
+ with its `undo:` lines, and a `skeleton ready` message.
96
110
 
97
111
  **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.
98
112
 
113
+ ### Already have code? Adopt what is there
114
+
115
+ If the repository already has an application, the next commit is not
116
+ green: `gateforge check` reports everything discovery finds as existing
117
+ debt, and debt blocks. Do not reach for `--no-verify` — there is a
118
+ command for exactly this situation, and `init` names it in its own output
119
+ whenever the repository already had code:
120
+
121
+ ```sh
122
+ gateforge adopt
123
+ ```
124
+
125
+ It records today's blocking findings as forgiven debt, in
126
+ `.gateforge/baselines/obligations.json` plus a dated receipt in
127
+ `.gateforge/baselines/adoption.json`, and then wires the blocking gate.
128
+
129
+ - The recorded set is **shrink-only**. It never forgives new work: new
130
+ unproven changes keep blocking. Resolve debt and shrink the set with
131
+ `gateforge baseline update`.
132
+ - Run it **once**. A second `adopt` is a no-op success; there is exactly
133
+ one sanctioned bulk-add per repository.
134
+ - Under `--preset strict` / `strictE2E`, an adopted E2E obligation is not
135
+ proof. It blocks with `ENFORCEMENT_UNTRUSTED` again as soon as a change
136
+ touches it — adoption forgives today's state, not the next edit.
137
+ - `gateforge adopt --help` prints this contract, and
138
+ `gateforge baseline diff <before> <after>` compares two adopted sets by
139
+ obligation ID.
140
+
141
+ Adopting forgives; it does not prove. The work of proving obligations
142
+ starts in step 4 and is unchanged.
143
+
99
144
  ## 4. Find existing tests and suggestions
100
145
 
101
146
  First inventory the test suite:
@@ -112,7 +157,7 @@ gateforge tests suggest
112
157
 
113
158
  Discovery writes a derived catalog under `.gateforge/test-gates/`. Suggestions are for inspection; they do not create declarations or prove a test.
114
159
 
115
- **You should see:** discovered test keys and suggestions with obligation IDs and any mapping problems.
160
+ **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.
116
161
 
117
162
  **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.
118
163
 
@@ -223,7 +268,15 @@ gateforge next
223
268
  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.
224
269
 
225
270
  The first real `next` on a FastAPI repository asks which data plane owns a
226
- route's records. That is an owner decision, so Gateforge explains the
271
+ route's records. The three planes:
272
+
273
+ - **tenant** — the data of one customer or organisation, e.g. a per-customer database or rows scoped by a customer id.
274
+ - **master** — the platform's own administrative data, shared by the operator, e.g. the admin platform's database of customers and plans.
275
+ - **global** — reference data that is the same for everyone, e.g. currencies.
276
+
277
+ An infrastructure route that serves no business data (health, readiness, metrics): Gateforge already classifies health and readiness probes as `global` itself. Do not cover a file that holds such probes with a `tenant` or `master` rule — the two answers contradict (`PLANE_CONTRADICTION`). If no route in the folder serves business data (`gateforge explain <endpoint>` shows `linkedResource: <none>`), answer `global` for it; if business routes share one router file with the probes, move the probes to their own router file. A file that is not part of the product: exclude it with `project.paths.exclude` in `.gateforge.yml`.
278
+
279
+ That is an owner decision, so Gateforge explains the
227
280
  question before asking it and prints one runnable command per answer. For
228
281
  `DELETE /items/{}` on tenant-scoped records, the answer is `tenant`:
229
282
 
@@ -233,6 +286,16 @@ gateforge classify plane 'app/main.py' tenant \
233
286
  --reason 'Owner review confirms the tenant plane for DELETE /items/{}.' --confirm
234
287
  ```
235
288
 
289
+ `classify plane` takes one file, one FOLDER, or one glob — a folder answer
290
+ is written as `match: 'app/routes/**'`, so a repository with hundreds of
291
+ routers needs one reviewed rule per router directory rather than one per
292
+ file:
293
+
294
+ ```sh
295
+ gateforge classify plane 'app/routes' tenant \
296
+ --reason 'Every router in this folder serves tenant-scoped records.' --confirm
297
+ ```
298
+
236
299
  Then run `gateforge next` again: the same block must not reappear. A route
237
300
  that is genuinely internal is the other answer, and it stays owner-only (an
238
301
  `internalRules` entry in `.gateforge/classification-policy.yml`).
@@ -331,7 +394,7 @@ the registry. To gate a release that is not on the registry yet (a local
331
394
  regenerate:
332
395
 
333
396
  ```sh
334
- GATEFORGE_CI_ENGINE_SOURCE=vendor/gate-forge-cli-0.8.0.tgz \
397
+ GATEFORGE_CI_ENGINE_SOURCE=vendor/gate-forge-cli-0.9.1.tgz \
335
398
  gateforge enforce --ci github
336
399
  ```
337
400
 
@@ -342,12 +405,14 @@ GitLab template needs no variable: it installs the repository's own declared
342
405
  `@gate-forge/cli` dependency.
343
406
 
344
407
  If your repository already had a `.pre-commit-config.yaml`, the wiring
345
- appends to it and says so on one line, with the exact way back
408
+ inserts the `gateforge-check` entry as the FIRST item of the `repos:`
409
+ list and says so on one line, with the exact way back
346
410
  (`undo: git restore -- .pre-commit-config.yaml`). Check that line before
347
- you commit. Then put the `gateforge-check` entry FIRST: hooks that rewrite
348
- files must not run after the gate, or they invalidate its receipt —
349
- `enforcement doctor` reports those hooks as `hook-mutation` and names
350
- those files.
411
+ you commit — hooks that rewrite files must not run before the gate, or
412
+ they invalidate its receipt; `enforcement doctor` reports such hooks as
413
+ `hook-mutation` and names those files. (A config with no block-style
414
+ `repos:` list — e.g. `repos: []` — is appended as before, with a note
415
+ to move the entry to the top yourself.)
351
416
 
352
417
  **You should see:** `installed:`, `updated:`, `verified:`, or a framework-managed hook message, followed by `blocking gate wired`.
353
418