@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.
- package/README.md +85 -1145
- package/dist/adapter-audit.d.ts +54 -0
- package/dist/adapter-audit.d.ts.map +1 -1
- package/dist/adapter-audit.js +48 -0
- package/dist/adapter-audit.js.map +1 -1
- package/dist/adapter-scaffold.d.ts +28 -3
- package/dist/adapter-scaffold.d.ts.map +1 -1
- package/dist/adapter-scaffold.js +145 -24
- package/dist/adapter-scaffold.js.map +1 -1
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +2 -0
- package/dist/args.js.map +1 -1
- package/dist/behavior-setup.d.ts.map +1 -1
- package/dist/behavior-setup.js +18 -5
- package/dist/behavior-setup.js.map +1 -1
- package/dist/commands/adapters.d.ts.map +1 -1
- package/dist/commands/adapters.js +73 -2
- package/dist/commands/adapters.js.map +1 -1
- package/dist/commands/adopt.d.ts +9 -1
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +72 -5
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/blocking.d.ts +45 -2
- package/dist/commands/blocking.d.ts.map +1 -1
- package/dist/commands/blocking.js +165 -11
- package/dist/commands/blocking.js.map +1 -1
- package/dist/commands/check.d.ts +34 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +152 -8
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/classify.d.ts +1 -1
- package/dist/commands/classify.d.ts.map +1 -1
- package/dist/commands/classify.js +63 -18
- package/dist/commands/classify.js.map +1 -1
- package/dist/commands/enforcement.d.ts.map +1 -1
- package/dist/commands/enforcement.js +263 -9
- package/dist/commands/enforcement.js.map +1 -1
- package/dist/commands/explain.d.ts +1 -1
- package/dist/commands/explain.d.ts.map +1 -1
- package/dist/commands/explain.js +162 -3
- package/dist/commands/explain.js.map +1 -1
- package/dist/commands/init-presets.d.ts +7 -0
- package/dist/commands/init-presets.d.ts.map +1 -1
- package/dist/commands/init-presets.js +10 -1
- package/dist/commands/init-presets.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +579 -61
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/next.d.ts.map +1 -1
- package/dist/commands/next.js +109 -6
- package/dist/commands/next.js.map +1 -1
- package/dist/commands/pre-commit.d.ts.map +1 -1
- package/dist/commands/pre-commit.js +62 -19
- package/dist/commands/pre-commit.js.map +1 -1
- package/dist/commands/test-gates.js +1 -1
- package/dist/commands/tests.d.ts.map +1 -1
- package/dist/commands/tests.js +46 -7
- package/dist/commands/tests.js.map +1 -1
- package/dist/docs-exclusions.d.ts.map +1 -1
- package/dist/docs-exclusions.js +18 -3
- package/dist/docs-exclusions.js.map +1 -1
- package/dist/endpoint-compiler.d.ts.map +1 -1
- package/dist/endpoint-compiler.js +49 -1
- package/dist/endpoint-compiler.js.map +1 -1
- package/dist/evaluate.d.ts +16 -1
- package/dist/evaluate.d.ts.map +1 -1
- package/dist/evaluate.js +12 -2
- package/dist/evaluate.js.map +1 -1
- package/dist/gateforge-owned.d.ts +103 -0
- package/dist/gateforge-owned.d.ts.map +1 -0
- package/dist/gateforge-owned.js +375 -0
- package/dist/gateforge-owned.js.map +1 -0
- package/dist/git-hooks.d.ts +18 -0
- package/dist/git-hooks.d.ts.map +1 -1
- package/dist/git-hooks.js +36 -1
- package/dist/git-hooks.js.map +1 -1
- package/dist/git-ignored.d.ts +27 -0
- package/dist/git-ignored.d.ts.map +1 -0
- package/dist/git-ignored.js +102 -0
- package/dist/git-ignored.js.map +1 -0
- package/dist/glob.d.ts +33 -14
- package/dist/glob.d.ts.map +1 -1
- package/dist/glob.js +96 -5
- package/dist/glob.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/io.d.ts +18 -5
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +5 -4
- package/dist/io.js.map +1 -1
- package/dist/pipeline.d.ts +16 -1
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +23 -3
- package/dist/pipeline.js.map +1 -1
- package/dist/planes-inference.d.ts +12 -5
- package/dist/planes-inference.d.ts.map +1 -1
- package/dist/planes-inference.js +13 -15
- package/dist/planes-inference.js.map +1 -1
- package/dist/providers.d.ts +54 -0
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +101 -0
- package/dist/providers.js.map +1 -1
- package/dist/repo-scan.d.ts +7 -0
- package/dist/repo-scan.d.ts.map +1 -1
- package/dist/repo-scan.js +109 -8
- package/dist/repo-scan.js.map +1 -1
- package/dist/route-plane-proposals.d.ts +100 -0
- package/dist/route-plane-proposals.d.ts.map +1 -0
- package/dist/route-plane-proposals.js +213 -0
- package/dist/route-plane-proposals.js.map +1 -0
- package/dist/scope.d.ts +20 -0
- package/dist/scope.d.ts.map +1 -1
- package/dist/scope.js +26 -5
- package/dist/scope.js.map +1 -1
- package/dist/singleton-guidance.d.ts +15 -6
- package/dist/singleton-guidance.d.ts.map +1 -1
- package/dist/singleton-guidance.js +30 -10
- package/dist/singleton-guidance.js.map +1 -1
- package/dist/staged-candidate.d.ts.map +1 -1
- package/dist/staged-candidate.js +2 -1
- package/dist/staged-candidate.js.map +1 -1
- package/dist/trusted-policy.d.ts.map +1 -1
- package/dist/trusted-policy.js +3 -2
- package/dist/trusted-policy.js.map +1 -1
- package/dist/unmatched-routes.d.ts +60 -0
- package/dist/unmatched-routes.d.ts.map +1 -0
- package/dist/unmatched-routes.js +131 -0
- package/dist/unmatched-routes.js.map +1 -0
- package/guides/CONNECT-YOUR-PROJECT.md +93 -20
- package/guides/QUICKSTART.md +81 -16
- package/guides/REFERENCE.md +1756 -0
- package/guides/TEST-ENVIRONMENT.md +8 -5
- package/guides/UPGRADE-0.8-to-0.9.md +112 -0
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -4,15 +4,37 @@ The gateforge command-line interface: initialize a project, discover
|
|
|
4
4
|
resources and classification signals, inspect automatic decisions, reuse a
|
|
5
5
|
repository's existing tests, evaluate obligations, run the supervised E2E
|
|
6
6
|
gate, enforce the exact staged candidate, and maintain baselines.
|
|
7
|
+
**0.9.1:** `init --blocking` and `enforce` now insert the `gateforge-check` entry as the FIRST item of an existing `.pre-commit-config.yaml` `repos:` list, so file-mutating hooks cannot run before the gate. See [CHANGELOG.md](../CHANGELOG.md) for the 0.9.1 fixes. **0.9.0 vs. published 0.8.0:** `check --staged` reads the staged bytes, the scan skips untracked gitignored files (receipt identity unchanged), Gateforge's own setup files are policy inputs so the setup commit passes with the policy digest pinned, test-directory models stay out of the graph, per-tenant singletons are tagged only on an exact configured scope, `init` asks one plane question per route folder, `classify plane` takes a folder, `--docs-exclude-file`, `init --behavior`, `explain <path>`, ranked and capped `tests suggest`, `FASTAPI_ROUTER_UNMOUNTED` / `HTTP_METHOD_DYNAMIC` / `ENDPOINT_RESOURCE_CANDIDATE_UNMATCHED` / folded FastAPI prefixes, and no `.pyc` in a published tarball. Upgrading: [UPGRADE-0.8-to-0.9](guides/UPGRADE-0.8-to-0.9.md).
|
|
8
|
+
|
|
7
9
|
**0.8.0 vs. published 0.7.1:** one-command local proof (`gateforge run`), witnessed single tests (`--test`), test-only re-seal, owner-chosen strictness and quarantine, a strict run preflight in the doctor, CI progress stream and witnessed CI templates, adapter kit and scaffold, an engine-owned queue observer for `task` cases, timing chaos and twin path coverage. Upgrading: [UPGRADE-0.7-to-0.8](guides/UPGRADE-0.7-to-0.8.md).
|
|
8
10
|
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Install the CLI, the Playwright pack, and only the detector packs
|
|
14
|
+
that fit your app. Keep every direct `@gate-forge/*` package on
|
|
15
|
+
the same release:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm i -D @gate-forge/cli @gate-forge/pack-playwright
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
You need Node.js 20 or newer. Use the project-local `gateforge`
|
|
22
|
+
binary from your npm script, or add `node_modules/.bin` to your
|
|
23
|
+
shell `PATH`. The scan recommends the packs your code uses; a
|
|
24
|
+
mismatched Gateforge package contract stops the CLI with exit code
|
|
25
|
+
2 and `GATEFORGE_PACKAGE_INCOMPATIBLE`. The full walkthrough,
|
|
26
|
+
including tarball installs: [Quickstart](guides/QUICKSTART.md).
|
|
27
|
+
|
|
9
28
|
## Start here
|
|
10
29
|
|
|
11
30
|
- [Quickstart](guides/QUICKSTART.md)
|
|
12
31
|
- [Test environment](guides/TEST-ENVIRONMENT.md)
|
|
32
|
+
- [Upgrade from 0.8 to 0.9](guides/UPGRADE-0.8-to-0.9.md)
|
|
13
33
|
- [Upgrade from 0.7 to 0.8](guides/UPGRADE-0.7-to-0.8.md)
|
|
14
34
|
- [Upgrade from 0.6 to 0.7](guides/UPGRADE-0.6-to-0.7.md)
|
|
15
35
|
- [Runners other than Playwright](guides/RUNNER-NEUTRAL-EVIDENCE.md)
|
|
36
|
+
- [Connect your project](guides/CONNECT-YOUR-PROJECT.md)
|
|
37
|
+
- [Reference](guides/REFERENCE.md) — every command, flag, exit code, and protocol
|
|
16
38
|
|
|
17
39
|
Also at https://github.com/umiddey/gateforge/tree/main/packages/cli/guides.
|
|
18
40
|
|
|
@@ -21,6 +43,40 @@ Just added a new table or endpoint and the gate is blocking? Run
|
|
|
21
43
|
next action. New proof tests go in `tests/e2e/gateforge/` (overlay);
|
|
22
44
|
never rewrite existing journeys, never `tests mark` as proof.
|
|
23
45
|
|
|
46
|
+
## First commands
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
gateforge init # scan the repo and write the standard scaffold
|
|
50
|
+
gateforge next # the ONE blocking next action — run this after any change
|
|
51
|
+
gateforge check # the full gate: discover → classify → obligations → verdicts
|
|
52
|
+
gateforge test-gates --changed # supervise the changed tests and seal an authenticated receipt
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The four commands a repository needs, with their full reference rows:
|
|
56
|
+
|
|
57
|
+
| Command | Purpose | Exit codes |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| `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 |
|
|
60
|
+
| `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 |
|
|
61
|
+
| `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 |
|
|
62
|
+
| `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) |
|
|
63
|
+
|
|
64
|
+
Every other command — `discover`, `classify`, `explain`,
|
|
65
|
+
`obligations`, the `tests` workflow (`discover` → `suggest` →
|
|
66
|
+
`sync`/`mark` → run), `tests diagnose`, `broker commit`,
|
|
67
|
+
`enforcement doctor`, `baseline`, the key ceremony, and every
|
|
68
|
+
flag — is documented in the [Reference](guides/REFERENCE.md).
|
|
69
|
+
|
|
70
|
+
To re-confirm a handful of hand-picked tests, `--test` names them
|
|
71
|
+
and the run is witnessed exactly like a full gate run:
|
|
72
|
+
`gateforge test-gates --test <selector> --result-only` (repeatable,
|
|
73
|
+
accepted only with `--result-only`, never seals a receipt).
|
|
74
|
+
|
|
75
|
+
Global flags: `--help`, `--version`. Exit codes per architecture contract 4:
|
|
76
|
+
`0` clean/waived, `1` unresolved obligations (or a failed/supervision-blocked
|
|
77
|
+
run), `2` config/usage error. `tests diagnose` has its own advisory contract
|
|
78
|
+
(0/1/2 above).
|
|
79
|
+
|
|
24
80
|
## Proof paths
|
|
25
81
|
|
|
26
82
|
- **Overlay (default).** New thin tests in `tests/e2e/gateforge/` using
|
|
@@ -54,1157 +110,41 @@ never rewrite existing journeys, never `tests mark` as proof.
|
|
|
54
110
|
gate needs a witnessed request and the resulting state, not a mock's
|
|
55
111
|
answer.
|
|
56
112
|
|
|
57
|
-
## Commands
|
|
58
|
-
|
|
59
|
-
| Command | Purpose | Exit codes |
|
|
60
|
-
| --- | --- | --- |
|
|
61
|
-
| `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,...>] [--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. `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 an `undo:` line; `--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 |
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
| `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 |
|
|
66
|
-
| `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 |
|
|
67
|
-
| `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 |
|
|
68
|
-
| `gateforge explain <resourceId> [--json]` | Show one resource's detector signals, classification rules, decision fingerprint, typed blocks, and generated obligations. | 0/1/2 |
|
|
69
|
-
| `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 |
|
|
70
|
-
| `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`). 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 |
|
|
71
|
-
| `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 |
|
|
72
|
-
| `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 |
|
|
73
|
-
| `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) |
|
|
74
|
-
| `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 |
|
|
75
|
-
| `gateforge obligations [--json]` | Evaluate policies against the automatically classified graph and dump obligations, blocking entries, and claim assessments. | 0/1/2 |
|
|
76
|
-
| `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 |
|
|
77
|
-
|
|
78
|
-
| `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) |
|
|
79
|
-
| `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. |
|
|
80
|
-
| `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. |
|
|
81
|
-
| `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 |
|
|
82
|
-
| `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 |
|
|
83
|
-
| `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 |
|
|
84
|
-
| `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 |
|
|
85
|
-
| `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 |
|
|
86
|
-
| `gateforge baseline update <fp...>` | Shrink the baseline to a strict subset (invariant 4). | 0/2 |
|
|
87
|
-
| `gateforge baseline diff <before> <after>` | Compare adopted obligations by ID without printing fingerprints. | 0/2 |
|
|
88
|
-
|
|
89
|
-
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:` line it prints names only the paths the run created (it prints no undo line when it created nothing) — so following it can never delete pre-existing config, baselines, waivers, hooks or CI files. A preset that wires no local hook says whether your existing commit hook and/or CI job still decide what blocks your commits.
|
|
90
|
-
|
|
91
|
-
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.
|
|
92
|
-
|
|
93
|
-
Global flags: `--help`, `--version`. Exit codes per architecture contract 4:
|
|
94
|
-
`0` clean/waived, `1` unresolved obligations (or a failed/supervision-blocked
|
|
95
|
-
run), `2` config/usage error. `tests diagnose` has its own advisory contract
|
|
96
|
-
(0/1/2 above).
|
|
97
|
-
|
|
98
|
-
### Result-only with an external witness
|
|
99
|
-
|
|
100
|
-
Start the witness with a dedicated state directory, then pass that same
|
|
101
|
-
directory and its run token to `test-gates`. The directory must be separate
|
|
102
|
-
from the configured authoritative `.gateforge/test-gates` directory:
|
|
103
|
-
|
|
104
|
-
```sh
|
|
105
|
-
gateforge test-gates --changed --scope changed --result-only \
|
|
106
|
-
--witness-url "$GATEFORGE_WITNESS_URL" \
|
|
107
|
-
--out "$GATEFORGE_STATE_DIR" \
|
|
108
|
-
--run-token "$GATEFORGE_RUN_TOKEN"
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
`test-gates` claim planning reads current Playwright annotations using a
|
|
112
|
-
disposable `GATEFORGE_STATE_DIR`, plus the tracked `test-map.yml`. It never
|
|
113
|
-
treats a previous run's `claims.json` as a declaration source.
|
|
114
|
-
|
|
115
|
-
The report remains `authority: non-authoritative`. The external-witness
|
|
116
|
-
state may contain this run's report and attestation, but this command never
|
|
117
|
-
creates, replaces, or clears a gate receipt. Pre-commit, hook, and CI gate
|
|
118
|
-
paths remain authoritative and do not accept `--result-only`.
|
|
119
|
-
|
|
120
|
-
### Re-check one failing test in seconds (`--test`)
|
|
121
|
-
|
|
122
|
-
To re-confirm a handful of hand-picked tests you do not need a whole
|
|
123
|
-
suite. `--test` names them, and the run is witnessed exactly like a full
|
|
124
|
-
gate run — the same supervisor, the same run token, the same server-side
|
|
125
|
-
evidence:
|
|
126
|
-
|
|
127
|
-
```sh
|
|
128
|
-
# one test (a logical key, or any unique substring of one)
|
|
129
|
-
gateforge test-gates --test 'backend/tests/test_x.py::test_commits' --result-only
|
|
130
|
-
|
|
131
|
-
# several at once — --test is repeatable
|
|
132
|
-
gateforge test-gates --test UC-53 --test UC-51 --result-only
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
`--test` is accepted **only** together with `--result-only`. A
|
|
136
|
-
hand-picked list never seals a receipt, so combining `--test` with a
|
|
137
|
-
sealing run exits 2 and says so. The named run never reads, writes, or
|
|
138
|
-
clears a gate receipt, so `check --require-e2e` is unaffected, and it
|
|
139
|
-
carries `authority: non-authoritative` plus `outcome: partial-selection`
|
|
140
|
-
in the report.
|
|
141
|
-
|
|
142
|
-
A selector is resolved against the **planned** rows — the expected set
|
|
143
|
-
fixed before the run — never against raw runner output, so it can only
|
|
144
|
-
name a test the gate already planned. An exact logical key always wins;
|
|
145
|
-
otherwise a unique case-insensitive substring is used. An unknown or
|
|
146
|
-
ambiguous selector exits 2 and lists the candidate logical keys, because
|
|
147
|
-
a narrower selection is never guessed:
|
|
148
|
-
|
|
149
|
-
```sh
|
|
150
|
-
$ gateforge test-gates --test 'session proxy' --result-only
|
|
151
|
-
gateforge: the selector 'session proxy' matches 2 planned tests — pick one exact logical key. Run `gateforge tests discover --json`. [TEST_SELECTOR_AMBIGUOUS]
|
|
152
|
-
candidate logical keys:
|
|
153
|
-
- tests/green.test.mjs#creates account through the session proxy
|
|
154
|
-
- tests/second.test.mjs#creates the billing account through the session proxy
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
The report gains an additive `selectors` field naming exactly what each
|
|
158
|
-
selector resolved to, and the run uses the `named-selection` selection
|
|
159
|
-
mode, so it can never collide with a full or a diff-linked slice:
|
|
160
|
-
|
|
161
|
-
```json
|
|
162
|
-
{ "outcome": "partial-selection", "selectors": [{ "selector": "UC-53", "logicalKeys": ["pytest:backend/tests/test_x.py::test_commits"] }] }
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
Selection works for every runner (Playwright, pytest, vitest, Cypress)
|
|
166
|
-
through the shared runner-adapter contract. Because it works from the
|
|
167
|
-
plan, it does not need the changed-file set — that is why `--test` is
|
|
168
|
-
useful when a fix touches a `.env`, a fixture, or a helper that no test
|
|
169
|
-
links to.
|
|
170
|
-
|
|
171
|
-
Each runner narrows to the named tests as far as it honestly can:
|
|
172
|
-
Playwright, pytest and vitest receive the exact `file:line` / node id /
|
|
173
|
-
anchored test name, so a named test never drags its file neighbours
|
|
174
|
-
along. Cypress cannot filter below the spec without a plugin the gate
|
|
175
|
-
refuses to trust, so it executes the whole spec, drops every unselected
|
|
176
|
-
outcome and session (an unselected test never becomes evidence), and
|
|
177
|
-
says `also ran N other test(s) in the same file — not graded`.
|
|
178
|
-
|
|
179
|
-
#### What a named run grades, and its exit codes
|
|
180
|
-
|
|
181
|
-
A named run grades **only the selection**: the obligations its selected
|
|
182
|
-
tests declare through the sidecar or native annotations. Everything else
|
|
183
|
-
— repository-wide policy, mapping and inventory findings, the coverage
|
|
184
|
-
policy — is still reported, under `repositoryDebt` and as
|
|
185
|
-
`not graded in a named run: N obligation(s)`, but never blocks: the run
|
|
186
|
-
never observed it. What still blocks is everything about the run itself
|
|
187
|
-
(supervision findings, lifecycle conflicts, intent failures, the witness
|
|
188
|
-
channel, evidence-context failures) and any finding that names a graded
|
|
189
|
-
obligation. The report and the diagnostic context both carry
|
|
190
|
-
`scope: "named"`, and the execution summary keeps the whole-repository
|
|
191
|
-
counts next to the selection's own.
|
|
192
|
-
|
|
193
|
-
| Exit | Meaning |
|
|
194
|
-
| --- | --- |
|
|
195
|
-
| `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 |
|
|
196
|
-
| `1` | anything else: a red selected test, an unproven graded obligation, an incomplete run, changed inputs, or a workspace that moved during the run |
|
|
197
|
-
| `2` | the selector could not be resolved (unknown or ambiguous) — nothing ran |
|
|
198
|
-
|
|
199
|
-
A named run never carries gate authority: it is `--result-only` only,
|
|
200
|
-
never creates, replaces or clears a receipt, and `check --require-e2e`
|
|
201
|
-
keeps reading the seal the authoritative run left. A run without
|
|
202
|
-
`--test` is unaffected by any of this.
|
|
203
|
-
|
|
204
|
-
## Staged runtime (`.gateforge/runtime.yml`)
|
|
205
|
-
|
|
206
|
-
`gateforge pre-commit` executes the candidate inside a materialized checkout
|
|
207
|
-
that contains TRACKED bytes only — no installed dependencies, no built
|
|
208
|
-
assets, no application processes. The reviewed staged-runtime document
|
|
209
|
-
declares how that checkout becomes a runnable candidate. It is
|
|
210
|
-
security-sensitive: its bytes are hashed into the trusted policy digest and
|
|
211
|
-
the authenticated input snapshot, so a candidate that edits its own runtime
|
|
212
|
-
commands cannot approve the edit in the same commit.
|
|
213
|
-
|
|
214
|
-
```yaml
|
|
215
|
-
schemaVersion: 1
|
|
216
|
-
prepare:
|
|
217
|
-
command: npm ci --offline # or pnpm/bun/uv — frozen install, build steps
|
|
218
|
-
reuse: [node_modules] # dependency dirs EXPLICITLY allowed to link from the user repo
|
|
219
|
-
timeoutSeconds: 600
|
|
220
|
-
preflight: # optional cheap checks before prepare
|
|
221
|
-
- { name: lint, command: npm run lint, timeoutSeconds: 60 }
|
|
222
|
-
health: # optional probes before/after the suite
|
|
223
|
-
- { name: database, tcp: '127.0.0.1:5432', timeoutSeconds: 5 }
|
|
224
|
-
- name: worker-startup
|
|
225
|
-
logAbsent:
|
|
226
|
-
command: ./tools/recent-worker-logs.sh
|
|
227
|
-
pattern: 'worker startup failed'
|
|
228
|
-
services: # candidate-owned app/database/worker processes
|
|
229
|
-
- id: app
|
|
230
|
-
command: node server.js --port ${service:app:port}
|
|
231
|
-
attested: true # fronted by the gate's attestation proxy
|
|
232
|
-
fingerprint: prod-v1 # GF-13 marker (reviewed adapters must declare the same)
|
|
233
|
-
target: true # this proxy URL becomes the run's attested target
|
|
234
|
-
ready: { log: 'listening on', timeoutSeconds: 60 } # or http: <url>
|
|
235
|
-
envAllowlist: [DATABASE_URL] # operator env names for services and supervised tests
|
|
236
|
-
executionTimeoutSeconds: 1800 # whole-run budget handed to the supervised gate
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
Contract highlights:
|
|
240
|
-
|
|
241
|
-
- Services start from the CHECKOUT bytes (never the worktree) in their own
|
|
242
|
-
process groups; readiness (`log` regex or `http` 2xx), startup, and
|
|
243
|
-
execution timeouts are bounded; stdout/stderr are captured to
|
|
244
|
-
`<run-state>/runtime/<id>.log`; teardown happens on success, failure,
|
|
245
|
-
timeout, and interruption (SIGINT/SIGTERM kill the whole groups).
|
|
246
|
-
- `prepare.preflight` checks run in order before `prepare`; the first
|
|
247
|
-
non-zero exit blocks preparation with `PREFLIGHT_FAILED <name>` and the
|
|
248
|
-
command's last 30 output lines.
|
|
249
|
-
- `health` supports one `tcp`, `http`, `command`, or `logAbsent` probe per
|
|
250
|
-
entry. `logAbsent` runs its declared log command after startup and blocks
|
|
251
|
-
when the configured regex is found. A failed startup probe blocks with
|
|
252
|
-
`FIXTURE_UNHEALTHY <name>`; the post-run probe is advisory and does not
|
|
253
|
-
change test verdicts. HTTPS uses normal certificate verification.
|
|
254
|
-
- Every `prepare.reuse` tree is constrained to a normalized repository-relative
|
|
255
|
-
path. Its reachable dependency bytes are hashed into the authenticated
|
|
256
|
-
input identity, so changing an ignored reused dependency invalidates the
|
|
257
|
-
receipt even though the checkout uses a link.
|
|
258
|
-
- `${service:<id>:port}` / `${service:<id>:url}` placeholders are
|
|
259
|
-
substituted by the supervisor and injected into every service's
|
|
260
|
-
environment (`GATEFORGE_SERVICE_PORT_<ID>` / `GATEFORGE_SERVICE_URL_<ID>`).
|
|
261
|
-
- The attested target is the process THE GATE started from the frozen
|
|
262
|
-
candidate — a bare target URL proves nothing. The receipt binds the raw-
|
|
263
|
-
ingested tree of the prepared checkout (`targetArtifactDigest`), and the
|
|
264
|
-
user's index is rechecked before authorization.
|
|
265
|
-
- ABSENT document = no bridge, no services (fail closed): discovery that
|
|
266
|
-
needs installed dependencies blocks honestly instead of silently reusing
|
|
267
|
-
the worktree's environment.
|
|
268
|
-
|
|
269
|
-
## Harness and run history
|
|
270
|
-
|
|
271
|
-
The optional `.gateforge.yml` `harness` section declares `up`, `reset`,
|
|
272
|
-
`seed`, `health`, and `down` shell commands. Supervised runs invoke configured
|
|
273
|
-
setup commands in that order before the suite; the first failure blocks the
|
|
274
|
-
suite, prints its last 30 output lines, and still attempts `down`. Gateforge
|
|
275
|
-
executes these commands but does not manage containers or other infrastructure.
|
|
276
|
-
Absent `harness` preserves current behavior.
|
|
277
|
-
|
|
278
|
-
```yaml
|
|
279
|
-
harness:
|
|
280
|
-
up: ./tools/test-up.sh
|
|
281
|
-
reset: ./tools/test-reset.sh
|
|
282
|
-
seed: ./tools/test-seed.sh
|
|
283
|
-
health: ./tools/test-health.sh
|
|
284
|
-
down: ./tools/test-down.sh
|
|
285
|
-
serviceLogs:
|
|
286
|
-
command: docker compose logs --no-color --tail ${lines} ${service}
|
|
287
|
-
services: [database, worker]
|
|
288
|
-
lines: 100
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
On a failed supervised run, `serviceLogs` runs the declared log command for
|
|
292
|
-
each service and saves the configured tail to
|
|
293
|
-
`<run-state>/diagnostics/service-logs.txt`. Log capture is advisory and does
|
|
294
|
-
not change test verdicts.
|
|
295
|
-
|
|
296
|
-
Each `verifyPersistence` adapter call is timed in
|
|
297
|
-
`<run-state>/diagnostics/adapter-timing.jsonl`; calls over two seconds also
|
|
298
|
-
print a warning. Timed-out tests report the observed app/runner time separately
|
|
299
|
-
from their summed witness-adapter time. These diagnostics do not alter the
|
|
300
|
-
receipt or verdict.
|
|
301
|
-
|
|
302
|
-
Run history is opt-in through `.gateforge.yml` `history`; when configured,
|
|
303
|
-
retention defaults to 14 days and is capped at 90. Set `retentionDays: off`
|
|
304
|
-
to disable it. History is stored beneath the ignored test-gates state and is
|
|
305
|
-
not receipt input. Query it with `gateforge history [--test TEXT] [--failed]
|
|
306
|
-
[--since ISO-8601]`.
|
|
307
|
-
|
|
308
|
-
## Existing-test reuse (`gateforge tests`)
|
|
309
|
-
|
|
310
|
-
The reuse-first workflow: inspect what exists, declare what is unclear, run
|
|
311
|
-
it, and add a new test only for a confirmed behavior gap. The fixed agent
|
|
312
|
-
sequence is: `tests discover` → `tests suggest` → `tests sync` for annotated
|
|
313
|
-
tests or `tests mark` for hand-written sidecar mappings → run the suite under
|
|
314
|
-
supervision → `check --require-e2e`.
|
|
315
|
-
|
|
316
|
-
`tests discover` writes the catalog to `.gateforge/test-gates/test-catalog.json`
|
|
317
|
-
— a DERIVED artifact under the excluded run-state directory, never a pipeline
|
|
318
|
-
input and never beside the tests it inventories. Logical keys are stable
|
|
319
|
-
(`playwright:<project>:<file>:<title path>`; `-` when the runner has no
|
|
320
|
-
project) so manual mappings survive comment edits; source digests still move,
|
|
321
|
-
so old evidence goes stale. Renamed/deleted tests and removed parameters
|
|
322
|
-
surface as stale or ambiguous mappings — never a silent reassignment.
|
|
323
|
-
|
|
324
|
-
`tests sync` statically resolves direct Gateforge annotations and local pure
|
|
325
|
-
helpers that return literals. It never loads a test runner or executes a test.
|
|
326
|
-
Entries marked `source: annotation` are regenerated; handwritten entries are
|
|
327
|
-
preserved. Unresolvable annotations are printed as `UNRESOLVED` with the test
|
|
328
|
-
file and location. `check` reports missing/extra generated claims as the
|
|
329
|
-
non-blocking `TEST_MAP_OUT_OF_SYNC` advisory for this release period; run
|
|
330
|
-
`gateforge tests sync` to reconcile them.
|
|
331
|
-
|
|
332
|
-
`tests mark` validates the declaration against the current catalog AND the
|
|
333
|
-
current obligation registry (an unknown obligation id or test key is a
|
|
334
|
-
precise exit-2 error) before writing `.gateforge/test-map.yml`:
|
|
335
|
-
|
|
336
|
-
```yaml
|
|
337
|
-
schemaVersion: 1
|
|
338
|
-
tests:
|
|
339
|
-
- key: playwright:chromium:e2e/accounts.spec.ts:deletes an account
|
|
340
|
-
selector:
|
|
341
|
-
runner: playwright
|
|
342
|
-
project: chromium
|
|
343
|
-
file: e2e/accounts.spec.ts
|
|
344
|
-
titlePath: [Accounts, deletes an account]
|
|
345
|
-
kind: browser-e2e
|
|
346
|
-
categories: [persistence.delete]
|
|
347
|
-
claims: [tenant.accounts:persistence:delete]
|
|
348
|
-
reason: Existing journey deletes the selected account.
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
`--kind` is one of `browser-e2e`, `observed-e2e`, `api-e2e`, `unit`, `integration`,
|
|
352
|
-
`component`, `unknown`. A declaration is INTENT, never proof:
|
|
353
|
-
|
|
354
|
-
- Native `{ type: 'gateforge', description: '<obligation id>' }` annotations
|
|
355
|
-
keep working; sidecar entries and native claims normalize through ONE
|
|
356
|
-
resolver. Exact duplicate claims deduplicate; contradictions block with
|
|
357
|
-
both source locations (`TEST_MAPPING_AMBIGUOUS`).
|
|
358
|
-
- An explicit kind may resolve `unknown` — and `observed-e2e` may refine an
|
|
359
|
-
inferred `browser-e2e` (same journey, witness-watched instead of
|
|
360
|
-
engine-driven) — but cannot override observed mocking or any other
|
|
361
|
-
strong code-signal inference — `tests mark` refuses with
|
|
362
|
-
both locations instead of writing the file.
|
|
363
|
-
- Agents may edit the sidecar directly; both paths receive identical
|
|
364
|
-
validation. `mark` is idempotent: re-running an exact declaration writes
|
|
365
|
-
nothing and reports `no changes`.
|
|
366
|
-
- Nothing here waives, weakens, or satisfies anything: a mapped test with no
|
|
367
|
-
witnessed evidence for this change grades `EVIDENCE_NOT_COLLECTED` —
|
|
368
|
-
blocking.
|
|
369
|
-
|
|
370
|
-
`tests suggest` emits `newTestNeeded: true` only when no suitable existing
|
|
371
|
-
candidate survives resolution. An unsupported proof channel produces a
|
|
372
|
-
capability task (`VERIFIER_UNSUPPORTED`), never a request to generate more
|
|
373
|
-
tests.
|
|
374
|
-
|
|
375
|
-
## Advisory pytest diagnostics
|
|
376
|
-
|
|
377
|
-
Register existing pytest suites under `diagnostics.suites` in
|
|
378
|
-
`.gateforge.yml` (explicit, tracked configuration — gateforge never scans
|
|
379
|
-
directories or executes commands on its own; only the `pytest` runner has an
|
|
380
|
-
adapter today):
|
|
381
|
-
|
|
382
|
-
```yaml
|
|
383
|
-
diagnostics:
|
|
384
|
-
suites:
|
|
385
|
-
- name: backend-pytest
|
|
386
|
-
runner: pytest
|
|
387
|
-
cwd: server
|
|
388
|
-
argv: [python, -m, pytest]
|
|
389
|
-
testPaths: [tests]
|
|
390
|
-
timeoutMs: 600000
|
|
391
|
-
hostLoad: true # opt-in: sample load average, CPU count, and disk space
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
`gateforge tests diagnose` runs each configured suite once against the
|
|
395
|
-
current inputs (drift around discovery refuses the run) and prints a SEPARATE
|
|
396
|
-
diagnostic report with `DIAGNOSTIC_TEST_FAILURE` /
|
|
397
|
-
`DIAGNOSTIC_RUN_INCOMPLETE` / `DIAGNOSTIC_RESULT_STALE` causes. Skips and
|
|
398
|
-
expected failures stay explicit counters; a run of only skipped/xfail cases
|
|
399
|
-
is INCOMPLETE (exit 2), never a passing alarm. Diagnostic results are never
|
|
400
|
-
fed into claims, witness records, baselines, waivers, or E2E satisfaction,
|
|
401
|
-
and are never merged into E2E pass counts — 100 passing pytest tests do not
|
|
402
|
-
clear one missing browser obligation. When the supervised run executes the
|
|
403
|
-
same suites, their results are displayed separately without changing the E2E
|
|
404
|
-
exit decision.
|
|
405
|
-
|
|
406
|
-
When enabled, the supervised run writes `diagnostics/host-load.json` at start,
|
|
407
|
-
every 30 seconds, and at completion. Failed tests completed while load exceeds
|
|
408
|
-
1.5× CPU count get a note with the nearest preceding sample. Free disk below
|
|
409
|
-
5% at start emits a warning; load and disk data are diagnostic only.
|
|
410
|
-
|
|
411
|
-
## Enforcement
|
|
412
|
-
|
|
413
|
-
Two named modes (ADR 0005 D1); the CLI never reports a hook as more than it
|
|
414
|
-
is.
|
|
415
|
-
|
|
416
|
-
When a witnessed pre-commit run reaches a blocking result, Gateforge reports
|
|
417
|
-
how many tests the current commit selected and, when recorded, how long the
|
|
418
|
-
last full run took. This is cost context only; the current run and its receipt
|
|
419
|
-
still decide whether the commit passes.
|
|
420
|
-
|
|
421
|
-
**Standard mode** — an active local hook PLUS a mandatory trusted server
|
|
422
|
-
check:
|
|
423
|
-
|
|
424
|
-
- `gateforge init --blocking` installs a static pre-commit check and, for
|
|
425
|
-
new configs (`enforcement.receiptStage: pre-push`), a pre-push hook that
|
|
426
|
-
checks each pushed commit tip with `check --candidate-commit <sha>
|
|
427
|
-
--require-e2e`. The static lane does not require a receipt; the pre-push
|
|
428
|
-
lane does. Existing configs without `receiptStage` keep their previous
|
|
429
|
-
pre-commit behavior. Hook activation is verified; foreign hooks are never
|
|
430
|
-
overwritten.
|
|
431
|
-
By default, `init --blocking` writes `.gateforge/ci/gitlab-gateforge.yml`
|
|
432
|
-
plus the `.gitlab-ci.yml` include. `gateforge enforce --ci github` writes
|
|
433
|
-
`.github/workflows/gateforge.yml` instead. Both strict templates run
|
|
434
|
-
`test-gates --changed`, then verify the exact CI commit with
|
|
435
|
-
`check --changed --candidate-commit "$CI_COMMIT_SHA"` (GitLab) or
|
|
436
|
-
`--candidate-commit "$GITHUB_SHA"` (GitHub). The verifier key and policy
|
|
437
|
-
pin come from protected CI secrets.
|
|
438
|
-
`init --blocking` prints exact GitHub/GitLab protection commands for
|
|
439
|
-
owner review; it never runs server mutations itself.
|
|
440
|
-
Protect the branch, require its Gateforge pipeline to succeed (skipped jobs
|
|
441
|
-
do not count), exclude agent roles from direct pushes, and use an
|
|
442
|
-
organization-controlled pipeline execution policy so a candidate cannot
|
|
443
|
-
remove the gate job. THE HONEST LIMIT: `--no-verify`, an alternate
|
|
444
|
-
`core.hooksPath`, direct plumbing, or an unrelated clone bypass any local
|
|
445
|
-
hook — keeping bypassed commits out of protected history is the server's
|
|
446
|
-
job, not the hook's.
|
|
447
|
-
`gateforge enforcement doctor` reports level 0–3. It reports level 3 only
|
|
448
|
-
when a read-only provider API confirms branch protection plus a required
|
|
449
|
-
Gateforge status check or passing-pipeline setting.
|
|
450
|
-
- The CI template checks that the installed `@gate-forge/cli` version equals
|
|
451
|
-
the version that generated it. Add that exact version as a root
|
|
452
|
-
`devDependency`. The template uses a package-manager lockfile when present;
|
|
453
|
-
without one, it installs from the manifest. Set
|
|
454
|
-
`GATEFORGE_CI_NESTED_PACKAGE_DIRS` to a space-separated list such as `e2e`
|
|
455
|
-
when the Playwright config imports dependencies from nested packages.
|
|
456
|
-
`enforce` and `adopt` use the same install and version checks, then run the
|
|
457
|
-
static `check --changed` gate. They do not recommend gating on report counts.
|
|
458
|
-
- A generated hook uses `GATEFORGE_DEV_ENGINE` when set, then the
|
|
459
|
-
repository-pinned CLI, `.gateforge/engine`, and `GATEFORGE_CLI`. A global
|
|
460
|
-
`gateforge` on `PATH` is a last-resort fallback with a warning.
|
|
461
|
-
- `check --staged [--require-e2e]` gates the EXACT staged bytes: the index
|
|
462
|
-
tree is frozen, materialized into an isolated scratch checkout, and the
|
|
463
|
-
regular gate runs against those bytes (never the worktree). The candidate
|
|
464
|
-
is re-checked after the gate — any index/HEAD drift during the run is a
|
|
465
|
-
typed `ENFORCEMENT_UNTRUSTED` block. Partial staging is fine; symlinks,
|
|
466
|
-
submodules, and unmerged index entries are typed blocks, never fallbacks.
|
|
467
|
-
- `check --changed --require-e2e` is the CI-side strict gate over the checked-
|
|
468
|
-
out candidate.
|
|
469
|
-
- `--strict-e2e` (config `enforcement.strictE2E`) makes waived or baselined
|
|
470
|
-
in-scope E2E obligations NOT proof (they block with `ENFORCEMENT_UNTRUSTED`
|
|
471
|
-
— no automatic debt forgiveness), and blocks unclassified changed files as
|
|
472
|
-
`CHANGE_UNMAPPED` until a resolved mapping covers them. Candidate edits to
|
|
473
|
-
policies, classification, adapters, waivers, baselines, or the mapping
|
|
474
|
-
sidecar cannot authorize weaker checks: gates evaluate under the trusted
|
|
475
|
-
policy digest, so a weakened candidate fails closed until a separate
|
|
476
|
-
trusted update is accepted.
|
|
477
|
-
|
|
478
|
-
**Receipts (the strict saved-state gate).** `check --require-e2e` accepts
|
|
479
|
-
only an authenticated gate receipt sealed by a COMPLETE supervised run for
|
|
480
|
-
the current input digest and trusted policy digest:
|
|
481
|
-
|
|
482
|
-
- no receipt (old record bundles included) → `RUN_INCOMPLETE`;
|
|
483
|
-
- receipt for different bytes/inputs → `EVIDENCE_STALE` (rerun for the
|
|
484
|
-
exact candidate);
|
|
485
|
-
- forged/tampered receipt → `ENFORCEMENT_UNTRUSTED`.
|
|
486
|
-
|
|
487
|
-
Receipts sealed by newer Gateforge versions add the `engine` identity
|
|
488
|
-
(`version`, `source`, and `unpublished`) inside the authenticated envelope.
|
|
489
|
-
When present, `check --require-e2e` requires the installed CLI version to
|
|
490
|
-
match the version that sealed the receipt. Legacy receipts without `engine`
|
|
491
|
-
continue to verify as before.
|
|
492
|
-
|
|
493
|
-
`test-gates --changed` seals a receipt only after planned-vs-executed
|
|
494
|
-
completeness, evidence grading, and a successful runner exit: zero selected
|
|
495
|
-
tests, skips, `.only`, retries, teardown failures, and incomplete shards all
|
|
496
|
-
fail the run. Identical authenticated inputs may reuse a prior receipt
|
|
497
|
-
(printed as `reused receipt <id>`); any changed input forces a fresh run.
|
|
498
|
-
Without the verifier key in the trusted environment nothing can be sealed
|
|
499
|
-
and `--require-e2e` blocks — it never downgrades to a weaker pass.
|
|
500
|
-
|
|
501
|
-
**Owner-declared documentation exclusions (explicit trust mode).** By default,
|
|
502
|
-
Gateforge hashes all inputs and all candidate files. On a terminal, the first
|
|
503
|
-
`gateforge init` asks for documentation-only folders to exclude. Automation can
|
|
504
|
-
use `gateforge init --docs-exclude docs,handbook`; a non-interactive run with no
|
|
505
|
-
option keeps the default. Gateforge writes the approved declaration to
|
|
506
|
-
`.gateforge/docs-exclusions.yml` and prints the candidate trusted-policy digest
|
|
507
|
-
to approve through the protected `GATEFORGE_APPROVED_POLICY_DIGEST` setting.
|
|
508
|
-
Gate checks refuse to use the exclusions until that external pin matches. A
|
|
509
|
-
later change to the exclusion declaration changes the digest; use
|
|
510
|
-
`--confirm-doc-exclusions` when `init` changes an existing approval.
|
|
511
|
-
|
|
512
|
-
The project states these folders do not affect the product or its tests.
|
|
513
|
-
Gateforge does not prove this. If application or test code reads an excluded
|
|
514
|
-
file, a later edit can make old evidence look valid without running the tests
|
|
515
|
-
again. Reports show the approved folders, pin identity, and this reduced
|
|
516
|
-
guarantee. Gateforge rejects exclusions that contain configured scan inputs,
|
|
517
|
-
source files, gate or trust metadata, manifests, lockfiles, or symlinks.
|
|
518
|
-
Every file must also use a supported document or raster-image format. MDX,
|
|
519
|
-
WASM, SVG, HTML, and unknown formats fail closed. This format allowlist does
|
|
520
|
-
not prove that an allowed file cannot affect application or test behavior;
|
|
521
|
-
the project assertion and its reduced guarantee still apply.
|
|
522
|
-
|
|
523
|
-
**Owner-declared Python bytecode exclusions (explicit trust mode).** By
|
|
524
|
-
default, Python bytecode remains part of candidate and input identity. To
|
|
525
|
-
exclude only exact generated cache files, run
|
|
526
|
-
`gateforge init --cache-exclude src/__pycache__/module.cpython-313.pyc`.
|
|
527
|
-
The command writes `.gateforge/cache-exclusions.yml` and prints the trusted
|
|
528
|
-
policy digest to approve outside the repository. A matching protected
|
|
529
|
-
`GATEFORGE_APPROVED_POLICY_DIGEST` pin is REQUIRED before a gate uses the
|
|
530
|
-
list; changing an existing list requires `--confirm-cache-exclusions`.
|
|
531
|
-
Only exact `.pyc` or `.pyo` files directly under `__pycache__` are allowed;
|
|
532
|
-
globs, symlinks, configured inputs, and other file types fail closed. Reports
|
|
533
|
-
show the exact files, pin status, and reduced trust guarantee. This is an
|
|
534
|
-
owner assertion, not proof that the excluded bytecode cannot affect runtime
|
|
535
|
-
behavior.
|
|
536
|
-
|
|
537
|
-
**Managed mode** (config `enforcement.mode: managed`) — the literal
|
|
538
|
-
no-bypass guarantee requires putting the authoritative Git metadata, commit
|
|
539
|
-
service, gate executable, policy authority, and signing material OUTSIDE the
|
|
540
|
-
agent's write/process boundary. `gateforge broker commit` ships the
|
|
541
|
-
MECHANISM — verify a receipt for the exact workspace bytes, then commit via
|
|
542
|
-
compare-and-swap ref update — not the deployment. Running the broker inside
|
|
543
|
-
the agent's own boundary provides NO managed guarantee.
|
|
544
|
-
`gateforge enforcement doctor` reports which boundary is actually active:
|
|
545
|
-
hook activation, runner/browser readiness, capability availability, trusted
|
|
546
|
-
binary/policy ownership, snapshot mode, and — in managed mode — an
|
|
547
|
-
agent-writable authoritative Git directory is a `fail`, never a pass.
|
|
548
|
-
When `.pre-commit-config.yaml` exists, the doctor runs its hooks twice in a
|
|
549
|
-
temporary checkout, reports files they modify, and recommends placing
|
|
550
|
-
`gateforge-check` before mutating hooks. Hook commands still run with the
|
|
551
|
-
caller’s system permissions; review them as you would any local command.
|
|
552
|
-
|
|
553
|
-
### Owner-operated systemd deployment recipe
|
|
554
|
-
|
|
555
|
-
This is an operator deployment pattern, not an installed Gateforge service.
|
|
556
|
-
Use a dedicated authority account and keep the bare authoritative repository,
|
|
557
|
-
trusted config, CLI binary, and verifier key outside the agent's writable
|
|
558
|
-
process boundary. Give agents write access only to unique inbox workspaces;
|
|
559
|
-
allow them to request this one fixed unit, never arbitrary systemd units.
|
|
560
|
-
Do not pass candidate-controlled environment variables to the service.
|
|
561
|
-
|
|
562
|
-
Create an owner-only key ring and approved config as the authority account:
|
|
563
|
-
|
|
564
|
-
```sh
|
|
565
|
-
sudo install -d -o gateforge-authority -g gateforge-authority -m 0700 /etc/gateforge
|
|
566
|
-
sudo -u gateforge-authority gateforge key create --file /etc/gateforge/verifier-keyring.json --confirm
|
|
567
|
-
```
|
|
568
|
-
|
|
569
|
-
Install `/etc/systemd/system/gateforge-broker@.service` (replace the
|
|
570
|
-
root-owned CLI path and ref for your installation):
|
|
571
|
-
|
|
572
|
-
```ini
|
|
573
|
-
[Unit]
|
|
574
|
-
Description=Verify and commit one Gateforge workspace
|
|
575
|
-
|
|
576
|
-
[Service]
|
|
577
|
-
Type=oneshot
|
|
578
|
-
User=gateforge-authority
|
|
579
|
-
Group=gateforge-authority
|
|
580
|
-
WorkingDirectory=/srv/gateforge/authority.git
|
|
581
|
-
Environment=GATEFORGE_WITNESS_VERIFIER_KEY_FILE=/etc/gateforge/verifier-keyring.json
|
|
582
|
-
Environment=GATEFORGE_TRUSTED_CONFIG=/etc/gateforge/approved.yml
|
|
583
|
-
ExecStart=/usr/local/bin/gateforge broker commit --workspace /srv/gateforge/inbox/%i --message "verified candidate" --ref refs/heads/main
|
|
584
|
-
ProtectSystem=strict
|
|
585
|
-
ProtectHome=true
|
|
586
|
-
PrivateTmp=true
|
|
587
|
-
NoNewPrivileges=true
|
|
588
|
-
ReadOnlyPaths=/srv/gateforge/inbox
|
|
589
|
-
ReadWritePaths=/srv/gateforge/authority.git
|
|
590
|
-
```
|
|
591
|
-
|
|
592
|
-
Provision `/srv/gateforge/authority.git`, `/srv/gateforge/inbox/<opaque-id>`,
|
|
593
|
-
and `/etc/gateforge/approved.yml` with owner-controlled permissions. Restrict
|
|
594
|
-
service activation to the agent role via an exact polkit rule; do not grant
|
|
595
|
-
general `sudo systemctl` access. The broker verifies the workspace receipt,
|
|
596
|
-
current approved policy, raw tree bytes, and compare-and-swap target ref
|
|
597
|
-
before committing. A missing, stale, forged, or wrong-key receipt fails
|
|
598
|
-
closed. `enforcement doctor` can verify the local boundary only; the owner
|
|
599
|
-
must separately audit the service account, polkit rule, filesystem
|
|
600
|
-
permissions, and immutable engine/config deployment.
|
|
601
|
-
|
|
602
|
-
## Contract capabilities
|
|
603
|
-
|
|
604
|
-
What the engine can grade today (single source of truth: the core capability
|
|
605
|
-
registry; `init --strict-e2e` preflight rejects setups that require anything
|
|
606
|
-
else):
|
|
607
|
-
|
|
608
|
-
| Namespace | Status |
|
|
609
|
-
| --- | --- |
|
|
610
|
-
| `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) |
|
|
611
|
-
| `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 |
|
|
612
|
-
| `http:frontend-request-observed` | UNAVAILABLE — no independent browser/test attribution channel; explicit selection remains blocking `missing` with `VERIFIER_UNSUPPORTED` |
|
|
613
|
-
| `crud:*` (UI-semantic) | FAIL-CLOSED — the tested suite owns the browser; use `persistence:*` |
|
|
614
|
-
| `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 |
|
|
615
|
-
| `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 |
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
A behavior case may declare a `signatureProfile` on its `request`
|
|
619
|
-
action: an algorithm plus bounded `;key=value` parameters
|
|
620
|
-
(`header`, `timestampHeader`, `toleranceMs`, `attemptHeader`,
|
|
621
|
-
`attempt`, `forgery`). One parser serves both the config schema and
|
|
622
|
-
the witness driver, so `hmac-sha256;forgery=signature` is understood
|
|
623
|
-
identically at parse time and at run time and an unknown parameter is
|
|
624
|
-
refused rather than defaulted. The signing secret is read only from
|
|
625
|
-
the trusted lease; the signature always covers the exact bytes on the
|
|
626
|
-
wire.
|
|
627
|
-
|
|
628
|
-
Unsupported proof stays blocking. Nothing silently replaces browser proof
|
|
629
|
-
with HTTP status proof.
|
|
630
|
-
`gateforge init` includes the available transport-only contracts for consumed
|
|
631
|
-
HTTP endpoints in new installations. Existing policies are unchanged;
|
|
632
|
-
explicitly requiring `http:frontend-request-observed` still blocks. The init
|
|
633
|
-
scan names that unavailable channel once as not yet provable.
|
|
634
|
-
|
|
635
|
-
### Observation scope for HTTP endpoints (opt-in policy option)
|
|
636
|
-
|
|
637
|
-
By default an `http.endpoint` owes the observation contracts
|
|
638
|
-
(`http:request-observed`, `http:response-status-ok`) only when a
|
|
639
|
-
`consumed: true` policy matches it — the static join with the frontend.
|
|
640
|
-
A brand-new route that no UI calls therefore owes nothing, and "you
|
|
641
|
-
forgot a test" stays invisible: `check` exits 0.
|
|
642
|
-
|
|
643
|
-
The pinned policies document (`.gateforge/policies.yml`, the trusted
|
|
644
|
-
policy) takes one additive option that widens that scope:
|
|
645
|
-
|
|
646
|
-
```yaml
|
|
647
|
-
schemaVersion: 1
|
|
648
|
-
options:
|
|
649
|
-
'http.endpoint.requireObservation': all # or 'consumed' (the default)
|
|
650
|
-
policies:
|
|
651
|
-
- id: frontend-consumed-endpoints-transport-only
|
|
652
|
-
when:
|
|
653
|
-
kind: http.endpoint
|
|
654
|
-
consumed: true
|
|
655
|
-
require:
|
|
656
|
-
- http:request-observed
|
|
657
|
-
- http:response-status-ok
|
|
658
|
-
```
|
|
659
|
-
|
|
660
|
-
- Absent (or `consumed`): today's behavior, byte for byte. A document
|
|
661
|
-
without the `options` section generates the same obligations, the same
|
|
662
|
-
report and the same exit code it always did.
|
|
663
|
-
- `all`: EVERY discovered endpoint owes the observation contracts of a
|
|
664
|
-
`consumed: true` endpoint policy. An unmapped one is `missing` with the
|
|
665
|
-
existing `TEST_MAPPING_MISSING` cause and the existing overlay next
|
|
666
|
-
action. Existing routes are not re-litigated: run `gateforge adopt`
|
|
667
|
-
once (the sanctioned bulk-add) and the adopted baseline forgives them,
|
|
668
|
-
so only NEW routes block.
|
|
669
|
-
- The option never widens a `consumed: false` policy, a policy that does
|
|
670
|
-
not name the `http.endpoint` kind, or anything that is not a route; it
|
|
671
|
-
adds no contract, cause code or exit code.
|
|
672
|
-
- It lives in the pinned policy document, so an agent cannot widen or
|
|
673
|
-
narrow the scope by itself — that is a policy revision.
|
|
674
|
-
- `gateforge next` names the option on the one item it explains (an
|
|
675
|
-
unmapped obligation on a route the frontend never calls while the
|
|
676
|
-
option is `all`) and stays silent everywhere else.
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
## Configuration
|
|
681
|
-
|
|
682
|
-
`.gateforge.yml` is loaded fail-closed from the working directory (the repo
|
|
683
|
-
root); see `@gate-forge/core` for the pinned schema. All paths are
|
|
684
|
-
repo-root-relative. `changed.provider: auto` (the default) picks
|
|
685
|
-
`github-pr` when `GITHUB_BASE_REF` is set, `gitlab-mr` when
|
|
686
|
-
`CI_MERGE_REQUEST_DIFF_BASE_SHA` is set, else `local-staged`
|
|
687
|
-
(`git diff --cached --name-only`). `clock.mode: fixed` freezes the run
|
|
688
|
-
instant for deterministic reports; `system` (default) freezes it at run
|
|
689
|
-
start.
|
|
690
|
-
|
|
691
|
-
Enforcement-relevant sections:
|
|
692
|
-
|
|
693
|
-
- `enforcement:` — `mode: standard | managed` (default `standard`),
|
|
694
|
-
`strictE2E: boolean` (default `false`), and optional
|
|
695
|
-
`receiptStage: pre-push | pre-commit | ci`. New configs choose `pre-push`;
|
|
696
|
-
omission preserves legacy behavior.
|
|
697
|
-
- `coveragePolicy:` (opt-in, fail closed) — the closed-world CRUD coverage
|
|
698
|
-
policy: enumerated user-facing tables (validated against the run's
|
|
699
|
-
resource inventory on EVERY run — an unknown table name is a config error,
|
|
700
|
-
a silently dropped inventory table is a violation), required operations,
|
|
701
|
-
and owner dispositions (`read-only-surface`, `admin-plane-unreachable`,
|
|
702
|
-
`not-user-facing`, `other`, with a note). With the policy enabled, an
|
|
703
|
-
uncovered, undispositioned required operation blocks with
|
|
704
|
-
`CRUD_COVERAGE_MISSING`. Recording or approving a disposition is a
|
|
705
|
-
trusted-policy act — the policy participates in the trusted policy
|
|
706
|
-
revision, so an agent edit never self-approves.
|
|
707
|
-
- `diagnostics.suites:` — the advisory pytest suites (see above).
|
|
708
|
-
- `runner:` — the test runner the supervised gate drives:
|
|
709
|
-
`playwright` (the default when the key is absent), `pytest`, `vitest` or
|
|
710
|
-
`cypress`. `check`, `next`, `tests`, `test-gates`, `doctor` and `init`
|
|
711
|
-
all follow it. See `guides/RUNNER-NEUTRAL-EVIDENCE.md`.
|
|
712
|
-
|
|
713
|
-
## Plugin invocation
|
|
714
|
-
|
|
715
|
-
Every configured plugin runs over the same expanded include path list
|
|
716
|
-
(`project.paths.include` minus `exclude`; `.git` and `node_modules` are
|
|
717
|
-
never scanned):
|
|
718
|
-
|
|
719
|
-
- **subprocess** (GPP/3): `command` argv is spawned via
|
|
720
|
-
`@gate-forge/plugin-protocol`'s `PluginSession` — pinned handshake, one
|
|
721
|
-
lock-step `discover`, shutdown handshake, fail-closed on any protocol
|
|
722
|
-
violation. Plugins run without network.
|
|
723
|
-
- **in-process**: `module` is dynamically imported and its *default
|
|
724
|
-
export* must provide `discover(paths)` returning
|
|
725
|
-
`{resources, unresolved, findings}` in the pinned discovery shape.
|
|
726
|
-
Relative module specifiers resolve against the repo root; the result is
|
|
727
|
-
schema-validated and fails closed on invalid output.
|
|
728
|
-
|
|
729
|
-
The plugin's `discover` receives repo-relative file paths; in-process
|
|
730
|
-
plugins resolve them against the process working directory, which for a
|
|
731
|
-
CLI run is the repo root.
|
|
732
|
-
|
|
733
|
-
## Endpoint plane rules (`.gateforge/planes.json`)
|
|
734
|
-
|
|
735
|
-
The same declarative plane document the packs apply to business tables
|
|
736
|
-
also carries endpoint-plane evidence. It is consumed by the endpoint
|
|
737
|
-
compiler (the pipeline stage that builds `http.endpoint` resources) with
|
|
738
|
-
the same strict reader, the same schema
|
|
739
|
-
(`{ rules: [{ match?, tables?, plane, reason }] }`), and the same
|
|
740
|
-
fail-closed posture.
|
|
741
|
-
|
|
742
|
-
**Endpoint plane rules are explicit human declarations keyed on the
|
|
743
|
-
router SOURCE FILE path — not automatic filename inference.** The config
|
|
744
|
-
IS the documented evidence (mirroring the classification policy's
|
|
745
|
-
declaration channels): a rule whose `match` glob (repo-root-relative,
|
|
746
|
-
posix, core classifier glob semantics) matches an endpoint's router file
|
|
747
|
-
asserts that endpoint's `plane` (`tenant` | `master` | `global`) with a
|
|
748
|
-
required non-empty `reason` as the review artifact. `tables` rules never
|
|
749
|
-
apply to endpoints — endpoints carry no table identity.
|
|
750
|
-
|
|
751
|
-
Evaluation per endpoint, deterministic and fail closed:
|
|
752
|
-
|
|
753
|
-
- **All matching rules agree** → the plane is applied as a plane-dimension
|
|
754
|
-
declaration signal (`gateforge.endpoint-compiler:config`), the same
|
|
755
|
-
evidence channel the classifier's inheritance pass uses, so the graph
|
|
756
|
-
qualifies the endpoint id as `plane.<name>`.
|
|
757
|
-
- **Matching rules disagree** → a blocking `PLANE_RULE_CONTRADICTION`
|
|
758
|
-
entry is emitted (the required `reason` of each matching rule rides the
|
|
759
|
-
diagnostic) and NO plane is applied — never first-match-wins.
|
|
760
|
-
- **No rule matches** → no evidence; the endpoint stays on the existing
|
|
761
|
-
channels (linked-resource inheritance, operational `global`, else
|
|
762
|
-
`PLANE_UNRESOLVED`).
|
|
763
|
-
|
|
764
|
-
Interaction with the other plane channels: the config plane participates
|
|
765
|
-
as EVIDENCE, never as a blanket override. When the plane the classifier
|
|
766
|
-
would derive for the endpoint (exactly one linked business resource, or
|
|
767
|
-
the operational `global` rule) is already derivable from the detector
|
|
768
|
-
contributions and CONTRADICTS the config plane, the compiler emits both
|
|
769
|
-
assertions so the classifier blocks with `PLANE_CONTRADICTION`; when they
|
|
770
|
-
agree, one plane remains and the endpoint resolves.
|
|
771
|
-
|
|
772
|
-
Absence of `.gateforge/planes.json` is normal and byte-identical to not
|
|
773
|
-
having this channel; a malformed document (bad JSON, unknown keys, a rule
|
|
774
|
-
without `plane`/`reason`, an absolute or `..`-escaping `match`) fails the
|
|
775
|
-
run closed at startup (exit 2).
|
|
776
|
-
|
|
777
|
-
### Review an endpoint plane
|
|
778
|
-
|
|
779
|
-
When `next` cannot resolve a route's plane, it asks which data boundary owns
|
|
780
|
-
the route and prints one command for each supported choice. Run only the
|
|
781
|
-
choice the owner has reviewed. `classify plane` accepts one repo-relative
|
|
782
|
-
router source path, one plane, and a non-empty reason:
|
|
783
|
-
|
|
784
|
-
```sh
|
|
785
|
-
gateforge classify plane 'src/routes.js' tenant \
|
|
786
|
-
--reason 'Owner review confirms tenant-owned records for this route.'
|
|
787
|
-
```
|
|
788
|
-
|
|
789
|
-
The default is a dry run: it prints the exact config diff and does not write.
|
|
790
|
-
Add `--confirm` to append the rule to an **existing**
|
|
791
|
-
`.gateforge/planes.json`. The command never creates another trust file,
|
|
792
|
-
replaces a rule, or writes an internality declaration; conflicting rules
|
|
793
|
-
must be resolved by editing the owner-reviewed config. This file is a
|
|
794
|
-
classification input, so changing it changes the trusted-policy digest; an
|
|
795
|
-
approved policy pin must be re-approved before strict gates run.
|
|
796
|
-
|
|
797
|
-
The alternative in `next` is owner-only: use the existing
|
|
798
|
-
`.gateforge/classification-policy.yml` `internalRules` declaration only when
|
|
799
|
-
the route is genuinely internal. Internal rules still require the existing
|
|
800
|
-
internality certificate; they are not overrides.
|
|
801
|
-
|
|
802
|
-
## Endpoint capability rules (`.gateforge/endpoints.json`)
|
|
803
|
-
|
|
804
|
-
Capability derivation uses detector FACTS only (method, canonical path,
|
|
805
|
-
handler simple name, schema symbols, resource linkage). A handler whose
|
|
806
|
-
logic lives behind a service call has no positive evidence and fail-closes
|
|
807
|
-
with `ENDPOINT_SEMANTICS_UNRESOLVED` — the compiler cannot see through
|
|
808
|
-
service-layer delegation, by design, and will not guess. This document is
|
|
809
|
-
the escape hatch that the blocking message names: an explicit, human
|
|
810
|
-
assertion of what an endpoint DOES.
|
|
811
|
-
|
|
812
|
-
A rule carries at least one selector (AND semantics when several) plus a
|
|
813
|
-
capability from the closed compiler vocabulary and a required non-empty
|
|
814
|
-
`reason` (the review artifact):
|
|
815
|
-
|
|
816
|
-
- `match` — repo-root-relative glob on the ROUTER SOURCE FILE path;
|
|
817
|
-
- `handlers` — globs on the handler SIMPLE name (case-sensitive; a route
|
|
818
|
-
with no handler symbol never matches);
|
|
819
|
-
- `paths` — globs on the canonical path (`/analytics/**`; must start
|
|
820
|
-
with `/`);
|
|
821
|
-
- `method` — optional exact verb (`GET`…`DELETE`, never `ANY`).
|
|
822
|
-
|
|
823
|
-
```json
|
|
824
|
-
{
|
|
825
|
-
"rules": [
|
|
826
|
-
{
|
|
827
|
-
"handlers": ["get_analytics_*"],
|
|
828
|
-
"capability": "crud-read",
|
|
829
|
-
"reason": "delegates to analytics_service; declared by the service owner"
|
|
830
|
-
},
|
|
831
|
-
{
|
|
832
|
-
"match": "backend/api/v1/accounts.py",
|
|
833
|
-
"method": "DELETE",
|
|
834
|
-
"capability": "crud-archive",
|
|
835
|
-
"reason": "sets archived_at via the service; soft delete by design"
|
|
836
|
-
}
|
|
837
|
-
]
|
|
838
|
-
}
|
|
839
|
-
```
|
|
840
|
-
|
|
841
|
-
Resource linkage accepts the path-derived name or its singular form with
|
|
842
|
-
one trailing `s` removed: `/items/{id}` can link to model `item`.
|
|
843
|
-
Exactly one discovered model must match, and a schema symbol or whole
|
|
844
|
-
handler-name word must corroborate it. Name coincidence alone never links;
|
|
845
|
-
if both `items` and `item` exist, the compiler blocks the ambiguity rather
|
|
846
|
-
than preferring one.
|
|
847
|
-
|
|
848
|
-
Evaluation per endpoint identity, deterministic and fail closed:
|
|
849
|
-
|
|
850
|
-
- **All matching rules agree** → the capability is declared (composed
|
|
851
|
-
with detected ones; overlapping agreeing rules are one declaration).
|
|
852
|
-
A declared `crud-delete`/`crud-archive` on a DELETE endpoint resolves
|
|
853
|
-
the archive-vs-hard question the linked model could not prove.
|
|
854
|
-
The declaration also supplies that evidence to the linked model's
|
|
855
|
-
classifier. Conflicting model/route semantics still block; an archive
|
|
856
|
-
declaration still needs the model's archive-state evidence.
|
|
857
|
-
- **Matching rules disagree** → a blocking
|
|
858
|
-
`ENDPOINT_CAPABILITY_CONTRADICTION` entry names every matching rule,
|
|
859
|
-
its capability, and its reason; NOTHING is applied — never
|
|
860
|
-
first-rule-wins.
|
|
861
|
-
- **No rule matches** → the endpoint stays on detector-fact evidence
|
|
862
|
-
only (and blocks if that is nothing).
|
|
863
|
-
|
|
864
|
-
The vocabulary is the compiler's own: `health-operations`,
|
|
865
|
-
`auth-session`, `webhook-callback`, `workflow-command`, `task-async`,
|
|
866
|
-
`search-query`, `validation-preview`, `file-transfer`, `ai-automation`,
|
|
867
|
-
`realtime`, `crud-create`, `crud-read`, `crud-update`, `crud-delete`,
|
|
868
|
-
`crud-archive`. Absence of the file is normal and byte-identical to not
|
|
869
|
-
having the channel; a malformed document fails the run closed at startup
|
|
870
|
-
(exit 2).
|
|
871
|
-
|
|
872
|
-
### Answering `ENDPOINT_SEMANTICS_UNRESOLVED`
|
|
873
|
-
|
|
874
|
-
When `gateforge next` prints that code, the run has found an endpoint and
|
|
875
|
-
cannot tell what it DOES; the remedy is an owner-authored rule, not
|
|
876
|
-
another read-only command. The printed block carries the whole answer for
|
|
877
|
-
THAT endpoint: its own method and canonical path as the selectors, the two
|
|
878
|
-
owner-chosen fields (`capability`, `reason`) marked in the snippet, and the
|
|
879
|
-
allowed values. Answer it by replacing the two marked fields and writing
|
|
880
|
-
the file (append the rule to `rules` when the file already exists), then
|
|
881
|
-
prove it applied with the printed `gateforge explain <endpoint-id>` — its
|
|
882
|
-
`capabilities:` line names the capability and its trace says
|
|
883
|
-
`endpoints.json`.
|
|
884
|
-
|
|
885
|
-
The shortest useful file — one exact endpoint, no glob at all — is:
|
|
886
|
-
|
|
887
|
-
```json
|
|
888
|
-
{
|
|
889
|
-
"rules": [
|
|
890
|
-
{
|
|
891
|
-
"method": "DELETE",
|
|
892
|
-
"paths": ["/items/{item_id}"],
|
|
893
|
-
"capability": "crud-archive",
|
|
894
|
-
"reason": "The handler sets archived_at; the row is never removed."
|
|
895
|
-
}
|
|
896
|
-
]
|
|
897
|
-
}
|
|
898
|
-
```
|
|
899
|
-
|
|
900
|
-
`paths` patterns are globs on the canonical path (`*` within a segment,
|
|
901
|
-
`**` across segments, `?` one character); a path with no wildcard is an
|
|
902
|
-
exact selector, which is what you want for one route. On a `DELETE`, the
|
|
903
|
-
capability is the archive-vs-hard answer (`crud-archive` /
|
|
904
|
-
`crud-delete`) and nothing else resolves that block; on any other verb it
|
|
905
|
-
is the closed vocabulary above. A rule left with a placeholder capability
|
|
906
|
-
fails the run closed at startup (exit 2) with the allowed values named.
|
|
907
|
-
|
|
908
|
-
## Proposing planes at init (`gateforge init --planes`)
|
|
909
|
-
|
|
910
|
-
`gateforge init --planes` runs discovery over the repo's own include and
|
|
911
|
-
exclude configuration and PROPOSES `.gateforge/planes.json` from the
|
|
912
|
-
directories the discovered tables live in: one non-overlapping `match`
|
|
913
|
-
glob per model tree, `master` for trees whose path names a control-plane
|
|
914
|
-
segment (`admin`, `master`, `control`, `root`, `operator`), `tenant`
|
|
915
|
-
otherwise, and a reason on every rule naming the directory it was
|
|
916
|
-
inferred from. The keyword mapping IS a heuristic — that is why the file
|
|
917
|
-
is a review artifact: it is written only after explicit consent (flag,
|
|
918
|
-
or the TTY prompt), only when absent, and must be reviewed before the
|
|
919
|
-
next run reads it. Tables under test directories are excluded from the
|
|
920
|
-
proposal (fixtures are not business surface); they stay plane-less and
|
|
921
|
-
gate-visible. Non-interactive runs without `--planes` propose nothing
|
|
922
|
-
and print the tip.
|
|
923
|
-
|
|
924
|
-
## test-gates protocol (G6 surface)
|
|
925
|
-
|
|
926
|
-
`gateforge test-gates` writes a run state directory (default
|
|
927
|
-
`.gateforge/test-gates/`, `--out` overrides):
|
|
928
|
-
|
|
929
|
-
| File | Content |
|
|
930
|
-
| --- | --- |
|
|
931
|
-
| `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`). |
|
|
932
|
-
| `obligations.json` | Every obligation the suite must cover, with pin #2 fingerprint and resource source/location. |
|
|
933
|
-
| `env.json` | `GATEFORGE_RUN_ID`, `GATEFORGE_RUN_TOKEN`, `GATEFORGE_STATE_DIR`, `GATEFORGE_OBLIGATIONS`, `GATEFORGE_WITNESS_URL`. |
|
|
934
|
-
| `claims.json` / `records.json` | Reporter output consumed by the verifier (written by the suite). |
|
|
935
|
-
| `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. |
|
|
936
|
-
| `report.json` | Canonical json-format run report after evaluation. |
|
|
937
|
-
| `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. |
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
The legacy suite command (`--suite`) runs with those env vars; its reporter
|
|
941
|
-
extracts claims from `{type: 'gateforge', description: '<obligation id>'}`
|
|
942
|
-
annotations and posts evidence through the witness service (pin #7, header
|
|
943
|
-
`x-gateforge-run: <token>`; `GATEFORGE_WITNESS_URL` is set when a witness
|
|
944
|
-
service URL is provided via `--witness-url`). `gateforge check` reads
|
|
945
|
-
run-state evidence but takes native bindings only from `claimInventory`
|
|
946
|
-
in an execution result authenticated by a receipt for the current inputs;
|
|
947
|
-
it combines those with the current tracked `test-map.yml`. Raw
|
|
948
|
-
`claims.json` cannot add current declarations. Receipts created before
|
|
949
|
-
`claimInventory` existed remain valid, but supply no native bindings.
|
|
950
|
-
Records whose provenance does not verify never satisfy (GF-23). The
|
|
951
|
-
legacy escape hatch can never redefine the strict gate's expected cases
|
|
952
|
-
or turn an arbitrary exit-zero command into E2E proof — the hook and CI
|
|
953
|
-
run `check --staged/--changed --require-e2e`, which accept only supervised
|
|
954
|
-
receipts.
|
|
955
|
-
|
|
956
|
-
Before supervised execution, Gateforge compares Playwright's scrubbed
|
|
957
|
-
inventory with a second `--list` using the safe run variables supplied to
|
|
958
|
-
the runner. A difference stops the run before tests start and names each
|
|
959
|
-
project, file, and title present in only one inventory. Static discovery
|
|
960
|
-
also warns when `process.env.GATEFORGE_*` controls test registration.
|
|
961
|
-
|
|
962
|
-
### Provenance trust model (GF-23, audited 2026-08-31, three rounds)
|
|
963
|
-
|
|
964
|
-
`records.json` and `manifest.json` live in the suite-writable state
|
|
965
|
-
directory, so NEITHER proves anything on its own: a hostile suite can
|
|
966
|
-
fabricate records (the id hash `recordIdOf` is public) and can write any id
|
|
967
|
-
list into the manifest. Two layers close this.
|
|
968
|
-
|
|
969
|
-
**Layer 1 — trust follows origin.** A record's `origin` is part of its
|
|
970
|
-
hashed identity:
|
|
971
|
-
|
|
972
|
-
- `suite-submitted` (`ui.action`, `ui.visible-result` POSTed by the
|
|
973
|
-
suite): the witness RECEIVED the assertion but cannot verify it
|
|
974
|
-
happened — the suite owns the browser and holds the run token. These
|
|
975
|
-
records are stamped `trust: 'claimed'` at issuance and only ANCHOR a
|
|
976
|
-
claim (entity + operation).
|
|
977
|
-
- `engine-observed` (`persistence.entity`, stamped by the witness from
|
|
978
|
-
its own adapter read): the only `trust: 'witnessed'` origin. This is
|
|
979
|
-
where `satisfied` is earned — the engine requires a witnessed
|
|
980
|
-
persistence record for the claimed entity, so fabricated outcomes can
|
|
981
|
-
never satisfy.
|
|
982
|
-
|
|
983
|
-
**Supervised session binding (Phase 1).** The trusted reporter opens ONE
|
|
984
|
-
witness session per started test (`runId`, `sessionId`, `testId`,
|
|
985
|
-
`worker`), and the evidence fixture's five primitives (`ui`, `visible`,
|
|
986
|
-
`persistence`, `http`, `finalize`) submit only under that OPEN session:
|
|
987
|
-
the witness rejects submissions without a session and forces each record's
|
|
988
|
-
testId onto the session's supervisor-registered value; sealing rejects all
|
|
989
|
-
late submissions. Every UI action runs inside a witness-recorded
|
|
990
|
-
observation interval (supervisor-issued session clock), so proxy exchanges
|
|
991
|
-
observed outside the action's interval — direct setup calls, stray
|
|
992
|
-
navigation — are never credited as browser evidence. For a mutation whose
|
|
993
|
-
journey collects input in the UI, the `ui.action` record's `fields` are
|
|
994
|
-
the declared input, and the independent engine-observed persistence read
|
|
995
|
-
must echo those values EXACTLY on the same entity identity: a mismatched
|
|
996
|
-
echo fails the obligation with `EVIDENCE_VALUE_MISMATCH` even when the
|
|
997
|
-
status was 2xx. Primitive receipts are frozen and branded — hand-rolled
|
|
998
|
-
forgeries fail closed (GF-22).
|
|
999
|
-
|
|
1000
|
-
**UI-semantic `crud:*` contracts fail closed (audit round 5).** The suite
|
|
1001
|
-
still owns the browser, so a claimed UI action cannot be verified at the
|
|
1002
|
-
DOM level; the namespace advertises no gradable contract. The gradable
|
|
1003
|
-
surface is the lifecycle-gated `persistence:*` namespace, graded on the
|
|
1004
|
-
witness's OWN engine-side observation
|
|
1005
|
-
(`{resourceId, entityId, found, fields, before}`) with expectations that
|
|
1006
|
-
NEVER come from the tested suite:
|
|
1007
|
-
|
|
1008
|
-
- `persistence:create`: an engine-side id-set PRE-OBSERVATION (`POST
|
|
1009
|
-
/witness/pre-observation`, backed by the adapter's optional `list`)
|
|
1010
|
-
shows the entity absent before the action; the post-read shows it
|
|
1011
|
-
present.
|
|
1012
|
-
- `persistence:update`: an engine-side entity pre-observation exists,
|
|
1013
|
-
the engine observed an actual before/after field delta, AND the delta
|
|
1014
|
-
touches at least one classification-declared `updateableFields` entry
|
|
1015
|
-
(audit round 6) — bookkeeping drift such as `updated_at` alone never
|
|
1016
|
-
satisfies, and a resource whose classification omits
|
|
1017
|
-
`updateableFields` fails closed for update obligations.
|
|
1018
|
-
- `persistence:read`: the entity is present in the engine-observed state.
|
|
1019
|
-
- `persistence:delete`: a hard delete observes the entity ABSENT; an
|
|
1020
|
-
archive observes it present and matching the classification's
|
|
1021
|
-
owner-declared `archiveFields` (e.g. `{status: archived}`) — the suite
|
|
1022
|
-
cannot bless an unarchived entity by declaring its current state as
|
|
1023
|
-
the expected result.
|
|
1024
|
-
|
|
1025
|
-
An adapter may declare an optional literal `fields: [...]` projection.
|
|
1026
|
-
Anchored persistence fails before consuming its pre-observation when the
|
|
1027
|
-
action changes a field outside that projection. `check` also reports
|
|
1028
|
-
model updateable fields missing from a statically readable projection.
|
|
1029
|
-
Adapters without this metadata keep their existing behavior.
|
|
1030
|
-
|
|
1031
|
-
Presence alone, contradicted observations, missing pre-observations, or
|
|
1032
|
-
absent deltas grade `invalid` — even when every provenance check passes.
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
When the complete endpoint inventory contains no update-capable route linked
|
|
1036
|
-
to the resource, the failure also says that no observed UI request writes the
|
|
1037
|
-
fields and the feature may be unreachable from the UI. This is diagnostic only;
|
|
1038
|
-
it does not change the verdict.
|
|
1039
|
-
|
|
1040
|
-
**Layer 2 — versioned attestation binding evidence to tested inputs.** A witnessed record is authorized only by ONE validated
|
|
1041
|
-
v2 envelope that simultaneously matches its run id, the expected input
|
|
1042
|
-
digest, the required invocation identity, and its record id:
|
|
1043
|
-
|
|
1044
|
-
- the durable manifest `attestation` (`attestationVersion: 2` with
|
|
1045
|
-
`runId`, `invocationId`, `inputDigest`, sorted unique `recordIds`, and
|
|
1046
|
-
`mac` — HMAC-SHA256 over the domain-tagged body
|
|
1047
|
-
`gateforge.ledger.v2`), written by the witness at shutdown from its
|
|
1048
|
-
FROZEN bound context plus EXACTLY its own ledger (pre-seeded forged
|
|
1049
|
-
ids are discarded, never signed), or
|
|
1050
|
-
- the live `GET /ledger-attestation` response: the SAME signed object,
|
|
1051
|
-
fetched (and MAC-verified) by `test-gates` from a still-running wired
|
|
1052
|
-
witness and persisted into the manifest as the durable fallback
|
|
1053
|
-
before the witness stops (401 to the run token alone).
|
|
1054
|
-
|
|
1055
|
-
The `inputDigest` is a deterministic snapshot of everything the
|
|
1056
|
-
pipeline examines (all Git-tracked files, nonignored untracked files,
|
|
1057
|
-
configured scan inputs even when ignored, `.gateforge.yml`,
|
|
1058
|
-
policies/classification/pack configs, adapters, local plugin modules,
|
|
1059
|
-
manifests/lockfiles, effective obligations/classifications/routes —
|
|
1060
|
-
`packages/cli/src/input-snapshot.ts`). A deleted file, an untracked
|
|
1061
|
-
file, a policy edit, or a lockfile change all move the digest, so old
|
|
1062
|
-
evidence blocks after any source/configuration change. The
|
|
1063
|
-
`invocationId` is fresh per `test-gates` run, so a restored old bundle
|
|
1064
|
-
cannot satisfy a new invocation. `check` (no suite) reuses a completed
|
|
1065
|
-
signed run only for byte-identical inputs — it never equates its own
|
|
1066
|
-
fresh manifest UUID with the evidence run UUID.
|
|
1067
|
-
|
|
1068
|
-
The witness never signs what a suite-writable file says: `test-gates`
|
|
1069
|
-
binds the context with authenticated `POST /run-context` (run token
|
|
1070
|
-
AND verifier key) BEFORE the suite starts, and the witness freezes it
|
|
1071
|
-
in memory. Binding is allowed only before any observation or issuance;
|
|
1072
|
-
a used witness answers 409, an identical rebind is idempotent, any
|
|
1073
|
-
change is 409, and an unbound witness issues no attestation. A proxy
|
|
1074
|
-
exchange in flight at bind time refuses the bind, and observations
|
|
1075
|
-
that completed before binding are never consumable under the new
|
|
1076
|
-
context.
|
|
1077
|
-
|
|
1078
|
-
The legacy v1 `recordIdsMac` (HMAC over `{runId, recordIds}` with no
|
|
1079
|
-
digest binding) NEVER authorizes evidence — even when it verifies.
|
|
1080
|
-
Invalid durable envelopes contribute nothing; live and durable
|
|
1081
|
-
contexts are validated independently and never merged; mismatches
|
|
1082
|
-
surface as explicit `evidence-context` blockers (missing vs malformed
|
|
1083
|
-
vs forged stay distinguished) that waivers cannot hide.
|
|
1084
|
-
|
|
1085
|
-
The key comes from one trusted source: the protected
|
|
1086
|
-
`GATEFORGE_WITNESS_VERIFIER_KEY` environment variable, an external
|
|
1087
|
-
owner-only key ring named by `GATEFORGE_WITNESS_VERIFIER_KEY_FILE`, or the
|
|
1088
|
-
default `$XDG_CONFIG_HOME/gateforge/verifier-keyring.json` (otherwise
|
|
1089
|
-
`~/.config/gateforge/verifier-keyring.json`) when present. Do not set both
|
|
1090
|
-
explicit sources. The file must be a regular file owned by the current
|
|
1091
|
-
user, with mode `0600` or stricter, and it must not be a symlink. Store
|
|
1092
|
-
it outside the candidate repository, Git directory, run state, `--out`
|
|
1093
|
-
directory, workspace, and receipt-artifact directory. Gateforge refuses
|
|
1094
|
-
unsafe paths and permissions. File mode is not supported on Windows;
|
|
1095
|
-
use the protected environment source there.
|
|
1096
|
-
Create and rotate keys only after an owner review:
|
|
1097
|
-
|
|
1098
|
-
If you already use an environment key, keep it in the protected environment
|
|
1099
|
-
while you import it. Do not place key material in shell history or argv.
|
|
1100
|
-
|
|
1101
|
-
```sh
|
|
1102
|
-
gateforge key create --confirm
|
|
1103
|
-
gateforge key import-env --confirm
|
|
1104
|
-
unset GATEFORGE_WITNESS_VERIFIER_KEY
|
|
1105
|
-
gateforge key rotate --confirm
|
|
1106
|
-
gateforge key retire --key-id key-old-id --confirm
|
|
1107
|
-
```
|
|
1108
|
-
|
|
1109
|
-
Create the parent directory first. `key import-env` retains an existing
|
|
1110
|
-
environment key under its stable id before switching to the file source.
|
|
1111
|
-
Key commands print only a non-secret
|
|
1112
|
-
key id. Rotation keeps old keys so their receipts still verify. Retire an
|
|
1113
|
-
old key only when its receipts no longer need to verify. Gateforge stores
|
|
1114
|
-
the key id, not the secret, in new receipts. A receipt for a removed id
|
|
1115
|
-
fails with `KEY_UNKNOWN`. The key ring file contains raw signing keys, so
|
|
1116
|
-
protect its backups with the same care as the original.
|
|
1117
|
-
|
|
1118
|
-
`test-gates` strips both key-source variables from the suite child's
|
|
1119
|
-
environment. The supervised browser runner and candidate runtime also
|
|
1120
|
-
refuse both sources, and Gateforge does not write either value or file
|
|
1121
|
-
path into run state. The trusted witness process receives the active key
|
|
1122
|
-
to authenticate records. A suite-owned Playwright global setup therefore
|
|
1123
|
-
cannot bootstrap trusted issuance by inheriting the key — it fails closed
|
|
1124
|
-
unless an externally wired trusted witness is provided. Residuals (not
|
|
1125
|
-
eliminable by env hygiene alone): a same-uid process can read environ when yama
|
|
1126
|
-
`ptrace_scope=0`, and env vars never isolate hostile same-user OS
|
|
1127
|
-
processes — for strong isolation run the suite as a distinct user or
|
|
1128
|
-
container. File-change capture is snapshot-based, not an OS sandbox:
|
|
1129
|
-
it guards changes visible at capture points, not a malicious process
|
|
1130
|
-
that changes and restores files between snapshots.
|
|
1131
|
-
|
|
1132
|
-
### The operator's fixture/actor provider
|
|
1133
|
-
|
|
1134
|
-
A declared behavior case names a `fixture` recipe and an `actor`, and the
|
|
1135
|
-
witness — not the test suite — must materialize them before it drives the
|
|
1136
|
-
case. `GATEFORGE_FIXTURE_PROVIDER` names the module that does that. The
|
|
1137
|
-
CLI-spawned witness loads it at startup; a repository that declares no
|
|
1138
|
-
behavior cases is unaffected.
|
|
1139
|
-
|
|
1140
|
-
The module's default export is `{ prepare(input), release(leaseId),
|
|
1141
|
-
resolveCredential(credentialRef) }`:
|
|
1142
|
-
|
|
1143
|
-
- `prepare` provisions the case's subjects and actor identities and returns
|
|
1144
|
-
`{ leaseId, namespace, subjects, actors }`. Subjects are server-issued
|
|
1145
|
-
identities; a lease namespace keeps concurrent cases isolated.
|
|
1146
|
-
- `release` drops what that lease provisioned.
|
|
1147
|
-
- `resolveCredential` turns a lease `credentialRef` into request material.
|
|
1148
|
-
It runs in the witness process, so a secret stays there; a declared
|
|
1149
|
-
`credentialVariant: valid` that cannot resolve fails closed rather than
|
|
1150
|
-
degrading.
|
|
1151
|
-
|
|
1152
|
-
The provider is ENGINE-SIDE code and is the only caller of its own
|
|
1153
|
-
provisioning HTTP calls — the suite never imports it, and nothing it
|
|
1154
|
-
returns can mint evidence, only supply the subjects a case drives. Because
|
|
1155
|
-
of that, a repository should exclude the provider from its product scan
|
|
1156
|
-
scope (`.gateforge.yml` `project.paths.exclude`, matching
|
|
1157
|
-
`classification-policy.yml` `scanRoots`): its calls are fixture
|
|
1158
|
-
provisioning, not application call sites, and scanning them reports the
|
|
1159
|
-
engine's own traffic as unresolved frontend targets. See
|
|
1160
|
-
`example/behavior/fixtures/fixture-provider.mjs` for a working provider.
|
|
1161
|
-
|
|
1162
|
-
Fail closed: without the key, or when no envelope validates for the
|
|
1163
|
-
expected context, every witnessed record demotes to claimed-tier
|
|
1164
|
-
(blocking, never satisfied).
|
|
1165
|
-
|
|
1166
|
-
### Evidence migration (v1 → v2, no auto-migration)
|
|
1167
|
-
|
|
1168
|
-
- Existing evidence bundles need a FRESH run: there is no command
|
|
1169
|
-
that signs old records into the new format without observations, and
|
|
1170
|
-
none will be added (signing old records would certify untested code).
|
|
1171
|
-
- Gate receipts (ADR 0005 D3) are a separate versioned, domain-separated
|
|
1172
|
-
envelope — never a repurposed v2 attestation, and never a mutable
|
|
1173
|
-
`passed` flag on a claim. `check --require-e2e` rejects old record
|
|
1174
|
-
bundles that lack the required complete-run receipt.
|
|
1175
|
-
- Policies and waivers keep their explicit semantics: snapshot binding
|
|
1176
|
-
never rewrites their IDs to evade blockers — and in strict E2E mode an
|
|
1177
|
-
in-scope waived/baselined E2E obligation is not proof at all
|
|
1178
|
-
(`ENFORCEMENT_UNTRUSTED`).
|
|
1179
|
-
- External witness setup: start `gateforge-witness` (or `startWitness`)
|
|
1180
|
-
with the run id/token from a TRUSTED parent env carrying
|
|
1181
|
-
`GATEFORGE_WITNESS_VERIFIER_KEY`, pass `--witness-url`/`--run-token`
|
|
1182
|
-
to `test-gates`, and start a FRESH witness per invocation (a witness
|
|
1183
|
-
used by an older invocation rejects binding with 409).
|
|
1184
|
-
- Non-Git checkouts keep discovery but fail evidence authorization
|
|
1185
|
-
with a `snapshot-unavailable` diagnostic; submodules, escaping
|
|
1186
|
-
symlinks, and `--out` overlapping source fail closed with explicit
|
|
1187
|
-
diagnostics.
|
|
1188
|
-
|
|
1189
113
|
## Limitations
|
|
1190
114
|
|
|
1191
115
|
- Staged candidates containing symlinks or submodules (and unmerged index
|
|
1192
116
|
entries) are typed blocks in `check --staged` and `broker commit` —
|
|
1193
117
|
explicit, never fallbacks; support is not implemented.
|
|
1194
|
-
- A Playwright config with NO named project
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
118
|
+
- A Playwright config with NO named project: `tests discover` prints an
|
|
119
|
+
error line naming the config and the fix
|
|
120
|
+
(`projects: [{ name: 'chromium' }]`) and still writes the catalog, and
|
|
121
|
+
`enforcement doctor` fails the `playwright-projects` row — `test-gates`
|
|
122
|
+
needs a named project.
|
|
123
|
+
- Gateforge reads the FIRST of `playwright.config.{ts,mts,cts,js,mjs,cjs}`
|
|
124
|
+
at the repository root; a suffixed config such as
|
|
125
|
+
`playwright.config.e2e.js` is not read — rename it to
|
|
126
|
+
`playwright.config.js` if it is the suite to prove.
|
|
1198
127
|
- Run-state hygiene is enforced, not forgiven: a committed run-state
|
|
1199
|
-
directory
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
`
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
128
|
+
directory or include globs that omit the spec directories fail closed —
|
|
129
|
+
gitignore `.gateforge/test-gates/` and include the spec globs.
|
|
130
|
+
- Consumer-worktree migration and the server-side GitLab enforcement
|
|
131
|
+
settings are pending owner actions — the complete template and settings
|
|
132
|
+
list ship from `init --blocking`, but a local simulation does not
|
|
133
|
+
complete a server rollout.
|
|
134
|
+
|
|
135
|
+
Every limitation with its full context: [Limitations](guides/REFERENCE.md#limitations).
|
|
136
|
+
|
|
137
|
+
## Existing repositories
|
|
138
|
+
|
|
139
|
+
On a repository that already has code, `gateforge check` reports
|
|
140
|
+
today's findings as blocking debt from day one. The sanctioned
|
|
141
|
+
one-time bulk-add is `gateforge adopt`: it records today's blocking
|
|
142
|
+
findings as forgiven (shrink-only, once per repository) and applies
|
|
143
|
+
the blocking wiring. The full adopt contract, and the baseline
|
|
144
|
+
commands that shrink the recorded set: [Reference](guides/REFERENCE.md).
|
|
145
|
+
Under `strictE2E`, an adopted E2E obligation still blocks
|
|
146
|
+
as soon as a change touches it — adoption forgives today's
|
|
147
|
+
debt, never new work.
|
|
1208
148
|
|
|
1209
149
|
## Development
|
|
1210
150
|
|