mandrel 2.90.0 → 2.92.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.
- package/.agents/README.md +47 -7
- package/.agents/agents/story-worker.md +20 -0
- package/.agents/audit-checklists/lean.md +26 -0
- package/.agents/docs/agentrc-reference.json +5 -6
- package/.agents/docs/configuration.md +31 -30
- package/.agents/docs/workflows.md +7 -1
- package/.agents/instructions.md +3 -1
- package/.agents/runtime-deps.json +0 -2
- package/.agents/schemas/agentrc.schema.json +46 -45
- package/.agents/schemas/audit-rules.json +19 -0
- package/.agents/scripts/acceptance-eval.js +2 -6
- package/.agents/scripts/audit-exceptions.js +2 -4
- package/.agents/scripts/check-arch-cycles.js +1 -5
- package/.agents/scripts/check-context-budget.js +1 -5
- package/.agents/scripts/check-cyclomatic.js +1 -5
- package/.agents/scripts/check-dead-exports.js +23 -14
- package/.agents/scripts/check-doc-links.js +4 -4
- package/.agents/scripts/check-test-temp-hygiene.js +29 -33
- package/.agents/scripts/coverage-capture.js +14 -6
- package/.agents/scripts/diagnose-friction.js +8 -10
- package/.agents/scripts/generate-workflows-doc.js +5 -0
- package/.agents/scripts/lib/audit-exceptions/adapters/index.js +2 -0
- package/.agents/scripts/lib/audit-exceptions/adapters/inline-suppressions.js +36 -27
- package/.agents/scripts/lib/audit-exceptions/adapters/shortcut-markers.js +70 -0
- package/.agents/scripts/lib/audit-exceptions/adapters/source-scan.js +26 -0
- package/.agents/scripts/lib/audit-to-stories/audit-lenses.js +1 -0
- package/.agents/scripts/lib/baseline-schema-registry.js +3 -5
- package/.agents/scripts/lib/baselines/bundle-size-scorer.js +11 -28
- package/.agents/scripts/lib/baselines/components.js +5 -5
- package/.agents/scripts/lib/baselines/crap-preview-scan.js +4 -1
- package/.agents/scripts/lib/baselines/crap-updater-cli.js +6 -4
- package/.agents/scripts/lib/baselines/duplication-scanner.js +4 -10
- package/.agents/scripts/lib/baselines/kinds/crap.js +4 -2
- package/.agents/scripts/lib/baselines/kinds/duplication.js +4 -2
- package/.agents/scripts/lib/baselines/kinds/kind-factory.js +13 -6
- package/.agents/scripts/lib/baselines/refresh-service.js +10 -13
- package/.agents/scripts/lib/baselines/writer.js +4 -4
- package/.agents/scripts/lib/bdd-scenario-scanner.js +26 -31
- package/.agents/scripts/lib/bootstrap/gh-list.js +4 -5
- package/.agents/scripts/lib/bootstrap/gh-preflight.js +13 -8
- package/.agents/scripts/lib/child-exec.js +4 -4
- package/.agents/scripts/lib/claude/agents-projection.js +170 -0
- package/.agents/scripts/lib/claude/commands-projection.js +184 -0
- package/.agents/scripts/lib/close-validation/commands.js +28 -117
- package/.agents/scripts/lib/close-validation/gates.js +54 -48
- package/.agents/scripts/lib/close-validation/projections/crap.js +2 -1
- package/.agents/scripts/lib/close-validation/projections/maintainability.js +50 -15
- package/.agents/scripts/lib/config/agentrc-overlay.js +4 -7
- package/.agents/scripts/lib/config/commands.js +82 -7
- package/.agents/scripts/lib/config/explain.js +2 -1
- package/.agents/scripts/lib/config/gates/coverage.schema.js +39 -3
- package/.agents/scripts/lib/config/gates/crap-incremental-coverage.schema.js +1 -1
- package/.agents/scripts/lib/config/gates/crap.schema.js +5 -3
- package/.agents/scripts/lib/config/gates/duplication.schema.js +6 -11
- package/.agents/scripts/lib/config/gates/shared.js +2 -2
- package/.agents/scripts/lib/config/git-roots.js +120 -0
- package/.agents/scripts/lib/config/quality.js +46 -50
- package/.agents/scripts/lib/config/review-chain-default.js +4 -3
- package/.agents/scripts/lib/config/review-provider-clis.js +11 -0
- package/.agents/scripts/lib/config/temp-paths.js +3 -37
- package/.agents/scripts/lib/config-resolver.js +5 -9
- package/.agents/scripts/lib/config-settings-schema-delivery.js +2 -2
- package/.agents/scripts/lib/config-settings-schema-quality.js +3 -2
- package/.agents/scripts/lib/config-settings-schema.js +6 -7
- package/.agents/scripts/lib/coverage-baseline.js +2 -1
- package/.agents/scripts/lib/coverage-capture-affected.js +4 -3
- package/.agents/scripts/lib/coverage-capture-fullscope.js +3 -1
- package/.agents/scripts/lib/coverage-capture-passes.js +119 -34
- package/.agents/scripts/lib/coverage-capture-usage.js +1 -1
- package/.agents/scripts/lib/coverage-capture.js +31 -20
- package/.agents/scripts/lib/coverage-utils.js +34 -16
- package/.agents/scripts/lib/cpu-pool.js +2 -4
- package/.agents/scripts/lib/crap-engine.js +19 -1
- package/.agents/scripts/lib/crap-utils.js +2 -1
- package/.agents/scripts/lib/dead-exports-knip.js +29 -11
- package/.agents/scripts/lib/detect-package-manager.js +13 -0
- package/.agents/scripts/lib/feedback-loop/graduator-gh.js +4 -2
- package/.agents/scripts/lib/full-suite-lock.js +25 -9
- package/.agents/scripts/lib/gates/baseline-store.js +2 -10
- package/.agents/scripts/lib/generated/agentrc-validator.js +4 -1
- package/.agents/scripts/lib/gh-env.js +72 -0
- package/.agents/scripts/lib/gh-exec.js +26 -1
- package/.agents/scripts/lib/maintainability-utils.js +8 -8
- package/.agents/scripts/lib/npm-scripts.js +1 -1
- package/.agents/scripts/lib/observability/signal-validator.js +2 -6
- package/.agents/scripts/lib/observability/terse-result.js +2 -6
- package/.agents/scripts/lib/orchestration/board-access-latch.js +19 -8
- package/.agents/scripts/lib/orchestration/ci-rerun-guard.js +10 -13
- package/.agents/scripts/lib/orchestration/deliver-recover.js +2 -1
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/git-probes.js +3 -3
- package/.agents/scripts/lib/orchestration/lifecycle/emit-ledger-event.js +2 -6
- package/.agents/scripts/lib/orchestration/light-suitability.js +5 -7
- package/.agents/scripts/lib/orchestration/pr-watch.js +7 -7
- package/.agents/scripts/lib/orchestration/project-meta-cache.js +2 -11
- package/.agents/scripts/lib/orchestration/review-deposit.js +2 -9
- package/.agents/scripts/lib/orchestration/review-providers/callers-context.js +219 -0
- package/.agents/scripts/lib/orchestration/review-providers/code-review.js +53 -5
- package/.agents/scripts/lib/orchestration/review-providers/codex-cli.js +2 -2
- package/.agents/scripts/lib/orchestration/review-providers/llm-review.js +96 -0
- package/.agents/scripts/lib/orchestration/review-providers/mi-exemptions.js +2 -2
- package/.agents/scripts/lib/orchestration/review-providers/native.js +13 -19
- package/.agents/scripts/lib/orchestration/review-providers/review-depth.js +3 -2
- package/.agents/scripts/lib/orchestration/review-providers/review-provider-factory.js +2 -0
- package/.agents/scripts/lib/orchestration/review-providers/security-review.js +11 -3
- package/.agents/scripts/lib/orchestration/single-story-close/phases/finish.js +4 -1
- package/.agents/scripts/lib/orchestration/single-story-close/runner.js +49 -83
- package/.agents/scripts/lib/orchestration/story-close/baseline-upward-writeback.js +2 -3
- package/.agents/scripts/lib/orchestration/story-close/format-autofix.js +41 -15
- package/.agents/scripts/lib/orchestration/story-deliver-terminal-schema.js +2 -4
- package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +2 -13
- package/.agents/scripts/lib/orchestration/story-handoff.js +13 -5
- package/.agents/scripts/lib/orchestration/story-init-result.js +11 -0
- package/.agents/scripts/lib/orchestration/story-progress.js +3 -11
- package/.agents/scripts/lib/orchestration/ticketing/bulk.js +3 -5
- package/.agents/scripts/lib/orchestration/ticketing/transition.js +47 -21
- package/.agents/scripts/lib/orchestration/verify-credit.js +52 -28
- package/.agents/scripts/lib/single-story-sweep/protection-ctx.js +11 -11
- package/.agents/scripts/lib/single-story-sweep/protection.js +1 -9
- package/.agents/scripts/lib/single-story-sweep/sweep-lock.js +1 -5
- package/.agents/scripts/lib/source-extensions.js +30 -15
- package/.agents/scripts/lib/test-run-credit.js +1 -9
- package/.agents/scripts/lib/test-temp.js +22 -21
- package/.agents/scripts/lib/util/ajv.js +111 -0
- package/.agents/scripts/lib/util/atomic-write.js +30 -0
- package/.agents/scripts/lib/util/paths.js +51 -0
- package/.agents/scripts/lib/util/sleep.js +6 -0
- package/.agents/scripts/lib/util/slug.js +12 -0
- package/.agents/scripts/lib/validation-evidence.js +19 -40
- package/.agents/scripts/lib/worktree/lifecycle/force-drain.js +2 -1
- package/.agents/scripts/lib/worktree/lifecycle/pending-cleanup.js +10 -28
- package/.agents/scripts/lib/worktree/lifecycle/reap.js +2 -2
- package/.agents/scripts/lib/worktree/node-modules-strategy.js +21 -14
- package/.agents/scripts/lint-issue-body.js +2 -2
- package/.agents/scripts/plan-context.js +2 -7
- package/.agents/scripts/providers/github/auth.js +3 -3
- package/.agents/scripts/providers/github/errors.js +3 -1
- package/.agents/scripts/providers/github/gh-token-diagnostics.js +10 -7
- package/.agents/scripts/providers/github/issues.js +6 -2
- package/.agents/scripts/providers/github/mappers.js +1 -5
- package/.agents/scripts/providers/github/projects-v2-graphql.js +11 -3
- package/.agents/scripts/providers/github/search-budget.js +3 -1
- package/.agents/scripts/resolve-doc-tiers.js +7 -20
- package/.agents/scripts/single-story-init.js +18 -14
- package/.agents/scripts/sync-agentrc.js +5 -14
- package/.agents/scripts/sync-claude-agents.js +38 -150
- package/.agents/scripts/sync-claude-commands.js +35 -218
- package/.agents/scripts/update-coverage-baseline.js +1 -1
- package/.agents/scripts/update-crap-baseline.js +1 -1
- package/.agents/scripts/update-duplication-baseline.js +2 -16
- package/.agents/scripts/validate-skills.js +6 -10
- package/.agents/skills/core/code-review-and-quality/SKILL.md +3 -18
- package/.agents/skills/core/documentation-and-adrs/SKILL.md +4 -14
- package/.agents/workflows/audit-exceptions.md +9 -0
- package/.agents/workflows/audit-lean.md +129 -0
- package/.agents/workflows/helpers/audit-lens-core.md +7 -0
- package/.agents/workflows/helpers/code-quality-guardrails.md +21 -0
- package/.agents/workflows/helpers/code-review.md +15 -1
- package/.agents/workflows/helpers/deliver-digest.md +1 -1
- package/.agents/workflows/helpers/deliver-reference.md +2 -2
- package/.agents/workflows/helpers/deliver-story-reference.md +19 -8
- package/.agents/workflows/mandrel-plan.md +2 -2
- package/docs/CHANGELOG.md +42 -0
- package/lib/cli/doctor-checks/codex.js +6 -5
- package/lib/cli/doctor-checks/llm-review.js +102 -0
- package/lib/cli/doctor-checks/project-access.js +20 -10
- package/lib/cli/doctor-checks/sync-parity.js +65 -140
- package/lib/cli/doctor-checks/test-credit-path.js +69 -28
- package/lib/cli/doctor-checks/toolchain.js +5 -3
- package/lib/cli/registry.js +5 -0
- package/lib/migrations/helpers/retire-agentrc-key.js +3 -3
- package/lib/migrations/index.js +6 -0
- package/lib/migrations/steps/2.91.0-move-shared-crap-capture-script.js +84 -0
- package/lib/migrations/steps/2.91.0-retire-duplication-formats.js +23 -0
- package/lib/migrations/steps/2.91.0-unset-null-lint-command.js +54 -0
- package/package.json +1 -3
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `delivery.quality` resolver. Every `gates.<tier>` shares `enabled`,
|
|
3
|
-
* `baselinePath`, `tolerance` (`{ kind, value }`) and
|
|
4
|
-
* `floors
|
|
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
|
|
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
|
-
/**
|
|
190
|
-
function
|
|
191
|
-
|
|
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
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
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}
|
|
192
|
+
* @param {{ coveragePath: string, captureScript: string }} coverageGate
|
|
204
193
|
* @returns {{ coveragePath: string, captureScript: string, ownCoverageSource: boolean }}
|
|
205
194
|
*/
|
|
206
|
-
function resolveCrapCoverageSource(userCrap,
|
|
195
|
+
function resolveCrapCoverageSource(userCrap, coverageGate) {
|
|
207
196
|
const userPath = nonEmptyString(userCrap?.coveragePath);
|
|
208
|
-
const
|
|
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
|
|
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]
|
|
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 {
|
|
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 =
|
|
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:
|
|
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
|
|
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
|
|
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 [
|
|
393
|
-
defaultsCopy[
|
|
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 [
|
|
394
|
+
for (const [component, axes] of Object.entries(userFloors)) {
|
|
399
395
|
if (axes != null && typeof axes === 'object') {
|
|
400
|
-
defaultsCopy[
|
|
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:
|
|
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. `
|
|
4
|
-
*
|
|
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: '
|
|
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);
|
|
@@ -8,52 +8,18 @@
|
|
|
8
8
|
* worktree and the host reading from the main checkout converge on one file.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { execFileSync } from 'node:child_process';
|
|
12
11
|
import { mkdtempSync } from 'node:fs';
|
|
13
12
|
import os from 'node:os';
|
|
14
13
|
import path from 'node:path';
|
|
15
14
|
|
|
16
15
|
import { reapOnExit } from '../test-temp.js';
|
|
16
|
+
import { _clearGitRootCaches, mainCheckoutRoot } from './git-roots.js';
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
const _mainCheckoutRootCache = new Map();
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Parent of `--git-common-dir`, which is the main checkout root from both the
|
|
23
|
-
* main checkout and any linked worktree. `null` outside a repo.
|
|
24
|
-
*
|
|
25
|
-
* @param {string} [cwd=process.cwd()]
|
|
26
|
-
* @param {{ exec?: typeof execFileSync }} [deps]
|
|
27
|
-
* @returns {string|null}
|
|
28
|
-
*/
|
|
29
|
-
export function mainCheckoutRoot(cwd = process.cwd(), deps = {}) {
|
|
30
|
-
const exec = deps.exec ?? execFileSync;
|
|
31
|
-
// Only the real resolver is memoized.
|
|
32
|
-
const memoize = !deps.exec;
|
|
33
|
-
if (memoize && _mainCheckoutRootCache.has(cwd)) {
|
|
34
|
-
return _mainCheckoutRootCache.get(cwd);
|
|
35
|
-
}
|
|
36
|
-
let resolved = null;
|
|
37
|
-
try {
|
|
38
|
-
const out = exec('git', ['rev-parse', '--git-common-dir'], {
|
|
39
|
-
cwd,
|
|
40
|
-
encoding: 'utf8',
|
|
41
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
42
|
-
}).trim();
|
|
43
|
-
if (out) {
|
|
44
|
-
const commonDir = path.isAbsolute(out) ? out : path.resolve(cwd, out);
|
|
45
|
-
resolved = path.dirname(commonDir);
|
|
46
|
-
}
|
|
47
|
-
} catch {
|
|
48
|
-
resolved = null;
|
|
49
|
-
}
|
|
50
|
-
if (memoize) _mainCheckoutRootCache.set(cwd, resolved);
|
|
51
|
-
return resolved;
|
|
52
|
-
}
|
|
18
|
+
export { mainCheckoutRoot } from './git-roots.js';
|
|
53
19
|
|
|
54
20
|
/** Test-only. */
|
|
55
21
|
export function _clearMainCheckoutRootCache() {
|
|
56
|
-
|
|
22
|
+
_clearGitRootCaches();
|
|
57
23
|
}
|
|
58
24
|
|
|
59
25
|
/**
|
|
@@ -12,14 +12,13 @@ import {
|
|
|
12
12
|
} from './config/agentrc-overlay.js';
|
|
13
13
|
import { getCiDelivery } from './config/ci.js';
|
|
14
14
|
import { getCommands } from './config/commands.js';
|
|
15
|
-
import {
|
|
15
|
+
import { overlayRoot, resolveAgentrcRoot } from './config/git-roots.js';
|
|
16
16
|
import { getGitHub } from './config/github.js';
|
|
17
17
|
import { resolvePaths } from './config/paths.js';
|
|
18
18
|
import { validateOrchestrationConfig } from './config/validate-orchestration.js';
|
|
19
19
|
import { getWorktreeIsolation } from './config/worktree-isolation.js';
|
|
20
20
|
import { getAgentrcValidator } from './config-schema.js';
|
|
21
21
|
import { loadEnv } from './env-loader.js';
|
|
22
|
-
import { PROJECT_ROOT } from './project-root.js';
|
|
23
22
|
|
|
24
23
|
export { getAcceptanceEval } from './config/acceptance-eval.js';
|
|
25
24
|
export { BASELINES_DEFAULTS, getBaselines } from './config/baselines.js';
|
|
@@ -147,7 +146,7 @@ function applyDefaults(raw) {
|
|
|
147
146
|
*/
|
|
148
147
|
function readRawConfig(fsImpl, root) {
|
|
149
148
|
const agentrcPath = path.join(root, '.agentrc.json');
|
|
150
|
-
const localPath = path.join(root, '.agentrc.local.json');
|
|
149
|
+
const localPath = path.join(overlayRoot(root), '.agentrc.local.json');
|
|
151
150
|
const hasAgentrc = fsImpl.existsSync(agentrcPath);
|
|
152
151
|
const hasLocal = fsImpl.existsSync(localPath);
|
|
153
152
|
if (!hasAgentrc) {
|
|
@@ -203,15 +202,13 @@ function ensureEnvLoaded(root) {
|
|
|
203
202
|
/**
|
|
204
203
|
* Returns `{ project, github, planning, delivery, qa?, raw, source }`. A
|
|
205
204
|
* missing file falls back to defaults; malformed JSON or a schema failure
|
|
206
|
-
* throws.
|
|
207
|
-
* shared cache.
|
|
205
|
+
* throws. The root is `resolveAgentrcRoot`'s; `GH_CONFIG_DIR` is gh-exec's. A call
|
|
206
|
+
* with an injected `ctx.fs` neither reads nor fills the shared cache.
|
|
208
207
|
*
|
|
209
208
|
* @param {{ bustCache?: boolean, cwd?: string, validate?: boolean, ctx?: object }} [opts]
|
|
210
209
|
*/
|
|
211
210
|
export function resolveConfig(opts) {
|
|
212
|
-
const root =
|
|
213
|
-
opts?.cwd ?? process.env.AP_AGENTRC_CWD ?? PROJECT_ROOT,
|
|
214
|
-
);
|
|
211
|
+
const root = resolveAgentrcRoot({ cwd: opts?.cwd });
|
|
215
212
|
const validate = opts?.validate !== false;
|
|
216
213
|
const injectedFs = opts?.ctx?.fs;
|
|
217
214
|
const key = `${root}\0${validate}`;
|
|
@@ -223,7 +220,6 @@ export function resolveConfig(opts) {
|
|
|
223
220
|
readRawConfig(injectedFs ?? fs, root),
|
|
224
221
|
validate,
|
|
225
222
|
);
|
|
226
|
-
applyGhConfigDir(resolved.github, root, { fsImpl: injectedFs ?? fs });
|
|
227
223
|
if (!injectedFs) _cacheByKey.set(key, resolved);
|
|
228
224
|
return resolved;
|
|
229
225
|
}
|
|
@@ -30,7 +30,7 @@ const EXECUTION_SCHEMA = {
|
|
|
30
30
|
fullSuiteLock: {
|
|
31
31
|
type: 'boolean',
|
|
32
32
|
description:
|
|
33
|
-
|
|
33
|
+
"Serialize full-suite spawns (`npm test` / the coverage gate's `captureScript`) behind a repository-level advisory lock shared by every worktree, so two concurrent deliveries do not run two suites against the same cores (see `capacity` / `workloads` for declared runs that may overlap). The lock queues, it never overlaps: a wait that expires with a live holder spawns nothing and exits 75 (resumable), naming the holder. A dead or non-heartbeating holder is taken over, and a broken lockfile proceeds unserialized, so the lock can never fail a delivery. Set false — or export `MANDREL_FULL_SUITE_LOCK=0` for one invocation — to disable.",
|
|
34
34
|
default: true,
|
|
35
35
|
},
|
|
36
36
|
capacity: {
|
|
@@ -51,7 +51,7 @@ const EXECUTION_SCHEMA = {
|
|
|
51
51
|
...SAFE_STRING,
|
|
52
52
|
minLength: 1,
|
|
53
53
|
description:
|
|
54
|
-
'The exact suite argv, as `project.commands.test` spells it (or
|
|
54
|
+
'The exact suite argv, as `project.commands.test` spells it (or `<pm> run <captureScript>` for coverage capture).',
|
|
55
55
|
},
|
|
56
56
|
weight: {
|
|
57
57
|
type: 'integer',
|
|
@@ -85,11 +85,12 @@ export const CODE_REVIEW_SCHEMA = {
|
|
|
85
85
|
'native',
|
|
86
86
|
'code-review',
|
|
87
87
|
'codex',
|
|
88
|
+
'llm-review',
|
|
88
89
|
'security-review',
|
|
89
90
|
'ultrareview',
|
|
90
91
|
],
|
|
91
92
|
description:
|
|
92
|
-
'Registered provider key. Inline: native, code-review, codex, security-review. Manual-prompt: ultrareview.',
|
|
93
|
+
'Registered provider key. Inline: native, code-review, codex, llm-review, security-review. Manual-prompt: ultrareview.',
|
|
93
94
|
},
|
|
94
95
|
scopes: {
|
|
95
96
|
type: 'array',
|
|
@@ -132,7 +133,7 @@ export const CODE_REVIEW_SCHEMA = {
|
|
|
132
133
|
additionalProperties: false,
|
|
133
134
|
},
|
|
134
135
|
description:
|
|
135
|
-
"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 `
|
|
136
|
+
"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.",
|
|
136
137
|
default: DEFAULT_REVIEW_PROVIDERS,
|
|
137
138
|
},
|
|
138
139
|
autoFixSeverity: {
|
|
@@ -80,32 +80,31 @@ const PATHS_SCHEMA = {
|
|
|
80
80
|
const COMMANDS_SCHEMA = {
|
|
81
81
|
type: 'object',
|
|
82
82
|
description:
|
|
83
|
-
'Shell commands the close-validation chain spawns
|
|
83
|
+
'Shell commands the close-validation chain spawns, each run from the repo root. One tri-state per key: absent uses the default shown; an explicit `null` disables an optional gate (`typecheck`, `lint`, `formatCheck`) — close reports it as skipped (`<gate>-disabled`) and runs nothing; a string is that command. Like every command here it must be a single argv (no `;`, `&&`, pipes or substitution), so wrap a multi-tool pair in one script and name that.',
|
|
84
84
|
properties: {
|
|
85
85
|
test: {
|
|
86
86
|
...SAFE_STRING,
|
|
87
87
|
minLength: 1,
|
|
88
88
|
description:
|
|
89
|
-
"Full test-suite command close's `test` gate spawns, and the identity its `test` credit is hashed under — the deposit `run-tests.js` makes, close's credit probe and `verify[]` credit all key on it, as does `mandrel doctor`'s `test-credit-path` check. Set it for a non-npm project (e.g. `python3 scripts/validation.py`)
|
|
89
|
+
"Full test-suite command close's `test` gate spawns, and the identity its `test` credit is hashed under — the deposit `run-tests.js` makes, close's credit probe and `verify[]` credit all key on it, as does `mandrel doctor`'s `test-credit-path` check. Set it for a non-npm project (e.g. `python3 scripts/validation.py`). Mandatory: `null` is rejected.",
|
|
90
90
|
default: COMMANDS_DEFAULTS.test,
|
|
91
91
|
},
|
|
92
92
|
typecheck: {
|
|
93
93
|
...NULLABLE_NONEMPTY_SAFE_STRING,
|
|
94
94
|
description:
|
|
95
|
-
'Static type-check command run as a close-validation gate.
|
|
95
|
+
'Static type-check command run as a close-validation gate. An explicit `null` disables the gate for projects with no type layer (skip reason `typecheck-disabled`). The empty string is rejected so a typo cannot silently disable it.',
|
|
96
96
|
default: COMMANDS_DEFAULTS.typecheck,
|
|
97
97
|
},
|
|
98
98
|
lint: {
|
|
99
99
|
...NULLABLE_NONEMPTY_SAFE_STRING,
|
|
100
100
|
description:
|
|
101
|
-
'Lint command run as a close-validation gate
|
|
101
|
+
'Lint command run as a close-validation gate and by the handoff preflight. An explicit `null` disables both (skip reason `lint-disabled`). Point it at the scoped command your hooks already run to stop paying for a third whole-repo lint at close — the gate still lints the diff, and CI still owns whole-repo drift.',
|
|
102
102
|
default: COMMANDS_DEFAULTS.lint,
|
|
103
103
|
},
|
|
104
104
|
formatCheck: {
|
|
105
|
-
...
|
|
106
|
-
minLength: 1,
|
|
105
|
+
...NULLABLE_NONEMPTY_SAFE_STRING,
|
|
107
106
|
description:
|
|
108
|
-
'Non-mutating format verification run as a close-validation gate.',
|
|
107
|
+
'Non-mutating format verification run as a close-validation gate. An explicit `null` disables the gate (skip reason `format-disabled`).',
|
|
109
108
|
default: COMMANDS_DEFAULTS.formatCheck,
|
|
110
109
|
},
|
|
111
110
|
formatWrite: {
|
|
@@ -7,12 +7,13 @@ import fs from 'node:fs';
|
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import picomatch from 'picomatch';
|
|
9
9
|
import { write, writeFile } from './baselines/writer.js';
|
|
10
|
+
import { COVERAGE_CAPTURE_DEFAULTS } from './config/gates/coverage.schema.js';
|
|
10
11
|
import {
|
|
11
12
|
captureStampPath,
|
|
12
13
|
MissingCoverageArtifactError,
|
|
13
14
|
} from './coverage-capture.js';
|
|
14
15
|
|
|
15
|
-
const COVERAGE_FINAL_PATH =
|
|
16
|
+
const COVERAGE_FINAL_PATH = COVERAGE_CAPTURE_DEFAULTS.coveragePath;
|
|
16
17
|
const COVERAGE_BASELINE_PATH = 'baselines/coverage.json';
|
|
17
18
|
// Percentage points; baselines store two decimals.
|
|
18
19
|
export const COVERAGE_TOLERANCE = 0.01;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import fs from 'node:fs';
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import { resolveChangedFilesRef } from './changed-files.js';
|
|
9
|
+
import { COVERAGE_CAPTURE_DEFAULTS } from './config/gates/coverage.schema.js';
|
|
9
10
|
import {
|
|
10
11
|
captureStampPath,
|
|
11
12
|
reportCaptureFailure,
|
|
@@ -19,7 +20,7 @@ import {
|
|
|
19
20
|
} from './coverage-capture-delta.js';
|
|
20
21
|
import { tryIncrementalCapture } from './coverage-capture-incremental.js';
|
|
21
22
|
|
|
22
|
-
const AFFECTED_CAPTURE_SCRIPT =
|
|
23
|
+
const AFFECTED_CAPTURE_SCRIPT = COVERAGE_CAPTURE_DEFAULTS.affectedCaptureScript;
|
|
23
24
|
const COVERAGE_BASE_REF_ENV = 'MANDREL_COVERAGE_BASE_REF';
|
|
24
25
|
|
|
25
26
|
/** A configured scope with no script warns, and the caller runs full scope. */
|
|
@@ -32,7 +33,7 @@ function shouldCaptureAffected({
|
|
|
32
33
|
if (coverage?.captureScope !== 'affected') return false;
|
|
33
34
|
if (hasNpmScriptImpl(scripts, AFFECTED_CAPTURE_SCRIPT)) return true;
|
|
34
35
|
logger.warn(
|
|
35
|
-
`[coverage-capture] ⚠ captureScope is "affected" but package.json has no "${AFFECTED_CAPTURE_SCRIPT}" script — running the full
|
|
36
|
+
`[coverage-capture] ⚠ captureScope is "affected" but package.json has no "${AFFECTED_CAPTURE_SCRIPT}" script — running the full ${coverage.captureScript} capture instead.`,
|
|
36
37
|
);
|
|
37
38
|
return false;
|
|
38
39
|
}
|
|
@@ -163,7 +164,7 @@ function writeMerged({
|
|
|
163
164
|
const scoped = readArtifact(artifactAbs, fsImpl);
|
|
164
165
|
if (scoped === null) {
|
|
165
166
|
logger.error(
|
|
166
|
-
`[coverage-capture] ✖
|
|
167
|
+
`[coverage-capture] ✖ the ${AFFECTED_CAPTURE_SCRIPT} script exited 0 but wrote no readable artifact at ${crap.coveragePath} — point its coverage output there.`,
|
|
167
168
|
);
|
|
168
169
|
return false;
|
|
169
170
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** Full-scope (default) capture path for `coverage-capture.js`. */
|
|
2
|
+
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { resolveChangedFilesRef } from './changed-files.js';
|
|
5
|
+
import { COVERAGE_CAPTURE_DEFAULTS } from './config/gates/coverage.schema.js';
|
|
4
6
|
import {
|
|
5
7
|
anyChangedUnderTargets,
|
|
6
8
|
describeFreshness,
|
|
@@ -96,7 +98,7 @@ export async function runFullScopeCapture({
|
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
logger.info(
|
|
99
|
-
`[coverage-capture] Coverage at ${crap.coveragePath} is ${describeFreshness(freshness, crap.targetDirs)}; running
|
|
101
|
+
`[coverage-capture] Coverage at ${crap.coveragePath} is ${describeFreshness(freshness, crap.targetDirs)}; running the ${crap.captureScript ?? COVERAGE_CAPTURE_DEFAULTS.captureScript} capture script… ${detail}`,
|
|
100
102
|
);
|
|
101
103
|
const tree = snapshotCapturedTree({
|
|
102
104
|
cwd: args.cwd,
|