mandrel 2.110.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 (190) 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/audit-checklists/state-machines.md +21 -0
  6. package/.agents/docs/agentrc-reference.json +23 -10
  7. package/.agents/docs/configuration.md +362 -15
  8. package/.agents/docs/execution-reference.md +11 -0
  9. package/.agents/docs/workflows.md +2 -1
  10. package/.agents/rules/ci-remediation.md +28 -4
  11. package/.agents/rules/git-conventions-reference.md +7 -0
  12. package/.agents/schemas/agentrc.schema.json +179 -13
  13. package/.agents/schemas/audit-rules.json +28 -0
  14. package/.agents/schemas/baselines/baseline-envelope.schema.json +16 -4
  15. package/.agents/schemas/baselines/bundle-size.schema.json +1 -0
  16. package/.agents/schemas/baselines/coverage.schema.json +1 -0
  17. package/.agents/schemas/baselines/crap.schema.json +37 -10
  18. package/.agents/schemas/baselines/duplication.schema.json +1 -0
  19. package/.agents/schemas/baselines/maintainability.schema.json +1 -0
  20. package/.agents/schemas/baselines/mutation.schema.json +1 -0
  21. package/.agents/schemas/crap-report.schema.json +6 -5
  22. package/.agents/schemas/story-deliver-terminal.schema.json +49 -3
  23. package/.agents/schemas/story-progress.schema.json +1 -1
  24. package/.agents/schemas/validation-evidence.schema.json +2 -2
  25. package/.agents/scripts/boot-sweep.js +41 -3
  26. package/.agents/scripts/coverage-capture.js +39 -3
  27. package/.agents/scripts/coverage-ratchet.js +106 -0
  28. package/.agents/scripts/evidence-gate.js +84 -21
  29. package/.agents/scripts/file-ci-gap.js +220 -10
  30. package/.agents/scripts/lib/audit-baselines/read.js +8 -1
  31. package/.agents/scripts/lib/audit-baselines/trend.js +2 -1
  32. package/.agents/scripts/lib/audit-to-stories/audit-lenses.js +1 -0
  33. package/.agents/scripts/lib/baseline-loader.js +4 -2
  34. package/.agents/scripts/lib/baselines/codec.js +57 -0
  35. package/.agents/scripts/lib/baselines/crap-preview-incremental.js +8 -3
  36. package/.agents/scripts/lib/baselines/crap-preview-scan.js +10 -16
  37. package/.agents/scripts/lib/baselines/crap-updater-cli.js +4 -13
  38. package/.agents/scripts/lib/baselines/kernel.js +19 -1
  39. package/.agents/scripts/lib/baselines/kinds/_crap-codec.js +171 -0
  40. package/.agents/scripts/lib/baselines/kinds/_crap-read.js +56 -16
  41. package/.agents/scripts/lib/baselines/kinds/_shared-metric.js +0 -59
  42. package/.agents/scripts/lib/baselines/kinds/crap.js +283 -319
  43. package/.agents/scripts/lib/baselines/preview-gates.js +29 -10
  44. package/.agents/scripts/lib/baselines/reader.js +36 -9
  45. package/.agents/scripts/lib/baselines/refresh-service.js +79 -18
  46. package/.agents/scripts/lib/baselines/seat-missing.js +173 -7
  47. package/.agents/scripts/lib/baselines/writer.js +36 -21
  48. package/.agents/scripts/lib/changed-files.js +70 -6
  49. package/.agents/scripts/lib/child-exec.js +10 -0
  50. package/.agents/scripts/lib/claude/agents-projection.js +5 -5
  51. package/.agents/scripts/lib/close-lock-events.js +8 -3
  52. package/.agents/scripts/lib/close-validation/ci-deferral.js +40 -0
  53. package/.agents/scripts/lib/close-validation/gates.js +156 -32
  54. package/.agents/scripts/lib/close-validation/process.js +16 -7
  55. package/.agents/scripts/lib/close-validation/projections/crap.js +43 -10
  56. package/.agents/scripts/lib/close-validation/runner.js +160 -41
  57. package/.agents/scripts/lib/close-validation/skip-branch-test.js +144 -0
  58. package/.agents/scripts/lib/close-validation/test-delta.js +33 -8
  59. package/.agents/scripts/lib/codex/agents-projection.js +6 -0
  60. package/.agents/scripts/lib/config/agentrc-overlay.js +9 -5
  61. package/.agents/scripts/lib/config/explain.js +5 -2
  62. package/.agents/scripts/lib/config/gates/coverage.schema.js +53 -0
  63. package/.agents/scripts/lib/config/gates/crap-incremental-coverage.schema.js +1 -1
  64. package/.agents/scripts/lib/config/git-roots.js +38 -4
  65. package/.agents/scripts/lib/config/handoff.js +24 -0
  66. package/.agents/scripts/lib/config/quality.js +28 -12
  67. package/.agents/scripts/lib/config/worktree-isolation.js +2 -5
  68. package/.agents/scripts/lib/config-resolver.js +22 -2
  69. package/.agents/scripts/lib/config-settings-schema-delivery.js +87 -4
  70. package/.agents/scripts/lib/config-settings-schema-quality.js +36 -1
  71. package/.agents/scripts/lib/config-settings-schema.js +1 -1
  72. package/.agents/scripts/lib/coverage-capture-affected.js +1 -0
  73. package/.agents/scripts/lib/coverage-capture-delta.js +164 -32
  74. package/.agents/scripts/lib/coverage-capture-own-fix.js +232 -0
  75. package/.agents/scripts/lib/coverage-capture-usage.js +2 -2
  76. package/.agents/scripts/lib/coverage-capture.js +31 -0
  77. package/.agents/scripts/lib/coverage-deferral.js +96 -0
  78. package/.agents/scripts/lib/coverage-ratchet.js +187 -0
  79. package/.agents/scripts/lib/crap-baseline-join.js +5 -5
  80. package/.agents/scripts/lib/crap-engine.js +3 -3
  81. package/.agents/scripts/lib/crap-method-identity.js +104 -48
  82. package/.agents/scripts/lib/escomplex-anchor.js +135 -0
  83. package/.agents/scripts/lib/escomplex-kernel.js +30 -1
  84. package/.agents/scripts/lib/failure-rows.js +121 -0
  85. package/.agents/scripts/lib/full-suite-lock.js +44 -4
  86. package/.agents/scripts/lib/full-suite-queue.js +89 -13
  87. package/.agents/scripts/lib/generated/agentrc-validator.js +8 -2
  88. package/.agents/scripts/lib/gh-env.js +3 -6
  89. package/.agents/scripts/lib/gh-pr-rest.js +1 -0
  90. package/.agents/scripts/lib/git/base-sync-probe.js +182 -0
  91. package/.agents/scripts/lib/git-branch-lifecycle.js +9 -0
  92. package/.agents/scripts/lib/observability/close-telemetry.js +37 -2
  93. package/.agents/scripts/lib/observability/handoff-telemetry.js +170 -0
  94. package/.agents/scripts/lib/observability/review-dispositions.js +23 -6
  95. package/.agents/scripts/lib/observability/runtime-friction.js +17 -4
  96. package/.agents/scripts/lib/observability/source-classifier.js +3 -0
  97. package/.agents/scripts/lib/observability/story-outcome.js +393 -0
  98. package/.agents/scripts/lib/orchestration/check-baselines/phases/compare.js +2 -1
  99. package/.agents/scripts/lib/orchestration/check-baselines/phases/evaluate.js +19 -1
  100. package/.agents/scripts/lib/orchestration/check-baselines/phases/fail-detail.js +84 -0
  101. package/.agents/scripts/lib/orchestration/check-baselines/phases/pipeline.js +14 -5
  102. package/.agents/scripts/lib/orchestration/check-baselines/phases/refresh-ack.js +3 -2
  103. package/.agents/scripts/lib/orchestration/check-baselines/phases/report.js +26 -6
  104. package/.agents/scripts/lib/orchestration/ci-rerun-guard.js +124 -23
  105. package/.agents/scripts/lib/orchestration/code-review.js +223 -19
  106. package/.agents/scripts/lib/orchestration/handoff-gates.js +217 -44
  107. package/.agents/scripts/lib/orchestration/handoff-rescore.js +169 -0
  108. package/.agents/scripts/lib/orchestration/handoff-suite-of-record.js +45 -0
  109. package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +5 -1
  110. package/.agents/scripts/lib/orchestration/plan-persist/source-rewrite.js +76 -4
  111. package/.agents/scripts/lib/orchestration/plan-persist/story-ops.js +2 -2
  112. package/.agents/scripts/lib/orchestration/preflight-lanes.js +208 -0
  113. package/.agents/scripts/lib/orchestration/review-base-ref.js +40 -17
  114. package/.agents/scripts/lib/orchestration/review-deposit.js +38 -12
  115. package/.agents/scripts/lib/orchestration/review-depth.js +21 -0
  116. package/.agents/scripts/lib/orchestration/review-history.js +124 -20
  117. package/.agents/scripts/lib/orchestration/review-providers/claude-verdict.js +23 -8
  118. package/.agents/scripts/lib/orchestration/review-providers/code-review.js +82 -39
  119. package/.agents/scripts/lib/orchestration/review-providers/critical-verifier.js +64 -11
  120. package/.agents/scripts/lib/orchestration/review-providers/degraded-gates.js +98 -3
  121. package/.agents/scripts/lib/orchestration/review-providers/finding-identity.js +6 -2
  122. package/.agents/scripts/lib/orchestration/review-providers/findings-renderer.js +55 -8
  123. package/.agents/scripts/lib/orchestration/review-providers/review-guidance.js +1 -0
  124. package/.agents/scripts/lib/orchestration/review-providers/review-provider-factory.js +42 -15
  125. package/.agents/scripts/lib/orchestration/review-providers/types.js +6 -0
  126. package/.agents/scripts/lib/orchestration/single-story-close/failed-terminal.js +10 -1
  127. package/.agents/scripts/lib/orchestration/single-story-close/gate-log.js +10 -0
  128. package/.agents/scripts/lib/orchestration/single-story-close/phases/base-sync.js +7 -4
  129. package/.agents/scripts/lib/orchestration/single-story-close/phases/close-validation.js +17 -2
  130. package/.agents/scripts/lib/orchestration/single-story-close/phases/code-review.js +59 -2
  131. package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +13 -1
  132. package/.agents/scripts/lib/orchestration/single-story-close/phases/finish.js +15 -4
  133. package/.agents/scripts/lib/orchestration/single-story-close/phases/land-review-record.js +213 -0
  134. package/.agents/scripts/lib/orchestration/single-story-close/phases/normalize-pr-title.js +17 -2
  135. package/.agents/scripts/lib/orchestration/single-story-close/phases/open-pr.js +42 -20
  136. package/.agents/scripts/lib/orchestration/single-story-close/phases/post-land.js +51 -26
  137. package/.agents/scripts/lib/orchestration/single-story-close/phases/pre-push.js +3 -1
  138. package/.agents/scripts/lib/orchestration/single-story-close/phases/pull-request.js +51 -15
  139. package/.agents/scripts/lib/orchestration/single-story-close/phases/push.js +59 -11
  140. package/.agents/scripts/lib/orchestration/single-story-close/phases/reconcile-done.js +1 -0
  141. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-block.js +31 -13
  142. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-halt.js +29 -6
  143. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-outcome.js +10 -12
  144. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-override.js +19 -4
  145. package/.agents/scripts/lib/orchestration/single-story-close/result.js +43 -13
  146. package/.agents/scripts/lib/orchestration/single-story-close/review-overlap.js +73 -39
  147. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +11 -2
  148. package/.agents/scripts/lib/orchestration/story-close/baseline-upward-writeback.js +3 -2
  149. package/.agents/scripts/lib/orchestration/story-close/duplication-close-rescore.js +20 -8
  150. package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +7 -0
  151. package/.agents/scripts/lib/orchestration/story-handoff.js +789 -196
  152. package/.agents/scripts/lib/orchestration/ticketing/reads.js +2 -0
  153. package/.agents/scripts/lib/pr-body-lines.js +32 -0
  154. package/.agents/scripts/lib/single-story/ci-ratchet-gate.js +140 -0
  155. package/.agents/scripts/lib/single-story/confirm-and-land.js +17 -7
  156. package/.agents/scripts/lib/single-story/confirm-merge.js +12 -3
  157. package/.agents/scripts/lib/single-story-sweep/report-stalled-executing.js +202 -0
  158. package/.agents/scripts/lib/standalone-ratchets.js +37 -0
  159. package/.agents/scripts/lib/suite-admission.js +20 -8
  160. package/.agents/scripts/lib/suite-sizing.js +146 -0
  161. package/.agents/scripts/lib/workspace-provisioner.js +2 -2
  162. package/.agents/scripts/merge-baseline.js +14 -3
  163. package/.agents/scripts/providers/github/comments.js +19 -3
  164. package/.agents/scripts/providers/github.js +1 -0
  165. package/.agents/scripts/review-dispositions-report.js +1 -1
  166. package/.agents/scripts/role-scope-guard.js +267 -0
  167. package/.agents/scripts/single-story-close.js +4 -4
  168. package/.agents/scripts/single-story-confirm-merge.js +31 -5
  169. package/.agents/scripts/single-story-init.js +24 -4
  170. package/.agents/scripts/story-handoff.js +3 -3
  171. package/.agents/scripts/story-outcomes-report.js +231 -0
  172. package/.agents/scripts/story-review-compute.js +9 -5
  173. package/.agents/scripts/update-coverage-baseline.js +12 -2
  174. package/.agents/scripts/update-crap-baseline.js +9 -1
  175. package/.agents/workflows/audit-state-machines.md +213 -0
  176. package/.agents/workflows/helpers/code-review.md +63 -9
  177. package/.agents/workflows/helpers/deliver-digest.md +53 -54
  178. package/.agents/workflows/helpers/deliver-reference.md +236 -63
  179. package/.agents/workflows/helpers/deliver-story-reference.md +19 -8
  180. package/.agents/workflows/helpers/deliver-story.md +7 -2
  181. package/.agents/workflows/helpers/parallel-tooling.md +29 -0
  182. package/.agents/workflows/helpers/plan-reference.md +10 -2
  183. package/docs/CHANGELOG.md +56 -0
  184. package/lib/cli/doctor-checks/coverage-ratchet.js +54 -0
  185. package/lib/cli/doctor-checks/effective-agentrc.js +23 -0
  186. package/lib/cli/doctor-checks/llm-review.js +2 -11
  187. package/lib/cli/doctor-checks/sync-parity.js +5 -1
  188. package/lib/cli/doctor-checks/test-credit-path.js +7 -2
  189. package/lib/cli/registry.js +5 -0
  190. package/package.json +1 -1
