mandrel 2.69.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.
- package/.agents/README.md +8 -9
- package/.agents/agents/acceptance-critic.md +1 -0
- package/.agents/agents/auditor.md +1 -0
- package/.agents/agents/plan-critic.md +1 -0
- package/.agents/agents/story-worker.md +63 -64
- package/.agents/docs/agentrc-reference.json +2 -1
- package/.agents/docs/configuration.md +7 -8
- package/.agents/rules/git-conventions-reference.md +2 -2
- package/.agents/schemas/agentrc.schema.json +19 -2
- package/.agents/scripts/acceptance-eval.js +194 -15
- package/.agents/scripts/audit-to-stories.js +39 -247
- package/.agents/scripts/deliver-run.js +92 -43
- package/.agents/scripts/lib/audit-suite/index.js +1 -1
- package/.agents/scripts/lib/audit-suite/story-checklist.js +65 -0
- package/.agents/scripts/lib/audit-to-stories/audit-label-taxonomy.js +2 -2
- package/.agents/scripts/lib/audit-to-stories/finding-adapter.js +1 -1
- package/.agents/scripts/lib/bootstrap/issue-forms-template.js +1 -1
- package/.agents/scripts/lib/cli-args.js +22 -0
- package/.agents/scripts/lib/close-validation/gates.js +17 -3
- package/.agents/scripts/lib/config/agent-models.js +117 -0
- package/.agents/scripts/lib/config-settings-schema-delivery.js +13 -1
- package/.agents/scripts/lib/config-settings-schema-quality.js +1 -1
- package/.agents/scripts/lib/findings/route-finding.js +15 -0
- package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
- package/.agents/scripts/lib/git/sync-from-base.js +89 -17
- package/.agents/scripts/lib/label-taxonomy.js +13 -3
- package/.agents/scripts/lib/notifications/notifier.js +11 -15
- package/.agents/scripts/lib/observability/close-telemetry.js +19 -3
- package/.agents/scripts/lib/observability/source-classifier.js +1 -0
- package/.agents/scripts/lib/orchestration/code-review.js +2 -2
- package/.agents/scripts/lib/orchestration/file-assumptions.js +45 -11
- package/.agents/scripts/lib/orchestration/plan-context.js +31 -11
- package/.agents/scripts/lib/orchestration/plan-persist/audit-provenance.js +35 -117
- package/.agents/scripts/lib/orchestration/plan-persist/changes-repair.js +130 -24
- package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +24 -22
- package/.agents/scripts/lib/orchestration/plan-persist/story-ops.js +1 -0
- package/.agents/scripts/lib/orchestration/plan-persist/summary.js +4 -3
- package/.agents/scripts/lib/orchestration/resolve-stories.js +10 -2
- package/.agents/scripts/lib/orchestration/review-providers/native.js +5 -165
- package/.agents/scripts/lib/orchestration/single-story-close/failed-terminal.js +14 -2
- package/.agents/scripts/lib/orchestration/single-story-close/phases/base-sync.js +151 -56
- package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +4 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/options.js +20 -4
- package/.agents/scripts/lib/orchestration/single-story-close/runner.js +26 -17
- package/.agents/scripts/lib/orchestration/story-handoff.js +849 -0
- package/.agents/scripts/lib/orchestration/story-init-result.js +83 -0
- package/.agents/scripts/lib/orchestration/task-body-validator.js +35 -5
- package/.agents/scripts/lib/orchestration/ticket-validator-sizing.js +1 -1
- package/.agents/scripts/lib/orchestration/ticket-validator.js +20 -2
- package/.agents/scripts/lib/single-story/confirm-merge.js +44 -7
- package/.agents/scripts/lib/story-body/story-body.js +40 -5
- package/.agents/scripts/lib/templates/decomposer-prompts.js +33 -36
- package/.agents/scripts/single-story-close.js +8 -0
- package/.agents/scripts/single-story-init.js +17 -32
- package/.agents/scripts/story-handoff.js +112 -0
- package/.agents/scripts/sync-claude-agents.js +58 -27
- package/.agents/templates/docs/audit-sweep-runbook.md +29 -59
- package/.agents/workflows/audit-to-stories.md +40 -67
- package/.agents/workflows/helpers/acceptance-self-eval.md +24 -18
- package/.agents/workflows/helpers/code-review.md +3 -3
- package/.agents/workflows/helpers/deliver-digest.md +79 -80
- package/.agents/workflows/helpers/deliver-light.md +9 -7
- package/.agents/workflows/helpers/deliver-reference.md +38 -22
- package/.agents/workflows/helpers/deliver-story-reference.md +11 -9
- package/.agents/workflows/helpers/deliver-story.md +30 -23
- package/.agents/workflows/helpers/plan-reference.md +24 -9
- package/docs/CHANGELOG.md +30 -0
- package/lib/cli/registry.js +7 -0
- package/lib/migrations/index.js +2 -0
- package/lib/migrations/steps/2.70.0-retire-audit-ledger.js +36 -0
- package/package.json +4 -3
- package/.agents/scripts/lib/audit-to-stories/ledger-commit.js +0 -184
- package/.agents/scripts/lib/audit-to-stories/ledger-pr.js +0 -279
- package/.agents/scripts/lib/audit-to-stories/ledger-record.js +0 -88
- package/.agents/scripts/lib/findings/audit-ledger.js +0 -289
- package/.agents/scripts/lib/orchestration/review-providers/scoped-lint.js +0 -272
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* phases/base-sync.js — sync the Story branch from `origin/<baseBranch>`
|
|
3
3
|
* before push, so a PR does not open behind a base a sibling's merge just
|
|
4
|
-
* moved. Runs in the worktree (else the main checkout)
|
|
5
|
-
*
|
|
4
|
+
* moved. Runs in the worktree (else the main checkout). A baseline-only
|
|
5
|
+
* conflict resolves inside the sync; any other conflict against a confirmed
|
|
6
|
+
* base goes back to the delivering agent (friction, labels unchanged); every
|
|
7
|
+
* other failure blocks the Story. All failures throw.
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
10
|
import { getQuality } from '../../../config/quality.js';
|
|
@@ -11,6 +13,7 @@ import { filterFilesUnderTargets } from '../../../coverage-capture.js';
|
|
|
11
13
|
import { syncBranchFromBase } from '../../../git/sync-from-base.js';
|
|
12
14
|
import { Logger } from '../../../Logger.js';
|
|
13
15
|
import { AGENT_LABELS } from '../../../label-constants.js';
|
|
16
|
+
import { NEXT_COMMANDS } from '../../story-deliver-terminal.js';
|
|
14
17
|
import {
|
|
15
18
|
STATE_LABELS,
|
|
16
19
|
transitionTicketState,
|
|
@@ -57,7 +60,7 @@ export async function runBaseSyncPhase({
|
|
|
57
60
|
log: (tag, msg) => progress(tag, msg),
|
|
58
61
|
});
|
|
59
62
|
if (!syncResult.synced) {
|
|
60
|
-
await handleSyncFailure({
|
|
63
|
+
const { handedBack } = await handleSyncFailure({
|
|
61
64
|
provider,
|
|
62
65
|
storyId,
|
|
63
66
|
syncCwd,
|
|
@@ -67,17 +70,18 @@ export async function runBaseSyncPhase({
|
|
|
67
70
|
result: syncResult,
|
|
68
71
|
progress,
|
|
69
72
|
});
|
|
70
|
-
throw
|
|
71
|
-
`[single-story-close] Base-sync failed (${syncResult.kind})` +
|
|
72
|
-
(syncResult.conflictFiles
|
|
73
|
-
? `: conflicting files = ${syncResult.conflictFiles.join(', ')}`
|
|
74
|
-
: syncResult.stderr
|
|
75
|
-
? `: ${syncResult.stderr.slice(0, 200)}`
|
|
76
|
-
: '') +
|
|
77
|
-
`. Story transitioned to ${AGENT_LABELS.BLOCKED}; resolve in ${syncCwd} and re-run \`/mandrel-deliver ${storyId}\`.`,
|
|
78
|
-
);
|
|
73
|
+
throw buildSyncFailureError({ storyId, syncCwd, syncResult, handedBack });
|
|
79
74
|
}
|
|
80
75
|
progress('SYNC', `✅ Synced from origin/${baseBranch} (${syncResult.kind}).`);
|
|
76
|
+
const resolved = syncResult.resolvedBaselineFiles ?? [];
|
|
77
|
+
if (resolved.length > 0) {
|
|
78
|
+
progress(
|
|
79
|
+
'SYNC',
|
|
80
|
+
`♻️ Baseline-only conflict resolved to origin/${baseBranch}'s version ` +
|
|
81
|
+
`(the insert-only seat and close's gates re-derive this Story's rows): ` +
|
|
82
|
+
resolved.join(', '),
|
|
83
|
+
);
|
|
84
|
+
}
|
|
81
85
|
for (const line of buildStampInvalidatedWarning({
|
|
82
86
|
baseBranch,
|
|
83
87
|
result: syncResult,
|
|
@@ -87,6 +91,36 @@ export async function runBaseSyncPhase({
|
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
|
|
94
|
+
/** A handed-back conflict re-runs close next (`closeNextCommand`). */
|
|
95
|
+
function buildSyncFailureError({ storyId, syncCwd, syncResult, handedBack }) {
|
|
96
|
+
const err = new Error(
|
|
97
|
+
`[single-story-close] Base-sync failed (${syncResult.kind})` +
|
|
98
|
+
syncFailureDetail(syncResult) +
|
|
99
|
+
(handedBack
|
|
100
|
+
? `. Labels unchanged — resolve the conflict in ${syncCwd}, commit, and re-run close.`
|
|
101
|
+
: `. Story transitioned to ${AGENT_LABELS.BLOCKED}; resolve in ${syncCwd} and re-run \`/mandrel-deliver ${storyId}\`.`),
|
|
102
|
+
);
|
|
103
|
+
if (handedBack) err.closeNextCommand = NEXT_COMMANDS.close(storyId);
|
|
104
|
+
return err;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function syncFailureDetail({ conflictFiles, stderr }) {
|
|
108
|
+
if (conflictFiles) return `: conflicting files = ${conflictFiles.join(', ')}`;
|
|
109
|
+
return stderr ? `: ${stderr.slice(0, 200)}` : '';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* A source conflict against a confirmed base is the delivering agent's to
|
|
114
|
+
* resolve; every other sync failure needs a human.
|
|
115
|
+
*
|
|
116
|
+
* @param {{ kind: string }} result
|
|
117
|
+
* @param {boolean} baseConfirmed
|
|
118
|
+
* @returns {boolean}
|
|
119
|
+
*/
|
|
120
|
+
function isHandedBack(result, baseConfirmed) {
|
|
121
|
+
return result.kind === 'conflict' && baseConfirmed === true;
|
|
122
|
+
}
|
|
123
|
+
|
|
90
124
|
/**
|
|
91
125
|
* The CRAP scoring scope, or `[]` when unresolvable.
|
|
92
126
|
*
|
|
@@ -142,7 +176,8 @@ function buildStampInvalidatedWarning({ baseBranch, result, targetDirs }) {
|
|
|
142
176
|
}
|
|
143
177
|
|
|
144
178
|
/**
|
|
145
|
-
* Post a `friction` comment
|
|
179
|
+
* Post a `friction` comment, then block the Story unless the failure is
|
|
180
|
+
* handed back to the delivering agent; both best-effort.
|
|
146
181
|
*
|
|
147
182
|
* @param {{
|
|
148
183
|
* provider: object,
|
|
@@ -154,6 +189,7 @@ function buildStampInvalidatedWarning({ baseBranch, result, targetDirs }) {
|
|
|
154
189
|
* result: { kind: string, conflictFiles?: string[], stderr?: string },
|
|
155
190
|
* progress: (tag: string, msg: string) => void,
|
|
156
191
|
* }} args
|
|
192
|
+
* @returns {Promise<{ handedBack: boolean }>}
|
|
157
193
|
*/
|
|
158
194
|
export async function handleSyncFailure({
|
|
159
195
|
provider,
|
|
@@ -185,6 +221,25 @@ export async function handleSyncFailure({
|
|
|
185
221
|
);
|
|
186
222
|
}
|
|
187
223
|
|
|
224
|
+
const handedBack = isHandedBack(result, baseConfirmed);
|
|
225
|
+
await settleSyncFailureLabels({ provider, storyId, handedBack, progress });
|
|
226
|
+
return { handedBack };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** A handed-back conflict leaves the labels alone; anything else blocks. */
|
|
230
|
+
async function settleSyncFailureLabels({
|
|
231
|
+
provider,
|
|
232
|
+
storyId,
|
|
233
|
+
handedBack,
|
|
234
|
+
progress,
|
|
235
|
+
}) {
|
|
236
|
+
if (handedBack) {
|
|
237
|
+
progress(
|
|
238
|
+
'SYNC',
|
|
239
|
+
`↩️ Conflict handed back to the delivering agent; Story #${storyId} labels unchanged.`,
|
|
240
|
+
);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
188
243
|
// The canonical mutator: a bare label write skips the Projects v2 sync.
|
|
189
244
|
try {
|
|
190
245
|
await transitionTicketState(provider, storyId, STATE_LABELS.BLOCKED, {});
|
|
@@ -196,6 +251,80 @@ export async function handleSyncFailure({
|
|
|
196
251
|
}
|
|
197
252
|
}
|
|
198
253
|
|
|
254
|
+
const CLOSE_RERUN = (storyId) =>
|
|
255
|
+
`node .agents/scripts/single-story-close.js --story ${storyId}`;
|
|
256
|
+
|
|
257
|
+
function commentLede(handedBack, baseBranch) {
|
|
258
|
+
if (handedBack) {
|
|
259
|
+
return [
|
|
260
|
+
`**For the delivering agent:** the pre-push sync against \`origin/${baseBranch}\``,
|
|
261
|
+
'conflicts. Labels are unchanged — this is not a block. Resolve the',
|
|
262
|
+
'conflict in the worktree, commit, and re-run close:',
|
|
263
|
+
];
|
|
264
|
+
}
|
|
265
|
+
return [
|
|
266
|
+
`The pre-push sync against \`origin/${baseBranch}\` could not complete. The`,
|
|
267
|
+
'Story has been transitioned to `agent::blocked`. To resume:',
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function mergeAdvice({ storyId, syncCwd, baseBranch, handedBack }) {
|
|
272
|
+
const lines = [
|
|
273
|
+
'```bash',
|
|
274
|
+
`cd ${syncCwd}`,
|
|
275
|
+
`git fetch origin ${baseBranch}`,
|
|
276
|
+
`git merge --no-edit origin/${baseBranch}`,
|
|
277
|
+
'# resolve any conflicts, then:',
|
|
278
|
+
`git add -A ; git commit --no-edit`,
|
|
279
|
+
'# re-run close:',
|
|
280
|
+
CLOSE_RERUN(storyId),
|
|
281
|
+
'```',
|
|
282
|
+
];
|
|
283
|
+
if (!handedBack) return lines;
|
|
284
|
+
return [
|
|
285
|
+
...lines,
|
|
286
|
+
'',
|
|
287
|
+
'Only an agent that cannot resolve it takes the blocked path: post why,',
|
|
288
|
+
`then \`node .agents/scripts/update-ticket-state.js --ticket ${storyId} --state agent::blocked\`.`,
|
|
289
|
+
];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function unconfirmedBaseAdvice({ storyId, storyBranch, baseBranch }) {
|
|
293
|
+
return [
|
|
294
|
+
`⚠️ **No merge advice: \`${baseBranch}\` is unconfirmed.** This close could not`,
|
|
295
|
+
`read the base branch \`${storyBranch}\` was seeded from off the run's`,
|
|
296
|
+
'init receipt, so merging that base in could contaminate the branch',
|
|
297
|
+
'and its PR diff with an unrelated base. Establish the real base first —',
|
|
298
|
+
`check \`temp/orchestration/story-init-result-${storyId}.log\` and \`project.baseBranch\` in`,
|
|
299
|
+
'`.agentrc.json` / `.agentrc.local.json` — then merge that base and re-run:',
|
|
300
|
+
'',
|
|
301
|
+
'```bash',
|
|
302
|
+
CLOSE_RERUN(storyId),
|
|
303
|
+
'```',
|
|
304
|
+
];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function failureEvidence(kind, result) {
|
|
308
|
+
const files = result.conflictFiles ?? [];
|
|
309
|
+
if (kind === 'conflict' && files.length > 0) {
|
|
310
|
+
return [
|
|
311
|
+
'',
|
|
312
|
+
'**Conflicting files:**',
|
|
313
|
+
'',
|
|
314
|
+
...files.map((f) => `- \`${f}\``),
|
|
315
|
+
];
|
|
316
|
+
}
|
|
317
|
+
if (!result.stderr) return [];
|
|
318
|
+
return [
|
|
319
|
+
'',
|
|
320
|
+
'**git stderr:**',
|
|
321
|
+
'',
|
|
322
|
+
'```',
|
|
323
|
+
result.stderr.slice(0, 1000),
|
|
324
|
+
'```',
|
|
325
|
+
];
|
|
326
|
+
}
|
|
327
|
+
|
|
199
328
|
/**
|
|
200
329
|
* `baseConfirmed` (default false, fail-closed) gates the merge-the-base
|
|
201
330
|
* advice: merging a base the Story was not seeded from contaminates the
|
|
@@ -213,54 +342,20 @@ export function buildSyncFailureCommentBody({
|
|
|
213
342
|
result,
|
|
214
343
|
}) {
|
|
215
344
|
const kind = result.kind ?? 'unknown';
|
|
345
|
+
const handedBack = isHandedBack(result, baseConfirmed);
|
|
216
346
|
const heading =
|
|
217
347
|
kind === 'conflict'
|
|
218
348
|
? `Base-sync conflict on close: ${storyBranch} ↔ origin/${baseBranch}`
|
|
219
349
|
: `Base-sync failed on close (${kind}): ${storyBranch} ↔ origin/${baseBranch}`;
|
|
220
|
-
const
|
|
221
|
-
|
|
350
|
+
const advice = baseConfirmed
|
|
351
|
+
? mergeAdvice({ storyId, syncCwd, baseBranch, handedBack })
|
|
352
|
+
: unconfirmedBaseAdvice({ storyId, storyBranch, baseBranch });
|
|
353
|
+
return [
|
|
222
354
|
`### ${heading}`,
|
|
223
355
|
'',
|
|
224
|
-
|
|
225
|
-
`sync against \`origin/${baseBranch}\` could not complete. The Story has`,
|
|
226
|
-
`been transitioned to \`agent::blocked\`. To resume:`,
|
|
356
|
+
...commentLede(handedBack, baseBranch),
|
|
227
357
|
'',
|
|
228
|
-
...
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
`cd ${syncCwd}`,
|
|
232
|
-
`git fetch origin ${baseBranch}`,
|
|
233
|
-
`git merge --no-edit origin/${baseBranch}`,
|
|
234
|
-
'# resolve any conflicts, then:',
|
|
235
|
-
`git add -A ; git commit --no-edit`,
|
|
236
|
-
'# re-run close:',
|
|
237
|
-
`node .agents/scripts/single-story-close.js --story ${storyId}`,
|
|
238
|
-
'```',
|
|
239
|
-
]
|
|
240
|
-
: [
|
|
241
|
-
`⚠️ **No merge advice: \`${baseBranch}\` is unconfirmed.** This close could not`,
|
|
242
|
-
`read the base branch \`${storyBranch}\` was seeded from off the run's`,
|
|
243
|
-
'init receipt, so merging that base in could contaminate the branch',
|
|
244
|
-
'and its PR diff with an unrelated base. Establish the real base first —',
|
|
245
|
-
`check \`temp/orchestration/story-init-result-${storyId}.log\` and \`project.baseBranch\` in`,
|
|
246
|
-
'`.agentrc.json` / `.agentrc.local.json` — then merge that base and re-run:',
|
|
247
|
-
'',
|
|
248
|
-
'```bash',
|
|
249
|
-
`node .agents/scripts/single-story-close.js --story ${storyId}`,
|
|
250
|
-
'```',
|
|
251
|
-
]),
|
|
252
|
-
];
|
|
253
|
-
if (kind === 'conflict' && fileList.length > 0) {
|
|
254
|
-
lines.push('', '**Conflicting files:**', '', ...fileList);
|
|
255
|
-
} else if (result.stderr) {
|
|
256
|
-
lines.push(
|
|
257
|
-
'',
|
|
258
|
-
'**git stderr:**',
|
|
259
|
-
'',
|
|
260
|
-
'```',
|
|
261
|
-
result.stderr.slice(0, 1000),
|
|
262
|
-
'```',
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
return lines.join('\n');
|
|
358
|
+
...advice,
|
|
359
|
+
...failureEvidence(kind, result),
|
|
360
|
+
].join('\n');
|
|
266
361
|
}
|
|
@@ -942,6 +942,7 @@ async function onMergeObserved({
|
|
|
942
942
|
emitMergeFlipFailedFn,
|
|
943
943
|
prProbe,
|
|
944
944
|
elapsedSeconds,
|
|
945
|
+
sleepFn,
|
|
945
946
|
}) {
|
|
946
947
|
const confirmation = await confirmStoryMergedFn({
|
|
947
948
|
provider,
|
|
@@ -956,6 +957,8 @@ async function onMergeObserved({
|
|
|
956
957
|
readPrMergeStateFn,
|
|
957
958
|
// Saves confirmation a second `gh pr view`.
|
|
958
959
|
prState: prProbe,
|
|
960
|
+
// The done-flip retry backs off on the wait's own clock.
|
|
961
|
+
sleepFn,
|
|
959
962
|
});
|
|
960
963
|
|
|
961
964
|
if (confirmation.merged && confirmation.action === 'flip-failed') {
|
|
@@ -1401,6 +1404,7 @@ export async function runConfirmMergePhase({
|
|
|
1401
1404
|
issued: new Set(),
|
|
1402
1405
|
},
|
|
1403
1406
|
confirmStoryMergedFn,
|
|
1407
|
+
sleepFn,
|
|
1404
1408
|
readPrWaitProbeFn,
|
|
1405
1409
|
readPrMergeStateFn,
|
|
1406
1410
|
classifyMergeBlockFn,
|
|
@@ -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
|
-
|
|
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
|
-
|
|
113
|
+
worker = NO_WORKER,
|
|
110
114
|
}) {
|
|
111
115
|
phaseTimer.stamp(terminal);
|
|
112
|
-
await recordCloseTelemetry({ terminal, result, config,
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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);
|