mandrel 2.70.0 → 2.71.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 (64) 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/scripts/acceptance-eval.js +194 -15
  11. package/.agents/scripts/deliver-run.js +92 -43
  12. package/.agents/scripts/lib/audit-suite/index.js +1 -1
  13. package/.agents/scripts/lib/audit-suite/story-checklist.js +65 -0
  14. package/.agents/scripts/lib/audit-to-stories/audit-label-taxonomy.js +2 -2
  15. package/.agents/scripts/lib/bootstrap/issue-forms-template.js +1 -1
  16. package/.agents/scripts/lib/cli-args.js +22 -0
  17. package/.agents/scripts/lib/close-validation/gates.js +17 -3
  18. package/.agents/scripts/lib/config/agent-models.js +117 -0
  19. package/.agents/scripts/lib/config-settings-schema-delivery.js +13 -1
  20. package/.agents/scripts/lib/config-settings-schema-quality.js +1 -1
  21. package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
  22. package/.agents/scripts/lib/git/sync-from-base.js +89 -17
  23. package/.agents/scripts/lib/label-taxonomy.js +13 -3
  24. package/.agents/scripts/lib/notifications/notifier.js +11 -15
  25. package/.agents/scripts/lib/observability/close-telemetry.js +19 -3
  26. package/.agents/scripts/lib/observability/source-classifier.js +1 -0
  27. package/.agents/scripts/lib/orchestration/code-review.js +2 -2
  28. package/.agents/scripts/lib/orchestration/file-assumptions.js +45 -11
  29. package/.agents/scripts/lib/orchestration/plan-context.js +17 -10
  30. package/.agents/scripts/lib/orchestration/plan-persist/changes-repair.js +130 -24
  31. package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +19 -16
  32. package/.agents/scripts/lib/orchestration/plan-persist/story-ops.js +1 -0
  33. package/.agents/scripts/lib/orchestration/plan-persist/summary.js +4 -3
  34. package/.agents/scripts/lib/orchestration/resolve-stories.js +10 -2
  35. package/.agents/scripts/lib/orchestration/review-providers/native.js +5 -165
  36. package/.agents/scripts/lib/orchestration/single-story-close/failed-terminal.js +14 -2
  37. package/.agents/scripts/lib/orchestration/single-story-close/phases/base-sync.js +151 -56
  38. package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +4 -0
  39. package/.agents/scripts/lib/orchestration/single-story-close/phases/options.js +20 -4
  40. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +26 -17
  41. package/.agents/scripts/lib/orchestration/story-handoff.js +849 -0
  42. package/.agents/scripts/lib/orchestration/story-init-result.js +83 -0
  43. package/.agents/scripts/lib/orchestration/task-body-validator.js +35 -5
  44. package/.agents/scripts/lib/orchestration/ticket-validator-sizing.js +1 -1
  45. package/.agents/scripts/lib/orchestration/ticket-validator.js +20 -2
  46. package/.agents/scripts/lib/single-story/confirm-merge.js +44 -7
  47. package/.agents/scripts/lib/story-body/story-body.js +40 -5
  48. package/.agents/scripts/lib/templates/decomposer-prompts.js +33 -36
  49. package/.agents/scripts/single-story-close.js +8 -0
  50. package/.agents/scripts/single-story-init.js +17 -32
  51. package/.agents/scripts/story-handoff.js +112 -0
  52. package/.agents/scripts/sync-claude-agents.js +58 -27
  53. package/.agents/workflows/helpers/acceptance-self-eval.md +24 -18
  54. package/.agents/workflows/helpers/code-review.md +3 -3
  55. package/.agents/workflows/helpers/deliver-digest.md +79 -80
  56. package/.agents/workflows/helpers/deliver-light.md +9 -7
  57. package/.agents/workflows/helpers/deliver-reference.md +38 -22
  58. package/.agents/workflows/helpers/deliver-story-reference.md +11 -9
  59. package/.agents/workflows/helpers/deliver-story.md +30 -23
  60. package/.agents/workflows/helpers/plan-reference.md +24 -9
  61. package/docs/CHANGELOG.md +19 -0
  62. package/lib/cli/registry.js +7 -0
  63. package/package.json +4 -3
  64. package/.agents/scripts/lib/orchestration/review-providers/scoped-lint.js +0 -272
