mandrel 2.111.0 → 2.113.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 (183) 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 +367 -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/merge-envelopes.js +46 -1
  38. package/.agents/scripts/lib/baselines/preview-gates.js +29 -10
  39. package/.agents/scripts/lib/baselines/reader.js +36 -9
  40. package/.agents/scripts/lib/baselines/refresh-service.js +93 -21
  41. package/.agents/scripts/lib/baselines/seat-missing.js +173 -7
  42. package/.agents/scripts/lib/baselines/writer.js +36 -21
  43. package/.agents/scripts/lib/changed-files.js +70 -6
  44. package/.agents/scripts/lib/child-exec.js +10 -0
  45. package/.agents/scripts/lib/claude/agents-projection.js +5 -5
  46. package/.agents/scripts/lib/close-lock-events.js +8 -3
  47. package/.agents/scripts/lib/close-validation/ci-deferral.js +40 -0
  48. package/.agents/scripts/lib/close-validation/gates.js +111 -35
  49. package/.agents/scripts/lib/close-validation/process.js +16 -7
  50. package/.agents/scripts/lib/close-validation/projections/crap.js +43 -10
  51. package/.agents/scripts/lib/close-validation/runner.js +55 -23
  52. package/.agents/scripts/lib/close-validation/skip-branch-test.js +144 -0
  53. package/.agents/scripts/lib/close-validation/test-delta.js +33 -8
  54. package/.agents/scripts/lib/codex/agents-projection.js +6 -0
  55. package/.agents/scripts/lib/config/agentrc-overlay.js +9 -5
  56. package/.agents/scripts/lib/config/explain.js +5 -2
  57. package/.agents/scripts/lib/config/gates/coverage.schema.js +45 -1
  58. package/.agents/scripts/lib/config/gates/crap-incremental-coverage.schema.js +1 -1
  59. package/.agents/scripts/lib/config/git-roots.js +38 -4
  60. package/.agents/scripts/lib/config/handoff.js +24 -0
  61. package/.agents/scripts/lib/config/quality.js +26 -13
  62. package/.agents/scripts/lib/config/worktree-isolation.js +2 -5
  63. package/.agents/scripts/lib/config-resolver.js +22 -2
  64. package/.agents/scripts/lib/config-settings-schema-delivery.js +87 -4
  65. package/.agents/scripts/lib/config-settings-schema-quality.js +36 -1
  66. package/.agents/scripts/lib/config-settings-schema.js +1 -1
  67. package/.agents/scripts/lib/coverage-capture-affected.js +1 -0
  68. package/.agents/scripts/lib/coverage-capture-delta.js +164 -32
  69. package/.agents/scripts/lib/coverage-capture-own-fix.js +232 -0
  70. package/.agents/scripts/lib/coverage-capture-usage.js +2 -2
  71. package/.agents/scripts/lib/coverage-capture.js +15 -0
  72. package/.agents/scripts/lib/coverage-deferral.js +96 -0
  73. package/.agents/scripts/lib/coverage-ratchet.js +187 -0
  74. package/.agents/scripts/lib/crap-baseline-join.js +5 -5
  75. package/.agents/scripts/lib/crap-engine.js +3 -3
  76. package/.agents/scripts/lib/crap-method-identity.js +104 -48
  77. package/.agents/scripts/lib/error-redactor.js +20 -0
  78. package/.agents/scripts/lib/escomplex-anchor.js +135 -0
  79. package/.agents/scripts/lib/escomplex-kernel.js +30 -1
  80. package/.agents/scripts/lib/failure-rows.js +121 -0
  81. package/.agents/scripts/lib/full-suite-lock.js +44 -4
  82. package/.agents/scripts/lib/full-suite-queue.js +89 -13
  83. package/.agents/scripts/lib/generated/agentrc-validator.js +8 -2
  84. package/.agents/scripts/lib/gh-env.js +3 -6
  85. package/.agents/scripts/lib/gh-pr-rest.js +1 -0
  86. package/.agents/scripts/lib/git/base-sync-probe.js +182 -0
  87. package/.agents/scripts/lib/git/baseline-conflict-rows.js +60 -0
  88. package/.agents/scripts/lib/git/sync-from-base.js +18 -9
  89. package/.agents/scripts/lib/git-branch-lifecycle.js +9 -0
  90. package/.agents/scripts/lib/observability/close-telemetry.js +37 -2
  91. package/.agents/scripts/lib/observability/handoff-telemetry.js +170 -0
  92. package/.agents/scripts/lib/observability/review-dispositions.js +23 -6
  93. package/.agents/scripts/lib/observability/runtime-friction.js +17 -4
  94. package/.agents/scripts/lib/observability/source-classifier.js +3 -0
  95. package/.agents/scripts/lib/observability/story-outcome.js +393 -0
  96. package/.agents/scripts/lib/orchestration/check-baselines/phases/compare.js +2 -1
  97. package/.agents/scripts/lib/orchestration/check-baselines/phases/evaluate.js +19 -1
  98. package/.agents/scripts/lib/orchestration/check-baselines/phases/fail-detail.js +84 -0
  99. package/.agents/scripts/lib/orchestration/check-baselines/phases/pipeline.js +14 -5
  100. package/.agents/scripts/lib/orchestration/check-baselines/phases/refresh-ack.js +3 -2
  101. package/.agents/scripts/lib/orchestration/check-baselines/phases/report.js +26 -6
  102. package/.agents/scripts/lib/orchestration/code-review.js +223 -19
  103. package/.agents/scripts/lib/orchestration/handoff-gates.js +129 -62
  104. package/.agents/scripts/lib/orchestration/handoff-rescore.js +170 -0
  105. package/.agents/scripts/lib/orchestration/handoff-suite-of-record.js +45 -0
  106. package/.agents/scripts/lib/orchestration/preflight-lanes.js +208 -0
  107. package/.agents/scripts/lib/orchestration/review-base-ref.js +40 -17
  108. package/.agents/scripts/lib/orchestration/review-deposit.js +38 -12
  109. package/.agents/scripts/lib/orchestration/review-depth.js +21 -0
  110. package/.agents/scripts/lib/orchestration/review-history.js +124 -20
  111. package/.agents/scripts/lib/orchestration/review-providers/claude-verdict.js +41 -12
  112. package/.agents/scripts/lib/orchestration/review-providers/code-review.js +90 -39
  113. package/.agents/scripts/lib/orchestration/review-providers/critical-verifier.js +64 -11
  114. package/.agents/scripts/lib/orchestration/review-providers/degraded-gates.js +102 -3
  115. package/.agents/scripts/lib/orchestration/review-providers/finding-identity.js +6 -2
  116. package/.agents/scripts/lib/orchestration/review-providers/findings-renderer.js +55 -8
  117. package/.agents/scripts/lib/orchestration/review-providers/review-guidance.js +1 -0
  118. package/.agents/scripts/lib/orchestration/review-providers/review-provider-factory.js +42 -15
  119. package/.agents/scripts/lib/orchestration/review-providers/types.js +6 -0
  120. package/.agents/scripts/lib/orchestration/single-story-close/failed-terminal.js +10 -1
  121. package/.agents/scripts/lib/orchestration/single-story-close/gate-log.js +10 -0
  122. package/.agents/scripts/lib/orchestration/single-story-close/phases/base-sync.js +7 -4
  123. package/.agents/scripts/lib/orchestration/single-story-close/phases/close-validation.js +16 -3
  124. package/.agents/scripts/lib/orchestration/single-story-close/phases/code-review.js +59 -2
  125. package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +6 -0
  126. package/.agents/scripts/lib/orchestration/single-story-close/phases/finish.js +15 -4
  127. package/.agents/scripts/lib/orchestration/single-story-close/phases/land-review-record.js +213 -0
  128. package/.agents/scripts/lib/orchestration/single-story-close/phases/normalize-pr-title.js +9 -12
  129. package/.agents/scripts/lib/orchestration/single-story-close/phases/open-pr.js +26 -12
  130. package/.agents/scripts/lib/orchestration/single-story-close/phases/post-land.js +51 -26
  131. package/.agents/scripts/lib/orchestration/single-story-close/phases/pre-gate-steps.js +2 -1
  132. package/.agents/scripts/lib/orchestration/single-story-close/phases/pre-push.js +3 -2
  133. package/.agents/scripts/lib/orchestration/single-story-close/phases/pull-request.js +50 -17
  134. package/.agents/scripts/lib/orchestration/single-story-close/phases/push.js +59 -11
  135. package/.agents/scripts/lib/orchestration/single-story-close/phases/reconcile-done.js +1 -0
  136. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-block.js +31 -13
  137. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-halt.js +29 -6
  138. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-outcome.js +10 -12
  139. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-override.js +19 -4
  140. package/.agents/scripts/lib/orchestration/single-story-close/result.js +30 -13
  141. package/.agents/scripts/lib/orchestration/single-story-close/review-overlap.js +73 -39
  142. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +11 -3
  143. package/.agents/scripts/lib/orchestration/story-close/baseline-upward-writeback.js +3 -2
  144. package/.agents/scripts/lib/orchestration/story-close/duplication-close-rescore.js +77 -15
  145. package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +7 -0
  146. package/.agents/scripts/lib/orchestration/story-handoff.js +796 -196
  147. package/.agents/scripts/lib/orchestration/ticketing/reads.js +2 -0
  148. package/.agents/scripts/lib/pr-body-lines.js +32 -0
  149. package/.agents/scripts/lib/single-story/ci-ratchet-gate.js +140 -0
  150. package/.agents/scripts/lib/single-story/confirm-and-land.js +17 -7
  151. package/.agents/scripts/lib/single-story/confirm-merge.js +12 -3
  152. package/.agents/scripts/lib/single-story-sweep/report-stalled-executing.js +202 -0
  153. package/.agents/scripts/lib/standalone-ratchets.js +37 -0
  154. package/.agents/scripts/lib/suite-admission.js +20 -8
  155. package/.agents/scripts/lib/suite-sizing.js +146 -0
  156. package/.agents/scripts/lib/workspace-provisioner.js +2 -2
  157. package/.agents/scripts/merge-baseline.js +14 -3
  158. package/.agents/scripts/providers/github/comments.js +19 -3
  159. package/.agents/scripts/providers/github.js +1 -0
  160. package/.agents/scripts/review-dispositions-report.js +1 -1
  161. package/.agents/scripts/role-scope-guard.js +267 -0
  162. package/.agents/scripts/single-story-close.js +4 -4
  163. package/.agents/scripts/single-story-confirm-merge.js +31 -5
  164. package/.agents/scripts/single-story-init.js +24 -4
  165. package/.agents/scripts/story-handoff.js +3 -3
  166. package/.agents/scripts/story-outcomes-report.js +231 -0
  167. package/.agents/scripts/story-review-compute.js +9 -5
  168. package/.agents/scripts/update-coverage-baseline.js +12 -2
  169. package/.agents/scripts/update-crap-baseline.js +9 -1
  170. package/.agents/workflows/helpers/code-review.md +63 -9
  171. package/.agents/workflows/helpers/deliver-digest.md +53 -54
  172. package/.agents/workflows/helpers/deliver-reference.md +233 -67
  173. package/.agents/workflows/helpers/deliver-story-reference.md +19 -8
  174. package/.agents/workflows/helpers/deliver-story.md +7 -2
  175. package/.agents/workflows/helpers/parallel-tooling.md +29 -0
  176. package/docs/CHANGELOG.md +55 -0
  177. package/lib/cli/doctor-checks/coverage-ratchet.js +54 -0
  178. package/lib/cli/doctor-checks/effective-agentrc.js +23 -0
  179. package/lib/cli/doctor-checks/llm-review.js +2 -11
  180. package/lib/cli/doctor-checks/sync-parity.js +5 -1
  181. package/lib/cli/doctor-checks/test-credit-path.js +7 -2
  182. package/lib/cli/registry.js +5 -0
  183. package/package.json +1 -1
