@gate-forge/cli 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +51 -6
  2. package/dist/args.js +1 -1
  3. package/dist/args.js.map +1 -1
  4. package/dist/broker.d.ts.map +1 -1
  5. package/dist/broker.js +10 -14
  6. package/dist/broker.js.map +1 -1
  7. package/dist/cli.d.ts +2 -8
  8. package/dist/cli.d.ts.map +1 -1
  9. package/dist/cli.js +9 -10
  10. package/dist/cli.js.map +1 -1
  11. package/dist/commands/blocking.d.ts +3 -0
  12. package/dist/commands/blocking.d.ts.map +1 -1
  13. package/dist/commands/blocking.js +38 -2
  14. package/dist/commands/blocking.js.map +1 -1
  15. package/dist/commands/check.d.ts +40 -0
  16. package/dist/commands/check.d.ts.map +1 -1
  17. package/dist/commands/check.js +37 -4
  18. package/dist/commands/check.js.map +1 -1
  19. package/dist/commands/init.d.ts.map +1 -1
  20. package/dist/commands/init.js +54 -97
  21. package/dist/commands/init.js.map +1 -1
  22. package/dist/commands/pre-commit.d.ts +5 -0
  23. package/dist/commands/pre-commit.d.ts.map +1 -0
  24. package/dist/commands/pre-commit.js +213 -0
  25. package/dist/commands/pre-commit.js.map +1 -0
  26. package/dist/commands/test-gates.d.ts +51 -0
  27. package/dist/commands/test-gates.d.ts.map +1 -1
  28. package/dist/commands/test-gates.js +32 -22
  29. package/dist/commands/test-gates.js.map +1 -1
  30. package/dist/execution.d.ts +1 -0
  31. package/dist/execution.d.ts.map +1 -1
  32. package/dist/execution.js +9 -0
  33. package/dist/execution.js.map +1 -1
  34. package/dist/git-hooks.d.ts +7 -2
  35. package/dist/git-hooks.d.ts.map +1 -1
  36. package/dist/git-hooks.js +48 -12
  37. package/dist/git-hooks.js.map +1 -1
  38. package/dist/input-snapshot.d.ts +5 -1
  39. package/dist/input-snapshot.d.ts.map +1 -1
  40. package/dist/input-snapshot.js +6 -3
  41. package/dist/input-snapshot.js.map +1 -1
  42. package/dist/io.d.ts +0 -3
  43. package/dist/io.d.ts.map +1 -1
  44. package/dist/io.js.map +1 -1
  45. package/dist/pipeline.d.ts.map +1 -1
  46. package/dist/pipeline.js +29 -7
  47. package/dist/pipeline.js.map +1 -1
  48. package/dist/runtime.d.ts +114 -0
  49. package/dist/runtime.d.ts.map +1 -0
  50. package/dist/runtime.js +682 -0
  51. package/dist/runtime.js.map +1 -0
  52. package/dist/staged-candidate.d.ts +1 -1
  53. package/dist/staged-candidate.d.ts.map +1 -1
  54. package/dist/staged-candidate.js +5 -4
  55. package/dist/staged-candidate.js.map +1 -1
  56. package/package.json +9 -9
  57. package/dist/commands/controller.d.ts +0 -43
  58. package/dist/commands/controller.d.ts.map +0 -1
  59. package/dist/commands/controller.js +0 -110
  60. package/dist/commands/controller.js.map +0 -1
  61. package/dist/isolation.d.ts +0 -104
  62. package/dist/isolation.d.ts.map +0 -1
  63. package/dist/isolation.js +0 -353
  64. package/dist/isolation.js.map +0 -1
  65. package/dist/podman-bootstrap.d.ts +0 -59
  66. package/dist/podman-bootstrap.d.ts.map +0 -1
  67. package/dist/podman-bootstrap.js +0 -123
  68. package/dist/podman-bootstrap.js.map +0 -1
