mandrel 2.70.0 → 2.72.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 (79) hide show
  1. package/.agents/README.md +8 -9
  2. package/.agents/agents/acceptance-critic.md +1 -0
  3. package/.agents/agents/auditor.md +1 -0
  4. package/.agents/agents/plan-critic.md +1 -0
  5. package/.agents/agents/story-worker.md +63 -64
  6. package/.agents/docs/agentrc-reference.json +2 -1
  7. package/.agents/docs/configuration.md +7 -8
  8. package/.agents/rules/git-conventions-reference.md +2 -2
  9. package/.agents/schemas/agentrc.schema.json +19 -2
  10. package/.agents/schemas/story-deliver-terminal.schema.json +10 -1
  11. package/.agents/scripts/acceptance-eval.js +194 -15
  12. package/.agents/scripts/deliver-run.js +92 -43
  13. package/.agents/scripts/lib/audit-suite/index.js +1 -1
  14. package/.agents/scripts/lib/audit-suite/story-checklist.js +65 -0
  15. package/.agents/scripts/lib/audit-to-stories/audit-label-taxonomy.js +2 -2
  16. package/.agents/scripts/lib/bootstrap/issue-forms-template.js +1 -1
  17. package/.agents/scripts/lib/cli-args.js +22 -0
  18. package/.agents/scripts/lib/close-validation/gates.js +17 -3
  19. package/.agents/scripts/lib/config/agent-models.js +117 -0
  20. package/.agents/scripts/lib/config-settings-schema-delivery.js +13 -1
  21. package/.agents/scripts/lib/config-settings-schema-quality.js +1 -1
  22. package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
  23. package/.agents/scripts/lib/git/sync-from-base.js +89 -17
  24. package/.agents/scripts/lib/label-taxonomy.js +13 -3
  25. package/.agents/scripts/lib/notifications/notifier.js +11 -15
  26. package/.agents/scripts/lib/observability/close-telemetry.js +19 -3
  27. package/.agents/scripts/lib/observability/source-classifier.js +1 -0
  28. package/.agents/scripts/lib/orchestration/cancelled-run-discount.js +129 -0
  29. package/.agents/scripts/lib/orchestration/code-review.js +2 -2
  30. package/.agents/scripts/lib/orchestration/deliver-recover.js +166 -34
  31. package/.agents/scripts/lib/orchestration/file-assumptions.js +45 -11
  32. package/.agents/scripts/lib/orchestration/plan-context.js +17 -10
  33. package/.agents/scripts/lib/orchestration/plan-persist/changes-repair.js +130 -24
  34. package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +19 -16
  35. package/.agents/scripts/lib/orchestration/plan-persist/story-ops.js +1 -0
  36. package/.agents/scripts/lib/orchestration/plan-persist/summary.js +4 -3
  37. package/.agents/scripts/lib/orchestration/pr-watch.js +14 -3
  38. package/.agents/scripts/lib/orchestration/resolve-stories.js +10 -2
  39. package/.agents/scripts/lib/orchestration/review-providers/native.js +5 -165
  40. package/.agents/scripts/lib/orchestration/single-story-close/failed-terminal.js +14 -2
  41. package/.agents/scripts/lib/orchestration/single-story-close/phases/auto-merge.js +45 -0
  42. package/.agents/scripts/lib/orchestration/single-story-close/phases/base-sync.js +162 -58
  43. package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +58 -6
  44. package/.agents/scripts/lib/orchestration/single-story-close/phases/merge-wait-recovery.js +296 -0
  45. package/.agents/scripts/lib/orchestration/single-story-close/phases/options.js +20 -4
  46. package/.agents/scripts/lib/orchestration/single-story-close/phases/post-land.js +52 -6
  47. package/.agents/scripts/lib/orchestration/single-story-close/phases/pull-request.js +2 -2
  48. package/.agents/scripts/lib/orchestration/single-story-close/phases/story-branch-catch-up.js +50 -0
  49. package/.agents/scripts/lib/orchestration/single-story-close/phases/worktree-reap.js +64 -52
  50. package/.agents/scripts/lib/orchestration/single-story-close/phases/worktree-restore.js +133 -0
  51. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +187 -74
  52. package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +46 -6
  53. package/.agents/scripts/lib/orchestration/story-handoff.js +849 -0
  54. package/.agents/scripts/lib/orchestration/story-init-result.js +83 -0
  55. package/.agents/scripts/lib/orchestration/task-body-validator.js +35 -5
  56. package/.agents/scripts/lib/orchestration/ticket-validator-sizing.js +1 -1
  57. package/.agents/scripts/lib/orchestration/ticket-validator.js +20 -2
  58. package/.agents/scripts/lib/single-story/confirm-merge.js +44 -7
  59. package/.agents/scripts/lib/story-body/story-body.js +40 -5
  60. package/.agents/scripts/lib/templates/decomposer-prompts.js +33 -36
  61. package/.agents/scripts/pr-watch-with-update.js +5 -0
  62. package/.agents/scripts/single-story-close.js +8 -0
  63. package/.agents/scripts/single-story-confirm-merge.js +34 -3
  64. package/.agents/scripts/single-story-init.js +17 -32
  65. package/.agents/scripts/story-handoff.js +112 -0
  66. package/.agents/scripts/sync-claude-agents.js +58 -27
  67. package/.agents/workflows/helpers/acceptance-self-eval.md +24 -18
  68. package/.agents/workflows/helpers/code-review.md +3 -3
  69. package/.agents/workflows/helpers/deliver-digest.md +79 -80
  70. package/.agents/workflows/helpers/deliver-light.md +9 -7
  71. package/.agents/workflows/helpers/deliver-reference.md +38 -22
  72. package/.agents/workflows/helpers/deliver-story-reference.md +39 -18
  73. package/.agents/workflows/helpers/deliver-story.md +30 -23
  74. package/.agents/workflows/helpers/plan-reference.md +24 -9
  75. package/.agents/workflows/helpers/worktree-lifecycle.md +5 -5
  76. package/docs/CHANGELOG.md +31 -0
  77. package/lib/cli/registry.js +7 -0
  78. package/package.json +4 -3
  79. package/.agents/scripts/lib/orchestration/review-providers/scoped-lint.js +0 -272