@@ -68,6 +68,7 @@ the two options above. Name the verdict you reached in the `friction` comment.
68
68
  | **pre-existing** | The same check fails on an unmodified `main` too | Option 2 — `file-ci-gap.js --verdict pre-existing`; remediate here only if it blocks this delivery |
69
69
  | **capacity** | Proven exhaustion of a runner resource, not a property of the diff (see below) | Option 2 — `file-ci-gap.js --verdict capacity` (`meta::framework-gap` unless `--owner` routes it elsewhere) **and** escalate to the operator |
70
70
  | **unreproducible-tier** | The tier cannot be exercised in this sandbox at all, proven by an attempted attach (see below) | Option 2 — `file-ci-gap.js --verdict unreproducible-tier` (`meta::framework-gap` unless `--owner` routes it elsewhere) **and** escalate on first encounter |
71
+ | **governance-label** | The red was a governance check awaiting an operator-approved label; adding it started a fresh run on the same head, which passed | Recovery, not a gap — `file-ci-gap.js --verdict governance-label --label <name>` (§ Governance-label recovery); files nothing |
71
72
 
72
73
  Why the verdict set carries these last two is recorded in
73
74
  [`docs/decisions.md` ADR 20260906-5160a](../../docs/decisions.md).
@@ -158,11 +159,31 @@ it names a real defect someone owns and a rerun cannot remove it. Skipping,
158
159
  quarantining or loosening a test to reach green stays forbidden under every
