@gate-forge/cli 0.9.0 → 0.10.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 (93) hide show
  1. package/README.md +12 -5
  2. package/dist/cache-exclusions.d.ts +20 -13
  3. package/dist/cache-exclusions.d.ts.map +1 -1
  4. package/dist/cache-exclusions.js +47 -33
  5. package/dist/cache-exclusions.js.map +1 -1
  6. package/dist/cli.d.ts +1 -1
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +11 -0
  9. package/dist/cli.js.map +1 -1
  10. package/dist/commands/adopt.d.ts +3 -2
  11. package/dist/commands/adopt.d.ts.map +1 -1
  12. package/dist/commands/adopt.js +38 -5
  13. package/dist/commands/adopt.js.map +1 -1
  14. package/dist/commands/blocking.d.ts +20 -1
  15. package/dist/commands/blocking.d.ts.map +1 -1
  16. package/dist/commands/blocking.js +105 -10
  17. package/dist/commands/blocking.js.map +1 -1
  18. package/dist/commands/check.d.ts +34 -0
  19. package/dist/commands/check.d.ts.map +1 -1
  20. package/dist/commands/check.js +93 -7
  21. package/dist/commands/check.js.map +1 -1
  22. package/dist/commands/classify.d.ts +1 -0
  23. package/dist/commands/classify.d.ts.map +1 -1
  24. package/dist/commands/classify.js +230 -14
  25. package/dist/commands/classify.js.map +1 -1
  26. package/dist/commands/common.d.ts +6 -1
  27. package/dist/commands/common.d.ts.map +1 -1
  28. package/dist/commands/common.js +8 -1
  29. package/dist/commands/common.js.map +1 -1
  30. package/dist/commands/enforcement.d.ts +9 -1
  31. package/dist/commands/enforcement.d.ts.map +1 -1
  32. package/dist/commands/enforcement.js +448 -13
  33. package/dist/commands/enforcement.js.map +1 -1
  34. package/dist/commands/init.d.ts +20 -0
  35. package/dist/commands/init.d.ts.map +1 -1
  36. package/dist/commands/init.js +296 -93
  37. package/dist/commands/init.js.map +1 -1
  38. package/dist/commands/migrate.d.ts +14 -0
  39. package/dist/commands/migrate.d.ts.map +1 -0
  40. package/dist/commands/migrate.js +177 -0
  41. package/dist/commands/migrate.js.map +1 -0
  42. package/dist/commands/next.d.ts.map +1 -1
  43. package/dist/commands/next.js +7 -2
  44. package/dist/commands/next.js.map +1 -1
  45. package/dist/commands/pre-commit.d.ts.map +1 -1
  46. package/dist/commands/pre-commit.js +62 -19
  47. package/dist/commands/pre-commit.js.map +1 -1
  48. package/dist/commands/tests.d.ts.map +1 -1
  49. package/dist/commands/tests.js +54 -24
  50. package/dist/commands/tests.js.map +1 -1
  51. package/dist/docs-exclusions.d.ts +32 -5
  52. package/dist/docs-exclusions.d.ts.map +1 -1
  53. package/dist/docs-exclusions.js +60 -26
  54. package/dist/docs-exclusions.js.map +1 -1
  55. package/dist/evidence-config-text.d.ts +57 -0
  56. package/dist/evidence-config-text.d.ts.map +1 -0
  57. package/dist/evidence-config-text.js +263 -0
  58. package/dist/evidence-config-text.js.map +1 -0
  59. package/dist/execution.d.ts +51 -8
  60. package/dist/execution.d.ts.map +1 -1
  61. package/dist/execution.js +61 -29
  62. package/dist/execution.js.map +1 -1
  63. package/dist/gateforge-owned.d.ts +30 -5
  64. package/dist/gateforge-owned.d.ts.map +1 -1
  65. package/dist/gateforge-owned.js +136 -18
  66. package/dist/gateforge-owned.js.map +1 -1
  67. package/dist/git-hooks.d.ts.map +1 -1
  68. package/dist/git-hooks.js +15 -0
  69. package/dist/git-hooks.js.map +1 -1
  70. package/dist/input-snapshot.d.ts.map +1 -1
  71. package/dist/input-snapshot.js +2 -6
  72. package/dist/input-snapshot.js.map +1 -1
  73. package/dist/legacy-exclusion-paths.d.ts +28 -0
  74. package/dist/legacy-exclusion-paths.d.ts.map +1 -0
  75. package/dist/legacy-exclusion-paths.js +48 -0
  76. package/dist/legacy-exclusion-paths.js.map +1 -0
  77. package/dist/providers.d.ts +54 -0
  78. package/dist/providers.d.ts.map +1 -1
  79. package/dist/providers.js +101 -0
  80. package/dist/providers.js.map +1 -1
  81. package/dist/staged-candidate.d.ts.map +1 -1
  82. package/dist/staged-candidate.js +2 -1
  83. package/dist/staged-candidate.js.map +1 -1
  84. package/dist/trusted-policy.d.ts.map +1 -1
  85. package/dist/trusted-policy.js +3 -2
  86. package/dist/trusted-policy.js.map +1 -1
  87. package/guides/CONNECT-YOUR-PROJECT.md +64 -0
  88. package/guides/QUICKSTART.md +68 -15
  89. package/guides/REFERENCE.md +229 -33
  90. package/guides/TEST-ENVIRONMENT.md +36 -0
  91. package/guides/UPGRADE-0.8-to-0.9.md +9 -1
  92. package/guides/UPGRADE-0.9-to-0.10.md +137 -0
  93. package/package.json +10 -10
@@ -10,6 +10,21 @@ ONE next action.
10
10
 
11
11
  ---
12
12
 
13
+ ## The setup order
14
+
15
+ `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. Each step assumes the previous one ran.
16
+ - 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.
17
+
18
+ - **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`). The three planes:
19
+ - **tenant** — the data of one customer or organisation, e.g. a per-customer database or rows scoped by a customer id.
20
+ - **master** — the platform's own administrative data, shared by the operator, e.g. the admin platform's database of customers and plans.
21
+ - **global** — reference data that is the same for everyone, e.g. currencies.
22
+
23
+ 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`.
24
+ - **`gateforge 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.
25
+ - **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.
26
+ - **Pin the owner-approved policy digest LAST**, right before the first strict commit: `git add -A .gateforge .gateforge.yml && gateforge enforcement pin --pin-file ~/.config/<repo>.gateforge.env --confirm`. The flag is `--pin-file`, not `--env-file`: node itself consumes `--env-file <path>` anywhere in argv and would read the file instead of running the command. The pin file must live OUTSIDE the repository, and the command refuses a path inside it (a candidate-controlled file cannot approve policy) as well as a policy input that is not fully staged — it names the file instead of pinning a revision the gate never digests. Without `--confirm` it only prints the line it would write. The digest changes whenever a policy input changes — `.gateforge.yml`, the policies, the classification policy, `.gateforge/test-map.yml`, `planes.json`, adapters, `runtime.yml`, waivers, hooks — so re-pin after every such edit; `enforcement doctor` names the inputs that changed since HEAD (`policy-inputs-vs-HEAD`) and whether the provisioned pin still matches the staged bytes (`approved-digest`).
27
+
13
28
  ## 1. What you need