@@ -0,0 +1,213 @@
1
+ /**
2
+ * Witnessed pre-commit orchestration over the exact staged candidate.
3
+ *
4
+ * The command freezes and materializes the Git index, prepares the
5
+ * candidate's staged runtime (owner-reviewed `.gateforge/runtime.yml`:
6
+ * sanctioned dependency reuse, frozen preparation command, candidate-
7
+ * owned application/database services started from the checkout bytes),
8
+ * executes the supervised witness run inside that checkout, validates
9
+ * its receipt, and rechecks the original index before it authorizes the
10
+ * commit.
11
+ */
12
+ import { cpSync, existsSync, mkdirSync } from 'node:fs';
13
+ import { dirname } from 'node:path';
14
+ import { CAUSE_NEXT_ACTIONS } from '@gate-forge/core';
15
+ import { parseArgs, stringFlag } from '../args.js';
16
+ import { computeCandidateTreeId, resolveGitDir } from '../candidate-tree.js';
17
+ import { trustedPolicyDigestForConfig } from '../execution.js';
18
+ import { UsageError } from '../errors.js';
19
+ import { writeLine } from '../io.js';
20
+ import { RuntimeBlockError, loadRuntimeConfigAt, prepareRuntime, startRuntimeServices, stopRuntimeChildren, runtimeReuseDigest as computeRuntimeReuseDigest, } from '../runtime.js';
21
+ import { freezeStagedCandidate, materializeStagedCandidate, recheckStagedCandidate, releaseStagedCandidate, StagedCandidateBlockError, } from '../staged-candidate.js';
22
+ import { resolveStateDir } from '../state.js';
23
+ import { loadConfigAt, rejectUnknownFlags } from './common.js';
24
+ import { runCheckGate } from './check.js';
25
+ import { runSupervisedTestGates } from './test-gates.js';
26
+ import { evaluateApprovedPolicy, resolveApprovedPolicyDigest } from '../trusted-policy.js';
27
+ export const PRE_COMMIT_USAGE = 'usage: gateforge pre-commit --scope staged|full\n' +
28
+ ' staged: run tests mapped to obligations affected by staged files\n' +
29
+ ' full: run the complete relevant mapped suite\n' +
30
+ ' both modes execute against the exact frozen index and require the normal witness runtime';
31
+ /** Runs a complete witnessed pre-commit gate against the frozen index. */
32
+ export async function preCommitCommand(io, argv) {
33
+ const { options } = parseArgs(argv);
34
+ if (options['help'] === true) {
35
+ writeLine(io.stdout, PRE_COMMIT_USAGE);
36
+ return 0;
37
+ }
38
+ rejectUnknownFlags(options, ['scope', 'help'], PRE_COMMIT_USAGE);
39
+ const scope = stringFlag(options, 'scope');
40
+ if (scope !== 'staged' && scope !== 'full') {
41
+ throw new UsageError("pre-commit: --scope must be 'staged' or 'full'");
42
+ }
43
+ let frozen;
44
+ try {
45
+ frozen = freezeStagedCandidate(io.cwd, io.env);
46
+ }
47
+ catch (error) {
48
+ if (error instanceof StagedCandidateBlockError)
49
+ return renderCandidateBlock(io, error.message, error.nextAction);
50
+ throw error;
51
+ }
52
+ const previousCwd = process.cwd();
53
+ let runtime = null;
54
+ let runtimeReuseDigest = null;
55
+ let preparedRuntime = null;
56
+ // Interruption safety: while candidate services are alive, SIGINT/
57
+ // SIGTERM tear the process groups down BEFORE the gate dies (the
58
+ // handlers restore the default disposition and re-raise so the shell
59
+ // observes the original signal).
60
+ const interruptSignals = ['SIGINT', 'SIGTERM'];
61
+ const interruptHandlers = new Map();
62
+ const armInterruptHandlers = () => {
63
+ for (const signal of interruptSignals) {
64
+ const handler = () => {
65
+ const teardown = runtime === null ? stopRuntimeChildren() : runtime.stop();
66
+ void teardown.finally(() => {
67
+ process.kill(process.pid, signal);
68
+ });
69
+ };
70
+ interruptHandlers.set(signal, handler);
71
+ process.once(signal, handler);
72
+ }
73
+ };
74
+ const disarmInterruptHandlers = () => {
75
+ for (const [signal, handler] of interruptHandlers)
76
+ process.removeListener(signal, handler);
77
+ interruptHandlers.clear();
78
+ };
79
+ try {
80
+ const checkoutDir = materializeStagedCandidate(io.cwd, io.env, frozen);
81
+ // Candidate run state starts as a copy of the user's (supervision
82
+ // artifacts only); runtime logs land there and are copied BACK after
83
+ // the run — the only bytes that ever leave the scratch checkout.
84
+ copyStateIfPresent(io.cwd, checkoutDir);
85
+ const candidateStateDir = resolveStateDir(checkoutDir);
86
+ const checkoutConfig = loadConfigAt(checkoutDir);
87
+ // The runtime document contains executable commands. Evaluate the same
88
+ // owner-approved policy gate used by supervised runs BEFORE any prepare
89
+ // or service command can start in the staged checkout.
90
+ const policyResolution = resolveApprovedPolicyDigest({
91
+ env: io.env,
92
+ candidateCwd: checkoutDir,
93
+ candidateConfig: checkoutConfig,
94
+ });
95
+ const policyGate = evaluateApprovedPolicy(policyResolution, trustedPolicyDigestForConfig(checkoutDir, checkoutConfig), checkoutConfig.enforcement?.strictE2E === true);
96
+ if (policyGate.status === 'blocked') {
97
+ return renderCandidateBlock(io, policyGate.detail, policyGate.nextAction);
98
+ }
99
+ const runtimeDoc = loadRuntimeConfigAt(checkoutDir, checkoutConfig.runtime);
100
+ if (runtimeDoc !== null) {
101
+ preparedRuntime = runtimeDoc;
102
+ // Armed BEFORE preparation: a SIGINT during a long prepare (or a
103
+ // readiness wait) still tears the detached process groups down.
104
+ armInterruptHandlers();
105
+ runtimeReuseDigest = (await prepareRuntime(io.cwd, checkoutDir, runtimeDoc, io, candidateStateDir)).reuseDigest;
106
+ runtime = await startRuntimeServices(checkoutDir, runtimeDoc, io, candidateStateDir);
107
+ }
108
+ process.chdir(checkoutDir);
109
+ // When the candidate runtime owns the attested target, ITS binding
110
+ // overrides any operator-provided target env: the witnessed subject
111
+ // must be the process this gate started from the checkout, never a
112
+ // URL the surrounding shell names.
113
+ const candidateEnv = { ...io.env };
114
+ if (runtime?.targetBaseUrl !== null && runtime?.targetBaseUrl !== undefined) {
115
+ candidateEnv['GATEFORGE_APP_BASE_URL'] = runtime.targetBaseUrl;
116
+ candidateEnv['GATEFORGE_TARGET_BASE_URL'] = runtime.targetBaseUrl;
117
+ candidateEnv['GATEFORGE_TARGET_FINGERPRINT'] = runtime.targetFingerprint ?? '';
118
+ }
119
+ const candidateIo = { ...io, cwd: checkoutDir, env: candidateEnv };
120
+ // The seal-time drift check recomputes the candidate tree by raw
121
+ // ingestion of the RUN WORKSPACE (the checkout, run state excluded).
122
+ // The trusted override must be the SAME computation over the prepared
123
+ // checkout — the frozen INDEX tree alone never matches it (prepared
124
+ // runtime artifacts are part of the tested workspace). The authenticated
125
+ // input digest also carries the deterministic bytes digest for any
126
+ // sanctioned external reuse link. The user-index binding stays with
127
+ // recheckStagedCandidate below.
128
+ const checkoutGitDir = resolveGitDir(checkoutDir, io.env);
129
+ const candidateTreeId = checkoutGitDir === null
130
+ ? undefined
131
+ : computeCandidateTreeId(checkoutGitDir, checkoutDir, io.env, candidateStateDir, 'record');
132
+ const runCode = await runSupervisedTestGates(candidateIo, {
133
+ out: undefined,
134
+ format: 'text',
135
+ witnessUrl: undefined,
136
+ runToken: undefined,
137
+ runTimeoutMs: runtimeDoc?.executionTimeoutSeconds !== undefined ? runtimeDoc.executionTimeoutSeconds * 1_000 : undefined,
138
+ scope: scope === 'staged' ? 'changed' : 'full',
139
+ fixedChangedFiles: frozen.changedPaths,
140
+ fixedCandidateTreeId: candidateTreeId,
141
+ fixedParentSha: frozen.headSha,
142
+ runtimeReuseDigest,
143
+ runtimeReuseCheck: preparedRuntime === null ? undefined : () => computeRuntimeReuseDigest(io.cwd, preparedRuntime),
144
+ });
145
+ const checkCode = runCode === 0
146
+ ? await runCheckGate(candidateIo, {
147
+ diffScoped: scope === 'staged',
148
+ requireE2E: true,
149
+ format: 'text',
150
+ fixedChangedFiles: frozen.changedPaths,
151
+ runtimeReuseDigest,
152
+ })
153
+ : runCode;
154
+ copyStateIfPresent(checkoutDir, io.cwd);
155
+ const recheck = recheckStagedCandidate(io.cwd, io.env, frozen);
156
+ if (!recheck.ok) {
157
+ return renderCandidateBlock(io, recheck.detail, 'Restage the intended bytes and run the pre-commit gate again.');
158
+ }
159
+ return checkCode;
160
+ }
161
+ catch (error) {
162
+ if (error instanceof RuntimeBlockError) {
163
+ return renderRuntimeBlock(io, error);
164
+ }
165
+ if (error instanceof StagedCandidateBlockError)
166
+ return renderCandidateBlock(io, error.message, error.nextAction);
167
+ throw error;
168
+ }
169
+ finally {
170
+ disarmInterruptHandlers();
171
+ if (runtime !== null)
172
+ await runtime.stop();
173
+ if (process.cwd() !== previousCwd)
174
+ process.chdir(previousCwd);
175
+ releaseStagedCandidate(frozen);
176
+ }
177
+ }
178
+ /** Copies Gateforge run-state artifacts between the user and candidate trees. */
179
+ function copyStateIfPresent(sourceRoot, destinationRoot) {
180
+ const source = resolveStateDir(sourceRoot);
181
+ if (!existsSync(source))
182
+ return;
183
+ const destination = resolveStateDir(destinationRoot);
184
+ mkdirSync(dirname(destination), { recursive: true });
185
+ cpSync(source, destination, { recursive: true, force: true });
186
+ }
187
+ /** Prints a deterministic staged-candidate failure. */
188
+ function renderCandidateBlock(io, detail, nextAction) {
189
+ writeLine(io.stdout, 'witnessed pre-commit gate: BLOCKED');
190
+ writeLine(io.stdout, 'cause: ENFORCEMENT_UNTRUSTED');
191
+ writeLine(io.stdout, `detail: ${detail}`);
192
+ writeLine(io.stdout, `next action: ${nextAction}`);
193
+ return 1;
194
+ }
195
+ /**
196
+ * Prints a deterministic typed runtime failure (preparation or
197
+ * readiness) with the shared next action for its cause code.
198
+ *
199
+ * Args:
200
+ * io: process context.
201
+ * error: the typed runtime block.
202
+ *
203
+ * Returns:
204
+ * number: 1 (blocking).
205
+ */
206
+ function renderRuntimeBlock(io, error) {
207
+ writeLine(io.stdout, 'witnessed pre-commit gate: BLOCKED');
208
+ writeLine(io.stdout, `cause: ${error.causeCode}`);
209
+ writeLine(io.stdout, `detail: ${error.message}`);
210
+ writeLine(io.stdout, `next action: ${CAUSE_NEXT_ACTIONS[error.causeCode]}`);
211
+ return 1;
212
+ }
213
+ //# sourceMappingURL=pre-commit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pre-commit.js","sourceRoot":"","sources":["../../src/commands/pre-commit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAsB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,IAAI,yBAAyB,GAEhD,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,GAE1B,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kBAAkB,CAAC,EAAM,EAAE,KAAwB;IAC1D,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;IAC3D,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;IAClD,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC5E,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -32,6 +32,57 @@ export declare function testGatesCommand(io: Io, argv: readonly string[]): Promi
32
32
  * @throws UsageError on non-integer, out-of-range, or repeated values.
