@gate-forge/cli 0.10.1 → 0.10.3
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/CHANGELOG.md +35 -0
- package/README.md +2 -0
- package/dist/adoption-mode.d.ts +37 -0
- package/dist/adoption-mode.d.ts.map +1 -0
- package/dist/adoption-mode.js +101 -0
- package/dist/adoption-mode.js.map +1 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +185 -15
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/enforcement.d.ts +19 -0
- package/dist/commands/enforcement.d.ts.map +1 -1
- package/dist/commands/enforcement.js +69 -3
- package/dist/commands/enforcement.js.map +1 -1
- package/dist/commands/explain.js +3 -1
- package/dist/commands/explain.js.map +1 -1
- package/dist/commands/pre-commit.d.ts.map +1 -1
- package/dist/commands/pre-commit.js +1 -0
- package/dist/commands/pre-commit.js.map +1 -1
- package/dist/commands/test-gates.d.ts +12 -1
- package/dist/commands/test-gates.d.ts.map +1 -1
- package/dist/commands/test-gates.js +285 -11
- package/dist/commands/test-gates.js.map +1 -1
- package/dist/evaluate.d.ts +34 -0
- package/dist/evaluate.d.ts.map +1 -1
- package/dist/evaluate.js +57 -29
- package/dist/evaluate.js.map +1 -1
- package/dist/execution.d.ts +26 -2
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +80 -2
- package/dist/execution.js.map +1 -1
- package/dist/input-snapshot.d.ts.map +1 -1
- package/dist/input-snapshot.js +20 -1
- package/dist/input-snapshot.js.map +1 -1
- package/dist/runtime.d.ts +29 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +39 -0
- package/dist/runtime.js.map +1 -1
- package/dist/scope.d.ts +81 -0
- package/dist/scope.d.ts.map +1 -1
- package/dist/scope.js +101 -2
- package/dist/scope.js.map +1 -1
- package/dist/staged-candidate.d.ts +12 -0
- package/dist/staged-candidate.d.ts.map +1 -1
- package/dist/staged-candidate.js +27 -6
- package/dist/staged-candidate.js.map +1 -1
- package/dist/test-infrastructure.d.ts +32 -0
- package/dist/test-infrastructure.d.ts.map +1 -0
- package/dist/test-infrastructure.js +125 -0
- package/dist/test-infrastructure.js.map +1 -0
- package/guides/QUICKSTART.md +20 -7
- package/guides/REFERENCE.md +160 -0
- package/guides/TEST-ENVIRONMENT.md +3 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
## 0.10.3
|
|
5
|
+
|
|
6
|
+
### Fixed
|
|
7
|
+
|
|
8
|
+
- **The docs-only slice seals in a repository that ADOPTED debt.** The seal guard also required the RAW policy blocking list to be empty, and that list is the pre-baseline view: in any repository that ran `gateforge adopt` it holds the adopted classification, finding, unclassified and unresolved entries forever (measured on the repository that motivated this: 1 660 entries), so the 0.10.2 exemption could never engage outside the template fixture, whose adopted debt was missing OBLIGATIONS — none of which are blocking entries. `test-gates --changed --scope changed` refused a `docs/**.md` commit with `--scope changed produced no runnable slice` and the next `check --staged` with the stale-attestation finding, exactly as before that fix. The condition is gone, and it was the only guard term that read a pre-baseline list: a docs-only change cannot change a policy entry, and `check` grades those entries against the adopted baseline on every commit. Nothing else about the receipt moves — it still covers no obligation, one non-docs file in the change keeps today's refusal, and a repository with no adopted debt takes the identical path.
|
|
9
|
+
- **A receipt carried forward no longer reads the raw policy list either.** The same raw term gated the carry-forward over sealed candidate trees, so in an adopted repository the path could never run at all: the parent receipt was verified, the tree difference was proved to lie inside the evaluated paths, and the run still fell through to `--scope changed produced no runnable slice`. What that term has to mean is "no NEW policy debt", and the raw list cannot express it — it is never empty after adoption. It now reads the ADOPTED-baseline view through the same split `applyBaseline` grades with (`splitBlockingByBaseline`, extracted so the guard and the grading cannot disagree): an entry the adoption receipt forgives — by whole-entry fingerprint or by the classification layer's resource identity — is forgiven here too, and an entry adoption never recorded still refuses the carry-forward. Nothing else about the seal moved: the parent receipt must still verify, the two sealed trees must still differ only inside the evaluated paths, and every changed file must still have been scanned.
|
|
10
|
+
|
|
11
|
+
## 0.10.2
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- **The whole-run cap is now the operator's, and a STALL bound is ours.** `DEFAULT_RUN_TIMEOUT_MS = 30 min` was a bound nobody declared, and it killed a real 1 101-test suite that needs two hours. By default there is no whole-run cap at all: one applies only from `runtime.yml executionTimeoutSeconds` or `--run-timeout-min` (the precedence from the fix below is unchanged). What remains is a stall bound — no test has FINISHED for `runtime.yml stallTimeoutSeconds` (new key, default 15 minutes) and the run is killed and fails closed with `stalled: no test finished for 15 min (last finished: <title>, <k>/<n>)`. It rides the per-test completion signal the `--progress` stream already consumes, so there is one signal in a run, not two. The pytest/vitest/cypress runner adapters publish no per-test signal and keep a whole-run bound; the constant says so where it is declared.
|
|
16
|
+
- **Adoption mode: the first commit that wires the gate is committable through the hook, with no bypass.** The commit that introduces the gate always touches gate-defining inputs, so the evaluation expanded to every obligation while the only affordable proof of a large repository is a `--scope changed` receipt — which the hook then refused as a scope mismatch. A commit is now judged in adoption mode when, and only when, HEAD has no gate AND the candidate wires one; it is COMPUTED from the base revision, so there is no flag and no config key, and once a gate exists at HEAD the condition can never hold again. Adoption mode changes only WHICH obligations must be proven — the ones this commit newly claims — and never relaxes `CHANGE_UNMAPPED`, the owner-approved policy pin, the receipt's candidate-tree binding, or anything in `.gateforge/waivers/`. `TEST-ENVIRONMENT.md` and `QUICKSTART.md` now name `check --staged`, the command the generated hook actually runs.
|
|
17
|
+
- **The pack configs and the generated gate wiring are owner-pinned.** `.gateforge/planes.json`, `endpoints.json`, `http-clients.json` and `fastapi.json` are classified as owner-owned policy inputs, which exempts them from product attribution ONLY while the approved digest binds their bytes; nothing bound them, so a candidate could narrow `clientScanRoots` — deleting obligations — in the same commit and the pin still matched. The generated `.gateforge/hooks/` and `.gateforge/ci/` wiring are bound for the same reason: deleting the generated hook is a policy-revision change, not a way back into adoption mode. **Upgrading:** a repository that ships a pack config or the generated gate wiring must re-pin once (`gateforge enforcement pin --pin-file <path> --confirm`); a repository that has neither keeps a byte-identical digest, because an absent file contributes no entry and no absence marker.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- **A documentation-only commit can re-seal its evidence again.** After a repository's first witnessed adoption commit, every later commit whose WHOLE changed set is `docs/**.md` was unblockable: `check --staged` refused it with `evidence-context: durable attestation inputDigest does not match the current input snapshot` (the previous run's envelope is bound to the previous bytes), and the prescribed repair `test-gates --changed --scope changed` refused with `--scope changed produced no runnable slice` — nothing ran, so no receipt was sealed, so the next check saw the same stale envelope. The only remaining route was a full-scope run (measured: 1 101 planned tests, 136 failures at 439, no seal). The engine's OWN docs-only exemption now extends to evidence: when it is the scope decision, the scoped run seals a receipt for the current candidate with ZERO records — `scope: 'changed'`, `docsOnly: true`, an empty covered set, a `docs-only-slice` execution result, and the same input-digest, candidate-tree and trusted-policy bindings as any receipt. The slice also REPLACES the run's evidence state (empty ledger, empty claims, a manifest with no attestation), because a run that executed no test witnessed no record; that is what removes the stale-digest finding. It proves nothing: a `docsOnly` receipt is a claim the commit gate RECOMPUTES from its own changed set (`EVIDENCE_STALE` when they differ), its empty covered set satisfies no obligation, and a later product change has a different input digest and still needs its own run. Unchanged everywhere else: one non-docs file in the change — including a Markdown file outside `docs/` — keeps today's refusal byte-for-byte, and `gateforge init --docs-exclude` is not involved.
|
|
22
|
+
- A repository's OWN test infrastructure is attributable under `enforcement.strictE2E`, so the first commit that wires the gate no longer reports every real file as `CHANGE_UNMAPPED`. Four independent gaps, all measured on a 2 055-test repository where the adoption commit produced 13 of them: **every** Playwright configuration at the repository root (including the suffixed `dev-stack` / `headed-run` wrappers) and every configuration a `package.json` script names is now a runner configuration — only the one that resolved was, so a sibling wrapper was structurally unattributable; a helper a catalog test IMPORTS is test infrastructure, by import graph rather than by folder name, so a `support/` folder nothing imports gets no free pass; and the files the staged runtime document NAMES are attributable. A `docs/**.md` edit in a MIXED commit stays blocked by design, and its message now names the route that works: commit the documentation on its own.
|
|
23
|
+
- **The test-infrastructure import graph also roots at the RUNNER CONFIGURATIONS.** It started at the catalog's own test files, so a file a configuration NAMES but no test imports — a custom `reporter`, a `globalSetup`/`globalTeardown`, a project `storageState`, a `require.resolve('./…')` — was structurally unattributable, and a real first adoption commit was refused with `CHANGE_UNMAPPED` for exactly that file. Every resolved configuration (including the suffixed wrappers, which the runner can be pointed at) is now a root: the files it names by a relative path string literal that resolves to an existing repository file are attributable, together with their own import closure, read through the SAME parser and the SAME import resolution as every other graph edge. A string that resolves to nothing contributes nothing — a declaration is read as a fact, never as a candidate-supplied string — and the walk keeps its own scan state, so a runner configuration that half-parses adds no catalog row. Fail-open as before: a budget-cut graph attributes nothing.
|
|
24
|
+
- **A directory in a runtime command is no longer a "runtime input" that refuses the whole run.** The reader that resolves a `runtime.yml` command's argv tokens accepted ANY path that existed, and a directory exists: `npm ci --prefix e2e` or `docker compose … --project backend` therefore bound a directory as a runtime input, and the input snapshot — which exists precisely to bind FILE bytes — rejected the run with `unsupported input snapshot: input snapshot rejects non-file input 'e2e'` (exit 2 on `check --changed`). 0.10.1 had no runtime inputs at all, so an upgrade turned a green repository red for a directory the owner never declared. The reader now stats each token and accepts a regular file only, exactly as its name says; a file token is still a runtime input and keeps its attribution, the scope expansion and its place in the snapshot.
|
|
25
|
+
- The files the staged runtime document NAMES — a `scripts/e2e/*` runner, a compose override, an `.env` in `env_files` — are RUNTIME inputs: attributable, scope-expanding, and part of the input snapshot, so a sealed receipt binds their bytes and an UNDECLARED stack file still blocks. They are deliberately NOT added to the owner-approved policy digest: a port or a base URL changes far too often to justify a re-pin, so binding them through the snapshot is the honest place. A declared file that does not exist yet is recorded as an explicit absence, so creating it later changes the receipt's identity.
|
|
26
|
+
- The static test catalog no longer turns a file the runner's OWN configuration disclaims into a blocking inventory gap. A spec matched by a project's `testIgnore`, or sitting outside every project's `testDir`, becomes no catalog row at all, so one folder of dead duplicate specs can no longer make a whole repository unsealable (`inventoryComplete: false` → `TEST_INVENTORY_INCOMPLETE` on every run). A file INSIDE a declared `testDir` that no selection claims is a possibly misplaced test and still blocks. Every scope read stays fail-open: a selection that cannot be read faithfully claims every file.
|
|
27
|
+
- Deleting test files no runner ever collected is no longer reported as an unclassified product change. A deletion cannot introduce behaviour, and a file no runner collects is not a test file, so it neither expands the evaluation scope nor blocks. Deleting a file a runner DOES collect keeps every other rule.
|
|
28
|
+
- `gateforge test-gates` honours the whole-run budget its own `runtime.yml` declares. `executionTimeoutSeconds` was read by the commit hook and ignored by the command it is written for, so a repository declaring 3600 s was killed at the 30-minute default. An explicit `--run-timeout-min` still wins; an unreadable runtime document keeps the default bound.
|
|
29
|
+
- `gateforge test-gates` names the cause when its policy digest disagrees with the owner-approved pin. It digests the WORKING TREE while `check --staged` digests the STAGED INDEX, so while a policy input is modified-but-unstaged the two compute different digests and no single pin satisfies both — and the remedy the commit gate prints was the command this refusal blocked. The diagnostic now names the differing policy inputs and a remedy that clears it.
|
|
30
|
+
- `gateforge enforcement pin` prints the command that loads the file it just wrote. Every command reads the pin once at process start, so a shell holding the previous digest read exactly like "my pin did not take".
|
|
31
|
+
- **Adoption mode no longer accepts the receipt and then exits 1 anyway.** The scoped receipt was accepted, but the adoption commit still failed: its gate-defining inputs (manifest, runner configuration, mapping sidecar) expand the evaluation to full scope, so every UNTOUCHED pre-existing obligation without evidence graded blocking `missing` under `strictE2E` — and the adopted baseline that covers exactly that debt was re-graded too, because the forgiveness required a change set of Gateforge-owned policy inputs ONLY, which is a set the commit that WIRES the gate can never be. The baseline now also survives the re-grade when the change set is product-behaviour-neutral (every changed file is a policy input, a gate-defining input, a catalog test file, test infrastructure, a runtime-declared input or `docs/**.md`, and NO discovered resource's source is in it), the candidate IS an adoption commit (still computed from the base revision — no flag, no config key), and the owner pin is enforced on the same condition as before. One changed product source, one commit after the first, or one missing pin denies all three and the debt blocks exactly as before. An owner waiver is still never forgiveness.
|
|
32
|
+
- **A worktree run and a worktree check are ONE input identity again.** `gateforge run` sealed its receipt with the declared `prepare.reuse` roots bound in the gate context, but a standalone `gateforge check --require-e2e` recomputed the identity WITHOUT them — so in every repository whose `runtime.yml` declares reuse roots, the pair a consumer is told to run (`gateforge run`, then `gateforge check --require-e2e`) failed closed on an UNCHANGED worktree with `evidence-context: durable attestation inputDigest does not match the current input snapshot`. The rule — an explicit digest, else the declared roots, else nothing — now lives in ONE resolver (`resolveRuntimeReuseDigest`) that `computeInputSnapshot` calls itself, so the run, `check`, `next` and `tests` cannot disagree about which dependency bytes the receipt is sealed over, and the local copy the run kept is gone. The staged surfaces still hand over the digest `prepareRuntime` bound AFTER the links were made, so the commit gate keeps its own value; one changed byte inside a declared reuse root still moves the identity and refuses.
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Config key `project.paths.testTooling` in `.gateforge.yml`: globs the owner asserts are test/developer tooling. The import-graph fix above cannot see a `scripts/e2e/run.sh` that only `package.json` scripts name — nothing imports it and no runner configuration names it — so the owner declares it, and the declaration is deliberately weak: a matching changed file EXPANDS the evaluation scope exactly like test infrastructure (never proven by a slice of the suite) and is never `CHANGE_UNMAPPED`. It can never hide product code: a discovered resource's own source keeps its own attribution, and a glob that matches one is a config error — `gateforge check` exits 2 and `gateforge enforcement doctor` fails a `test-tooling` row, both naming the file and the glob. `gateforge explain <file>` names the key among the remedies for an unclassified change. The list lives in `.gateforge.yml`, so it is inside the trusted policy digest like every other declaration there (changing it moves the approved revision); absent means today's behaviour, byte for byte, digests included.
|
|
37
|
+
|
|
3
38
|
## 0.10.1
|
|
4
39
|
|
|
5
40
|
### Fixed
|
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ 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.10.3:** the two receipt paths that read the RAW policy blocking list now read the ADOPTED baseline instead, so both engage in a repository that ran `gateforge adopt` — a `docs/**.md` commit re-seals its zero-record receipt, and a receipt carried forward over sealed candidate trees is carried. Neither ever seals over NEW debt: an entry the adoption receipt forgives (by whole-entry fingerprint or by the classification layer's resource identity) is forgiven in the guard through the same split the grader uses, and an entry adoption never recorded still refuses the path. Nothing else about either receipt moved.
|
|
8
|
+
**0.10.2:** the whole-run cap is the operator's (`runtime.yml executionTimeoutSeconds` or `--run-timeout-min`; by default there is none) and only a STALL bound is ours (`stallTimeoutSeconds`, default 15 min). The commit that WIRES the gate is committable: adoption mode is computed from the base revision — no flag, no config key — so the first adoption commit proves only the obligations it newly claims and the adopted baseline survives the strict-E2E re-grade. The pack configs (`.gateforge/planes.json`, `endpoints.json`, `http-clients.json`, `fastapi.json`) and the generated `.gateforge/hooks/` + `.gateforge/ci/` wiring are owner-pinned, and a run, a `check --staged` and an `enforcement pin` now agree on ONE input identity for the same repository. Upgrading a repository that ships a pack config or the generated wiring: re-pin once.
|
|
7
9
|
**0.10.1:** `enforcement pin`, `check --staged` and `enforcement doctor` now agree on ONE policy digest for the same repository — a repository whose `.gateforge/adapters/` and `.gateforge/waivers/` are empty but untracked (exactly what `gateforge init` leaves behind) no longer makes a freshly written pin fail `check --staged` with `ENFORCEMENT_UNTRUSTED`, and re-pinning converges instead of looping. `tests mark --test` and `tests explain --test` accept the documented `<file>#<titlePath joined by '>'` reconciliation key next to the catalog `logicalKey`, so a key copied out of a report resolves instead of being reported as absent from the catalog. The npm tarball now ships this [CHANGELOG.md](CHANGELOG.md), so the release notes are readable from the installed package.
|
|
8
10
|
**0.10.0:** evidence exclusions moved INTO `.gateforge.yml` (`evidence.exclude.docs` / `.cache`), and `gateforge migrate` moves an existing 0.9 declaration there; `enforcement pin --pin-file` writes the owner-approved policy digest outside the repository and `enforcement doctor` reports `policy-inputs-vs-HEAD` / `approved-digest`; transport (`http:*`) obligations can now be PROVEN through the Observe channel by an ordinary suite-driven test; `@gate-forge/pack-playwright/fixture` works from CommonJS (`require`), so a default-shaped Playwright suite can route its traffic through the session proxy; `classify delete` records owner-declared delete semantics. Upgrading: [UPGRADE-0.9-to-0.10](guides/UPGRADE-0.9-to-0.10.md).
|
|
9
11
|
**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).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** The generated pre-commit hook `init --blocking` installs. */
|
|
2
|
+
export declare const GENERATED_HOOK_PATH = ".gateforge/hooks/gateforge-check.mjs";
|
|
3
|
+
/** What the caller knows about the candidate it is judging. */
|
|
4
|
+
export interface AdoptionCommitInput {
|
|
5
|
+
/**
|
|
6
|
+
* The base revision's text reader (HEAD for the staged diff). `null`
|
|
7
|
+
* means the base could not be read at all — then nothing may be claimed
|
|
8
|
+
* about the gate at HEAD, and adoption mode is refused.
|
|
9
|
+
*/
|
|
10
|
+
baseText: ((path: string) => string | null) | null;
|
|
11
|
+
/** Repo-relative config path the candidate declares (always `.gateforge.yml`). */
|
|
12
|
+
configPath: string;
|
|
13
|
+
/** Whether the CANDIDATE's own config carries an enforcement block. */
|
|
14
|
+
candidateEnforcement: boolean;
|
|
15
|
+
/** The frozen change set this evaluation grades. */
|
|
16
|
+
changedFiles: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
/** Whether this candidate is an adoption commit, and why not when it is not. */
|
|
19
|
+
export interface AdoptionCommitVerdict {
|
|
20
|
+
/** True only when conditions 1–3 hold. */
|
|
21
|
+
adoptionCommit: boolean;
|
|
22
|
+
/** One sentence explaining a refusal; empty when it is an adoption commit. */
|
|
23
|
+
reason: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Decides whether the candidate is an ADOPTION COMMIT.
|
|
27
|
+
*
|
|
28
|
+
* @param input: the base reader, the candidate's config path and
|
|
29
|
+
* enforcement header, and the frozen change set.
|
|
30
|
+
*
|
|
31
|
+
* @returns
|
|
32
|
+
* AdoptionCommitVerdict: the decision and, for a refusal, the one
|
|
33
|
+
* sentence that says why. The caller checks the policy pin itself, so
|
|
34
|
+
* reaching a verdict here never weakens the owner approval.
|
|
35
|
+
*/
|
|
36
|
+
export declare function evaluateAdoptionCommit(input: AdoptionCommitInput): AdoptionCommitVerdict;
|
|
37
|
+
//# sourceMappingURL=adoption-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adoption-mode.d.ts","sourceRoot":"","sources":["../src/adoption-mode.ts"],"names":[],"mappings":"AAiCA,gEAAgE;AAChE,eAAO,MAAM,mBAAmB,yCAAyC,CAAC;AAK1E,+DAA+D;AAC/D,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IACnD,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,oBAAoB,EAAE,OAAO,CAAC;IAC9B,oDAAoD;IACpD,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC;AAED,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,0CAA0C;IAC1C,cAAc,EAAE,OAAO,CAAC;IACxB,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;CAChB;AA6BD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,mBAAmB,GAAG,qBAAqB,CA0BxF"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOPTION MODE — the one commit a repository with no gate may make
|
|
3
|
+
* weaker in SCOPE, never in trust (0.10.2; REFERENCE "Adoption mode").
|
|
4
|
+
*
|
|
5
|
+
* The commit that wires the gate is the commit the gate cannot judge: it
|
|
6
|
+
* always touches `.gateforge.yml`, the runner config and the specs, every
|
|
7
|
+
* one of them a gate-defining input, so the evaluation expands to every
|
|
8
|
+
* obligation in the repository — while the only affordable proof of a
|
|
9
|
+
* large repository is a changed-scope receipt. The generated hook
|
|
10
|
+
* (`check --staged`) refused that receipt as a scope mismatch, so every
|
|
11
|
+
* adopting repository had to bypass the hook exactly once.
|
|
12
|
+
*
|
|
13
|
+
* A commit is an ADOPTION COMMIT when, and only when:
|
|
14
|
+
*
|
|
15
|
+
* 1. HEAD has NO gate — no `enforcement` block in its config, and no
|
|
16
|
+
* generated `.gateforge/hooks/gateforge-check.mjs`; and
|
|
17
|
+
* 2. the candidate DOES wire one (it introduces the generated gate
|
|
18
|
+
* wiring, or turns `enforcement` on); and
|
|
19
|
+
* 3. the candidate's trusted policy digest matches the owner-approved
|
|
20
|
+
* pin — checked by the CALLER, which reaches this verdict only after
|
|
21
|
+
* that gate passed, so a weakened candidate still fails closed.
|
|
22
|
+
*
|
|
23
|
+
* Condition 1 is what makes it safe: it is monotone and one-shot. Once a
|
|
24
|
+
* gate exists at HEAD the condition can never hold again, so no later
|
|
25
|
+
* commit can re-enter adoption mode. There is no flag, no config key and
|
|
26
|
+
* no environment variable — nothing a candidate can set.
|
|
27
|
+
*
|
|
28
|
+
* This module only DECIDES. What adoption mode changes is the caller's
|
|
29
|
+
* receipt-coverage requirement; it never relaxes `CHANGE_UNMAPPED`,
|
|
30
|
+
* never relaxes the policy pin, and never forgives an obligation.
|
|
31
|
+
*/
|
|
32
|
+
import { parse as parseYaml } from 'yaml';
|
|
33
|
+
/** The generated pre-commit hook `init --blocking` installs. */
|
|
34
|
+
export const GENERATED_HOOK_PATH = '.gateforge/hooks/gateforge-check.mjs';
|
|
35
|
+
/** The generated gate wiring directories a first adoption commit writes. */
|
|
36
|
+
const GENERATED_WIRING_PREFIXES = ['.gateforge/hooks/', '.gateforge/ci/'];
|
|
37
|
+
/**
|
|
38
|
+
* Whether the base revision's config document declares an `enforcement`
|
|
39
|
+
* block — the header that turns a configured repository into a gated one.
|
|
40
|
+
*
|
|
41
|
+
* A document that cannot be parsed is treated as DECLARING one: the
|
|
42
|
+
* engine refuses to read a base it does not understand as "no gate
|
|
43
|
+
* there", because that reading would hand adoption mode to any candidate
|
|
44
|
+
* that could make HEAD unreadable.
|
|
45
|
+
*
|
|
46
|
+
* @param text: the base revision's config bytes, or null when absent.
|
|
47
|
+
*
|
|
48
|
+
* @returns
|
|
49
|
+
* boolean: true when an enforcement block is present.
|
|
50
|
+
*/
|
|
51
|
+
function declaresEnforcement(text) {
|
|
52
|
+
if (text === null)
|
|
53
|
+
return false;
|
|
54
|
+
let document;
|
|
55
|
+
try {
|
|
56
|
+
document = parseYaml(text);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
if (typeof document !== 'object' || document === null || !('enforcement' in document))
|
|
62
|
+
return false;
|
|
63
|
+
const enforcement = document.enforcement;
|
|
64
|
+
return typeof enforcement === 'object' && enforcement !== null && Object.keys(enforcement).length > 0;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Decides whether the candidate is an ADOPTION COMMIT.
|
|
68
|
+
*
|
|
69
|
+
* @param input: the base reader, the candidate's config path and
|
|
70
|
+
* enforcement header, and the frozen change set.
|
|
71
|
+
*
|
|
72
|
+
* @returns
|
|
73
|
+
* AdoptionCommitVerdict: the decision and, for a refusal, the one
|
|
74
|
+
* sentence that says why. The caller checks the policy pin itself, so
|
|
75
|
+
* reaching a verdict here never weakens the owner approval.
|
|
76
|
+
*/
|
|
77
|
+
export function evaluateAdoptionCommit(input) {
|
|
78
|
+
if (input.baseText === null) {
|
|
79
|
+
return {
|
|
80
|
+
adoptionCommit: false,
|
|
81
|
+
reason: 'the base revision could not be read, so what gate exists at HEAD is unknown',
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const baseEnforcement = declaresEnforcement(input.baseText(input.configPath));
|
|
85
|
+
const baseHook = input.baseText(GENERATED_HOOK_PATH);
|
|
86
|
+
if (baseEnforcement || baseHook !== null) {
|
|
87
|
+
return {
|
|
88
|
+
adoptionCommit: false,
|
|
89
|
+
reason: 'the base revision already carries the gate, so this commit is judged exactly like every later one',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const wiresGate = input.changedFiles.some((file) => file === GENERATED_HOOK_PATH || GENERATED_WIRING_PREFIXES.some((prefix) => file.startsWith(prefix)));
|
|
93
|
+
if (!wiresGate && !input.candidateEnforcement) {
|
|
94
|
+
return {
|
|
95
|
+
adoptionCommit: false,
|
|
96
|
+
reason: 'the candidate wires no gate, so there is nothing to adopt',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return { adoptionCommit: true, reason: '' };
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=adoption-mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adoption-mode.js","sourceRoot":"","sources":["../src/adoption-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,gEAAgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,sCAAsC,CAAC;AAE1E,4EAA4E;AAC5E,MAAM,yBAAyB,GAAsB,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;AA0B7F;;;;;;;;;;;;;GAaG;AACH,SAAS,mBAAmB,CAAC,IAAmB;IAC9C,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAChC,IAAI,QAAiB,CAAC;IACtB,IAAI,CAAC;QACH,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,IAAI,CAAC,CAAC,aAAa,IAAI,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IACpG,MAAM,WAAW,GAAY,QAAQ,CAAC,WAAW,CAAC;IAClD,OAAO,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACxG,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAA0B;IAC/D,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO;YACL,cAAc,EAAE,KAAK;YACrB,MAAM,EAAE,6EAA6E;SACtF,CAAC;IACJ,CAAC;IACD,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9E,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IACrD,IAAI,eAAe,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACzC,OAAO;YACL,cAAc,EAAE,KAAK;YACrB,MAAM,EACJ,mGAAmG;SACtG,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,CACvC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,mBAAmB,IAAI,yBAAyB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAC9G,CAAC;IACF,IAAI,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAC9C,OAAO;YACL,cAAc,EAAE,KAAK;YACrB,MAAM,EAAE,2DAA2D;SACpE,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAwIA,OAAO,
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAwIA,OAAO,EA0BL,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAc1B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAgCnC,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAoCvF,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AA8TnF,eAAO,MAAM,WAAW,QAM2F,CAAC;AAEpH,8EAA8E;AAC9E,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,UAAU,EAAE,OAAO,CAAC;IACpB,yEAAyE;IACzE,UAAU,EAAE,OAAO,CAAC;IACpB,qBAAqB;IACrB,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAClC;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kEAAkE;IAClE,eAAe,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IACzC,kEAAkE;IAClE,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,yEAAyE;IACzE,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,8EAA8E;IAC9E,kBAAkB,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAClD,2DAA2D;IAC3D,iBAAiB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACxC,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAChD;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA4CnF;AAqWD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAEgE,CAAC;AAEnG;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMhE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI,GAAG,OAAO,CAE9E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,GACf,MAAM,CAeR;AAsCD;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAysCrF"}
|
package/dist/commands/check.js
CHANGED
|
@@ -134,7 +134,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
134
134
|
import { createHash } from 'node:crypto';
|
|
135
135
|
import { join } from 'node:path';
|
|
136
136
|
import { performance } from 'node:perf_hooks';
|
|
137
|
-
import { BLOCKING_VERDICTS, decideStrictness, loadQuarantines, QUARANTINE_DIR, resolveStrictnessMode, strictnessSummaryLine, CAUSE_NEXT_ACTIONS, canonicalJson, ENGINE_UPGRADE_REFUSAL_PREFIX, volatileEchoSkips, engineBundleDigestOf, executionBoundaryDigestOf, GateReceiptSchema, humanMessage, LOCAL_UNISOLATED_BOUNDARY, renderRun, runExitCode, } from '@gate-forge/core';
|
|
137
|
+
import { BLOCKING_VERDICTS, decideStrictness, loadQuarantines, QUARANTINE_DIR, resolveStrictnessMode, strictnessSummaryLine, CAUSE_NEXT_ACTIONS, canonicalJson, ENGINE_UPGRADE_REFUSAL_PREFIX, volatileEchoSkips, engineBundleDigestOf, executionBoundaryDigestOf, GateforgeConfigError, GateReceiptSchema, humanMessage, LOCAL_UNISOLATED_BOUNDARY, renderRun, runExitCode, } from '@gate-forge/core';
|
|
138
138
|
import { discoverTestCatalog, findPlaywrightConfig, scanTestFiles, TestDiscoveryError, untrustedEnv, } from '@gate-forge/pack-playwright';
|
|
139
139
|
import { parseArgs, stringFlag } from '../args.js';
|
|
140
140
|
import { resolveAdoptedBaseline } from '../adopted-baseline.js';
|
|
@@ -147,7 +147,8 @@ import { auditAdapters } from '../adapter-audit.js';
|
|
|
147
147
|
import { singletonPerTenantAdvisories } from '../singleton-guidance.js';
|
|
148
148
|
import { responseFieldAdvisories } from '../response-field-guidance.js';
|
|
149
149
|
import { unmatchedRouteBannerLines } from '../unmatched-routes.js';
|
|
150
|
-
import { annotationMapSyncAdvisories,
|
|
150
|
+
import { annotationMapSyncAdvisories, loadOptionalTestMap, mappedCoverageFrom, mappingBlocking, nativeInventoryBlocking, resolveRepositoryMappings, TEST_MAP_RELATIVE } from '../mapping.js';
|
|
151
|
+
import { runnerConfigPaths, runtimeDeclaredInputs } from '../test-infrastructure.js';
|
|
151
152
|
import { collectInputFiles, computeInputSnapshot, diffInputFiles, SnapshotUnavailableError, UnsupportedSnapshotError, } from '../input-snapshot.js';
|
|
152
153
|
import { runPipeline, sourcesByResourceId } from '../pipeline.js';
|
|
153
154
|
import { digestPytestInputs, interpreterIdentity, pytestCacheKey, readPytestCache, resolveCacheControl, writePytestCache, } from '../run-cache.js';
|
|
@@ -155,8 +156,9 @@ import { RuntimeBlockError, loadRuntimeConfigAt, prepareRuntime } from '../runti
|
|
|
155
156
|
import { digestRuntimeReuseMounts } from '../runtime-reuse.js';
|
|
156
157
|
import { authenticatedChangedInputs, loadReceiptFor, receiptGateBlocking, scopedReceiptCoverageBlocking, } from '../receipts.js';
|
|
157
158
|
import { resealChainBlocking, retainedCarriedEvidence } from '../reseal-chain.js';
|
|
159
|
+
import { evaluateAdoptionCommit } from '../adoption-mode.js';
|
|
158
160
|
import { changeBaseTextReader, mergeRequestScopePreflight, resolveProvider, textReaderAtRevision } from '../providers.js';
|
|
159
|
-
import { computeEvaluationScope, detectStagedWorkingTreeMismatches, } from '../scope.js';
|
|
161
|
+
import { computeEvaluationScope, detectStagedWorkingTreeMismatches, testToolingSourceConflicts, } from '../scope.js';
|
|
160
162
|
import { assertRuntimeReuseOwnerApproval, freezeCommitCandidate, freezeStagedCandidate, materializeStagedCandidate, mirrorEmptyConfigDirs, recheckStagedCandidate, releaseStagedCandidate, StagedCandidateBlockError, } from '../staged-candidate.js';
|
|
161
163
|
import { httpRoutesView, readCandidateTreeEntries, readStateDocument, resolveStateDir } from '../state.js';
|
|
162
164
|
import { engineGeneratedStateFileFilter } from '../state-artifacts.js';
|
|
@@ -164,7 +166,7 @@ import { assertReceiptApprovedPolicy, evaluateApprovedPolicy, resolveApprovedPol
|
|
|
164
166
|
import { loadConfigAt, parseRunFormat, rejectUnknownFlags, VERSION } from './common.js';
|
|
165
167
|
import { resolveVerifierKeyring } from '../verifier-keys.js';
|
|
166
168
|
import { renderEndpointInventory } from '../endpoint-report.js';
|
|
167
|
-
import { computeCandidateTreeSnapshot, resolveGitDir, sanitizedAuthorityEnv } from '../candidate-tree.js';
|
|
169
|
+
import { candidateTreeCoversCommit, computeCandidateTreeSnapshot, resolveGitDir, sanitizedAuthorityEnv } from '../candidate-tree.js';
|
|
168
170
|
import { DOCS_EXCLUSIONS_GUARANTEE, loadDocsExclusions } from '../docs-exclusions.js';
|
|
169
171
|
import { CACHE_EXCLUSIONS_GUARANTEE, loadCacheExclusions } from '../cache-exclusions.js';
|
|
170
172
|
import { engineIdentity, reportEngineLine } from '../engine-identity.js';
|
|
@@ -488,6 +490,54 @@ export async function checkCommand(io, argv) {
|
|
|
488
490
|
noCache,
|
|
489
491
|
});
|
|
490
492
|
}
|
|
493
|
+
/**
|
|
494
|
+
* The candidate tree id `check --staged` binds a sealed receipt to.
|
|
495
|
+
*
|
|
496
|
+
* The frozen index tree is what the commit will contain, but a receipt is
|
|
497
|
+
* sealed over the WORKSPACE its run tested, and a candidate tree carries
|
|
498
|
+
* that workspace's untracked and gitignored bytes as well — that is what
|
|
499
|
+
* makes it a candidate, and it is why `candidateTreeCoversCommit` treats
|
|
500
|
+
* CONTAINMENT of the committed bytes, not equality with the commit tree,
|
|
501
|
+
* as the property a gate relies on. String equality between a workspace
|
|
502
|
+
* tree and the index tree can therefore never hold in a repository whose
|
|
503
|
+
* run writes into its own worktree (`node_modules/`, a blob report, a
|
|
504
|
+
* storage state), so a receipt sealed over a fully staged worktree could
|
|
505
|
+
* not satisfy the gate at all.
|
|
506
|
+
*
|
|
507
|
+
* What the gate actually needs is that every staged byte was among the
|
|
508
|
+
* tested bytes: when the sealed tree carries every staged path with the
|
|
509
|
+
* SAME mode and blob, the sealed tree IS the candidate, and binding the
|
|
510
|
+
* receipt to it says exactly what containment means. Nothing is relaxed
|
|
511
|
+
* — the receipt's authenticated input digest must still equal the digest
|
|
512
|
+
* this checkout computes, every staged path must be present in the sealed
|
|
513
|
+
* tree, and an unreadable receipt, an unreadable tree listing or a single
|
|
514
|
+
* differing byte falls back to the frozen index tree, which is the
|
|
515
|
+
* previous (stricter) test.
|
|
516
|
+
*
|
|
517
|
+
* Args:
|
|
518
|
+
* gitDir: the USER repository's git dir — the sealed candidate tree
|
|
519
|
+
* objects were written there by the run that sealed the receipt.
|
|
520
|
+
* env: process environment.
|
|
521
|
+
* stateDir: the USER run-state directory holding the sealed receipt.
|
|
522
|
+
* frozen: the frozen candidate (staged index or candidate commit).
|
|
523
|
+
* docsExclusions: owner-approved documentation folders (never sealed).
|
|
524
|
+
* cacheExclusions: exact approved Python bytecode files (never sealed).
|
|
525
|
+
*
|
|
526
|
+
* Returns:
|
|
527
|
+
* string: the sealed tree id when it provably covers the candidate,
|
|
528
|
+
* otherwise the frozen candidate's own tree id.
|
|
529
|
+
*/
|
|
530
|
+
function boundCandidateTreeId(gitDir, env, stateDir, frozen, docsExclusions, cacheExclusions) {
|
|
531
|
+
if (gitDir === null)
|
|
532
|
+
return frozen.treeId;
|
|
533
|
+
const parsed = GateReceiptSchema.safeParse(readStateDocument(stateDir, 'receipt.json'));
|
|
534
|
+
const sealed = parsed.success ? parsed.data.candidateTreeId : null;
|
|
535
|
+
if (sealed === null || sealed === undefined || sealed === frozen.treeId)
|
|
536
|
+
return frozen.treeId;
|
|
537
|
+
return candidateTreeCoversCommit(gitDir, env, sealed, frozen.treeId, docsExclusions, cacheExclusions)
|
|
538
|
+
? sealed
|
|
539
|
+
: frozen.treeId;
|
|
540
|
+
}
|
|
491
541
|
/**
|
|
492
542
|
* The `--staged` gate (plan 2026-09-13 Phase 5 items 3–4): gate the EXACT
|
|
493
543
|
* staged candidate. The candidate is frozen (tree id + parents + change
|
|
@@ -543,6 +593,8 @@ async function stagedCheckCommand(io, options) {
|
|
|
543
593
|
let runtimeReuseDigest = null;
|
|
544
594
|
let runtimeReuseMounts = [];
|
|
545
595
|
let runtimeDoc = null;
|
|
596
|
+
let docsExclusions = [];
|
|
597
|
+
let cacheExclusions = [];
|
|
546
598
|
try {
|
|
547
599
|
checkoutDir = materializeStagedCandidate(io.cwd, io.env, frozen);
|
|
548
600
|
// Empty directories are invisible to Git trees — checkout-index cannot
|
|
@@ -557,8 +609,8 @@ async function stagedCheckCommand(io, options) {
|
|
|
557
609
|
// mirrored, and only for a STAGED index (a candidate commit tree is
|
|
558
610
|
// gated on its own contents, never on the worktree around it).
|
|
559
611
|
const checkoutConfig = loadConfigAt(checkoutDir);
|
|
560
|
-
|
|
561
|
-
|
|
612
|
+
docsExclusions = loadDocsExclusions(checkoutDir, checkoutConfig);
|
|
613
|
+
cacheExclusions = loadCacheExclusions(checkoutDir, checkoutConfig);
|
|
562
614
|
mirrorEmptyConfigDirs(io.cwd, checkoutDir, checkoutConfig, {
|
|
563
615
|
fromStagedIndex: options.candidateCommitSha === undefined,
|
|
564
616
|
});
|
|
@@ -667,7 +719,7 @@ async function stagedCheckCommand(io, options) {
|
|
|
667
719
|
format: options.format,
|
|
668
720
|
approvedPolicyDigest: options.approvedPolicyDigest,
|
|
669
721
|
verifierKeyring: options.verifierKeyring,
|
|
670
|
-
fixedCandidateTreeId:
|
|
722
|
+
fixedCandidateTreeId: boundCandidateTreeId(resolveGitDir(io.cwd, io.env), io.env, userState, frozen, docsExclusions, cacheExclusions),
|
|
671
723
|
...(options.diffScoped
|
|
672
724
|
? {
|
|
673
725
|
fixedChangedFiles: frozen.changedPaths,
|
|
@@ -946,6 +998,23 @@ export async function runCheckGate(io, options) {
|
|
|
946
998
|
...(fixedChangedFiles !== undefined ? { changedFilesOverride: fixedChangedFiles } : {}),
|
|
947
999
|
pluginCache: cacheControl,
|
|
948
1000
|
});
|
|
1001
|
+
// 0.10.2: a declared test-tooling glob that reaches a discovered
|
|
1002
|
+
// resource's own source is a CONFIG error, not a silent pass — the
|
|
1003
|
+
// declaration exists so tooling can be attributed, never so product
|
|
1004
|
+
// code can hide behind it. Fail closed before anything is graded.
|
|
1005
|
+
const toolingConflicts = testToolingSourceConflicts(config, [
|
|
1006
|
+
...new Set(pipeline.graph.resources.flatMap((resource) => resource.id === null ? [] : sourcesByResourceId(pipeline.graph, pipeline.behaviorCatalog).get(resource.id) ?? [])),
|
|
1007
|
+
]);
|
|
1008
|
+
if (toolingConflicts.length > 0) {
|
|
1009
|
+
throw new GateforgeConfigError(toolingConflicts.map((conflict) => ({
|
|
1010
|
+
file: '.gateforge.yml',
|
|
1011
|
+
jsonPath: '$.project.paths.testTooling',
|
|
1012
|
+
message: `glob '${conflict.glob}' matches the source of a discovered resource: declared test tooling ` +
|
|
1013
|
+
'cannot be product code — narrow the glob',
|
|
1014
|
+
expected: 'a glob that matches no discovered resource source',
|
|
1015
|
+
got: conflict.file,
|
|
1016
|
+
})));
|
|
1017
|
+
}
|
|
949
1018
|
// Owner quarantine population: check is
|
|
950
1019
|
// the debt view, so an owner-quarantined test is reported here too —
|
|
951
1020
|
// loaded against the INJECTED run clock, never the wall clock. It is
|
|
@@ -1067,7 +1136,14 @@ export async function runCheckGate(io, options) {
|
|
|
1067
1136
|
unmappedFiles: [],
|
|
1068
1137
|
policyInputs: [],
|
|
1069
1138
|
policyInputsOnly: false,
|
|
1139
|
+
productBehaviorNeutral: false,
|
|
1140
|
+
docsOnly: false,
|
|
1070
1141
|
};
|
|
1142
|
+
// F2 adoption mode: computed from the BASE revision (HEAD for the
|
|
1143
|
+
// staged diff), never declared — no flag, no config key. It only moves
|
|
1144
|
+
// WHICH obligations must be proven (the ones this commit newly claims);
|
|
1145
|
+
// it never relaxes `CHANGE_UNMAPPED` and never forgives an obligation.
|
|
1146
|
+
let adoptionCommit = false;
|
|
1071
1147
|
let mismatchBlocking = [];
|
|
1072
1148
|
let scopeDiscoveryTimings;
|
|
1073
1149
|
if (scopeAwareRun) {
|
|
@@ -1077,9 +1153,12 @@ export async function runCheckGate(io, options) {
|
|
|
1077
1153
|
// without it keeps the exact historical behavior) or a mapping
|
|
1078
1154
|
// sidecar.
|
|
1079
1155
|
const sidecar = loadOptionalTestMap(io.cwd);
|
|
1080
|
-
const
|
|
1156
|
+
const runnerConfigs = runnerConfigPaths(io.cwd, config.runner);
|
|
1157
|
+
const runtimeInputs = runtimeDeclaredInputs(io.cwd, config);
|
|
1081
1158
|
let testFiles = [];
|
|
1082
|
-
|
|
1159
|
+
let testInfrastructureFiles = [];
|
|
1160
|
+
let fileVerdict;
|
|
1161
|
+
if (runnerConfigs.length > 0) {
|
|
1083
1162
|
try {
|
|
1084
1163
|
const scopeDiscovery = await discoverTestCatalog({
|
|
1085
1164
|
cwd: io.cwd,
|
|
@@ -1090,11 +1169,15 @@ export async function runCheckGate(io, options) {
|
|
|
1090
1169
|
testFiles = scopeDiscovery.catalog.entries
|
|
1091
1170
|
.filter((entry) => entry.runner === config.runner)
|
|
1092
1171
|
.map((entry) => entry.file);
|
|
1172
|
+
testInfrastructureFiles = scopeDiscovery.testInfrastructureFiles;
|
|
1173
|
+
fileVerdict = scopeDiscovery.fileVerdict;
|
|
1093
1174
|
}
|
|
1094
1175
|
catch {
|
|
1095
1176
|
// Discovery problems surface on their own gates; scope expansion
|
|
1096
1177
|
// proceeds with the infrastructure signals it does have.
|
|
1097
1178
|
testFiles = [];
|
|
1179
|
+
testInfrastructureFiles = [];
|
|
1180
|
+
fileVerdict = undefined;
|
|
1098
1181
|
}
|
|
1099
1182
|
}
|
|
1100
1183
|
const knownSourceFiles = [
|
|
@@ -1112,14 +1195,40 @@ export async function runCheckGate(io, options) {
|
|
|
1112
1195
|
// USER's repository BEFORE the process moved to the isolated checkout:
|
|
1113
1196
|
// the checkout's HEAD is the staged tree, not the base, so the base
|
|
1114
1197
|
// revision's objects are reachable only in the user's repository.
|
|
1115
|
-
const
|
|
1198
|
+
const baseText = fixedChangedFiles === undefined
|
|
1116
1199
|
? changeBaseTextReader(providerIdentity, io.cwd, io.env) ?? undefined
|
|
1117
|
-
: options.fixedBaseText
|
|
1200
|
+
: options.fixedBaseText;
|
|
1201
|
+
// The adoption verdict rides the SAME base reader the policy-input
|
|
1202
|
+
// classifier uses: HEAD for the staged diff, the merge/CI base for the
|
|
1203
|
+
// platform diffs. Condition 3 (the owner-approved digest) is checked
|
|
1204
|
+
// by the receipt gate below, which reaches its coverage decision only
|
|
1205
|
+
// after that pin has passed.
|
|
1206
|
+
adoptionCommit = evaluateAdoptionCommit({
|
|
1207
|
+
baseText: baseText ?? null,
|
|
1208
|
+
configPath: '.gateforge.yml',
|
|
1209
|
+
candidateEnforcement: config.enforcement !== undefined && Object.keys(config.enforcement).length > 0,
|
|
1210
|
+
changedFiles: pipeline.changedFiles,
|
|
1211
|
+
}).adoptionCommit;
|
|
1212
|
+
const ownedInputs = gateforgeOwnedInputs(io.cwd, pipeline.changedFiles, config, baseText);
|
|
1213
|
+
// A path this change DELETED that no configured runner's own
|
|
1214
|
+
// test-file selection ever claimed. Nothing collected it, so removing
|
|
1215
|
+
// it removes no test and no behaviour: it neither expands the scope
|
|
1216
|
+
// nor blocks as unmapped. Without a readable runner selection
|
|
1217
|
+
// (`fileVerdict` absent) nothing is excused and every deletion keeps
|
|
1218
|
+
// today's treatment.
|
|
1219
|
+
const removedUnclaimedFiles = fileVerdict === undefined || baseText === undefined
|
|
1220
|
+
? []
|
|
1221
|
+
: pipeline.changedFiles.filter((file) => !existsSync(join(io.cwd, ...file.split('/'))) &&
|
|
1222
|
+
baseText(file) !== null &&
|
|
1223
|
+
fileVerdict(file) === 'disclaimed');
|
|
1118
1224
|
scopeDecision = computeEvaluationScope({
|
|
1119
1225
|
config,
|
|
1120
1226
|
changedFiles: pipeline.changedFiles,
|
|
1121
1227
|
testFiles,
|
|
1122
|
-
runnerConfigs
|
|
1228
|
+
runnerConfigs,
|
|
1229
|
+
testInfrastructureFiles,
|
|
1230
|
+
runtimeInputs,
|
|
1231
|
+
removedUnclaimedFiles,
|
|
1123
1232
|
mappingSidecar: sidecar !== null,
|
|
1124
1233
|
knownSourceFiles,
|
|
1125
1234
|
strictE2E: config.enforcement?.strictE2E === true,
|
|
@@ -1146,7 +1255,13 @@ export async function runCheckGate(io, options) {
|
|
|
1146
1255
|
nextAction: `Attributing '${file}' starts with \`gateforge explain ${file}\`, which prints what the file is ` +
|
|
1147
1256
|
'and what governs it: map the detected resource, declare documentation folders with ' +
|
|
1148
1257
|
'`gateforge init --docs-exclude <folders>`, or add the detection that owns the file. ' +
|
|
1149
|
-
'Never weaken the policy.'
|
|
1258
|
+
'Never weaken the policy.' +
|
|
1259
|
+
// The docs-only exemption is engine-owned and applies only to a
|
|
1260
|
+
// WHOLE documentation commit, so name the route that works
|
|
1261
|
+
// rather than leaving the owner to guess at "mixed change".
|
|
1262
|
+
(file.startsWith('docs/') && file.endsWith('.md')
|
|
1263
|
+
? ' A `docs/**.md` edit is exempt only when the WHOLE commit is documentation: commit it on its own, before or after this change.'
|
|
1264
|
+
: ''),
|
|
1150
1265
|
}));
|
|
1151
1266
|
mismatchBlocking = [...mismatchBlocking, ...unmappedBlocking];
|
|
1152
1267
|
// The local-staged provider lists index changes, but discovery reads
|
|
@@ -1167,6 +1282,10 @@ export async function runCheckGate(io, options) {
|
|
|
1167
1282
|
unmappedFiles: scopeDecision.unmappedFiles,
|
|
1168
1283
|
policyInputs: scopeDecision.policyInputs,
|
|
1169
1284
|
policyInputsOnly: scopeDecision.policyInputsOnly,
|
|
1285
|
+
productBehaviorNeutral: scopeDecision.productBehaviorNeutral,
|
|
1286
|
+
// A worktree that diverges from the index is not the candidate,
|
|
1287
|
+
// so it can never be certified as the docs-only slice either.
|
|
1288
|
+
docsOnly: false,
|
|
1170
1289
|
};
|
|
1171
1290
|
mismatchBlocking = [
|
|
1172
1291
|
...mismatchBlocking,
|
|
@@ -1192,8 +1311,26 @@ export async function runCheckGate(io, options) {
|
|
|
1192
1311
|
// policy revision that governs those files: a mismatching pin still blocks
|
|
1193
1312
|
// on its own, and with no pin today's reporting stays (adopted debt is
|
|
1194
1313
|
// re-graded as blocking). An owner waiver is never forgiveness here.
|
|
1314
|
+
//
|
|
1315
|
+
// 0.10.2 (adoption mode, REFERENCE "Adoption mode"): the commit that WIRES the gate is
|
|
1316
|
+
// never policy-inputs-only — it brings the manifest, the runner
|
|
1317
|
+
// configuration, the mapping sidecar and the specs, every one of them
|
|
1318
|
+
// gate-defining or test infrastructure — so the 0.9.0 condition could
|
|
1319
|
+
// never hold for exactly the commit adoption mode exists to serve, and
|
|
1320
|
+
// adopted debt was re-graded blocking on the first commit of every
|
|
1321
|
+
// repository. The forgiveness therefore ALSO holds when the change set is
|
|
1322
|
+
// product-behaviour-NEUTRAL, read from the same attribution that produced
|
|
1323
|
+
// the scope decision (every changed file is a policy input, a
|
|
1324
|
+
// gate-defining input, a catalog test file, test infrastructure, a
|
|
1325
|
+
// runtime-declared input or docs, and NO discovered resource's source is
|
|
1326
|
+
// in the set), AND this candidate IS an adoption commit (computed from
|
|
1327
|
+
// the base revision, never declared), AND the owner pin is enforced on
|
|
1328
|
+
// exactly the same `evaluateApprovedPolicy(...).status === 'enforced'`
|
|
1329
|
+
// condition. One product source in the change set denies the neutrality,
|
|
1330
|
+
// so the strict re-grade returns. Nothing else moves.
|
|
1195
1331
|
const adoptedBaselineSurvivesStrictE2E = diffScoped &&
|
|
1196
|
-
scopeDecision.policyInputsOnly
|
|
1332
|
+
(scopeDecision.policyInputsOnly ||
|
|
1333
|
+
(adoptionCommit && scopeDecision.productBehaviorNeutral)) &&
|
|
1197
1334
|
evaluateApprovedPolicy(docsApprovalResolution ??
|
|
1198
1335
|
resolveApprovedPolicyDigest({
|
|
1199
1336
|
flag: options.approvedPolicyDigest,
|
|
@@ -1414,7 +1551,18 @@ export async function runCheckGate(io, options) {
|
|
|
1414
1551
|
// obligation for an unscoped or expanded run (a slice receipt cannot
|
|
1415
1552
|
// silently certify a whole-repo evaluation). Carried as id +
|
|
1416
1553
|
// pin-#2 fingerprint, the exact identity a changed-scope receipt seals.
|
|
1417
|
-
|
|
1554
|
+
// ADOPTION MODE (F2 §4): the commit that wires the gate always expands
|
|
1555
|
+
// the scope, yet the only affordable proof of a large repository is a
|
|
1556
|
+
// changed-slice receipt. An adoption commit therefore demands coverage
|
|
1557
|
+
// of the obligations this change set NEWLY CLAIMS — the same
|
|
1558
|
+
// join-aware slice a narrowed run demands — while every obligation it
|
|
1559
|
+
// does not touch stays unproven debt (`adopt` baselines it, and the
|
|
1560
|
+
// report still names it). Nothing else moves: a policy-input pin
|
|
1561
|
+
// mismatch, a receipt bound to another candidate tree, a
|
|
1562
|
+
// `CHANGE_UNMAPPED` file and an uncovered newly claimed obligation are
|
|
1563
|
+
// all refused exactly as before.
|
|
1564
|
+
//
|
|
1565
|
+
const coverageChangedFiles = diffScoped && (scopeDecision.mode === 'changed' || adoptionCommit) ? scopeDecision.changedFiles : null;
|
|
1418
1566
|
const requiredCoverage = () => {
|
|
1419
1567
|
const sources = sourcesByResourceId(pipeline.graph, pipeline.behaviorCatalog);
|
|
1420
1568
|
return pipeline.policy.obligations
|
|
@@ -1529,6 +1677,28 @@ export async function runCheckGate(io, options) {
|
|
|
1529
1677
|
];
|
|
1530
1678
|
}
|
|
1531
1679
|
}
|
|
1680
|
+
// 0.10.2: a `docsOnly` receipt is a CLAIM, exactly like the
|
|
1681
|
+
// re-seal's `changeClass`: it says this candidate's WHOLE changed
|
|
1682
|
+
// set was `docs/**.md`. The consumer recomputes that decision from
|
|
1683
|
+
// its OWN scope computation rather than believing it, so a marking
|
|
1684
|
+
// that does not match the staged change set is refused. A matching
|
|
1685
|
+
// one covers nothing — `scopedReceiptCoverageBlocking` below still
|
|
1686
|
+
// demands a fingerprint for every obligation this change produces.
|
|
1687
|
+
if (receiptBlocking.length === 0 && load.receipt.docsOnly === true && !scopeDecision.docsOnly) {
|
|
1688
|
+
receiptBlocking = [
|
|
1689
|
+
{
|
|
1690
|
+
kind: 'finding',
|
|
1691
|
+
resourceId: null,
|
|
1692
|
+
name: null,
|
|
1693
|
+
detail: `require-e2e: the receipt claims the engine-owned docs-only slice, but this change set is not ` +
|
|
1694
|
+
`docs-only (changed files: ${scopeDecision.changedFiles.length > 0 ? scopeDecision.changedFiles.join(', ') : '<none>'}) ` +
|
|
1695
|
+
'— the claim is a stale slice, not this candidate (fail closed)',
|
|
1696
|
+
location: null,
|
|
1697
|
+
cause: 'EVIDENCE_STALE',
|
|
1698
|
+
nextAction: CAUSE_NEXT_ACTIONS.EVIDENCE_STALE,
|
|
1699
|
+
},
|
|
1700
|
+
];
|
|
1701
|
+
}
|
|
1532
1702
|
if (receiptBlocking.length === 0) {
|
|
1533
1703
|
// Scope consumption (Goal 2): full receipts pass unchanged; a
|
|
1534
1704
|
// changed-scope receipt must cover every obligation this
|