14
29
 
15
30
  | Your stack | Detector pack (installed by `init`) | Runner | What you write |
@@ -357,6 +372,55 @@ npx gateforge tests mark --test <key> --kind browser-e2e \
357
372
  Marking a test never satisfies an obligation; it only says which existing
358
373
  test is *about* it. New proof goes in `tests/e2e/gateforge/`.
359
374
 
375
+ ### 6a. Base an existing suite on Gateforge's fixture
376
+
377
+ An `observed-e2e` test proves transport and persistence through the witness
378
+ ONLY when its `page` comes from Gateforge's test object: that fixture is what
379
+ routes the test's app traffic through the supervisor's session observation
380
+ proxy. A test that takes `page` from plain `@playwright/test` reaches the app
381
+ directly, the witness observes nothing, and its claims finalize with "no HTTP
382
+ exchange passed through this session's observation proxy" — while the test
383
+ itself passes.
384
+
385
+ When the suite has one shared fixture file, that is a one-line rebase and
386
+ nothing else in the suite changes:
387
+
388
+ ```js
389
+ // CommonJS suite — the shape most existing Playwright suites have.
390
+ // `require` needs Node >= 20.19 / >= 22.12.
391
+ const { test: baseTest, expect } = require('@gate-forge/pack-playwright/fixture');
392
+ ```
393
+
394
+ ```ts
395
+ // ESM suite
396
+ import { test as baseTest, expect } from '@gate-forge/pack-playwright/fixture';
397
+ ```
398
+
399
+ Keep the suite's own journeys, steps, assertions and fixtures; change only
400
+ which `test` object they extend. Under a witnessed run, every test then runs
401
+ under a supervisor-issued session whose traffic the witness can observe.
402
+
403
+ ### 6b. Point the suite at the origin Gateforge routes
404
+
405
+ Rebasing the fixture is only half of it. The fixture rewrites requests to
406
+ `GATEFORGE_APP_BASE_URL` onto the supervisor's session observation proxy — and
407
+ only those. A suite whose own base URL differs (`E2E_BASE_URL` resolving to
408
+ `http://localhost:13001` while Gateforge runs at `http://localhost:13101`, or a
409
+ variable that never reaches the test process at all because it is not in
410
+ `envAllowlist`) sends every request past the witness, and its `observed-e2e`
411
+ claims finalize with "no HTTP exchange passed through this session's
412
+ observation proxy" while the tests pass.
413
+
414
+ So, for the suite you just rebased:
415
+
416
+ - list its base-URL variable in `runtime.yml` `envAllowlist` (see
417
+ `TEST-ENVIRONMENT.md`), or have the helpers read `GATEFORGE_APP_BASE_URL`;
418
+ - and make that origin the one the tests actually load.
419
+
420
+ When the origins disagree, the witness's zero-traffic note now names both —
421
+ the origin the page really requested and the one Gateforge routes — instead of
422
+ guessing at the fixture page alone.
423
+
360
424
  ## 7. First run
361
425
 
362
426
  ```bash
@@ -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: `git add -A .gateforge .gateforge.yml && gateforge enforcement pin --pin-file ~/.config/<repo>.gateforge.env --confirm`. The flag is `--pin-file`, not `--env-file`: node itself consumes `--env-file <path>` anywhere in argv and would read the file instead of running the command. Without `--confirm` the command only prints the line it would write. The pin file must live OUTSIDE the repository — a file the candidate controls cannot approve its own policy revision — and the command refuses any path inside the repo, plus a policy input that is not fully staged (it names the file). The digest changes whenever a policy input changes — `.gateforge.yml`, the policies, the classification policy, `.gateforge/test-map.yml`, `planes.json`, adapters, `runtime.yml`, waivers, hooks — so re-pin after every such edit. `gateforge enforcement doctor` names the inputs that changed since HEAD (`policy-inputs-vs-HEAD`) and whether the provisioned pin still matches the staged bytes (`approved-digest`).
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,15 +24,21 @@ 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.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
27
+ @gate-forge/cli@0.10.0 \
28
+ @gate-forge/pack-playwright@0.10.0 \
29
+ @gate-forge/pack-http@0.10.0 \
30
+ @gate-forge/pack-fastapi@0.10.0 \
31
+ @gate-forge/pack-sqlalchemy@0.10.0
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`.
25
35
 
36
+ `gateforge init` prints that same command for you: after it writes the
37
+ config it names — in ONE line — every detector pack it enabled that your
38
+ `package.json` does not already declare, at the CLI's own version. Run
39
+ that line (init never runs npm for you), and commit the install on its own
40
+ before committing the setup files.
41
+
26
42
  **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
43
 