33
33
  */
34
34
  export declare function parseRunTimeoutMin(raw: string | undefined): number | undefined;
35
+ /** Options of the supervised (`--changed`) path. */
36
+ export interface SupervisedOptions {
37
+ /** State-dir override. */
38
+ out: string | undefined;
39
+ /** Report format. */
40
+ format: 'text' | 'json' | 'sarif';
41
+ /** External witness URL (the caller owns the witness). */
42
+ witnessUrl: string | undefined;
43
+ /** External witness run token. */
44
+ runToken: string | undefined;
45
+ /** Whole-run wall-clock bound ms (undefined = 30-minute default). */
46
+ runTimeoutMs: number | undefined;
47
+ /**
48
+ * Evaluation scope (Goal 2): `full` (default, unchanged behavior) runs
49
+ * the whole relevant suite and seals a whole-repo receipt; `changed`
50
+ * runs and seals only the affected slice.
51
+ */
52
+ scope: 'full' | 'changed';
53
+ /** Trusted staged-candidate changed paths supplied by the pre-commit orchestrator. */
54
+ fixedChangedFiles?: readonly string[];
55
+ /** Trusted staged-candidate tree id supplied by the pre-commit orchestrator. */
56
+ fixedCandidateTreeId?: string;
57
+ /** Trusted parent sha supplied by the pre-commit orchestrator. */
58
+ fixedParentSha?: string | null;
59
+ /** Digest of dependency bytes reused by the staged candidate runtime. */
60
+ runtimeReuseDigest?: string | null;
61
+ /** Recomputes the external reuse digest at the end of a staged run. */
62
+ runtimeReuseCheck?: () => string | null;
63
+ }
64
+ /**
65
+ * The supervised `--changed` path (plan Phase 4, ADR 0005 D2/D3):
66
+ * resolve catalog + mappings → fix the expected set → prepare the
67
+ * observer → REGISTER the expected set with the witness from an
68
+ * independent `playwright --list` child (scrubbed env, finite timeout) →
69
+ * execute through the adapter under the supervisor spool drain → enforce
70
+ * planned vs executed + the witness-side session trace → seal the
71
+ * execution result → run diagnostics (separate, advisory) → evaluate →
72
+ * issue the gate receipt only on complete success. Identical
73
+ * authenticated inputs reuse a prior receipt (printed, exit reflects the
74
+ * current gate evaluation); any changed input forces a fresh run.
75
+ *
76
+ * Args:
77
+ * io: process context.
78
+ * options: parsed flags.
79
+ *
80
+ * Returns:
81
+ * Promise<number>: exit code — 0 clean (or reused clean receipt), 1
82
+ * supervision/evidence failure, 2 config/usage.
83
+ * @throws fail-closed errors (exit 2) from config/plugin/pipeline layers.
84
+ */
85
+ export declare function runSupervisedTestGates(io: Io, options: SupervisedOptions): Promise<number>;
35
86
  /**
36
87
  * Computes the receipt's executed-case digest from only authenticated,
37
88
  * schema-valid behavior.case records that the evaluator used for a
@@ -1 +1 @@
1
- {"version":3,"file":"test-gates.d.ts","sourceRoot":"","sources":["../../src/commands/test-gates.ts"],"names":[],"mappings":"AA2DA,OAAO,EAmBL,KAAK,eAAe,EAIpB,KAAK,iBAAiB,EAKvB,MAAM,kBAAkB,CAAC;AAe1B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAiDnC,eAAO,MAAM,gBAAgB,QAOgF,CAAC;AAE9G;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAgDvF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,G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,gFAAgF;IAChF,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kEAAkE;IAClE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,yEAAyE;IACzE,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,uEAAuE;IACvE,iBAAiB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;CACzC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CA44BhG;AAiED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,eAAe,GAAG,IAAI,EACvC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,GACrC,MAAM,CAgDR"}
@@ -57,7 +57,7 @@ import { spawn, spawnSync } from 'node:child_process';
57
57
  import { randomUUID } from 'node:crypto';
58
58
  import { readFileSync, writeFileSync } from 'node:fs';
59
59
  import { join } from 'node:path';
60
- import { AttestationSchema, BEHAVIOR_CASE_KIND, BehaviorCasePayloadSchema, CAUSE_NEXT_ACTIONS, canonicalJson, caseExecutionDigestOf, EMPTY_BEHAVIOR_CATALOG_DIGEST, engineBundleDigestOf, EvidenceRecordSchema, isWitnessedRecord, renderRun, requiredCaseSetDigestOf, runExitCode, sha256Canonical, selectionDigestOf, targetArtifactDigestOf, verifyAttestationMac, } from '@gate-forge/core';
60
+ import { AttestationSchema, BEHAVIOR_CASE_KIND, BehaviorCasePayloadSchema, CAUSE_NEXT_ACTIONS, canonicalJson, caseExecutionDigestOf, EMPTY_BEHAVIOR_CATALOG_DIGEST, engineBundleDigestOf, EvidenceRecordSchema, executionBoundaryDigestOf, LOCAL_UNISOLATED_BOUNDARY, isWitnessedRecord, renderRun, requiredCaseSetDigestOf, runExitCode, sha256Canonical, selectionDigestOf, targetArtifactDigestOf, verifyAttestationMac, } from '@gate-forge/core';
61
61
  import { buildWitnessedPytestChildEnv, discoverTestCatalog, listNativePlaywrightTests, PlaywrightAdapter, readRunnerOutcomes, startSupervisorSpoolDrain, startWitnessProcess, SupervisorClient, TestDiscoveryError, } from '@gate-forge/pack-playwright';
62
62
  import { parseArgs, stringFlag } from '../args.js';
63
63
  import { resolveAdoptedBaseline } from '../adopted-baseline.js';
@@ -73,7 +73,6 @@ import { tryReuseReceipt } from '../receipts.js';
73
73
  import { computeCandidateTreeId, resolveGitDir } from '../candidate-tree.js';
74
74
  import { resolveProvider } from '../providers.js';
75
75
  import { assertReceiptApprovedPolicy, evaluateApprovedPolicy, resolveApprovedPolicyDigest } from '../trusted-policy.js';
76
- import { isolationProfileForEnvironment, resolveIsolation } from '../isolation.js';
77
76
  import { clearGateReceipt, httpRoutesView, readJsonArray, resolveStateDir, stateObligations, writeClaimInjections, writeClassificationsView, writeEnv, writeExecutionResult, writeGateReceipt, writeHttpRoutesView, writeManifest, writeObligations, writeReport, } from '../state.js';
78
77
  import { loadConfigAt, parseRunFormat, rejectUnknownFlags, VERIFIER_KEY_ENV, VERSION } from './common.js';
79
78
  export const TEST_GATES_USAGE = 'usage: gateforge test-gates [--changed] [--scope full|changed] [--suite <command>] [--out <dir>] ' +
@@ -127,7 +126,7 @@ export async function testGatesCommand(io, argv) {
127
126
  scope = scopeFlag;
128
127
  }
129
128
  if (changed) {
130
- return supervisedTestGates(io, {
129
+ return runSupervisedTestGates(io, {
131
130
  out,
132
131
  format,
133
132
  witnessUrl,
@@ -438,28 +437,24 @@ async function legacyTestGates(io, options) {
438
437
  * supervision/evidence failure, 2 config/usage.
439
438
  * @throws fail-closed errors (exit 2) from config/plugin/pipeline layers.
440
439
  */