159
160
  verdict, always.
160
161
 
162
+ ### Governance-label recovery
163
+
164
+ Some checks are designed to stay red until an authorized person approves a
165
+ governance label, such as `migration:destructive-ok`. Adding the label starts a
166
+ **fresh** workflow run on the same head SHA. That run gets a new run ID; it is
167
+ not a rerun of the failed job. Its green is still on the red head, so the
168
+ guard reads it as a forbidden rerun. Record the audited recovery instead:
169
+
170
+ ```bash
171
+ node .agents/scripts/file-ci-gap.js --story <id> --verdict governance-label --label <name>
172
+ ```
173
+
174
+ It reads the PR's issue events and refuses (non-zero exit, nothing written)
175
+ unless the label is still on the PR **and** a `labeled` event for it is newer
176
+ than the red. On proof it stamps the one-green allowance on the digest. It
177
+ then posts a `friction` comment recording the label, who added it, when, and
178
+ the red and green run links. It files **no** intake issue and applies no
179
+ `friction::*` label: the CI did what it was built to do. Nothing is faked and
180
+ no check is loosened. Resume the watch; the same-SHA green is admitted once.
181
+
161
182
  ## Verifier
162
183
 
163
184
  The check is resolved only when it is **green with no rerun of the failed job**
164
- — save the one a recorded `capacity` / `unreproducible-tier` verdict buys (§
165
- above) — and the diff carries **no `.skip` / `.only`, no quarantine, and no
185
+ — save the one a recorded `capacity` / `unreproducible-tier` verdict buys,
186
+ or the fresh run a recorded `governance-label` recovery admits (§§ above) — and the diff carries **no `.skip` / `.only`, no quarantine, and no
166
187
  deleted or loosened assertion** introduced to reach green. You may **not**