28
44
  ```sh
@@ -33,7 +49,7 @@ This installs every pack of the release; the scan still recommends the ones your
33
49
 
34
50
  **You should see:** npm installs the packages without a Gateforge compatibility error.
35
51
 
36
- **If not:** align every direct `@gate-forge/*` package to `0.9.0`, then install again. Do not work around the compatibility error.
52
+ **If not:** align every direct `@gate-forge/*` package to `0.10.0`, then install again. Do not work around the compatibility error.
37
53
 
38
54
  ## 2. Pick a goal
39
55
 
@@ -92,8 +108,8 @@ It writes:
92
108
  It also creates `.gateforge/adapters/` and `.gateforge/waivers/`, and adds
93
109
  `.gateforge/test-gates/` (Gateforge's own run state: catalog, caches,
94
110
  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`.
111
+ preserves existing files. A chosen documentation exclusion is added to
112
+ `.gateforge.yml` under `evidence.exclude.docs`.
97
113
 
98
114
  **You should see:** a scan summary, recommended packages, the goal summary
99
115
  with its `undo:` lines, and a `skeleton ready` message.
@@ -258,7 +274,15 @@ gateforge next
258
274
  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.
259
275
 
260
276
  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
277
+ route's records. The three planes:
278
+
279
+ - **tenant** — the data of one customer or organisation, e.g. a per-customer database or rows scoped by a customer id.
280
+ - **master** — the platform's own administrative data, shared by the operator, e.g. the admin platform's database of customers and plans.
281
+ - **global** — reference data that is the same for everyone, e.g. currencies.
282
+
283
+ 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`.
284
+
285
+ That is an owner decision, so Gateforge explains the
262
286
  question before asking it and prints one runnable command per answer. For
263
287
  `DELETE /items/{}` on tenant-scoped records, the answer is `tenant`:
264
288
 
@@ -282,6 +306,33 @@ Then run `gateforge next` again: the same block must not reappear. A route
282
306
  that is genuinely internal is the other answer, and it stays owner-only (an
283
307
  `internalRules` entry in `.gateforge/classification-policy.yml`).
284
308
 
309
+ The second owner question is what removal MEANS. Delete semantics are
310
+ proven, never guessed: a model that declares nothing keeps its resource
311
+ `unclassified` and blocks with `DELETE_SEMANTICS_UNRESOLVED` (nothing on
312
+ it accrues, and `gateforge explain <resource>` names it). You answer with
313
+ `hard` (the row is removed) or `archive` (the row stays, with your own
314
+ archived state):
315
+
316
+ ```sh
317
+ gateforge classify delete 'backend/models' hard \
318
+ --reason 'Rows in this model tree are removed permanently.' --confirm
319
+ ```
320
+
321
+ Like `classify plane` it previews without `--confirm`, and it takes one
322
+ file, one FOLDER (written as `match: 'backend/models/**'`), or one glob —
323
+ one reviewed rule per model tree, not per model. `archive` refuses to run
324
+ without the archived field values the run grades removal against:
325
+
326
+ ```sh
327
+ gateforge classify delete 'backend/models/invoice' archive \
328
+ --archive-field status=archived --archive-field archived_by=system \
329
+ --reason 'Invoices are archived, never removed.' --confirm
330
+ ```
331
+
332
+ Your declaration is an evidence contract, not an override: if a detector
333
+ reads the model and disagrees with your rule, the run blocks and names
334
+ both instead of picking one. Then run `gateforge next` again.
335
+
285
336
  To verify a specific commit tree (for example, the tip of a pushed ref)
286
337
  instead of the current worktree or index:
287
338
 
@@ -376,7 +427,7 @@ the registry. To gate a release that is not on the registry yet (a local
376
427
  regenerate:
377
428
 
378
429
  ```sh
379
- GATEFORGE_CI_ENGINE_SOURCE=vendor/gate-forge-cli-0.9.0.tgz \
430
+ GATEFORGE_CI_ENGINE_SOURCE=vendor/gate-forge-cli-0.10.0.tgz \
380
431
  gateforge enforce --ci github
381
432
  ```
382
433
 
@@ -387,12 +438,14 @@ GitLab template needs no variable: it installs the repository's own declared
387
438
  `@gate-forge/cli` dependency.
388
439
 
389
440
  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
441
+ inserts the `gateforge-check` entry as the FIRST item of the `repos:`
442
+ list and says so on one line, with the exact way back
391
443
  (`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.
444
+ you commit — hooks that rewrite files must not run before the gate, or
445
+ they invalidate its receipt; `enforcement doctor` reports such hooks as
446
+ `hook-mutation` and names those files. (A config with no block-style
447
+ `repos:` list — e.g. `repos: []` — is appended as before, with a note
448
+ to move the entry to the top yourself.)
396
449
 
397
450
  **You should see:** `installed:`, `updated:`, `verified:`, or a framework-managed hook message, followed by `blocking gate wired`.
398
451
 
@@ -9,7 +9,8 @@ first commands; the guides cover the walks:
9
9
  [Quickstart](QUICKSTART.md), [Connect your project](CONNECT-YOUR-PROJECT.md),
10
10
  [Test environment](TEST-ENVIRONMENT.md),
11
11
  [Runners other than Playwright](RUNNER-NEUTRAL-EVIDENCE.md),
12
- [Upgrade from 0.8 to 0.9](UPGRADE-0.8-to-0.9.md).
12
+ [Upgrade from 0.8 to 0.9](UPGRADE-0.8-to-0.9.md),
13
+ [Upgrade from 0.9 to 0.10](UPGRADE-0.9-to-0.10.md).
13
14
 
14
15
  ## Contents
15
16
 
@@ -21,6 +22,7 @@ first commands; the guides cover the walks:
21
22
  - [Enforcement](#enforcement)
22
23
  - [Contract capabilities](#contract-capabilities)
23
24
  - [Configuration](#configuration)
25
+ - [Classification policy (`.gateforge/classification-policy.yml`)](#classification-policy-gateforgeclassification-policyyml)
24
26
  - [Plugin invocation](#plugin-invocation)
25
27
  - [Endpoint plane rules (`.gateforge/planes.json`)](#endpoint-plane-rules-gateforgeplanesjson)
26
28
  - [Endpoint capability rules (`.gateforge/endpoints.json`)](#endpoint-capability-rules-gateforgeendpointsjson)
@@ -42,18 +44,20 @@ first commands; the guides cover the walks:
42
44
  | Command | Purpose | Exit codes |
43
45
  | --- | --- | --- |
44
46
  | `gateforge init [--preset light\|normal\|strict] [--explain-presets] [--languages <comma,list>] [--plugins <comma,list>] [--accept-recommended] [--no-scan] [--proof overlay\|observe] [--blocking] [--no-blocking] [--pre-commit] [--no-pre-commit] [--ci] [--no-ci] [--planes] [--no-planes] [--strict-e2e] [--docs-exclude <folder,...>] [--docs-exclude-file <path>] [--confirm-doc-exclusions]` | Scan the repo (heuristics, no network), print the recommended install (plugins, persistence policy, transport-only HTTP policy for consumed endpoints, overlay proof), and write the standard Gateforge scaffold. Idempotent — never overwrites existing files unless `--confirm-doc-exclusions` approves an exclusion update. It also appends Gateforge's own engine state (`.gateforge/test-gates/`) to `.gitignore`, and on a repository that already has code it names `gateforge adopt` as the way through the debt the first commit will meet. `pack-task` is opt-in only (`--plugins`); `--proof observe` skips the overlay scaffold and prints the observe wiring checklist instead. Default language: `python`. `--preset` applies one goal in one step (`light` -> `mode: warn`, no hooks; `normal` -> `mode: changed` + pre-commit hook + CI job; `strict` -> `mode: strict` + staged gate + pre-push receipt check + CI job) and prints what it wrote plus `undo:` lines for created and in-place-changed files; `--explain-presets` prints that mapping and writes nothing. In a terminal init asks the same question instead; with no terminal and no `--preset` it writes `light` only and says so on one line with the `--preset` flag that changes it. The negative forms (`--no-blocking`, `--no-pre-commit`, `--no-ci`, `--no-planes`) answer the matching question without a prompt. A preset never writes a waiver, an adopted baseline or a plane rule, and an existing `.gateforge.yml` is never rewritten. `--strict-e2e` writes the `enforcement` block and refuses unavailable required proof channels. | 0/1/2 |
47
+ | `gateforge migrate [--confirm]` | Move owner declarations out of their own files and into `.gateforge.yml`. Today that is the evidence exclusions: `.gateforge/docs-exclusions.yml` and `.gateforge/cache-exclusions.yml` become `evidence.exclude.docs` and `evidence.exclude.cache`. Preview by default — it prints the exact `.gateforge.yml` diff and the files it would delete, writes nothing, exits 0; `--confirm` writes the block as TEXT (your YAML is never re-serialized), deletes the old files, and ends with `policy inputs changed: re-pin the approved digest (gateforge enforcement doctor)`. It validates the old files with the loader rules, refuses an `evidence:`/`exclude:`/`docs` form it cannot extend safely by name, and is idempotent (`nothing to migrate`, exit 0). Every other command refuses a repository that still carries an old file, naming this one. | 0/2 |
45
48
 
46
49
 
47
50
 
48
51
  | `gateforge next [--changed] [--json]` | Print the ONE blocking next action (`next`/`cause`/`why`/`do`; `--json` adds `remainingBlocking` and route-specific `guidance` when relevant). For an endpoint with no plane, ask which boundary owns its data and show the owner-reviewed choices; internality remains owner-only. Navigation, not the gate: never requires an E2E receipt. Exit 0 clean, 1 next action, 2 config/usage. | 0/1/2 |
49
52
  | `gateforge discover [--json]` | Run every configured detector over the expanded `project.paths` and dump the resource graph (default: human listing; `--json`: GF-canonical JSON). | 0 |
50
53
  | `gateforge classify [--json] [--write-snapshot <path>]` | Recompute effective classifications from detector signals and print decisions, traces, and typed blocks. `classify plane` previews or explicitly appends an owner-reviewed endpoint plane rule to the existing `.gateforge/planes.json`; snapshots are derived review artifacts and never pipeline input. | 0/1/2 |
54
+ | `gateforge classify delete <file\|folder\|glob> <hard\|archive> [--archive-field <key=value>]... --reason <text> [--confirm]` | Preview (default) or explicitly append one owner delete-semantics rule to `.gateforge/classification-policy.yml`: how removal manifests for every model whose source file matches the pattern. `archive` requires at least one `--archive-field` (the owner-owned archived state the run grades removal against); `hard` refuses the flag. The preview writes nothing, prints the exact diff, and quotes the policy-pin consequence; `--confirm` appends the rule at TEXT level — the key at the end of the document when absent, a new `- match:` item at the end of the block when present — so every byte the owner wrote survives (comments, key order, flow sequences), and the resulting document is validated against the pinned schema. A `deleteRules` the command cannot extend safely (flow style, or a value that is not a list of rules) is refused by name. An existing rule for the same source is reported, never shadowed. Declaring is an evidence contract, not an override: contradicting detector evidence still blocks. | 0/2 |
51
55
  | `gateforge explain <resourceId\|path> [--json]` | Show one resource's detector signals, classification rules, decision fingerprint, typed blocks, and generated obligations. A repo-relative PATH is also a target: when no resource matches it, the command prints what the file is and what governs it (Gateforge policy input, declared gate input, owner-declared documentation folder, known source of a resource, or an unclassified change) with the steps that attribute it — this is the answer an unmapped `CHANGE_UNMAPPED` file needs. An unknown target stays unknown (exit 1). | 0/1/2 |
52
56
  | `gateforge tests discover [--json] [--pytest]` | Inventory existing tests into the derived run-state catalog: static analysis reconciled with native Playwright enumeration (`--list`). Unresolved wrappers, parse errors, and inventory gaps are DATA (never an empty catalog — failed native enumeration is exit 2). `--pytest` additionally collects the configured diagnostic suites' node ids (`--collect-only`). Playwright enumeration runs ONE config (a repo-root config wins; otherwise the alphabetically first config one directory deep), and when the repo holds more than one the runner line names every config, the one used, why, and the ones NOT inventoried. `inventoryComplete=false` means a reconciliation gap (an enumerated-vs-static mismatch, an unresolved case, or a not-inventoried extra config), not a partial success. | 0/2 |
53
- | `gateforge tests suggest [--changed] [--json]` | Resolve mappings for the run's obligations and produce reuse-ordered existing-test candidates with typed causes (`TEST_MAPPING_MISSING` / `TEST_KIND_UNKNOWN` / `TEST_MAPPING_AMBIGUOUS` / `TEST_MAPPING_STALE`). Candidates are RANKED by the evidence their catalog row carries (explicit tag, resource token in title/file, operation word, route segment, unmocked folder, minus mocks) with the matching reason printed as `why:`; the text surface prints the top five and names how many it hid, `--json` carries every candidate with its `rank` and `score`. With a candidate present the next action is to MARK it `observed-e2e` and run it under the witness — the overlay instruction belongs to `newTestNeeded: true`. When Playwright reports load errors and enumerates no tests, report one `TEST_INVENTORY_INCOMPLETE` with the error count and first error instead of stale-mapping fan-out; the action is to install the missing dependency and rerun Gateforge. An inspection surface, NOT a gate: exit 0 even with blocking problems. | 0/2 |
57
+ | `gateforge tests suggest [--changed] [--json]` | Resolve mappings for the run's obligations and produce reuse-ordered existing-test candidates with typed causes (`TEST_MAPPING_MISSING` / `TEST_KIND_UNKNOWN` / `TEST_MAPPING_AMBIGUOUS` / `TEST_MAPPING_STALE`). Candidates are RANKED by the evidence their catalog row carries (explicit tag, resource token in title/file, operation word, route segment, unmocked folder, minus mocks) with the matching reason printed as `why:`; the text surface prints the top five and names how many it hid, `--json` carries every candidate with its `rank` and `score`. The reuse verdict `newTestNeeded` has THREE honest values: `no` (the `#1` candidate is an unmocked e2e row more than one signal supports), `yes` (no candidate survived resolution, or every candidate mocks the system under test) and `unverified` (a candidate exists but one signal carries it — confirm the request with `gateforge explain <obligation>` before marking). The next action follows it: MARK the candidate and run it under the witness when the verdict is `no`, write the overlay when it is `yes`. When Playwright reports load errors and enumerates no tests, report one `TEST_INVENTORY_INCOMPLETE` with the error count and first error instead of stale-mapping fan-out; the action is to install the missing dependency and rerun Gateforge. An inspection surface, NOT a gate: exit 0 even with blocking problems. | 0/2 |
54
58
  | `gateforge tests mark --test <key> --kind <kind> [--category <c>]... --obligation <id>... --reason "<text>"` | Declare an existing test in `.gateforge/test-map.yml` (see the test-reuse workflow below). Validates against the CURRENT catalog and obligation registry, writes atomically and idempotently, prints the exact diff. Never edits test files, never adds waivers, refuses contradictions. | 0/2 |
55
59
  | `gateforge tests sync [--json]` | AST-only scan of test annotations; updates generated `source: annotation` entries in `.gateforge/test-map.yml` and leaves handwritten entries unchanged. Reports unresolved helpers with source locations; does not run tests. | 0/1/2 |
56
- | `gateforge tests explain --test <key> [--json]` | Per-test report: requirements, existing-test identity, mapping origin, honest execution status, next action, `New test needed`. | 0/2 (unknown key → 2) |
60
+ | `gateforge tests explain --test <key> [--json]` | Per-test report: requirements, existing-test identity, mapping origin, honest execution status, next action, and the same three-state reuse verdict `New test needed` (`no` / `yes` / `unverified`) `tests suggest` prints — built from the SAME route evidence, so the two surfaces never disagree about one test. | 0/2 (unknown key → 2) |
57
61
  | `gateforge tests diagnose [--suite <name>] [--json]` | Run the configured pytest diagnostic suites once per suite, isolated (own process, `GATEFORGE_*` stripped, finite timeout). Advisory: exit 0 completed run (≥1 pass, no unexpected failures), 1 test failures, 2 unavailable/incomplete (collection error, timeout, missing interpreter, interruption, zero tests, or only skipped/xfail). Never E2E proof. | 0/1/2 |
58
62
  | `gateforge obligations [--json]` | Evaluate policies against the automatically classified graph and dump obligations, blocking entries, and claim assessments. | 0/1/2 |
59
63
  | `gateforge check [--changed] [--staged] [--candidate-commit <sha>] [--require-e2e] [--timing] [--no-cache] [--format text\|json\|sarif]` | The full gate: discover → classify → obligations → claims → verdicts → report. `--timing` appends per-step wall-clock timings (detectors, test collection, TS scan, planning, total) — an additive report key in json and one line in text, never an input to any verdict. Detector and pytest-collection results are cached under the excluded run-state dir. Detector keys include plugin config, executable module/script bytes, Python import environment, inputs, interpreter packages, and Gateforge engine version; pytest keys include all Python/config file bytes, collector argv/environment, interpreter identity, and engine version. Unchanged successful pytest collections reuse their node ids; any changed Python byte recollects. Any uncertainty runs fresh. The report carries additive `cache: {hits, misses}` counts. `--no-cache` (or `GATEFORGE_NO_CACHE=1`, or a CI environment) disables cache reads and writes. | 0 clean/waived, 1 unresolved, 2 config/usage error |
@@ -65,6 +69,7 @@ first commands; the guides cover the walks:
65
69
  | `gateforge key create|import-env|rotate|retire [--file <path>] --confirm` | Owner-only key ceremony. With no `--file` the ring is `${XDG_CONFIG_HOME:-$HOME/.config}/gateforge/verifier-keyring.json` — the parent directory is created, mode `0600` — and every later command reads that same path, so no `GATEFORGE_WITNESS_VERIFIER_KEY_FILE` export is needed; pass `--file <path>` AND export that variable only when the ring lives elsewhere. Creates, imports, rotates, or retires keys without printing secrets. | 0/2 |
66
70
  | `gateforge pre-commit --scope staged\|full` | The witnessed commit gate: freezes the Git index, materializes it into a scratch checkout, prepares the candidate's staged runtime (`.gateforge/runtime.yml` — below), runs the supervised witness gate INSIDE that checkout (`staged`: only tests mapped to obligations affected by the staged paths, `EVIDENCE_SCOPE_INCOMPLETE` blocks an unmapped affected obligation; `full`: the complete relevant mapped suite), validates the fresh receipt against the same checkout, rechecks the original index/HEAD/MERGE_HEAD, and copies only Gateforge audit artifacts (run state incl. runtime logs) back. Runtime preparation/readiness failures are typed (`RUNTIME_PREPARATION_FAILED` / `RUNTIME_READINESS_FAILED`); child process groups are cleaned up on every exit path. Install via `gateforge init --blocking --witnessed staged\|full`. | 0/1/2 |
67
71
  | `gateforge enforcement doctor [--json]` | Reports verified enforcement `level` (0–3), hook activation, wired CI templates, and read-only GitHub/GitLab branch-protection results; missing credentials or uncertain responses remain `not verified`. A local hook never counts as server protection. Its `engine:` line reports the install provenance npm's own metadata proves: a tarball/directory install (read from `node_modules/.package-lock.json`, or the manifest's `_resolved`) is named as such instead of claiming the registry, and an install with no readable metadata is reported as unproven rather than as an all-clear. The receipt's `engine.source` is receipt-bound and keeps its meaning. Diagnostic only: exit 0 whenever it runs. | 0/2 |
72
+ | `gateforge enforcement pin --pin-file <path> [--confirm]` | Writes the owner-approved policy digest of the STAGED candidate into an env file OUTSIDE the repository. The flag is `--pin-file`, NOT `--env-file`: Node itself consumes `--env-file <path>` (and `--env-file-if-exists <path>`) anywhere in argv — it reads the file and exits 9 on a missing one, so the CLI would never run. The digest is the one the commit gate computes: the index is frozen and materialized exactly as `check --staged` does, and the entries are hashed by the same function. It refuses when a policy input is not fully staged, naming the files. Preview by default — the line it would write, nothing written. `--confirm` replaces exactly the `GATEFORGE_APPROVED_POLICY_DIGEST=<hex>` line, drops a duplicate assignment, leaves every other line untouched, never prints another line of the file, and writes the file mode `0600`. A path inside the repository is refused: the pin must live outside the candidate, because a candidate-controlled file cannot approve policy. A symlink or a non-regular file is refused too (fail closed). | 0/2 |
68
73
  | `gateforge enforce [--ci github\|gitlab]` | Add blocking wiring to an initialized repository. The provider defaults to GitLab unless GitHub is the only detected CI provider; the explicit flag selects GitHub Actions or GitLab CI. Appending to an EXISTING `.pre-commit-config.yaml` is announced as an action on one line, naming the file as the repository's own and printing the exact way back (`git restore -- .pre-commit-config.yaml` for a tracked file; for an untracked one, which has nothing to restore, the line says to delete the appended entry). The generated GitHub workflow installs `@gate-forge/cli@<version>` from the registry unless `GATEFORGE_CI_ENGINE_SOURCE` is set when the generator runs: it then installs that one npm specifier (a `.tgz` path, a directory, or any specifier) through the step environment, for a release that is not on the registry. Unset the variable and rerun for the registry install. | 0/2 |
69
74
  | `gateforge adopt` | Adopt an EXISTING repository: run it once, after `init`, on a project that already has code and therefore already has findings. Records today's blocking findings (pin-#2 obligation fingerprints, blocking entries, and the classification-blocked resource identities) into `.gateforge/baselines/obligations.json`, sanctioned by a dated, count-annotated receipt `.gateforge/baselines/adoption.json` — without that receipt a baseline forgives nothing — then applies the blocking wiring through the same idempotent path as `init --blocking`. It is the ONE sanctioned bulk-add and only once per repository: a second `adopt` is a no-op success. The recorded set is shrink-only (`gateforge baseline update` shrinks it) and never forgives new work. With `enforcement.strictE2E: true`, a baselined E2E obligation is not proof and blocks with `ENFORCEMENT_UNTRUSTED` again as soon as a change touches it. `adopt --help` prints this contract. | 0/2 |
70
75
  | `gateforge baseline update <fp...>` | Shrink the baseline to a strict subset (invariant 4). | 0/2 |
@@ -212,6 +217,32 @@ security-sensitive: its bytes are hashed into the trusted policy digest and
212
217
  the authenticated input snapshot, so a candidate that edits its own runtime
213
218
  commands cannot approve the edit in the same commit.
214
219
 
220
+ ONE document, TWO independent key groups that may coexist:
221
+ `schemaVersion`, `prepare`, `health`, `services`, `envAllowlist`,
222
+ and `executionTimeoutSeconds` are read by the staged/supervised
223
+ runtime — `check --staged` and `test-gates` (see
224
+ `packages/cli/src/runtime.ts`), where `check --staged` reads
225
+ `prepare` (its `command`, `reuse`, `timeoutSeconds`, and
226
+ `preflight` sub-keys) — while `env_files`, `reset`, `seed`,
227
+ `services_up`, `healthcheck`, and `services_down` are the
228
+ `gateforge run` recipe (see `packages/cli/src/run-recipe.ts`),
229
+ which also reads `prepare` (its `commands`, `runTimeoutSeconds`,
230
+ and `runRetries` sub-keys). Neither group requires the other: a
231
+ document may carry both, one, or none of the staged keys. Minimal
232
+ combined example:
233
+
234
+ ```yaml
235
+ schemaVersion: 1
236
+ prepare:
237
+ command: npm ci --offline # staged runtime (check --staged / test-gates)
238
+ commands: [['npm', 'run', 'build']] # gateforge run recipe step
239
+ envAllowlist: [DATABASE_URL]
240
+ executionTimeoutSeconds: 1800
241
+ env_files: [.gateforge/test.env]
242
+ reset: { commands: [['./scripts/reset-db.sh']] }
243
+ services_up: { commands: [['./scripts/start-stack.sh']] }
244
+ ```
245
+
215
246
  ```yaml
216
247
  schemaVersion: 1
217
248
  prepare:
@@ -368,10 +399,18 @@ tests:
368
399
  witnessed evidence for this change grades `EVIDENCE_NOT_COLLECTED` —
369
400
  blocking.
370
401
 
371
- `tests suggest` emits `newTestNeeded: true` only when no suitable existing
372
- candidate survives resolution. An unsupported proof channel produces a
373
- capability task (`VERIFIER_UNSUPPORTED`), never a request to generate more
374
- tests.
402
+ `tests suggest` emits a THREE-STATE reuse verdict, never a boolean:
403
+ `no` when the `#1` candidate is an unmocked e2e row that more than ONE
404
+ signal supports (an explicit tag naming this resource, or a resource-token
405
+ match together with a file that names the route); `yes` when no candidate
406
+ survived resolution or every candidate mocks the system under test; and
407
+ `unverified` when a candidate exists but ONE signal carries it — a name in
408
+ common is not proof the test drives that request, so the next action is
409
+ the check (`new test needed: unverified — check that a candidate really
410
+ sends <METHOD> <route> before marking (gateforge explain <obligation>)`),
411
+ never a ready-made `tests mark` command. An unsupported proof channel
412
+ produces a capability task (`VERIFIER_UNSUPPORTED`), never a request to
413
+ generate more tests.
375
414
 
376
415
  ### Ranked candidates
377
416
 
@@ -379,6 +418,26 @@ Candidates are RANKED by the evidence the catalog row itself carries, not
379
418
  listed alphabetically: an explicit `@crud(...)` tag, a resource token in the
380
419
  title path or the file, the obligation's operation word, a route segment from
381
420
  the run's route inventory, a `real/` (unmocked) folder, minus a mock signal.
421
+ Tokens are matched WHOLE-WORD (title path words; file path segments split on
422
+ `/ . _ -`), never inside a longer word, and a generated resource id
423
+ contributes only its NAME: the plane (`tenant`), the transport (`http`), the
424
+ method (`get`), route furniture (`api`, `v1`), the `param` marker that stands
425
+ in for a `{route_param}`, and the trailing id hash identify no resource, so
426
+ `@crud(tenant.accounts:create)` is never evidence for
427
+ `tenant.http-get-api-v1-notifications-…`. A tag is a DECLARATION: only its
428
+ resource part (the text before `:` in `@crud(tenant.accounts:read)`, minus the
429
+ plane) counts as a resource name, and the tag text itself is stripped before
430
+ the title is read as prose — the `:read` in that tag never matches a `…/read`
431
+ route segment.
432
+ For an `http:*` obligation that operation must also FIT the route's method —
433
+ `GET`/`HEAD` read, `POST` create, `PUT`/`PATCH` update, `DELETE` delete. A tag
434
+ declaring `create` says the test creates the resource, which is no evidence
435
+ that it reads `GET /api/v2/accounts`, so it scores nothing there; with no
436
+ other evidence the row is not a candidate and the verdict is `unverified`,
437
+ never a `no` that would send the owner to mark a create test as the proof of
438
+ a read. A non-transport obligation has no route method to fit, so its tags
439
+ stay judged on the resource alone.
440
+
382
441
  Every weight is additive and printed as a `why:` line, so the order explains
383
442
  itself — the score is never a bare number. Ties break on the logical key, so
384
443
  the list is deterministic. The text surface prints the top five and says how
@@ -405,12 +464,14 @@ that line.
405
464
 
406
465
  ### One instruction, not two
407
466
 
408
- When a candidate exists, the suggestion's next action is to MARK that
409
- existing test `observed-e2e` and run it under the witness
410
- (`gateforge tests mark --test <key> --kind observed-e2e --obligation <id>
411
- --reason "…"` then `gateforge test-gates --changed`). The overlay
412
- instruction — write `tests/e2e/gateforge/<resource>.<op>.spec.js` — belongs
413
- to `newTestNeeded: true`, i.e. no existing test fits. A suggestion block
467
+ When a candidate exists and its verdict is `no`, the suggestion's next
468
+ action is to MARK that existing test `observed-e2e` and run it under the
469
+ witness (`gateforge tests mark --test <key> --kind observed-e2e
470
+ --obligation <id> --reason "…"` then `gateforge test-gates --changed`).
471
+ The overlay instruction — write
472
+ `tests/e2e/gateforge/<resource>.<op>.spec.js` — belongs to
473
+ `newTestNeeded: yes`, i.e. no existing test fits; an `unverified` verdict
474
+ asks you to confirm the candidate's request first. A suggestion block
414
475
  never tells you to write a new overlay test and, in the same breath, to
415
476
  reuse the test it just listed.
416
477
 
@@ -603,12 +664,17 @@ and `--require-e2e` blocks — it never downgrades to a weaker pass.
603
664
  Gateforge hashes all inputs and all candidate files. On a terminal, the first
604
665
  `gateforge init` asks for documentation-only folders to exclude. Automation can
605
666
  use `gateforge init --docs-exclude docs,handbook`; a non-interactive run with no
606
- option keeps the default. Gateforge writes the approved declaration to
607
- `.gateforge/docs-exclusions.yml` and prints the candidate trusted-policy digest
608
- to approve through the protected `GATEFORGE_APPROVED_POLICY_DIGEST` setting.
609
- Gate checks refuse to use the exclusions until that external pin matches. A
610
- later change to the exclusion declaration changes the digest; use
611
- `--confirm-doc-exclusions` when `init` changes an existing approval.
667
+ option keeps the default. Gateforge writes the approved declaration into
668
+ `.gateforge.yml`, under `evidence.exclude.docs`, and prints the candidate
669
+ trusted-policy digest to approve through the protected
670
+ `GATEFORGE_APPROVED_POLICY_DIGEST` setting. Gate checks refuse to use the
671
+ exclusions until that external pin matches. A later change to the declaration
672
+ changes the digest; use `--confirm-doc-exclusions` when `init` changes an
673
+ existing approval. The declaration is inserted as text, so the rest of your
674
+ `.gateforge.yml` (comments, key order, quoting) is preserved byte for byte.
675
+ Before 0.10 this list lived in its own `.gateforge/docs-exclusions.yml`; a
676
+ repository that still carries that file is refused by name until
677
+ `gateforge migrate --confirm` moves it.
612
678
 
613
679
  The project states these folders do not affect the product or its tests.
614
680
  Gateforge does not prove this. If application or test code reads an excluded
@@ -632,16 +698,36 @@ reduced guarantee still apply.
632
698
  default, Python bytecode remains part of candidate and input identity. To
633
699
  exclude only exact generated cache files, run
634
700
  `gateforge init --cache-exclude src/__pycache__/module.cpython-313.pyc`.
635
- The command writes `.gateforge/cache-exclusions.yml` and prints the trusted
636
- policy digest to approve outside the repository. A matching protected
701
+ The command writes the list into `.gateforge.yml` under
702
+ `evidence.exclude.cache` and prints the trusted policy digest to approve
703
+ outside the repository. A matching protected
637
704
  `GATEFORGE_APPROVED_POLICY_DIGEST` pin is REQUIRED before a gate uses the
638
- list; changing an existing list requires `--confirm-cache-exclusions`.
705
+ list; changing an existing list requires `--confirm-cache-exclusions`. Before
706
+ 0.10 this list lived in `.gateforge/cache-exclusions.yml`, and
707
+ `gateforge migrate --confirm` moves it.
639
708
  Only exact `.pyc` or `.pyo` files directly under `__pycache__` are allowed;
640
709
  globs, symlinks, configured inputs, and other file types fail closed. Reports
641
710
  show the exact files, pin status, and reduced trust guarantee. This is an
642
711
  owner assertion, not proof that the excluded bytecode cannot affect runtime
643
712
  behavior.
644
713
 
714
+ **Re-pinning the approved policy digest.** The pin is one aggregate hash, so a
715
+ mismatch alone never said WHICH input moved. Two things answer that now.
716
+ `gateforge enforcement doctor` reports `policy-inputs-vs-HEAD` — the
717
+ trusted-digest inputs whose STAGED bytes differ from HEAD, named one by one
718
+ (`policy inputs changed since HEAD: .gateforge.yml, .gateforge/runtime.yml`); a
719
+ whitespace-only edit counts, because it moves the digest — and `approved-digest`,
720
+ which compares the provisioned pin with the STAGED digest: `matches staged`,
721
+ `does NOT match staged (changed inputs: …)`, or `absent`. Both rows read the one
722
+ entry list the digest is computed from, so they cannot disagree.
723
+ `gateforge enforcement pin --pin-file <path> [--confirm]` then writes that value
724
+ for you. The policy inputs it covers are `.gateforge.yml`, the policies and
725
+ classification-policy documents, `.gateforge/test-map.yml`, the behavior and
726
+ runtime documents, the adapters, waivers and quarantine directories, and every
727
+ local in-process plugin module. Stage every policy file first: the pin digests
728
+ the STAGED bytes, and a working tree that differs from the index is refused by
729
+ name instead of pinning a revision the gate never digests.
730
+
645
731
  **Managed mode** (config `enforcement.mode: managed`) — the literal
646
732
  no-bypass guarantee requires putting the authoritative Git metadata, commit
647
733
  service, gate executable, policy authority, and signing material OUTSIDE the
@@ -716,7 +802,7 @@ else):
716
802
  | Namespace | Status |
717
803
  | --- | --- |
718
804
  | `persistence:create\|read\|update\|delete` | AVAILABLE — engine-observed same-entity persistence reads with the exact-value echo requirement (`EVIDENCE_VALUE_MISMATCH` on a mismatched echo, even when the status was 2xx) |
719
- | `http:request-observed`, `http:response-status-ok` | AVAILABLE — transport semantics only: a witness-observed exchange plus a provenance-verified claimed `ui.action` anchor from the declaring test |
805
+ | `http:request-observed`, `http:response-status-ok` | AVAILABLE — engine browser, or the Observe channel for tests mapped `observed-e2e` (an exchange the witness proxied in the test's own session; test attribution is suite-claimed). The engine path grades FIRST and its verdict is final: a `satisfied` grade keeps its own record ids, and an `invalid` one (a witnessed exchange of a different endpoint, a non-2xx response) is an engine-found error no second channel may mask. The Observe channel is consulted only when the engine path found nothing |
720
806
  | `http:frontend-request-observed` | UNAVAILABLE — no independent browser/test attribution channel; explicit selection remains blocking `missing` with `VERIFIER_UNSUPPORTED` |
721
807
  | `crud:*` (UI-semantic) | FAIL-CLOSED — the tested suite owns the browser; use `persistence:*` |
722
808
  | `http:effect-verified`, `http:read-result-verified` | AVAILABLE (behavior-case channel) — graded across the approved required cases with witness-issued `behavior.case` records; needs a compiled `behaviorPolicy` requirement set |
@@ -818,6 +904,77 @@ Enforcement-relevant sections:
818
904
  `cypress`. `check`, `next`, `tests`, `test-gates`, `doctor` and `init`
819
905
  all follow it. See `guides/RUNNER-NEUTRAL-EVIDENCE.md`.
820
906
 
907
+ ## Classification policy (`.gateforge/classification-policy.yml`)
908
+
909
+ The repository-wide deterministic classification inputs. `gateforge init`
910
+ scaffolds the file; every key is an OWNER answer, and the file
911
+ participates in the trusted-policy digest, so changing it re-approves any
912
+ approved policy pin before strict gates run.
913
+
914
+ | Key | What it decides | Shape |
915
+ | --- | --- | --- |
916
+ | `scanRoots` | the files a closed-world proof must cover | repo-root-relative globs |
917
+ | `trustedInternalEntryPoints` | which entry-point categories certify internality | category + patterns + detector |
918
+ | `internalRules` | organization rules for internal resources | `resourceName` / `resourceKind` patterns |
919
+ | `lifecycleRules` | operations that structurally do not exist, for one EXACT resource | exact `<plane>.<resource>` + `disable` |
920
+ | `deleteRules` | how removal manifests, per source glob | `match` glob + `semantics` (+ `archiveFields`) |
921
+ | `coverage` | which detector must examine which files before a proof counts | capability + detector + globs (+ `exhaustive`) |
922
+ | `declarations` | the declaration syntax detectors may emit | source strings |
923
+ | `volatileFields` | bookkeeping columns that never satisfy an update | column names |
924
+
925
+ Unknown keys, an unknown value, and two rules answering the same target
926
+ are refused (exit 2, fail closed) — the document is an input, never a
927
+ place to smuggle intent past the schema.
928
+
929
+ ### Owner-declared delete semantics (`deleteRules`)
930
+
931
+ Delete semantics are proven, never guessed. A detector that reads the
932
+ model's own declaration can prove `hard` or `archive`; when nothing
933
+ proves them, the resource stays `unclassified` and blocks with
934
+ `DELETE_SEMANTICS_UNRESOLVED` (no obligations accrue, and `gateforge
935
+ explain <resource>` names the resource and its source file). `lifecycleRules`
936
+ can DISABLE delete for one exact resource; declaring semantics is the
937
+ other half of the answer, and it needs a pattern because one declaration
938
+ usually covers a whole model tree.
939
+
940
+ ```yaml
941
+ deleteRules:
942
+ - match: 'backend/models/session/**'
943
+ semantics: hard
944
+ reason: 'Sessions are removed the moment the tenant logs out.'
945
+ - match: 'backend/models/invoice/**'
946
+ semantics: archive
947
+ archiveFields:
948
+ status: archived
949
+ reason: 'Invoices are retained for the audit window.'
950
+ ```
951
+
952
+ - `match` is a repo-root-relative glob over the SOURCE FILE of the
953
+ resources it declares for — the same glob engine `.gateforge/planes.json`
954
+ uses. It must stay inside the repository.
955
+ - `semantics` is `hard` or `archive`. `archive` REQUIRES non-empty
956
+ `archiveFields`: the owner-owned archived state (e.g.
957
+ `{status: archived}`) the engine grades removal against. `hard` must not
958
+ carry the key — a permanent removal has no archived state.
959
+ - `reason` is required and is shown with the rule in traces.
960
+
961
+ Write it with the command, which previews without `--confirm` and writes
962
+ with it (folder answers become `match: '<folder>/**'`):
963
+
964
+ ```sh
965
+ gateforge classify delete backend/models/invoice archive \
966
+ --archive-field status=archived \
967
+ --reason 'Invoices are retained for the audit window.' --confirm
968
+ ```
969
+
970
+ Declaring semantics is an evidence CONTRACT, not an override: the rule
971
+ contributes the same delete-semantics / archive-state evidence a detector
972
+ would. Detector evidence that disagrees therefore still blocks — the
973
+ conflicting-semantics detail names the owner declaration — and nothing is
974
+ ever silently overridden. A resolved decision names the rule it used
975
+ (`DELETE_SEMANTICS_OWNER_RULE(<match>)` in the trace), and a resource
976
+ outside every `match` is exactly as it was.
977
+
821
978
  ## Plugin invocation
822
979
 
823
980
  Every configured plugin runs over the same expanded include path list
@@ -1383,10 +1540,15 @@ expected context, every witnessed record demotes to claimed-tier
1383
1540
  - Staged candidates containing symlinks or submodules (and unmerged index
1384
1541
  entries) are typed blocks in `check --staged` and `broker commit` —
1385
1542
  explicit, never fallbacks; support is not implemented.
1386
- - A Playwright config with NO named project yields native rows with an
1387
- empty project name, which the strict catalog schema rejects as an
1388
- internal error (exit 2) instead of a typed row. The documented consumer
1389
- shape uses named projects; a typed empty-project row is open work.
1543
+ - A Playwright config with NO named project: `tests discover` prints an
1544
+ error line naming the config and the fix
1545
+ (`projects: [{ name: 'chromium' }]`) and still writes the catalog, and
1546
+ `enforcement doctor` fails the `playwright-projects` row — `test-gates`
1547
+ needs a named project.
1548
+ - Gateforge reads the FIRST of `playwright.config.{ts,mts,cts,js,mjs,cjs}`
1549
+ at the repository root; a suffixed config such as
1550
+ `playwright.config.e2e.js` is not read — rename it to
1551
+ `playwright.config.js` if it is the suite to prove.
1390
1552
  - Run-state hygiene is enforced, not forgiven: a committed run-state
1391
1553
  directory (it overlaps source inputs) or config include globs that omit
1392
1554
  the spec directories produce fail-closed diagnostics — gitignore
@@ -1448,13 +1610,32 @@ artifacts automatically creates auditable testing responsibilities.
1448
1610
 
1449
1611
  Blocked agents run `gateforge next` (or `gateforge next --json`): exactly
1450
1612
  one blocking next action (`next`/`cause`/`why`/`do`), never a dump. Do the
1451
- single `do:` line and stop. New proof tests go in `tests/e2e/gateforge/`
1613
+ single `do:` line and stop. New proof goes in `tests/e2e/gateforge/`
1452
1614
  (overlay, engine-driven fixture — wizard creates via surface v2 steps);
1453
- existing suite-driven browser tests prove persistence via the Observe
1454
- channel once mapped `--kind observed-e2e`. Never rewrite existing
1455
- `tests/e2e/**` journeys, never `tests mark` as proof, never edit policies
1456
- or waivers to self-approve. `GATEFORGE.md` (written by `gateforge init`)
1457
- carries the full loop contract.
1615
+ existing suite-driven browser tests prove persistence and transport via the
1616
+ Observe channel once mapped `--kind observed-e2e` — but ONLY when the test's
1617
+ `page` comes from Gateforge's own test object, because that fixture is what
1618
+ routes the test's app traffic through the supervisor's session observation
1619
+ proxy. A test that takes `page` from plain `@playwright/test` reaches the app
1620
+ directly, the witness observes nothing, and the claims finalize missing while
1621
+ the test passes. When the suite has one shared fixture file, rebase it on
1622
+ Gateforge's fixture and change nothing else in the suite:
1623
+
1624
+ ```js
1625
+ // CommonJS suite (Node >= 20.19 / >= 22.12 for require)
1626
+ const { test: baseTest, expect } = require('@gate-forge/pack-playwright/fixture');
1627
+ ```
1628
+
1629
+ ```ts
1630
+ // ESM suite
1631
+ import { test as baseTest, expect } from '@gate-forge/pack-playwright/fixture';
1632
+ ```
1633
+
1634
+ Rebasing the shared base is not rewriting a journey: the journeys' own steps,
1635
+ assertions and fixtures stay as they are, and only the `test` object they
1636
+ extend changes. Never rewrite existing `tests/e2e/**` journeys, never
1637
+ `tests mark` as proof, never edit policies or waivers to self-approve.
1638
+ `GATEFORGE.md` (written by `gateforge init`) carries the full loop contract.
1458
1639
 
1459
1640
  ## Fix a failing test without a full run
1460
1641
 
@@ -1658,6 +1839,21 @@ services_down:
1658
1839
  commands: [['./scripts/stop-stack.sh']]
1659
1840
  ```
1660
1841
 
1842
+ The recipe shares `.gateforge/runtime.yml` with the
1843
+ staged/supervised runtime: it is ONE document with TWO
1844
+ independent key groups that may coexist. `env_files`, `reset`,
1845
+ `seed`, `services_up`, `healthcheck`, and `services_down` are
1846
+ read only by `gateforge run` (see
1847
+ `packages/cli/src/run-recipe.ts`, which also reads `prepare`
1848
+ — its `commands`, `runTimeoutSeconds`, and `runRetries`
1849
+ sub-keys), while `schemaVersion`, `prepare`, `health`,
1850
+ `services`, `envAllowlist`, and `executionTimeoutSeconds`
1851
+ belong to the staged/supervised runtime (`check --staged` and
1852
+ `test-gates`; see `packages/cli/src/runtime.ts`, where
1853
+ `check --staged` reads `prepare`'s `command`, `reuse`,
1854
+ `timeoutSeconds`, and `preflight` sub-keys). Both groups may
1855
+ live in the same document; neither enables the other.
1856
+
1661
1857
  An unknown key, a malformed step, or an inline value in `env_files` is a
1662
1858
  plain error with exit 2 — Gateforge never runs a half-understood recipe. See
1663
1859
  the [test environment guide](TEST-ENVIRONMENT.md) for the