mandrel 2.89.0 → 2.91.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 (175) hide show
  1. package/.agents/README.md +47 -7
  2. package/.agents/agents/story-worker.md +20 -0
  3. package/.agents/audit-checklists/lean.md +26 -0
  4. package/.agents/docs/agentrc-reference.json +5 -6
  5. package/.agents/docs/configuration.md +38 -30
  6. package/.agents/docs/workflows.md +7 -1
  7. package/.agents/instructions.md +3 -1
  8. package/.agents/runtime-deps.json +0 -2
  9. package/.agents/schemas/agentrc.schema.json +46 -45
  10. package/.agents/schemas/audit-rules.json +19 -0
  11. package/.agents/scripts/acceptance-eval.js +2 -6
  12. package/.agents/scripts/audit-exceptions.js +2 -4
  13. package/.agents/scripts/board-backfill.js +253 -0
  14. package/.agents/scripts/check-arch-cycles.js +1 -5
  15. package/.agents/scripts/check-context-budget.js +1 -5
  16. package/.agents/scripts/check-cyclomatic.js +1 -5
  17. package/.agents/scripts/check-dead-exports.js +23 -14
  18. package/.agents/scripts/check-doc-links.js +4 -4
  19. package/.agents/scripts/check-test-temp-hygiene.js +29 -33
  20. package/.agents/scripts/coverage-capture.js +14 -6
  21. package/.agents/scripts/diagnose-friction.js +8 -10
  22. package/.agents/scripts/generate-workflows-doc.js +5 -0
  23. package/.agents/scripts/lib/audit-exceptions/adapters/index.js +2 -0
  24. package/.agents/scripts/lib/audit-exceptions/adapters/inline-suppressions.js +36 -27
  25. package/.agents/scripts/lib/audit-exceptions/adapters/shortcut-markers.js +70 -0
  26. package/.agents/scripts/lib/audit-exceptions/adapters/source-scan.js +26 -0
  27. package/.agents/scripts/lib/audit-to-stories/audit-lenses.js +1 -0
  28. package/.agents/scripts/lib/baseline-schema-registry.js +3 -5
  29. package/.agents/scripts/lib/baselines/bundle-size-scorer.js +11 -28
  30. package/.agents/scripts/lib/baselines/components.js +5 -5
  31. package/.agents/scripts/lib/baselines/crap-preview-scan.js +4 -1
  32. package/.agents/scripts/lib/baselines/crap-updater-cli.js +6 -4
  33. package/.agents/scripts/lib/baselines/duplication-scanner.js +4 -10
  34. package/.agents/scripts/lib/baselines/kinds/crap.js +4 -2
  35. package/.agents/scripts/lib/baselines/kinds/duplication.js +4 -2
  36. package/.agents/scripts/lib/baselines/kinds/kind-factory.js +13 -6
  37. package/.agents/scripts/lib/baselines/refresh-service.js +10 -13
  38. package/.agents/scripts/lib/baselines/writer.js +4 -4
  39. package/.agents/scripts/lib/bdd-scenario-scanner.js +26 -31
  40. package/.agents/scripts/lib/bootstrap/gh-list.js +4 -5
  41. package/.agents/scripts/lib/bootstrap/gh-preflight.js +13 -8
  42. package/.agents/scripts/lib/child-exec.js +4 -4
  43. package/.agents/scripts/lib/claude/agents-projection.js +170 -0
  44. package/.agents/scripts/lib/claude/commands-projection.js +184 -0
  45. package/.agents/scripts/lib/close-validation/commands.js +28 -117
  46. package/.agents/scripts/lib/close-validation/gates.js +54 -48
  47. package/.agents/scripts/lib/close-validation/process.js +5 -1
  48. package/.agents/scripts/lib/close-validation/projections/crap.js +2 -1
  49. package/.agents/scripts/lib/close-validation/projections/maintainability.js +50 -15
  50. package/.agents/scripts/lib/config/agentrc-overlay.js +4 -7
  51. package/.agents/scripts/lib/config/commands.js +82 -7
  52. package/.agents/scripts/lib/config/explain.js +2 -1
  53. package/.agents/scripts/lib/config/gates/coverage.schema.js +39 -3
  54. package/.agents/scripts/lib/config/gates/crap-incremental-coverage.schema.js +1 -1
  55. package/.agents/scripts/lib/config/gates/crap.schema.js +5 -3
  56. package/.agents/scripts/lib/config/gates/duplication.schema.js +6 -11
  57. package/.agents/scripts/lib/config/gates/shared.js +2 -2
  58. package/.agents/scripts/lib/config/git-roots.js +120 -0
  59. package/.agents/scripts/lib/config/quality.js +46 -50
  60. package/.agents/scripts/lib/config/review-chain-default.js +4 -3
  61. package/.agents/scripts/lib/config/review-provider-clis.js +11 -0
  62. package/.agents/scripts/lib/config/temp-paths.js +3 -37
  63. package/.agents/scripts/lib/config-resolver.js +5 -9
  64. package/.agents/scripts/lib/config-settings-schema-delivery.js +2 -2
  65. package/.agents/scripts/lib/config-settings-schema-quality.js +3 -2
  66. package/.agents/scripts/lib/config-settings-schema.js +6 -7
  67. package/.agents/scripts/lib/coverage-baseline.js +2 -1
  68. package/.agents/scripts/lib/coverage-capture-affected.js +4 -3
  69. package/.agents/scripts/lib/coverage-capture-fullscope.js +3 -1
  70. package/.agents/scripts/lib/coverage-capture-passes.js +119 -34
  71. package/.agents/scripts/lib/coverage-capture-usage.js +1 -1
  72. package/.agents/scripts/lib/coverage-capture.js +80 -43
  73. package/.agents/scripts/lib/coverage-utils.js +34 -16
  74. package/.agents/scripts/lib/cpu-pool.js +2 -4
  75. package/.agents/scripts/lib/crap-engine.js +19 -1
  76. package/.agents/scripts/lib/crap-utils.js +2 -1
  77. package/.agents/scripts/lib/dead-exports-knip.js +29 -11
  78. package/.agents/scripts/lib/detect-package-manager.js +13 -0
  79. package/.agents/scripts/lib/feedback-loop/graduator-gh.js +4 -2
  80. package/.agents/scripts/lib/full-suite-lock.js +25 -9
  81. package/.agents/scripts/lib/gates/baseline-store.js +2 -10
  82. package/.agents/scripts/lib/generated/agentrc-validator.js +4 -1
  83. package/.agents/scripts/lib/gh-env.js +72 -0
  84. package/.agents/scripts/lib/gh-exec.js +26 -1
  85. package/.agents/scripts/lib/maintainability-utils.js +8 -8
  86. package/.agents/scripts/lib/npm-scripts.js +1 -1
  87. package/.agents/scripts/lib/observability/signal-validator.js +2 -6
  88. package/.agents/scripts/lib/observability/source-classifier.js +1 -0
  89. package/.agents/scripts/lib/observability/terse-result.js +2 -6
  90. package/.agents/scripts/lib/orchestration/board-access-latch.js +112 -0
  91. package/.agents/scripts/lib/orchestration/ci-rerun-guard.js +10 -13
  92. package/.agents/scripts/lib/orchestration/column-sync.js +107 -52
  93. package/.agents/scripts/lib/orchestration/deliver-recover.js +2 -1
  94. package/.agents/scripts/lib/orchestration/git-cleanup/phases/git-probes.js +3 -3
  95. package/.agents/scripts/lib/orchestration/lifecycle/emit-ledger-event.js +2 -6
  96. package/.agents/scripts/lib/orchestration/light-suitability.js +5 -7
  97. package/.agents/scripts/lib/orchestration/pr-watch.js +7 -7
  98. package/.agents/scripts/lib/orchestration/project-meta-cache.js +2 -11
  99. package/.agents/scripts/lib/orchestration/project-meta-resolver.js +44 -17
  100. package/.agents/scripts/lib/orchestration/review-deposit.js +2 -9
  101. package/.agents/scripts/lib/orchestration/review-providers/callers-context.js +219 -0
  102. package/.agents/scripts/lib/orchestration/review-providers/code-review.js +53 -5
  103. package/.agents/scripts/lib/orchestration/review-providers/codex-cli.js +2 -2
  104. package/.agents/scripts/lib/orchestration/review-providers/llm-review.js +96 -0
  105. package/.agents/scripts/lib/orchestration/review-providers/mi-exemptions.js +2 -2
  106. package/.agents/scripts/lib/orchestration/review-providers/native.js +13 -19
  107. package/.agents/scripts/lib/orchestration/review-providers/review-depth.js +3 -2
  108. package/.agents/scripts/lib/orchestration/review-providers/review-provider-factory.js +2 -0
  109. package/.agents/scripts/lib/orchestration/review-providers/security-review.js +11 -3
  110. package/.agents/scripts/lib/orchestration/story-close/baseline-upward-writeback.js +2 -3
  111. package/.agents/scripts/lib/orchestration/story-close/format-autofix.js +41 -15
  112. package/.agents/scripts/lib/orchestration/story-deliver-terminal-schema.js +2 -4
  113. package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +2 -13
  114. package/.agents/scripts/lib/orchestration/story-handoff.js +27 -6
  115. package/.agents/scripts/lib/orchestration/story-progress.js +3 -11
  116. package/.agents/scripts/lib/orchestration/ticketing/bulk.js +3 -5
  117. package/.agents/scripts/lib/orchestration/verify-credit.js +52 -28
  118. package/.agents/scripts/lib/single-story-sweep/protection-ctx.js +11 -11
  119. package/.agents/scripts/lib/single-story-sweep/protection.js +1 -9
  120. package/.agents/scripts/lib/single-story-sweep/sweep-lock.js +1 -5
  121. package/.agents/scripts/lib/source-extensions.js +30 -15
  122. package/.agents/scripts/lib/test-run-credit.js +1 -9
  123. package/.agents/scripts/lib/test-temp.js +22 -21
  124. package/.agents/scripts/lib/util/ajv.js +111 -0
  125. package/.agents/scripts/lib/util/atomic-write.js +30 -0
  126. package/.agents/scripts/lib/util/paths.js +51 -0
  127. package/.agents/scripts/lib/util/sleep.js +6 -0
  128. package/.agents/scripts/lib/util/slug.js +12 -0
  129. package/.agents/scripts/lib/validation-evidence.js +19 -40
  130. package/.agents/scripts/lib/worktree/lifecycle/force-drain.js +2 -1
  131. package/.agents/scripts/lib/worktree/lifecycle/pending-cleanup.js +10 -28
  132. package/.agents/scripts/lib/worktree/lifecycle/reap.js +2 -2
  133. package/.agents/scripts/lib/worktree/node-modules-strategy.js +21 -14
  134. package/.agents/scripts/lint-issue-body.js +2 -2
  135. package/.agents/scripts/plan-context.js +2 -7
  136. package/.agents/scripts/providers/github/auth.js +3 -3
  137. package/.agents/scripts/providers/github/board-add.js +18 -9
  138. package/.agents/scripts/providers/github/errors.js +3 -1
  139. package/.agents/scripts/providers/github/gh-token-diagnostics.js +10 -7
  140. package/.agents/scripts/providers/github/issues.js +6 -2
  141. package/.agents/scripts/providers/github/mappers.js +1 -5
  142. package/.agents/scripts/providers/github/projects-v2-graphql.js +26 -6
  143. package/.agents/scripts/providers/github/search-budget.js +3 -1
  144. package/.agents/scripts/resolve-doc-tiers.js +7 -20
  145. package/.agents/scripts/sync-agentrc.js +5 -14
  146. package/.agents/scripts/sync-claude-agents.js +38 -150
  147. package/.agents/scripts/sync-claude-commands.js +35 -218
  148. package/.agents/scripts/update-coverage-baseline.js +1 -1
  149. package/.agents/scripts/update-crap-baseline.js +1 -1
  150. package/.agents/scripts/update-duplication-baseline.js +2 -16
  151. package/.agents/scripts/validate-skills.js +6 -10
  152. package/.agents/skills/core/code-review-and-quality/SKILL.md +3 -18
  153. package/.agents/skills/core/documentation-and-adrs/SKILL.md +4 -14
  154. package/.agents/workflows/audit-exceptions.md +9 -0
  155. package/.agents/workflows/audit-lean.md +129 -0
  156. package/.agents/workflows/helpers/audit-lens-core.md +7 -0
  157. package/.agents/workflows/helpers/code-quality-guardrails.md +21 -0
  158. package/.agents/workflows/helpers/code-review.md +15 -1
  159. package/.agents/workflows/helpers/deliver-digest.md +1 -1
  160. package/.agents/workflows/helpers/deliver-reference.md +2 -2
  161. package/.agents/workflows/mandrel-plan.md +2 -2
  162. package/docs/CHANGELOG.md +48 -0
  163. package/lib/cli/doctor-checks/codex.js +6 -5
  164. package/lib/cli/doctor-checks/llm-review.js +102 -0
  165. package/lib/cli/doctor-checks/project-access.js +124 -0
  166. package/lib/cli/doctor-checks/sync-parity.js +65 -140
  167. package/lib/cli/doctor-checks/test-credit-path.js +69 -28
  168. package/lib/cli/doctor-checks/toolchain.js +5 -3
  169. package/lib/cli/registry.js +11 -0
  170. package/lib/migrations/helpers/retire-agentrc-key.js +3 -3
  171. package/lib/migrations/index.js +6 -0
  172. package/lib/migrations/steps/2.91.0-move-shared-crap-capture-script.js +84 -0
  173. package/lib/migrations/steps/2.91.0-retire-duplication-formats.js +23 -0
  174. package/lib/migrations/steps/2.91.0-unset-null-lint-command.js +54 -0
  175. package/package.json +1 -3
