@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.
Files changed (53) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +2 -0
  3. package/dist/adoption-mode.d.ts +37 -0
  4. package/dist/adoption-mode.d.ts.map +1 -0
  5. package/dist/adoption-mode.js +101 -0
  6. package/dist/adoption-mode.js.map +1 -0
  7. package/dist/commands/check.d.ts.map +1 -1
  8. package/dist/commands/check.js +185 -15
  9. package/dist/commands/check.js.map +1 -1
  10. package/dist/commands/enforcement.d.ts +19 -0
  11. package/dist/commands/enforcement.d.ts.map +1 -1
  12. package/dist/commands/enforcement.js +69 -3
  13. package/dist/commands/enforcement.js.map +1 -1
  14. package/dist/commands/explain.js +3 -1
  15. package/dist/commands/explain.js.map +1 -1
  16. package/dist/commands/pre-commit.d.ts.map +1 -1
  17. package/dist/commands/pre-commit.js +1 -0
  18. package/dist/commands/pre-commit.js.map +1 -1
  19. package/dist/commands/test-gates.d.ts +12 -1
  20. package/dist/commands/test-gates.d.ts.map +1 -1
  21. package/dist/commands/test-gates.js +285 -11
  22. package/dist/commands/test-gates.js.map +1 -1
  23. package/dist/evaluate.d.ts +34 -0
  24. package/dist/evaluate.d.ts.map +1 -1
  25. package/dist/evaluate.js +57 -29
  26. package/dist/evaluate.js.map +1 -1
  27. package/dist/execution.d.ts +26 -2
  28. package/dist/execution.d.ts.map +1 -1
  29. package/dist/execution.js +80 -2
  30. package/dist/execution.js.map +1 -1
  31. package/dist/input-snapshot.d.ts.map +1 -1
  32. package/dist/input-snapshot.js +20 -1
  33. package/dist/input-snapshot.js.map +1 -1
  34. package/dist/runtime.d.ts +29 -0
  35. package/dist/runtime.d.ts.map +1 -1
  36. package/dist/runtime.js +39 -0
  37. package/dist/runtime.js.map +1 -1
  38. package/dist/scope.d.ts +81 -0
  39. package/dist/scope.d.ts.map +1 -1
  40. package/dist/scope.js +101 -2
  41. package/dist/scope.js.map +1 -1
  42. package/dist/staged-candidate.d.ts +12 -0
  43. package/dist/staged-candidate.d.ts.map +1 -1
  44. package/dist/staged-candidate.js +27 -6
  45. package/dist/staged-candidate.js.map +1 -1
  46. package/dist/test-infrastructure.d.ts +32 -0
  47. package/dist/test-infrastructure.d.ts.map +1 -0
  48. package/dist/test-infrastructure.js +125 -0
  49. package/dist/test-infrastructure.js.map +1 -0
  50. package/guides/QUICKSTART.md +20 -7
  51. package/guides/REFERENCE.md +160 -0
  52. package/guides/TEST-ENVIRONMENT.md +3 -1
  53. package/package.json +10 -10
@@ -67,7 +67,7 @@ import { UsageError } from '../errors.js';
67
67
  import { writeLine } from '../io.js';
68
68
  import { runDiagnosticSuites, runWitnessedPytestSuites } from '../diagnostics.js';
69
69
  import { claimInjectionsFor, planScopedExpectedSet, trustedPolicyDigestForConfig, issueGateReceipt, issueRunRecord, parentSha, planExpectedSet, plannedProjectScopes, plannedRowsWithProjectDependencies, sealExecutionResult, supervisionBlocking, SUPERVISED_INVOCATION, } from '../execution.js';
70
- import { evaluateRun, scopeBlocking } from '../evaluate.js';
70
+ import { evaluateRun, scopeBlocking, splitBlockingByBaseline } from '../evaluate.js';
71
71
  import { installedPlaywrightCompatibilityError } from '../package-compatibility.js';
72
72
  import { DOCS_EXCLUSIONS_GUARANTEE, loadDocsExclusions } from '../docs-exclusions.js';
73
73
  import { CACHE_EXCLUSIONS_GUARANTEE, loadCacheExclusions } from '../cache-exclusions.js';
@@ -82,10 +82,11 @@ import { obligationFingerprint } from '../evaluate.js';
82
82
  import { computeEvaluationScope } from '../scope.js';