@@ -110,11 +110,27 @@ export function assertNoRetiredFlags(argv) {
110
110
  }
111
111
  }
112
112
 
113
+ /**
114
+ * The story-worker figures close records in its telemetry. Raw: validated
115
+ * best-effort by the runner, never thrown on.
116
+ *
117
+ * @param {unknown} tokensParam
118
+ * @param {unknown} modelParam
119
+ * @param {{ workerTokens?: unknown, workerModel?: unknown }} parsed
120
+ * @returns {{ workerTokens: unknown, workerModel: unknown }}
121
+ */
122
+ function workerFlags(tokensParam, modelParam, parsed) {
123
+ return {
124
+ workerTokens: resolveFlag(tokensParam, parsed.workerTokens),
125
+ workerModel: resolveFlag(modelParam, parsed.workerModel),
126
+ };
127
+ }
128
+
113
129
  /**
114
130
  * Returns raw wait-for-merge intent; the runner resolves it after the arm.
115
131
  *
116
- * @param {{ storyIdParam, cwdParam, skipValidationParam, skipSyncParam, noAutoMergeParam, waitForMergeParam, noWaitForMergeParam, maxWaitSecondsParam, mergeWatchModeParam, rerunAdvisoryParam, overrideReviewBlockParam, workerTokensParam }} raw
117
- * @returns {{ storyId, cwd, skipValidation, skipSync, noAutoMerge, waitForMergeExplicit, noWaitForMerge, maxWaitSeconds, mergeWatchMode, rerunAdvisory, overrideReviewBlock, workerTokens }}
132
+ * @param {{ storyIdParam, cwdParam, skipValidationParam, skipSyncParam, noAutoMergeParam, waitForMergeParam, noWaitForMergeParam, maxWaitSecondsParam, mergeWatchModeParam, rerunAdvisoryParam, overrideReviewBlockParam, workerTokensParam, workerModelParam }} raw
133
+ * @returns {{ storyId, cwd, skipValidation, skipSync, noAutoMerge, waitForMergeExplicit, noWaitForMerge, maxWaitSeconds, mergeWatchMode, rerunAdvisory, overrideReviewBlock, workerTokens, workerModel }}
118
134
  */