@@ -17,10 +17,14 @@
17
17
  * [--rerun-advisory <n>]
18
18
  * [--override-review-block <reason>]
19
19
  * [--worker-tokens <n>]
20
+ * [--worker-model <model>]
20
21
  *
21
22
  * `--worker-tokens <n>` is the story-worker's host-reported token total,
22
23
  * recorded best-effort in the close result's `telemetry` (absent or invalid →
23
24
  * `null` plus a warning; never a change of status or exit code).
25
+ * `--worker-model <model>` is the dispatched story-worker's resolved model,
26
+ * which deliver-run renders on a multi-Story close (`telemetry.workerModel`;
27
+ * an inline close omits it and records `null`).
24
28
  * `--override-review-block <reason>` is the audited escape past a code-review
25
29
  * CRITICAL blocker (instead of a hand-merge with no record).
26
30
  * `--merge-watch-mode async` is passed per close by the orchestrator, the only
@@ -138,6 +142,10 @@ runAsCli(import.meta.url, main, {
138
142
  '--worker-tokens <n>',
139
143
  'The story-worker’s host-reported total tokens, recorded in the close result’s `telemetry.workerTokens`. Best-effort: an absent or non-integer value records null with a warning and never changes the status or exit code.',
140
144
  ],
145
+ [
146
+ '--worker-model <model>',
147
+ 'The dispatched story-worker’s resolved model, recorded in the close result’s `telemetry.workerModel` beside `workerTokens`. deliver-run renders it on every close of a multi-Story run; an inline close omits it and records null. Best-effort: an invalid value records null with a warning and never changes the status or exit code.',
148
+ ],
141
149
  ],