167
188
  re-run a failed job to "see if it goes green," and you may **not** skip,
168
189
  `.only`, or quarantine a flaky test to get a green bar. Both mask the defect
@@ -174,7 +195,8 @@ on the **first red** — GitHub's native auto-merge fires server-side, so it
174
195
  races any attempt to detect a rerun-green and block it after the fact. On the
175
196
  first red the watcher **disarms native auto-merge** (a disarm failure is a
176
197
  blocker, not a warning) and records the PR **head SHA** in the digest
177
- alongside the failing check-run identity. On green it adjudicates:
198
+ alongside the failing check-run identity: the **failed** run of that
199
+ check, never a same-name green run from another workflow run on the head. On green it adjudicates:
178
200
 
179
201
  - **Same head SHA, with a recorded allowance** → the one rerun the section
180
202
  above buys. The digest is retired (spending the allowance), auto-merge is
@@ -183,7 +205,9 @@ alongside the failing check-run identity. On green it adjudicates:
183
205
  job. The watcher exits non-zero, flips the Story to `agent::blocked` with a
184
206
  `friction` comment, and requires the CI-gap intake issue
185
207
  (`file-ci-gap.js` — run link and failure signature are already in the
186
- digest) before the delivery proceeds.
208
+ digest) before the delivery proceeds. When the green came from a fresh run
209
+ an operator-approved label started, record `--verdict governance-label`
210
+ instead (§ Governance-label recovery).
187
211
  - **New head SHA** → fix at source. The digest is retired, auto-merge is
188
212
  re-armed, and the delivery continues unobstructed.
189
213
  - **Same head SHA, every recorded failure advisory, each now green**
@@ -114,6 +114,13 @@ owned by `boot-sweep.js` / `clean-git.js`:
114
114
  ancestry of its own) is **never** reaped by the boot sweep; it is surfaced
115
115
  under `contentMerged` for the operator to send to `/clean-git` for a
116
116
  confirmed, eyeballed reap.
117
+ - **Stalled deliveries are reported, never touched.** The same boot sweep
118
+ (`boot-sweep.js` and `single-story-init.js`) automatically lists every open
119
+ `agent::executing` Story whose `story-<id>` origin head has not moved (no
120
+ commit and no push) for 6 hours (`--stalled-after-hours <n>`) and that has no open PR — a session
121
+ that died silently. It reads origin over the REST API, writes nothing, and
122
+ is advisory: each row names `deliver-recover.js --story <id>`, which owns
123
+ the verdict.
117
124
  - **`/clean-git` is recovery, not routine.** Run it by hand only for a state
118
125
  the automated hygiene does not cover — triaging stashes, reaping across
119
126
  non-standard namespaces, or `--remote` pruning after a force-push. Reaching
@@ -91,7 +91,7 @@
91
91
  "type": "string",
92
92
  "pattern": "([;&|`]|\\$\\()"
93
93
  },
94
- "description": "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."
94
+ "description": "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."
95
95
  },