83
83
  import { candidateTreeCoversCommit, computeCandidateTreeSnapshot, listTrackedPaths, resolveGitDir, sanitizedAuthorityEnv } from '../candidate-tree.js';
84
84
  import { acceptedFreezeRequest, classifyGeneratedTargets, planNativeFreeze, preparedCandidateViolations, unfrozenPrerequisiteState, } from '../native-freeze.js';
85
- import { loadRuntimeConfigAt } from '../runtime.js';
85
+ import { loadRuntimeConfigAt, resolveRuntimeReuseDigest } from '../runtime.js';
86
86
  import { mergeRequestScopePreflight, resolveProvider } from '../providers.js';
87
87
  import { engineIdentity, reportEngineLine } from '../engine-identity.js';
88
88
  import { assertReceiptApprovedPolicy, evaluateApprovedPolicy, resolveApprovedPolicyDigest } from '../trusted-policy.js';
89
+ import { unstagedPolicyInputs } from './enforcement.js';
89
90
  import { clearGateReceipt, clearRunRecord, httpRoutesView, readJsonArray, readStateDocument, resolveStateDir, stateObligations, writeClaimInjections, writeClassificationsView, writeEnv, writeExecutionResult, writeCandidateTreeEntries, writeGateReceipt, writeHttpRoutesView, writeInputSnapshot, writeManifest, writeObligations, writeLastFullRunSummary, writeReport, writeRunRecord, writeTwinInventory, writeTwinShapes, } from '../state.js';
90
91
  import { engineGeneratedStateFileFilter } from '../state-artifacts.js';
91
92
  import { loadConfigAt, parseRunFormat, rejectUnknownFlags, VERIFIER_KEY_ENV, VERIFIER_KEY_FILE_ENV, VERSION, } from './common.js';
@@ -94,7 +95,7 @@ import { hostLoadFailureNotices, startHostLoadSampler } from '../host-load.js';
94
95
  import { captureServiceLogs, runHarnessSetup, runHarnessTeardown, } from '../run-reliability.js';
95
96
  import { pruneRunHistory, recordRunHistory } from '../history.js';
96
97
  import { ProgressStream, resolveProgressTarget } from '../progress.js';
97
- import { writeRunScopeView, writeTestFailures } from '../state.js';
98
+ import { writeRunScopeView, writeStateFile, writeTestFailures } from '../state.js';
98
99
  export const TEST_GATES_USAGE = 'usage: gateforge test-gates [--changed] [--scope full|changed] [--suite <command>] [--out <dir>] ' +
99
100
  '[--result-only] [--test <selector>] [--format text|json|sarif] [--witness-url <url>] [--run-token <token>] ' +
100
101
  '[--run-timeout-min <minutes>] [--progress stderr|file:<path>|off|auto] ' +
@@ -224,7 +225,8 @@ export async function testGatesCommand(io, argv) {
224
225
  format,
225
226
  witnessUrl,
226
227
  runToken: stringFlag(options, 'run-token'),
227
- runTimeoutMs: parseRunTimeoutMin(stringFlag(options, 'run-timeout-min')),
228
+ runTimeoutMs: parseRunTimeoutMin(stringFlag(options, 'run-timeout-min')) ?? runtimeRunTimeoutMs(io.cwd),
229
+ stallTimeoutMs: runtimeStallTimeoutMs(io.cwd),
228
230
  progress: progressFlag,
229
231
  scope,
230
232
  resultOnly,
@@ -302,6 +304,57 @@ export function parseRunTimeoutMin(raw) {
302
304
  }
303
305
  return minutes * 60_000;
304
306
  }
