mandrel 2.114.0 → 2.115.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/docs/agentrc-reference.json +1 -0
- package/.agents/docs/configuration.md +10 -4
- package/.agents/schemas/agentrc.schema.json +7 -1
- package/.agents/scripts/acceptance-eval.js +2 -2
- package/.agents/scripts/ceremony-derive.js +15 -2
- package/.agents/scripts/lib/baselines/crap-preview-scan.js +15 -8
- package/.agents/scripts/lib/baselines/crap-preview-touched.js +140 -0
- package/.agents/scripts/lib/baselines/crap-prune.js +86 -0
- package/.agents/scripts/lib/baselines/kinds/crap.js +12 -4
- package/.agents/scripts/lib/baselines/seat-missing.js +1 -1
- package/.agents/scripts/lib/config/gates/coverage.schema.js +1 -1
- package/.agents/scripts/lib/config/gates/crap.schema.js +7 -0
- package/.agents/scripts/lib/config/quality.js +3 -0
- package/.agents/scripts/lib/coverage-capture-delta.js +26 -3
- package/.agents/scripts/lib/coverage-capture-own-fix.js +35 -19
- package/.agents/scripts/lib/coverage-capture.js +62 -14
- package/.agents/scripts/lib/crap-engine.js +3 -5
- package/.agents/scripts/lib/crap-utils.js +12 -2
- package/.agents/scripts/lib/generated/agentrc-validator.js +2 -2
- package/.agents/scripts/lib/git-branch-lifecycle.js +2 -1
- package/.agents/scripts/lib/orchestration/handoff-gates.js +25 -8
- package/.agents/scripts/lib/orchestration/story-handoff.js +131 -41
- package/.agents/scripts/single-story-init.js +43 -5
- package/.agents/scripts/story-handoff.js +6 -2
- package/.agents/workflows/helpers/deliver-digest.md +3 -3
- package/.agents/workflows/helpers/deliver-reference.md +13 -4
- package/docs/CHANGELOG.md +13 -0
- package/package.json +1 -1
|
@@ -137,7 +137,8 @@ export function seedStoryBranchRef({
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
progress('GIT', messages.create(storyBranch, baseRef));
|
|
140
|
-
|
|
140
|
+
// --no-track: a remote base ref must not become the Story's upstream.
|
|
141
|
+
const r = spawn(['branch', '--no-track', storyBranch, baseRef]);
|
|
141
142
|
if (r.status !== 0) {
|
|
142
143
|
const stderr = r.stderr || r.stdout || '';
|
|
143
144
|
if (swallowCreateRace && /already exists/i.test(stderr)) {
|
|
@@ -66,7 +66,7 @@ function holdsLint(ctx, gate) {
|
|
|
66
66
|
|
|
67
67
|
/** The argv a preflight check runs: bare when held, else deposited. */
|
|
68
68
|
function preflightArgv(ctx, gate, run) {
|
|
69
|
-
if (holdsLint(ctx, gate)) {
|
|
69
|
+
if (ctx.reportAll || holdsLint(ctx, gate)) {
|
|
70
70
|
return { cmd: run.cmd, args: run.args, held: true };
|
|
71
71
|
}
|
|
72
72
|
return {
|
|
@@ -100,6 +100,21 @@ function isWholeTreeLint(gate, run) {
|
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
/** Close's artifact-free baseline compare, as a preflight check. */
|
|
104
|
+
export function baselineComparePreflight(ctx) {
|
|
105
|
+
return closeGates(ctx)
|
|
106
|
+
.filter((g) => g.name === BASELINES_GATE_NAMES.independent && !g.skip)
|
|
107
|
+
.map((gate) => ({
|
|
108
|
+
key: gate.name,
|
|
109
|
+
label: describeGate(gate),
|
|
110
|
+
cmd: gate.cmd,
|
|
111
|
+
args: gate.args,
|
|
112
|
+
env: gate.env,
|
|
113
|
+
scoresDuplication: scoresDuplication(gate),
|
|
114
|
+
baselineRef: gate.env?.BASELINE_REF,
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
|
|
103
118
|
/**
|
|
104
119
|
* Close's preflight entries wrapped in `evidence-gate.js` with the argv close
|
|
105
120
|
* executes; a disabled or scoped-out gate deposits nothing.
|
|
@@ -259,8 +274,9 @@ export function seatableKinds(ctx, kinds) {
|
|
|
259
274
|
}
|
|
260
275
|
|
|
261
276
|
/**
|
|
262
|
-
* `quality-preview-crap` (capture
|
|
263
|
-
*
|
|
277
|
+
* The coverage-reading half of close's list: `quality-preview-crap` (capture
|
|
278
|
+
* depositor only) and the baselines entries that read the artifact, none
|
|
279
|
+
* after a deferral. The artifact-free compare runs at preflight.
|
|
264
280
|
*/
|
|
265
281
|
function postCaptureGates(ctx) {
|
|
266
282
|
const names = new Set(Object.values(BASELINES_GATE_NAMES));
|
|
@@ -271,10 +287,10 @@ function postCaptureGates(ctx) {
|
|
|
271
287
|
return closeGates(ctx).filter(keep);
|
|
272
288
|
}
|
|
273
289
|
|
|
274
|
-
/** A registered, unskipped
|
|
290
|
+
/** A registered, unskipped artifact reader; none after a deferral. */
|
|
275
291
|
function postCaptureFilter(names, deferred) {
|
|
276
292
|
return (g) =>
|
|
277
|
-
names.has(g.name) && !g.skip && !
|
|
293
|
+
names.has(g.name) && !g.skip && !deferred && g.readsCoverageArtifact;
|
|
278
294
|
}
|
|
279
295
|
|
|
280
296
|
/** The kinds a baselines entry scores; `null` without `--gate` (every kind). */
|
|
@@ -306,9 +322,10 @@ function failure(gate, res) {
|
|
|
306
322
|
};
|
|
307
323
|
}
|
|
308
324
|
|
|
309
|
-
/** Run
|
|
325
|
+
/** Run every post-capture gate through `run`; each non-zero exit is a finding. */
|
|
310
326
|
export async function scorePostCapture(ctx, run) {
|
|
311
327
|
const gates = postCaptureGates(ctx);
|
|
328
|
+
const failures = [];
|
|
312
329
|
for (const gate of gates) {
|
|
313
330
|
const env = gate.env ? { ...ctx.env, ...gate.env } : undefined;
|
|
314
331
|
const res = await run(
|
|
@@ -317,7 +334,7 @@ export async function scorePostCapture(ctx, run) {
|
|
|
317
334
|
gate.args,
|
|
318
335
|
env,
|
|
319
336
|
);
|
|
320
|
-
if (res.status !== 0)
|
|
337
|
+
if (res.status !== 0) failures.push(failure(gate, res));
|
|
321
338
|
}
|
|
322
|
-
return { gates,
|
|
339
|
+
return { gates, failures };
|
|
323
340
|
}
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
import fs from 'node:fs';
|
|
23
23
|
import path from 'node:path';
|
|
24
24
|
import { fileURLToPath } from 'node:url';
|
|
25
|
-
|
|
25
|
+
import { pruneStaleCrapRows } from '../baselines/crap-prune.js';
|
|
26
|
+
import { isCaptureFresh, SeatRefusal } from '../baselines/seat-missing.js';
|
|
26
27
|
import { spawnStreamAsync } from '../child-exec.js';
|
|
27
28
|
import {
|
|
28
29
|
createLockEventChannel,
|
|
@@ -30,12 +31,14 @@ import {
|
|
|
30
31
|
} from '../close-lock-events.js';
|
|
31
32
|
import { resolveTestGateArgv } from '../close-validation/commands.js';
|
|
32
33
|
import {
|
|
34
|
+
BASELINES_GATE_NAMES,
|
|
33
35
|
isCrapGateEnabled,
|
|
34
36
|
resolveCreditedDepositor,
|
|
35
37
|
} from '../close-validation/gates.js';
|
|
36
38
|
import { isBiomeNoFilesProcessed } from '../close-validation/process.js';
|
|
37
39
|
import { applyChangedFileScope } from '../close-validation/runner.js';
|
|
38
40
|
import { skipBranchDeposit } from '../close-validation/skip-branch-test.js';
|
|
41
|
+
import { getBaselines } from '../config/baselines.js';
|
|
39
42
|
import { getPostSeatChecks } from '../config/handoff.js';
|
|
40
43
|
import { getQuality } from '../config/quality.js';
|
|
41
44
|
import {
|
|
@@ -72,6 +75,7 @@ import { defaultSleep } from '../util/sleep.js';
|
|
|
72
75
|
import { hashCommandConfig } from '../validation-evidence.js';
|
|
73
76
|
import { runStreamed } from './evidence-stream.js';
|
|
74
77
|
import {
|
|
78
|
+
baselineComparePreflight,
|
|
75
79
|
carryCoverageDeferral,
|
|
76
80
|
carryCredit,
|
|
77
81
|
carryPreflightCredits,
|
|
@@ -346,8 +350,8 @@ function describeSuiteFailure(status) {
|
|
|
346
350
|
}
|
|
347
351
|
|
|
348
352
|
/**
|
|
349
|
-
* Typecheck, lint and format (deposited), quality-preview,
|
|
350
|
-
* baseline is committed.
|
|
353
|
+
* Typecheck, lint and format (deposited), quality-preview, each ratchet whose
|
|
354
|
+
* baseline is committed, then close's artifact-free baseline compare.
|
|
351
355
|
*
|
|
352
356
|
* @param {object} ctx
|
|
353
357
|
* @returns {Array<{ key: string, cmd: string, args: string[], gated?: boolean, deposit?: object }>}
|
|
@@ -375,6 +379,7 @@ function preflightChecks(ctx) {
|
|
|
375
379
|
],
|
|
376
380
|
},
|
|
377
381
|
...ratchets,
|
|
382
|
+
...baselineComparePreflight(ctx),
|
|
378
383
|
];
|
|
379
384
|
}
|
|
380
385
|
|
|
@@ -400,7 +405,7 @@ function preflightFinding(check, run) {
|
|
|
400
405
|
.slice(0, MAX_OFFENDING_LINES)
|
|
401
406
|
: extractFailureRows(run.output, { max: MAX_OFFENDING_LINES });
|
|
402
407
|
const rows = offending.length > 0 ? `: ${offending.join('; ')}` : '';
|
|
403
|
-
return `${check.key}${check.gated ? ' ratchet' : ''} finding${rows} — fix and commit, then re-run`;
|
|
408
|
+
return `${check.label ?? check.key}${check.gated ? ' ratchet' : ''} finding${rows} — fix and commit, then re-run`;
|
|
404
409
|
}
|
|
405
410
|
|
|
406
411
|
/**
|
|
@@ -463,7 +468,10 @@ async function stepPreflight(ctx) {
|
|
|
463
468
|
|
|
464
469
|
/** A baselined ratchet's finding is a `ratchet`; any other check is its own key. */
|
|
465
470
|
function preflightCause(key) {
|
|
466
|
-
return
|
|
471
|
+
return key === BASELINES_GATE_NAMES.independent ||
|
|
472
|
+
STANDALONE_RATCHETS.some((r) => r.key === key)
|
|
473
|
+
? 'ratchet'
|
|
474
|
+
: key;
|
|
467
475
|
}
|
|
468
476
|
|
|
469
477
|
/**
|
|
@@ -487,7 +495,7 @@ async function runPreflightCheck(ctx, check, pass, env) {
|
|
|
487
495
|
`preflight-${check.key}`,
|
|
488
496
|
check.cmd,
|
|
489
497
|
check.args,
|
|
490
|
-
env,
|
|
498
|
+
check.env ? { ...(env ?? ctx.env), ...check.env } : env,
|
|
491
499
|
);
|
|
492
500
|
const finding = preflightFinding(check, run);
|
|
493
501
|
if (check.key === 'lint') pass.lint = finding ? 'failed' : 'passed';
|
|
@@ -495,7 +503,10 @@ async function runPreflightCheck(ctx, check, pass, env) {
|
|
|
495
503
|
creditCheck(ctx, check);
|
|
496
504
|
return null;
|
|
497
505
|
}
|
|
498
|
-
const detail =
|
|
506
|
+
const detail =
|
|
507
|
+
finding +
|
|
508
|
+
raisedDuplicationSuffix(ctx, check, MAX_OFFENDING_LINES) +
|
|
509
|
+
seatHint(ctx, check);
|
|
499
510
|
return { check: check.key, detail, evidencePath: run.evidencePath };
|
|
500
511
|
}
|
|
501
512
|
|
|
@@ -943,6 +954,30 @@ function seatsCoverage(ctx) {
|
|
|
943
954
|
);
|
|
944
955
|
}
|
|
945
956
|
|
|
957
|
+
/**
|
|
958
|
+
* Drop the stale CRAP rows of change-set files; a refusal stops the step.
|
|
959
|
+
*
|
|
960
|
+
* @returns {Promise<StepResult|{ total: number }>}
|
|
961
|
+
*/
|
|
962
|
+
async function pruneCrapRows(ctx, name) {
|
|
963
|
+
if (!isCrapGateEnabled(ctx.config)) return { total: 0 };
|
|
964
|
+
try {
|
|
965
|
+
const { pruned } = await ctx.pruneStaleCrap({
|
|
966
|
+
writePath: path.resolve(ctx.cwd, getBaselines(ctx.config).crap.path),
|
|
967
|
+
baseRef: `origin/${ctx.baseBranch}`,
|
|
968
|
+
cwd: ctx.cwd,
|
|
969
|
+
});
|
|
970
|
+
ctx.progress(name, `pruned ${pruned} stale CRAP row(s)`);
|
|
971
|
+
return { total: pruned };
|
|
972
|
+
} catch (err) {
|
|
973
|
+
if (!(err instanceof SeatRefusal)) throw err;
|
|
974
|
+
return fixRequired(name, err.message, {
|
|
975
|
+
evidencePath: ctx.writeEvidence('seat-prune', err.message),
|
|
976
|
+
cause: 'seat-refused',
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
946
981
|
/** Static MI needs no capture, so its seat runs before preflight. */
|
|
947
982
|
function staticSeatKinds(config) {
|
|
948
983
|
const mi = config?.delivery?.quality?.gates?.maintainability?.enabled;
|
|
@@ -954,8 +989,11 @@ async function seatAndCommit(ctx, kinds, step) {
|
|
|
954
989
|
if (ctx.state[step.headKey] === ctx.head) {
|
|
955
990
|
return creditSkip(step.name, `nothing to seat at ${ctx.head.slice(0, 12)}`);
|
|
956
991
|
}
|
|
957
|
-
const
|
|
958
|
-
if (
|
|
992
|
+
const seats = await runSeats(ctx, step.name, kinds);
|
|
993
|
+
if (seats.stop) return seats;
|
|
994
|
+
const pruned = step.prune ? await step.prune(ctx, step.name) : { total: 0 };
|
|
995
|
+
if (pruned.stop) return pruned;
|
|
996
|
+
const seated = { ...seats, total: seats.total + pruned.total };
|
|
959
997
|
if (seated.total === 0) {
|
|
960
998
|
ctx.state[step.headKey] = ctx.head;
|
|
961
999
|
return skipped(step.name, 'seated: 0 — nothing to seat', {
|
|
@@ -970,6 +1008,7 @@ function stepSeatStatic(ctx) {
|
|
|
970
1008
|
return seatAndCommit(ctx, staticSeatKinds(ctx.config), {
|
|
971
1009
|
name: 'seat-static',
|
|
972
1010
|
headKey: 'staticSeatHead',
|
|
1011
|
+
prune: pruneCrapRows,
|
|
973
1012
|
});
|
|
974
1013
|
}
|
|
975
1014
|
|
|
@@ -1331,40 +1370,48 @@ async function stepPostCapture(ctx) {
|
|
|
1331
1370
|
if (postCaptureHead === ctx.head && postCaptureSettled(ctx)) {
|
|
1332
1371
|
return creditSkip(name, `already clean at ${ctx.head.slice(0, 12)}`);
|
|
1333
1372
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
);
|
|
1337
|
-
if (failed) {
|
|
1338
|
-
const rows = raisedDuplicationSuffix(ctx, failed, MAX_OFFENDING_LINES);
|
|
1339
|
-
return fixRequired(name, `${failed.finding}${rows}`, {
|
|
1340
|
-
evidencePath: failed.evidencePath,
|
|
1341
|
-
gate: failed.gate,
|
|
1342
|
-
cause: 'post-capture',
|
|
1343
|
-
});
|
|
1373
|
+
if (ctx.reportAll && !hasFreshArtifact(ctx)) {
|
|
1374
|
+
return skipped(name, 'no fresh coverage artifact to score');
|
|
1344
1375
|
}
|
|
1345
|
-
const
|
|
1346
|
-
|
|
1376
|
+
const run = (...a) => runLogged(ctx, ...a);
|
|
1377
|
+
const { gates, failures } = await scorePostCapture(ctx, run);
|
|
1378
|
+
const post = await runPostSeatChecks(ctx, run);
|
|
1379
|
+
const findings = [...failures, ...post.failures];
|
|
1380
|
+
if (findings.length > 0) return postCaptureFixRequired(ctx, name, findings);
|
|
1347
1381
|
ctx.state.postCaptureHead = ctx.head;
|
|
1348
1382
|
return settledPostCapture(name, gates, post);
|
|
1349
1383
|
}
|
|
1350
1384
|
|
|
1385
|
+
/** Whether any capture stamp vouches for the CRAP artifact at this tree. */
|
|
1386
|
+
function hasFreshArtifact(ctx) {
|
|
1387
|
+
const { coveragePath, targetDirs } = getQuality(ctx.config).crap;
|
|
1388
|
+
return ctx.isCaptureFresh({ coveragePath, targetDirs }, { cwd: ctx.cwd });
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
/** Why the post-seat checks do not run; a `--report-all` run seats nothing. */
|
|
1392
|
+
function postSeatSkipReason(ctx) {
|
|
1393
|
+
if (ctx.reportAll) return 'report-all seats nothing';
|
|
1394
|
+
return isCoverageDeferred(ctx) ? 'coverage deferred' : null;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1351
1397
|
/**
|
|
1352
|
-
* Run
|
|
1353
|
-
* non-zero exit is
|
|
1398
|
+
* Run every `delivery.handoff.postSeatChecks` entry through `run`; each
|
|
1399
|
+
* non-zero exit is a finding, and a clean set releases the held lint.
|
|
1354
1400
|
*
|
|
1355
|
-
* @returns {Promise<{ checks: object[], skipped?:
|
|
1401
|
+
* @returns {Promise<{ checks: object[], skipped?: string, failures: object[] }>}
|
|
1356
1402
|
*/
|
|
1357
1403
|
async function runPostSeatChecks(ctx, run) {
|
|
1358
1404
|
const checks = getPostSeatChecks(ctx.config);
|
|
1359
|
-
if (checks.length === 0) return { checks,
|
|
1360
|
-
|
|
1405
|
+
if (checks.length === 0) return { checks, failures: [] };
|
|
1406
|
+
const skipReason = postSeatSkipReason(ctx);
|
|
1407
|
+
if (skipReason) return { checks, skipped: skipReason, failures: [] };
|
|
1408
|
+
const failures = [];
|
|
1361
1409
|
for (const [i, check] of checks.entries()) {
|
|
1362
1410
|
const res = await run(`post-seat-${i + 1}`, check.cmd, check.args);
|
|
1363
|
-
if (res.status !== 0)
|
|
1364
|
-
return { checks, failed: postSeatFailure(check, res) };
|
|
1411
|
+
if (res.status !== 0) failures.push(postSeatFailure(check, res));
|
|
1365
1412
|
}
|
|
1366
|
-
releaseHeldLint(ctx);
|
|
1367
|
-
return { checks,
|
|
1413
|
+
if (failures.length === 0) releaseHeldLint(ctx);
|
|
1414
|
+
return { checks, failures };
|
|
1368
1415
|
}
|
|
1369
1416
|
|
|
1370
1417
|
/** A failed post-seat check as the handoff's finding. */
|
|
@@ -1377,11 +1424,17 @@ function postSeatFailure(check, res) {
|
|
|
1377
1424
|
};
|
|
1378
1425
|
}
|
|
1379
1426
|
|
|
1380
|
-
/**
|
|
1381
|
-
function
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1427
|
+
/** One `fix-required` listing every post-capture finding, in run order. */
|
|
1428
|
+
function postCaptureFixRequired(ctx, name, failed) {
|
|
1429
|
+
const findings = failed.map((f) => ({
|
|
1430
|
+
check: f.gate,
|
|
1431
|
+
detail: `${f.finding}${raisedDuplicationSuffix(ctx, f, MAX_OFFENDING_LINES)}`,
|
|
1432
|
+
evidencePath: f.evidencePath,
|
|
1433
|
+
}));
|
|
1434
|
+
return fixRequired(name, findings.map((f) => f.detail).join('\n'), {
|
|
1435
|
+
evidencePath: findings[0].evidencePath,
|
|
1436
|
+
gate: findings[0].check,
|
|
1437
|
+
findings,
|
|
1385
1438
|
cause: 'post-capture',
|
|
1386
1439
|
});
|
|
1387
1440
|
}
|
|
@@ -1392,7 +1445,7 @@ function settledPostCapture(name, gates, post) {
|
|
|
1392
1445
|
if (post.checks.length > 0) {
|
|
1393
1446
|
names.push(
|
|
1394
1447
|
post.skipped
|
|
1395
|
-
?
|
|
1448
|
+
? `post-seat checks skipped (${post.skipped})`
|
|
1396
1449
|
: `${post.checks.length} post-seat check(s)`,
|
|
1397
1450
|
);
|
|
1398
1451
|
}
|
|
@@ -1441,6 +1494,9 @@ function stepOrder(depositor) {
|
|
|
1441
1494
|
];
|
|
1442
1495
|
}
|
|
1443
1496
|
|
|
1497
|
+
/** `--report-all`: the steps that spawn no suite and write nothing. */
|
|
1498
|
+
const REPORT_ALL_STEPS = Object.freeze([stepPreflight, stepPostCapture]);
|
|
1499
|
+
|
|
1444
1500
|
/** `run`'s results, each carrying the call's wall time as `durationMs`. */
|
|
1445
1501
|
async function timed(ctx, run) {
|
|
1446
1502
|
const startedAt = ctx.now();
|
|
@@ -1459,11 +1515,15 @@ function envelopeStep(ctx, { stop: _stop, ...rest }) {
|
|
|
1459
1515
|
|
|
1460
1516
|
/**
|
|
1461
1517
|
* Run the steps in order into `steps`; a step may settle several results.
|
|
1518
|
+
* A `--report-all` run continues past every finding and always ends
|
|
1519
|
+
* `fix-required`: nothing it did makes the branch ready to hand off.
|
|
1462
1520
|
*
|
|
1463
1521
|
* @returns {Promise<StepResult|null>} the result that stopped the run.
|
|
1464
1522
|
*/
|
|
1465
1523
|
async function runSteps(ctx, steps) {
|
|
1466
|
-
|
|
1524
|
+
const order = ctx.reportAll ? REPORT_ALL_STEPS : stepOrder(ctx.depositor);
|
|
1525
|
+
let first = null;
|
|
1526
|
+
for (const step of order) {
|
|
1467
1527
|
ctx.stepName = handoffStepName(step);
|
|
1468
1528
|
ctx.storyProgress.phase(ctx.stepName);
|
|
1469
1529
|
const results = await timed(ctx, async () => [await step(ctx)].flat());
|
|
@@ -1472,9 +1532,29 @@ async function runSteps(ctx, steps) {
|
|
|
1472
1532
|
ctx.progress(result.name, `${result.outcome} — ${result.detail}`);
|
|
1473
1533
|
}
|
|
1474
1534
|
const stop = results.find((r) => r.stop);
|
|
1475
|
-
if (stop) return stop;
|
|
1535
|
+
if (stop && !ctx.reportAll) return stop;
|
|
1536
|
+
first ??= stop ?? null;
|
|
1476
1537
|
}
|
|
1477
|
-
return
|
|
1538
|
+
if (!ctx.reportAll || first) return first;
|
|
1539
|
+
const none = fixRequired(
|
|
1540
|
+
'report-all',
|
|
1541
|
+
'no findings in the non-suite steps; nothing was credited, seated or pushed, so run without --report-all to hand off',
|
|
1542
|
+
{ cause: 'other' },
|
|
1543
|
+
);
|
|
1544
|
+
steps.push(none);
|
|
1545
|
+
return none;
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
/** Every finding the steps settled; a step without a list is one finding. */
|
|
1549
|
+
function reportAllFindings(steps) {
|
|
1550
|
+
return steps
|
|
1551
|
+
.filter((s) => s.stop)
|
|
1552
|
+
.flatMap(
|
|
1553
|
+
(s) =>
|
|
1554
|
+
s.findings ?? [
|
|
1555
|
+
{ check: s.name, detail: s.detail, evidencePath: s.evidencePath },
|
|
1556
|
+
],
|
|
1557
|
+
);
|
|
1478
1558
|
}
|
|
1479
1559
|
|
|
1480
1560
|
const PRECHECK = Object.freeze({ cause: 'precheck' });
|
|
@@ -1574,7 +1654,7 @@ async function defaultBlock({
|
|
|
1574
1654
|
}
|
|
1575
1655
|
|
|
1576
1656
|
/**
|
|
1577
|
-
* @param {{ storyId: number, cwd: string, config: object }} input
|
|
1657
|
+
* @param {{ storyId: number, cwd: string, config: object, reportAll?: boolean }} input
|
|
1578
1658
|
* @param {{
|
|
1579
1659
|
* git?: typeof gitSpawn,
|
|
1580
1660
|
* runCommand?: (cmd: string, args: string[], opts: { cwd: string }) => Promise<{ status: number, stdout: string, stderr: string, timedOut?: boolean }>,
|
|
@@ -1611,7 +1691,10 @@ async function defaultBlock({
|
|
|
1611
1691
|
* still gets its whole output written at settle.
|
|
1612
1692
|
* @returns {Promise<{ envelope: object, exitCode: number }>}
|
|
1613
1693
|
*/
|
|
1614
|
-
export async function runStoryHandoff(
|
|
1694
|
+
export async function runStoryHandoff(
|
|
1695
|
+
{ storyId, cwd, config, reportAll = false },
|
|
1696
|
+
deps,
|
|
1697
|
+
) {
|
|
1615
1698
|
const {
|
|
1616
1699
|
git = gitSpawn,
|
|
1617
1700
|
runCommand = spawnStreamAsync,
|
|
@@ -1639,6 +1722,8 @@ export async function runStoryHandoff({ storyId, cwd, config }, deps) {
|
|
|
1639
1722
|
runDuplicationRescore = runDuplicationCloseRescore,
|
|
1640
1723
|
emitFriction = emitRuntimeFriction,
|
|
1641
1724
|
admitSuite = withSuiteAdmission,
|
|
1725
|
+
pruneStaleCrap = pruneStaleCrapRows,
|
|
1726
|
+
isCaptureFreshFn = isCaptureFresh,
|
|
1642
1727
|
writeSignal,
|
|
1643
1728
|
readSignals,
|
|
1644
1729
|
} = deps;
|
|
@@ -1685,6 +1770,9 @@ export async function runStoryHandoff({ storyId, cwd, config }, deps) {
|
|
|
1685
1770
|
runDuplicationRescore,
|
|
1686
1771
|
emitFriction,
|
|
1687
1772
|
admitSuite,
|
|
1773
|
+
pruneStaleCrap,
|
|
1774
|
+
isCaptureFresh: isCaptureFreshFn,
|
|
1775
|
+
reportAll,
|
|
1688
1776
|
state: readState(statePath, progress),
|
|
1689
1777
|
review: null,
|
|
1690
1778
|
reviewPending: null,
|
|
@@ -1777,7 +1865,9 @@ export async function runStoryHandoff({ storyId, cwd, config }, deps) {
|
|
|
1777
1865
|
}
|
|
1778
1866
|
: {}),
|
|
1779
1867
|
attempt: await nextHandoffAttempt({ storyId, config, readFn: readSignals }),
|
|
1868
|
+
...(reportAll ? { reportAll, findings: reportAllFindings(steps) } : {}),
|
|
1780
1869
|
};
|
|
1870
|
+
if (reportAll) return { envelope, exitCode: EXIT_CODES[status] };
|
|
1781
1871
|
writeFileAtomic(
|
|
1782
1872
|
statePath,
|
|
1783
1873
|
`${JSON.stringify({ state: ctx.state, envelope }, null, 2)}\n`,
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
planFastForward,
|
|
43
43
|
} from './lib/orchestration/git-cleanup/phases/fast-forward.js';
|
|
44
44
|
import { verifyRemote } from './lib/orchestration/remote-verifier.js';
|
|
45
|
+
import { resolveSharedBaseRef } from './lib/orchestration/review-base-ref.js';
|
|
45
46
|
import {
|
|
46
47
|
acquireStoryLease,
|
|
47
48
|
releaseStoryLease,
|
|
@@ -448,6 +449,7 @@ export async function materializeBaseBranch({
|
|
|
448
449
|
`Fetch completed after ${fetchResult.attempts} attempt(s) — packed-refs contention.`,
|
|
449
450
|
);
|
|
450
451
|
}
|
|
452
|
+
deepenShallowClone({ cwd, baseBranch, progress });
|
|
451
453
|
|
|
452
454
|
const { worktreeSweep } = await reapMergedStoryBranches({
|
|
453
455
|
cwd,
|
|
@@ -469,12 +471,47 @@ export async function materializeBaseBranch({
|
|
|
469
471
|
return { worktreeSweep };
|
|
470
472
|
}
|
|
471
473
|
|
|
472
|
-
|
|
474
|
+
reconcileLocalBase({ cwd, baseBranch, progress });
|
|
473
475
|
return { worktreeSweep };
|
|
474
476
|
}
|
|
475
477
|
|
|
478
|
+
/**
|
|
479
|
+
* Merge-base probes are meaningless against a truncated history.
|
|
480
|
+
*
|
|
481
|
+
* @param {{ cwd: string, baseBranch: string, progress: Function }} opts
|
|
482
|
+
*/
|
|
483
|
+
function deepenShallowClone({ cwd, baseBranch, progress }) {
|
|
484
|
+
const probe = gitSpawn(cwd, 'rev-parse', '--is-shallow-repository');
|
|
485
|
+
if (String(probe.stdout ?? '').trim() !== 'true') return;
|
|
486
|
+
progress('GIT', `Shallow clone — deepening from origin/${baseBranch}.`);
|
|
487
|
+
const r = gitSpawn(cwd, 'fetch', '--unshallow', 'origin', baseBranch);
|
|
488
|
+
if (r.status !== 0) {
|
|
489
|
+
throw new Error(
|
|
490
|
+
`\`git fetch --unshallow origin ${baseBranch}\` failed: ${r.stderr || '(no stderr)'}`,
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* A base with no history in common cannot fast-forward: warn once and move on.
|
|
497
|
+
*
|
|
498
|
+
* @param {{ cwd: string, baseBranch: string, progress: Function }} opts
|
|
499
|
+
*/
|
|
500
|
+
function reconcileLocalBase({ cwd, baseBranch, progress }) {
|
|
501
|
+
const probe = gitSpawn(cwd, 'merge-base', baseBranch, `origin/${baseBranch}`);
|
|
502
|
+
if (probe.status === 1) {
|
|
503
|
+
progress(
|
|
504
|
+
'GIT',
|
|
505
|
+
`⚠️ local ${baseBranch} shares no history with origin/${baseBranch}; leaving it as is.`,
|
|
506
|
+
);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
fastForwardBase({ cwd, baseBranch, progress });
|
|
510
|
+
}
|
|
511
|
+
|
|
476
512
|
/**
|
|
477
513
|
* `git fetch` leaves local base at the old tip until fast-forwarded.
|
|
514
|
+
* Best-effort: the Story branch seeds from the remote base regardless.
|
|
478
515
|
*
|
|
479
516
|
* @param {{ cwd: string, baseBranch: string, progress: Function }} opts
|
|
480
517
|
*/
|
|
@@ -497,7 +534,7 @@ function fastForwardBase({ cwd, baseBranch, progress }) {
|
|
|
497
534
|
} else if (ff.reason === 'not-fast-forward') {
|
|
498
535
|
progress(
|
|
499
536
|
'GIT',
|
|
500
|
-
`⚠️ local ${baseBranch} is not a fast-forward behind origin/${baseBranch};
|
|
537
|
+
`⚠️ local ${baseBranch} is not a fast-forward behind origin/${baseBranch}; leaving it as is.`,
|
|
501
538
|
);
|
|
502
539
|
} else if (ff.reason === 'dirty-tree') {
|
|
503
540
|
progress(
|
|
@@ -508,8 +545,9 @@ function fastForwardBase({ cwd, baseBranch, progress }) {
|
|
|
508
545
|
}
|
|
509
546
|
|
|
510
547
|
/**
|
|
511
|
-
* Idempotent seed
|
|
512
|
-
*
|
|
548
|
+
* Idempotent seed from `origin/<base>`, or the local base when no remote ref
|
|
549
|
+
* resolves. Assumes `materializeBaseBranch` already fetched, so tracking refs
|
|
550
|
+
* are authoritative (no `ls-remote`).
|
|
513
551
|
*
|
|
514
552
|
* @param {object} opts
|
|
515
553
|
* @param {string} opts.cwd
|
|
@@ -521,7 +559,7 @@ export function seedStoryBranch({ cwd, storyBranch, baseBranch, progress }) {
|
|
|
521
559
|
// No concurrent creator to race here, so create failures are fatal.
|
|
522
560
|
seedStoryBranchRef({
|
|
523
561
|
storyBranch,
|
|
524
|
-
baseRef: baseBranch,
|
|
562
|
+
baseRef: resolveSharedBaseRef({ baseBranch, cwd }).ref ?? baseBranch,
|
|
525
563
|
swallowCreateRace: false,
|
|
526
564
|
spawn: (args) => gitSpawn(cwd, ...args),
|
|
527
565
|
existsLocally: (b) => branchExistsLocally(b, cwd),
|
|
@@ -24,12 +24,16 @@ import { computeStoryReviewDeposit } from './story-review-compute.js';
|
|
|
24
24
|
|
|
25
25
|
const USAGE = {
|
|
26
26
|
invocation:
|
|
27
|
-
'node .agents/scripts/story-handoff.js --story <id> [--cwd <workCwd>]',
|
|
27
|
+
'node .agents/scripts/story-handoff.js --story <id> [--cwd <workCwd>] [--report-all]',
|
|
28
28
|
summary:
|
|
29
29
|
"Run the story-worker's post-implementation tail — base merge, duplication re-score, preflight, the one credited run, baseline seating, push and held review — and print one envelope: ready (exit 0), fix-required (exit 2) or blocked (exit 1).",
|
|
30
30
|
flags: [
|
|
31
31
|
['--story <id>', 'Story issue number; the branch is story-<id>.'],
|
|
32
32
|
['--cwd <path>', "The Story's worktree (default: the current directory)."],
|
|
33
|
+
[
|
|
34
|
+
'--report-all',
|
|
35
|
+
'List every finding from preflight and post-capture in one fix-required envelope: spawns no suite, records no credit, seats, commits and pushes nothing, and runs no review.',
|
|
36
|
+
],
|
|
33
37
|
],
|
|
34
38
|
notes: [
|
|
35
39
|
'Exit codes:\n 0 ready — hand off\n 2 fix-required — fix, commit, re-run (labels untouched)\n 1 blocked — agent::blocked + friction comment, or a usage error',
|
|
@@ -67,7 +71,7 @@ export async function runStoryHandoffCli(
|
|
|
67
71
|
const workCwd = cwd ?? defaultCwd;
|
|
68
72
|
const config = resolveConfigImpl({ cwd: workCwd });
|
|
69
73
|
const outcome = await runHandoffImpl(
|
|
70
|
-
{ storyId, cwd: workCwd, config },
|
|
74
|
+
{ storyId, cwd: workCwd, config, reportAll: argv.includes('--report-all') },
|
|
71
75
|
{
|
|
72
76
|
computeReview: computeStoryReviewDeposit,
|
|
73
77
|
createProviderFn: createProvider,
|
|
@@ -111,9 +111,9 @@ driver or `host-resources` (exit 77): it flips `agent::blocked` and posts
|
|
|
111
111
|
**first**, ahead of every check: close's base-sync then no-ops. Then close's **duplication re-score**, committed
|
|
112
112
|
**untagged** before any credit.
|
|
113
113
|
2. **Preflight — blocking.** `typecheck`/`lint`/`format` (close's credit),
|
|
114
|
-
`quality-preview.js --changed-since origin/<baseBranch>`,
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
`quality-preview.js --changed-since origin/<baseBranch>`, each baselined
|
|
115
|
+
ratchet, `check-baselines`; one `fix-required` lists all. Serial unless
|
|
116
|
+
per-host `.agentrc.local.json` sets `delivery.execution.preflightConcurrency`
|
|
117
117
|
above 1 (default 1): close's independent gates then run in admitted
|
|
118
118
|
lanes beside the base lane — [`deliver-reference.md`](deliver-reference.md) § Preflight.
|
|
119
119
|
3. **One depositor**, by the one predicate close registers `coverage-capture`
|
|
@@ -493,10 +493,10 @@ Digest § 5 states the rule and both invocations; this is what surrounds them.
|
|
|
493
493
|
`captureScope: affected`, it re-measures only the delta when HEAD's
|
|
494
494
|
first-parent chain splits into base-sync merges sharing no suite input or
|
|
495
495
|
config with the Story and own commits touching at most `N` suite-input
|
|
496
|
-
files, with no config, no deleted or renamed suite input, no
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
496
|
+
files, with no config, no deleted or renamed suite input, no test
|
|
497
|
+
file and none reachable from the base. Any other shape logs
|
|
498
|
+
`delta refresh not eligible (own-fix: …)` and captures as before. Rows
|
|
499
|
+
outside the delta are kept and can go stale either way, so validate against
|
|
500
500
|
full captures before raising the cap
|
|
501
501
|
([configuration](../../docs/configuration.md)).
|
|
502
502
|
- **Background dispatch.** If the handoff outruns the host's sync Bash ceiling,
|
|
@@ -575,6 +575,15 @@ Digest § 5 states the rule and both invocations; this is what surrounds them.
|
|
|
575
575
|
path the handoff seats first — MI is static and needs no coverage — then
|
|
576
576
|
runs the suite.
|
|
577
577
|
|
|
578
|
+
**Findings in one run.** Without a fresh coverage artifact the preflight CRAP
|
|
579
|
+
preview prints one `crap-coverage-not-fresh` line and passes. Seat-static also
|
|
580
|
+
prunes the CRAP rows of change-set methods that no longer exist. Post-capture
|
|
581
|
+
runs every coverage-reading gate and post-seat check, then lists every finding
|
|
582
|
+
in one `fix-required`. `story-handoff.js --report-all` lists every preflight
|
|
583
|
+
and post-capture finding the same way, always ends `fix-required`, and spawns
|
|
584
|
+
no suite, records no credit, seats, commits and pushes nothing, and runs no
|
|
585
|
+
review; post-seat checks wait for a real run, because it seats nothing.
|
|
586
|
+
|
|
578
587
|
## Held review at hand-off {#held-review}
|
|
579
588
|
|
|
580
589
|
The one home of this rule; the digest and the worker contract point here.
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,19 @@ All notable changes to this project will be documented in this file.
|
|
|
15
15
|
-->
|
|
16
16
|
<!-- markdownlint-disable-file MD004 MD012 MD037 -->
|
|
17
17
|
|
|
18
|
+
## [2.115.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.114.0...mandrel-v2.115.0) (2026-11-09)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
* one handoff run reports every finding it can, stale CRAP rows prune themselves, and the CRAP ratchet judges only the methods a Story touched ([#6031](https://github.com/dsj1984/mandrel/issues/6031)) ([#6037](https://github.com/dsj1984/mandrel/issues/6037)) ([58bfa88](https://github.com/dsj1984/mandrel/commit/58bfa88f15843b55dd037742af556fdbb2fa4e1a))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
* a test added after a green capture counts toward coverage, and a red capture no longer forces the next fix to re-pay the whole slice ([#6032](https://github.com/dsj1984/mandrel/issues/6032)) ([#6035](https://github.com/dsj1984/mandrel/issues/6035)) ([32d39e3](https://github.com/dsj1984/mandrel/commit/32d39e35d848b258f7a39a1c30b3f0e376435eb0))
|
|
29
|
+
* story init seeds from the remote base on any clone, and the self-eval scores the same change set handoff and close do ([#6033](https://github.com/dsj1984/mandrel/issues/6033)) ([#6034](https://github.com/dsj1984/mandrel/issues/6034)) ([79430a6](https://github.com/dsj1984/mandrel/commit/79430a6f69d9c207eed7449ef38660b17f226e51))
|
|
30
|
+
|
|
18
31
|
## [2.114.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.113.0...mandrel-v2.114.0) (2026-11-08)
|
|
19
32
|
|
|
20
33
|
|
package/package.json
CHANGED