mandrel 2.111.0 → 2.112.0

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 (178) hide show
  1. package/.agents/agents/acceptance-critic.md +14 -0
  2. package/.agents/agents/auditor.md +14 -0
  3. package/.agents/agents/plan-critic.md +5 -0
  4. package/.agents/agents/story-worker.md +4 -1
  5. package/.agents/docs/agentrc-reference.json +22 -10
  6. package/.agents/docs/configuration.md +351 -37
  7. package/.agents/docs/execution-reference.md +11 -0
  8. package/.agents/rules/git-conventions-reference.md +7 -0
  9. package/.agents/schemas/agentrc.schema.json +174 -14
  10. package/.agents/schemas/baselines/baseline-envelope.schema.json +16 -4
  11. package/.agents/schemas/baselines/bundle-size.schema.json +1 -0
  12. package/.agents/schemas/baselines/coverage.schema.json +1 -0
  13. package/.agents/schemas/baselines/crap.schema.json +37 -10
  14. package/.agents/schemas/baselines/duplication.schema.json +1 -0
  15. package/.agents/schemas/baselines/maintainability.schema.json +1 -0
  16. package/.agents/schemas/baselines/mutation.schema.json +1 -0
  17. package/.agents/schemas/crap-report.schema.json +6 -5
  18. package/.agents/schemas/story-deliver-terminal.schema.json +41 -2
  19. package/.agents/schemas/story-progress.schema.json +1 -1
  20. package/.agents/schemas/validation-evidence.schema.json +2 -2
  21. package/.agents/scripts/boot-sweep.js +41 -3
  22. package/.agents/scripts/coverage-capture.js +37 -3
  23. package/.agents/scripts/coverage-ratchet.js +106 -0
  24. package/.agents/scripts/evidence-gate.js +84 -21
  25. package/.agents/scripts/lib/audit-baselines/read.js +8 -1
  26. package/.agents/scripts/lib/audit-baselines/trend.js +2 -1
  27. package/.agents/scripts/lib/baseline-loader.js +4 -2
  28. package/.agents/scripts/lib/baselines/codec.js +57 -0
  29. package/.agents/scripts/lib/baselines/crap-preview-incremental.js +8 -3
  30. package/.agents/scripts/lib/baselines/crap-preview-scan.js +10 -16
  31. package/.agents/scripts/lib/baselines/crap-updater-cli.js +4 -13
  32. package/.agents/scripts/lib/baselines/kernel.js +19 -1
  33. package/.agents/scripts/lib/baselines/kinds/_crap-codec.js +171 -0
  34. package/.agents/scripts/lib/baselines/kinds/_crap-read.js +56 -16
  35. package/.agents/scripts/lib/baselines/kinds/_shared-metric.js +0 -59
  36. package/.agents/scripts/lib/baselines/kinds/crap.js +283 -319
  37. package/.agents/scripts/lib/baselines/preview-gates.js +29 -10
  38. package/.agents/scripts/lib/baselines/reader.js +36 -9
  39. package/.agents/scripts/lib/baselines/refresh-service.js +79 -18
  40. package/.agents/scripts/lib/baselines/seat-missing.js +173 -7
  41. package/.agents/scripts/lib/baselines/writer.js +36 -21
  42. package/.agents/scripts/lib/changed-files.js +70 -6
  43. package/.agents/scripts/lib/child-exec.js +10 -0
  44. package/.agents/scripts/lib/claude/agents-projection.js +5 -5
  45. package/.agents/scripts/lib/close-lock-events.js +8 -3
  46. package/.agents/scripts/lib/close-validation/ci-deferral.js +40 -0
  47. package/.agents/scripts/lib/close-validation/gates.js +111 -35
  48. package/.agents/scripts/lib/close-validation/process.js +16 -7
  49. package/.agents/scripts/lib/close-validation/projections/crap.js +43 -10
  50. package/.agents/scripts/lib/close-validation/runner.js +55 -23
  51. package/.agents/scripts/lib/close-validation/skip-branch-test.js +144 -0
  52. package/.agents/scripts/lib/close-validation/test-delta.js +33 -8
  53. package/.agents/scripts/lib/codex/agents-projection.js +6 -0
  54. package/.agents/scripts/lib/config/agentrc-overlay.js +9 -5
  55. package/.agents/scripts/lib/config/explain.js +5 -2
  56. package/.agents/scripts/lib/config/gates/coverage.schema.js +45 -1
  57. package/.agents/scripts/lib/config/gates/crap-incremental-coverage.schema.js +1 -1
  58. package/.agents/scripts/lib/config/git-roots.js +38 -4
  59. package/.agents/scripts/lib/config/handoff.js +24 -0
  60. package/.agents/scripts/lib/config/quality.js +26 -13
  61. package/.agents/scripts/lib/config/worktree-isolation.js +2 -5
  62. package/.agents/scripts/lib/config-resolver.js +22 -2
  63. package/.agents/scripts/lib/config-settings-schema-delivery.js +87 -4
  64. package/.agents/scripts/lib/config-settings-schema-quality.js +36 -1
  65. package/.agents/scripts/lib/config-settings-schema.js +1 -1
  66. package/.agents/scripts/lib/coverage-capture-affected.js +1 -0
  67. package/.agents/scripts/lib/coverage-capture-delta.js +164 -32
  68. package/.agents/scripts/lib/coverage-capture-own-fix.js +232 -0
  69. package/.agents/scripts/lib/coverage-capture-usage.js +2 -2
  70. package/.agents/scripts/lib/coverage-capture.js +15 -0
  71. package/.agents/scripts/lib/coverage-deferral.js +96 -0
  72. package/.agents/scripts/lib/coverage-ratchet.js +187 -0
  73. package/.agents/scripts/lib/crap-baseline-join.js +5 -5
  74. package/.agents/scripts/lib/crap-engine.js +3 -3
  75. package/.agents/scripts/lib/crap-method-identity.js +104 -48
  76. package/.agents/scripts/lib/escomplex-anchor.js +135 -0
  77. package/.agents/scripts/lib/escomplex-kernel.js +30 -1
  78. package/.agents/scripts/lib/failure-rows.js +121 -0
  79. package/.agents/scripts/lib/full-suite-lock.js +44 -4
  80. package/.agents/scripts/lib/full-suite-queue.js +89 -13
  81. package/.agents/scripts/lib/generated/agentrc-validator.js +8 -2
  82. package/.agents/scripts/lib/gh-env.js +3 -6
  83. package/.agents/scripts/lib/gh-pr-rest.js +1 -0
  84. package/.agents/scripts/lib/git/base-sync-probe.js +182 -0
  85. package/.agents/scripts/lib/git-branch-lifecycle.js +9 -0
  86. package/.agents/scripts/lib/observability/close-telemetry.js +37 -2
  87. package/.agents/scripts/lib/observability/handoff-telemetry.js +170 -0
  88. package/.agents/scripts/lib/observability/review-dispositions.js +23 -6
  89. package/.agents/scripts/lib/observability/runtime-friction.js +17 -4
  90. package/.agents/scripts/lib/observability/source-classifier.js +3 -0
  91. package/.agents/scripts/lib/observability/story-outcome.js +393 -0
  92. package/.agents/scripts/lib/orchestration/check-baselines/phases/compare.js +2 -1
  93. package/.agents/scripts/lib/orchestration/check-baselines/phases/evaluate.js +19 -1
  94. package/.agents/scripts/lib/orchestration/check-baselines/phases/fail-detail.js +84 -0
  95. package/.agents/scripts/lib/orchestration/check-baselines/phases/pipeline.js +14 -5
  96. package/.agents/scripts/lib/orchestration/check-baselines/phases/refresh-ack.js +3 -2
  97. package/.agents/scripts/lib/orchestration/check-baselines/phases/report.js +26 -6
  98. package/.agents/scripts/lib/orchestration/code-review.js +223 -19
  99. package/.agents/scripts/lib/orchestration/handoff-gates.js +129 -62
  100. package/.agents/scripts/lib/orchestration/handoff-rescore.js +169 -0
  101. package/.agents/scripts/lib/orchestration/handoff-suite-of-record.js +45 -0
  102. package/.agents/scripts/lib/orchestration/preflight-lanes.js +208 -0
  103. package/.agents/scripts/lib/orchestration/review-base-ref.js +40 -17
  104. package/.agents/scripts/lib/orchestration/review-deposit.js +38 -12
  105. package/.agents/scripts/lib/orchestration/review-depth.js +21 -0
  106. package/.agents/scripts/lib/orchestration/review-history.js +124 -20
  107. package/.agents/scripts/lib/orchestration/review-providers/claude-verdict.js +23 -8
  108. package/.agents/scripts/lib/orchestration/review-providers/code-review.js +82 -39
  109. package/.agents/scripts/lib/orchestration/review-providers/critical-verifier.js +64 -11
  110. package/.agents/scripts/lib/orchestration/review-providers/degraded-gates.js +98 -3
  111. package/.agents/scripts/lib/orchestration/review-providers/finding-identity.js +6 -2
  112. package/.agents/scripts/lib/orchestration/review-providers/findings-renderer.js +55 -8
  113. package/.agents/scripts/lib/orchestration/review-providers/review-guidance.js +1 -0
  114. package/.agents/scripts/lib/orchestration/review-providers/review-provider-factory.js +42 -15
  115. package/.agents/scripts/lib/orchestration/review-providers/types.js +6 -0
  116. package/.agents/scripts/lib/orchestration/single-story-close/failed-terminal.js +10 -1
  117. package/.agents/scripts/lib/orchestration/single-story-close/gate-log.js +10 -0
  118. package/.agents/scripts/lib/orchestration/single-story-close/phases/base-sync.js +7 -4
  119. package/.agents/scripts/lib/orchestration/single-story-close/phases/close-validation.js +15 -3
  120. package/.agents/scripts/lib/orchestration/single-story-close/phases/code-review.js +59 -2
  121. package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +6 -0
  122. package/.agents/scripts/lib/orchestration/single-story-close/phases/finish.js +15 -4
  123. package/.agents/scripts/lib/orchestration/single-story-close/phases/land-review-record.js +213 -0
  124. package/.agents/scripts/lib/orchestration/single-story-close/phases/normalize-pr-title.js +9 -12
  125. package/.agents/scripts/lib/orchestration/single-story-close/phases/open-pr.js +26 -12
  126. package/.agents/scripts/lib/orchestration/single-story-close/phases/post-land.js +51 -26
  127. package/.agents/scripts/lib/orchestration/single-story-close/phases/pre-push.js +3 -2
  128. package/.agents/scripts/lib/orchestration/single-story-close/phases/pull-request.js +50 -17
  129. package/.agents/scripts/lib/orchestration/single-story-close/phases/push.js +59 -11
  130. package/.agents/scripts/lib/orchestration/single-story-close/phases/reconcile-done.js +1 -0
  131. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-block.js +31 -13
  132. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-halt.js +29 -6
  133. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-outcome.js +10 -12
  134. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-override.js +19 -4
  135. package/.agents/scripts/lib/orchestration/single-story-close/result.js +30 -13
  136. package/.agents/scripts/lib/orchestration/single-story-close/review-overlap.js +73 -39
  137. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +11 -3
  138. package/.agents/scripts/lib/orchestration/story-close/baseline-upward-writeback.js +3 -2
  139. package/.agents/scripts/lib/orchestration/story-close/duplication-close-rescore.js +20 -8
  140. package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +7 -0
  141. package/.agents/scripts/lib/orchestration/story-handoff.js +774 -196
  142. package/.agents/scripts/lib/orchestration/ticketing/reads.js +2 -0
  143. package/.agents/scripts/lib/pr-body-lines.js +32 -0
  144. package/.agents/scripts/lib/single-story/ci-ratchet-gate.js +140 -0
  145. package/.agents/scripts/lib/single-story/confirm-and-land.js +17 -7
  146. package/.agents/scripts/lib/single-story/confirm-merge.js +12 -3
  147. package/.agents/scripts/lib/single-story-sweep/report-stalled-executing.js +202 -0
  148. package/.agents/scripts/lib/standalone-ratchets.js +37 -0
  149. package/.agents/scripts/lib/suite-admission.js +20 -8
  150. package/.agents/scripts/lib/suite-sizing.js +146 -0
  151. package/.agents/scripts/lib/workspace-provisioner.js +2 -2
  152. package/.agents/scripts/merge-baseline.js +14 -3
  153. package/.agents/scripts/providers/github/comments.js +19 -3
  154. package/.agents/scripts/providers/github.js +1 -0
  155. package/.agents/scripts/review-dispositions-report.js +1 -1
  156. package/.agents/scripts/role-scope-guard.js +267 -0
  157. package/.agents/scripts/single-story-close.js +4 -4
  158. package/.agents/scripts/single-story-confirm-merge.js +31 -5
  159. package/.agents/scripts/single-story-init.js +24 -4
  160. package/.agents/scripts/story-handoff.js +3 -3
  161. package/.agents/scripts/story-outcomes-report.js +231 -0
  162. package/.agents/scripts/story-review-compute.js +9 -5
  163. package/.agents/scripts/update-coverage-baseline.js +12 -2
  164. package/.agents/scripts/update-crap-baseline.js +9 -1
  165. package/.agents/workflows/helpers/code-review.md +63 -9
  166. package/.agents/workflows/helpers/deliver-digest.md +53 -54
  167. package/.agents/workflows/helpers/deliver-reference.md +233 -67
  168. package/.agents/workflows/helpers/deliver-story-reference.md +19 -8
  169. package/.agents/workflows/helpers/deliver-story.md +7 -2
  170. package/.agents/workflows/helpers/parallel-tooling.md +29 -0
  171. package/docs/CHANGELOG.md +46 -0
  172. package/lib/cli/doctor-checks/coverage-ratchet.js +54 -0
  173. package/lib/cli/doctor-checks/effective-agentrc.js +23 -0
  174. package/lib/cli/doctor-checks/llm-review.js +2 -11
  175. package/lib/cli/doctor-checks/sync-parity.js +5 -1
  176. package/lib/cli/doctor-checks/test-credit-path.js +7 -2
  177. package/lib/cli/registry.js +5 -0
  178. package/package.json +1 -1
