mandrel 2.98.0 → 2.101.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.agents/agents/story-worker.md +7 -1
  2. package/.agents/audit-checklists/quality.md +1 -0
  3. package/.agents/docs/agentrc-reference.json +3 -0
  4. package/.agents/docs/configuration.md +3 -0
  5. package/.agents/rules/api-conventions.md +4 -0
  6. package/.agents/rules/ci-remediation.md +8 -0
  7. package/.agents/rules/testing-standards.md +19 -1
  8. package/.agents/schemas/agentrc.schema.json +26 -0
  9. package/.agents/schemas/story-deliver-terminal.schema.json +17 -3
  10. package/.agents/schemas/validation-evidence.schema.json +10 -0
  11. package/.agents/scripts/lib/close-lock-events.js +18 -5
  12. package/.agents/scripts/lib/close-validation/gates.js +6 -1
  13. package/.agents/scripts/lib/close-validation/runner.js +10 -11
  14. package/.agents/scripts/lib/close-validation/test-delta.js +124 -0
  15. package/.agents/scripts/lib/config/pull-request.js +25 -0
  16. package/.agents/scripts/lib/config-settings-schema-delivery.js +22 -0
  17. package/.agents/scripts/lib/config-settings-schema.js +5 -0
  18. package/.agents/scripts/lib/coverage-capture-delta.js +2 -1
  19. package/.agents/scripts/lib/generated/agentrc-validator.js +2 -2
  20. package/.agents/scripts/lib/git/sync-from-base.js +4 -2
  21. package/.agents/scripts/lib/orchestration/ci-red-handling.js +4 -3
  22. package/.agents/scripts/lib/orchestration/ci-rerun-guard.js +81 -25
  23. package/.agents/scripts/lib/orchestration/handoff-state.js +41 -0
  24. package/.agents/scripts/lib/orchestration/review-providers/code-review.js +97 -28
  25. package/.agents/scripts/lib/orchestration/single-story-close/phases/base-sync.js +7 -0
  26. package/.agents/scripts/lib/orchestration/single-story-close/phases/close-validation.js +22 -4
  27. package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +104 -57
  28. package/.agents/scripts/lib/orchestration/single-story-close/phases/merge-wait-recovery.js +16 -16
  29. package/.agents/scripts/lib/orchestration/single-story-close/phases/normalize-pr-title.js +28 -13
  30. package/.agents/scripts/lib/orchestration/single-story-close/phases/open-pr.js +1 -0
  31. package/.agents/scripts/lib/orchestration/single-story-close/phases/pr-body-trailers.js +38 -0
  32. package/.agents/scripts/lib/orchestration/single-story-close/phases/pre-push.js +24 -16
  33. package/.agents/scripts/lib/orchestration/single-story-close/phases/pull-request.js +18 -7
  34. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +60 -34
  35. package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +1 -1
  36. package/.agents/scripts/lib/orchestration/story-handoff.js +36 -9
  37. package/.agents/scripts/lib/test-run-credit.js +26 -0
  38. package/.agents/scripts/lib/test-tiers.js +14 -10
  39. package/.agents/scripts/lib/validation-evidence.js +6 -0
  40. package/.agents/scripts/run-tests.js +162 -92
  41. package/.agents/skills/core/code-review-and-quality/SKILL.md +1 -1
  42. package/.agents/workflows/audit-quality.md +7 -0
  43. package/.agents/workflows/helpers/code-review.md +10 -0
  44. package/.agents/workflows/helpers/deliver-reference.md +28 -1
  45. package/docs/CHANGELOG.md +33 -0
  46. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
+ import { sourcedTimings } from '../../close-lock-events.js';
1
2
  import { buildDefaultGates } from '../../close-validation/gates.js';
2
3
  import { runCloseValidation } from '../../close-validation/runner.js';
3
4
  import { getCiDelivery } from '../../config/ci.js';
4
- import { resolveWorktreeEnabled } from '../../config/runtime.js';
5
5
  import { resolveConfig } from '../../config-resolver.js';
6
6
  import { gh as defaultGh } from '../../gh-exec.js';
7
7
  import { getStoryBranch, gitSpawn, gitSync } from '../../git-utils.js';
@@ -15,6 +15,7 @@ import { createProvider } from '../../provider-factory.js';
15
15
  import { flipLabelAndNotify } from '../../single-story/story-merged-notify.js';
16
16
  import { WorktreeManager } from '../../worktree-manager.js';