441
- async function supervisedTestGates(io, options) {
440
+ export async function runSupervisedTestGates(io, options) {
442
441
  const { out, format, witnessUrl, runTimeoutMs } = options;
442
+ const runtimeReuseDigest = options.runtimeReuseDigest;
443
443
  const witnessVerifierKey = io.env[VERIFIER_KEY_ENV];
444
444
  const config = loadConfigAt(io.cwd);
445
445
  const stateDir = resolveStateDir(io.cwd, out);
446
- // The authority owns the requested profile. Candidate configuration never
447
- // selects managed mode, and a managed request never falls back to local.
448
- const isolationProfile = isolationProfileForEnvironment(io.env);
449
- const isolation = resolveIsolation({
450
- profile: isolationProfile,
451
- candidateDir: io.cwd,
452
- engineBundleDir: io.env['GATEFORGE_ENGINE_BUNDLE_DIR'] ?? (isolationProfile === 'podman-rootless' ? '/engine' : ''),
453
- appStateDir: stateDir,
454
- }, io.env);
446
+ const executionBoundary = io.env['GATEFORGE_AUTHORITY_BOUNDARY']?.trim() || LOCAL_UNISOLATED_BOUNDARY;
447
+ const executionBoundaryDigest = executionBoundaryDigestOf(executionBoundary);
455
448
  // Scoped sealing (Goal 2): resolve the changed-file basis through the
456
449
  // SAME configured provider `check --changed` uses (auto → GHA/GitLab/
457
450
  // staged), and stamp the resolved identity into the run manifest so a
458
451
  // scoped run names the diff basis it sliced from. Full mode keeps
459
452
  // `all-files` — byte-identical to the historical run.
460
- const providerIdentity = options.scope === 'changed'
461
- ? resolveProvider(config.changed.provider, io.cwd, io.env).provider
462
- : 'all-files';
453
+ const providerIdentity = options.fixedChangedFiles !== undefined
454
+ ? 'local-staged'
455
+ : options.scope === 'changed'
456
+ ? resolveProvider(config.changed.provider, io.cwd, io.env).provider
457
+ : 'all-files';
463
458
  // 1. Inventory + stability + input digest (same discipline as check).
464
459
  let preFiles = null;
465
460
  let snapshotUnavailable = false;
@@ -480,11 +475,16 @@ async function supervisedTestGates(io, options) {
480
475
  config,
481
476
  provider: providerIdentity,
482
477
  stateDir,
478
+ ...(options.fixedChangedFiles !== undefined
479
+ ? { changedFilesOverride: options.fixedChangedFiles }
480
+ : {}),
483
481
  });
484
482
  // The scoped slice's changed set: exactly what the resolved provider
485
483
  // reported for THIS tree (the pipeline already ran it — one resolution,
486
484
  // one diff basis stamped in the manifest).
487
- const scopeChangedFiles = options.scope === 'changed' ? pipeline.changedFiles : null;
485
+ const scopeChangedFiles = options.scope === 'changed'
486
+ ? options.fixedChangedFiles ?? pipeline.changedFiles
487
+ : null;
488
488
  const httpRoutes = httpRoutesView(pipeline.graph);
489
489
  let expectedDigest = null;
490
490
  if (!snapshotUnavailable) {
@@ -502,6 +502,7 @@ async function supervisedTestGates(io, options) {
502
502
  obligations: pipeline.policy.obligations,
503
503
  httpRoutes,
504
504
  plugins: pipeline.manifest.plugins.map((plugin) => ({ id: plugin.id, version: plugin.version })),
505
+ runtimeReuseDigest,
505
506
  }).inputDigest;
506
507
  }