96
96
  "typecheck": {
97
97
  "type": ["string", "null"],
@@ -416,11 +416,11 @@
416
416
  "capacity": {
417
417
  "type": "integer",
418
418
  "minimum": 1,
419
- "description": "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."
419
+ "description": "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."
420
420
  },
421
421
  "workloads": {
422
422
  "type": "array",
423
- "description": "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.",
423
+ "description": "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.",
424
424
  "items": {
425
425
  "type": "object",
426
426
  "required": ["command", "weight"],
@@ -446,11 +446,54 @@
446
446
  "pattern": "^[a-z0-9][a-z0-9-]*$"
447
447
  },
448
448
  "description": "Names of shared resources this run needs exclusively."
449
+ },
450
+ "tiers": {
451
+ "type": "array",
452
+ "minItems": 1,
453
+ "items": {
454
+ "type": "object",
455
+ "required": ["maxFiles", "weight"],
456
+ "properties": {
457
+ "maxFiles": {
458
+ "type": "integer",
459
+ "minimum": 0
460
+ },
461
+ "weight": {
462
+ "type": "integer",
463
+ "minimum": 1
464
+ }
465
+ },
466
+ "additionalProperties": false
467
+ },
468
+ "description": "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`."
469
+ },
470
+ "sizeCommand": {
471
+ "type": "string",
472
+ "not": {
473
+ "pattern": "([;&|`]|\\$\\()"
474
+ },
475
+ "minLength": 1,
476
+ "description": "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`."
477
+ },
478
+ "backfill": {
479
+ "type": "boolean",
480
+ "default": false,
481
+ "description": "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."
449
482
  }
450
483
  },
484
+ "dependencies": {
485
+ "tiers": ["sizeCommand"],
486
+ "sizeCommand": ["tiers"]
487
+ },
451
488
  "additionalProperties": false
452
489
  },
453
490
  "default": []
491
+ },
492
+ "preflightConcurrency": {
493
+ "type": "integer",
494
+ "minimum": 1,
495
+ "default": 1,
496
+ "description": "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."
454
497
  }
455
498
  },
456
499
  "additionalProperties": false
@@ -580,13 +623,8 @@
580
623
  "type": "string",
581
624
  "minLength": 1
582
625
  },
583
- "description": "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.",
584
- "default": [
585
- ".env",
586
- ".mcp.json",
587
- ".agentrc.local.json",
588
- ".agents/instructions.local.md"
589
- ]
626
+ "description": "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.",
627
+ "default": [".env", ".mcp.json", ".agents/instructions.local.md"]
590
628
  }
591
629
  },
592
630
  "additionalProperties": false,
@@ -710,6 +748,48 @@
710
748
  "maximum": 7200000,
711
749
  "description": "Kill bound (ms) for one full-suite run — the coverage capture, the close-validation full-suite gate and the full-suite lock-wait budget all read it. The clock starts at spawn, never while queued on the host lock; a suite that signals `MANDREL_SUITE_READY_FILE` gets a fresh bound for its test phase, so worst-case wall is lock wait + 2 × timeoutMs. On expiry the run exits 124 so callers can tell a hang from a failure.",
712
750
  "default": 600000
751
+ },
752
+ "onOverBudget": {
753
+ "type": "string",
754
+ "enum": ["block", "defer-to-ci"],
755
+ "description": "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.",
756
+ "default": "block"
757
+ },
758
+ "suiteOfRecord": {
759
+ "type": "string",
760
+ "enum": ["local", "ci"],
761
+ "description": "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.",
762
+ "default": "local"
763
+ },
764
+ "ciRatchetCheck": {
765
+ "type": ["string", "null"],
766
+ "minLength": 1,
767
+ "description": "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`.",
768
+ "default": null
769
+ },
770
+ "nonInputGlobs": {
771
+ "type": "array",
772
+ "items": {
773
+ "type": "string",
774
+ "not": {
775
+ "pattern": "([;&|`]|\\$\\()"
776
+ },
777
+ "minLength": 1
778
+ },
779
+ "description": "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.",
780
+ "default": []
781
+ },
782
+ "captureHandlesConfigChanges": {
783
+ "type": "boolean",
784
+ "description": "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`.",
785
+ "default": false
786
+ },
787
+ "ownFixDeltaMaxFiles": {
788
+ "type": "integer",
789
+ "minimum": 0,
790
+ "maximum": 50,
791
+ "description": "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.",
792
+ "default": 0
713
793
  }
714
794
  },
715
795
  "additionalProperties": false
@@ -855,7 +935,7 @@
855
935
  "baseRef": {
856
936
  "type": "string",
857
937
  "minLength": 1,
858
- "description": "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."
938
+ "description": "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."
859
939
  }
860
940
  },
861
941
  "additionalProperties": false
@@ -1282,6 +1362,28 @@
1282
1362
  },
1283
1363
  "additionalProperties": false
1284
1364
  },
1365
+ "ratchets": {
1366
+ "type": "object",
1367
+ "description": "CI's standalone ratchets as the handoff preflight runs them.",
1368
+ "properties": {
1369
+ "coveredByLint": {
1370
+ "type": "array",
1371
+ "uniqueItems": true,
1372
+ "items": {
1373
+ "type": "string",
1374
+ "enum": [
1375
+ "dead-exports",
1376
+ "dead-exports-production",
1377
+ "arch-cycles",
1378
+ "cyclomatic"
1379
+ ]
1380
+ },
1381
+ "default": [],
1382
+ "description": "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."
1383
+ }
1384
+ },
1385
+ "additionalProperties": false
1386
+ },
1285
1387
  "requireBaselines": {
1286
1388
  "type": "boolean",
1287
1389
  "description": "Story #4495. Fail-closed baseline-enforcement policy for the unified check-baselines close-validation gate. When false (default), a consumer that enables baseline gates (crap/maintainability/…) but has not committed the corresponding baseline artifacts under baselines/ gets a clean skip-with-reason instead of a deterministic first-try close failure. Set true to keep the gate registered so an absent baseline artifact fails close-validation with a preflight hint naming the fix (the fail-closed posture).",
@@ -1313,6 +1415,19 @@
1313
1415
  },