17
17
  import { runCodeReview as runCodeReviewDefault } from '../code-review.js';
18
+ import { readCreditTimings } from '../handoff-state.js';
18
19
  import { resolveOperatorFromCandidates } from '../lease-guard-shared.js';
19
20
  import { resolveRunScopedConfig } from '../run-scoped-config.js';
20
21
  import {
@@ -38,10 +39,7 @@ import { parseCloseOptions, resolveWaitForMerge } from './phases/options.js';
38
39
  import { runPrePushPhases } from './phases/pre-push.js';
39
40
  import { pickHeadPullRequest } from './phases/pull-request.js';
40
41
  import { reconcileDoneLabel } from './phases/reconcile-done.js';
41
- import {
42
- existingWorktreePath,
43
- resolveStoryWorktree,
44
- } from './phases/worktree-restore.js';
42
+ import { resolveStoryWorktree } from './phases/worktree-restore.js';
45
43
  import {
46
44
  alreadyClosedResult,
47
45
  closeEnvelopeGates,
@@ -260,16 +258,28 @@ async function resolveBasePhase(ctx, deps) {
260
258
  return null;
261
259
  }
262
260
 
261
+ /** First SHA of a `show-ref` / `ls-remote` line; `''` on an empty read. */
262
+ function firstSha(stdout) {
263
+ return String(stdout ?? '')
264
+ .trim()
265
+ .split(/\s+/)[0];
266
+ }
267
+
263
268
  /**
264
- * A surviving local ref, or a branch still on origin, may carry work no PR
265
- * holds yet. Only `ls-remote`'s "no such ref" (exit 2) proves the remote
266
- * branch gone — a read failure counts as surviving.
269
+ * Tip SHAs of the surviving story refs (local, then origin). Only
270
+ * `ls-remote`'s "no such ref" (exit 2) proves the remote gone; any other
271
+ * failure yields `''`, which matches no PR head.
267
272
  */
268
- function storyBranchSurvives(ctx) {
273
+ function survivingStoryHeads(ctx) {
269
274
  const cwd = ctx.options.cwd;
270
- const ref = `refs/heads/${ctx.storyBranch}`;
271
- const local = gitSpawn(cwd, 'show-ref', '--verify', '--quiet', ref);
272
- if (local.status === 0) return true;
275
+ const heads = [];
276
+ const local = gitSpawn(
277
+ cwd,
278
+ 'show-ref',
279
+ '--verify',
280
+ `refs/heads/${ctx.storyBranch}`,
281
+ );
282
+ if (local.status === 0) heads.push(firstSha(local.stdout));
273
283
  const remote = gitSpawn(
274
284
  cwd,
275
285
  'ls-remote',
@@ -278,28 +288,38 @@ function storyBranchSurvives(ctx) {
278
288
  'origin',
279
289
  ctx.storyBranch,
280
290
  );
281
- return remote.status !== 2;
291
+ if (remote.status !== 2)
292
+ heads.push(remote.status === 0 ? firstSha(remote.stdout) : '');
293
+ return heads;
282
294
  }
283
295
 
284
296
  /**
285
- * The Story's PR, when it already merged and nothing newer is in flight — a
286
- * re-run after the land, whose branch `--delete-branch` and a sweep removed.
287
- * An OPEN PR on the head wins (a re-delivery), as `ensurePullRequestWith`
288
- * decides, and a surviving branch means there may be work to deliver.
289
- * Any read failure reads as "not merged": the normal path then decides.
297
+ * The Story's PR, when it already merged and nothing newer is in flight. A
298
+ * surviving branch is not evidence of unlanded work (the land tail's reap may
299
+ * be pending or failed), but a surviving tip past the merged PR's head is: it
300
+ * takes the normal path. An OPEN PR on the head wins (a re-delivery), as
301
+ * `ensurePullRequestWith` decides. Any read failure reads as "not merged".
290
302
  *
291
- * @returns {Promise<{ prUrl: string, prNumber: number|null }|null>}
303
+ * @returns {Promise<{ prUrl: string, prNumber: number|null, mergedAt: string }|null>}
292
304
  */
293
305
  async function findLandedPr(ctx, deps) {
294
- if (storyBranchSurvives(ctx)) return null;
295
306
  try {
296
307
  const rows = await (deps.gh ?? defaultGh).pr.list(
297
308
  ['--head', ctx.storyBranch, '--state', 'all'],
298
- ['url', 'state', 'mergedAt'],
309
+ ['url', 'state', 'mergedAt', 'headRefOid'],
299
310
  );
300
311
  const head = pickHeadPullRequest(rows);
301
- return head?.state === 'MERGED'
302
- ? { prUrl: head.url, prNumber: parsePrNumber(head.url) }
312
+ if (head?.state !== 'MERGED') return null;
313
+ const row = rows.find((r) => String(r?.url ?? '').trim() === head.url);
314
+ const landed = survivingStoryHeads(ctx).every(
315
+ (sha) => sha === row.headRefOid,
316
+ );
317
+ return landed
318
+ ? {
319
+ prUrl: head.url,
320
+ prNumber: parsePrNumber(head.url),
321
+ mergedAt: row.mergedAt ?? 'an unknown time',
322
+ }
303
323
  : null;
304
324
  } catch {
305
325
  return null;
@@ -307,22 +327,17 @@ async function findLandedPr(ctx, deps) {
307
327
  }
308
328
 
309
329
  /**
310
- * A missing worktree is recreated — unless the PR already merged, which
311
- * short-circuits to the confirm before any restore is attempted.
330
+ * A head whose PR already merged short-circuits to the confirm before any
331
+ * worktree restore; otherwise a missing worktree is recreated.
312
332
  */
313
333
  async function resolveCloseWorktree(ctx, deps) {
314
- const cwd = ctx.options.cwd;
315
- const wtIsolation = deps.config.delivery?.worktreeIsolation;
316
- const missing =
317
- !existingWorktreePath({ cwd, wtIsolation, storyId: ctx.storyId }) &&
318
- resolveWorktreeEnabled({ config: deps.config });
319
- ctx.landedPr = missing ? await findLandedPr(ctx, deps) : null;
334
+ ctx.landedPr = await findLandedPr(ctx, deps);
320
335
  if (ctx.landedPr) {
321
336
  ctx.recordPrNumber(ctx.landedPr.prNumber);
322
337
  return null;
323
338
  }
324
339
  return await resolveStoryWorktree({
325
- cwd,
340
+ cwd: ctx.options.cwd,
326
341
  config: deps.config,
327
342
  storyId: ctx.storyId,
328
343
  storyBranch: ctx.storyBranch,
@@ -340,7 +355,7 @@ function unlessLanded(phase, onLanded) {
340
355
  function landedPrePush(ctx) {
341
356
  progress(
342
357
  'INIT',
343
- `⏭ PR ${ctx.landedPr.prUrl} already merged — skipping validation, sync and push.`,
358
+ `⏭ PR ${ctx.landedPr.prUrl} already merged at ${ctx.landedPr.mergedAt} — skipping validation, sync and push.`,
344
359
  );
345
360
  ctx.options = { ...ctx.options, skipValidation: true, skipSync: true };
346
361
  ctx.prePush = {
@@ -433,7 +448,7 @@ function buildPrContext(ctx, deps) {
433
448
  phaseTimer: ctx.phaseTimer,
434
449
  worker: ctx.worker,
435
450
  lockWait: ctx.prePush.lockWait,
436
- suiteTimings: ctx.prePush.suiteTimings,
451
+ suiteTimings: envelopeSuiteTimings(ctx, deps),
437
452
  gates: closeEnvelopeGates(
438
453
  options,
439
454
  ctx.prePush.validationGates,
@@ -443,6 +458,17 @@ function buildPrContext(ctx, deps) {
443
458
  };
444
459
  }
445
460
 
461
+ /**
462
+ * The suite close spawned (`source: 'close'`), else — when its gates ran and
463
+ * honoured the handoff's credit — the credited run's figures.
464
+ */
465
+ function envelopeSuiteTimings(ctx, deps) {
466
+ const { validationGates, suiteTimings } = ctx.prePush;
467
+ if (suiteTimings || !validationGates) return suiteTimings;
468
+ const credit = readCreditTimings(ctx.storyId, deps.config);
469
+ return credit && sourcedTimings(credit, 'credited-run');
470
+ }
471
+
446
472
  function decideWaitForMerge(ctx, deps) {
447
473
  const { options, arm } = ctx;
448
474
  const decision = resolveWaitForMerge({
@@ -116,7 +116,7 @@ function compact(obj) {
116
116
  * @param {object|null} [args.waitBudget]
117
117
  * @param {{ waitedSeconds: number, expired: boolean, holder?: object }|null} [args.lockWait]
118
118
  * Full-suite lock wait; `waitBudget` is merge-wait only.
119
- * @param {{ lockWaitMs: number, hostWaitMs: number|null, testRunMs: number }|null} [args.suiteTimings]
119
+ * @param {{ lockWaitMs: number, hostWaitMs: number|null, testRunMs: number, source: 'close'|'credited-run', spawns: object[] }|null} [args.suiteTimings]
120
120
  * @param {Record<string, number>|null} [args.phaseDurations] Seconds per phase.
121
121
  * @param {string} [args.timestamp]
122
122
  * @param {{ schema: object|null, error: string|null }} [args.schemaSource]
@@ -23,7 +23,10 @@ import path from 'node:path';
23
23
  import { fileURLToPath } from 'node:url';
24
24
 
25
25
  import { spawnStreamAsync } from '../child-exec.js';
26
- import { createLockEventChannel } from '../close-lock-events.js';
26
+ import {
27
+ createLockEventChannel,
28
+ summarizeLockEvents,
29
+ } from '../close-lock-events.js';
27
30
  import {
28
31
  resolveGateCommand,
29
32
  resolveTestGateArgv,
@@ -48,6 +51,7 @@ import { describeBlocking } from '../suite-admission.js';
48
51
  import { writeFileAtomic } from '../util/atomic-write.js';
49
52
  import { defaultSleep } from '../util/sleep.js';
50
53
  import { runStreamed } from './evidence-stream.js';
54
+ import { handoffStatePath } from './handoff-state.js';
51
55
  import { probeHeldReviewDiff } from './review-deposit.js';
52
56
  import { createStoryProgress, handoffStepName } from './story-progress.js';
53
57
  import {
@@ -254,11 +258,16 @@ function durations({ waitMs, executionMs }) {
254
258
  /**
255
259
  * Tail a fresh lock-event channel while `run(env)` runs, forwarding each
256
260
  * `lock-progress` event once; never the child's output, which can be forged.
261
+ * `timings` summarizes every event drained (the lock wait and suite spawns).
262
+ *
263
+ * @returns {Promise<{ result: any, timings: ReturnType<typeof summarizeLockEvents> }>}
257
264
  */
258
265
  async function withLockProgress(ctx, run) {
259
266
  const channel = ctx.createLockChannel();
267
+ const events = [];
260
268
  const forward = () => {
261
269
  for (const event of channel.drain()) {
270
+ events.push(event);
262
271
  if (event.kind === 'lock-progress') {
263
272
  ctx.progress('LOCK', describeLockProgress(event));
264
273
  }
@@ -272,13 +281,15 @@ async function withLockProgress(ctx, run) {
272
281
  if (running) forward();
273
282
  }
274
283
  })().catch(() => {});
284
+ let result;
275
285
  try {
276
- return await run({ ...ctx.env, ...channel.env });
286
+ result = await run({ ...ctx.env, ...channel.env });
277
287
  } finally {
278
288
  running = false;
279
289
  forward();
280
290
  channel.dispose();
281
291
  }
292
+ return { result, timings: summarizeLockEvents(events) };
282
293
  }
283
294
 
284
295
  /**
@@ -477,22 +488,29 @@ async function stepCreditedRun(ctx) {
477
488
  // Close's `test` gate argv, so the deposit keys on its credit identity.
478
489
  ...testGateArgv(ctx.config),
479
490
  ];
480
- const run = await withLockProgress(ctx, (env) =>
491
+ const { result: run, timings } = await withLockProgress(ctx, (env) =>
481
492
  runLogged(ctx, 'credited-run', 'node', args, env),
482
493
  );
483
- const extra = { evidencePath: run.evidencePath, depositor: ctx.depositor };
494
+ const { lockWait, suiteTimings, spawns } = timings;
495
+ const extra = {
496
+ evidencePath: run.evidencePath,
497
+ depositor: ctx.depositor,
498
+ lockWait,
499
+ suiteTimings,
500
+ };
484
501
  if (run.status !== 0) {
485
502
  return fixRequired(name, describeSuiteFailure(run.status), extra);
486
503
  }
487
504
  const [ranSignal, freshSignal] = capture
488
505
  ? [SIGNALS.captureRan, SIGNALS.captureFresh]
489
506
  : [SIGNALS.testRan, SIGNALS.testFresh];
507
+ const credit = { head: ctx.head, lockWait, suiteTimings, spawns };
490
508
  if (ranSignal.test(run.output)) {
491
- ctx.state.creditHead = ctx.head;
509
+ recordCredit(ctx, credit);
492
510
  return ran(name, `${ctx.depositor} deposited credit`, extra);
493
511
  }
494
512
  if (freshSignal.test(run.output)) {
495
- ctx.state.creditHead = ctx.head;
513
+ recordCredit(ctx, credit);
496
514
  return skipped(name, `${ctx.depositor} credit already fresh`, extra);
497
515
  }
498
516
  return fixRequired(
@@ -502,6 +520,12 @@ async function stepCreditedRun(ctx) {
502
520
  );
503
521
  }
504
522
 
523
+ /** Credit and its run's figures move together, keyed by the credited head. */
524
+ function recordCredit(ctx, creditTimings) {
525
+ ctx.state.creditHead = creditTimings.head;
526
+ ctx.state.creditTimings = creditTimings;
527
+ }
528
+
505
529
  /**
506
530
  * @param {Function} git
507
531
  * @param {string} cwd
@@ -547,7 +571,7 @@ async function commitSeatedRows(ctx, total, evidencePath) {
547
571
  // Both capture-stamp digests leave `baselines/` out, so a baseline-JSON-only
548
572
  // commit keeps the credit it already holds.
549
573
  if (creditedPrior && ctx.depositor === 'coverage-capture') {
550
- ctx.state.creditHead = ctx.head;
574
+ recordCredit(ctx, { ...ctx.state.creditTimings, head: ctx.head });
551
575
  }
552
576
  return ran(name, `seated ${total} row(s) and committed them`, {
553
577
  evidencePath,
@@ -822,7 +846,7 @@ function precheck(ctx) {
822
846
  *
823
847
  * @param {string} statePath
824
848
  * @param {(tag: string, msg: string) => void} progress
825
- * @returns {{ preflightHead?: string, creditHead?: string, seatHead?: string }}
849
+ * @returns {{ preflightHead?: string, creditHead?: string, creditTimings?: object, seatHead?: string }}
826
850
  */
827
851
  function readState(statePath, progress) {
828
852
  let raw;
@@ -934,7 +958,7 @@ export async function runStoryHandoff({ storyId, cwd, config }, deps) {
934
958
  warn: (m) => progress('BLOCK', m),
935
959
  }));
936
960
  fs.mkdirSync(logDir, { recursive: true });
937
- const statePath = path.join(logDir, `story-handoff-${storyId}.json`);
961
+ const statePath = handoffStatePath(logDir, storyId);
938
962
  const branch = getStoryBranch(storyId);
939
963
  const evidencePathFor = (name) =>
940
964
  path.join(logDir, `story-handoff-${storyId}-${name}.log`);
@@ -1001,6 +1025,7 @@ export async function runStoryHandoff({ storyId, cwd, config }, deps) {
1001
1025
  }
1002
1026
 
1003
1027
  const status = stop?.stop ?? HANDOFF_STATUS.READY;
1028
+ const credited = steps.find((s) => s.name === 'credited-run');
1004
1029
  if (status === HANDOFF_STATUS.BLOCKED) {
1005
1030
  await block({ storyId, config, reason: stop.reason, detail: stop.detail });
1006
1031
  }
@@ -1013,6 +1038,8 @@ export async function runStoryHandoff({ storyId, cwd, config }, deps) {
1013
1038
  depositor: ctx.depositor,
1014
1039
  steps: steps.map(({ stop: _stop, ...rest }) => rest),
1015
1040
  review: ctx.review,
1041
+ lockWait: credited?.lockWait ?? null,
1042
+ suiteTimings: credited?.suiteTimings ?? null,
1016
1043
  ...(stop
1017
1044
  ? {
1018
1045
  failedStep: stop.name,
@@ -201,6 +201,32 @@ export function predictsTestEvidenceCredit({
201
201
  }
202
202
  }
203
203
 
204
+ /** Does `sha` hold `test` credit under the full-suite identity? Uncertainty is `false`. */
205
+ export function hasTestCreditAt({
206
+ config,
207
+ storyId,
208
+ cwd,
209
+ evidenceCwd,
210
+ sha,
211
+ shouldSkipImpl = defaultShouldSkip,
212
+ } = {}) {
213
+ if (!sha) return false;
214
+ try {
215
+ const verdict = shouldSkipImpl(
216
+ {
217
+ storyId,
218
+ gateName: GATE_NAME,
219
+ currentSha: sha,
220
+ configHash: testGateConfigHash(config, cwd),
221
+ },
222
+ { cwd: evidenceCwd ?? cwd, standalone: true },
223
+ );
224
+ return verdict.skip === true;
225
+ } catch {
226
+ return false;
227
+ }
228
+ }
229
+
204
230
  /**
205
231
  * @param {{ storyId: number, sha: string, cwd: string, config: object|null, evidenceRoot: string, durationMs: number|null, gitSpawnFn: Function, recordPassFn: Function }} args
206
232
  * @returns {{ deposited: boolean, reason: string, storyId: number, sha: string }}
@@ -28,10 +28,10 @@ const matchesE2E = picomatch(E2E_INCLUDE, { dot: true });
28
28
  const TIERS = ['full', 'quick', 'integration', 'e2e'];
29
29
 
30
30
  /**
31
- * The only flags forwarded to `node --test`; any other `--flag` is rejected,
32
- * since `node --test` reads it as a file pattern and exits 0 having run nothing.
31
+ * The only `node --test` flags passed through; any other `--flag` is rejected,
32
+ * so a typo can never run nothing and exit 0.
33
33
  */
34
- const PASSTHROUGH_FLAGS = ['--test-name-pattern', '--test-only'];
34
+ export const PASSTHROUGH_FLAGS = ['--test-name-pattern', '--test-only'];
35
35
 
36
36
  /** Roots scanned for `*.test.js`, including colocated `__tests__` trees. */
37
37
  const TEST_WALK_ROOTS = ['tests', 'lib', '.agents/scripts'];
@@ -115,6 +115,16 @@ export function listTestFilesForTier(tier, repoRoot, fsLike = fs) {
115
115
  return splitBySpeed(rest, tier);
116
116
  }
117
117
 
118
+ /** The one unrecognized-argument error every run-tests flag check throws. */
119
+ export function unrecognizedArgument(args) {
120
+ return new Error(
121
+ `[run-tests] unrecognized argument(s): ${args.join(', ')}. ` +
122
+ `Accepted: --tier <${TIERS.join('|')}>, ${PASSTHROUGH_FLAGS.join(', ')}, --shard <i>/<n>, --help. ` +
123
+ 'Unrecognized flags are not forwarded: `node --test` would read them as ' +
124
+ 'file patterns and exit 0 having run nothing.',
125
+ );
126
+ }
127
+
118
128
  /**
119
129
  * @param {string[]} rest
120
130
  * @throws {Error} naming both the accepted tiers and the accepted flags.
@@ -126,13 +136,7 @@ function assertKnownFlags(rest) {
126
136
  !PASSTHROUGH_FLAGS.includes(arg) &&
127
137
  !PASSTHROUGH_FLAGS.some((flag) => arg.startsWith(`${flag}=`)),
128
138
  );
129
- if (unknown.length === 0) return;
130
- throw new Error(
131
- `[run-tests] unrecognized argument(s): ${unknown.join(', ')}. ` +
132
- `Accepted: --tier <${TIERS.join('|')}>, ${PASSTHROUGH_FLAGS.join(', ')}, --help. ` +
133
- 'Unrecognized flags are not forwarded: `node --test` would read them as ' +
134
- 'file patterns and exit 0 having run nothing.',
135
- );
139
+ if (unknown.length > 0) throw unrecognizedArgument(unknown);
136
140
  }
137
141
 
138
142
  /**
@@ -165,6 +165,8 @@ export function loadEvidence(scopeId, opts = {}) {
165
165
  * configHash: string,
166
166
  * exitCode?: number,
167
167
  * durationMs?: number|null,
168
+ * scope?: 'full'|'delta',
169
+ * since?: string,
168
170
  * }} input
169
171
  * @param {{ cwd?: string, tempDir?: string, standalone?: boolean, fs?: object, now?: Function }} opts
170
172
  * @returns {object} The persisted record.
@@ -178,6 +180,8 @@ export function recordPass(
178
180
  exitCode = 0,
179
181
  durationMs = null,
180
182
  inputFingerprint = null,
183
+ scope,
184
+ since,
181
185
  },
182
186
  opts = {},
183
187
  ) {
@@ -201,6 +205,8 @@ export function recordPass(
201
205
  inputFingerprint: isNonEmptyString(inputFingerprint)
202
206
  ? inputFingerprint
203
207
  : null,
208
+ ...(scope ? { scope } : {}),
209
+ ...(since ? { since } : {}),
204
210
  timestamp: resolved.now().toISOString(),
205
211
  };
206
212
  doc.records = [...doc.records.filter((r) => r.gateName !== gateName), record];