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