1314
1416
  "additionalProperties": false
1315
1417
  },
1418
+ "close": {
1419
+ "type": "object",
1420
+ "description": "Close-time posture (Story #5954). `baseSync` decides whether close and a handoff re-run merge `origin/<baseBranch>` before validating.",
1421
+ "properties": {
1422
+ "baseSync": {
1423
+ "type": "string",
1424
+ "enum": ["always", "on-conflict"],
1425
+ "description": "`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.",
1426
+ "default": "always"
1427
+ }
1428
+ },
1429
+ "additionalProperties": false
1430
+ },
1316
1431
  "codeReview": {
1317
1432
  "type": "object",
1318
1433
  "description": "Review-provider chain and on-branch remediation threshold for the /mandrel-deliver code-review ceremony.",
@@ -1377,7 +1492,7 @@
1377
1492
  },
1378
1493
  "additionalProperties": false
1379
1494
  },
1380
- "description": "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.",
1495
+ "description": "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.",
1381
1496
  "default": [
1382
1497
  {
1383
1498
  "name": "native"
@@ -1420,11 +1535,28 @@
1420
1535
  "additionalProperties": false
1421
1536
  }
1422
1537
  },
1538
+ "effortByDepth": {
1539
+ "type": "object",
1540
+ "description": "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`.",
1541
+ "propertyNames": {
1542
+ "enum": ["light", "standard", "deep"]
1543
+ },
1544
+ "additionalProperties": {
1545
+ "type": "string",
1546
+ "enum": ["low", "medium", "high", "xhigh", "max"]
1547
+ }
1548
+ },
1423
1549
  "guidanceFile": {
1424
1550
  "type": "string",
1425
1551
  "minLength": 1,
1426
1552
  "description": "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."
1427
1553
  },
1554
+ "onNoVerdict": {
1555
+ "type": "string",
1556
+ "enum": ["report", "block"],
1557
+ "default": "report",
1558
+ "description": "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."
1559
+ },
1428
1560
  "skipPaths": {
1429
1561
  "type": "array",
1430
1562
  "items": {
@@ -1463,12 +1595,17 @@
1463
1595
  },
1464
1596
  "feedbackLoop": {
1465
1597
  "type": "object",
1466
- "description": "Opt-in toggle for the close-time retro auto-file graduator. Auto-filing defaults to OFF (Story #5341).",
1598
+ "description": "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).",
1467
1599
  "properties": {
1468
1600
  "retroProposals": {
1469
1601
  "type": "boolean",
1470
1602
  "description": "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.",
1471
1603
  "default": false
1604
+ },
1605
+ "outcomeRecord": {
1606
+ "type": "boolean",
1607
+ "description": "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.",
1608
+ "default": false
1472
1609
  }
1473
1610
  },
1474
1611
  "additionalProperties": false
@@ -1522,6 +1659,35 @@
1522
1659
  },
1523
1660
  "additionalProperties": false
1524
1661
  },
1662
+ "handoff": {
1663
+ "type": "object",
1664
+ "description": "Story #5960. What `story-handoff.js` runs beyond close's own gates.",
1665
+ "properties": {
1666
+ "postSeatChecks": {
1667
+ "type": "array",
1668
+ "items": {
1669
+ "type": "object",
1670
+ "properties": {
1671
+ "cmd": {
1672
+ "type": "string",
1673
+ "minLength": 1
1674
+ },
1675
+ "args": {
1676
+ "type": "array",
1677
+ "items": {
1678
+ "type": "string"
1679
+ }
1680
+ }
1681
+ },
1682
+ "required": ["cmd"],
1683
+ "additionalProperties": false
1684
+ },
1685
+ "description": "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.",
1686
+ "default": []
1687
+ }
1688
+ },
1689
+ "additionalProperties": false
1690
+ },
1525
1691
  "routing": {
1526
1692
  "type": "object",
1527
1693
  "description": "v2 delivery-spawn routing: role-scoped boot contexts and the ceremony profile. The v1 singleDelivery epic-route kill-switch was removed in Stage 6; the freshCriticSampleRate sampling floor was retired in Story #5313 and the derived-level ceremony routing in Story #5343.",
@@ -288,6 +288,34 @@
288
288
  "scope": "cumulative",
289
289
  "substitutionKeys": []
290
290
  },