119
135
  export function parseCloseOptions({
120
136
  storyIdParam,
@@ -129,6 +145,7 @@ export function parseCloseOptions({
129
145
  rerunAdvisoryParam,
130
146
  overrideReviewBlockParam,
131
147
  workerTokensParam,
148
+ workerModelParam,
132
149
  }) {
133
150
  // An injecting caller never reads argv (the host's flags are not its
134
151
  // business), so `parsed` stays empty and the retired-flag guard is skipped.
@@ -169,7 +186,6 @@ export function parseCloseOptions({
169
186
  overrideReviewBlock: parseOverrideReviewBlock(
170
187
  resolveFlag(overrideReviewBlockParam, parsed.overrideReviewBlock),
171
188
  ),
172
- // Raw: validated best-effort by the runner, never thrown on.
173
- workerTokens: resolveFlag(workerTokensParam, parsed.workerTokens),
189
+ ...workerFlags(workerTokensParam, workerModelParam, parsed),
174
190
  };
175
191
  }
@@ -12,6 +12,7 @@ import { Logger } from '../../Logger.js';
12
12
  import {
13
13
  emitReviewBlockedFriction,
14
14
  recordCloseTelemetry,
15
+ resolveWorkerModel,
15
16
  resolveWorkerTokens,
16
17
  } from '../../observability/close-telemetry.js';
17
18
  import { emitTerminalFriction } from '../../observability/runtime-friction.js';
@@ -95,6 +96,9 @@ function createPhaseTimer(nowMs = Date.now) {
95
96
 
96
97
  const UNTIMED = Object.freeze({ stamp() {} });
97
98
 
99
+ /** No worker figures: an inline close, or an ending before they resolve. */
100
+ const NO_WORKER = Object.freeze({ workerTokens: null, workerModel: null });
101
+
98
102
  /**
99
103
  * The single terminal writer: the retry signal, the result summary (with its
100
104
  * `telemetry`), the envelope callers parse, and terminal friction — so no
@@ -106,10 +110,10 @@ async function emitTerminal({
106
110
  result,
107
111
  config,
108
112
  phaseTimer = UNTIMED,
109
- workerTokens = null,
113
+ worker = NO_WORKER,
110
114
  }) {
111
115
  phaseTimer.stamp(terminal);
112
- await recordCloseTelemetry({ terminal, result, config, workerTokens });
116
+ await recordCloseTelemetry({ terminal, result, config, ...worker });
113
117
  if (result) {
114
118
  emitTerseResult({
115
119
  label: 'STORY CLOSE RESULT',
@@ -146,7 +150,7 @@ async function alreadyClosedResult(
146
150
  storyId,
147
151
  stateReason = null,
148
152
  config,
149
- workerTokens = null,
153
+ worker = NO_WORKER,
150
154
  ) {
151
155
  if (stateReason === 'not_planned') {
152
156
  progress(
@@ -166,7 +170,7 @@ async function alreadyClosedResult(
166
170
  nextCommand: null,
167
171
  elapsedSeconds: 0,
168
172
  });
169
- await emitTerminal({ terminal, result, config, workerTokens });
173
+ await emitTerminal({ terminal, result, config, worker });
170
174
  return { success: false, result, terminal };
171
175
  }
172
176
 
@@ -179,7 +183,7 @@ async function alreadyClosedResult(
179
183
  nextCommand: null,
180
184
  elapsedSeconds: 0,
181
185
  });
182
- await emitTerminal({ terminal, result, config, workerTokens });
186
+ await emitTerminal({ terminal, result, config, worker });
183
187
  return { success: true, result, terminal };
184
188
  }
185
189
 
@@ -202,7 +206,7 @@ async function preflightBlockedResult({
202
206
  preflight,
203
207
  config,
204
208
  startedAtMs,
205
- workerTokens = null,
209
+ worker = NO_WORKER,
206
210
  }) {
207
211
  const result = noopResult(storyId, `graphql-preflight-${preflight.verdict}`);
208
212
  const terminal = buildTerminalEnvelope({
@@ -217,7 +221,7 @@ async function preflightBlockedResult({
217
221
  nextCommand: NEXT_COMMANDS.close(storyId),
218
222
  elapsedSeconds: elapsedSecondsSince(startedAtMs),
219
223
  });
220
- await emitTerminal({ terminal, result, config, workerTokens });
224
+ await emitTerminal({ terminal, result, config, worker });
221
225
  return { success: false, result, terminal };
222
226
  }
223
227
 
@@ -589,6 +593,7 @@ export async function runSingleStoryClose({
589
593
  rerunAdvisory: rerunAdvisoryParam,
590
594
  overrideReviewBlock: overrideReviewBlockParam,
591
595
  workerTokens: workerTokensParam,
596
+ workerModel: workerModelParam,
592
597
  ...injected
593
598
  } = {}) {
594
599
  const options = parseCloseOptions({
@@ -604,10 +609,11 @@ export async function runSingleStoryClose({
604
609
  rerunAdvisoryParam,
605
610
  overrideReviewBlockParam,
606
611
  workerTokensParam,
612
+ workerModelParam,
607
613
  });
608
614
  if (!options.storyId) {
609
615
  throw new Error(
610
- 'Usage: node single-story-close.js --story <STORY_ID> [--cwd <main-repo>] [--skip-validation] [--skip-sync] [--no-auto-merge] [--wait-merge|--no-wait-merge] [--max-wait-seconds <n>] [--merge-watch-mode <sync|async>] [--rerun-advisory <n>] [--override-review-block <reason>] [--worker-tokens <n>]',
616
+ 'Usage: node single-story-close.js --story <STORY_ID> [--cwd <main-repo>] [--skip-validation] [--skip-sync] [--no-auto-merge] [--wait-merge|--no-wait-merge] [--max-wait-seconds <n>] [--merge-watch-mode <sync|async>] [--rerun-advisory <n>] [--override-review-block <reason>] [--worker-tokens <n>] [--worker-model <model>]',
611
617
  );
612
618
  }
613
619
 
@@ -754,7 +760,7 @@ async function finishWithMergeWait(prCtx, deps) {
754
760
  result,
755
761
  config: prCtx.config,
756
762
  phaseTimer: prCtx.phaseTimer,
757
- workerTokens: prCtx.workerTokens,
763
+ worker: prCtx.worker,
758
764
  });
759
765
  reportWaitTerminal(terminal, { storyId: prCtx.storyId, prUrl: prCtx.prUrl });
760
766
  return { success: terminal.status === 'landed', result, terminal };
@@ -809,7 +815,7 @@ async function finishWithoutMergeWait(prCtx, waitForMergeReason) {
809
815
  result,
810
816
  config: prCtx.config,
811
817
  phaseTimer: prCtx.phaseTimer,
812
- workerTokens: prCtx.workerTokens,
818
+ worker: prCtx.worker,
813
819
  });
814
820
  progress(
815
821
  'DONE',
@@ -828,14 +834,14 @@ async function finishWithoutMergeWait(prCtx, waitForMergeReason) {
828
834
  */
829
835
  async function finishDeferred(
830
836
  lockWait,
831
- { config, startedAtMs, phaseTimer, workerTokens, ...ids },
837
+ { config, startedAtMs, phaseTimer, worker, ...ids },
832
838
  ) {
833
839
  const { result, terminal, note } = lockWaitPending({
834
840
  ...ids,
835
841
  lockWait,
836
842
  elapsedSeconds: elapsedSecondsSince(startedAtMs),
837
843
  });
838
- await emitTerminal({ terminal, result, config, phaseTimer, workerTokens });
844
+ await emitTerminal({ terminal, result, config, phaseTimer, worker });
839
845
  progress('PENDING', note);
840
846
  return { success: false, result, terminal };
841
847
  }
@@ -878,7 +884,7 @@ async function loadStoryPhase(ctx, deps) {
878
884
  ctx.storyId,
879
885
  ctx.story.stateReason,
880
886
  deps.config,
881
- ctx.workerTokens,
887
+ ctx.worker,
882
888
  );
883
889
  }
884
890
 
@@ -898,7 +904,7 @@ async function graphqlPreflightPhase(ctx, deps) {
898
904
  preflight,
899
905
  config: deps.config,
900
906
  startedAtMs: ctx.startedAtMs,
901
- workerTokens: ctx.workerTokens,
907
+ worker: ctx.worker,
902
908
  });
903
909
  }
904
910
 
@@ -937,7 +943,7 @@ async function prePushPhase(ctx, deps) {
937
943
  config: deps.config,
938
944
  startedAtMs: ctx.startedAtMs,
939
945
  phaseTimer: ctx.phaseTimer,
940
- workerTokens: ctx.workerTokens,
946
+ worker: ctx.worker,
941
947
  });
942
948
  }
943
949
 
@@ -1028,7 +1034,7 @@ async function finishPhase(ctx, deps) {
1028
1034
  config: deps.config,
1029
1035
  startedAtMs: ctx.startedAtMs,
1030
1036
  phaseTimer: ctx.phaseTimer,
1031
- workerTokens: ctx.workerTokens,
1037
+ worker: ctx.worker,
1032
1038
  lockWait: ctx.prePush.lockWait,
1033
1039
  suiteTimings: ctx.prePush.suiteTimings,
1034
1040
  gates: closeEnvelopeGates(
@@ -1074,7 +1080,10 @@ async function runClosePipeline(run, deps) {
1074
1080
  ...run,
1075
1081
  storyId: run.options.storyId,
1076
1082
  storyBranch: getStoryBranch(run.options.storyId),
1077
- workerTokens: resolveWorkerTokens(run.options.workerTokens),
1083
+ worker: {
1084
+ workerTokens: resolveWorkerTokens(run.options.workerTokens),
1085
+ workerModel: resolveWorkerModel(run.options.workerModel),
1086
+ },
1078
1087
  };
1079
1088
  for (const phase of CLOSE_PIPELINE) {
1080
1089
  const ending = await phase(ctx, deps);