507
508
  const invocationId = randomUUID();
@@ -510,8 +511,9 @@ async function supervisedTestGates(io, options) {
510
511
  // same values are recomputed — a live-workspace edit mid-run is an
511
512
  // explicit drift block, never a mixed-bytes seal.
512
513
  const freezeGitDir = resolveGitDir(io.cwd, io.env);
513
- const frozenTreeId = freezeGitDir === null ? null : computeCandidateTreeId(freezeGitDir, io.cwd, io.env, stateDir, 'record');
514
- const frozenParentSha = parentSha(io.cwd);
514
+ const frozenTreeId = options.fixedCandidateTreeId ??
515
+ (freezeGitDir === null ? null : computeCandidateTreeId(freezeGitDir, io.cwd, io.env, stateDir, 'record'));
516
+ const frozenParentSha = options.fixedParentSha !== undefined ? options.fixedParentSha : parentSha(io.cwd);
515
517
  // 2. Catalog + mappings (Phase 3 resolver) → expected set + claim
516
518
  // injections + typed mapping blockers. A failed discovery blocks the
517
519
  // gate (E16) — never an empty-success fallback.
@@ -663,7 +665,7 @@ async function supervisedTestGates(io, options) {
663
665
  trustedPolicyDigest: trustedPolicy,
664
666
  selectionDigest,
665
667
  candidateTreeId: frozenTreeId,
666
- executionBoundaryDigest: isolation.boundaryDigest,
668
+ executionBoundaryDigest,
667
669
  ...behaviorReceiptBindings(pipeline.behaviorCatalog),
668
670
  scope: options.scope === 'changed' ? 'changed' : 'full',
669
671
  ...(options.scope === 'changed' ? { coveredObligationFingerprints: coveredFingerprints } : {}),
@@ -1058,6 +1060,14 @@ async function supervisedTestGates(io, options) {
1058
1060
  await stopWitnessProcess(spawnedWitness);
1059
1061
  }
1060
1062
  }
1063
+ if (options.runtimeReuseCheck !== undefined) {
1064
+ const currentReuseDigest = options.runtimeReuseCheck();
1065
+ if (currentReuseDigest !== runtimeReuseDigest) {
1066
+ clearGateReceipt(stateDir);
1067
+ writeLine(io.stderr, 'test-gates: reused dependency bytes changed during the run; no receipt is sealed over mixed runtime inputs');
1068
+ return 1;
1069
+ }
1070
+ }
1061
1071
  const outcomesDoc = readRunnerOutcomes(join(stateDir, 'runner-outcomes.json'));
1062
1072
  const sealed = sealExecutionResult({
1063
1073
  runId: manifest.runId,
@@ -1226,7 +1236,7 @@ async function supervisedTestGates(io, options) {
1226
1236
  // (the drift-checked seal-time value, equal to the frozen evaluation tree),
1227
1237
  // the behavior catalog + required case set, authenticated executed
1228
1238
  // behavior cases that contributed to satisfied verdicts, the engine
1229
- // bundle, the controller-inspected execution boundary, and target artifact.
1239
+ // bundle, the execution boundary, and target artifact.
1230
1240
  const candidateTreeId = sealTreeId;
1231
1241
  const behaviorBindings = behaviorReceiptBindings(pipeline.behaviorCatalog);
1232
1242
  const receipt = issueGateReceipt({
@@ -1254,7 +1264,7 @@ async function supervisedTestGates(io, options) {
1254
1264
  requiredCaseSetDigest: behaviorBindings.requiredCaseSetDigest,
1255
1265
  caseExecutionDigest: executedBehaviorCaseDigest(stateDir, manifest.runId, pipeline.behaviorCatalog, evaluated.verdicts),
1256
1266
  engineBundleDigest: engineBundleDigestOf(VERSION, trustedPolicy),
1257
- executionBoundaryDigest: isolation.boundaryDigest,
1267
+ executionBoundaryDigest,
1258
1268
  targetArtifactDigest: targetArtifactDigestOf(candidateTreeId),
1259
1269
  verdictSummary: {
1260
1270
  total: evaluated.verdicts.length,