291
+ "audit-state-machines": {
292
+ "triggers": {
293
+ "gates": ["gate1", "gate3"],
294
+ "keywords": [
295
+ "state machine",
296
+ "state transition",
297
+ "lifecycle",
298
+ "impossible state",
299
+ "illegal state",
300
+ "discriminated union",
301
+ "tagged union",
302
+ "exhaustive",
303
+ "isLoading"
304
+ ],
305
+ "filePatterns": [
306
+ "**/*.{js,mjs,cjs,jsx,ts,tsx}",
307
+ "**/*.py",
308
+ "**/*.go",
309
+ "**/*.rs",
310
+ "**/*.java",
311
+ "**/*.kt",
312
+ "**/*.swift",
313
+ "**/*.rb"
314
+ ]
315
+ },
316
+ "scope": "cumulative",
317
+ "substitutionKeys": []
318
+ },
291
319
  "audit-documentation": {
292
320
  "triggers": {
293
321
  "gates": ["gate1", "gate3"],
@@ -4,7 +4,7 @@
4
4
  "title": "BaselineEnvelope",
5
5
  "description": "Shared envelope contract for every committed Mandrel baseline (lint, coverage, crap, maintainability, mutation, lighthouse, bundle-size). Each per-kind schema extends this envelope via allOf to constrain the row shape. The committed file carries no run timestamp and no rollup: both were rewritten on every refresh, so two branches refreshing disjoint rows always conflicted textually — and GitHub (PR mergeability, update-branch, the merge queue) never runs the custom merge driver. Readers derive the rollup from rows[]; freshness is the file's git history. The envelope itself is intentionally agnostic about row contents so the kernel can evolve without churning the shared contract.",
6
6
  "type": "object",
7
- "required": ["$schema", "kernelVersion", "rows"],
7
+ "required": ["$schema", "kernelVersion"],
8
8
  "additionalProperties": false,
9
9
  "properties": {
10
10
  "$schema": {
@@ -26,14 +26,26 @@
26
26
  },
27
27
  "provenanceStamped": {
28
28
  "type": "boolean",
29
- "description": "Optional per-kind POSITIVE assertion that the writer which produced these rows recorded each row's coordinate provenance (Story #4901). Only meaningful for kinds whose rows carry a line coordinate that may be transpiled. Absence is the only evidence a baseline written before provenance existed leaves behind — such a baseline claims by omission that every row is an original-source coordinate — so the kind's compat axis fails it closed with re-seed guidance rather than letting the comparator key rows against a coordinate space they are not in."
29
+ "description": "Legacy per-kind stamp, no longer written: the CRAP writer once used it to assert that each row's coordinate provenance was recorded. It stays accepted so a baseline written before the grouped CRAP layout parses and reaches the kind's scoring-semantics compat axis, which fails it closed with the re-seed command, instead of dying on a raw schema error."
30
30
  },
31
31
  "rows": {
32
32
  "type": "array",
33
- "description": "Per-row metrics. Order is kind-specific (e.g. CRAP sorts by file+startLine+method); per-kind schemas tighten the item shape.",
33
+ "description": "Per-row metrics. Order is kind-specific (e.g. CRAP sorts by path then method key); per-kind schemas tighten the item shape. Exactly one of rows and files is present.",
34
34
  "items": {
35
35
  "type": "object"
36
36
  }
37
+ },
38
+ "files": {
39
+ "type": "object",
40
+ "description": "Grouped on-disk row layout for kinds whose codec writes one (CRAP): each canonical path once, mapped to its per-row values. Exactly one of rows and files is present; readers decode it back to rows through the kind's layout codec."
41
+ }
42
+ },
43
+ "oneOf": [
44
+ {
45
+ "required": ["rows"]
46
+ },
47
+ {
48
+ "required": ["files"]
37
49
  }
38
- }
50
+ ]
39
51
  }
@@ -4,6 +4,7 @@
4
4
  "title": "BundleSizeBaseline",
5
5
  "description": "Per-kind baseline schema for the bundle-size gate. Extends the shared baseline-envelope contract.",
6
6
  "allOf": [{ "$ref": "baseline-envelope.schema.json" }],
7
+ "required": ["rows"],
7
8
  "type": "object",
