@gate-forge/cli 0.10.0 → 0.10.2
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 +371 -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 +199 -29
- 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 +80 -4
- 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 +9 -1
- 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 +267 -9
- package/dist/commands/test-gates.js.map +1 -1
- package/dist/commands/tests.js +74 -17
- package/dist/commands/tests.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/pipeline.d.ts +8 -2
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +9 -8
- package/dist/pipeline.js.map +1 -1
- package/dist/repo-path.d.ts +3 -0
- package/dist/repo-path.d.ts.map +1 -0
- package/dist/repo-path.js +24 -0
- package/dist/repo-path.js.map +1 -0
- 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 +48 -1
- package/dist/staged-candidate.d.ts.map +1 -1
- package/dist/staged-candidate.js +74 -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 +188 -2
- package/guides/TEST-ENVIRONMENT.md +3 -1
- package/package.json +12 -10
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.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.
|
|
8
|
+
**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.
|
|
7
9
|
**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).
|
|
8
10
|
**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).
|
|
9
11
|
|
|
@@ -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
|
@@ -129,12 +129,12 @@ async function adapterAdvisories(cwd, pipeline, verdicts, stateDir) {
|
|
|
129
129
|
* annotations are compared with generated sidecar entries but are not direct
|
|
130
130
|
* check bindings; raw `claims.json` is never a declaration source.
|
|
131
131
|
*/
|
|
132
|
-
import { cpSync, existsSync, lstatSync,
|
|
132
|
+
import { cpSync, existsSync, lstatSync, readFileSync } from 'node:fs';
|
|
133
133
|
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,24 +147,26 @@ 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
|
-
import { runPipeline,
|
|
153
|
+
import { runPipeline, sourcesByResourceId } from '../pipeline.js';
|
|
153
154
|
import { digestPytestInputs, interpreterIdentity, pytestCacheKey, readPytestCache, resolveCacheControl, writePytestCache, } from '../run-cache.js';
|
|
154
155
|
import { RuntimeBlockError, loadRuntimeConfigAt, prepareRuntime } from '../runtime.js';
|
|
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';
|
|
160
|
-
import { assertRuntimeReuseOwnerApproval, freezeCommitCandidate, freezeStagedCandidate, materializeStagedCandidate, recheckStagedCandidate, releaseStagedCandidate, StagedCandidateBlockError, } from '../staged-candidate.js';
|
|
161
|
+
import { computeEvaluationScope, detectStagedWorkingTreeMismatches, testToolingSourceConflicts, } from '../scope.js';
|
|
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';
|
|
163
165
|
import { assertReceiptApprovedPolicy, evaluateApprovedPolicy, resolveApprovedPolicyDigest, } from '../trusted-policy.js';
|
|
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,25 +593,27 @@ 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
|
|
549
601
|
// create them — yet the input snapshot distinguishes an EMPTY optional
|
|
550
602
|
// config directory (adapters/waivers) from a MISSING one through
|
|
551
|
-
// explicit absence markers
|
|
552
|
-
//
|
|
553
|
-
//
|
|
554
|
-
// staged
|
|
603
|
+
// explicit absence markers, and so does the trusted-policy digest entry
|
|
604
|
+
// list. `mirrorEmptyConfigDirs` is the ONE implementation of that
|
|
605
|
+
// mirroring, shared with every other surface that digests or snapshots
|
|
606
|
+
// the staged checkout (`enforcement pin`, doctor, the pre-commit gate),
|
|
607
|
+
// so all of them compute the same digest for the same bytes. The bytes
|
|
608
|
+
// stay exactly the staged tree; only the marker-relevant empty dirs are
|
|
609
|
+
// mirrored, and only for a STAGED index (a candidate commit tree is
|
|
610
|
+
// gated on its own contents, never on the worktree around it).
|
|
555
611
|
const checkoutConfig = loadConfigAt(checkoutDir);
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
if (options.candidateCommitSha === undefined && existsSync(userDir) && !existsSync(checkoutPath)) {
|
|
562
|
-
mkdirSync(checkoutPath, { recursive: true });
|
|
563
|
-
}
|
|
564
|
-
}
|
|
612
|
+
docsExclusions = loadDocsExclusions(checkoutDir, checkoutConfig);
|
|
613
|
+
cacheExclusions = loadCacheExclusions(checkoutDir, checkoutConfig);
|
|
614
|
+
mirrorEmptyConfigDirs(io.cwd, checkoutDir, checkoutConfig, {
|
|
615
|
+
fromStagedIndex: options.candidateCommitSha === undefined,
|
|
616
|
+
});
|
|
565
617
|
// The candidate's own staged-runtime document prepares ITS checkout
|
|
566
618
|
// (dependency reuse + tracked preparation command) — discovery reads
|
|
567
619
|
// installed tooling from the candidate, never the worktree. The
|
|
@@ -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
|