@@ -1,22 +1,97 @@
1
+ /**
2
+ * `project.commands.*` tri-state: absent → default; own-present `null` →
3
+ * disabled (optional gates only); string → that command. Anything else throws.
4
+ */
5
+
6
+ import { isObject } from '../json-utils.js';
7
+
8
+ /** `test` must stay byte-identical: every recorded `test` credit hashes it. */
1
9
  export const COMMANDS_DEFAULTS = Object.freeze({
2
10
  test: 'npm test',
3
- typecheck: null,
4
- lint: null,
11
+ typecheck: 'npm run typecheck',
12
+ lint: 'npm run lint',
5
13
  formatCheck: 'npx biome format .',
6
14
  formatWrite: 'npx biome format --write .',
7
15
  });
8
16
 
17
+ /** The gates an explicit `null` disables. */
18
+ const OPTIONAL_COMMAND_KEYS = Object.freeze([
19
+ 'typecheck',
20
+ 'lint',
21
+ 'formatCheck',
22
+ ]);
23
+
24
+ /** @param {string} raw */
25
+ function splitArgv(raw) {
26
+ return raw.split(/\s+/).filter(Boolean);
27
+ }
28
+
29
+ /** @param {string} detail */
30
+ function configError(detail) {
31
+ return new Error(`[config] project.commands${detail}.`);
32
+ }
33
+
34
+ /** @param {object|null|undefined} config */
35
+ function commandsBlock(config) {
36
+ const commands = config?.project?.commands;
37
+ if (commands === undefined) return {};
38
+ if (!isObject(commands)) {
39
+ throw configError(' must be an object of command strings');
40
+ }
41
+ return commands;
42
+ }
43
+
44
+ /** @param {string} raw @param {'default'|'config'} source */
45
+ function enabled(raw, source) {
46
+ return { argv: splitArgv(raw), raw, disabled: false, source };
47
+ }
48
+
49
+ /** @param {string} key */
50
+ function disabledCommand(key) {
51
+ if (!OPTIONAL_COMMAND_KEYS.includes(key)) {
52
+ throw configError(`.${key} cannot be null — that gate is mandatory`);
53
+ }
54
+ return { argv: [], raw: null, disabled: true, source: 'disabled' };
55
+ }
56
+
57
+ /** @param {string} key @param {unknown} value */
58
+ function configuredCommand(key, value) {
59
+ const raw = typeof value === 'string' ? value.trim() : '';
60
+ if (raw.length === 0) {
61
+ throw configError(`.${key} must be a non-empty command string`);
62
+ }
63
+ return enabled(raw, 'config');
64
+ }
65
+
66
+ /** @param {string} key */
67
+ function assertKnownKey(key) {
68
+ if (!Object.hasOwn(COMMANDS_DEFAULTS, key)) {
69
+ throw configError(`.${key} is not a known command`);
70
+ }
71
+ }
72
+
9
73
  /**
10
- * @param {object | null | undefined} config
11
- * @returns {{ test: string, typecheck: string|null, lint: string|null, formatCheck: string, formatWrite: string }}
74
+ * @param {object|null|undefined} config
75
+ * @param {keyof typeof COMMANDS_DEFAULTS} key
76
+ * @returns {{ argv: string[], raw: string|null, disabled: boolean, source: 'default'|'disabled'|'config' }}
12
77
  */