8
9
  "properties": {
9
10
  "rows": {
@@ -4,6 +4,7 @@
4
4
  "title": "CoverageBaseline",
5
5
  "description": "Per-kind baseline schema for the coverage gate. Extends the shared baseline-envelope contract.",
6
6
  "allOf": [{ "$ref": "baseline-envelope.schema.json" }],
7
+ "required": ["rows"],
7
8
  "type": "object",
8
9
  "properties": {
9
10
  "rows": {
@@ -2,8 +2,12 @@
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "$id": "https://mandrel/.agents/schemas/baselines/crap.schema.json",
4
4
  "title": "CrapBaselineV2",
5
- "description": "Per-kind baseline schema for the CRAP gate, envelope-shaped. Extends the shared baseline-envelope contract. Distinct from the legacy crap-baseline.schema.json which used a flat shape.",
6
- "allOf": [{ "$ref": "baseline-envelope.schema.json" }],
5
+ "description": "Per-kind baseline schema for the CRAP gate, envelope-shaped. Extends the shared baseline-envelope contract. On disk the rows are grouped under `files` (each path once, each method key on its own line); the previous `rows[]` layout still validates so it reaches the scoring-semantics compat axis, which refuses it with the full-scope re-seed command. Distinct from the legacy crap-baseline.schema.json which used a flat shape.",
6
+ "allOf": [
7
+ {
8
+ "$ref": "baseline-envelope.schema.json"
9
+ }
10
+ ],
7
11
  "type": "object",
8
12
  "properties": {
9
13
  "scoringSemantics": {
@@ -12,28 +16,51 @@
12
16
  },
13
17
  "provenanceStamped": {
14
18
  "type": "boolean",
15
- "description": "Positive assertion that the writer which produced these rows recorded coordinate provenance per row (Story #4901). Absence is the ONLY evidence a pre-Story-#4866 baseline leaves — such a baseline claims by omission that every row is an original-source coordinate while some are transpiled. Deliberately optional and unconstrained here for the same reason as scoringSemantics: an unstamped baseline must reach the `provenance-unstamped` compat axis, which fails it closed with the re-seed command when it also carries transpiled-source rows, rather than dying on a raw schema error. A pure-JavaScript baseline never needs it."
19
+ "description": "Legacy stamp, no longer written (the persisted row carries no line coordinate to qualify). Accepted only so a baseline from before the grouped layout reaches the scoring-semantics compat axis rather than a raw schema error."
16
20
  },
17
21
  "rows": {
18
22
  "type": "array",
19
23
  "items": {
20
24
  "type": "object",
21
- "required": ["path", "method", "startLine", "crap"],
25
+ "required": ["path", "method", "crap"],
22
26
  "additionalProperties": false,
23
27
  "properties": {
24
- "path": { "type": "string" },
25
- "method": { "type": "string" },
26
- "startLine": { "type": "integer", "minimum": 1 },
27
- "crap": { "type": "number", "minimum": 0 },
28
+ "path": {
29
+ "type": "string"
30
+ },
31
+ "method": {
32
+ "type": "string"
33
+ },
34
+ "startLine": {
35
+ "type": "integer",
36
+ "minimum": 1,
37
+ "description": "Previous rows[] layout only. The persisted CRAP identity is path::method; startLine lives on scan rows in memory."
38
+ },
39
+ "crap": {
40
+ "type": "number",
41
+ "minimum": 0
42
+ },
28
43
  "anonymous": {
29
44
  "enum": [true],
30
- "description": "Marks `method` as a DERIVED identity rather than a name the source carries (Story #4969). escomplex labels an unnamed function `<anon method-N>`, where N is a per-module counter, so inserting one anonymous function renumbers every later one and re-keys 34.6% of this baseline's rows; the derived identity is the method's enclosing-scope path plus its parameter list, which is invariant under edits elsewhere in the file. Written ONLY when true, mirroring `coordinateSystem`: a named row keeps the exact four-key shape it always had. Absence on a row whose `method` still looks anonymous is the signature of a half-migrated baseline — rows preserved verbatim by a diff-scoped refresh under an envelope stamped with the current semantics — which the `anon-identity-unstamped` compat axis fails closed."
45
+ "description": "Previous rows[] layout only; an anonymous key is recognisable by its `<anon ` prefix."
31
46
  },
32
47
  "coordinateSystem": {
33
48
  "enum": ["transpiled"],
34
- "description": "Coordinate provenance of startLine (Story #4866). Written ONLY when the row kept transpiled coordinates because its sourcemap lookup did not resolve — the absent-means-'original' default keeps a pure-JavaScript baseline byte-identical, since JavaScript coordinates already ARE original-source coordinates. A row carrying this key is not comparable to one without it: the compare refuses to resolve the two through its nearest-line drift heuristic rather than manufacturing a regression from the gap between two coordinate systems."
49
+ "description": "Previous rows[] layout only; it qualified startLine, which the persisted identity no longer carries."
35
50
  }
36
51
  }
52
+ },
53
+ "description": "In-memory row shape `{ path, method, crap }`, which writers validate before encoding; on disk only the previous layout carries rows[]."
54
+ },
55
+ "files": {
56
+ "type": "object",
57
+ "description": "The grouped on-disk layout: canonical path (sorted) to an object of `\"<method key>\": <crap>` entries (sorted by key). A method key is its scope path — enclosing method segments joined by `/`, ending in its own name — with `#<n>` on a later method that would repeat an earlier key in the same file; an anonymous key is wrapped as `<anon …>`. Identity is path::method; no line number is persisted.",
58
+ "additionalProperties": {
59
+ "type": "object",
60
+ "additionalProperties": {
61
+ "type": "number",
62
+ "minimum": 0
63
+ }
37
64
  }
38
65
  }
39
66
  }
@@ -4,6 +4,7 @@
4
4
  "title": "DuplicationBaselineV2",
5
5
  "description": "Per-kind baseline schema for the code-duplication (DRY) gate, envelope-shaped. Extends the shared baseline-envelope contract. Rows record per-file copy-paste duplication reported by a clone detector (jscpd); the rollup recomputes an exact aggregate ratio from raw line counts.",
6
6
  "allOf": [{ "$ref": "baseline-envelope.schema.json" }],
7
+ "required": ["rows"],
7
8
  "type": "object",
8
9
  "properties": {
9
10
  "rows": {
@@ -4,6 +4,7 @@
4
4
  "title": "MaintainabilityBaseline",
5
5
  "description": "Per-kind baseline schema for the Maintainability Index (MI) gate. Extends the shared baseline-envelope contract. Story #2193: the row axis stays `mi`; rollups expose `min` / `p50` / `p95` axes, and configured floors under `delivery.quality.gates.maintainability.floors[*]` target those rollup axes (the framework default is `{ min: 70 }`).",
6
6
  "allOf": [{ "$ref": "baseline-envelope.schema.json" }],
7
+ "required": ["rows"],
7
8
  "type": "object",
8
9
  "properties": {
9
10
  "rows": {
@@ -4,6 +4,7 @@
4
4
  "title": "MutationBaseline",
5
5
  "description": "Per-kind baseline schema for the mutation-testing gate. Extends the shared baseline-envelope contract.",
6
6
  "allOf": [{ "$ref": "baseline-envelope.schema.json" }],
7
+ "required": ["rows"],
7
8
  "type": "object",
8
9
  "properties": {
9
10
  "rows": {