@@ -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,
@@ -2,8 +2,10 @@
2
2
 
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
+ import { isDeepStrictEqual } from 'node:util';
5
6
 
6
7
  import { execFileCapture } from '../child-exec.js';
8
+ import { readJsonOrNull } from '../json-utils.js';
7
9
  import { PROJECT_ROOT } from '../project-root.js';
8
10
 
9
11
  const GIT_QUIET = { stdio: ['ignore', 'pipe', 'ignore'] };
@@ -108,10 +110,42 @@ export function storeRoot(root, exec, platform = process.platform) {
108
110
  return checkoutOf(root, exec, platform) ?? root;
109
111
  }
110
112
 
111
- /** Where `root`'s `.agentrc.local.json` is read: its own, else `storeRoot`'s. */
112
- export function overlayRoot(root, exec) {
113
- if (fs.existsSync(path.join(root, '.agentrc.local.json'))) return root;
114
- return storeRoot(root, exec);
113
+ const LOCAL_AGENTRC = '.agentrc.local.json';
114
+ const hasOverlay = (dir, fsImpl = fs) =>
115
+ fsImpl.existsSync(path.join(dir, LOCAL_AGENTRC));
116
+
117
+ /**
118
+ * Where `root`'s `.agentrc.local.json` is read: one overlay per machine, so a
119
+ * linked worktree reads the main checkout's when it holds one, else its own.
120
+ */
121
+ export function overlayRoot(root, exec, fsImpl = fs) {
122
+ const main = storeRoot(root, exec);
123
+ return hasOverlay(main, fsImpl) ? main : root;
124
+ }
125
+
126
+ const sameDir = (a, b) =>
127
+ canonical(a, process.platform) === canonical(b, process.platform);
128
+
129
+ /** Equal as parsed JSON; an unparseable `own` never matches. */
130
+ function sameOverlay(own, live) {
131
+ const parsed = readJsonOrNull(own);
132
+ return parsed !== null && isDeepStrictEqual(parsed, readJsonOrNull(live));
133
+ }
134
+
135
+ /**
136
+ * A linked worktree's own overlay that differs from the main checkout's one
137
+ * in force, else `null`.
138
+ *
139
+ * @returns {{ worktreePath: string, mainPath: string }|null}
140
+ */
141
+ export function overlayDivergence(root, exec) {
142
+ const main = overlayRoot(root, exec);
143
+ if (sameDir(main, root) || !hasOverlay(root)) return null;
144
+ const worktreePath = path.join(root, LOCAL_AGENTRC);
145
+ const mainPath = path.join(main, LOCAL_AGENTRC);
146
+ return sameOverlay(worktreePath, mainPath)
147
+ ? null
148
+ : { worktreePath, mainPath };
115
149
  }
116
150
 
117
151
  /** Test-only. */
@@ -0,0 +1,24 @@
1
+ /** `delivery.handoff`: consumer checks the handoff re-runs after its seat. */
2
+
3
+ const isStringArray = (v) =>
4
+ Array.isArray(v) && v.every((a) => typeof a === 'string');
5
+
6
+ /** A `{ cmd, args? }` entry with a non-empty `cmd` and string `args`. */
7
+ const isCheck = (c) =>
8
+ typeof c?.cmd === 'string' &&
9
+ c.cmd.length > 0 &&
10
+ (c.args === undefined || isStringArray(c.args));
11
+
12
+ /**
13
+ * `delivery.handoff.postSeatChecks`, malformed entries dropped.
14
+ *
15
+ * @param {object|null|undefined} config
16
+ * @returns {Array<{ cmd: string, args: string[] }>}
17
+ */
18
+ export function getPostSeatChecks(config) {
19
+ const checks = config?.delivery?.handoff?.postSeatChecks;
20
+ if (!Array.isArray(checks)) return [];
21
+ return checks
22
+ .filter(isCheck)
23
+ .map(({ cmd, args }) => ({ cmd, args: args ?? [] }));
24
+ }
@@ -99,6 +99,11 @@ const COVERAGE_GATE_KEYS = new Set([
99
99
  'captureScope',
100
100
  'timeoutMs',
101
101
  'onOverBudget',
102
+ 'suiteOfRecord',
103
+ 'ciRatchetCheck',
104
+ 'nonInputGlobs',
105
+ 'captureHandlesConfigChanges',
106
+ 'ownFixDeltaMaxFiles',
102
107
  ]);
103
108
 
104
109
  const MI_GATE_KEYS = new Set([
@@ -307,20 +312,10 @@ function resolveMaintainabilityQuality(userBlock) {
307
312
  return out;
308
313
  }
309
314
 
310
- function resolveCoverageGate(userBlock) {
315
+ function resolveCoverageGate(raw) {
311
316
  const defaults = COVERAGE_GATE_DEFAULTS;
312
- if (userBlock == null || typeof userBlock !== 'object') {
313
- return {
314
- enabled: defaults.enabled,
315
- baselinePath: defaults.baselinePath,
316
- coveragePath: defaults.coveragePath,
317
- captureScript: defaults.captureScript,
318
- captureScope: defaults.captureScope,
319
- tolerance: toleranceScalar(defaults.tolerance, 0),
320
- timeoutMs: defaults.timeoutMs,
321
- onOverBudget: defaults.onOverBudget,
322
- };
323
- }
317
+ // An absent or malformed block resolves exactly as an empty one.
318
+ const userBlock = raw != null && typeof raw === 'object' ? raw : {};
324
319
  warnUnknownKeys(userBlock, COVERAGE_GATE_KEYS, 'quality.gates.coverage');
325
320
  return {
326
321
  enabled: userBlock.enabled ?? defaults.enabled,
@@ -335,6 +330,17 @@ function resolveCoverageGate(userBlock) {
335
330
  ),
336
331
  timeoutMs: userBlock.timeoutMs ?? defaults.timeoutMs,
337
332
  onOverBudget: userBlock.onOverBudget ?? defaults.onOverBudget,
333
+ suiteOfRecord: userBlock.suiteOfRecord ?? defaults.suiteOfRecord,
334
+ ciRatchetCheck:
335
+ nonEmptyString(userBlock.ciRatchetCheck) ?? defaults.ciRatchetCheck,
336
+ nonInputGlobs: Array.isArray(userBlock.nonInputGlobs)
337
+ ? userBlock.nonInputGlobs.slice()
338
+ : [...defaults.nonInputGlobs],
339
+ captureHandlesConfigChanges:
340
+ userBlock.captureHandlesConfigChanges ??
341
+ defaults.captureHandlesConfigChanges,
342
+ ownFixDeltaMaxFiles:
343
+ userBlock.ownFixDeltaMaxFiles ?? defaults.ownFixDeltaMaxFiles,
338
344
  };
339
345
  }
340
346
 
@@ -426,6 +432,12 @@ function resolveGatesWithFloors(gates) {
426
432
  return out;
427
433
  }
428
434
 
435
+ /** `coveredByLint` is always an array; absent or malformed is `[]`. */
436
+ function resolveRatchets(userBlock) {
437
+ const covered = userBlock?.coveredByLint;
438
+ return { coveredByLint: Array.isArray(covered) ? covered.slice() : [] };
439
+ }
440
+
429
441
  /**
430
442
  * @param {object|undefined} userQuality
431
443
  */
@@ -443,6 +455,7 @@ export function resolveQuality(userQuality) {
443
455
  baselines: resolveBaselinesFromGates(gates),
444
456
  codingGuardrails: { ...CODING_GUARDRAILS },
445
457
  autoRefresh: resolveAutoRefresh(block.autoRefresh),
458
+ ratchets: resolveRatchets(block.ratchets),
446
459
  baselineEpsilon: { ...BASELINE_EPSILON },
447
460
  gates: resolvedGates,
448
461
  };
@@ -21,14 +21,11 @@ export const WORKTREE_ISOLATION_DEFAULTS = Object.freeze({
21
21
  primeFromPath: null,
22
22
  allowSymlinkOnWindows: false,
23
23
  reapOnSuccess: true,
24
- // Local overrides must reach the worktree, or e.g. `operatorHandle` reads
25
- // the committed placeholder and lease release breaks at close. Absent
26
- // files are skipped. Keep in sync with `DEFAULT_WORKSPACE_FILES` in
27
- // `../workspace-provisioner.js`.
24
+ // Gitignored files a worktree needs; absent files are skipped. Keep in
25
+ // sync with `DEFAULT_WORKSPACE_FILES` in `../workspace-provisioner.js`.
28
26
  bootstrapFiles: Object.freeze([
29
27
  '.env',
30
28
  '.mcp.json',
31
- '.agentrc.local.json',
32
29
  '.agents/instructions.local.md',
33
30
  ]),
34
31
  });
@@ -12,7 +12,11 @@ import {
12
12
  } from './config/agentrc-overlay.js';
13
13
  import { getCiDelivery } from './config/ci.js';
14
14
  import { getCommands } from './config/commands.js';
15
- import { overlayRoot, resolveAgentrcRoot } from './config/git-roots.js';
15
+ import {
16
+ overlayDivergence,
17
+ overlayRoot,
18
+ resolveAgentrcRoot,
19
+ } from './config/git-roots.js';
16
20
  import { applyOperatorHandleEnv, getGitHub } from './config/github.js';
17
21
  import { resolvePaths } from './config/paths.js';
18
22
  import { validateOrchestrationConfig } from './config/validate-orchestration.js';
@@ -56,6 +60,7 @@ export { PROJECT_ROOT } from './project-root.js';
56
60
  // `validate: false` read never answer a validating caller.
57
61
  const _cacheByKey = new Map();
58
62
  const _envLoadedRoots = new Set();
63
+ const _divergenceWarned = new Set();
59
64
 
60
65
  /**
61
66
  * Enrich `github.notifications` with NOTIFICATIONS_DEFAULTS so an omitted
@@ -146,7 +151,10 @@ function applyDefaults(raw) {
146
151
  */
147
152
  function readRawConfig(fsImpl, root) {
148
153
  const agentrcPath = path.join(root, '.agentrc.json');
149
- const localPath = path.join(overlayRoot(root), '.agentrc.local.json');
154
+ const localPath = path.join(
155
+ overlayRoot(root, undefined, fsImpl),
156
+ '.agentrc.local.json',
157
+ );
150
158
  const hasAgentrc = fsImpl.existsSync(agentrcPath);
151
159
  const hasLocal = fsImpl.existsSync(localPath);
152
160
  if (!hasAgentrc) {
@@ -193,6 +201,17 @@ function finalizeConfig({ raw, source }, validate) {
193
201
  return { ...blocks, raw, source };
194
202
  }
195
203
 
204
+ const divergenceLine = ({ worktreePath, mainPath }) =>
205
+ `[config] ⚠️ ${worktreePath} differs from ${mainPath}; the main checkout's overlay is in force, and the worktree copy is ignored and can be deleted.\n`;
206
+
207
+ /** One stderr line per worktree root whose own overlay a main one shadows. */
208
+ function warnOverlayDivergence(root) {
209
+ if (_divergenceWarned.has(root)) return;
210
+ _divergenceWarned.add(root);
211
+ const diverged = overlayDivergence(root);
212
+ if (diverged) process.stderr.write(divergenceLine(diverged));
213
+ }
214
+
196
215
  function ensureEnvLoaded(root) {
197
216
  if (_envLoadedRoots.has(root)) return;
198
217
  loadEnv(root);
@@ -216,6 +235,7 @@ export function resolveConfig(opts) {
216
235
  return _cacheByKey.get(key);
217
236
  }
218
237
  ensureEnvLoaded(root);
238
+ warnOverlayDivergence(root);
219
239
  const resolved = finalizeConfig(
220
240
  applyOperatorHandleEnv(readRawConfig(injectedFs ?? fs, root)),
221
241
  validate,
@@ -41,12 +41,12 @@ const EXECUTION_SCHEMA = {
41
41
  type: 'integer',
42
42
  minimum: 1,
43
43
  description:
44
- "Story #5668. The admission budget, in weight units (CPU workers), shared by every suite spawn across this repository's worktrees and sessions — runs in other repositories on the host are not counted. Unset → the host's `os.availableParallelism()`. A declared workload is admitted while the live weights plus its own fit, strictly first-in-first-out: nothing overtakes an earlier live waiter, so a queued full suite is never starved.",
44
+ "Story #5668. The admission budget, in weight units (CPU workers), shared by every suite spawn across this repository's worktrees and sessions — runs in other repositories on the host are not counted. Unset → the host's `os.availableParallelism()`. A declared workload is admitted while the live weights plus its own fit, first-in-first-out: nothing overtakes an earlier live waiter, so a queued full suite is never starved — except a `workloads[].backfill` run, which may pass earlier declared waiters it fits beside, only while the oldest has waited under 300 s.",
45
45
  },
46
46
  workloads: {
47
47
  type: 'array',
48
48
  description:
49
- "Story #5668. Suite commands declared safe to run alongside others. A spawn whose argv (whitespace-normalized) EXACTLY equals `command` takes that `weight` and `resources`; anything else — and every spawn when this list is empty, the default — runs exclusively (full capacity, today's serialization). Isolation is never inferred from a flag, prefix or diff size. `weight` must count the run's nested worker pool (`--workers 4` → 4), and a full suite needs its own entry before anything can overlap it. Two runs naming a common `resources` entry (a database fixture, a shared coverage file) never overlap; worktree-local outputs need none. A weight above `capacity` refuses the run with exit 78 — nothing spawns, no credit is recorded. An expired wait still exits 75, resumably. Scheduling never changes a run's credit identity. `MANDREL_FULL_SUITE_LOCK=0` (one invocation) or `fullSuiteLock: false` turns admission off entirely; reach for the env hatch only when you have checked the runs share nothing.",
49
+ "Story #5668. Suite commands declared safe to run alongside others. A spawn whose argv (whitespace-normalized) EXACTLY equals `command` takes that `weight` and `resources`; anything else — and every spawn when this list is empty, the default — runs exclusively (full capacity, today's serialization). Isolation is never inferred from a flag or prefix; a weight comes from the entry, or from its `tiers` as sized by its own `sizeCommand`. `weight` must count the run's nested worker pool (`--workers 4` → 4), and a full suite needs its own entry before anything can overlap it. Two runs naming a common `resources` entry (a database fixture, a shared coverage file) never overlap; worktree-local outputs need none. A weight above `capacity` refuses the run with exit 78 — nothing spawns, no credit is recorded. An expired wait still exits 75, resumably. Scheduling never changes a run's credit identity. `MANDREL_FULL_SUITE_LOCK=0` (one invocation) or `fullSuiteLock: false` turns admission off entirely; reach for the env hatch only when you have checked the runs share nothing.",
50
50
  items: {
51
51
  type: 'object',
52
52
  required: ['command', 'weight'],
@@ -70,11 +70,46 @@ const EXECUTION_SCHEMA = {
70
70
  description:
71
71
  'Names of shared resources this run needs exclusively.',
72
72
  },
73
+ tiers: {
74
+ type: 'array',
75
+ minItems: 1,
76
+ items: {
77
+ type: 'object',
78
+ required: ['maxFiles', 'weight'],
79
+ properties: {
80
+ maxFiles: { type: 'integer', minimum: 0 },
81
+ weight: { type: 'integer', minimum: 1 },
82
+ },
83
+ additionalProperties: false,
84
+ },
85
+ description:
86
+ 'Story #5963. Slice-size tiers: the run books the weight of the first tier (ascending `maxFiles`) whose `maxFiles` covers the count `sizeCommand` prints; none, a sizing failure or a tier weight above `weight` books the full `weight`. Requires `sizeCommand`.',
87
+ },
88
+ sizeCommand: {
89
+ ...SAFE_STRING,
90
+ minLength: 1,
91
+ description:
92
+ "Story #5963. Argv (no shell, 60 s bound) printing the slice's test-file count as its last stdout line; run in the spawn's cwd and env just before reserving. Requires `tiers`.",
93
+ },
94
+ backfill: {
95
+ type: 'boolean',
96
+ default: false,
97
+ description:
98
+ 'Story #5963. Let this run be admitted ahead of earlier waiters when every one is declared, fits beside it within `capacity` and shares no resource with it, and the oldest has waited under 300 s.',
99
+ },
73
100
  },
101
+ dependencies: { tiers: ['sizeCommand'], sizeCommand: ['tiers'] },
74
102
  additionalProperties: false,
75
103
  },
76
104
  default: [],
77
105
  },
106
+ preflightConcurrency: {
107
+ type: 'integer',
108
+ minimum: 1,
109
+ default: 1,
110
+ description:
111
+ "Story #5997. The most handoff preflight checks that may run at once. `1` (the default) is the serial preflight. Above 1, typecheck, lint and format (close's independent gates) may also run in up to N − 1 extra lanes, each admitted through suite admission with no wait under close's argv for that gate; a miss hands the check back to the serial lane. Set it per host in `.agentrc.local.json`: whether a host can afford a second CPU-heavy check is a per-host fact.",
112
+ },
78
113
  },
79
114
  additionalProperties: false,
80
115
  };
@@ -167,7 +202,7 @@ const WORKTREE_ISOLATION_SCHEMA = {
167
202
  type: 'array',
168
203
  items: { type: 'string', minLength: 1 },
169
204
  description:
170
- 'Gitignored files copied from the main checkout into every new worktree. A worktree checks out tracked files only, so local secrets and overrides would otherwise be missing.',
205
+ "Gitignored files copied from the main checkout into every new worktree. A worktree checks out tracked files only, so local secrets would otherwise be missing. `.agentrc.local.json` is not copied by default: a worktree reads the main checkout's live overlay.",
171
206
  default: [...WORKTREE_ISOLATION_DEFAULTS.bootstrapFiles],
172
207
  },
173
208
  },
@@ -184,6 +219,22 @@ const WORKTREE_ISOLATION_SCHEMA = {
184
219
  ],
185
220
  };
186
221
 
222
+ const CLOSE_SCHEMA = {
223
+ type: 'object',
224
+ description:
225
+ 'Close-time posture (Story #5954). `baseSync` decides whether close and a handoff re-run merge `origin/<baseBranch>` before validating.',
226
+ properties: {
227
+ baseSync: {
228
+ type: 'string',
229
+ enum: ['always', 'on-conflict'],
230
+ description:
231
+ "`always` (default) merges `origin/<baseBranch>` on every close, as before. `on-conflict` first runs a conflict-only probe and skips the merge when it is conflict-free (`git merge-tree --write-tree`) and the incoming and Story paths are disjoint (raw paths, `baselines/` and renames included); `check-baselines` then compares against the merge-base and the terminal envelope's `baseSync` says why. Any other probe answer merges as today. A handoff applies the probe only on a re-run. Opt in only behind a merge queue that re-tests the merged tree and with no up-to-date-branch requirement: a semantic conflict the probe cannot see surfaces in CI, and coverage is measured on the pre-merge tree.",
232
+ default: 'always',
233
+ },
234
+ },
235
+ additionalProperties: false,
236
+ };
237
+
187
238
  const MERGE_WATCH_SCHEMA = {
188
239
  type: 'object',
189
240
  description:
@@ -301,6 +352,30 @@ const PULL_REQUEST_DELIVERY_SCHEMA = {
301
352
  additionalProperties: false,
302
353
  };
303
354
 
355
+ const HANDOFF_SCHEMA = {
356
+ type: 'object',
357
+ description:
358
+ "Story #5960. What `story-handoff.js` runs beyond close's own gates.",
359
+ properties: {
360
+ postSeatChecks: {
361
+ type: 'array',
362
+ items: {
363
+ type: 'object',
364
+ properties: {
365
+ cmd: { type: 'string', minLength: 1 },
366
+ args: { type: 'array', items: { type: 'string' } },
367
+ },
368
+ required: ['cmd'],
369
+ additionalProperties: false,
370
+ },
371
+ description:
372
+ "Story #5960. Consumer checks the handoff re-runs in its post-capture step, after the seat commits the Story's new baseline rows: each `{ cmd, args? }` runs in the worktree without a shell, with `MANDREL_HANDOFF_STEP=post-capture`, and a non-zero exit settles `fix-required`. Declare the check a consumer downgrades during `preflight` (keyed on `MANDREL_HANDOFF_STEP`) here, so a row the seat did not write still fails the handoff; while any is declared the preflight `lint` credit is withheld until they pass at HEAD. Skipped under a coverage deferral. Default [] runs nothing extra.",
373
+ default: [],
374
+ },
375
+ },
376
+ additionalProperties: false,
377
+ };
378
+
304
379
  const REFACTOR_STAGE_SCHEMA = {
305
380
  type: 'object',
306
381
  description:
@@ -336,7 +411,7 @@ const ACCEPTANCE_EVAL_SCHEMA = {
336
411
  const FEEDBACK_LOOP_SCHEMA = {
337
412
  type: 'object',
338
413
  description:
339
- 'Opt-in toggle for the close-time retro auto-file graduator. Auto-filing defaults to OFF (Story #5341).',
414
+ 'Opt-in toggles for anything posted to the tracker unasked: the retro auto-file graduator and the per-Story outcome record. Both default to OFF (Story #5341).',
340
415
  properties: {
341
416
  retroProposals: {
342
417
  type: 'boolean',
@@ -344,6 +419,12 @@ const FEEDBACK_LOOP_SCHEMA = {
344
419
  'When true, the retro auto-files its actionable routed proposals as meta::<framework-gap|consumer-improvement> + friction::<category> issues via the graduator pre-parsed-findings seam, and the rendered retro sections list the filed issue numbers instead of paste-ready gh command stanzas. Defaults to false (Story #5341), which renders the command stanzas instead.',
345
420
  default: false,
346
421
  },
422
+ outcomeRecord: {
423
+ type: 'boolean',
424
+ description:
425
+ 'When true, every close and confirm-merge attempt upserts one `story-outcome` structured comment on the Story issue: a JSON record of each attempt (status, cause, failed gates, mandrel version) plus a carried-forward summary, read back by story-outcomes-report.js. Defaults to false, which makes no extra GitHub call.',
426
+ default: false,
427
+ },
347
428
  },
348
429
  additionalProperties: false,
349
430
  };
@@ -428,12 +509,14 @@ export const DELIVERY_SCHEMA = {
428
509
  // Gate-level schemas (`config/gates/*.schema.js`) compose in here.
429
510
  quality: QUALITY_SCHEMA,
430
511
  mergeWatch: MERGE_WATCH_SCHEMA,
512
+ close: CLOSE_SCHEMA,
431
513
  codeReview: CODE_REVIEW_SCHEMA,
432
514
  refactorStage: REFACTOR_STAGE_SCHEMA,
433
515
  acceptanceEval: ACCEPTANCE_EVAL_SCHEMA,
434
516
  feedbackLoop: FEEDBACK_LOOP_SCHEMA,
435
517
  ci: CI_DELIVERY_SCHEMA,
436
518
  pullRequest: PULL_REQUEST_DELIVERY_SCHEMA,
519
+ handoff: HANDOFF_SCHEMA,
437
520
  routing: ROUTING_SCHEMA,
438
521
  },
439
522
  additionalProperties: false,
@@ -6,6 +6,7 @@
6
6
  import { GATES_SCHEMA } from './config/gates/index.js';
7
7
  import { DEFAULT_REVIEW_PROVIDERS } from './config/review-chain-default.js';
8
8
  import { DEFAULT_CODE_REVIEW } from './config/runners.js';
9
+ import { STANDALONE_RATCHET_KEYS } from './standalone-ratchets.js';
9
10
 
10
11
  const AUTO_REFRESH_SCHEMA = {
11
12
  type: 'object',
@@ -22,6 +23,22 @@ const AUTO_REFRESH_SCHEMA = {
22
23
  additionalProperties: false,
23
24
  };
24
25
 
26
+ const RATCHETS_SCHEMA = {
27
+ type: 'object',
28
+ description: "CI's standalone ratchets as the handoff preflight runs them.",
29
+ properties: {
30
+ coveredByLint: {
31
+ type: 'array',
32
+ uniqueItems: true,
33
+ items: { type: 'string', enum: [...STANDALONE_RATCHET_KEYS] },
34
+ default: [],
35
+ description:
36
+ "Standalone ratchets the handoff preflight skips once the same pass's whole-tree `lint` check exited 0. Each listed ratchet MUST be run, with the same arguments and over the whole repository, by the command `project.commands.lint` resolves to; mandrel cannot inspect that command, so this is the consumer's declaration. A lint that is absent, disabled, failing or narrowed to changed files covers nothing, and CI stays the backstop. Default `[]` runs every ratchet whose baseline is committed.",
37
+ },
38
+ },
39
+ additionalProperties: false,
40
+ };
41
+
25
42
  export const QUALITY_SCHEMA = {
26
43
  type: 'object',
27
44
  description:
@@ -29,6 +46,7 @@ export const QUALITY_SCHEMA = {
29
46
  properties: {
30
47
  gates: GATES_SCHEMA,
31
48
  autoRefresh: AUTO_REFRESH_SCHEMA,
49
+ ratchets: RATCHETS_SCHEMA,
32
50
  requireBaselines: {
33
51
  type: 'boolean',
34
52
  description:
@@ -106,7 +124,7 @@ export const CODE_REVIEW_SCHEMA = {
106
124
  additionalProperties: false,
107
125
  },
108
126
  description:
109
- "Review-provider chain (Story #2871). When unset or empty, falls back to this default: `native` (maintainability scoring of the changed files) then an optional story-scoped `llm-review` — the first available of `code-review` (a low-effort `claude --print` bug review whose every finding is critical and halts close before auto-merge) and `codex` (`codex exec`), so a host with both CLIs runs one LLM review and a host with neither skips it. Pin `code-review` or `codex` to choose the CLI. `security-review` and `ultrareview` are opt-in. The orchestrator iterates inline entries in declaration order and merges their Finding[] before posting one structured comment; manual-prompt entries (e.g. ultrareview) contribute a trailing 'Manual review suggestions' section. Selecting an adapter whose probe fails hard-fails at factory construction unless declared `optional: true` in the chain.",
127
+ "Review-provider chain (Story #2871). When unset or empty, falls back to this default: `native` (maintainability scoring of the changed files) then an optional story-scoped `llm-review` — the first available of `code-review` (a `claude --print` bug review, at the effort `effortByDepth` maps its depth to, whose every finding is critical and halts close before auto-merge) and `codex` (`codex exec`), so a host with both CLIs runs one LLM review and a host with neither skips it. Pin `code-review` or `codex` to choose the CLI. `security-review` and `ultrareview` are opt-in. The orchestrator iterates inline entries in declaration order and merges their Finding[] before posting one structured comment; manual-prompt entries (e.g. ultrareview) contribute a trailing 'Manual review suggestions' section. Selecting an adapter whose probe fails hard-fails at factory construction unless declared `optional: true` in the chain.",
110
128
  default: DEFAULT_REVIEW_PROVIDERS,
111
129
  },
112
130
  autoFixSeverity: {
@@ -135,12 +153,29 @@ export const CODE_REVIEW_SCHEMA = {
135
153
  additionalProperties: false,
136
154
  },
137
155
  },
156
+ effortByDepth: {
157
+ type: 'object',
158
+ description:
159
+ 'The `claude --effort` level the `code-review` provider runs at for each review depth. An entry overrides the shipped default for that depth only: `light: low`, `standard: low`, `deep: high`.',
160
+ propertyNames: { enum: ['light', 'standard', 'deep'] },
161
+ additionalProperties: {
162
+ type: 'string',
163
+ enum: ['low', 'medium', 'high', 'xhigh', 'max'],
164
+ },
165
+ },
138
166
  guidanceFile: {
139
167
  type: 'string',
140
168
  minLength: 1,
141
169
  description:
142
170
  "Project review guidance, a path relative to the project root. Unset, a root `REVIEW.md` is used when present; an absent file is a no-op. Its text is rendered into every LLM review provider's prompt after the framework's severity and anti-gaming rules, and over 8,000 characters is truncated with a degradation. Guidance may add failure classes and paths worth skipping but cannot lower a severity rule, excuse a `shortcut:`, or change the output shape.",
143
171
  },
172
+ onNoVerdict: {
173
+ type: 'string',
174
+ enum: ['report', 'block'],
175
+ default: 'report',
176
+ description:
177
+ 'What a Story-scope review that left part or all of the diff without a verdict does. `report` (default) records it (`gates.codeReview: unreviewed` or `partial`) and does not halt. `block` halts handoff and close on any `verdict-missing` or `coverage-partial` degradation, naming the cause, its fix and the `story-review-compute.js` re-run command; `--override-review-block` stays the escape. Reduced context (`degraded`) never halts. Set `block` when this review is the only pre-merge review.',
178
+ },
144
179
  skipPaths: {
145
180
  type: 'array',
146
181
  items: { type: 'string', minLength: 1 },
@@ -89,7 +89,7 @@ const COMMANDS_SCHEMA = {
89
89
  testChanged: {
90
90
  ...NULLABLE_NONEMPTY_SAFE_STRING,
91
91
  description:
92
- "Optional changed-tests command for the delta re-credit: when close's base sync merged sibling landings into a branch whose pre-sync head holds `test` credit, close's `test` gate runs this instead of the full suite, with the credited commit in the `MANDREL_CHANGED_SINCE` environment variable and in place of a literal `$MANDREL_CHANGED_SINCE` argument (e.g. `pnpm vitest run --changed $MANDREL_CHANGED_SINCE`; no shell runs it), and a green run re-credits the merged tree. Ineligible when coverage-capture runs the suite, an incoming path is a coverage-config file or one of the Story's own files, or no incoming path is a suite input. The overlap rule ignores baseline (`baselines/`) and coverage-directory paths. Absent or `null` keeps the full re-run.",
92
+ "Optional changed-tests command for the delta re-credit: when close's base sync merged sibling landings into a branch whose pre-sync head holds `test` credit, close's `test` gate runs this instead of the full suite, with the credited commit in the `MANDREL_CHANGED_SINCE` environment variable and in place of a literal `$MANDREL_CHANGED_SINCE` argument (e.g. `pnpm vitest run --changed $MANDREL_CHANGED_SINCE`; no shell runs it), and a green run re-credits the merged tree. Ineligible when coverage-capture runs the suite, an incoming path is a coverage-config file or one of the Story's own files, or no incoming path is a suite input. The overlap rule ignores baseline (`baselines/`) and coverage-directory paths, and paths matching `delivery.quality.gates.coverage.nonInputGlobs`; those globs never change the incoming count or the emptiness rule, and a config file refuses under either value of `captureHandlesConfigChanges`. It is also the skip-branch first-credit depositor: when coverage-capture is active but takes its incremental skip (no changed file under `crap.targetDirs`), handoff and close run it keyed on the `origin/<baseBranch>` merge-base, credited as the full suite. It MUST therefore select any test that reads a non-module input by path (a docs registry, a fixture file) — `--changed` cannot see that edge, so a break only such a test catches surfaces only where the full suite runs later. Prefer reading `MANDREL_CHANGED_SINCE` from the env over the argv token, so the spawned argv stays constant and declarable in `delivery.execution.workloads[]`. Absent or `null` keeps the full re-run and the full skip-branch suite.",
93
93
  },
94
94
  typecheck: {
95
95
  ...NULLABLE_NONEMPTY_SAFE_STRING,
@@ -321,6 +321,7 @@ async function runAffectedCapture({
321
321
  ref,
322
322
  fsImpl,
323
323
  classifyDeltaRefreshImpl,
324
+ coverage: rest.coverage,
324
325
  logger,
325
326
  });
326
327
  return captureAndMerge({