307
+ /**
308
+ * The whole-run budget the OWNER declared in the staged runtime document,
309
+ * in milliseconds, or undefined when the document declares none.
310
+ *
311
+ * `runtime.yml`'s `executionTimeoutSeconds` is the owner's budget for a
312
+ * supervised run and the commit hook has always honoured it. Run
313
+ * directly, the same document was ignored and every run died at the
314
+ * 30-minute default — the owner's own runtime document did not apply to
315
+ * the owner's own command. An explicit `--run-timeout-min` still wins, and
316
+ * a document that cannot be read declares nothing: no whole-run cap applies,
317
+ * and the stall bound (see {@link runtimeStallTimeoutMs}) is the only backstop.
318
+ *
319
+ * Args:
320
+ * cwd: absolute repository root.
321
+ *
322
+ * Returns:
323
+ * number | undefined: milliseconds, or undefined when no cap is declared.
324
+ */
325
+ function runtimeRunTimeoutMs(cwd) {
326
+ try {
327
+ const seconds = loadRuntimeConfigAt(cwd, loadConfigAt(cwd).runtime)?.executionTimeoutSeconds;
328
+ return seconds === undefined ? undefined : seconds * 1_000;
329
+ }
330
+ catch {
331
+ return undefined;
332
+ }
333
+ }
334
+ /**
335
+ * The stall bound the OWNER declared in the staged runtime document, in
336
+ * milliseconds, or undefined when the document declares none.
337
+ *
338
+ * `runtime.yml`'s `stallTimeoutSeconds` is the owner's own answer to
339
+ * "how long may my suite go without finishing a test". The engine
340
+ * default stands when the document says nothing, and a document that
341
+ * cannot be read declares nothing.
342
+ *
343
+ * Args:
344
+ * cwd: absolute repository root.
345
+ *
346
+ * Returns:
347
+ * number | undefined: milliseconds, or undefined for the engine default.
348
+ */
349
+ function runtimeStallTimeoutMs(cwd) {
350
+ try {
351
+ const seconds = loadRuntimeConfigAt(cwd, loadConfigAt(cwd).runtime)?.stallTimeoutSeconds;
352
+ return seconds === undefined ? undefined : seconds * 1_000;
353
+ }
354
+ catch {
355
+ return undefined;
356
+ }
357
+ }
305
358
  /**
306
359
  * The legacy `--suite` orchestration (unchanged behavior): materialize
307
360
  * run state, run the user's suite command, evaluate, report.
@@ -601,6 +654,13 @@ async function legacyTestGates(io, options) {
601
654
  const CHAOS_DEFAULT_MAX_DELAY_MS = 400;
602
655
  /** The hard ceiling on a configured bound (a chaos run is a finding tool). */
603
656
  const CHAOS_MAX_DELAY_CEILING_MS = 5_000;