@@ -9,11 +9,19 @@
9
9
  */
10
10
 
11
11
  import path from 'node:path';
12
+ import {
13
+ aheadStampOf,
14
+ classifyScoringSemantics,
15
+ SCORING_SEMANTICS,
16
+ } from '../../baselines/kinds/_crap-read.js';
12
17
  import {
13
18
  compareCrap,
14
19
  filterRowsByFileScope,
15
20
  } from '../../baselines/kinds/crap.js';
16
- import { loadFile as loadBaselineFile } from '../../baselines/reader.js';
21
+ import {
22
+ loadFile as loadBaselineFile,
23
+ peekFile,
24
+ } from '../../baselines/reader.js';
17
25
  import { diffNameOnly } from '../../changed-files.js';
18
26
  import { COVERAGE_CAPTURE_DEFAULTS } from '../../config/gates/coverage.schema.js';
19
27
  import { loadCoverage } from '../../coverage-utils.js';
@@ -43,7 +51,7 @@ function normaliseSkipReason(reason) {
43
51
  * `[]` when absent or unreadable.
44
52
  *
45
53
  * @param {string} baselinePath
46
- * @returns {Array<{file: string, method: string, startLine: number, crap: number}>}
54
+ * @returns {Array<{file: string, method: string, crap: number}>}
47
55
  */
48
56
  function loadCrapBaselineRows(baselinePath) {
49
57
  let envelope;
@@ -56,7 +64,6 @@ function loadCrapBaselineRows(baselinePath) {
56
64
  return rows.map((row) => ({
57
65
  file: row.path,
58
66
  method: row.method,
59
- startLine: row.startLine,
60
67
  crap: row.crap,
61
68
  }));
62
69
  }
@@ -139,6 +146,32 @@ function diffScorableFiles({ cwd, baseBranch, storyBranch, git }) {
139
146
  }
140
147
  }
141
148
 
149
+ /**
150
+ * Rows scored under other semantics are not comparable. A missing or
151
+ * unreadable file is no mismatch; it falls through to `no-baseline`.
152
+ */
153
+ function semanticsMismatch(raw) {
154
+ if (raw === null || typeof raw !== 'object') return null;
155
+ const ahead = aheadStampOf(raw);
156
+ if (ahead) return { reason: 'semantics-ahead', detail: ahead.message };
157
+ if (classifyScoringSemantics(raw.scoringSemantics) !== 'behind') return null;
158
+ return { reason: 'semantics-behind', detail: behindDetail(raw) };
159
+ }
160
+
161
+ /** Invalid inputs, then a semantics mismatch, as a skip; else null. */
162
+ function inputsSkip(inputs, peekBaseline) {
163
+ const validation = validateProjectionInputs(inputs);
164
+ if (!validation.ok) {
165
+ return { reason: normaliseSkipReason(validation.reason) };
166
+ }
167
+ return semanticsMismatch(peekBaseline(inputs.baselinePath));
168
+ }
169
+
170
+ /** The stamp pair a behind baseline reports. */
171
+ function behindDetail(raw) {
172
+ return `baseline=${raw.scoringSemantics ?? '(unstamped)'} running=${SCORING_SEMANTICS}`;
173
+ }
174
+
142
175
  /**
143
176
  * Breaches are vs the baseline row, or `newMethodCeiling` for new methods.
144
177
  * Baseline rows are narrowed to changed files so untouched rows do not read
@@ -153,6 +186,7 @@ function diffScorableFiles({ cwd, baseBranch, storyBranch, git }) {
153
186
  * tolerance?: number,
154
187
  * git?: { gitSpawn: typeof defaultGitSpawn },
155
188
  * loadBaseline?: (path: string) => Array<object>,
189
+ * peekBaseline?: (path: string) => unknown,
156
190
  * scoreFiles?: (files: string[]) => Promise<Array<object>|null>|Array<object>|null,
157
191
  * }} opts
158
192
  * @returns {Promise<{
@@ -171,6 +205,7 @@ export async function projectCrapBreaches({
171
205
  tolerance = DEFAULT_CRAP_TOLERANCE,
172
206
  git = { gitSpawn: defaultGitSpawn },
173
207
  loadBaseline = loadCrapBaselineRows,
208
+ peekBaseline = peekFile,
174
209
  scoreFiles,
175
210
  } = {}) {
176
211
  const skip = (reason, detail) => ({
@@ -180,13 +215,11 @@ export async function projectCrapBreaches({
180
215
  ...(detail === undefined ? {} : { detail }),
181
216
  });
182
217
 
183
- const validation = validateProjectionInputs({
184
- cwd,
185
- baseBranch,
186
- storyBranch,
187
- baselinePath,
188
- });
189
- if (!validation.ok) return skip(normaliseSkipReason(validation.reason));
218
+ const early = inputsSkip(
219
+ { cwd, baseBranch, storyBranch, baselinePath },
220
+ peekBaseline,
221
+ );
222
+ if (early) return skip(early.reason, early.detail);
190
223
 
191
224
  const baselineRows = loadBaseline(baselinePath);
192
225
  if (!Array.isArray(baselineRows) || baselineRows.length === 0) {
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { getQuality } from '../config/quality.js';
7
7
  import {
8
+ COVERAGE_HOST_RESOURCES_EXIT_CODE,
8
9
  COVERAGE_OVER_BUDGET_EXIT_CODE,
9
10
  COVERAGE_TIMEOUT_EXIT_CODE,
10
11
  } from '../coverage-capture.js';
@@ -19,6 +20,7 @@ import {
19
20
  treeFingerprint as defaultTreeFingerprint,
20
21
  hashCommandConfig,
21
22
  } from '../validation-evidence.js';
23
+ import { presetCiDeferral } from './ci-deferral.js';
22
24
  import {
23
25
  isFormatterEligible,
24
26
  listChangedFilesForFormatGate,
@@ -29,6 +31,7 @@ import {
29
31
  GATE_TIMEOUT_HINT,
30
32
  OVER_BUDGET_BLOCK_HINT,
31
33
  partitionGates,
34
+ withFailureRows,
32
35
  } from './gates.js';
33
36
  import { defaultGateRunner } from './process.js';
34
37
  import { runProjectionAdvisories as defaultRunProjections } from './projections/advisories.js';
@@ -40,15 +43,15 @@ import { defaultGetHeadSha } from './projections/head-sha.js';
40
43
  * Classify a non-zero gate exit and log it as what it is: `75` is an expired
41
44
  * full-suite lock wait (nothing ran), `124` a killed suite (no verdict), and
42
45
  * `76` an over-budget capture the policy blocks (a deferring gate never gets
43
- * here), and anything else a real failure with the gate's own hint. Returns the
46
+ * here), `77` a suite gate that lost workers to host memory, and anything else a real failure with the gate's own hint. Returns the
44
47
  * `failed[]` entry, carrying `outcome` so callers never re-derive it; its
45
48
  * `gate.hint` is the one that fits the outcome (none when deferred), so a
46
49
  * caller replaying it never prints the failing-tests hint for a non-failure.
47
50
  *
48
- * @param {{ gate: Gate, status: number, cwd: string, log: (m: string) => void }} args
49
- * @returns {{ gate: Gate, status: number, cwd: string, outcome: 'deferred'|'timeout'|'over-budget'|'failed' }}
51
+ * @param {{ gate: Gate, status: number, cwd: string, log: (m: string) => void, failureRows?: string[] }} args
52
+ * @returns {{ gate: Gate, status: number, cwd: string, outcome: 'deferred'|'timeout'|'over-budget'|'host-resources'|'failed' }}
50
53
  */
51
- function reportGateExit({ gate, status, cwd, log }) {
54
+ function reportGateExit({ gate, status, cwd, log, failureRows }) {
52
55
  if (status === LOCK_WAIT_EXPIRED_EXIT_CODE) {
53
56
  log(
54
57
  `[close-validation] ⏸ ${gate.name} deferred (exit ${status}) — the full-suite lock wait expired, so nothing ran in ${cwd}`,
@@ -59,8 +62,9 @@ function reportGateExit({ gate, status, cwd, log }) {
59
62
  const hinted = hintedExit(gate, status);
60
63
  if (hinted) return reportHintedExit({ gate, status, cwd, log, ...hinted });
61
64
  log(`[close-validation] ✖ ${gate.name} failed (exit ${status}) in ${cwd}`);
62
- if (gate.hint) log(`[close-validation] hint: ${gate.hint}`);
63
- return { gate, status, cwd, outcome: 'failed' };
65
+ const failedGate = withFailureRows(gate, failureRows);
66
+ if (failedGate.hint) log(`[close-validation] hint: ${failedGate.hint}`);
67
+ return { gate: failedGate, status, cwd, outcome: 'failed' };
64
68
  }
65
69
 
66
70
  export function applyChangedFileScope({ gate, spawnCwd, log }) {
@@ -138,10 +142,12 @@ export function applyChangedFileScope({ gate, spawnCwd, log }) {
138
142
  * shouldSkip?: typeof defaultShouldSkip,
139
143
  * }} opts An expired full-suite lock wait spawns nothing (here or in any gate
140
144
  * child) and reports `LOCK_WAIT_EXPIRED_EXIT_CODE`.
141
- * @returns {{ ok: boolean, failed: Array<{ gate: Gate, status: number, cwd: string, outcome: 'deferred'|'timeout'|'over-budget'|'failed' }>, skipped: Array<{ gate: Gate, reason: string }>, deferred: Array<{ gate: Gate, status: number, reason: 'over-budget' }> }}
145
+ * @returns {{ ok: boolean, failed: Array<{ gate: Gate, status: number, cwd: string, outcome: 'deferred'|'timeout'|'over-budget'|'host-resources'|'failed' }>, skipped: Array<{ gate: Gate, reason: string }>, deferred: Array<{ gate: Gate, status: number|null, reason: 'over-budget'|'suite-of-record-ci' }> }}
142
146
  * `outcome` classifies the exit: `deferred` (75), `timeout` (124),
143
- * `over-budget` (76 under `block`), else `failed`. `deferred[]` holds a
144
- * `deferOnOverBudget` gate that exited 76: not a failure, no evidence.
147
+ * `over-budget` (76 under `block`), `host-resources` (77 from a suite gate),
148
+ * else `failed`. `deferred[]` holds a
149
+ * `deferOnOverBudget` gate that exited 76, or a `suiteOfRecordCi` capture
150
+ * never spawned: not a failure, no evidence.
145
151
  */
146
152
  export async function runCloseValidation({
147
153
  cwd,
@@ -256,8 +262,9 @@ export async function runCloseValidation({
256
262
  ...(gate.tolerateNoFilesProcessed
257
263
  ? { tolerateNoFilesProcessed: true }
258
264
  : {}),
265
+ retainFailureRows: gate.retainFailureRows,
259
266
  });
260
- return { status: result?.status ?? 1 };
267
+ return { status: result?.status ?? 1, failureRows: result?.failureRows };
261
268
  };
262
269
 
263
270
  const { independent, serial } = partitionGates(gates);
@@ -312,7 +319,7 @@ export async function runCloseValidation({
312
319
  }
313
320
  if (result.status !== 0) {
314
321
  if (!firstIndepFailure) {
315
- firstIndepFailure = { gate, status: result.status };
322
+ firstIndepFailure = { ...result, gate };
316
323
  ac.abort();
317
324
  }
318
325
  return;
@@ -328,8 +335,7 @@ export async function runCloseValidation({
328
335
  await Promise.all(indepTasks);
329
336
 
330
337
  if (firstIndepFailure) {
331
- const { gate, status } = firstIndepFailure;
332
- failed.push(reportGateExit({ gate, status, cwd: spawnCwd, log }));
338
+ failed.push(reportGateExit({ ...firstIndepFailure, cwd: spawnCwd, log }));
333
339
  return { ok: false, failed, skipped, deferred };
334
340
  }
335
341
 
@@ -440,10 +446,15 @@ async function runSerialGates(
440
446
  dispatchGate,
441
447
  },
442
448
  ) {
443
- const failGate = (gate, status) => {
444
- failed.push(reportGateExit({ gate, status, cwd: spawnCwd, log }));
449
+ const failGate = (gate, status, failureRows) => {
450
+ failed.push(
451
+ reportGateExit({ gate, status, cwd: spawnCwd, log, failureRows }),
452
+ );
445
453
  };
446
454
  for (const gate of serial) {
455
+ const preset = presetCiDeferral(gate, { deferred, failed, log, spawnCwd });
456
+ if (preset === 'stop') return;
457
+ if (preset) continue;
447
458
  let execution;
448
459
  try {
449
460
  execution = resolveSerialExecution({ gate, spawnCwd, log, deferred });
@@ -494,31 +505,52 @@ function isDeferredOverBudget(gate, status) {
494
505
  return status === COVERAGE_OVER_BUDGET_EXIT_CODE && gate.deferOnOverBudget;
495
506
  }
496
507
 
497
- /** A capture exit 76 the policy blocks. @param {Gate} gate @param {number} status */
508
+ /** A suite gate's exit 76 the policy blocks. @param {Gate} gate @param {number} status */
498
509
  function isBlockedOverBudget(gate, status) {
499
510
  return (
500
- status === COVERAGE_OVER_BUDGET_EXIT_CODE &&
501
- gate.name === 'coverage-capture'
511
+ status === COVERAGE_OVER_BUDGET_EXIT_CODE && SUITE_GATES.has(gate.name)
502
512
  );
503
513
  }
504
514
 
515
+ /** Replaces a suite gate's own hint on exit 77: lost workers, no failing test. */
516
+ const GATE_HOST_RESOURCES_HINT =
517
+ 'The suite lost workers to host memory (exit 77) and no test failed — do not re-run it unchanged on this host. Use fewer workers or a larger host, or — when CI runs the suite with a coverage floor — have the capture script declare the slice over budget (exit 76) under `delivery.quality.gates.coverage.onOverBudget: "defer-to-ci"`.';
518
+
519
+ /** The gates that run the suite, the only ones whose 77 means lost workers. */
520
+ const SUITE_GATES = new Set(['test', 'coverage-capture']);
521
+
505
522
  /**
506
523
  * A non-failure exit that carries its own hint in place of the gate's: a
507
- * killed suite (124), or a capture over budget the policy blocks (76).
524
+ * killed suite (124), a suite that lost workers to host memory (77), or a
525
+ * suite over budget the policy blocks (76).
508
526
  *
509
527
  * @param {Gate} gate @param {number} status
510
- * @returns {{ outcome: 'timeout'|'over-budget', hint: string, line: string }|null}
528
+ * @returns {{ outcome: 'timeout'|'host-resources'|'over-budget', hint: string, line: string }|null}
511
529
  */
512
530
  function hintedExit(gate, status) {
513
531
  if (status === COVERAGE_TIMEOUT_EXIT_CODE) {
514
532
  const line = `⏱ ${gate.name} timed out (exit ${status})`;
515
533
  return { outcome: 'timeout', hint: GATE_TIMEOUT_HINT, line };
516
534
  }
517
- if (!isBlockedOverBudget(gate, status)) return null;
518
- const line = `✖ ${gate.name} over budget (exit ${status}) — the capture ran no tests`;
535
+ return isBlockedOverBudget(gate, status)
536
+ ? overBudgetExit(gate, status)
537
+ : hostResourcesExit(gate, status);
538
+ }
539
+
540
+ /** @param {Gate} gate @param {number} status */
541
+ function overBudgetExit(gate, status) {
542
+ const line = `✖ ${gate.name} over budget (exit ${status}) — no tests ran`;
519
543
  return { outcome: 'over-budget', hint: OVER_BUDGET_BLOCK_HINT, line };
520
544
  }
521
545
 
546
+ /** A suite gate's 77; any other gate's 77 is an ordinary failure. @param {Gate} gate @param {number} status */
547
+ function hostResourcesExit(gate, status) {
548
+ if (status !== COVERAGE_HOST_RESOURCES_EXIT_CODE) return null;
549
+ if (!SUITE_GATES.has(gate.name)) return null;
550
+ const line = `⛔ ${gate.name} lost workers to host memory (exit ${status}) — no test failed`;
551
+ return { outcome: 'host-resources', hint: GATE_HOST_RESOURCES_HINT, line };
552
+ }
553
+
522
554
  function reportHintedExit({ gate, status, cwd, log, outcome, hint, line }) {
523
555
  log(`[close-validation] ${line} in ${cwd}`);
524
556
  log(`[close-validation] hint: ${hint}`);
@@ -551,7 +583,7 @@ function settleSerialResult(gate, result, ctx) {
551
583
  return false;
552
584
  }
553
585
  if (result.status !== 0) {
554
- failGate(gate, result.status);
586
+ failGate(gate, result.status, result.failureRows);
555
587
  return true;
556
588
  }
557
589
  log(`[close-validation] ✓ ${gate.name}`);
@@ -0,0 +1,144 @@
1
+ /**
2
+ * The skip-branch `test` run: when coverage-capture takes its incremental
3
+ * skip, handoff and close run `project.commands.testChanged` keyed on the
4
+ * `origin/<baseBranch>` merge-base instead of the full suite, credited under
5
+ * close's full-suite `test` identity as `scope: delta`.
6
+ */
7
+
8
+ import { gitSpawn } from '../git-utils.js';
9
+ import { hashCommandConfig } from '../validation-evidence.js';
10
+ import { resolveTestGateArgv } from './commands.js';
11
+ import {
12
+ NO_TEST_CHANGED,
13
+ resolveTestChangedCommand,
14
+ substituteChangedSince,
15
+ } from './test-delta.js';
16
+
17
+ const HEX_SHA = /^[0-9a-f]{7,64}$/i;
18
+
19
+ /** The merge-base sha, or `null` when git fails or prints nothing. */
20
+ function readMergeBase(gitSpawnImpl, cwd, baseBranch) {
21
+ try {
22
+ const res = gitSpawnImpl(cwd, 'merge-base', `origin/${baseBranch}`, 'HEAD');
23
+ return res?.status === 0 ? String(res.stdout ?? '').trim() || null : null;
24
+ } catch {
25
+ return null;
26
+ }
27
+ }
28
+
29
+ /**
30
+ * The scope both handoff and close read: `testChanged` and the merge-base it
31
+ * is keyed on, or the reason the full suite runs instead.
32
+ *
33
+ * @returns {{ testChanged: object, since: string } | { fallback: string }}
34
+ */
35
+ function resolveSkipBranchScope({
36
+ config,
37
+ cwd,
38
+ baseBranch,
39
+ gitSpawnImpl = gitSpawn,
40
+ }) {
41
+ const testChanged = resolveTestChangedCommand(config);
42
+ if (testChanged.disabled) return { fallback: NO_TEST_CHANGED };
43
+ const since = readMergeBase(gitSpawnImpl, cwd, baseBranch);
44
+ return since ? { testChanged, since } : { fallback: 'merge-base unreadable' };
45
+ }
46
+
47
+ /** Close's skip-branch `test` gate. */
48
+ function buildSkipBranchTestGate({ config, testChanged, since }) {
49
+ const short = since.slice(0, 12);
50
+ return {
51
+ name: 'test',
52
+ label: `test (testChanged since ${short})`,
53
+ ...substituteChangedSince(testChanged, since),
54
+ fullSuiteLock: true,
55
+ evidenceIdentity: resolveTestGateArgv(config),
56
+ evidenceNote: { scope: 'delta', since },
57
+ hint: `\`${testChanged.raw}\` (\`project.commands.testChanged\`, the tests affected since ${short}) exited non-zero. Fix the failing tests, commit, and re-run close.`,
58
+ };
59
+ }
60
+
61
+ /**
62
+ * Close's `test` gate: the scoped run when a skip-branch scope resolved,
63
+ * else the plain full suite (`project.commands.test`).
64
+ */
65
+ export function closeTestGate(config, scope) {
66
+ return scope?.since
67
+ ? buildSkipBranchTestGate({ config, ...scope })
68
+ : { name: 'test', ...resolveTestGateArgv(config), fullSuiteLock: true };
69
+ }
70
+
71
+ const SKIP_PREFIX =
72
+ '[close-validation] coverage-capture will take the incremental skip (no changed file under the CRAP target dirs) — registering';
73
+
74
+ /** Close's one log line naming the `test` shape the skip branch registers. */
75
+ function describeCloseScope(scope) {
76
+ return scope.since
77
+ ? `${SKIP_PREFIX} the \`test\` gate as \`project.commands.testChanged\` since ${scope.since.slice(0, 12)}, credited as the full suite.`
78
+ : `${SKIP_PREFIX} the plain \`test\` gate (${scope.fallback}) so this close still runs the suite.`;
79
+ }
80
+
81
+ /** On the skip branch, close's scope (logged); elsewhere `null`. */
82
+ export function closeTestScope({ skipBranch, log, gitSpawnImpl, ...where }) {
83
+ if (!skipBranch) return null;
84
+ const scope = resolveSkipBranchScope({
85
+ ...where,
86
+ baseBranch: where.baseBranch || 'main',
87
+ ...(gitSpawnImpl ? { gitSpawnImpl } : {}),
88
+ });
89
+ log?.(describeCloseScope(scope));
90
+ return scope;
91
+ }
92
+
93
+ /**
94
+ * The handoff's `test` deposit tail for evidence-gate and its step label: the
95
+ * scoped run, or close's full `test` argv naming why.
96
+ *
97
+ * @returns {{ argv: string[], label: string, fallback?: string }}
98
+ */
99
+ export function skipBranchDeposit({ config, cwd, baseBranch, gitSpawnImpl }) {
100
+ const scope = resolveSkipBranchScope({
101
+ config,
102
+ cwd,
103
+ baseBranch,
104
+ gitSpawnImpl,
105
+ });
106
+ if (scope.fallback) {
107
+ const { cmd, args } = resolveTestGateArgv(config);
108
+ return {
109
+ argv: ['--', cmd, ...args],
110
+ label: `test (full suite: ${scope.fallback})`,
111
+ fallback: scope.fallback,
112
+ };
113
+ }
114
+ const { cmd, args } = scope.testChanged;
115
+ return {
116
+ argv: ['--changed-since', scope.since, '--', cmd, ...args],
117
+ label: `test (testChanged since ${scope.since.slice(0, 12)})`,
118
+ };
119
+ }
120
+
121
+ /** evidence-gate's `--changed-since` refusal, or `null` when it may run. */
122
+ export function changedSinceError(gate, changedSince) {
123
+ if (changedSince === null || changedSince === undefined) return null;
124
+ if (gate !== 'test') return '--changed-since is valid only with --gate test';
125
+ return HEX_SHA.test(String(changedSince))
126
+ ? null
127
+ : `--changed-since must be a hex commit sha, got "${changedSince}"`;
128
+ }
129
+
130
+ /**
131
+ * evidence-gate's scoped run: the token substituted, the sha in the env, and
132
+ * the pass credited under close's full-suite `test` identity.
133
+ */
134
+ export function scopedEvidenceRun({ cmd, args, since, config, cwd }) {
135
+ const run = substituteChangedSince({ cmd, args }, since);
136
+ return {
137
+ cmd: run.cmd,
138
+ cmdArgs: run.args,
139
+ env: run.env,
140
+ note: { scope: 'delta', since },
141
+ // Hashed exactly as close's runner hashes the `test` gate it spends this on.
142
+ configHash: hashCommandConfig({ ...resolveTestGateArgv(config), cwd }),
143
+ };
144
+ }
@@ -15,7 +15,7 @@ import { resolveTestGateArgv } from './commands.js';
15
15
  *
16
16
  * @param {object|null|undefined} config
17
17
  */
18
- function resolveTestChangedCommand(config) {
18
+ export function resolveTestChangedCommand(config) {
19
19
  const raw = config?.project?.commands?.testChanged?.trim() || null;
20
20
  const [cmd, ...args] = raw ? raw.split(/\s+/) : [];
21
21
  return { cmd, args, raw, disabled: raw === null };
@@ -23,15 +23,29 @@ function resolveTestChangedCommand(config) {
23
23
 
24
24
  const CHANGED_SINCE_TOKEN = '$MANDREL_CHANGED_SINCE';
25
25
 
26
- /** `testChanged` keyed on `since`, credited as the full suite; no shell runs it, so the token is substituted here. */
26
+ /**
27
+ * `testChanged` keyed on `since`: no shell runs it, so the token is
28
+ * substituted here and the sha is also handed over in the env.
29
+ *
30
+ * @param {{ cmd: string, args: string[] }} testChanged @param {string} since
31
+ */
32
+ export function substituteChangedSince({ cmd, args }, since) {
33
+ return {
34
+ cmd,
35
+ args: args.map((a) => (a === CHANGED_SINCE_TOKEN ? since : a)),
36
+ env: { MANDREL_CHANGED_SINCE: since },
37
+ };
38
+ }
39
+
40
+ export const NO_TEST_CHANGED = 'no `project.commands.testChanged`';
41
+
42
+ /** `testChanged` keyed on `since`, credited as the full suite. */
27
43
  function buildTestDeltaGate({ config, testChanged, since, incoming }) {
28
44
  const label = `test (delta since ${since.slice(0, 12)}, ${incoming} incoming path(s))`;
29
45
  return {
30
46
  name: 'test',
31
47
  label,
32
- cmd: testChanged.cmd,
33
- args: testChanged.args.map((a) => (a === CHANGED_SINCE_TOKEN ? since : a)),
34
- env: { MANDREL_CHANGED_SINCE: since },
48
+ ...substituteChangedSince(testChanged, since),
35
49
  fullSuiteLock: true,
36
50
  evidenceIdentity: resolveTestGateArgv(config),
37
51
  evidenceNote: { scope: 'delta', since },
@@ -48,7 +62,7 @@ function testDeltaIneligibility({
48
62
  storyFiles,
49
63
  config,
50
64
  }) {
51
- if (testChanged.disabled) return 'no `project.commands.testChanged`';
65
+ if (testChanged.disabled) return NO_TEST_CHANGED;
52
66
  if (captureRuns) return 'coverage-capture runs the suite';
53
67
  if (!credited()) return 'no `test` credit for the pre-sync head';
54
68
  const files = storyFiles();
@@ -71,6 +85,16 @@ function readStoryFiles({ cwd, baseBranch, getChangedFilesImpl }) {
71
85
  }
72
86
  }
73
87
 
88
+ /** The run an ineligible delta leaves in place, for its log line. */
89
+ function keptRun(gate) {
90
+ return gate?.evidenceNote ? 'the skip-branch scoped run' : 'the full suite';
91
+ }
92
+
93
+ /** The replaced gate's over-budget flag, carried onto the delta. */
94
+ function overBudgetOf({ deferOnOverBudget }) {
95
+ return deferOnOverBudget ? { deferOnOverBudget } : {};
96
+ }
97
+
74
98
  /**
75
99
  * Swap the plain `test` gate for the delta re-credit when every rule holds;
76
100
  * otherwise return `gates` unchanged, logging the failed rule (no base move
@@ -116,7 +140,7 @@ export function applyTestDelta(
116
140
  });
117
141
  if (reason) {
118
142
  log?.(
119
- `[close-validation] test delta re-credit not eligible (${reason}) — running the full suite`,
143
+ `[close-validation] test delta re-credit not eligible (${reason}) — running ${keptRun(gates[index])}`,
120
144
  );
121
145
  return gates;
122
146
  }
@@ -126,5 +150,6 @@ export function applyTestDelta(
126
150
  since,
127
151
  incoming: incoming.length,
128
152
  });
129
- return gates.map((g, i) => (i === index ? delta : g));
153
+ const swapped = { ...delta, ...overBudgetOf(gates[index]) };
154
+ return gates.map((g, i) => (i === index ? swapped : g));
130
155
  }
@@ -166,6 +166,12 @@ function renderCodexAgent({ role, source, baseDir, sourceLabel }) {
166
166
  `description = ${tomlString(description)}`,
167
167
  ];
168
168
  if (effort) lines.push(`model_reasoning_effort = ${tomlString(effort)}`);
169
+ // A Bash-free `tools` allowlist turns the shell off; Codex agent files
170
+ // cannot set `sandbox_mode` (the parent turn's sandbox is inherited).
171
+ const tools = fm?.[1].match(/^tools:(.*)$/m)?.[1].split(',');
172
+ if (tools && !tools.some((t) => t.trim() === 'Bash')) {
173
+ lines.push('features.shell_tool = false');
174
+ }
169
175
  lines.push(
170
176
  `developer_instructions = ${tomlMultiline(inlineImports(body.replace(/^\n+/, ''), baseDir))}`,
171
177
  );
@@ -5,6 +5,7 @@
5
5
 
6
6
  import path from 'node:path';
7
7
  import { isObject } from '../json-utils.js';
8
+ import { overlayRoot } from './git-roots.js';
8
9
 
9
10
  const LOCAL_AGENTRC = '.agentrc.local.json';
10
11
 
@@ -34,14 +35,17 @@ function mergeValue(baseVal, overrideVal) {
34
35
  }
35
36
 
36
37
  /**
37
- * Merge the project's overlay, when present, over the committed config.
38
- * Throws a parse error naming `.agentrc.local.json`.
38
+ * Merge the project's overlay (located by `overlayRoot`), when present, over
39
+ * the committed config. Throws a parse error naming `.agentrc.local.json`.
39
40
  *
40
- * @param {{ fsImpl: typeof import('node:fs'), projectRoot: string, committed: object }} opts
41
+ * @param {{ fsImpl: typeof import('node:fs'), projectRoot: string, committed: object, exec?: Function }} opts
41
42
  * @returns {{ effective: object, localPath: string|null }}
42
43
  */
43
- export function applyLocalOverlay({ fsImpl, projectRoot, committed }) {
44
- const localPath = path.join(projectRoot, LOCAL_AGENTRC);
44
+ export function applyLocalOverlay({ fsImpl, projectRoot, committed, exec }) {
45
+ const localPath = path.join(
46
+ overlayRoot(projectRoot, exec, fsImpl),
47
+ LOCAL_AGENTRC,
48
+ );
45
49
  if (!fsImpl.existsSync(localPath)) {
46
50
  return { effective: committed, localPath: null };
47
51
  }
@@ -110,7 +110,7 @@ const KEY_MEANINGS = Object.freeze({
110
110
  'delivery.worktreeIsolation.reapOnSuccess':
111
111
  'Whether a worktree is removed after a Story closes cleanly.',
112
112
  'delivery.worktreeIsolation.bootstrapFiles':
113
- 'Files copied into each new worktree (e.g. .env, .mcp.json, local overrides).',
113
+ 'Files copied into each new worktree (e.g. .env, .mcp.json); .agentrc.local.json is read live from the main checkout.',
114
114
  'delivery.mergeWatch.maxBudgetSeconds':
115
115
  'Cumulative wall-clock budget (seconds) across resumes before the merge wait gives up and blocks.',
116
116
  'delivery.codeReview.providers':
@@ -125,6 +125,8 @@ const KEY_MEANINGS = Object.freeze({
125
125
  'When true, single-story-close lands through merge in one close (opt out with --no-wait-merge).',
126
126
  'delivery.feedbackLoop.retroProposals':
127
127
  'When true, auto-file actionable retro proposals as follow-up issues.',
128
+ 'delivery.feedbackLoop.outcomeRecord':
129
+ 'When true, each close attempt updates one story-outcome comment on the Story for story-outcomes-report.js.',
128
130
  'delivery.quality.requireBaselines':
129
131
  'When true, absent baseline artifacts fail close-validation instead of skipping cleanly.',
130
132
  'delivery.refactorStage.enabled':
@@ -153,9 +155,10 @@ const PREFIX_MEANINGS = Object.freeze([
153
155
  ],
154
156
  ['delivery.quality', 'Delivery-time quality configuration.'],
155
157
  ['delivery.mergeWatch', 'Merge-wait posture and wall-clock budget.'],
158
+ ['delivery.close', 'Close-time base-sync posture.'],
156
159
  [
157
160
  'delivery.feedbackLoop',
158
- 'Opt-out toggles for auto-filing non-blocking findings.',
161
+ 'Opt-in toggles for posting to the tracker unasked.',
159
162
  ],
160
163
  [
161
164
  'delivery.routing',
@@ -31,6 +31,15 @@ export const COVERAGE_GATE_DEFAULTS = Object.freeze({
31
31
  timeoutMs: 600_000,
32
32
  // What a capture script's over-budget exit (76) means to handoff and close.
33
33
  onOverBudget: 'block',
34
+ // `ci` makes CI the coverage and CRAP ratchet of record (a host setting).
35
+ suiteOfRecord: 'local',
36
+ // The consumer's CI check that runs `coverage-ratchet.js`.
37
+ ciRatchetCheck: null,
38
+ // Consumer-declared paths that feed no test; no built-in entries.
39
+ nonInputGlobs: Object.freeze([]),
40
+ captureHandlesConfigChanges: false,
41
+ // 0 keeps the own-fix delta refresh off; N caps its own part.
42
+ ownFixDeltaMaxFiles: 0,
34
43
  });
35
44
 
36
45
  /** Schema bounds on `coverage.timeoutMs`: one minute to two hours. */
@@ -84,9 +93,44 @@ export const COVERAGE_GATE = {
84
93
  type: 'string',
85
94
  enum: ['block', 'defer-to-ci'],
86
95
  description:
87
- "What handoff and close do when the capture script exits 76 — the consumer-declared signal that the selected slice is over this host's budget and no test ran. `block` (default) stops the handoff (`blocked`) and fails close, naming this key. `defer-to-ci` settles the coverage gate as deferred to CI: no artifact is written or stamped and no credit is recorded, the coverage-reading gates (CRAP preview, coverage and CRAP baselines) are skipped, and handoff and close proceed — the terminal envelope and the PR body say coverage was deferred. Set it only when the consumer's CI runs the deferred suite with a coverage floor. A timeout (124) is never deferred, under either value.",
96
+ "What handoff and close do when the capture script — or the `test` command (`project.commands.test`, or `testChanged` on the skip branch and the delta re-credit) — exits 76: the consumer-declared signal that the selected slice is over this host's budget and no test ran. `block` (default) stops the handoff (`blocked`) and fails close, naming this key. `defer-to-ci` settles the coverage gate as deferred to CI: no artifact is written or stamped and no credit is recorded, the coverage-reading gates (CRAP preview, coverage and CRAP baselines) are skipped, and handoff and close proceed — the terminal envelope and the PR body say coverage was deferred. Set it only when the consumer's CI runs the deferred suite with a coverage floor. A timeout (124) is never deferred, under either value.",
88
97
  default: COVERAGE_GATE_DEFAULTS.onOverBudget,
89
98
  },
99
+ suiteOfRecord: {
100
+ type: 'string',
101
+ enum: ['local', 'ci'],
102
+ description:
103
+ "Where the coverage capture runs. `local` (default) changes nothing. `ci` — meant for a small host's `.agentrc.local.json` — makes CI the coverage and CRAP ratchet of record: handoff and close settle the coverage gate as deferred (reason `suite-of-record-ci`) without spawning the capture, the PR body carries the `Coverage-deferred:` key line, and confirm-merge waits for `ciRatchetCheck` to go green. Requires `ciRatchetCheck`; without it handoff blocks and close fails.",
104
+ default: COVERAGE_GATE_DEFAULTS.suiteOfRecord,
105
+ },
106
+ ciRatchetCheck: {
107
+ type: ['string', 'null'],
108
+ minLength: 1,
109
+ description:
110
+ "Name of the consumer's CI check (check-run or status context) that runs `coverage-ratchet.js` on a deferred PR. Required by `suiteOfRecord: ci`; when set, confirm-merge holds `agent::done` on a PR carrying the `Coverage-deferred:` key line until this check is green on the PR head. Default `null`.",
111
+ default: null,
112
+ },
113
+ nonInputGlobs: {
114
+ type: 'array',
115
+ items: { ...SAFE_STRING, minLength: 1 },
116
+ description:
117
+ "Repo-relative picomatch globs naming paths no test reads. A matching path is dropped from both sides of the coverage delta-refresh overlap check and from the re-measured set — a delta of only matching, baseline and coverage-directory paths restamps without a run — and from the overlap check of close's `test` delta re-credit (its incoming count and emptiness test are unchanged). It never changes the suite-input filter, the tree digest or stamp freshness. Default `[]`: nothing is built in, so Markdown counts as an input unless declared here.",
118
+ default: [],
119
+ },
120
+ captureHandlesConfigChanges: {
121
+ type: 'boolean',
122
+ description:
123
+ "Declares that the affected capture script, given `MANDREL_COVERAGE_BASE_REF`, widens its own selection when a coverage-determining config file (`package.json`, a lockfile, `tsconfig*.json`, a test-runner config) changes. When `true`, such a file in the coverage delta no longer refuses the delta refresh. Close's `test` delta re-credit refuses on a config file under either value. Default `false`.",
124
+ default: COVERAGE_GATE_DEFAULTS.captureHandlesConfigChanges,
125
+ },
126
+ ownFixDeltaMaxFiles: {
127
+ type: 'integer',
128
+ minimum: 0,
129
+ maximum: 50,
130
+ description:
131
+ "Opt-in own-fix delta refresh for `captureScope: affected`. `0` (default) keeps it off. `N >= 1` lets a delta that today's rule refuses for a Story overlap or a config file be re-measured as a delta when it splits, along HEAD's first-parent chain, into base-sync merges that pass today's rule and the Story's own non-merge commits touching at most `N` suite-input files, with no config file, no deleted or renamed suite input and no net line removal in a test file. Rows outside the delta can go stale high; validate against full captures before raising it. `10` is a reasonable start.",
132
+ default: COVERAGE_GATE_DEFAULTS.ownFixDeltaMaxFiles,
133
+ },
90
134
  },
91
135
  additionalProperties: false,
92
136
  };
@@ -25,7 +25,7 @@ export const INCREMENTAL_COVERAGE_SCHEMA = {
25
25
  type: 'string',
26
26
  minLength: 1,
27
27
  description:
28
- 'Default git ref the changed-file set is computed against, for a caller that passes no `--ref`. A `--ref` the caller named wins over this value, so a caller that anchors another gate on the same ref — `.husky/pre-push`, which passes `--ref origin/main` and then previews `--changed-since origin/main` — resolves ONE scope for both steps (Story #5365). Omitted and unpassed, the gate’s own default `main` applies.',
28
+ 'Default git ref the changed-file set is computed against, for a caller that passes no `--ref`. A `--ref` the caller named wins over this value, so a caller that anchors another gate on the same ref — `.husky/pre-push`, which passes `--ref origin/main` and then previews `--changed-since origin/main` — resolves ONE scope for both steps (Story #5365). Omitted and unpassed, the default is `origin/<project.baseBranch>` (`origin/main` by default), so a local base branch that trails the remote cannot widen the set; a clone where that remote ref does not resolve falls back to the local base branch with a warning.',
29
29
  },
30
30
  },
31
31
  additionalProperties: false,