142
150
  notes: [
143
151
  'Exit codes:\n 0 landed\n 1 blocked or failed\n 3 pending (resumable — run the envelope’s nextCommand)',
@@ -27,12 +27,15 @@ import { getStoryBranch } from './lib/git-utils.js';
27
27
  import { Logger } from './lib/Logger.js';
28
28
  import { emitTerminalFriction } from './lib/observability/runtime-friction.js';
29
29
  import { emitTerseResult } from './lib/observability/terse-result.js';
30
+ import { probeCloseArtifacts } from './lib/orchestration/deliver-recover.js';
30
31
  import { MERGED_FLIP_FAILED_BLOCK_CLASS } from './lib/orchestration/lifecycle/emit-merge-flip-failed.js';
31
32
  import { MERGE_WAIT_GH_TIMEOUT_MS } from './lib/orchestration/merge-poll.js';
33
+ import { closeArmedPr } from './lib/orchestration/single-story-close/phases/auto-merge.js';
32
34
  import { parsePrNumber } from './lib/orchestration/single-story-close/phases/code-review.js';
33
35
  import { runConfirmMergePhase as defaultRunConfirmMergePhase } from './lib/orchestration/single-story-close/phases/confirm-merge.js';
34
36
  import { assertNoRetiredFlags } from './lib/orchestration/single-story-close/phases/options.js';
35
37
  import { runPostLandTail } from './lib/orchestration/single-story-close/phases/post-land.js';
38
+ import { resolveStoryWorktree } from './lib/orchestration/single-story-close/phases/worktree-restore.js';
36
39
  import {
37
40
  buildTerminalEnvelope,
38
41
  emitTerminalEnvelope,
@@ -268,22 +271,44 @@ async function confirmWithoutPr(ctx) {
268
271
  );
269
272
  }
270
273
 
274
+ /** Lazy: only a DIRTY sync needs the worktree, never confirming a merge. */
275
+ function lazyWaitWorktree({ cwd, config, storyId, storyBranch, ...ctx }) {
276
+ return () =>
277
+ ctx.resolveWorktreeFn({ cwd, config, storyId, storyBranch, progress });
278
+ }
279
+
280
+ /**
281
+ * What the last close recorded about the arm, off its persisted envelope.
282
+ * Only positive evidence that close armed the PR lets the wait re-arm it.
283
+ *
284
+ * @returns {{ armed: boolean, reason: string|null }}
285
+ */
286
+ function readCloseArmEvidence({ storyId, config, readCloseEnvelopeFn }) {
287
+ const { envelope } = readCloseEnvelopeFn({ storyId, config });
288
+ const pr = envelope?.storyId === storyId ? envelope.pr : null;
289
+ return { armed: closeArmedPr(pr), reason: pr?.autoMergeReason ?? null };
290
+ }
291
+
271
292
  /**
272
293
  * `--wait` runs the SAME phase as close so the cumulative budget give-up
273
294
  * (the only path to `merge.unlanded` / `agent::blocked`) is reachable from a
274
295
  * resume. The budget is anchored at the PR's `createdAt`, so resuming does
275
- * not restart the clock.
296
+ * not restart the clock. The Story worktree is resolved (and recreated when
297
+ * missing) exactly as close does, so a DIRTY PR syncs there.
276
298
  */
277
299
  async function resumeMergeWait(ctx) {
278
300
  const { storyId, storyBranch, baseBranch, prNumber } = ctx;
301
+ const evidence = readCloseArmEvidence(ctx);
279
302
  const waitOutcome = await ctx.runConfirmMergePhaseFn({
280
303
  cwd: ctx.cwd,
304
+ resolveWorktree: lazyWaitWorktree(ctx),
305
+ closeArmed: evidence.armed,
281
306
  storyId,
282
307
  storyBranch,
283
308
  baseBranch,
284
309
  prNumber,
285
310
  prUrl: `${storyBranch} PR #${prNumber}`,
286
- // The close already armed it.
311
+ // Enters the wait; re-arming a disarmed PR needs `closeArmed` above.
287
312
  autoMergeEnabled: true,
288
313
  maxWaitSeconds: ctx.maxWaitSeconds,
289
314
  provider: ctx.provider,
@@ -300,7 +325,9 @@ async function resumeMergeWait(ctx) {
300
325
  baseBranch,
301
326
  prNumber,
302
327
  prUrl: null,
303
- autoMergeEnabled: true,
328
+ // Carried forward, so the next resume reads the same evidence.
329
+ autoMergeEnabled: evidence.armed,
330
+ autoMergeReason: evidence.reason,
304
331
  // This CLI runs no close gates.
305
332
  gates: undefined,
306
333
  elapsedSeconds: elapsedSeconds(ctx),
@@ -382,6 +409,8 @@ export async function runConfirmMerge({
382
409
  injectedNotify,
383
410
  injectedReadPrMergeState,
384
411
  runConfirmMergePhaseFn = defaultRunConfirmMergePhase,
412
+ resolveWorktreeFn = resolveStoryWorktree,
413
+ readCloseEnvelopeFn = probeCloseArtifacts,
385
414
  } = {}) {
386
415
  if (!storyId) {
387
416
  throw new Error(USAGE);
@@ -403,6 +432,8 @@ export async function runConfirmMerge({
403
432
  injectedNotify,
404
433
  injectedReadPrMergeState,
405
434
  runConfirmMergePhaseFn,
435
+ resolveWorktreeFn,
436
+ readCloseEnvelopeFn,
406
437
  };
407
438
 
408
439
  progress('INIT', `Confirming merge for standalone Story #${storyId}...`);
@@ -13,6 +13,7 @@
13
13
 
14
14
  import { existsSync } from 'node:fs';
15
15
  import path from 'node:path';
16
+ import { buildStoryChecklist } from './lib/audit-suite/index.js';
16
17
  import { parseSprintArgs } from './lib/cli-args.js';
17
18
  import { runAsCli } from './lib/cli-utils.js';
18
19
  import {
@@ -37,12 +38,12 @@ import {
37
38
  planFastForward,
38
39
  } from './lib/orchestration/git-cleanup/phases/fast-forward.js';
39
40
  import { verifyRemote } from './lib/orchestration/remote-verifier.js';
40
- import { pinRunScopedConfig } from './lib/orchestration/run-scoped-config.js';
41
41
  import {
42
42
  acquireStoryLease,
43
43
  releaseStoryLease,
44
44
  } from './lib/orchestration/single-story-lease-guard.js';
45
45
  import { handleRemoteVerificationFailure } from './lib/orchestration/story-init-remote.js';
46
+ import { composeStoryInitResult } from './lib/orchestration/story-init-result.js';
46
47
  import {
47
48
  STATE_LABELS,
48
49
  transitionTicketState,
@@ -564,6 +565,7 @@ export async function runSingleStoryInit({
564
565
  injectedMaterialize = materializeBaseBranch,
565
566
  injectedSeedBranch = seedStoryBranch,
566
567
  injectedProvisionWorktree = provisionWorktree,
568
+ injectedBuildChecklist = buildStoryChecklist,
567
569
  } = {}) {
568
570
  const parsed =
569
571
  storyIdParam !== undefined
@@ -688,35 +690,26 @@ export async function runSingleStoryInit({
688
690
  }
689
691
  }
690
692
 
691
- const dependenciesInstalled =
692
- installStatus.status === 'installed'
693
- ? 'true'
694
- : installStatus.status === 'failed'
695
- ? 'false'
696
- : 'skipped';
697
-
698
- const result = {
693
+ // Every path gets the checklist; `buildStoryChecklist` never throws.
694
+ const checklistPath = dryRun
695
+ ? null
696
+ : injectedBuildChecklist({ storyId, body: story.body, config, progress })
697
+ .checklistPath;
698
+ const { result, summary } = composeStoryInitResult({
699
699
  storyId,
700
- epicId: null,
701
- standalone: true,
702
700
  storyBranch,
703
701
  baseBranch,
704
- // Write half of the run-scoped config pin; `baseBranch` is close's fallback.
705
- runScopedConfig: pinRunScopedConfig(config),
706
- storyTitle: story.title,
707
- worktreeEnabled: runtime.worktreeEnabled,
702
+ config,
703
+ story,
704
+ runtime,
708
705
  workCwd,
709
706
  worktreeCreated,
710
707
  installStatus,
711
- dependenciesInstalled,
712
- installFailed: installStatus.status === 'failed',
713
- // Closed-Story worktree sweep outcome; a failure degrades here, never
714
- // into an init failure. `null` under --dry-run.
715
- worktreeSweep: worktreeSweep ?? null,
708
+ worktreeSweep,
716
709
  dryRun,
717
- remoteVerified: remote.remoteVerified,
718
- remoteProbe: { remoteUrl: remote.remoteUrl, detail: remote.detail },
719
- };
710
+ remote,
711
+ checklistPath,
712
+ });
720
713
 
721
714
  // The envelope (stdout + disk) is the only record; no ticket comment. Full
722
715
  // result goes to a temp log, stdout gets the fields the caller acts on.
@@ -725,15 +718,7 @@ export async function runSingleStoryInit({
725
718
  result,
726
719
  scope: storyId,
727
720
  config,
728
- summary: {
729
- storyId,
730
- storyBranch,
731
- workCwd,
732
- worktreeCreated,
733
- dependenciesInstalled,
734
- remoteVerified: result.remoteVerified,
735
- dryRun,
736
- },
721
+ summary,
737
722
  });
738
723
  progress(
739
724
  'DONE',
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * story-handoff.js — the story-worker's whole post-implementation tail in one
5
+ * command: preflight (lint + quality-preview + baselined ratchets) → merge
6
+ * origin/<base> → the one credited run → `--seat-missing` baseline seating →
7
+ * push + remote-ref check → held Story-scope review. Prints one JSON envelope on stdout.
8
+ *
9
+ * Exit 0 `ready` (hand off) · 2 `fix-required` (fix, commit, re-run; labels
10
+ * untouched) · 1 `blocked` (flips agent::blocked + posts friction) or a usage
11
+ * error. Idempotent: a re-run on an unchanged tree spawns no suite, seats
12
+ * nothing, pushes nothing and recomputes no review. Never runs close, opens a
13
+ * PR, or writes any other label.
14
+ *
15
+ * @see .agents/scripts/lib/orchestration/story-handoff.js
16
+ */
17
+
18
+ import { parseArgs } from 'node:util';
19
+
20
+ import { runAsCli } from './lib/cli-utils.js';
21
+ import { resolveConfig } from './lib/config-resolver.js';
22
+ import { runStoryHandoff } from './lib/orchestration/story-handoff.js';
23
+ import { createProvider } from './lib/provider-factory.js';
24
+ import { computeStoryReviewDeposit } from './story-review-compute.js';
25
+
26
+ const USAGE = {
27
+ invocation:
28
+ 'node .agents/scripts/story-handoff.js --story <id> [--cwd <workCwd>]',
29
+ summary:
30
+ "Run the story-worker's post-implementation tail — preflight, base merge, 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).",
31
+ flags: [
32
+ ['--story <id>', 'Story issue number; the branch is story-<id>.'],
33
+ ['--cwd <path>', "The Story's worktree (default: the current directory)."],
34
+ ],
35
+ notes: [
36
+ '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',
37
+ ],
38
+ };
39
+
40
+ /**
41
+ * @param {string[]} argv
42
+ * @returns {{ storyId: number|null, cwd: string|null }}
43
+ */
44
+ function parseArgv(argv) {
45
+ const { values } = parseArgs({
46
+ args: argv,
47
+ options: {
48
+ story: { type: 'string' },
49
+ cwd: { type: 'string' },
50
+ },
51
+ strict: false,
52
+ });
53
+ const storyId = Number.parseInt(values.story ?? '', 10);
54
+ return {
55
+ storyId: Number.isInteger(storyId) && storyId > 0 ? storyId : null,
56
+ cwd: values.cwd ?? null,
57
+ };
58
+ }
59
+
60
+ /**
61
+ * @param {string[]} [argv]
62
+ * @param {{
63
+ * resolveConfigImpl?: typeof resolveConfig,
64
+ * runHandoffImpl?: typeof runStoryHandoff,
65
+ * stdout?: { write: (s: string) => void },
66
+ * stderr?: { write: (s: string) => void },
67
+ * cwd?: string,
68
+ * }} [deps]
69
+ * @returns {Promise<{ envelope: object, exitCode: number }>}
70
+ */
71
+ export async function runStoryHandoffCli(
72
+ argv = process.argv.slice(2),
73
+ deps = {},
74
+ ) {
75
+ const {
76
+ resolveConfigImpl = resolveConfig,
77
+ runHandoffImpl = runStoryHandoff,
78
+ stdout = process.stdout,
79
+ stderr = process.stderr,
80
+ cwd: defaultCwd = process.cwd(),
81
+ } = deps;
82
+ const { storyId, cwd } = parseArgv(argv);
83
+ if (!storyId) {
84
+ throw new Error(
85
+ 'story-handoff: --story <id> is required (a positive integer).',
86
+ );
87
+ }
88
+ const workCwd = cwd ?? defaultCwd;
89
+ const config = resolveConfigImpl({ cwd: workCwd });
90
+ const outcome = await runHandoffImpl(
91
+ { storyId, cwd: workCwd, config },
92
+ {
93
+ computeReview: computeStoryReviewDeposit,
94
+ createProviderFn: createProvider,
95
+ progress: (tag, msg) => stderr.write(`[story-handoff] [${tag}] ${msg}\n`),
96
+ },
97
+ );
98
+ stdout.write(`${JSON.stringify(outcome.envelope, null, 2)}\n`);
99
+ return outcome;
100
+ }
101
+
102
+ async function main() {
103
+ const { exitCode } = await runStoryHandoffCli();
104
+ return exitCode;
105
+ }
106
+
107
+ runAsCli(import.meta.url, main, {
108
+ source: 'story-handoff',
109
+ propagateExitCode: true,
110
+ errorPrefix: '[story-handoff] ❌ Fatal error',
111
+ usage: USAGE,
112
+ });
@@ -5,6 +5,7 @@
5
5
  * `.claude/agents/` tree — the sibling of `sync-claude-commands.js`, with the
6
6
  * same payload-wins shadowing and orphan-reap. A role agent runs on its own
7
7
  * system prompt (no entry-doc `@`-import closure), which is the point of routing to it.
8
+ * A `delivery.routing.agentModels` entry overrides the role's `model:` default.
8
9
  */
9
10
 
10
11
  // cli-opt-out: top-level-await script with no main() function — runAsCli wraps an async main, which doesn't apply here.
@@ -12,6 +13,8 @@ import fs from 'node:fs';
12
13
  import path from 'node:path';
13
14
 
14
15
  import { applyHeader } from './lib/command-header.js';
16
+ import { applyAgentModel, getAgentModels } from './lib/config/agent-models.js';
17
+ import { resolveConfig } from './lib/config-resolver.js';
15
18
  import { Logger } from './lib/Logger.js';
16
19
 
17
20
  // cwd, never `__dirname/../..`, which lands inside node_modules when installed.
@@ -52,13 +55,23 @@ const isTopLevelAgent = (entry) => entry.isFile() && entry.name.endsWith('.md');
52
55
  // Payload first, so it wins a collision.
53
56
  const SRC_DIRS = [PAYLOAD_SRC, LOCAL_SRC].filter(dirExists);
54
57
 
55
- /** @type {Array<{dir: string, name: string}>} */
56
- const entries = SRC_DIRS.flatMap((dir) =>
57
- fs
58
+ /**
59
+ * Named, not inline: an anonymous callback in this spawned-only script has no
60
+ * coverage coordinates for the CRAP seat to resolve.
61
+ *
62
+ * @param {string} dir
63
+ * @returns {Array<{dir: string, name: string}>}
64
+ */
65
+ function agentEntriesIn(dir) {
66
+ return fs
58
67
  .readdirSync(dir, { withFileTypes: true })
59
68
  .filter(isTopLevelAgent)
60
- .map((e) => ({ dir, name: e.name })),
61
- );
69
+ .map(function toAgentEntry(e) {
70
+ return { dir, name: e.name };
71
+ });
72
+ }
73
+
74
+ const entries = SRC_DIRS.flatMap(agentEntriesIn);
62
75
 
63
76
  const byName = new Map();
64
77
  for (const e of entries) {
@@ -90,29 +103,47 @@ for (const name of listExistingAgents()) {
90
103
  }
91
104
  }
92
105
 
93
- // The header goes after any frontmatter, so `---` stays on line 1.
106
+ // Resolved once: an invalid override (an unknown role) fails the sync here.
107
+ const agentModels = getAgentModels(resolveConfig({ cwd: PROJECT_ROOT }));
108
+
109
+ /**
110
+ * @param {string} name
111
+ * @param {string} content
112
+ * @returns {string}
113
+ */
114
+ function withModelOverride(name, content) {
115
+ const model = agentModels[name.replace(/\.md$/, '')];
116
+ return model ? applyAgentModel(content, model) : content;
117
+ }
118
+
94
119
  let synced = 0;
95
- const resolvedEntries = Array.from(byName.values());
96
- await Promise.all(
97
- resolvedEntries.map(async ({ dir, name }) => {
98
- const isLocal = dir === LOCAL_SRC;
99
- const header = isLocal ? LOCAL_HEADER : HEADER;
100
- const content = await fs.promises.readFile(path.join(dir, name), 'utf8');
101
- const dest = path.join(DEST_DIR, name);
102
- const target = applyHeader(content, header);
103
-
104
- try {
105
- const existingContent = await fs.promises.readFile(dest, 'utf8');
106
- if (existingContent === target) return;
107
- } catch (err) {
108
- if (err.code !== 'ENOENT') throw err;
109
- }
110
-
111
- await fs.promises.writeFile(dest, target, 'utf8');
112
- synced++;
113
- Logger.info(` synced ${name}`);
114
- }),
115
- );
120
+
121
+ /**
122
+ * The header goes after any frontmatter, so `---` stays on line 1.
123
+ *
124
+ * @param {{ dir: string, name: string }} entry
125
+ * @returns {Promise<void>}
126
+ */
127
+ async function syncEntry({ dir, name }) {
128
+ const isLocal = dir === LOCAL_SRC;
129
+ const header = isLocal ? LOCAL_HEADER : HEADER;
130
+ const content = await fs.promises.readFile(path.join(dir, name), 'utf8');
131
+ const dest = path.join(DEST_DIR, name);
132
+ const target = applyHeader(withModelOverride(name, content), header);
133
+
134
+ try {
135
+ const existingContent = await fs.promises.readFile(dest, 'utf8');
136
+ if (existingContent === target) return;
137
+ } catch (err) {
138
+ if (err.code !== 'ENOENT') throw err;
139
+ }
140
+
141
+ await fs.promises.writeFile(dest, target, 'utf8');
142
+ synced++;
143
+ Logger.info(` synced ${name}`);
144
+ }
145
+
146
+ await Promise.all(Array.from(byName.values()).map(syncEntry));
116
147
 
117
148
  Logger.info(
118
149
  `\n✔ ${synced} file(s) synced, ${sourceSet.size} total agents in .claude/agents/`,
@@ -36,15 +36,20 @@ per-criterion, mid-delivery, and evaluates the actual work product.
36
36
  alone**:
37
37
 
38
38
  > ```bash
39
- > node <main-repo>/.agents/scripts/ceremony-derive.js --story <storyId> --cwd <workCwd>
39
+ > node <main-repo>/.agents/scripts/acceptance-eval.js --story <storyId> --init --cwd <workCwd>
40
40
  > ```
41
41
  >
42
- > One call computes the change set once (`files`), derives the level and
43
- > classes **for review depth**, and resolves the owner (`mode`, `reason`,
44
- > `verdictOwner`): **`minimal` / `standard` → `inline`** (the default — you
45
- > author the verdict yourself), **`strict` → `fresh`** (dispatch the
46
- > maker-blind critic). The derived level feeds `review-depth.js`, not
47
- > this decision; review depth resolves `deep` for any sensitive path.
42
+ > One call writes the verdict **skeleton** — one record per
43
+ > `acceptance[]` item, in order, `index` and `criterion` filled, `verdict`
44
+ > and `evidence` empty, plus `storyId`, `schemaVersion`, the next `round`
45
+ > and HEAD — under `temp/scratch/story-<id>/`, and prints its path, the
46
+ > change set computed once (`files`) and the `verdictOwner`, derived by the
47
+ > same function `ceremony-derive.js` uses: **`minimal` / `standard` →
48
+ > `inline`** (the default — you fill the skeleton yourself), **`strict` →
49
+ > `fresh`** (dispatch the maker-blind critic with that `files` list).
50
+ > `ceremony-derive.js` stays for close and for a critic hand-off outside
51
+ > this loop; the level it derives feeds `review-depth.js`, not this
52
+ > decision.
48
53
 
49
54
  **Never run both**, and never run a preliminary self-assessment before
50
55
  dispatching a fresh critic — the redundant pre-pass buys no measurable
@@ -95,13 +100,11 @@ per-criterion, mid-delivery, and evaluates the actual work product.
95
100
  without being respawned; a stale or absent stamp reports `spawn: true` and
96
101
  the command runs for real. The credited run itself is stated once, in
97
102
  [`deliver-digest.md`](deliver-digest.md) § 5.
98
- + Emits **one** verdict file under `temp/scratch/story-<id>/` conforming to
103
+ + **Fills the skeleton** into **one** verdict file conforming to
99
104
  [`acceptance-eval-verdict.schema.json`](../../schemas/acceptance-eval-verdict.schema.json):
100
- one `{ index, criterion, verdict: met|partial|unmet, evidence,
101
- verifyEvidence[] }` record per `acceptance[]` item, in acceptance-array
102
- order, under a single top-level `storyId`, `schemaVersion`, `round` and
103
- `commitSha`. A fresh critic **returns that path to you** rather than
104
- calling the gate itself.
105
+ every `{ index, criterion, verdict: met|partial|unmet, evidence,
106
+ verifyEvidence[] }` record, in acceptance-array order. A fresh critic
107
+ **returns that path to you** rather than calling the gate itself.
105
108
  2. **Decide — exactly one gate call per round.** Run the gate against that one
106
109
  verdict file (the caller's Step 1a names the exact invocation — omit
107
110
  `--epic`). The gate **scores the verdict the round produced** — schema
@@ -115,8 +118,10 @@ per-criterion, mid-delivery, and evaluates the actual work product.
115
118
  The gate reads the Story's `acceptance[]` count itself (Story #5313): a
116
119
  verdict whose `criteria[]` length differs — one covering only part of the
117
120
  Story — is rejected **before scoring**, with an error naming the count and
118
- consuming **no round**. `--expected-criteria` is still accepted but
119
- redundant; when passed it must agree with that count.
121
+ consuming **no round**. A skeleton record left unfilled (empty `verdict`
122
+ or `evidence`) is likewise rejected before scoring, naming the unfilled
123
+ indices, with no round consumed. `--expected-criteria` is still accepted
124
+ but redundant; when passed it must agree with that count.
120
125
 
121
126
  > **Why one call per round and not several.** The round counter is
122
127
  > **Story-scoped** — derived by counting `acceptance-eval` signals in the
@@ -127,11 +132,12 @@ per-criterion, mid-delivery, and evaluates the actual work product.
127
132
  The gate validates the verdict against the schema, applies the round cap,
128
133
  emits the per-criterion `acceptance-eval` signal into the retro / feedback
129
134
  substrate, prints a JSON envelope, and exits with one of three decisions:
130
- + **`decision: "proceed"`** (every criterion `met`) → exit 0. Proceed to
131
- close.
135
+ + **`decision: "proceed"`** (every criterion `met`) → exit 0. Run the one
136
+ tail command, `story-handoff.js` ([`deliver-digest.md`](deliver-digest.md)
137
+ § 5).
132
138
  + **`decision: "redraft"`** (some `partial`/`unmet`, rounds remaining) →
133
139
  exit 0. Redraft the flagged criteria (named in `unmetCriteria[]`), commit
134
- the fix, and start another round.
140
+ the fix, re-run `--init` for the next round's skeleton, and score again.
135
141
  + **`decision: "block"`** (round cap reached, criteria still unmet) → exit
136
142
  non-zero. **Do not proceed to close.** Take the caller's blocked path
137
143
  (transition to `agent::blocked`) and post a `friction` comment naming the
@@ -79,7 +79,7 @@ How each tier changes the review protocol:
79
79
  The LLM-backed review providers (code-review, codex, security-review,
80
80
  ultrareview) render the resolved `depth` into the prompt/instructions they emit so the underlying
81
81
  model actually changes thoroughness. The native provider deliberately ignores
82
- `depth` — its mechanical lint + maintainability sweep already scales with diff
82
+ `depth` — its mechanical maintainability sweep already scales with diff
83
83
  size, and there is no "review harder" knob a deterministic scorer can turn (its
84
84
  module JSDoc documents this). When you (the host LLM) perform the Step 2 pillar
85
85
  review yourself, honor the `depth` semantics above directly.
@@ -108,8 +108,8 @@ diff `baseRef..headRef`, with the LLM-backed providers honoring `depth`
108
108
  The pipeline will:
109
109
 
110
110
  - Generate a `git diff baseRef..headRef`.
111
- - Calculate maintainability scores for all new/modified files.
112
- - Run a focused lint check on the change set.
111
+ - Calculate maintainability scores for all new/modified files (lint is a
112
+ close-validation gate, so the review does not re-run it).
113
113
  - Post a structured summary report to the `[TICKET_ID]` issue.
114
114
 
115
115
  ### Story scope runs no lens pass