657
+ /**
658
+ * How long the generated freeze controller waits for a valid release
659
+ * when the run declared no whole-run budget. A wait, not a run bound:
660
+ * the controller's own handshake must stay finite whatever the suite's
661
+ * budget is, and the ceiling below already caps it at this value.
662
+ */
663
+ const FREEZE_RELEASE_WAIT_MS = 900_000;
604
664
  /**
605
665
  * Validates `--chaos <seed>` against the same authority contract as
606
666
  * `--test`: a chaos run reports, it never seals, and a seed that is not
@@ -1695,9 +1755,28 @@ function nativePlaywrightConfigDir(cwd) {
1695
1755
  }
1696
1756
  async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames) {
1697
1757
  const { out, format, witnessUrl, runTimeoutMs } = options;
1698
- const runtimeReuseDigest = options.runtimeReuseDigest;
1699
- const runtimeReuseMounts = options.runtimeReuseMounts ?? [];
1758
+ // The stall bound: the caller's value wins (the CLI entry resolved it
1759
+ // from `runtime.yml`), the document is re-read for an in-process
1760
+ // caller that has no value of its own (the commit hook), and the
1761
+ // engine default stands when neither declares one.
1762
+ const stallTimeoutMs = options.stallTimeoutMs ?? runtimeStallTimeoutMs(io.cwd);
1763
+ // The reuse digest is the IDENTITY of the dependency bytes this run
1764
+ // executes against, and it must be the same value whoever computes it.
1765
+ // ONE resolver owns that value: the commit hook hands over the digest
1766
+ // `prepareRuntime` bound AFTER the staged links were made, and every
1767
+ // other surface reads the declared `prepare.reuse` roots of the same
1768
+ // runtime document through `resolveRuntimeReuseDigest` — which
1769
+ // `computeInputSnapshot` itself calls for `check`, `next` and `tests`
1770
+ // when they hand it no digest, so no surface can seal one identity and
1771
+ // verify another. A document that cannot be read, or that declares no
1772
+ // reuse root, binds nothing — the staged candidate is where a declared
1773
+ // root is prepared, and an unbound run fails closed there.
1700
1774
  const config = loadConfigAt(io.cwd);
1775
+ // The `??` here is not a second identity rule: it only lets the
1776
+ // declared roots below stand in when a mounted caller bound nothing at
1777
+ // all, which is also the value the reuse-drift guards compare against.
1778
+ const runtimeReuseDigest = options.runtimeReuseDigest ?? resolveRuntimeReuseDigest(io.cwd, config.runtime);
1779
+ const runtimeReuseMounts = options.runtimeReuseMounts ?? [];
1701
1780
  // The configured runner (plan 2026-09-25, runner-agnostic evidence):
1702
1781
  // `playwright` (the default) keeps the byte-identical supervised path;
1703
1782
  // pytest/vitest/cypress enumerate, execute, and report through the
@@ -1942,6 +2021,23 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
1942
2021
  clearGateReceipt(stateDir);
1943
2022
  writeLine(io.stderr, `test-gates: ${policyGate.cause}: ${policyGate.detail}`);
1944
2023
  writeLine(io.stderr, `next action: ${policyGate.nextAction}`);
2024
+ // The two commands of one pipeline digest DIFFERENT trees: this one
2025
+ // digests the working tree, `check --staged` digests the staged
2026
+ // index. While a policy input is modified-but-unstaged they compute
2027
+ // different digests, so the single owner-approved pin that satisfies
2028
+ // the commit gate refuses HERE, and the remedy the commit gate prints
2029
+ // (`test-gates --changed`) is the command this refusal blocks. Name
2030
+ // the offending files and the remedy that actually clears it.
2031
+ if (policyGate.cause === 'ENFORCEMENT_UNTRUSTED') {
2032
+ const unstaged = unstagedPolicyInputs(io, config);
2033
+ if (unstaged !== null && unstaged.length > 0) {
2034
+ writeLine(io.stderr, 'this run digests the WORKING TREE while `check --staged` digests the STAGED INDEX: ' +
2035
+ 'while a policy input is modified-but-unstaged the two compute different digests, so one ' +
2036
+ `approved pin cannot satisfy both. Policy inputs differing between them: ${unstaged.join(', ')}`);
2037
+ writeLine(io.stderr, 'next action: stage them (`git add` the files above) and re-run, or commit or restore them — ' +
2038
+ 'then re-pin outside the repository if the approved revision changed');
2039
+ }
2040
+ }
1945
2041
  return 1;
1946
2042
  }
1947
2043
  // When the pin is provisioned and matches, the approved revision is
@@ -2626,6 +2722,16 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
2626
2722
  currentTreeId: frozenTreeId,
2627
2723
  evaluatedPaths: scopeDecision.changedFiles,
2628
2724
  });
2725
+ // The policy-debt term reads the ADOPTED-baseline view, not the raw
2726
+ // one. What a carry-forward must never seal over is NEW debt, and the
2727
+ // raw list cannot express that: in a repository that ran `gateforge
2728
+ // adopt` it holds the adopted classification, finding, unclassified
2729
+ // and unresolved entries forever, so the term denied the carry there
2730
+ // altogether. The split keeps the protection and drops only what
2731
+ // adoption forgave — an entry adoption never recorded still blocks —
2732
+ // and it is the same split `applyBaseline` grades through, so the guard
2733
+ // and the grading cannot disagree about what debt is forgiven.
2734
+ const unadoptedPolicyBlocking = splitBlockingByBaseline(adoptedBaseline, pipeline.policy.blocking).kept;
2629
2735
  // A planned re-seal is never a carry-forward: it re-runs the
2630
2736
  // affected tests and seals its own receipt. `affectedTestCount`
2631
2737
  // is the CHANGED-SCOPE plan's count, which a test-only change
@@ -2646,7 +2752,7 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
2646
2752
  scopeBlockers.length === 0 &&
2647
2753
  mappingBlockers.length === 0 &&
2648
2754
  inventoryBlocking.length === 0 &&
2649
- pipeline.policy.blocking.length === 0 &&
2755
+ unadoptedPolicyBlocking.length === 0 &&
2650
2756
  (config.diagnostics?.suites.length ?? 0) === 0 &&
2651
2757
  pipeline.policy.obligations.length === carryParent.receipt.verdictSummary.total &&
2652
2758
  carryParent.receipt.behaviorCatalogDigest === behaviorBindings.behaviorCatalogDigest &&
@@ -2719,6 +2825,157 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
2719
2825
  }
2720
2826
  if (!options.resultOnly)
2721
2827
  clearGateReceipt(stateDir);
2828
+ // 0.10.2 — the docs-only slice seals a receipt over ZERO records.
2829
+ //
2830
+ // The scope decision computed above is the engine-owned exemption: the
2831
+ // WHOLE changed set is `docs/**.md`, so no obligation can arise from it
2832
+ // and no test can prove anything about it. Refusing here (today's
2833
+ // behaviour) left the commit unblockable — no receipt, so the previous
2834
+ // run's durable attestation stayed stale and the very next check
2835
+ // refused the commit for it.
2836
+ //
2837
+ // The receipt binds the CURRENT input digest, candidate tree and
2838
+ // trusted policy digest exactly as any receipt, and covers NOTHING:
2839
+ // a later product change has a different input digest (so this receipt
2840
+ // is stale) and its own obligations (so nothing here could cover them
2841
+ // even if it were current). The empty evidence set is also written out,
2842
+ // replacing the previous run's records: a slice that executed no test
2843
+ // witnessed no record, and leaving the old ledger beside a new receipt
2844
+ // would read as evidence this run never produced.
2845
+ //
2846
+ // Every condition below is CHECKED, never assumed: an unusable digest,
2847
+ // a candidate tree that moved under the run, a missing verifier key, an
2848
+ // incomplete inventory or discovery, a diagnostics suite, a planned
2849
+ // re-seal, or any mapping, scope or inventory blocker all fall through
2850
+ // to today's refusal below, byte-for-byte.
2851
+ //
2852
+ // The RAW policy blocking list is deliberately NOT one of them. It is the
2853
+ // pre-baseline view, so in a repository that adopted debt with
2854
+ // `gateforge adopt` it is never empty and the seal could never engage.
2855
+ // A docs-only change cannot change a policy entry, and the commit gate
2856
+ // (`check`) grades those entries against the adopted baseline exactly as
2857
+ // for every commit; this receipt covers no obligation.
2858
+ const docsOnlySlice = !options.resultOnly &&
2859
+ namedTestIds === null &&
2860
+ catalog !== null &&
2861
+ catalog.inventoryComplete &&
2862
+ discoveryError === null &&
2863
+ reSealPlan === null &&
2864
+ scopeDecision !== null &&
2865
+ scopeDecision.docsOnly &&
2866
+ scopeDecision.mode === 'changed' &&
2867
+ scopeDecision.expandedBecause.length === 0 &&
2868
+ scopeDecision.unmappedFiles.length === 0 &&
2869
+ scopeBlockers.length === 0 &&
2870
+ mappingBlockers.length === 0 &&
2871
+ inventoryBlocking.length === 0 &&
2872
+ (config.diagnostics?.suites.length ?? 0) === 0 &&
2873
+ expectedDigest !== null &&
2874
+ frozenTreeId !== null &&
2875
+ witnessVerifierKey !== undefined;
2876
+ const docsOnlyGitDir = docsOnlySlice ? resolveGitDir(io.cwd, io.env) : null;
2877
+ const docsOnlyTree = docsOnlyGitDir === null
2878
+ ? null
2879
+ : computeCandidateTreeSnapshot(docsOnlyGitDir, io.cwd, io.env, stateDir, 'record', runtimeReuseMounts, docsExclusions, cacheExclusions);
2880
+ // `catalog` is re-checked here so its non-null type reaches the seal
2881
+ // body; `docsOnlySlice` already requires it.
2882
+ if (docsOnlySlice &&
2883
+ catalog !== null &&
2884
+ docsOnlyTree !== null &&
2885
+ docsOnlyTree.treeId === frozenTreeId &&
2886
+ expectedDigest !== null) {
2887
+ const docsOnlySelection = { ...selection, mode: 'docs-only-slice', logicalKeys: [] };
2888
+ const docsOnlyExecution = sealExecutionResult({
2889
+ runId: pipeline.manifest.runId,
2890
+ invocationId,
2891
+ inputDigest: expectedDigest,
2892
+ trustedPolicyDigest: trustedPolicy,
2893
+ runner: runnerName,
2894
+ mode: docsOnlySelection.mode,
2895
+ logicalKeys: docsOnlySelection.logicalKeys,
2896
+ catalog,
2897
+ plannedRows: [],
2898
+ envelope: {
2899
+ processExit: null,
2900
+ complete: true,
2901
+ outcomes: [],
2902
+ // No runner was spawned, so there is no setup or teardown that
2903
+ // could fail — and `planned`/`outcomes` below stay empty, so no
2904
+ // reader can mistake this for an executed test.
2905
+ fixtureOutcome: 'passed',
2906
+ shards: null,
2907
+ retriesDetected: false,
2908
+ },
2909
+ outcomesDoc: null,
2910
+ startedAt: pipeline.now,
2911
+ finishedAt: pipeline.now,
2912
+ });
2913
+ writeManifest(stateDir, pipeline.manifest);
2914
+ if (inputSnapshot !== null)
2915
+ writeInputSnapshot(stateDir, inputSnapshot);
2916
+ writeExecutionResult(stateDir, docsOnlyExecution.result);
2917
+ writeStateFile(stateDir, 'records.json', []);
2918
+ writeStateFile(stateDir, 'claims.json', []);
2919
+ const docsOnlyReceipt = issueGateReceipt({
2920
+ verifierKey: witnessVerifierKey,
2921
+ ...(verifierKeyring === null ? {} : { verifierKeyId: verifierKeyring.active.keyId }),
2922
+ runId: pipeline.manifest.runId,
2923
+ invocationId,
2924
+ inputDigest: expectedDigest,
2925
+ gitSha: pipeline.manifest.gitSha,
2926
+ parentSha: frozenParentSha,
2927
+ trustedPolicyDigest: trustedPolicy,
2928
+ approvedPolicyDigest,
2929
+ ...(config.enforcement?.receiptStage === undefined
2930
+ ? {}
2931
+ : { receiptStage: config.enforcement.receiptStage }),
2932
+ engine: engineIdentity(),
2933
+ invocation: SUPERVISED_INVOCATION,
2934
+ selectionDigest: selectionDigestOf(docsOnlySelection),
2935
+ catalogDigest,
2936
+ scope: 'changed',
2937
+ docsOnly: true,
2938
+ executionResultDigest: docsOnlyExecution.digest,
2939
+ evidenceAttestationDigest: null,
2940
+ candidateTreeId: frozenTreeId,
2941
+ behaviorCatalogDigest: behaviorBindings.behaviorCatalogDigest,
2942
+ requiredCaseSetDigest: behaviorBindings.requiredCaseSetDigest,
2943
+ caseExecutionDigest: executedBehaviorCaseDigest(stateDir, pipeline.manifest.runId, pipeline.behaviorCatalog, []),
2944
+ engineBundleDigest: engineBundleDigestOf(VERSION, trustedPolicy),
2945
+ executionBoundaryDigest,
2946
+ targetArtifactDigest: targetArtifactDigestOf(frozenTreeId),
2947
+ verdictSummary: { total: 0, satisfied: 0, waived: 0, blocking: 0 },
2948
+ issuedAt: pipeline.now,
2949
+ });
2950
+ writeGateReceipt(stateDir, docsOnlyReceipt);
2951
+ // A receipt supersedes the run record of the same run, and this seal
2952
+ // is not a re-seal, so it leaves no parent chain behind: the next
2953
+ // re-seal must start from a receipt whose evidence it can verify.
2954
+ clearRunRecord(stateDir);
2955
+ clearResealChain(stateDir);
2956
+ writeCandidateTreeEntries(stateDir, docsOnlyTree.entries);
2957
+ const docsOnlyReport = canonicalJson({
2958
+ schemaVersion: 1,
2959
+ docsOnlySlice: true,
2960
+ receiptId: docsOnlyReceipt.receiptId,
2961
+ candidateTreeId: frozenTreeId,
2962
+ inputDigest: expectedDigest,
2963
+ scope: 'changed',
2964
+ changedFiles: [...providerChangedFiles],
2965
+ coveredObligations: 0,
2966
+ testsPerformedThisInvocation: 0,
2967
+ summary: docsOnlyReceipt.verdictSummary,
2968
+ evidenceState: 'docs-only-no-records',
2969
+ engine: { ...engineIdentity() },
2970
+ });
2971
+ writeReport(stateDir, docsOnlyReport);
2972
+ writeLine(io.stdout, format === 'json'
2973
+ ? docsOnlyReport
2974
+ : `receipt ${docsOnlyReceipt.receiptId} sealed for the docs-only slice; 0 tests run; ` +
2975
+ `no obligation arises from ${providerChangedFiles.join(', ')}`);
2976
+ writeLine(io.stderr, `receipt ${docsOnlyReceipt.receiptId} sealed (docs-only slice, 0 records, inputs bound)`);
2977
+ return 0;
2978
+ }
2722
2979
  const emptySliceBlocking = inventoryBlocking.length > 0
2723
2980
  ? // A failed/incomplete discovery already explains the block.
2724
2981
  []
@@ -3239,7 +3496,10 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
3239
3496
  // worker exists — the only honest baseline a body worker's
3240
3497
  // inherited preparation environment can be projected back to.
3241
3498
  baseEnv: supervisedRunnerChildEnv(suiteEnv, io.cwd),
3242
- timeoutMs: Math.min(Math.max(runTimeoutMs ?? DEFAULT_RUN_TIMEOUT_MS, 120_000), 900_000),
3499
+ // The freeze controller's own wait for a release. Independent of
3500
+ // the run's own bounds: it must stay finite, and its ceiling is
3501
+ // the release wait, not the whole-run budget.
3502
+ timeoutMs: Math.min(Math.max(runTimeoutMs ?? FREEZE_RELEASE_WAIT_MS, 120_000), 900_000),
3243
3503
  });
3244
3504
  // The identity the freeze accepted, written by the handler below and
3245
3505
  // read once when this run seals. It is read through a NAMED accessor
@@ -3260,6 +3520,11 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
3260
3520
  // declared, so the project that reads the saved session is handed it
3261
3521
  // while the setup project keeps running unauthenticated. An operator's
3262
3522
  // GATEFORGE_SESSION_STATE still outranks both (above).
3523
+ // The per-test completion sink the supervised run fills in before it
3524
+ // spawns. The drain below feeds it from the SAME event the `--progress`
3525
+ // stream consumes, so the stall watchdog and the progress stream share
3526
+ // one signal instead of two.
3527
+ const runActivity = {};
3263
3528
  const adapter = runnerName === 'playwright'
3264
3529
  ? new PlaywrightAdapter({
3265
3530
  config,
@@ -3283,10 +3548,12 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
3283
3548
  prerequisiteProjects: freezePlan.prerequisiteProjects,
3284
3549
  },
3285
3550
  }),
3286
- // Operator-provided whole-run bound for multi-hour suites (default
3287
- // 30 minutes stands when absent — same expected set and
3288
- // completeness rules either way).
3551
+ // Operator-declared whole-run bound: absent, NO cap applies
3552
+ // (same expected set and completeness rules either way — only
3553
+ // the kill timer moves). The stall bound is the default backstop.
3289
3554
  ...(runTimeoutMs !== undefined ? { timeoutMs: runTimeoutMs } : {}),
3555
+ ...(stallTimeoutMs !== undefined ? { stallTimeoutMs } : {}),
3556
+ activity: runActivity,
3290
3557
  },
3291
3558
  })
3292
3559
  : null;
@@ -3553,6 +3820,9 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
3553
3820
  // still owes it): counting it would report a test twice.
3554
3821
  if (event.outcome === undefined)
3555
3822
  return;
3823
+ // The stall watchdog rides THIS event — the run's own per-test
3824
+ // completion signal — exactly as the progress stream below does.
3825
+ runActivity.onTestFinished?.(title);
3556
3826
  progress.endTest({
3557
3827
  logicalKey: `${event.file ?? ''}#${event.titlePath.join('>')}`,
3558
3828
  title,
@@ -3649,6 +3919,10 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
3649
3919
  logicalKeys: selection.logicalKeys,
3650
3920
  stateDir,
3651
3921
  runId: manifest.runId,
3922
+ // These adapters publish NO per-test completion signal, so no
3923
+ // stall bound can be honoured for them; the whole-run bound stays
3924
+ // (operator's value, else the documented default). The Playwright
3925
+ // path above is the one with the stall watchdog.
3652
3926
  timeoutMs: runTimeoutMs ?? DEFAULT_RUN_TIMEOUT_MS,
3653
3927
  cwd: io.cwd,
3654
3928
  mode: selection.mode,