@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
@@ -0,0 +1,1756 @@
1
+ # Gateforge CLI reference
2
+
3
+ The reference for the `gateforge` CLI: every command, flag, exit
4
+ code, and protocol, plus the usage documentation that lived in the
5
+ repository README before the 0.9.0 documentation split. Both halves
6
+ moved verbatim from `packages/cli/README.md` and the root
7
+ `README.md`. The [CLI README](../README.md) covers install and the
8
+ first commands; the guides cover the walks:
9
+ [Quickstart](QUICKSTART.md), [Connect your project](CONNECT-YOUR-PROJECT.md),
10
+ [Test environment](TEST-ENVIRONMENT.md),
11
+ [Runners other than Playwright](RUNNER-NEUTRAL-EVIDENCE.md),
12
+ [Upgrade from 0.8 to 0.9](UPGRADE-0.8-to-0.9.md).
13
+
14
+ ## Contents
15
+
16
+ - [Commands](#commands)
17
+ - [Staged runtime (`.gateforge/runtime.yml`)](#staged-runtime-gateforgeruntimeyml)
18
+ - [Harness and run history](#harness-and-run-history)
19
+ - [Existing-test reuse (`gateforge tests`)](#existing-test-reuse-gateforge-tests)
20
+ - [Advisory pytest diagnostics](#advisory-pytest-diagnostics)
21
+ - [Enforcement](#enforcement)
22
+ - [Contract capabilities](#contract-capabilities)
23
+ - [Configuration](#configuration)
24
+ - [Plugin invocation](#plugin-invocation)
25
+ - [Endpoint plane rules (`.gateforge/planes.json`)](#endpoint-plane-rules-gateforgeplanesjson)
26
+ - [Endpoint capability rules (`.gateforge/endpoints.json`)](#endpoint-capability-rules-gateforgeendpointsjson)
27
+ - [Proposing planes at init (`gateforge init --planes`)](#proposing-planes-at-init-gateforge-init---planes)
28
+ - [test-gates protocol (G6 surface)](#test-gates-protocol-g6-surface)
29
+ - [Limitations](#limitations)
30
+ - [Pick a goal, not a wall of flags](#pick-a-goal-not-a-wall-of-flags)
31
+ - [Agent loop](#agent-loop)
32
+ - [Fix a failing test without a full run](#fix-a-failing-test-without-a-full-run)
33
+ - [What the gate catches that ordinary tests can miss](#what-the-gate-catches-that-ordinary-tests-can-miss)
34
+ - [Running in CI](#running-in-ci)
35
+ - [Gate strictness and flaky tests](#gate-strictness-and-flaky-tests)
36
+ - [Run the whole proof with one command](#run-the-whole-proof-with-one-command)
37
+ - [The witnessed CI job](#the-witnessed-ci-job)
38
+ - [Known limitations](#known-limitations)
39
+
40
+ ## Commands
41
+
42
+ | Command | Purpose | Exit codes |
43
+ | --- | --- | --- |
44
+ | `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 |
45
+
46
+
47
+
48
+ | `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
+ | `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
+ | `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 |
51
+ | `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
+ | `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 |
54
+ | `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
+ | `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) |
57
+ | `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
+ | `gateforge obligations [--json]` | Evaluate policies against the automatically classified graph and dump obligations, blocking entries, and claim assessments. | 0/1/2 |
59
+ | `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 |
60
+
61
+ | `gateforge test-gates [--changed] [--scope full\|changed] [--progress stderr\|file:<path>\|off] [--result-only] [--suite <cmd>] [--out <dir>] [--format F] [--witness-url <url>] [--run-token <token>]` | The progress stream (additive, `--progress`, or the `run.progress` config key) prints the registered expected-set size, one line per finished test with exact `N/M` counters and the catalog title, an alive line per quiet minute, and the finish line before grading. It is built from witness-side facts only and never from runner output; a failing test's first error line passes a credential guard and is replaced whole when it matches, and the full guarded diagnosis lands in `.gateforge/test-gates/failures.json`. `auto` (the default) is stderr under `CI=true` and off locally. The stream is not evidence and no gate reads it. Supervised `--changed` plans and runs mapped Playwright tests through the trusted adapter, checks planned/executed completeness, and seals an authenticated receipt only after complete success. `--scope changed` limits a sealed slice to obligations affected by changed files; incomplete mappings block, and `check --require-e2e` accepts it only when it covers every currently changed obligation. `--result-only` requires `--changed --scope changed`, reports selected results plus repository debt, and has no gate authority: without an external witness it uses private temporary state; with `--witness-url` it requires `--out` + `--run-token` shared with the external witness in a separate state directory (not the configured authoritative state directory). It never creates or clears a receipt. `--suite` remains legacy and cannot combine with `--changed` or redefine strict expected cases. Verifier keys use `GATEFORGE_WITNESS_VERIFIER_KEY` or the external key ring selected by `GATEFORGE_WITNESS_VERIFIER_KEY_FILE`. | 0/1/2 (suite failure forces 1) |
62
+ | `gateforge test-gates --chaos <seed> --result-only` | Timing chaos (additive, opt-in, E63): the witness observation proxy releases proxied app RESPONSES on a schedule derived from `<seed>` — a delay in `[0, maxDelayMs]` per response, and, for requests sharing a route key inside one test session, the option of releasing a later response before an earlier one. Only timing changes; bytes, status, headers and evidence semantics never do. The schedule is a pure function of (seed, session identity, route key, k), so the same seed replays it exactly, and the report plus the sealed execution result carry `chaos: { seed, maxDelayMs, reorder, schedule }` (route key = method + pathname, query stripped) with the text line `timing chaos: seed <n>`. Accepted only with `--result-only`: a chaos run finds races, it never seals a receipt. `run.chaos: { maxDelayMs, reorder }` tunes the bounds of a witness the run spawns itself (default 400 ms, reorder on) and never enables chaos by itself — without the flag every run, report and execution result is byte-identical to before. With `--witness-url` nothing is configured on the witness side: the plan travels with the supervisor-authenticated run-context binding (`options.chaos`), which the witness applies before the first session opens, so `run.chaos` tunes the bounds in both cases. A NORMAL run against a witness that was itself started with `GATEFORGE_CHAOS_SEED` exits 2 before any test runs, naming the variable to unset (a perturbed witness can never seal), and a witness too old to accept run options is refused for `--chaos` rather than reporting a schedule it never applied. A normal run against a witness with no plan — including one too old to have the route — is byte-identical to before. A seed that is not a non-negative integer exits 2 with one plain line. |
63
+ | `enforcement.twinPaths` (with `enforcement.twinQueryKeys`) | Twin path coverage (additive, opt-in, E64): links a raw test and its witnessed twin — by `twinOf` in `.gateforge/test-map.yml` or by the title convention `X [witnessed]` next to `X raw` (or the one `X raw: <description>`) — and compares the REQUEST SHAPES each side exercised (method, route template, and the values of the allowlisted query keys; never a URL, a body or a non-allowlisted value). A pair that disagrees is reported as `TWIN_PATH_DIVERGENT`, naming both tests and the exact differing value; `advisory` reports it and leaves the exit code alone, `block` makes it a blocking entry (exit 1). The raw twin's session is marked OBSERVATION-ONLY engine-side, so every submission from it is refused with 403: it can issue no record, no attestation and satisfy nothing, and contributes only its shapes. Absent (or set with no pair linked), nothing is wired, no state file is written and the report is byte-identical. With `--witness-url` the shape plan travels with the run-context binding (`options.twinShapes`: the allowlist and the route inventory as templates), so a repository's own witness needs no twin environment; a witness too old to accept run options records nothing and the run says so in one line instead of reporting twins that agree because nobody looked. |
64
+ | `gateforge broker commit --workspace <dir> --message <msg> [--receipt <path>] [--ref <ref>]` | Managed-mode commit broker (MECHANISM, not deployment): snapshots the workspace bytes into a throwaway index, recomputes the input + trusted-policy digests, verifies a valid non-stale gate receipt for EXACTLY those bytes, then creates the commit via compare-and-swap `git update-ref`. Typed rejections (`ENFORCEMENT_UNTRUSTED` / `EVIDENCE_STALE` / `RUN_INCOMPLETE` / `KEY_UNKNOWN` / `BROKER_CAS_MISMATCH` / `BROKER_UNSAFE_MESSAGE`); symlinks/submodules are typed rejections. Verifier keys use either supported environment source; the key file must be outside authority, workspace, and receipt artifact roots. | 0/2 |
65
+ | `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
+ | `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
+ | `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 |
68
+ | `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
+ | `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
+ | `gateforge baseline update <fp...>` | Shrink the baseline to a strict subset (invariant 4). | 0/2 |
71
+ | `gateforge baseline diff <before> <after>` | Compare adopted obligations by ID without printing fingerprints. | 0/2 |
72
+
73
+ On a repo that already has Gateforge files, `init` reports only what THAT run did: it keeps an existing `.gateforge.yml` and says so instead of claiming to write a preset, and the `undo:` lines it prints name every path the run created (`rm -rf`) and every file it changed in place (`git restore --`, for an appended `.gitlab-ci.yml` include, an appended `.pre-commit-config.yaml` entry, or an added ignore rule) — so following them can never delete pre-existing config, baselines, waivers, hooks or CI files, and a run that changed nothing prints no undo line at all. A preset that wires no local hook says whether your existing commit hook and/or CI job still decide what blocks your commits.
74
+
75
+ `init` also adds Gateforge's own engine state to `.gitignore` (`.gateforge/test-gates/` — the run catalog, plugin caches, receipts and history the engine regenerates on every run). Without it the first `git add -A` stages the run cache and the gate then blocks on its own files. The file is created when absent and appended to when present, your own lines are preserved, and a second run reports it as already ignored instead of appending again. The same run prints the `undo:` line for it.
76
+
77
+ `init` reads the repository to recommend detectors, and prefers quoting evidence from application code: hidden dot-folders (agent tooling, tool caches, leftover working directories) are not scanned at all, and a file inside an `archive/`, `vendor/`, `generated/`, `fixtures/`-style directory is only quoted when no application file carries the same signal. The generated `.gateforge.yml` carries the matching default excludes, so the detectors make the same choice.
78
+
79
+ `init` on a repository that ALREADY has code says so and names the way through the debt it will report on day one: `gateforge adopt` records today's findings as forgiven, shrink-only, and — under `strictE2E` — still blocks on an adopted E2E obligation as soon as a change touches it. A fresh, empty project never sees that block.
80
+
81
+ `--docs-exclude <folder,...>` and `--docs-exclude-file <path>` are the same owner assertion in two spellings (the file holds one folder per line; blank lines and `#` comments are ignored); they combine into one deduplicated list, and the interactive prompt says the flag exists so a long list does not have to be typed into one prompt.
82
+
83
+ `--unmatched-routes block|warn` answers, ahead of the terminal question, the
84
+ one thing a NEW repository must say about routes whose name matches no
85
+ discovered table: gate commits on them, or only report them. In a terminal
86
+ `init` asks once ("Routes whose name matches no table: block commits, or
87
+ warn only? [block/warn]"); headless it writes `warn` and prints the exact
88
+ key that turns blocking on. A repository that already has a
89
+ `.gateforge.yml` is never asked and never rewritten here — it keeps saying
90
+ nothing, which the `check`/`next` banner keeps pointing at.
91
+
92
+ The cache is disabled by `--no-cache`, `GATEFORGE_NO_CACHE=1`, or recognized CI-provider markers (`GITHUB_ACTIONS`, `GITLAB_CI`, `BUILDKITE`, `CIRCLECI`, `JENKINS_URL`, `TF_BUILD`). A bare `CI=true` does not disable it.
93
+
94
+ Global flags: `--help`, `--version`. Exit codes per architecture contract 4:
95
+ `0` clean/waived, `1` unresolved obligations (or a failed/supervision-blocked
96
+ run), `2` config/usage error. `tests diagnose` has its own advisory contract
97
+ (0/1/2 above).
98
+
99
+ ### Result-only with an external witness
100
+
101
+ Start the witness with a dedicated state directory, then pass that same
102
+ directory and its run token to `test-gates`. The directory must be separate
103
+ from the configured authoritative `.gateforge/test-gates` directory:
104
+
105
+ ```sh
106
+ gateforge test-gates --changed --scope changed --result-only \
107
+ --witness-url "$GATEFORGE_WITNESS_URL" \
108
+ --out "$GATEFORGE_STATE_DIR" \
109
+ --run-token "$GATEFORGE_RUN_TOKEN"
110
+ ```
111
+
112
+ `test-gates` claim planning reads current Playwright annotations using a
113
+ disposable `GATEFORGE_STATE_DIR`, plus the tracked `test-map.yml`. It never
114
+ treats a previous run's `claims.json` as a declaration source.
115
+
116
+ The report remains `authority: non-authoritative`. The external-witness
117
+ state may contain this run's report and attestation, but this command never
118
+ creates, replaces, or clears a gate receipt. Pre-commit, hook, and CI gate
119
+ paths remain authoritative and do not accept `--result-only`.
120
+
121
+ ### Re-check one failing test in seconds (`--test`)
122
+
123
+ To re-confirm a handful of hand-picked tests you do not need a whole
124
+ suite. `--test` names them, and the run is witnessed exactly like a full
125
+ gate run — the same supervisor, the same run token, the same server-side
126
+ evidence:
127
+
128
+ ```sh
129
+ # one test (a logical key, or any unique substring of one)
130
+ gateforge test-gates --test 'backend/tests/test_x.py::test_commits' --result-only
131
+
132
+ # several at once — --test is repeatable
133
+ gateforge test-gates --test UC-53 --test UC-51 --result-only
134
+ ```
135
+
136
+ `--test` is accepted **only** together with `--result-only`. A
137
+ hand-picked list never seals a receipt, so combining `--test` with a
138
+ sealing run exits 2 and says so. The named run never reads, writes, or
139
+ clears a gate receipt, so `check --require-e2e` is unaffected, and it
140
+ carries `authority: non-authoritative` plus `outcome: partial-selection`
141
+ in the report.
142
+
143
+ A selector is resolved against the **planned** rows — the expected set
144
+ fixed before the run — never against raw runner output, so it can only
145
+ name a test the gate already planned. An exact logical key always wins;
146
+ otherwise a unique case-insensitive substring is used. An unknown or
147
+ ambiguous selector exits 2 and lists the candidate logical keys, because
148
+ a narrower selection is never guessed:
149
+
150
+ ```sh
151
+ $ gateforge test-gates --test 'session proxy' --result-only
152
+ gateforge: the selector 'session proxy' matches 2 planned tests — pick one exact logical key. Run `gateforge tests discover --json`. [TEST_SELECTOR_AMBIGUOUS]
153
+ candidate logical keys:
154
+ - tests/green.test.mjs#creates account through the session proxy
155
+ - tests/second.test.mjs#creates the billing account through the session proxy
156
+ ```
157
+
158
+ The report gains an additive `selectors` field naming exactly what each
159
+ selector resolved to, and the run uses the `named-selection` selection
160
+ mode, so it can never collide with a full or a diff-linked slice:
161
+
162
+ ```json
163
+ { "outcome": "partial-selection", "selectors": [{ "selector": "UC-53", "logicalKeys": ["pytest:backend/tests/test_x.py::test_commits"] }] }
164
+ ```
165
+
166
+ Selection works for every runner (Playwright, pytest, vitest, Cypress)
167
+ through the shared runner-adapter contract. Because it works from the
168
+ plan, it does not need the changed-file set — that is why `--test` is
169
+ useful when a fix touches a `.env`, a fixture, or a helper that no test
170
+ links to.
171
+
172
+ Each runner narrows to the named tests as far as it honestly can:
173
+ Playwright, pytest and vitest receive the exact `file:line` / node id /
174
+ anchored test name, so a named test never drags its file neighbours
175
+ along. Cypress cannot filter below the spec without a plugin the gate
176
+ refuses to trust, so it executes the whole spec, drops every unselected
177
+ outcome and session (an unselected test never becomes evidence), and
178
+ says `also ran N other test(s) in the same file — not graded`.
179
+
180
+ #### What a named run grades, and its exit codes
181
+
182
+ A named run grades **only the selection**: the obligations its selected
183
+ tests declare through the sidecar or native annotations. Everything else
184
+ — repository-wide policy, mapping and inventory findings, the coverage
185
+ policy — is still reported, under `repositoryDebt` and as
186
+ `not graded in a named run: N obligation(s)`, but never blocks: the run
187
+ never observed it. What still blocks is everything about the run itself
188
+ (supervision findings, lifecycle conflicts, intent failures, the witness
189
+ channel, evidence-context failures) and any finding that names a graded
190
+ obligation. The report and the diagnostic context both carry
191
+ `scope: "named"`, and the execution summary keeps the whole-repository
192
+ counts next to the selection's own.
193
+
194
+ | Exit | Meaning |
195
+ | --- | --- |
196
+ | `0` | every selected test passed and every obligation it declares is satisfied (or waived by the owner), with a complete run and no run-execution finding |
197
+ | `1` | anything else: a red selected test, an unproven graded obligation, an incomplete run, changed inputs, or a workspace that moved during the run |
198
+ | `2` | the selector could not be resolved (unknown or ambiguous) — nothing ran |
199
+
200
+ A named run never carries gate authority: it is `--result-only` only,
201
+ never creates, replaces or clears a receipt, and `check --require-e2e`
202
+ keeps reading the seal the authoritative run left. A run without
203
+ `--test` is unaffected by any of this.
204
+
205
+ ## Staged runtime (`.gateforge/runtime.yml`)
206
+
207
+ `gateforge pre-commit` executes the candidate inside a materialized checkout
208
+ that contains TRACKED bytes only — no installed dependencies, no built
209
+ assets, no application processes. The reviewed staged-runtime document
210
+ declares how that checkout becomes a runnable candidate. It is
211
+ security-sensitive: its bytes are hashed into the trusted policy digest and
212
+ the authenticated input snapshot, so a candidate that edits its own runtime
213
+ commands cannot approve the edit in the same commit.
214
+
215
+ ONE document, TWO independent key groups that may coexist:
216
+ `schemaVersion`, `prepare`, `health`, `services`, `envAllowlist`,
217
+ and `executionTimeoutSeconds` are read by the staged/supervised
218
+ runtime — `check --staged` and `test-gates` (see
219
+ `packages/cli/src/runtime.ts`), where `check --staged` reads
220
+ `prepare` (its `command`, `reuse`, `timeoutSeconds`, and
221
+ `preflight` sub-keys) — while `env_files`, `reset`, `seed`,
222
+ `services_up`, `healthcheck`, and `services_down` are the
223
+ `gateforge run` recipe (see `packages/cli/src/run-recipe.ts`),
224
+ which also reads `prepare` (its `commands`, `runTimeoutSeconds`,
225
+ and `runRetries` sub-keys). Neither group requires the other: a
226
+ document may carry both, one, or none of the staged keys. Minimal
227
+ combined example:
228
+
229
+ ```yaml
230
+ schemaVersion: 1
231
+ prepare:
232
+ command: npm ci --offline # staged runtime (check --staged / test-gates)
233
+ commands: [['npm', 'run', 'build']] # gateforge run recipe step
234
+ envAllowlist: [DATABASE_URL]
235
+ executionTimeoutSeconds: 1800
236
+ env_files: [.gateforge/test.env]
237
+ reset: { commands: [['./scripts/reset-db.sh']] }
238
+ services_up: { commands: [['./scripts/start-stack.sh']] }
239
+ ```
240
+
241
+ ```yaml
242
+ schemaVersion: 1
243
+ prepare:
244
+ command: npm ci --offline # or pnpm/bun/uv — frozen install, build steps
245
+ reuse: [node_modules] # dependency dirs EXPLICITLY allowed to link from the user repo
246
+ timeoutSeconds: 600
247
+ preflight: # optional cheap checks before prepare
248
+ - { name: lint, command: npm run lint, timeoutSeconds: 60 }
249
+ health: # optional probes before/after the suite
250
+ - { name: database, tcp: '127.0.0.1:5432', timeoutSeconds: 5 }
251
+ - name: worker-startup
252
+ logAbsent:
253
+ command: ./tools/recent-worker-logs.sh
254
+ pattern: 'worker startup failed'
255
+ services: # candidate-owned app/database/worker processes
256
+ - id: app
257
+ command: node server.js --port ${service:app:port}
258
+ attested: true # fronted by the gate's attestation proxy
259
+ fingerprint: prod-v1 # GF-13 marker (reviewed adapters must declare the same)
260
+ target: true # this proxy URL becomes the run's attested target
261
+ ready: { log: 'listening on', timeoutSeconds: 60 } # or http: <url>
262
+ envAllowlist: [DATABASE_URL] # operator env names for services and supervised tests
263
+ executionTimeoutSeconds: 1800 # whole-run budget handed to the supervised gate
264
+ ```
265
+
266
+ Contract highlights:
267
+
268
+ - Services start from the CHECKOUT bytes (never the worktree) in their own
269
+ process groups; readiness (`log` regex or `http` 2xx), startup, and
270
+ execution timeouts are bounded; stdout/stderr are captured to
271
+ `<run-state>/runtime/<id>.log`; teardown happens on success, failure,
272
+ timeout, and interruption (SIGINT/SIGTERM kill the whole groups).
273
+ - `prepare.preflight` checks run in order before `prepare`; the first
274
+ non-zero exit blocks preparation with `PREFLIGHT_FAILED <name>` and the
275
+ command's last 30 output lines.
276
+ - `health` supports one `tcp`, `http`, `command`, or `logAbsent` probe per
277
+ entry. `logAbsent` runs its declared log command after startup and blocks
278
+ when the configured regex is found. A failed startup probe blocks with
279
+ `FIXTURE_UNHEALTHY <name>`; the post-run probe is advisory and does not
280
+ change test verdicts. HTTPS uses normal certificate verification.
281
+ - Every `prepare.reuse` tree is constrained to a normalized repository-relative
282
+ path. Its reachable dependency bytes are hashed into the authenticated
283
+ input identity, so changing an ignored reused dependency invalidates the
284
+ receipt even though the checkout uses a link.
285
+ - `${service:<id>:port}` / `${service:<id>:url}` placeholders are
286
+ substituted by the supervisor and injected into every service's
287
+ environment (`GATEFORGE_SERVICE_PORT_<ID>` / `GATEFORGE_SERVICE_URL_<ID>`).
288
+ - The attested target is the process THE GATE started from the frozen
289
+ candidate — a bare target URL proves nothing. The receipt binds the raw-
290
+ ingested tree of the prepared checkout (`targetArtifactDigest`), and the
291
+ user's index is rechecked before authorization.
292
+ - ABSENT document = no bridge, no services (fail closed): discovery that
293
+ needs installed dependencies blocks honestly instead of silently reusing
294
+ the worktree's environment.
295
+
296
+ ## Harness and run history
297
+
298
+ The optional `.gateforge.yml` `harness` section declares `up`, `reset`,
299
+ `seed`, `health`, and `down` shell commands. Supervised runs invoke configured
300
+ setup commands in that order before the suite; the first failure blocks the
301
+ suite, prints its last 30 output lines, and still attempts `down`. Gateforge
302
+ executes these commands but does not manage containers or other infrastructure.
303
+ Absent `harness` preserves current behavior.
304
+
305
+ ```yaml
306
+ harness:
307
+ up: ./tools/test-up.sh
308
+ reset: ./tools/test-reset.sh
309
+ seed: ./tools/test-seed.sh
310
+ health: ./tools/test-health.sh
311
+ down: ./tools/test-down.sh
312
+ serviceLogs:
313
+ command: docker compose logs --no-color --tail ${lines} ${service}
314
+ services: [database, worker]
315
+ lines: 100
316
+ ```
317
+
318
+ On a failed supervised run, `serviceLogs` runs the declared log command for
319
+ each service and saves the configured tail to
320
+ `<run-state>/diagnostics/service-logs.txt`. Log capture is advisory and does
321
+ not change test verdicts.
322
+
323
+ Each `verifyPersistence` adapter call is timed in
324
+ `<run-state>/diagnostics/adapter-timing.jsonl`; calls over two seconds also
325
+ print a warning. Timed-out tests report the observed app/runner time separately
326
+ from their summed witness-adapter time. These diagnostics do not alter the
327
+ receipt or verdict.
328
+
329
+ Run history is opt-in through `.gateforge.yml` `history`; when configured,
330
+ retention defaults to 14 days and is capped at 90. Set `retentionDays: off`
331
+ to disable it. History is stored beneath the ignored test-gates state and is
332
+ not receipt input. Query it with `gateforge history [--test TEXT] [--failed]
333
+ [--since ISO-8601]`.
334
+
335
+ ## Existing-test reuse (`gateforge tests`)
336
+
337
+ The reuse-first workflow: inspect what exists, declare what is unclear, run
338
+ it, and add a new test only for a confirmed behavior gap. The fixed agent
339
+ sequence is: `tests discover` → `tests suggest` → `tests sync` for annotated
340
+ tests or `tests mark` for hand-written sidecar mappings → run the suite under
341
+ supervision → `check --require-e2e`.
342
+
343
+ `tests discover` writes the catalog to `.gateforge/test-gates/test-catalog.json`
344
+ — a DERIVED artifact under the excluded run-state directory, never a pipeline
345
+ input and never beside the tests it inventories. Logical keys are stable
346
+ (`playwright:<project>:<file>:<title path>`; `-` when the runner has no
347
+ project) so manual mappings survive comment edits; source digests still move,
348
+ so old evidence goes stale. Renamed/deleted tests and removed parameters
349
+ surface as stale or ambiguous mappings — never a silent reassignment.
350
+
351
+ `tests sync` statically resolves direct Gateforge annotations and local pure
352
+ helpers that return literals. It never loads a test runner or executes a test.
353
+ Entries marked `source: annotation` are regenerated; handwritten entries are
354
+ preserved. Unresolvable annotations are printed as `UNRESOLVED` with the test
355
+ file and location. `check` reports missing/extra generated claims as the
356
+ non-blocking `TEST_MAP_OUT_OF_SYNC` advisory for this release period; run
357
+ `gateforge tests sync` to reconcile them.
358
+
359
+ `tests mark` validates the declaration against the current catalog AND the
360
+ current obligation registry (an unknown obligation id or test key is a
361
+ precise exit-2 error) before writing `.gateforge/test-map.yml`:
362
+
363
+ ```yaml
364
+ schemaVersion: 1
365
+ tests:
366
+ - key: playwright:chromium:e2e/accounts.spec.ts:deletes an account
367
+ selector:
368
+ runner: playwright
369
+ project: chromium
370
+ file: e2e/accounts.spec.ts
371
+ titlePath: [Accounts, deletes an account]
372
+ kind: browser-e2e
373
+ categories: [persistence.delete]
374
+ claims: [tenant.accounts:persistence:delete]
375
+ reason: Existing journey deletes the selected account.
376
+ ```
377
+
378
+ `--kind` is one of `browser-e2e`, `observed-e2e`, `api-e2e`, `unit`, `integration`,
379
+ `component`, `unknown`. A declaration is INTENT, never proof:
380
+
381
+ - Native `{ type: 'gateforge', description: '<obligation id>' }` annotations
382
+ keep working; sidecar entries and native claims normalize through ONE
383
+ resolver. Exact duplicate claims deduplicate; contradictions block with
384
+ both source locations (`TEST_MAPPING_AMBIGUOUS`).
385
+ - An explicit kind may resolve `unknown` — and `observed-e2e` may refine an
386
+ inferred `browser-e2e` (same journey, witness-watched instead of
387
+ engine-driven) — but cannot override observed mocking or any other
388
+ strong code-signal inference — `tests mark` refuses with
389
+ both locations instead of writing the file.
390
+ - Agents may edit the sidecar directly; both paths receive identical
391
+ validation. `mark` is idempotent: re-running an exact declaration writes
392
+ nothing and reports `no changes`.
393
+ - Nothing here waives, weakens, or satisfies anything: a mapped test with no
394
+ witnessed evidence for this change grades `EVIDENCE_NOT_COLLECTED` —
395
+ blocking.
396
+
397
+ `tests suggest` emits `newTestNeeded: true` only when no suitable existing
398
+ candidate survives resolution. An unsupported proof channel produces a
399
+ capability task (`VERIFIER_UNSUPPORTED`), never a request to generate more
400
+ tests.
401
+
402
+ ### Ranked candidates
403
+
404
+ Candidates are RANKED by the evidence the catalog row itself carries, not
405
+ listed alphabetically: an explicit `@crud(...)` tag, a resource token in the
406
+ title path or the file, the obligation's operation word, a route segment from
407
+ the run's route inventory, a `real/` (unmocked) folder, minus a mock signal.
408
+ Every weight is additive and printed as a `why:` line, so the order explains
409
+ itself — the score is never a bare number. Ties break on the logical key, so
410
+ the list is deterministic. The text surface prints the top five and says how
411
+ many it hid; `--json` carries every candidate with its `rank` and `score`:
412
+
413
+ ```text
414
+ obligation: tenant.accounts:persistence:create cause: TEST_MAPPING_MISSING
415
+ candidates (ranked by evidence):
416
+ - #1 playwright:chromium:tests/e2e/real/account_create_matrix.spec.js:company tenant persists (tests/e2e/real/account_create_matrix.spec.js)
417
+ why: explicit tag names this obligation's resource 'accounts'
418
+ why: lives in a 'real' folder (unmocked)
419
+ ... and 286 more candidate(s) — run `gateforge tests suggest --json` for the full ranked list
420
+ ```
421
+
422
+ In `--json`, each candidate's `overlaps` lists the obligations that
423
+ DECLARE that test (a `test-map.yml` entry or a `@gateforge` annotation) —
424
+ not every obligation the test merely came up as a candidate for. The
425
+ candidate list itself is unchanged and still carries every candidate.
426
+
427
+ `already declared for: …` is printed only when a DECLARATION exists (a
428
+ `test-map.yml` entry or an `@gateforge` annotation). An inferred or
429
+ prior-run binding is a suggestion, never a declaration, and no longer prints
430
+ that line.
431
+
432
+ ### One instruction, not two
433
+
434
+ When a candidate exists, the suggestion's next action is to MARK that
435
+ existing test `observed-e2e` and run it under the witness
436
+ (`gateforge tests mark --test <key> --kind observed-e2e --obligation <id>
437
+ --reason "…"` then `gateforge test-gates --changed`). The overlay
438
+ instruction — write `tests/e2e/gateforge/<resource>.<op>.spec.js` — belongs
439
+ to `newTestNeeded: true`, i.e. no existing test fits. A suggestion block
440
+ never tells you to write a new overlay test and, in the same breath, to
441
+ reuse the test it just listed.
442
+
443
+ ### A declared mapping is visible in `check`
444
+
445
+ After `tests mark`, `check` says `mapped to: <test keys> (not yet witnessed)`
446
+ for every obligation whose test ids are declared but whose records were not
447
+ consulted, and its next action names the command that collects the evidence
448
+ (`gateforge test-gates --changed`) instead of the generic "write a test"
449
+ advice. The JSON report adds `declaredTests` and
450
+ `mappingState: "declared" | "declared-not-witnessed"`. Only DECLARED ids
451
+ appear there — an inferred or prior-run binding never does.
452
+
453
+ ### Runner file scope (`tests discover`)
454
+
455
+ The static scan is seeded from Gateforge's own include globs, so it finds
456
+ test-shaped calls anywhere in the repository — including files no configured
457
+ runner would ever collect. Each runner's OWN file selection is therefore read
458
+ as data and decides the row's runner:
459
+
460
+ - Playwright: the enumeration's project-graph reporter records each
461
+ project's resolved `testDir`, `testMatch` and `testIgnore`. A file outside
462
+ every project's selection is not a playwright test and is not catalogued as
463
+ one.
464
+ - Vitest: `vitest.config.*` / `vite.config.*` (at any depth, bounded) are read
465
+ with the TypeScript AST only — `test.include`, `test.exclude`,
466
+ `test.globals` literals, never an evaluated expression. A vitest suite
467
+ inside a playwright-configured repository is catalogued as a vitest row
468
+ with a `runner-file-scope` weak signal naming the evidence; with
469
+ `globals: true`, a bare `describe`/`it` is a registration the runner owns,
470
+ not an `unresolved-test-alias` gap.
471
+
472
+ Every selection is FAIL-OPEN and says so. A pattern that cannot be translated
473
+ (`!`-negated class, unbalanced group), a computed value, a function-valued
474
+ selector, or a missing config makes the scope select everything — today's
475
+ behaviour — and the runner summary line states which selection could not be
476
+ read. A file that NO runner's selection claims keeps the configured runner
477
+ and stays a blocking row (`reconciliation-static-only`, carrying a
478
+ `no-runner-claims-file` weak signal that says so): ownership is never
479
+ invented.
480
+ `inventoryComplete` is judged over the CONFIGURED runner's unresolved rows.
481
+
482
+ ## Advisory pytest diagnostics
483
+
484
+ Register existing pytest suites under `diagnostics.suites` in
485
+ `.gateforge.yml` (explicit, tracked configuration — gateforge never scans
486
+ directories or executes commands on its own; only the `pytest` runner has an
487
+ adapter today):
488
+
489
+ ```yaml
490
+ diagnostics:
491
+ suites:
492
+ - name: backend-pytest
493
+ runner: pytest
494
+ cwd: server
495
+ argv: [python, -m, pytest]
496
+ testPaths: [tests]
497
+ timeoutMs: 600000
498
+ hostLoad: true # opt-in: sample load average, CPU count, and disk space
499
+ ```
500
+
501
+ `gateforge tests diagnose` runs each configured suite once against the
502
+ current inputs (drift around discovery refuses the run) and prints a SEPARATE
503
+ diagnostic report with `DIAGNOSTIC_TEST_FAILURE` /
504
+ `DIAGNOSTIC_RUN_INCOMPLETE` / `DIAGNOSTIC_RESULT_STALE` causes. Skips and
505
+ expected failures stay explicit counters; a run of only skipped/xfail cases
506
+ is INCOMPLETE (exit 2), never a passing alarm. Diagnostic results are never
507
+ fed into claims, witness records, baselines, waivers, or E2E satisfaction,
508
+ and are never merged into E2E pass counts — 100 passing pytest tests do not
509
+ clear one missing browser obligation. When the supervised run executes the
510
+ same suites, their results are displayed separately without changing the E2E
511
+ exit decision.
512
+
513
+ When enabled, the supervised run writes `diagnostics/host-load.json` at start,
514
+ every 30 seconds, and at completion. Failed tests completed while load exceeds
515
+ 1.5× CPU count get a note with the nearest preceding sample. Free disk below
516
+ 5% at start emits a warning; load and disk data are diagnostic only.
517
+
518
+ ## Enforcement
519
+
520
+ Two named modes (ADR 0005 D1); the CLI never reports a hook as more than it
521
+ is.
522
+
523
+ When a witnessed pre-commit run reaches a blocking result, Gateforge reports
524
+ how many tests the current commit selected and, when recorded, how long the
525
+ last full run took. This is cost context only; the current run and its receipt
526
+ still decide whether the commit passes.
527
+
528
+ **Standard mode** — an active local hook PLUS a mandatory trusted server
529
+ check:
530
+
531
+ - `gateforge init --blocking` installs a static pre-commit check and, for
532
+ new configs (`enforcement.receiptStage: pre-push`), a pre-push hook that
533
+ checks each pushed commit tip with `check --candidate-commit <sha>
534
+ --require-e2e`. The static lane does not require a receipt; the pre-push
535
+ lane does. Existing configs without `receiptStage` keep their previous
536
+ pre-commit behavior. Hook activation is verified; foreign hooks are never
537
+ overwritten.
538
+ By default, `init --blocking` writes `.gateforge/ci/gitlab-gateforge.yml`
539
+ plus the `.gitlab-ci.yml` include. `gateforge enforce --ci github` writes
540
+ `.github/workflows/gateforge.yml` instead. Both strict templates run
541
+ `test-gates --changed`, then verify the exact CI commit with
542
+ `check --changed --candidate-commit "$CI_COMMIT_SHA"` (GitLab) or
543
+ `--candidate-commit "$GITHUB_SHA"` (GitHub). The verifier key and policy
544
+ pin come from protected CI secrets.
545
+ `init --blocking` prints exact GitHub/GitLab protection commands for
546
+ owner review; it never runs server mutations itself.
547
+ Protect the branch, require its Gateforge pipeline to succeed (skipped jobs
548
+ do not count), exclude agent roles from direct pushes, and use an
549
+ organization-controlled pipeline execution policy so a candidate cannot
550
+ remove the gate job. THE HONEST LIMIT: `--no-verify`, an alternate
551
+ `core.hooksPath`, direct plumbing, or an unrelated clone bypass any local
552
+ hook — keeping bypassed commits out of protected history is the server's
553
+ job, not the hook's.
554
+ `gateforge enforcement doctor` reports level 0–3. It reports level 3 only
555
+ when a read-only provider API confirms branch protection plus a required
556
+ Gateforge status check or passing-pipeline setting.
557
+ - The CI template checks that the installed `@gate-forge/cli` version equals
558
+ the version that generated it. Add that exact version as a root
559
+ `devDependency`. The template uses a package-manager lockfile when present;
560
+ without one, it installs from the manifest. Set
561
+ `GATEFORGE_CI_NESTED_PACKAGE_DIRS` to a space-separated list such as `e2e`
562
+ when the Playwright config imports dependencies from nested packages.
563
+ `enforce` and `adopt` use the same install and version checks, then run the
564
+ static `check --changed` gate. They do not recommend gating on report counts.
565
+ - A generated hook uses `GATEFORGE_DEV_ENGINE` when set, then the
566
+ repository-pinned CLI, `.gateforge/engine`, and `GATEFORGE_CLI`. A global
567
+ `gateforge` on `PATH` is a last-resort fallback with a warning.
568
+ - `check --staged [--require-e2e]` gates the EXACT staged bytes: the index
569
+ tree is frozen, materialized into an isolated scratch checkout, and the
570
+ regular gate runs against those bytes (never the worktree). The candidate
571
+ is re-checked after the gate — any index/HEAD drift during the run is a
572
+ typed `ENFORCEMENT_UNTRUSTED` block. Partial staging is fine; symlinks,
573
+ submodules, and unmerged index entries are typed blocks, never fallbacks.
574
+ - `check --changed --require-e2e` is the CI-side strict gate over the checked-
575
+ out candidate.
576
+ - `--strict-e2e` (config `enforcement.strictE2E`) makes waived or baselined
577
+ in-scope E2E obligations NOT proof (they block with `ENFORCEMENT_UNTRUSTED`
578
+ — no automatic debt forgiveness), and blocks unclassified changed files as
579
+ `CHANGE_UNMAPPED` until a resolved mapping covers them. Candidate edits to
580
+ policies, classification, adapters, waivers, baselines, or the mapping
581
+ sidecar cannot authorize weaker checks: gates evaluate under the trusted
582
+ policy digest, so a weakened candidate fails closed until a separate
583
+ trusted update is accepted.
584
+
585
+ **Gateforge's own files are policy inputs.** The config, the policy,
586
+ classification, behavior and runtime documents, the exclusion declarations,
587
+ the mapping sidecar, the adapter/waiver/baseline/quarantine records, the
588
+ generated gate wiring (hook script, CI job templates, `GATEFORGE.md`, the
589
+ overlay-proof README, the engine reference) and your CI/pre-commit config
590
+ *while they still carry Gateforge's managed block* are policy inputs, not
591
+ product files: a change to one of them is never an unmapped `CHANGE_UNMAPPED`
592
+ change, and a change set that contains only those files cannot change product
593
+ behavior — so it does not drag your adopted E2E obligations into a strict
594
+ re-grade, and the setup/adopt commit passes `check --changed` without
595
+ `--no-verify`. Their integrity is governed exactly as before: they are inside
596
+ the approved policy digest, so a change to them needs your pin to be
597
+ re-approved, and a mismatching pin still blocks. Deleting the gate job from
598
+ your CI config, or
599
+ the entry from `.pre-commit-config.yaml`, is not a policy input — it goes back
600
+ to blocking. Everything Gateforge does not own (your source, tests, runner
601
+ config, manifests, ignore controls, documentation you did not exclude) keeps
602
+ today's treatment, including the scope expansion that makes a policy change
603
+ re-check the whole repository.
604
+
605
+ **Receipts (the strict saved-state gate).** `check --require-e2e` accepts
606
+ only an authenticated gate receipt sealed by a COMPLETE supervised run for
607
+ the current input digest and trusted policy digest:
608
+
609
+ - no receipt (old record bundles included) → `RUN_INCOMPLETE`;
610
+ - receipt for different bytes/inputs → `EVIDENCE_STALE` (rerun for the
611
+ exact candidate);
612
+ - forged/tampered receipt → `ENFORCEMENT_UNTRUSTED`.
613
+
614
+ Receipts sealed by newer Gateforge versions add the `engine` identity
615
+ (`version`, `source`, and `unpublished`) inside the authenticated envelope.
616
+ When present, `check --require-e2e` requires the installed CLI version to
617
+ match the version that sealed the receipt. Legacy receipts without `engine`
618
+ continue to verify as before.
619
+
620
+ `test-gates --changed` seals a receipt only after planned-vs-executed
621
+ completeness, evidence grading, and a successful runner exit: zero selected
622
+ tests, skips, `.only`, retries, teardown failures, and incomplete shards all
623
+ fail the run. Identical authenticated inputs may reuse a prior receipt
624
+ (printed as `reused receipt <id>`); any changed input forces a fresh run.
625
+ Without the verifier key in the trusted environment nothing can be sealed
626
+ and `--require-e2e` blocks — it never downgrades to a weaker pass.
627
+
628
+ **Owner-declared documentation exclusions (explicit trust mode).** By default,
629
+ Gateforge hashes all inputs and all candidate files. On a terminal, the first
630
+ `gateforge init` asks for documentation-only folders to exclude. Automation can
631
+ use `gateforge init --docs-exclude docs,handbook`; a non-interactive run with no
632
+ option keeps the default. Gateforge writes the approved declaration to
633
+ `.gateforge/docs-exclusions.yml` and prints the candidate trusted-policy digest
634
+ to approve through the protected `GATEFORGE_APPROVED_POLICY_DIGEST` setting.
635
+ Gate checks refuse to use the exclusions until that external pin matches. A
636
+ later change to the exclusion declaration changes the digest; use
637
+ `--confirm-doc-exclusions` when `init` changes an existing approval.
638
+
639
+ The project states these folders do not affect the product or its tests.
640
+ Gateforge does not prove this. If application or test code reads an excluded
641
+ file, a later edit can make old evidence look valid without running the tests
642
+ again. Reports show the approved folders, pin identity, and this reduced
643
+ guarantee. Gateforge rejects exclusions that contain configured scan inputs,
644
+ source files, gate or trust metadata, manifests, lockfiles, or symlinks.
645
+ Every file must also use a supported document, data, or raster-image format.
646
+ Besides Markdown, reStructuredText, plain text, PDF, and static raster images,
647
+ an excluded folder may hold `.json`, `.yaml`, `.yml`, `.csv`, and `.html`
648
+ files. Refusal is by name first, so `package.json`, `tsconfig.json`,
649
+ `.pre-commit-config.yaml`, `.gitlab-ci.yml`, `pnpm-workspace.yaml`,
650
+ `composer.json`, any `*.config.*` file, and lockfiles stay refused inside an
651
+ excluded folder. MDX, WASM, SVG, and unknown formats fail closed. HTML is
652
+ accepted only as content of a declared folder; elsewhere it keeps full
653
+ evidence identity. This format allowlist does not prove that an allowed file
654
+ cannot affect application or test behavior; the project assertion and its
655
+ reduced guarantee still apply.
656
+
657
+ **Owner-declared Python bytecode exclusions (explicit trust mode).** By
658
+ default, Python bytecode remains part of candidate and input identity. To
659
+ exclude only exact generated cache files, run
660
+ `gateforge init --cache-exclude src/__pycache__/module.cpython-313.pyc`.
661
+ The command writes `.gateforge/cache-exclusions.yml` and prints the trusted
662
+ policy digest to approve outside the repository. A matching protected
663
+ `GATEFORGE_APPROVED_POLICY_DIGEST` pin is REQUIRED before a gate uses the
664
+ list; changing an existing list requires `--confirm-cache-exclusions`.
665
+ Only exact `.pyc` or `.pyo` files directly under `__pycache__` are allowed;
666
+ globs, symlinks, configured inputs, and other file types fail closed. Reports
667
+ show the exact files, pin status, and reduced trust guarantee. This is an
668
+ owner assertion, not proof that the excluded bytecode cannot affect runtime
669
+ behavior.
670
+
671
+ **Managed mode** (config `enforcement.mode: managed`) — the literal
672
+ no-bypass guarantee requires putting the authoritative Git metadata, commit
673
+ service, gate executable, policy authority, and signing material OUTSIDE the
674
+ agent's write/process boundary. `gateforge broker commit` ships the
675
+ MECHANISM — verify a receipt for the exact workspace bytes, then commit via
676
+ compare-and-swap ref update — not the deployment. Running the broker inside
677
+ the agent's own boundary provides NO managed guarantee.
678
+ `gateforge enforcement doctor` reports which boundary is actually active:
679
+ hook activation, runner/browser readiness, capability availability, trusted
680
+ binary/policy ownership, snapshot mode, and — in managed mode — an
681
+ agent-writable authoritative Git directory is a `fail`, never a pass.
682
+ When `.pre-commit-config.yaml` exists, the doctor runs its hooks twice in a
683
+ temporary checkout, reports files they modify, and recommends placing
684
+ `gateforge-check` before mutating hooks. Hook commands still run with the
685
+ caller’s system permissions; review them as you would any local command.
686
+
687
+ ### Owner-operated systemd deployment recipe
688
+
689
+ This is an operator deployment pattern, not an installed Gateforge service.
690
+ Use a dedicated authority account and keep the bare authoritative repository,
691
+ trusted config, CLI binary, and verifier key outside the agent's writable
692
+ process boundary. Give agents write access only to unique inbox workspaces;
693
+ allow them to request this one fixed unit, never arbitrary systemd units.
694
+ Do not pass candidate-controlled environment variables to the service.
695
+
696
+ Create an owner-only key ring and approved config as the authority account:
697
+
698
+ ```sh
699
+ sudo install -d -o gateforge-authority -g gateforge-authority -m 0700 /etc/gateforge
700
+ sudo -u gateforge-authority gateforge key create --file /etc/gateforge/verifier-keyring.json --confirm
701
+ ```
702
+
703
+ Install `/etc/systemd/system/gateforge-broker@.service` (replace the
704
+ root-owned CLI path and ref for your installation):
705
+
706
+ ```ini
707
+ [Unit]
708
+ Description=Verify and commit one Gateforge workspace
709
+
710
+ [Service]
711
+ Type=oneshot
712
+ User=gateforge-authority
713
+ Group=gateforge-authority
714
+ WorkingDirectory=/srv/gateforge/authority.git
715
+ Environment=GATEFORGE_WITNESS_VERIFIER_KEY_FILE=/etc/gateforge/verifier-keyring.json
716
+ Environment=GATEFORGE_TRUSTED_CONFIG=/etc/gateforge/approved.yml
717
+ ExecStart=/usr/local/bin/gateforge broker commit --workspace /srv/gateforge/inbox/%i --message "verified candidate" --ref refs/heads/main
718
+ ProtectSystem=strict
719
+ ProtectHome=true
720
+ PrivateTmp=true
721
+ NoNewPrivileges=true
722
+ ReadOnlyPaths=/srv/gateforge/inbox
723
+ ReadWritePaths=/srv/gateforge/authority.git
724
+ ```
725
+
726
+ Provision `/srv/gateforge/authority.git`, `/srv/gateforge/inbox/<opaque-id>`,
727
+ and `/etc/gateforge/approved.yml` with owner-controlled permissions. Restrict
728
+ service activation to the agent role via an exact polkit rule; do not grant
729
+ general `sudo systemctl` access. The broker verifies the workspace receipt,
730
+ current approved policy, raw tree bytes, and compare-and-swap target ref
731
+ before committing. A missing, stale, forged, or wrong-key receipt fails
732
+ closed. `enforcement doctor` can verify the local boundary only; the owner
733
+ must separately audit the service account, polkit rule, filesystem
734
+ permissions, and immutable engine/config deployment.
735
+
736
+ ## Contract capabilities
737
+
738
+ What the engine can grade today (single source of truth: the core capability
739
+ registry; `init --strict-e2e` preflight rejects setups that require anything
740
+ else):
741
+
742
+ | Namespace | Status |
743
+ | --- | --- |
744
+ | `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) |
745
+ | `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 |
746
+ | `http:frontend-request-observed` | UNAVAILABLE — no independent browser/test attribution channel; explicit selection remains blocking `missing` with `VERIFIER_UNSUPPORTED` |
747
+ | `crud:*` (UI-semantic) | FAIL-CLOSED — the tested suite owns the browser; use `persistence:*` |
748
+ | `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 |
749
+ | `auth:*`, `validation:*`, `task:*`, `webhook:*`, `workflow:*` | AVAILABLE (behavior-case channel) — same required-case aggregation over engine-controlled requests with independent state scopes. A repository that declares no case for the obligation stays blocking `missing`: the grader never falls back to transport evidence |
750
+
751
+
752
+ A behavior case may declare a `signatureProfile` on its `request`
753
+ action: an algorithm plus bounded `;key=value` parameters
754
+ (`header`, `timestampHeader`, `toleranceMs`, `attemptHeader`,
755
+ `attempt`, `forgery`). One parser serves both the config schema and
756
+ the witness driver, so `hmac-sha256;forgery=signature` is understood
757
+ identically at parse time and at run time and an unknown parameter is
758
+ refused rather than defaulted. The signing secret is read only from
759
+ the trusted lease; the signature always covers the exact bytes on the
760
+ wire.
761
+
762
+ Unsupported proof stays blocking. Nothing silently replaces browser proof
763
+ with HTTP status proof.
764
+ `gateforge init` includes the available transport-only contracts for consumed
765
+ HTTP endpoints in new installations. Existing policies are unchanged;
766
+ explicitly requiring `http:frontend-request-observed` still blocks. The init
767
+ scan names that unavailable channel once as not yet provable.
768
+
769
+ ### Observation scope for HTTP endpoints (opt-in policy option)
770
+
771
+ By default an `http.endpoint` owes the observation contracts
772
+ (`http:request-observed`, `http:response-status-ok`) only when a
773
+ `consumed: true` policy matches it — the static join with the frontend.
774
+ A brand-new route that no UI calls therefore owes nothing, and "you
775
+ forgot a test" stays invisible: `check` exits 0.
776
+
777
+ The pinned policies document (`.gateforge/policies.yml`, the trusted
778
+ policy) takes one additive option that widens that scope:
779
+
780
+ ```yaml
781
+ schemaVersion: 1
782
+ options:
783
+ 'http.endpoint.requireObservation': all # or 'consumed' (the default)
784
+ policies:
785
+ - id: frontend-consumed-endpoints-transport-only
786
+ when:
787
+ kind: http.endpoint
788
+ consumed: true
789
+ require:
790
+ - http:request-observed
791
+ - http:response-status-ok
792
+ ```
793
+
794
+ - Absent (or `consumed`): today's behavior, byte for byte. A document
795
+ without the `options` section generates the same obligations, the same
796
+ report and the same exit code it always did.
797
+ - `all`: EVERY discovered endpoint owes the observation contracts of a
798
+ `consumed: true` endpoint policy. An unmapped one is `missing` with the
799
+ existing `TEST_MAPPING_MISSING` cause and the existing overlay next
800
+ action. Existing routes are not re-litigated: run `gateforge adopt`
801
+ once (the sanctioned bulk-add) and the adopted baseline forgives them,
802
+ so only NEW routes block.
803
+ - The option never widens a `consumed: false` policy, a policy that does
804
+ not name the `http.endpoint` kind, or anything that is not a route; it
805
+ adds no contract, cause code or exit code.
806
+ - It lives in the pinned policy document, so an agent cannot widen or
807
+ narrow the scope by itself — that is a policy revision.
808
+ - `gateforge next` names the option on the one item it explains (an
809
+ unmapped obligation on a route the frontend never calls while the
810
+ option is `all`) and stays silent everywhere else.
811
+
812
+
813
+
814
+ ## Configuration
815
+
816
+ `.gateforge.yml` is loaded fail-closed from the working directory (the repo
817
+ root); see `@gate-forge/core` for the pinned schema. All paths are
818
+ repo-root-relative. `changed.provider: auto` (the default) picks
819
+ `github-pr` when `GITHUB_BASE_REF` is set, `gitlab-mr` when
820
+ `CI_MERGE_REQUEST_DIFF_BASE_SHA` is set, else `local-staged`
821
+ (`git diff --cached --name-only`). `clock.mode: fixed` freezes the run
822
+ instant for deterministic reports; `system` (default) freezes it at run
823
+ start.
824
+
825
+ Enforcement-relevant sections:
826
+
827
+ - `enforcement:` — `mode: standard | managed` (default `standard`),
828
+ `strictE2E: boolean` (default `false`), and optional
829
+ `receiptStage: pre-push | pre-commit | ci`. New configs choose `pre-push`;
830
+ omission preserves legacy behavior.
831
+ - `coveragePolicy:` (opt-in, fail closed) — the closed-world CRUD coverage
832
+ policy: enumerated user-facing tables (validated against the run's
833
+ resource inventory on EVERY run — an unknown table name is a config error,
834
+ a silently dropped inventory table is a violation), required operations,
835
+ and owner dispositions (`read-only-surface`, `admin-plane-unreachable`,
836
+ `not-user-facing`, `other`, with a note). With the policy enabled, an
837
+ uncovered, undispositioned required operation blocks with
838
+ `CRUD_COVERAGE_MISSING`. Recording or approving a disposition is a
839
+ trusted-policy act — the policy participates in the trusted policy
840
+ revision, so an agent edit never self-approves.
841
+ - `diagnostics.suites:` — the advisory pytest suites (see above).
842
+ - `runner:` — the test runner the supervised gate drives:
843
+ `playwright` (the default when the key is absent), `pytest`, `vitest` or
844
+ `cypress`. `check`, `next`, `tests`, `test-gates`, `doctor` and `init`
845
+ all follow it. See `guides/RUNNER-NEUTRAL-EVIDENCE.md`.
846
+
847
+ ## Plugin invocation
848
+
849
+ Every configured plugin runs over the same expanded include path list
850
+ (`project.paths.include` minus `exclude`; `.git` and `node_modules` are
851
+ never scanned):
852
+
853
+
854
+ - **subprocess** (GPP/3): `command` argv is spawned via
855
+ `@gate-forge/plugin-protocol`'s `PluginSession` — pinned handshake, one
856
+ lock-step `discover`, shutdown handshake, fail-closed on any protocol
857
+ violation. Plugins run without network.
858
+ - **in-process**: `module` is dynamically imported and its *default
859
+ export* must provide `discover(paths)` returning
860
+ `{resources, unresolved, findings}` in the pinned discovery shape.
861
+ Relative module specifiers resolve against the repo root; the result is
862
+ schema-validated and fails closed on invalid output.
863
+
864
+ The plugin's `discover` receives repo-relative file paths; in-process
865
+ plugins resolve them against the process working directory, which for a
866
+ CLI run is the repo root.
867
+
868
+ **Gitignored files are not scanned.** Untracked files Git ignores —
869
+ anything a `.gitignore` at any depth, or `.git/info/exclude`, excludes —
870
+ never enter the detector input list, so a dirty working copy (a built
871
+ `playwright-report/`, a cache tree, local output) produces exactly the
872
+ scan a clean clone of the same commit does. TRACKED files are always
873
+ scanned, even when an ignore pattern matches them: Git's own semantics.
874
+ The user's global excludes file is deliberately not consulted, so the
875
+ same repository scans identically on every machine; only repository
876
+ state decides. Outside a Git work tree (or without `git` on `PATH`)
877
+ nothing is skipped. The evidence digest still hashes configured scan
878
+ inputs even when Git ignores them, so an edit to an ignored file still
879
+ invalidates old evidence — the digest is a deliberate superset of the
880
+ scan, never a subset.
881
+
882
+ ## Endpoint plane rules (`.gateforge/planes.json`)
883
+
884
+ The same declarative plane document the packs apply to business tables
885
+ also carries endpoint-plane evidence. It is consumed by the endpoint
886
+ compiler (the pipeline stage that builds `http.endpoint` resources) with
887
+ the same strict reader, the same schema
888
+ (`{ rules: [{ match?, tables?, plane, reason }] }`), and the same
889
+ fail-closed posture.
890
+
891
+ **Endpoint plane rules are explicit human declarations keyed on the
892
+ router SOURCE FILE path — not automatic filename inference.** The config
893
+ IS the documented evidence (mirroring the classification policy's
894
+ declaration channels): a rule whose `match` glob (repo-root-relative,
895
+ posix, core classifier glob semantics) matches an endpoint's router file
896
+ asserts that endpoint's `plane` (`tenant` | `master` | `global`) with a
897
+ required non-empty `reason` as the review artifact. `tables` rules never
898
+ apply to endpoints — endpoints carry no table identity.
899
+
900
+ Evaluation per endpoint, deterministic and fail closed:
901
+
902
+ - **All matching rules agree** → the plane is applied as a plane-dimension
903
+ declaration signal (`gateforge.endpoint-compiler:config`), the same
904
+ evidence channel the classifier's inheritance pass uses, so the graph
905
+ qualifies the endpoint id as `plane.<name>`.
906
+ - **Matching rules disagree** → a blocking `PLANE_RULE_CONTRADICTION`
907
+ entry is emitted (the required `reason` of each matching rule rides the
908
+ diagnostic) and NO plane is applied — never first-match-wins.
909
+ - **No rule matches** → no evidence; the endpoint stays on the existing
910
+ channels (linked-resource inheritance, operational `global`, else
911
+ `PLANE_UNRESOLVED`).
912
+
913
+ Interaction with the other plane channels: the config plane participates
914
+ as EVIDENCE, never as a blanket override. When the plane the classifier
915
+ would derive for the endpoint (exactly one linked business resource, or
916
+ the operational `global` rule) is already derivable from the detector
917
+ contributions and CONTRADICTS the config plane, the compiler emits both
918
+ assertions so the classifier blocks with `PLANE_CONTRADICTION`; when they
919
+ agree, one plane remains and the endpoint resolves.
920
+
921
+ Absence of `.gateforge/planes.json` is normal and byte-identical to not
922
+ having this channel; a malformed document (bad JSON, unknown keys, a rule
923
+ without `plane`/`reason`, an absolute or `..`-escaping `match`) fails the
924
+ run closed at startup (exit 2).
925
+
926
+ ### Review an endpoint plane
927
+
928
+ When `next` cannot resolve a route's plane, it asks which data boundary owns
929
+ the route and prints one command for each supported choice. Run only the
930
+ choice the owner has reviewed. `classify plane` takes one repo-relative
931
+ file path, FOLDER, or glob, one plane, and a non-empty reason:
932
+
933
+ ```sh
934
+ # one router file (as before)
935
+ gateforge classify plane 'src/routes.js' tenant \
936
+ --reason 'Owner review confirms tenant-owned records for this route.'
937
+
938
+ # a whole router folder — written as the rule 'src/routes/**'
939
+ gateforge classify plane 'backend/api/v1' tenant \
940
+ --reason 'Every router in this folder serves tenant-owned records.'
941
+
942
+ # your own glob, matched verbatim
943
+ gateforge classify plane 'backend/api/v1/*_admin.py' master \
944
+ --reason 'These admin routers serve operator-managed records.'
945
+ ```
946
+
947
+ The default is a dry run: it prints the exact config diff and does not write.
948
+ Add `--confirm` to append the rule to an **existing**
949
+ `.gateforge/planes.json`. The command never creates another trust file,
950
+ replaces a rule, or writes an internality declaration; a source outside the
951
+ repository (absolute, drive-qualified, backslashed, or `..`-escaping) is
952
+ refused, and a new rule that would overlap an existing one with a different
953
+ plane is refused too — conflicting rules must be resolved by editing the
954
+ owner-reviewed config. This file is a classification input, so changing it
955
+ changes the trusted-policy digest; an approved policy pin must be
956
+ re-approved before strict gates run.
957
+
958
+ The alternative in `next` is owner-only: use the existing
959
+ `.gateforge/classification-policy.yml` `internalRules` declaration only when
960
+ the route is genuinely internal. Internal rules still require the existing
961
+ internality certificate; they are not overrides.
962
+
963
+ ## Endpoint capability rules (`.gateforge/endpoints.json`)
964
+
965
+ Capability derivation uses detector FACTS only (method, canonical path,
966
+ handler simple name, schema symbols, resource linkage). A handler whose
967
+ logic lives behind a service call has no positive evidence and fail-closes
968
+ with `ENDPOINT_SEMANTICS_UNRESOLVED` — the compiler cannot see through
969
+ service-layer delegation, by design, and will not guess. This document is
970
+ the escape hatch that the blocking message names: an explicit, human
971
+ assertion of what an endpoint DOES.
972
+
973
+ A rule carries at least one selector (AND semantics when several) plus a
974
+ capability from the closed compiler vocabulary and a required non-empty
975
+ `reason` (the review artifact):
976
+
977
+ - `match` — repo-root-relative glob on the ROUTER SOURCE FILE path;
978
+ - `handlers` — globs on the handler SIMPLE name (case-sensitive; a route
979
+ with no handler symbol never matches);
980
+ - `paths` — globs on the canonical path (`/analytics/**`; must start
981
+ with `/`);
982
+ - `method` — optional exact verb (`GET`…`DELETE`, never `ANY`).
983
+
984
+ ```json
985
+ {
986
+ "rules": [
987
+ {
988
+ "handlers": ["get_analytics_*"],
989
+ "capability": "crud-read",
990
+ "reason": "delegates to analytics_service; declared by the service owner"
991
+ },
992
+ {
993
+ "match": "backend/api/v1/accounts.py",
994
+ "method": "DELETE",
995
+ "capability": "crud-archive",
996
+ "reason": "sets archived_at via the service; soft delete by design"
997
+ }
998
+ ]
999
+ }
1000
+ ```
1001
+
1002
+ Resource linkage accepts the path-derived name or its singular form with
1003
+ one trailing `s` removed: `/items/{id}` can link to model `item`.
1004
+ Exactly one discovered model must match, and a schema symbol or whole
1005
+ handler-name word must corroborate it. Name coincidence alone never links;
1006
+ if both `items` and `item` exist, the compiler blocks the ambiguity rather
1007
+ than preferring one.
1008
+
1009
+ Evaluation per endpoint identity, deterministic and fail closed:
1010
+
1011
+ - **All matching rules agree** → the capability is declared (composed
1012
+ with detected ones; overlapping agreeing rules are one declaration).
1013
+ A declared `crud-delete`/`crud-archive` on a DELETE endpoint resolves
1014
+ the archive-vs-hard question the linked model could not prove.
1015
+ The declaration also supplies that evidence to the linked model's
1016
+ classifier. Conflicting model/route semantics still block; an archive
1017
+ declaration still needs the model's archive-state evidence.
1018
+ - **Matching rules disagree** → a blocking
1019
+ `ENDPOINT_CAPABILITY_CONTRADICTION` entry names every matching rule,
1020
+ its capability, and its reason; NOTHING is applied — never
1021
+ first-rule-wins.
1022
+ - **No rule matches** → the endpoint stays on detector-fact evidence
1023
+ only (and blocks if that is nothing).
1024
+
1025
+ The vocabulary is the compiler's own: `health-operations`,
1026
+ `auth-session`, `webhook-callback`, `workflow-command`, `task-async`,
1027
+ `search-query`, `validation-preview`, `file-transfer`, `ai-automation`,
1028
+ `realtime`, `crud-create`, `crud-read`, `crud-update`, `crud-delete`,
1029
+ `crud-archive`. Absence of the file is normal and byte-identical to not
1030
+ having the channel; a malformed document fails the run closed at startup
1031
+ (exit 2).
1032
+
1033
+ ### Answering `ENDPOINT_SEMANTICS_UNRESOLVED`
1034
+
1035
+ When `gateforge next` prints that code, the run has found an endpoint and
1036
+ cannot tell what it DOES; the remedy is an owner-authored rule, not
1037
+ another read-only command. The printed block carries the whole answer for
1038
+ THAT endpoint: its own method and canonical path as the selectors, the two
1039
+ owner-chosen fields (`capability`, `reason`) marked in the snippet, and the
1040
+ allowed values. Answer it by replacing the two marked fields and writing
1041
+ the file (append the rule to `rules` when the file already exists), then
1042
+ prove it applied with the printed `gateforge explain <endpoint-id>` — its
1043
+ `capabilities:` line names the capability and its trace says
1044
+ `endpoints.json`.
1045
+
1046
+ The shortest useful file — one exact endpoint, no glob at all — is:
1047
+
1048
+ ```json
1049
+ {
1050
+ "rules": [
1051
+ {
1052
+ "method": "DELETE",
1053
+ "paths": ["/items/{item_id}"],
1054
+ "capability": "crud-archive",
1055
+ "reason": "The handler sets archived_at; the row is never removed."
1056
+ }
1057
+ ]
1058
+ }
1059
+ ```
1060
+
1061
+ `paths` patterns are globs on the canonical path (`*` within a segment,
1062
+ `**` across segments, `?` one character); a path with no wildcard is an
1063
+ exact selector, which is what you want for one route. On a `DELETE`, the
1064
+ capability is the archive-vs-hard answer (`crud-archive` /
1065
+ `crud-delete`) and nothing else resolves that block; on any other verb it
1066
+ is the closed vocabulary above. A rule left with a placeholder capability
1067
+ fails the run closed at startup (exit 2) with the allowed values named.
1068
+
1069
+ ### Answering `ENDPOINT_RESOURCE_CANDIDATE_UNMATCHED`
1070
+
1071
+ This code says one thing: the route reads a single entity, and the name
1072
+ its path carries is not a name Gateforge found among your resources.
1073
+ `GET /api/v1/reports/logs/{}` served by a table called `report_logs` used
1074
+ to produce nothing at all, which read like a route that does not
1075
+ exist. The entry names the route, the name it derived, and up to three
1076
+ discovered resources whose last `_`-segment could be the same thing.
1077
+
1078
+ Those names are CANDIDATES, never links. Gateforge links an endpoint to a
1079
+ resource only on an exact name plus a corroborating fact (a response or
1080
+ request schema named after it, or a handler named after it), and it does
1081
+ not do that here. If one of the candidates is right, give the route the
1082
+ evidence: name the response model or the handler after the resource, or
1083
+ declare the missing mapping. If none is right, the route genuinely serves
1084
+ something the resource graph does not model. A route that links, a route
1085
+ with nothing near it, and any collection route are unaffected.
1086
+
1087
+ Whether the entry BLOCKS is the owner's call, in `.gateforge.yml`:
1088
+
1089
+ ```yaml
1090
+ endpoints:
1091
+ unmatchedRoutes: warn # the default; `block` gates commits on them
1092
+ ```
1093
+
1094
+ Absent the key means `warn`: the entries are reported under this same code
1095
+ in the advisory channel, `check --changed` does not block on them, and
1096
+ `check` and `next` print a banner at the top with the count, the first
1097
+ three examples and the key above — a repository that upgraded must not
1098
+ start failing commits over a finding it never chose. `warn` says the same
1099
+ thing with the "you have not chosen" sentence gone; `block` makes the entry
1100
+ a blocking entry like any other. `gateforge init` asks once in a terminal
1101
+ and takes `--unmatched-routes block|warn`.
1102
+
1103
+ ## Proposing planes at init (`gateforge init --planes`)
1104
+
1105
+ `gateforge init --planes` runs discovery over the repo's own include and
1106
+ exclude configuration and PROPOSES `.gateforge/planes.json` from the
1107
+ directories the discovered tables live in: one non-overlapping `match`
1108
+ glob per model tree, `master` for trees whose path names a control-plane
1109
+ segment (`admin`, `master`, `control`, `root`, `operator`), `tenant`
1110
+ otherwise, and a reason on every rule naming the directory it was
1111
+ inferred from. The keyword mapping IS a heuristic — that is why the file
1112
+ is a review artifact: it is written only after explicit consent (flag,
1113
+ or the TTY prompt), only when absent, and must be reviewed before the
1114
+ next run reads it.
1115
+ Tables under test directories are excluded from the proposal (fixtures are
1116
+ not business surface) and never enter the resource graph at all, so a
1117
+ fixture that re-declares a real table's name cannot collide with it. The
1118
+ same rule (a `test/` or `tests/` directory segment) is generic — it names
1119
+ no repository. Non-interactive runs without `--planes` propose nothing and
1120
+ print the tip.
1121
+
1122
+ ### Route folders get their own question
1123
+
1124
+ Model folders alone leave every discovered endpoint `PLANE_UNRESOLVED`, so
1125
+ `--planes` also asks ONE question per ROUTE folder — the directory of the
1126
+ file that declares the handlers, e.g. `backend/api/v1` — and writes one
1127
+ `match: 'backend/api/v1/**'` rule per answer. A route's plane is never
1128
+ inferred from the model it links to (an `accounts` route can serve master
1129
+ data): the question may SHOW that model's plane as a hint, and only when
1130
+ every model behind the folder's routes has the same resolved plane —
1131
+ otherwise no hint is shown and the owner answers from the routes.
1132
+
1133
+ Nothing is applied without an answer. In a non-interactive run init prints
1134
+ each folder, its unresolved route count, the hint (labelled as a hint) and
1135
+ the exact command to run later:
1136
+
1137
+ ```sh
1138
+ gateforge classify plane 'backend/api/v1' tenant \
1139
+ --reason 'These routers serve tenant-owned records.'
1140
+ ```
1141
+
1142
+ ## test-gates protocol (G6 surface)
1143
+
1144
+ `gateforge test-gates` writes a run state directory (default
1145
+ `.gateforge/test-gates/`, `--out` overrides):
1146
+
1147
+ | File | Content |
1148
+ | --- | --- |
1149
+ | `manifest.json` | Pin #4 RunManifest (runId, injected-clock startedAt, gitSha, provider, plugin registrations, plus the `test-gates`-minted `invocationId` and tested `inputDigest`). At shutdown the witness appends `recordIds` + the v2 `attestation` envelope (never a legacy `recordIdsMac`). |
1150
+ | `obligations.json` | Every obligation the suite must cover, with pin #2 fingerprint and resource source/location. |
1151
+ | `env.json` | `GATEFORGE_RUN_ID`, `GATEFORGE_RUN_TOKEN`, `GATEFORGE_STATE_DIR`, `GATEFORGE_OBLIGATIONS`, `GATEFORGE_WITNESS_URL`. |
1152
+ | `claims.json` / `records.json` | Reporter output consumed by the verifier (written by the suite). |
1153
+ | `execution-result.json` / `receipt.json` / `diagnostics.json` | Supervised `--changed` mode: the sealed execution result (planned vs executed instances, outcomes, native claim inventory, runner exit, completeness), the authenticated gate receipt issued after complete success, and the separate advisory diagnostic report. |
1154
+ | `report.json` | Canonical json-format run report after evaluation. |
1155
+ | `last-full-run.json` | Advisory test count and measured duration for the latest completed full run; used only to explain commit cost, never as gate evidence. |
1156
+
1157
+
1158
+ The legacy suite command (`--suite`) runs with those env vars; its reporter
1159
+ extracts claims from `{type: 'gateforge', description: '<obligation id>'}`
1160
+ annotations and posts evidence through the witness service (pin #7, header
1161
+ `x-gateforge-run: <token>`; `GATEFORGE_WITNESS_URL` is set when a witness
1162
+ service URL is provided via `--witness-url`). `gateforge check` reads
1163
+ run-state evidence but takes native bindings only from `claimInventory`
1164
+ in an execution result authenticated by a receipt for the current inputs;
1165
+ it combines those with the current tracked `test-map.yml`. Raw
1166
+ `claims.json` cannot add current declarations. Receipts created before
1167
+ `claimInventory` existed remain valid, but supply no native bindings.
1168
+ Records whose provenance does not verify never satisfy (GF-23). The
1169
+ legacy escape hatch can never redefine the strict gate's expected cases
1170
+ or turn an arbitrary exit-zero command into E2E proof — the hook and CI
1171
+ run `check --staged/--changed --require-e2e`, which accept only supervised
1172
+ receipts.
1173
+
1174
+ Before supervised execution, Gateforge compares Playwright's scrubbed
1175
+ inventory with a second `--list` using the safe run variables supplied to
1176
+ the runner. A difference stops the run before tests start and names each
1177
+ project, file, and title present in only one inventory. Static discovery
1178
+ also warns when `process.env.GATEFORGE_*` controls test registration.
1179
+
1180
+ ### Provenance trust model (GF-23, audited 2026-08-31, three rounds)
1181
+
1182
+ `records.json` and `manifest.json` live in the suite-writable state
1183
+ directory, so NEITHER proves anything on its own: a hostile suite can
1184
+ fabricate records (the id hash `recordIdOf` is public) and can write any id
1185
+ list into the manifest. Two layers close this.
1186
+
1187
+ **Layer 1 — trust follows origin.** A record's `origin` is part of its
1188
+ hashed identity:
1189
+
1190
+ - `suite-submitted` (`ui.action`, `ui.visible-result` POSTed by the
1191
+ suite): the witness RECEIVED the assertion but cannot verify it
1192
+ happened — the suite owns the browser and holds the run token. These
1193
+ records are stamped `trust: 'claimed'` at issuance and only ANCHOR a
1194
+ claim (entity + operation).
1195
+ - `engine-observed` (`persistence.entity`, stamped by the witness from
1196
+ its own adapter read): the only `trust: 'witnessed'` origin. This is
1197
+ where `satisfied` is earned — the engine requires a witnessed
1198
+ persistence record for the claimed entity, so fabricated outcomes can
1199
+ never satisfy.
1200
+
1201
+ **Supervised session binding (Phase 1).** The trusted reporter opens ONE
1202
+ witness session per started test (`runId`, `sessionId`, `testId`,
1203
+ `worker`), and the evidence fixture's five primitives (`ui`, `visible`,
1204
+ `persistence`, `http`, `finalize`) submit only under that OPEN session:
1205
+ the witness rejects submissions without a session and forces each record's
1206
+ testId onto the session's supervisor-registered value; sealing rejects all
1207
+ late submissions. Every UI action runs inside a witness-recorded
1208
+ observation interval (supervisor-issued session clock), so proxy exchanges
1209
+ observed outside the action's interval — direct setup calls, stray
1210
+ navigation — are never credited as browser evidence. For a mutation whose
1211
+ journey collects input in the UI, the `ui.action` record's `fields` are
1212
+ the declared input, and the independent engine-observed persistence read
1213
+ must echo those values EXACTLY on the same entity identity: a mismatched
1214
+ echo fails the obligation with `EVIDENCE_VALUE_MISMATCH` even when the
1215
+ status was 2xx. Primitive receipts are frozen and branded — hand-rolled
1216
+ forgeries fail closed (GF-22).
1217
+
1218
+ **UI-semantic `crud:*` contracts fail closed (audit round 5).** The suite
1219
+ still owns the browser, so a claimed UI action cannot be verified at the
1220
+ DOM level; the namespace advertises no gradable contract. The gradable
1221
+ surface is the lifecycle-gated `persistence:*` namespace, graded on the
1222
+ witness's OWN engine-side observation
1223
+ (`{resourceId, entityId, found, fields, before}`) with expectations that
1224
+ NEVER come from the tested suite:
1225
+
1226
+ - `persistence:create`: an engine-side id-set PRE-OBSERVATION (`POST
1227
+ /witness/pre-observation`, backed by the adapter's optional `list`)
1228
+ shows the entity absent before the action; the post-read shows it
1229
+ present.
1230
+ - `persistence:update`: an engine-side entity pre-observation exists,
1231
+ the engine observed an actual before/after field delta, AND the delta
1232
+ touches at least one classification-declared `updateableFields` entry
1233
+ (audit round 6) — bookkeeping drift such as `updated_at` alone never
1234
+ satisfies, and a resource whose classification omits
1235
+ `updateableFields` fails closed for update obligations.
1236
+ - `persistence:read`: the entity is present in the engine-observed state.
1237
+ - `persistence:delete`: a hard delete observes the entity ABSENT; an
1238
+ archive observes it present and matching the classification's
1239
+ owner-declared `archiveFields` (e.g. `{status: archived}`) — the suite
1240
+ cannot bless an unarchived entity by declaring its current state as
1241
+ the expected result.
1242
+
1243
+ An adapter may declare an optional literal `fields: [...]` projection.
1244
+ Anchored persistence fails before consuming its pre-observation when the
1245
+ action changes a field outside that projection. `check` also reports
1246
+ model updateable fields missing from a statically readable projection.
1247
+ Adapters without this metadata keep their existing behavior.
1248
+
1249
+ Presence alone, contradicted observations, missing pre-observations, or
1250
+ absent deltas grade `invalid` — even when every provenance check passes.
1251
+
1252
+
1253
+ When the complete endpoint inventory contains no update-capable route linked
1254
+ to the resource, the failure also says that no observed UI request writes the
1255
+ fields and the feature may be unreachable from the UI. This is diagnostic only;
1256
+ it does not change the verdict.
1257
+
1258
+ **Layer 2 — versioned attestation binding evidence to tested inputs.** A witnessed record is authorized only by ONE validated
1259
+ v2 envelope that simultaneously matches its run id, the expected input
1260
+ digest, the required invocation identity, and its record id:
1261
+
1262
+ - the durable manifest `attestation` (`attestationVersion: 2` with
1263
+ `runId`, `invocationId`, `inputDigest`, sorted unique `recordIds`, and
1264
+ `mac` — HMAC-SHA256 over the domain-tagged body
1265
+ `gateforge.ledger.v2`), written by the witness at shutdown from its
1266
+ FROZEN bound context plus EXACTLY its own ledger (pre-seeded forged
1267
+ ids are discarded, never signed), or
1268
+ - the live `GET /ledger-attestation` response: the SAME signed object,
1269
+ fetched (and MAC-verified) by `test-gates` from a still-running wired
1270
+ witness and persisted into the manifest as the durable fallback
1271
+ before the witness stops (401 to the run token alone).
1272
+
1273
+ The `inputDigest` is a deterministic snapshot of everything the
1274
+ pipeline examines (all Git-tracked files, nonignored untracked files,
1275
+ configured scan inputs even when ignored, `.gateforge.yml`,
1276
+ policies/classification/pack configs, adapters, local plugin modules,
1277
+ manifests/lockfiles, effective obligations/classifications/routes —
1278
+ `packages/cli/src/input-snapshot.ts`). A deleted file, an untracked
1279
+ file, a policy edit, or a lockfile change all move the digest, so old
1280
+ evidence blocks after any source/configuration change. The
1281
+ `invocationId` is fresh per `test-gates` run, so a restored old bundle
1282
+ cannot satisfy a new invocation. `check` (no suite) reuses a completed
1283
+ signed run only for byte-identical inputs — it never equates its own
1284
+ fresh manifest UUID with the evidence run UUID.
1285
+
1286
+ The witness never signs what a suite-writable file says: `test-gates`
1287
+ binds the context with authenticated `POST /run-context` (run token
1288
+ AND verifier key) BEFORE the suite starts, and the witness freezes it
1289
+ in memory. Binding is allowed only before any observation or issuance;
1290
+ a used witness answers 409, an identical rebind is idempotent, any
1291
+ change is 409, and an unbound witness issues no attestation. A proxy
1292
+ exchange in flight at bind time refuses the bind, and observations
1293
+ that completed before binding are never consumable under the new
1294
+ context.
1295
+
1296
+ The legacy v1 `recordIdsMac` (HMAC over `{runId, recordIds}` with no
1297
+ digest binding) NEVER authorizes evidence — even when it verifies.
1298
+ Invalid durable envelopes contribute nothing; live and durable
1299
+ contexts are validated independently and never merged; mismatches
1300
+ surface as explicit `evidence-context` blockers (missing vs malformed
1301
+ vs forged stay distinguished) that waivers cannot hide.
1302
+
1303
+ The key comes from one trusted source: the protected
1304
+ `GATEFORGE_WITNESS_VERIFIER_KEY` environment variable, an external
1305
+ owner-only key ring named by `GATEFORGE_WITNESS_VERIFIER_KEY_FILE`, or the
1306
+ default `$XDG_CONFIG_HOME/gateforge/verifier-keyring.json` (otherwise
1307
+ `~/.config/gateforge/verifier-keyring.json`) when present. Do not set both
1308
+ explicit sources. The file must be a regular file owned by the current
1309
+ user, with mode `0600` or stricter, and it must not be a symlink. Store
1310
+ it outside the candidate repository, Git directory, run state, `--out`
1311
+ directory, workspace, and receipt-artifact directory. Gateforge refuses
1312
+ unsafe paths and permissions. File mode is not supported on Windows;
1313
+ use the protected environment source there.
1314
+ Create and rotate keys only after an owner review:
1315
+
1316
+ If you already use an environment key, keep it in the protected environment
1317
+ while you import it. Do not place key material in shell history or argv.
1318
+
1319
+ ```sh
1320
+ gateforge key create --confirm
1321
+ gateforge key import-env --confirm
1322
+ unset GATEFORGE_WITNESS_VERIFIER_KEY
1323
+ gateforge key rotate --confirm
1324
+ gateforge key retire --key-id key-old-id --confirm
1325
+ ```
1326
+
1327
+ Create the parent directory first. `key import-env` retains an existing
1328
+ environment key under its stable id before switching to the file source.
1329
+ Key commands print only a non-secret
1330
+ key id. Rotation keeps old keys so their receipts still verify. Retire an
1331
+ old key only when its receipts no longer need to verify. Gateforge stores
1332
+ the key id, not the secret, in new receipts. A receipt for a removed id
1333
+ fails with `KEY_UNKNOWN`. The key ring file contains raw signing keys, so
1334
+ protect its backups with the same care as the original.
1335
+
1336
+ `test-gates` strips both key-source variables from the suite child's
1337
+ environment. The supervised browser runner and candidate runtime also
1338
+ refuse both sources, and Gateforge does not write either value or file
1339
+ path into run state. The trusted witness process receives the active key
1340
+ to authenticate records. A suite-owned Playwright global setup therefore
1341
+ cannot bootstrap trusted issuance by inheriting the key — it fails closed
1342
+ unless an externally wired trusted witness is provided. Residuals (not
1343
+ eliminable by env hygiene alone): a same-uid process can read environ when yama
1344
+ `ptrace_scope=0`, and env vars never isolate hostile same-user OS
1345
+ processes — for strong isolation run the suite as a distinct user or
1346
+ container. File-change capture is snapshot-based, not an OS sandbox:
1347
+ it guards changes visible at capture points, not a malicious process
1348
+ that changes and restores files between snapshots.
1349
+
1350
+ ### The operator's fixture/actor provider
1351
+
1352
+ A declared behavior case names a `fixture` recipe and an `actor`, and the
1353
+ witness — not the test suite — must materialize them before it drives the
1354
+ case. `GATEFORGE_FIXTURE_PROVIDER` names the module that does that. The
1355
+ CLI-spawned witness loads it at startup; a repository that declares no
1356
+ behavior cases is unaffected.
1357
+
1358
+ The module's default export is `{ prepare(input), release(leaseId),
1359
+ resolveCredential(credentialRef) }`:
1360
+
1361
+ - `prepare` provisions the case's subjects and actor identities and returns
1362
+ `{ leaseId, namespace, subjects, actors }`. Subjects are server-issued
1363
+ identities; a lease namespace keeps concurrent cases isolated.
1364
+ - `release` drops what that lease provisioned.
1365
+ - `resolveCredential` turns a lease `credentialRef` into request material.
1366
+ It runs in the witness process, so a secret stays there; a declared
1367
+ `credentialVariant: valid` that cannot resolve fails closed rather than
1368
+ degrading.
1369
+
1370
+ The provider is ENGINE-SIDE code and is the only caller of its own
1371
+ provisioning HTTP calls — the suite never imports it, and nothing it
1372
+ returns can mint evidence, only supply the subjects a case drives. Because
1373
+ of that, a repository should exclude the provider from its product scan
1374
+ scope (`.gateforge.yml` `project.paths.exclude`, matching
1375
+ `classification-policy.yml` `scanRoots`): its calls are fixture
1376
+ provisioning, not application call sites, and scanning them reports the
1377
+ engine's own traffic as unresolved frontend targets. See
1378
+ `example/behavior/fixtures/fixture-provider.mjs` for a working provider.
1379
+
1380
+ Fail closed: without the key, or when no envelope validates for the
1381
+ expected context, every witnessed record demotes to claimed-tier
1382
+ (blocking, never satisfied).
1383
+
1384
+ ### Evidence migration (v1 → v2, no auto-migration)
1385
+
1386
+ - Existing evidence bundles need a FRESH run: there is no command
1387
+ that signs old records into the new format without observations, and
1388
+ none will be added (signing old records would certify untested code).
1389
+ - Gate receipts (ADR 0005 D3) are a separate versioned, domain-separated
1390
+ envelope — never a repurposed v2 attestation, and never a mutable
1391
+ `passed` flag on a claim. `check --require-e2e` rejects old record
1392
+ bundles that lack the required complete-run receipt.
1393
+ - Policies and waivers keep their explicit semantics: snapshot binding
1394
+ never rewrites their IDs to evade blockers — and in strict E2E mode an
1395
+ in-scope waived/baselined E2E obligation is not proof at all
1396
+ (`ENFORCEMENT_UNTRUSTED`).
1397
+ - External witness setup: start `gateforge-witness` (or `startWitness`)
1398
+ with the run id/token from a TRUSTED parent env carrying
1399
+ `GATEFORGE_WITNESS_VERIFIER_KEY`, pass `--witness-url`/`--run-token`
1400
+ to `test-gates`, and start a FRESH witness per invocation (a witness
1401
+ used by an older invocation rejects binding with 409).
1402
+ - Non-Git checkouts keep discovery but fail evidence authorization
1403
+ with a `snapshot-unavailable` diagnostic; submodules, escaping
1404
+ symlinks, and `--out` overlapping source fail closed with explicit
1405
+ diagnostics.
1406
+
1407
+ ## Limitations
1408
+
1409
+ - Staged candidates containing symlinks or submodules (and unmerged index
1410
+ entries) are typed blocks in `check --staged` and `broker commit` —
1411
+ explicit, never fallbacks; support is not implemented.
1412
+ - A Playwright config with NO named project: `tests discover` prints an
1413
+ error line naming the config and the fix
1414
+ (`projects: [{ name: 'chromium' }]`) and still writes the catalog, and
1415
+ `enforcement doctor` fails the `playwright-projects` row — `test-gates`
1416
+ needs a named project.
1417
+ - Gateforge reads the FIRST of `playwright.config.{ts,mts,cts,js,mjs,cjs}`
1418
+ at the repository root; a suffixed config such as
1419
+ `playwright.config.e2e.js` is not read — rename it to
1420
+ `playwright.config.js` if it is the suite to prove.
1421
+ - Run-state hygiene is enforced, not forgiven: a committed run-state
1422
+ directory (it overlaps source inputs) or config include globs that omit
1423
+ the spec directories produce fail-closed diagnostics — gitignore
1424
+ `.gateforge/test-gates/` and include the spec globs.
1425
+ - Consumer-worktree migration (writing `.gateforge` configuration,
1426
+ `coveragePolicy`, or `test-map.yml` into the inventoried ERP consumer
1427
+ worktree) and the server-side GitLab enforcement settings are pending
1428
+ owner actions — the complete template and settings list ship from
1429
+ `init --blocking`, but a local simulation does not complete a server
1430
+ rollout (`docs/plans/immediate/20260913_consumer_migration_record.md`).
1431
+
1432
+ ## Pick a goal, not a wall of flags
1433
+
1434
+ `gateforge init` asks ONE question — what should Gateforge do for you — and
1435
+ maps the answer to settings:
1436
+
1437
+ | Goal | Meaning | Writes |
1438
+ | --- | --- | --- |
1439
+ | `light` | show me code nothing has proven yet, block nothing | `mode: warn` |
1440
+ | `normal` | block a commit that adds untested endpoints or models (about a second) | `mode: changed`, pre-commit hook, CI job |
1441
+ | `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 |
1442
+
1443
+ ```sh
1444
+ gateforge init --explain-presets # print this table
1445
+ gateforge init --preset normal # or: light, or strict
1446
+ ```
1447
+
1448
+ In a terminal, `gateforge init` asks the goal question instead. With no
1449
+ terminal and no `--preset` (an AI agent or CI), it writes `light` only and
1450
+ prints that a human must choose: Gateforge never guesses `normal` or `strict`
1451
+ for someone who is not there. Existing flags (`--blocking`, `--strict-e2e`,
1452
+ `--pre-commit`, `--witnessed`, `--mode`) keep working exactly as before and
1453
+ win over a preset. Re-running `init` never rewrites an existing
1454
+ `.gateforge.yml`; to change the goal later, edit the `mode:` key.
1455
+
1456
+ The core flow:
1457
+
1458
+ ```text
1459
+ Source change
1460
+ -> Detector recognizes a resource
1461
+ -> Classifier establishes resource properties
1462
+ -> Policy produces test obligations
1463
+ -> Existing tests are inventoried, suggested, and declared against
1464
+ obligations (`gateforge tests discover|suggest|mark`); a new test is
1465
+ the last step for a confirmed behavior gap, never the default
1466
+ -> `gateforge test-gates --changed` supervises a complete run of the
1467
+ selected existing suite and seals an authenticated gate receipt
1468
+ -> `gateforge check --require-e2e` accepts only a valid, non-stale
1469
+ receipt for the exact candidate bytes
1470
+ -> The pre-commit hook, the commit broker, and the CI gate block
1471
+ everything else
1472
+ ```
1473
+
1474
+ CRUD coverage is the first proof case, not the final architecture. The broader
1475
+ product is a user-extensible test-policy compiler: creating or modifying code
1476
+ artifacts automatically creates auditable testing responsibilities.
1477
+
1478
+ ## Agent loop
1479
+
1480
+ Blocked agents run `gateforge next` (or `gateforge next --json`): exactly
1481
+ one blocking next action (`next`/`cause`/`why`/`do`), never a dump. Do the
1482
+ single `do:` line and stop. New proof tests go in `tests/e2e/gateforge/`
1483
+ (overlay, engine-driven fixture — wizard creates via surface v2 steps);
1484
+ existing suite-driven browser tests prove persistence via the Observe
1485
+ channel once mapped `--kind observed-e2e`. Never rewrite existing
1486
+ `tests/e2e/**` journeys, never `tests mark` as proof, never edit policies
1487
+ or waivers to self-approve. `GATEFORGE.md` (written by `gateforge init`)
1488
+ carries the full loop contract.
1489
+
1490
+ ## Fix a failing test without a full run
1491
+
1492
+ Fixing one failing test changes the candidate, so the run that found it no
1493
+ longer describes it. When only test code changed, you can re-run just the
1494
+ affected tests and carry the rest, with `enforcement.reseal: true` in
1495
+ `.gateforge.yml` (off by default in every mode, on in any mode including
1496
+ `strict` when you set it):
1497
+
1498
+ ```sh
1499
+ gateforge test-gates --changed --scope changed
1500
+ # only test files changed: re-ran 1 test(s), kept 562 from the previous receipt
1501
+ ```
1502
+
1503
+ Gateforge diffs the two sealed trees itself, classifies every changed path
1504
+ from the runner's catalog and the import graph (test files and test
1505
+ helpers only; importers of a changed file re-run too, and a dynamic
1506
+ import with a literal specifier is an ordinary edge), and otherwise falls
1507
+ back to the plain changed-scope run with one reason line — app code, a
1508
+ deleted file, a setup-stage test, a computed or unresolvable import.
1509
+ A whole-suite run that
1510
+ failed a test seals no receipt, so it leaves a MAC'd run record instead
1511
+ and the same command re-seals from it. A re-seal is itself a whole-suite
1512
+ proof, so **consecutive re-seals chain**: fix one test, commit, run; fix
1513
+ the next, commit, run. Each re-seal's parent is the previous re-seal, the
1514
+ chain retains every hop's outcomes and each contributing run's witnessed
1515
+ evidence, and a test no hop re-ran keeps its original proof. The parent is
1516
+ the previous run **in `.gateforge/test-gates/`** — no CI variable is
1517
+ involved (`CI_MERGE_REQUEST_DIFF_BASE_SHA` names a merge base, never the
1518
+ commit the previous pipeline tested, and is ignored), so a CI run must
1519
+ **persist the state directory between pipelines**, cached by branch; with
1520
+ a cold cache there is no parent and the run is the ordinary run. The chain
1521
+ is bounded at five consecutive re-seals — the sixth prints
1522
+ `test-gates: the run state already retains 5 consecutive re-seals, the bound this path may chain to → changed-scope run`
1523
+ — and `check --require-e2e` and `broker commit` recompute the whole chain
1524
+ with their own key before accepting it. See
1525
+ [`Fix one test without a full run`](TEST-ENVIRONMENT.md#fix-one-test-without-a-full-run)
1526
+ for the rules, the exact reason lines, and the residual risk.
1527
+
1528
+ If your run writes into the workspace — a witnessed login stage saving
1529
+ its storage state, a runner cache — those gitignored bytes are part of
1530
+ every sealed tree, so the re-seal refuses on them every time. Declare
1531
+ them with `enforcement.resealRuntimeFiles` (repo-relative globs, off by
1532
+ default):
1533
+
1534
+ ```yaml
1535
+ enforcement:
1536
+ reseal: true
1537
+ resealRuntimeFiles:
1538
+ - 'e2e/.auth/*.json'
1539
+ ```
1540
+
1541
+ A matching path is disregarded only while **neither sealed commit tracks
1542
+ it**; a committed one is source, and a declaration can never hide a
1543
+ source change. The run prints
1544
+ `test-gates: re-seal disregards 2 declared runtime file(s): …`, the
1545
+ receipt records the list in `resealDisregarded`, and CI recomputes that
1546
+ exact list or rejects the receipt.
1547
+
1548
+ ## What the gate catches that ordinary tests can miss
1549
+
1550
+ Mocks and passing clicks can miss bugs in the real path:
1551
+
1552
+ - A UI request succeeded, but the server response dropped a persisted source fingerprint. The mocked test checked the request only.
1553
+ - An update control changed only a synchronization timestamp, not the user-editable setting the test claimed to update.
1554
+ - Two journeys reused a shared tenant fixture, hiding a missing tenant boundary that appeared when the real application handled separate records.
1555
+
1556
+ Gateforge connects existing journeys to obligations, then checks witness evidence from the configured run. It complements the test suite; it does not replace it.
1557
+
1558
+ ## Running in CI
1559
+
1560
+ A long witnessed run used to be a blank CI screen. The runner log does
1561
+ carry the app env, the request bodies and the seed credentials, so the
1562
+ job redirects it to a private file — and then nothing distinguishes a
1563
+ healthy 45-minute run from a hung one.
1564
+
1565
+ `gateforge test-gates` now prints a progress stream of its own:
1566
+
1567
+ ```
1568
+ gateforge: run started — 563 tests expected (runner playwright, scope full)
1569
+ gateforge: ✓ 214/563 Accounts > creates an account
1570
+ gateforge: ✘ 215/563 Accounts > archives the account — Expected: 200
1571
+ gateforge: alive — 214/563 done, 3 running, 12m04s elapsed
1572
+ gateforge: run finished — 561 passed, 1 failed, 1 skipped in 44m05s; grading…
1573
+ ```
1574
+
1575
+ It is on automatically under `CI=true` and off everywhere else, so a
1576
+ local run's output is unchanged. `--progress stderr|file:<path>|off`, and
1577
+ the `run.progress` config key, say so explicitly; an unusable target is a
1578
+ usage error, never a silently dropped stream.
1579
+
1580
+ **Why it is safe to show.** The stream is built from witness-side facts
1581
+ only — how many tests were registered before the run, which test the
1582
+ supervisor has open, its title as declared in the committed catalog, and
1583
+ its outcome. It never reads, filters, or tails runner output, so no
1584
+ secret can reach it by construction: a filter over secret text is not
1585
+ secret-free. The one runtime value it carries is a failing test's first
1586
+ error line, and that is matched against credential shapes and REPLACED
1587
+ whole (a prefix of a secret is a secret) — the line becomes
1588
+ `(message withheld: looks like a secret)`, and a title that itself looks
1589
+ like a secret is replaced by its own digest. The stream decides nothing:
1590
+ it is not evidence, no gate reads it, and a write failure is reported
1591
+ once and then ignored.
1592
+
1593
+ **Failing tests in CI.** A red witnessed test used to ship nothing but a
1594
+ browser snapshot. Its error message and a short `file:line` stack now
1595
+ land in `.gateforge/test-gates/failures.json`, behind the same guard, so
1596
+ a job never has to publish the runner log to explain a failure. Request
1597
+ and response bodies are never included.
1598
+
1599
+ **Two numbers, one meaning.** Reports used to print
1600
+ `repository debt: 192 blocking` next to a gate line that said zero
1601
+ blockers: both were true and neither was actionable. `repositoryDebt`
1602
+ now derives its split from ONE definition, the graded verdicts, so
1603
+ `baselined` and `newlyBlocking` are the same two numbers in the text and
1604
+ in the JSON, and `newlyBlocking` is exactly what this run's exit code
1605
+ blocks on. A changed- or named-scope run grades a slice, so debt outside
1606
+ it is reported in its own words — `not graded by this changed-scope run:
1607
+ 96 blocking obligation(s) — this run never observed them; a full run
1608
+ grades them` — and never counted as new. A run is never printed twice:
1609
+ the in-runner reporter grades claims only, so it names no debt count of
1610
+ its own (`repository debt: graded by gateforge after the run`) instead of
1611
+ contradicting the CLI's line seconds later. A named or changed run never
1612
+ verdicts debt it did not observe — the in-runner reporter prints
1613
+ `GATEFORGE GATE: SELECTION (N satisfied, 0 blocking; repository verdict
1614
+ not graded here)` instead of contradicting the CLI's exit code.
1615
+
1616
+ **A merge-request pipeline with no base commit** used to resolve the
1617
+ `auto` changed-file provider to the local staged diff — zero changed
1618
+ files in a CI job, and a gate that failed an hour later on debt nobody
1619
+ changed. `test-gates --scope changed` and `check --changed` now refuse in
1620
+ seconds with exit 2 and the fix.
1621
+
1622
+ ## Gate strictness and flaky tests
1623
+
1624
+ The gate is strict by default, and that stays the default: a config
1625
+ without `mode` behaves exactly as it always has. The owner can soften
1626
+ the GATE (never the evidence) with `mode: changed` (block only on debt
1627
+ this change touches; the full debt is still reported) or `mode: warn`
1628
+ (evaluate and report everything, exit 0, with an additive `wouldBlock`),
1629
+ and can quarantine an individual flaky test with `gateforge quarantine`
1630
+ — owner-approved, expiring, never proof, never blocking, always visible
1631
+ in the report and in `gateforge enforcement doctor`. Both settings live
1632
+ inside the pinned trusted policy: an agent cannot soften the gate or
1633
+ quarantine a test to make its own commit pass.
1634
+
1635
+ ## Run the whole proof with one command
1636
+
1637
+ Reproducing a witnessed proof locally used to mean hand-building every
1638
+ precondition: the verifier key, the policy pin, the interpreter paths, the
1639
+ bytecode guard, the services, the database reset, the seed, the freeze, the
1640
+ strict check. One missed precondition cost the whole run.
1641
+
1642
+ `gateforge run` owns the generic lifecycle; your app owns the recipe:
1643
+
1644
+ ```sh
1645
+ gateforge run -- --changed --scope full # preflight, recipe, full supervised suite, strict check, teardown
1646
+ gateforge run -- --changed --scope changed # prove only the changed slice
1647
+ gateforge enforcement doctor # every precondition as one PASS/FAIL line with its fix command
1648
+ ```
1649
+
1650
+ Keep `-- --changed`: `run` forwards only the arguments after `--`, and
1651
+ `test-gates` needs `--changed` to supervise the tests and seal a receipt.
1652
+ `--scope full` proves the whole suite; `--scope changed` proves a changed slice.
1653
+
1654
+ The order is fixed: a **strict preflight** (the first failing precondition
1655
+ ends the run before a minute is spent), then the optional recipe
1656
+ `prepare → reset → seed → services_up → healthcheck`, then the supervised
1657
+ `test-gates` with your flags, then `check --require-e2e`, then
1658
+ `services_down` — always, after success and after failure. Every step prints
1659
+ one line with its duration, and the exit code is the first failing step's own
1660
+ code (2 for a usage/config/recipe error, 1 for a preflight failure or a
1661
+ failing gate, the command's own code for a recipe step, 124 for a step
1662
+ timeout).
1663
+
1664
+ `gateforge run` adds no authority: it only SEQUENCES commands you could run
1665
+ yourself, and every verdict still comes from the same engine. Recipe command
1666
+ output never reaches the console — it goes to a log file under
1667
+ `.gateforge/test-gates/run-recipe/`, because your commands may print secrets.
1668
+
1669
+ The recipe is optional and lives in `.gateforge/runtime.yml` (absent = today’s
1670
+ behavior, byte for byte). It holds **paths, never secrets**:
1671
+
1672
+ ```yaml
1673
+ schemaVersion: 1
1674
+ env_files:
1675
+ - .gateforge/test.env # paths only; the values are never printed
1676
+ reset:
1677
+ commands: [['./scripts/reset-db.sh']]
1678
+ timeoutSeconds: 300
1679
+ seed:
1680
+ commands: [['./scripts/seed.sh']]
1681
+ retries: 1
1682
+ services_up:
1683
+ commands: [['./scripts/start-stack.sh']]
1684
+ healthcheck:
1685
+ commands: [['./scripts/health.sh']]
1686
+ timeoutSeconds: 60
1687
+ retries: 5
1688
+ services_down:
1689
+ commands: [['./scripts/stop-stack.sh']]
1690
+ ```
1691
+
1692
+ The recipe shares `.gateforge/runtime.yml` with the
1693
+ staged/supervised runtime: it is ONE document with TWO
1694
+ independent key groups that may coexist. `env_files`, `reset`,
1695
+ `seed`, `services_up`, `healthcheck`, and `services_down` are
1696
+ read only by `gateforge run` (see
1697
+ `packages/cli/src/run-recipe.ts`, which also reads `prepare`
1698
+ — its `commands`, `runTimeoutSeconds`, and `runRetries`
1699
+ sub-keys), while `schemaVersion`, `prepare`, `health`,
1700
+ `services`, `envAllowlist`, and `executionTimeoutSeconds`
1701
+ belong to the staged/supervised runtime (`check --staged` and
1702
+ `test-gates`; see `packages/cli/src/runtime.ts`, where
1703
+ `check --staged` reads `prepare`'s `command`, `reuse`,
1704
+ `timeoutSeconds`, and `preflight` sub-keys). Both groups may
1705
+ live in the same document; neither enables the other.
1706
+
1707
+ An unknown key, a malformed step, or an inline value in `env_files` is a
1708
+ plain error with exit 2 — Gateforge never runs a half-understood recipe. See
1709
+ the [test environment guide](TEST-ENVIRONMENT.md) for the
1710
+ full schema, the exit-code table, and how the recipe relates to the
1711
+ witnessed pre-commit staged runtime.
1712
+
1713
+ ## The witnessed CI job
1714
+
1715
+ `gateforge enforce --ci gitlab|github` writes the **static** check job.
1716
+ Add `--witnessed` and it writes the **witnessed** job next to it — the
1717
+ lane that actually seals a receipt in CI:
1718
+
1719
+ ```sh
1720
+ gateforge enforce --ci gitlab --witnessed # .gateforge/ci/gitlab-witnessed.yml
1721
+ gateforge enforce --ci github --witnessed # .github/workflows/gateforge-witnessed.yml
1722
+ ```
1723
+
1724
+ One job, one proof. It installs the pinned Gateforge, forwards the
1725
+ merge-request base sha into BOTH supervised commands (without it the
1726
+ scope provider falls back to a local diff and can select zero changed
1727
+ files), runs `gateforge run -- --changed --scope full` so your recipe
1728
+ owns the services, reads the verdict out of `report.json`, and uploads
1729
+ `report.json`, `receipt.json`, `execution-result.json` and the run log as
1730
+ artifacts. Job-scoped stack/image names and a private per-job workspace
1731
+ come from the CI job id, so two concurrent jobs never collide.
1732
+
1733
+ You fill in exactly two things: the recipe (`.gateforge/runtime.yml`)
1734
+ and the secret variables (`GATEFORGE_WITNESS_VERIFIER_KEY`,
1735
+ `GATEFORGE_APPROVED_POLICY_DIGEST` as protected/masked CI variables or
1736
+ GitHub secrets). The generated files are plain YAML you review and edit
1737
+ yourself; an existing file is never overwritten, and without the flag
1738
+ every generated file is byte-identical to what it always was. No secret
1739
+ variable is ever echoed, and the recipe log is deliberately NOT an
1740
+ artifact — it may contain your app's secrets.
1741
+
1742
+ ## Known limitations
1743
+
1744
+ - Staged candidates containing symlinks or submodules (and unmerged index
1745
+ entries) are explicit typed blocks in `check --staged` and the broker —
1746
+ not fallbacks; support is not implemented.
1747
+ - A Playwright config without any NAMED project yields native rows with an
1748
+ empty project name that the strict catalog schema rejects as an internal
1749
+ error (exit 2) instead of a typed row; the documented consumer shape uses
1750
+ named projects, and a typed empty-project row is open work.
1751
+ - Writing `.gateforge` configuration or `test-map.yml` into the inventoried
1752
+ consumer worktree, and the server-side GitLab enforcement settings
1753
+ ("Pipelines must succeed", protected branches, pipeline execution policy),
1754
+ are pending owner actions — the complete configuration ships from
1755
+ `init --blocking`, but a local simulation does not complete a server
1756
+ rollout (internal migration record).