78
+ export function resolveProjectCommand(config, key) {
79
+ assertKnownKey(key);
80
+ const commands = commandsBlock(config);
81
+ if (!Object.hasOwn(commands, key) || commands[key] === undefined) {
82
+ return enabled(COMMANDS_DEFAULTS[key], 'default');
83
+ }
84
+ return commands[key] === null
85
+ ? disabledCommand(key)
86
+ : configuredCommand(key, commands[key]);
87
+ }
88
+
89
+ /** Projection over {@link resolveProjectCommand}; a disabled gate keeps `null`. */
13
90
  export function getCommands(config) {
14
- const commands = config?.project?.commands ?? {};
15
- // `??` is safe for the nullable keys: their default is `null` too.
16
91
  return Object.fromEntries(
17
92
  Object.keys(COMMANDS_DEFAULTS).map((key) => [
18
93
  key,
19
- commands[key] ?? COMMANDS_DEFAULTS[key],
94
+ resolveProjectCommand(config, key).raw,
20
95
  ]),
21
96
  );
22
97
  }
@@ -49,8 +49,9 @@ const KEY_MEANINGS = Object.freeze({
49
49
  "Test command close's `test` gate runs and its credit identity hashes.",
50
50
  'project.commands.typecheck':
51
51
  'Typecheck command (null disables the typecheck gate).',
52
+ 'project.commands.lint': 'Lint command (null disables the lint gate).',
52
53
  'project.commands.formatCheck':
53
- 'Format-verify command run without modifying files.',
54
+ 'Format-verify command run without modifying files (null disables the format gate).',
54
55
  'project.commands.formatWrite':
55
56
  'Format-write command that applies formatting in place.',
56
57
 
@@ -1,8 +1,36 @@
1
1
  /* node:coverage ignore file -- AJV schema declaration (data-as-code) */
2
2
 
3
- import { COVERAGE_GATE_DEFAULTS } from '../quality.js';
4
3
  import { gateBase, SAFE_STRING } from './shared.js';
5
4
 
5
+ /**
6
+ * The single home of the coverage capture literals: the script the coverage
7
+ * gate's capture runs, the consumer-owned `affected` variant, and the
8
+ * artifact path. Every other site imports these, never re-types them.
9
+ */
10
+ export const COVERAGE_CAPTURE_DEFAULTS = Object.freeze({
11
+ captureScript: 'test:coverage',
12
+ affectedCaptureScript: 'test:coverage:affected',
13
+ coveragePath: 'coverage/coverage-final.json',
14
+ });
15
+
16
+ /** Injected when a declared gate omits a workspace key (usually `'*'`). */
17
+ const DEFAULT_COVERAGE_FLOORS = Object.freeze({
18
+ '*': Object.freeze({ lines: 90, branches: 85, functions: 90 }),
19
+ });
20
+
21
+ export const COVERAGE_GATE_DEFAULTS = Object.freeze({
22
+ enabled: true,
23
+ baselinePath: 'baselines/coverage.json',
24
+ tolerance: Object.freeze({ kind: 'absolute', value: 0 }),
25
+ floors: DEFAULT_COVERAGE_FLOORS,
26
+ coveragePath: COVERAGE_CAPTURE_DEFAULTS.coveragePath,
27
+ captureScript: COVERAGE_CAPTURE_DEFAULTS.captureScript,
28
+ // `affected` runs the consumer's affected capture script instead.
29
+ captureScope: 'full',
30
+ // On expiry `runCapture` exits 124 so callers can tell a hang from a failure.
31
+ timeoutMs: 600_000,
32
+ });
33
+
6
34
  /** Schema bounds on `coverage.timeoutMs`: one minute to two hours. */
7
35
  export const COVERAGE_TIMEOUT_BOUNDS = Object.freeze({
8
36
  min: 60_000,
@@ -24,14 +52,22 @@ export const COVERAGE_GATE = {
24
52
  ...SAFE_STRING,
25
53
  minLength: 1,
26
54
  description:
27
- 'Repo-relative path to the Istanbul `coverage-final.json` the capture step writes and the gate reads. The capture contract: `npm run test:coverage` MUST write Istanbul per-file JSON (the `json` reporter) here — the coverage and CRAP refreshes both read it. A `json-summary` (`coverage-summary.json`) alone cannot feed them, so a green capture that leaves no file here fails and a full-scope refresh refuses to run.',
55
+ 'Repo-relative path to the Istanbul `coverage-final.json` the capture step writes and the gate reads. The capture contract: `captureScript` MUST write Istanbul per-file JSON (the `json` reporter) here — the coverage and CRAP refreshes both read it. A `json-summary` (`coverage-summary.json`) alone cannot feed them, so a green capture that leaves no file here fails and a full-scope refresh refuses to run. Its capture stamp sits beside it (`.capture-stamp.<file>.json`), so another artifact may share its directory.',
28
56
  default: COVERAGE_GATE_DEFAULTS.coveragePath,
29
57
  },
58
+ captureScript: {
59
+ type: 'string',
60
+ minLength: 1,
61
+ pattern: '^[A-Za-z0-9@:._/-]+$',
62
+ description: `\`package.json\` script (never a shell command) the coverage gate's capture runs, spawned as \`<pm> run <script>\` under the detected package manager (npm, pnpm, yarn or bun). Close registers the coverage-capture gate when the coverage or CRAP gate is enabled and this script exists; the full-suite lock's workload identity and \`mandrel doctor\`'s \`test-credit-path\` check follow it. Default \`${COVERAGE_CAPTURE_DEFAULTS.captureScript}\`.`,
63
+ default: COVERAGE_GATE_DEFAULTS.captureScript,
64
+ },
30
65
  captureScope: {
31
66
  type: 'string',
32
67
  enum: ['full', 'affected'],
33
68
  description:
34
- 'What coverage-capture runs. `full` (default) runs `npm run test:coverage`. `affected` runs the consumer-owned `npm run test:coverage:affected` with the base ref in `MANDREL_COVERAGE_BASE_REF`, merges its rows over the prior artifact and stamps it `affected`; baseline rows the scoped run did not measure are treated as unmeasured, never removed. Falls back to `full` with a warning when the script is absent. Meant for consumers whose CI already enforces coverage on the full suite.',
69
+ `What coverage-capture runs. \`full\` (default) runs \`captureScript\`. \`affected\` runs the consumer-owned \`${COVERAGE_CAPTURE_DEFAULTS.affectedCaptureScript}\` script` +
70
+ ' with the base ref in `MANDREL_COVERAGE_BASE_REF`, merges its rows over the prior artifact and stamps it `affected`; baseline rows the scoped run did not measure are treated as unmeasured, never removed. Falls back to `full` with a warning when the script is absent. Meant for consumers whose CI already enforces coverage on the full suite.',
35
71
  default: COVERAGE_GATE_DEFAULTS.captureScope,
36
72
  },
37
73
  timeoutMs: {
@@ -7,7 +7,7 @@
7
7
  export const INCREMENTAL_COVERAGE_SCHEMA = {
8
8
  type: 'object',
9
9
  description:
10
- 'The two independent full-suite economies (Story #4981, split by Story #5173). `skipWhenUnchanged` (default true) decides WHETHER to capture — no changed file under `crap.targetDirs` versus `baseRef` means no capture at all — and is a pure saving. `baselineJoin` (default false) loosens gate semantics: the CRAP join resolves a method in an untouched file from its committed baseline row instead of requiring fresh coverage for it. Neither narrows the capture run itself: a capture that does happen is the ordinary full `npm run test:coverage` (Story #5065).',
10
+ "The two independent full-suite economies (Story #4981, split by Story #5173). `skipWhenUnchanged` (default true) decides WHETHER to capture — no changed file under `crap.targetDirs` versus `baseRef` means no capture at all — and is a pure saving. `baselineJoin` (default false) loosens gate semantics: the CRAP join resolves a method in an untouched file from its committed baseline row instead of requiring fresh coverage for it. Neither narrows the capture run itself: a capture that does happen is the ordinary full run of the coverage gate's `captureScript` (Story #5065).",
11
11
  properties: {
12
12
  skipWhenUnchanged: {
13
13
  type: 'boolean',
@@ -53,7 +53,7 @@ export const CRAP_GATE = {
53
53
  type: ['string', 'null'],
54
54
  minLength: 1,
55
55
  description:
56
- "Repo-relative Istanbul `coverage-final.json` the CRAP gate joins against (Story #5717). `null` or unset falls back to `delivery.quality.gates.coverage.coveragePath`. When it differs from that path the CRAP gate has its OWN coverage source: `coverage-capture.js` refreshes it full-scope via `captureScript`, and the handoff seat, close preview and `update-crap-baseline.js` read it. It must live in a different directory from the coverage gate's artifact (the capture stamp is per directory); a same-directory path is refused at config resolution.",
56
+ "Repo-relative Istanbul `coverage-final.json` the CRAP gate joins against (Story #5717). `null` or unset falls back to `delivery.quality.gates.coverage.coveragePath`. When it differs from that path the CRAP gate has its OWN coverage source: `coverage-capture.js` refreshes it full-scope via `captureScript`, and the handoff seat, close preview and `update-crap-baseline.js` read it. Its capture stamp sits beside it, so it may share a directory with the coverage gate's artifact.",
57
57
  default: null,
58
58
  },
59
59
  captureScript: {
@@ -61,9 +61,11 @@ export const CRAP_GATE = {
61
61
  minLength: 1,
62
62
  pattern: '^[A-Za-z0-9@:._/-]+$',
63
63
  description:
64
- 'npm script name (run as `npm run <script>`, never a shell command) that writes the CRAP coverage artifact. Close registers the coverage-capture gate, and the capture refusal and credited-run probe key, on this script.',
65
- default: CRAP_GATE_DEFAULTS.captureScript,
64
+ "`package.json` script (never a shell command) that writes the CRAP gate's OWN coverage artifact, spawned as `<pm> run <script>`. Valid only beside an own `coveragePath`: without one the CRAP gate reads the coverage gate's artifact, so this key is refused and `delivery.quality.gates.coverage.captureScript` runs. Unset beside an own `coveragePath`, it is the coverage gate's `captureScript`.",
66
65
  },
67
66
  },
67
+ // Draft-07 `dependencies` (array form) — the `dependentRequired` contract:
68
+ // a CRAP capture script needs the own artifact it writes.
69
+ dependencies: { captureScript: ['coveragePath'] },
68
70
  additionalProperties: false,
69
71
  };
@@ -5,7 +5,7 @@ import { gateBase, LIST_OR_EXTENDER_OF_STRINGS } from './shared.js';
5
5
  export const DUPLICATION_GATE = {
6
6
  type: 'object',
7
7
  description:
8
- 'Code-duplication (DRY) gate (Story #3664). Shares the gate base and adds the scan-scope extras: the `targetDirs` the duplication scanner walks, the jscpd `formats` it reads there, and `ignoreGlobs` to exclude files from the scan.',
8
+ 'Code-duplication (DRY) gate (Story #3664). Shares the gate base and adds the scan-scope extras: the `targetDirs` the duplication scanner walks and `ignoreGlobs` to exclude files from the scan. The jscpd formats it reads are derived from the scorable-extension list every other gate scores (JavaScript, JSX, TypeScript, TSX), so they are not configurable (Story #5738).',
9
9
  properties: {
10
10
  ...gateBase({
11
11
  enabled: false,
@@ -16,22 +16,17 @@ export const DUPLICATION_GATE = {
16
16
  targetDirs: {
17
17
  ...LIST_OR_EXTENDER_OF_STRINGS,
18
18
  description:
19
- "Directories whose sources — the languages `formats` selects — the duplication (DRY) gate scans for copy-paste clones. Mandrel ships a `src/`-centric default; projects whose executable code lives elsewhere (e.g. this repo's `.agents/scripts/`) override here. The framework default is intentionally not auto-discovered, so an override is the explicit, auditable signal (Story #3664).",
19
+ "Directories whose scorable sources (`.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.tsx`, `.mts`, `.cts`) the duplication (DRY) gate scans for copy-paste clones. Mandrel ships a `src/`-centric default; projects whose executable code lives elsewhere (e.g. this repo's `.agents/scripts/`) override here. The framework default is intentionally not auto-discovered, so an override is the explicit, auditable signal (Story #3664).",
20
20
  default: ['src'],
21
21
  },
22
- formats: {
23
- type: 'array',
24
- items: { type: 'string', minLength: 1 },
25
- minItems: 1,
26
- description:
27
- "jscpd format names the duplication (DRY) gate scans under `targetDirs`. The default covers JavaScript, JSX, TypeScript and TSX; jscpd's `javascript` format alone reads only `.js`/`.es`/`.es6`/`.mjs`/`.cjs`. Names are jscpd's own vocabulary and are not restricted here. Widening the set adds rows, so re-seat the baseline with `npm run duplication:reanchor` after changing it.",
28
- default: ['javascript', 'jsx', 'typescript', 'tsx'],
29
- },
22
+ // No `formats`: jscpd formats derive from `jscpdFormatsFor()`, and the
23
+ // 2.91.0 migration `retire-duplication-formats` strips the old key from
24
+ // `.agentrc.json` / `.agentrc.local.json` before this strict block sees it.
30
25
  ignoreGlobs: {
31
26
  type: 'array',
32
27
  items: { type: 'string', minLength: 1 },
33
28
  description:
34
- 'Minimatch glob patterns matched against the canonicalised repo-relative path of each discovered file. Files matching any pattern are excluded from duplication discovery before scanning. Orthogonal to `components` (grouping). Absent or empty preserves the existing behaviour (Story #3664).',
29
+ 'Minimatch glob patterns matched against the canonicalised repo-relative path of each discovered file. Files matching any pattern are excluded from duplication discovery before scanning. Orthogonal to `components` (grouping). Absent or empty preserves the existing behaviour (Story #3664). This is the lever for scanning fewer files.',
35
30
  default: [],
36
31
  },
37
32
  },
@@ -50,7 +50,7 @@ const TOLERANCE_SCHEMA = {
50
50
  const FLOORS_SCHEMA = {
51
51
  type: 'object',
52
52
  description:
53
- 'Workspace-keyed absolute floors: `{ "<workspace>": { "<metric>": number } }`. `"*"` is the project-wide catch-all; the metric keyset is open so per-rollup keys flow through without each gate enumerating them. Floors are absolute — unlike `tolerance`, they are enforced regardless of the baseline.',
53
+ 'Component-keyed absolute floors: `{ "<component>": { "<metric>": number } }` — the threshold half of the component mapping whose membership half is `components`. `"*"` is the project-wide catch-all component; the metric keyset is open so per-rollup keys flow through without each gate enumerating them. Floors are absolute — unlike `tolerance`, they are enforced regardless of the baseline.',
54
54
  additionalProperties: {
55
55
  type: 'object',
56
56
  additionalProperties: { type: 'number' },
@@ -60,7 +60,7 @@ const FLOORS_SCHEMA = {
60
60
  const COMPONENTS_SCHEMA = {
61
61
  type: 'object',
62
62
  description:
63
- 'Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors["*"]`. Defaults to `{ "*": ["**"] }` at the resolver layer.',
63
+ 'Component-keyed membership map — the membership half of the component mapping whose threshold half is `floors`: component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors["*"]`. Defaults to `{ "*": ["**"] }` at the resolver layer.',
64
64
  additionalProperties: {
65
65
  type: 'array',
66
66
  items: { type: 'string', minLength: 1 },
@@ -0,0 +1,120 @@
1
+ /** Git-derived roots; Node builtins only, since doctor imports it. */
2
+
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+
6
+ import { execFileCapture } from '../child-exec.js';
7
+ import { PROJECT_ROOT } from '../project-root.js';
8
+
9
+ const GIT_QUIET = { stdio: ['ignore', 'pipe', 'ignore'] };
10
+
11
+ const _cache = new Map();
12
+
13
+ /** Memoized per flag and cwd for the real runner; `null` outside a repo. */
14
+ function revParse(flag, cwd, exec) {
15
+ const key = `${flag}\0${cwd}`;
16
+ if (!exec && _cache.has(key)) return _cache.get(key);
17
+ let out = null;
18
+ try {
19
+ const opts = { cwd, ...GIT_QUIET, ...(exec ? { run: exec } : {}) };
20
+ out = execFileCapture('git', ['rev-parse', flag], opts).trim() || null;
21
+ } catch {
22
+ out = null;
23
+ }
24
+ if (!exec) _cache.set(key, out);
25
+ return out;
26
+ }
27
+
28
+ /** Parent of `--git-common-dir`: the main checkout, from any worktree. */
29
+ export function mainCheckoutRoot(cwd = process.cwd(), deps = {}) {
30
+ const out = revParse('--git-common-dir', cwd, deps.exec);
31
+ if (!out) return null;
32
+ return path.dirname(path.isAbsolute(out) ? out : path.resolve(cwd, out));
33
+ }
34
+
35
+ /** This work tree's own root — a linked worktree's, not the main one's. */
36
+ function gitToplevel(cwd, exec) {
37
+ return revParse('--show-toplevel', cwd, exec);
38
+ }
39
+
40
+ /**
41
+ * Where `.agentrc.json` is read: `cwd` → `AP_AGENTRC_CWD` → the nearest
42
+ * config dir within the process cwd's work tree (else its toplevel) →
43
+ * `PROJECT_ROOT`.
44
+ */
45
+ export function resolveAgentrcRoot({
46
+ cwd,
47
+ env = process.env,
48
+ processCwd = process.cwd,
49
+ exec,
50
+ } = {}) {
51
+ if (cwd) return path.resolve(cwd);
52
+ if (env.AP_AGENTRC_CWD) return path.resolve(env.AP_AGENTRC_CWD);
53
+ return path.resolve(cwdRoot(processCwd(), exec));
54
+ }
55
+
56
+ /** The config dir of the work tree `here` is in, or `PROJECT_ROOT`. */
57
+ function cwdRoot(here, exec) {
58
+ const top = gitToplevel(here, exec);
59
+ return top === null ? PROJECT_ROOT : nearestConfig(here, top);
60
+ }
61
+
62
+ /**
63
+ * The nearest dir from `start` up to the work tree root `top` holding an
64
+ * `.agentrc.json` — a project nested in a larger repo — else `top`.
65
+ */
66
+ function nearestConfig(start, top) {
67
+ const stop = canonical(top, process.platform);
68
+ for (let dir = start; ; dir = path.dirname(dir)) {
69
+ if (fs.existsSync(path.join(dir, '.agentrc.json'))) return dir;
70
+ const atTop = canonical(dir, process.platform) === stop;
71
+ if (atTop || path.dirname(dir) === dir) return top;
72
+ }
73
+ }
74
+
75
+ function nativeReal(p) {
76
+ try {
77
+ return fs.realpathSync.native(p);
78
+ } catch {
79
+ return p;
80
+ }
81
+ }
82
+
83
+ /** Native realpath (8.3 names, symlinks); win32 compares case-insensitively. */
84
+ function canonical(p, platform) {
85
+ const win = platform === 'win32';
86
+ const resolved = (win ? path.win32 : path).resolve(nativeReal(p));
87
+ return win ? resolved.toLowerCase() : resolved;
88
+ }
89
+
90
+ /** The main checkout when `root` is a work tree root over a checkout's `.git`. */
91
+ function checkoutOf(root, exec, platform) {
92
+ const top = gitToplevel(root, exec);
93
+ const same =
94
+ top !== null && canonical(top, platform) === canonical(root, platform);
95
+ if (!same) return null;
96
+ const common = revParse('--git-common-dir', root, exec) ?? '';
97
+ return path.basename(common) === '.git'
98
+ ? mainCheckoutRoot(root, { exec })
99
+ : null;
100
+ }
101
+
102
+ /**
103
+ * The project root a gitignored file under `root` lives in: the main
104
+ * checkout for a checkout or linked worktree root, else `root` (a nested
105
+ * project, a submodule, a separate git dir).
106
+ */
107
+ export function storeRoot(root, exec, platform = process.platform) {
108
+ return checkoutOf(root, exec, platform) ?? root;
109
+ }
110
+
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);
115
+ }
116
+
117
+ /** Test-only. */
118
+ export function _clearGitRootCaches() {
119
+ _cache.clear();
120
+ }
@@ -1,13 +1,16 @@
1
1
  /**
2
2
  * `delivery.quality` resolver. Every `gates.<tier>` shares `enabled`,
3
- * `baselinePath`, `tolerance` (`{ kind, value }`) and workspace-keyed
4
- * `floors`; the resolver flattens them into the legacy bag callers read
3
+ * `baselinePath`, `tolerance` (`{ kind, value }`) and the
4
+ * component-keyed `floors` / `components` pair (threshold and membership); the resolver flattens them into the legacy bag callers read
5
5
  * (scalar `tolerance`, `crap.coveragePath` cross-read from the coverage gate).
6
6
  */
7
7
 
8
8
  import { Logger } from '../Logger.js';
9
+ import { COVERAGE_GATE_DEFAULTS } from './gates/coverage.schema.js';
9
10
  import { resolveListValue } from './shared.js';
10
11
 
12
+ export { COVERAGE_GATE_DEFAULTS };
13
+
11
14
  const GATE_SCOPING = Object.freeze({ scope: 'diff', diffRef: 'main' });
12
15
 
13
16
  /** Commit-subject substring acknowledging a deliberate baseline refresh. */
@@ -16,10 +19,7 @@ const BASELINE_REFRESH_TAG = 'baseline-refresh:';
16
19
  const DEFAULT_CRAP_TOLERANCE = Object.freeze({ kind: 'absolute', value: 0.05 });
17
20
  const DEFAULT_MI_TOLERANCE = Object.freeze({ kind: 'absolute', value: 0.5 });
18
21
 
19
- /** Injected when a declared gate omits a workspace key (usually `'*'`). */
20
- const DEFAULT_COVERAGE_FLOORS = Object.freeze({
21
- '*': Object.freeze({ lines: 90, branches: 85, functions: 90 }),
22
- });
22
+ /** Injected when a declared gate omits a component key (usually `'*'`). */
23
23
  const DEFAULT_CRAP_FLOORS = Object.freeze({
24
24
  '*': Object.freeze({ max: 30, p95: 20, methodsAbove20: 50 }),
25
25
  });
@@ -58,20 +58,6 @@ export const CRAP_GATE_DEFAULTS = Object.freeze({
58
58
  // Healthy runs resolve ~98%; a coordinate mismatch resolves 4–6%.
59
59
  minMethodResolutionRate: 0.75,
60
60
  incrementalCoverage: DEFAULT_INCREMENTAL_COVERAGE,
61
- // npm script that writes the CRAP coverage artifact (never a shell command).
62
- captureScript: 'test:coverage',
63
- });
64
-
65
- export const COVERAGE_GATE_DEFAULTS = Object.freeze({
66
- enabled: true,
67
- baselinePath: 'baselines/coverage.json',
68
- tolerance: Object.freeze({ kind: 'absolute', value: 0 }),
69
- floors: DEFAULT_COVERAGE_FLOORS,
70
- coveragePath: 'coverage/coverage-final.json',
71
- // `affected` runs the consumer's `test:coverage:affected` instead.
72
- captureScope: 'full',
73
- // On expiry `runCapture` exits 124 so callers can tell a hang from a failure.
74
- timeoutMs: 600_000,
75
61
  });
76
62
 
77
63
  export const MAINTAINABILITY_GATE_DEFAULTS = Object.freeze({
@@ -109,6 +95,7 @@ const COVERAGE_GATE_KEYS = new Set([
109
95
  'floors',
110
96
  'components',
111
97
  'coveragePath',
98
+ 'captureScript',
112
99
  'captureScope',
113
100
  'timeoutMs',
114
101
  ]);
@@ -186,40 +173,41 @@ function nonEmptyString(value) {
186
173
  : null;
187
174
  }
188
175
 
189
- /** Directory part of a repo-relative path, separator-agnostic. */
190
- function artifactDir(relPath) {
191
- const parts = relPath.replace(/\\/g, '/').split('/').filter(Boolean);
192
- parts.pop();
193
- return parts.filter((p) => p !== '.').join('/');
176
+ /** @param {string} relPath @returns {string} forward-slash form. */
177
+ function slashed(relPath) {
178
+ return relPath.replace(/\\/g, '/');
194
179
  }
195
180
 
181
+ const CRAP_CAPTURE_SCRIPT_KEY = 'delivery.quality.gates.crap.captureScript';
182
+ const CRAP_COVERAGE_PATH_KEY = 'delivery.quality.gates.crap.coveragePath';
183
+
196
184
  /**
197
- * The CRAP gate's coverage source. A user `coveragePath` that
198
- * differs from the coverage gate's is an OWN source; one in the same
199
- * directory would share the per-directory capture stamp and cross-credit
200
- * freshness, so it is refused here rather than silently falling back.
185
+ * The CRAP gate's coverage source. A user `coveragePath` that differs from
186
+ * the coverage gate's is an OWN source with its own capture stamp. Without
187
+ * one the CRAP gate reads the coverage gate's artifact, captured by the
188
+ * coverage gate's `captureScript` — so a `crap.captureScript` there has no
189
+ * artifact to write and is refused rather than silently ignored.
201
190
  *
202
191
  * @param {{ coveragePath?: unknown, captureScript?: unknown }} userCrap
203
- * @param {string} coverageGatePath
192
+ * @param {{ coveragePath: string, captureScript: string }} coverageGate
204
193
  * @returns {{ coveragePath: string, captureScript: string, ownCoverageSource: boolean }}
205
194
  */
206
- function resolveCrapCoverageSource(userCrap, coverageGatePath) {
195
+ function resolveCrapCoverageSource(userCrap, coverageGate) {
207
196
  const userPath = nonEmptyString(userCrap?.coveragePath);
208
- const captureScript =
209
- nonEmptyString(userCrap?.captureScript) ?? CRAP_GATE_DEFAULTS.captureScript;
210
- const coveragePath = userPath ?? coverageGatePath;
197
+ const userScript = nonEmptyString(userCrap?.captureScript);
211
198
  const ownCoverageSource =
212
199
  userPath !== null &&
213
- userPath.replace(/\\/g, '/') !== coverageGatePath.replace(/\\/g, '/');
214
- if (
215
- ownCoverageSource &&
216
- artifactDir(userPath) === artifactDir(coverageGatePath)
217
- ) {
200
+ slashed(userPath) !== slashed(coverageGate.coveragePath);
201
+ if (userScript !== null && !ownCoverageSource) {
218
202
  throw new Error(
219
- `[config] delivery.quality.gates.crap.coveragePath '${userPath}' sits in the same directory as delivery.quality.gates.coverage.coveragePath '${coverageGatePath}'. The capture stamp is per directory, so an own CRAP coverage source must live in its own directory.`,
203
+ `[config] ${CRAP_CAPTURE_SCRIPT_KEY} '${userScript}' is set without an own ${CRAP_COVERAGE_PATH_KEY}. A CRAP capture script only writes a CRAP coverage artifact distinct from delivery.quality.gates.coverage.coveragePath — set ${CRAP_COVERAGE_PATH_KEY} to that artifact, or move it to delivery.quality.gates.coverage.captureScript (\`npx mandrel update\` migrates it).`,
220
204
  );
221
205
  }
222
- return { coveragePath, captureScript, ownCoverageSource };
206
+ return {
207
+ coveragePath: userPath ?? coverageGate.coveragePath,
208
+ captureScript: userScript ?? coverageGate.captureScript,
209
+ ownCoverageSource,
210
+ };
223
211
  }
224
212
 
225
213
  /**
@@ -229,7 +217,12 @@ function resolveCrapCoverageSource(userCrap, coverageGatePath) {
229
217
  */
230
218
  export function resolveMaintainabilityCrap(userCrap, coverageGate) {
231
219
  const defaults = CRAP_GATE_DEFAULTS;
232
- const coverage = coverageGate ?? COVERAGE_GATE_DEFAULTS;
220
+ const coverage = {
221
+ coveragePath:
222
+ coverageGate?.coveragePath ?? COVERAGE_GATE_DEFAULTS.coveragePath,
223
+ captureScript:
224
+ coverageGate?.captureScript ?? COVERAGE_GATE_DEFAULTS.captureScript,
225
+ };
233
226
  const fixed = {
234
227
  refreshTag: defaults.refreshTag,
235
228
  defaultScope: GATE_SCOPING.scope,
@@ -241,7 +234,7 @@ export function resolveMaintainabilityCrap(userCrap, coverageGate) {
241
234
  targetDirs: [...defaults.targetDirs],
242
235
  newMethodCeiling: defaults.newMethodCeiling,
243
236
  coveragePath: coverage.coveragePath,
244
- captureScript: defaults.captureScript,
237
+ captureScript: coverage.captureScript,
245
238
  ownCoverageSource: false,
246
239
  tolerance: toleranceScalar(
247
240
  defaults.tolerance,
@@ -261,7 +254,7 @@ export function resolveMaintainabilityCrap(userCrap, coverageGate) {
261
254
  enabled: userCrap.enabled ?? defaults.enabled,
262
255
  targetDirs: resolveListValue(defaults.targetDirs, userCrap.targetDirs),
263
256
  newMethodCeiling: userCrap.newMethodCeiling ?? defaults.newMethodCeiling,
264
- ...resolveCrapCoverageSource(userCrap, coverage.coveragePath),
257
+ ...resolveCrapCoverageSource(userCrap, coverage),
265
258
  tolerance: toleranceScalar(
266
259
  userCrap.tolerance,
267
260
  toleranceScalar(defaults.tolerance, DEFAULT_CRAP_TOLERANCE.value),
@@ -320,6 +313,7 @@ function resolveCoverageGate(userBlock) {
320
313
  enabled: defaults.enabled,
321
314
  baselinePath: defaults.baselinePath,
322
315
  coveragePath: defaults.coveragePath,
316
+ captureScript: defaults.captureScript,
323
317
  captureScope: defaults.captureScope,
324
318
  tolerance: toleranceScalar(defaults.tolerance, 0),
325
319
  timeoutMs: defaults.timeoutMs,
@@ -330,6 +324,8 @@ function resolveCoverageGate(userBlock) {
330
324
  enabled: userBlock.enabled ?? defaults.enabled,
331
325
  baselinePath: userBlock.baselinePath ?? defaults.baselinePath,
332
326
  coveragePath: userBlock.coveragePath ?? defaults.coveragePath,
327
+ captureScript:
328
+ nonEmptyString(userBlock.captureScript) ?? defaults.captureScript,
333
329
  captureScope: userBlock.captureScope ?? defaults.captureScope,
334
330
  tolerance: toleranceScalar(
335
331
  userBlock.tolerance,
@@ -380,7 +376,7 @@ function resolveBaselinesFromGates(gates) {
380
376
  }
381
377
 
382
378
  /**
383
- * Consumer entries win per workspace key. Returns a fresh object so callers
379
+ * Consumer entries win per component key. Returns a fresh object so callers
384
380
  * cannot mutate the frozen defaults.
385
381
  *
386
382
  * @param {object | undefined | null} userFloors
@@ -389,22 +385,22 @@ function resolveBaselinesFromGates(gates) {
389
385
  */
390
386
  function mergeFloorsWithDefaults(userFloors, defaults) {
391
387
  const defaultsCopy = {};
392
- for (const [workspace, axes] of Object.entries(defaults)) {
393
- defaultsCopy[workspace] = { ...axes };
388
+ for (const [component, axes] of Object.entries(defaults)) {
389
+ defaultsCopy[component] = { ...axes };
394
390
  }
395
391
  if (userFloors == null || typeof userFloors !== 'object') {
396
392
  return defaultsCopy;
397
393
  }
398
- for (const [workspace, axes] of Object.entries(userFloors)) {
394
+ for (const [component, axes] of Object.entries(userFloors)) {
399
395
  if (axes != null && typeof axes === 'object') {
400
- defaultsCopy[workspace] = { ...axes };
396
+ defaultsCopy[component] = { ...axes };
401
397
  }
402
398
  }
403
399
  return defaultsCopy;
404
400
  }
405
401
 
406
402
  const FLOOR_DEFAULTS_BY_KIND = Object.freeze({
407
- coverage: DEFAULT_COVERAGE_FLOORS,
403
+ coverage: COVERAGE_GATE_DEFAULTS.floors,
408
404
  crap: DEFAULT_CRAP_FLOORS,
409
405
  maintainability: DEFAULT_MI_FLOORS,
410
406
  });
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * The one default review chain: the factory's unset/empty fallback and the
3
- * runtime schema's declared default. `code-review` is `optional` so hosts
4
- * without the `claude` CLI close on `native` alone.
3
+ * runtime schema's declared default. `llm-review` (the first available of
4
+ * `claude` then `codex`) is `optional` so hosts with neither CLI close on
5
+ * `native` alone.
5
6
  */
6
7
  export const DEFAULT_REVIEW_PROVIDERS = Object.freeze([
7
8
  Object.freeze({ name: 'native' }),
8
9
  Object.freeze({
9
- name: 'code-review',
10
+ name: 'llm-review',
10
11
  scopes: Object.freeze(['story']),
11
12
  optional: true,
12
13
  }),
@@ -0,0 +1,11 @@
1
+ /** Each review provider's CLIs, in probe order. Built-ins only, for doctor. */
2
+ const clis = {
3
+ 'code-review': ['claude'],
4
+ 'security-review': ['claude'],
5
+ codex: ['codex'],
6
+ 'llm-review': ['claude', 'codex'],
7
+ };
8
+
9
+ for (const order of Object.values(clis)) Object.freeze(order);
10
+
11
+ export const REVIEW_PROVIDER_CLIS = Object.freeze(clis);