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.
- 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/schemas/story-deliver-terminal.schema.json +10 -1
- package/.agents/scripts/acceptance-eval.js +194 -15
- 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/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/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/cancelled-run-discount.js +129 -0
- package/.agents/scripts/lib/orchestration/code-review.js +2 -2
- package/.agents/scripts/lib/orchestration/deliver-recover.js +166 -34
- package/.agents/scripts/lib/orchestration/file-assumptions.js +45 -11
- package/.agents/scripts/lib/orchestration/plan-context.js +17 -10
- package/.agents/scripts/lib/orchestration/plan-persist/changes-repair.js +130 -24
- package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +19 -16
- 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/pr-watch.js +14 -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/auto-merge.js +45 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/base-sync.js +162 -58
- package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +58 -6
- package/.agents/scripts/lib/orchestration/single-story-close/phases/merge-wait-recovery.js +296 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/options.js +20 -4
- package/.agents/scripts/lib/orchestration/single-story-close/phases/post-land.js +52 -6
- package/.agents/scripts/lib/orchestration/single-story-close/phases/pull-request.js +2 -2
- package/.agents/scripts/lib/orchestration/single-story-close/phases/story-branch-catch-up.js +50 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/worktree-reap.js +64 -52
- package/.agents/scripts/lib/orchestration/single-story-close/phases/worktree-restore.js +133 -0
- package/.agents/scripts/lib/orchestration/single-story-close/runner.js +187 -74
- package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +46 -6
- 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/pr-watch-with-update.js +5 -0
- package/.agents/scripts/single-story-close.js +8 -0
- package/.agents/scripts/single-story-confirm-merge.js +34 -3
- 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/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 +39 -18
- package/.agents/workflows/helpers/deliver-story.md +30 -23
- package/.agents/workflows/helpers/plan-reference.md +24 -9
- package/.agents/workflows/helpers/worktree-lifecycle.md +5 -5
- package/docs/CHANGELOG.md +31 -0
- package/lib/cli/registry.js +7 -0
- package/package.json +4 -3
- package/.agents/scripts/lib/orchestration/review-providers/scoped-lint.js +0 -272
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { spawnSync } from 'node:child_process';
|
|
9
9
|
|
|
10
10
|
import { applyBehindUpdate } from './behind-recovery.js';
|
|
11
|
+
import { createCancelledRunDiscount } from './cancelled-run-discount.js';
|
|
11
12
|
import { checkVerdict, classifyRequiredCheck } from './check-state.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -32,7 +33,7 @@ function ghPrChecks({ prUrl, cwd, repo, spawnFn = spawnSync }) {
|
|
|
32
33
|
prUrl,
|
|
33
34
|
'--required',
|
|
34
35
|
'--json',
|
|
35
|
-
'name,state,bucket,workflow',
|
|
36
|
+
'name,state,bucket,workflow,link',
|
|
36
37
|
...ghRepoFlag(repo),
|
|
37
38
|
],
|
|
38
39
|
{ cwd, encoding: 'utf-8', shell: false },
|
|
@@ -144,6 +145,10 @@ export function hasFailingCheck(outcomes) {
|
|
|
144
145
|
return Object.values(outcomes).some((v) => checkVerdict(v) === 'fail');
|
|
145
146
|
}
|
|
146
147
|
|
|
148
|
+
async function identityDiscount(_entries, outcomes) {
|
|
149
|
+
return outcomes;
|
|
150
|
+
}
|
|
151
|
+
|
|
147
152
|
function defaultSleep(ms) {
|
|
148
153
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
149
154
|
}
|
|
@@ -161,6 +166,7 @@ function defaultSleep(ms) {
|
|
|
161
166
|
* @param {Function} opts.ghPrChecksFn
|
|
162
167
|
* @param {number} opts.pollIntervalMs
|
|
163
168
|
* @param {Function} opts.sleepFn
|
|
169
|
+
* @param {Function} [opts.discountFn]
|
|
164
170
|
* @param {{ warn?: Function }} opts.logger
|
|
165
171
|
* @returns {Promise<{ outcomes: object, polls: number }>}
|
|
166
172
|
*/
|
|
@@ -174,6 +180,7 @@ export async function pollUntilTerminal({
|
|
|
174
180
|
ghPrChecksFn,
|
|
175
181
|
pollIntervalMs,
|
|
176
182
|
sleepFn,
|
|
183
|
+
discountFn = identityDiscount,
|
|
177
184
|
logger,
|
|
178
185
|
}) {
|
|
179
186
|
let currentOutcomes = outcomes;
|
|
@@ -189,7 +196,7 @@ export async function pollUntilTerminal({
|
|
|
189
196
|
);
|
|
190
197
|
continue;
|
|
191
198
|
}
|
|
192
|
-
currentOutcomes = reduceOutcomes(entries);
|
|
199
|
+
currentOutcomes = await discountFn(entries, reduceOutcomes(entries));
|
|
193
200
|
}
|
|
194
201
|
return { outcomes: currentOutcomes, polls: currentPolls };
|
|
195
202
|
}
|
|
@@ -212,6 +219,7 @@ export async function pollUntilTerminal({
|
|
|
212
219
|
* @param {Function} [opts.ghPrViewFn]
|
|
213
220
|
* @param {Function} [opts.ghPrUpdateBranchFn]
|
|
214
221
|
* @param {Function} [opts.sleepFn]
|
|
222
|
+
* @param {Function} [opts.ghApiFn]
|
|
215
223
|
* @param {{ info?: Function, warn?: Function, debug?: Function }} opts.logger
|
|
216
224
|
* @param {{status:number,stdout:string,stderr:string}} [opts.firstProbe]
|
|
217
225
|
* An already-issued `gh pr checks` result, so the first call is not
|
|
@@ -243,6 +251,7 @@ export async function watchPrToTerminal({
|
|
|
243
251
|
ghPrViewFn = ghPrView,
|
|
244
252
|
ghPrUpdateBranchFn = ghPrUpdateBranch,
|
|
245
253
|
sleepFn = defaultSleep,
|
|
254
|
+
ghApiFn,
|
|
246
255
|
logger,
|
|
247
256
|
firstProbe,
|
|
248
257
|
}) {
|
|
@@ -277,7 +286,8 @@ export async function watchPrToTerminal({
|
|
|
277
286
|
|
|
278
287
|
const requiredChecks = firstEntries.map((e) => e.name);
|
|
279
288
|
|
|
280
|
-
|
|
289
|
+
const discountFn = createCancelledRunDiscount({ repo, ghApiFn, logger });
|
|
290
|
+
let outcomes = await discountFn(firstEntries, reduceOutcomes(firstEntries));
|
|
281
291
|
let polls = 0;
|
|
282
292
|
let updatesApplied = 0;
|
|
283
293
|
let resumesApplied = 0;
|
|
@@ -294,6 +304,7 @@ export async function watchPrToTerminal({
|
|
|
294
304
|
ghPrChecksFn,
|
|
295
305
|
pollIntervalMs,
|
|
296
306
|
sleepFn,
|
|
307
|
+
discountFn,
|
|
297
308
|
logger,
|
|
298
309
|
}));
|
|
299
310
|
// BEHIND recovery only when all green; `maxUpdates` stops a racing
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { extractEpicIdFromBody, parseBlockedBy } from '../dependency-parser.js';
|
|
10
|
-
import { TYPE_LABELS } from '../label-constants.js';
|
|
10
|
+
import { AGENT_LABELS, TYPE_LABELS } from '../label-constants.js';
|
|
11
11
|
import { buildStoryAdjacency } from '../story-adjacency.js';
|
|
12
12
|
import {
|
|
13
13
|
extractChangePaths,
|
|
@@ -83,13 +83,21 @@ export function toStoryRecord(issue, requestedId, { allowUnlabelled } = {}) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* Refuse
|
|
86
|
+
* Refuse a Story still awaiting planning (`agent::review-spec`, which the
|
|
87
|
+
* issue form applies) or an unplanned one (audit sweeps file them unlabelled
|
|
88
|
+
* on purpose).
|
|
87
89
|
*
|
|
88
90
|
* @param {number} id
|
|
89
91
|
* @param {string[]} labels
|
|
90
92
|
* @param {boolean} [allowUnlabelled]
|
|
91
93
|
*/
|
|
92
94
|
function assertDispatchable(id, labels, allowUnlabelled) {
|
|
95
|
+
if (labels.includes(AGENT_LABELS.REVIEW_SPEC)) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
`[resolve-stories] Story #${id} is labelled ${AGENT_LABELS.REVIEW_SPEC}, so it is awaiting ` +
|
|
98
|
+
`planning before delivery. Run /mandrel-plan ${id} first, which applies agent::ready.`,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
93
101
|
if (allowUnlabelled) return;
|
|
94
102
|
if (labels.some((l) => l.startsWith(AGENT_LABEL_PREFIX))) return;
|
|
95
103
|
throw new Error(
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* review-providers/native.js — in-process ReviewProvider:
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* review-providers/native.js — in-process ReviewProvider: maintainability
|
|
3
|
+
* scoring of the changed files, honouring the gate's exemptions. It runs no
|
|
4
|
+
* lint — lint is a close-validation gate the worker's preflight also runs.
|
|
5
|
+
* `input.depth` is ignored by design.
|
|
5
6
|
*
|
|
6
7
|
* @typedef {import('./types.js').Finding} Finding
|
|
7
8
|
* @typedef {import('./types.js').ReviewInput} ReviewInput
|
|
@@ -15,23 +16,12 @@ import {
|
|
|
15
16
|
calculateReport,
|
|
16
17
|
classifyReport,
|
|
17
18
|
} from '../../maintainability-engine.js';
|
|
18
|
-
import {
|
|
19
|
-
emitRuntimeFriction,
|
|
20
|
-
RUNTIME_FRICTION_CATEGORIES,
|
|
21
|
-
} from '../../observability/runtime-friction.js';
|
|
22
19
|
import { PROJECT_ROOT } from '../../project-root.js';
|
|
23
20
|
import { transpileIfNeeded } from '../../transpile.js';
|
|
24
21
|
import {
|
|
25
22
|
resolveMaintainabilityIgnoreGlobs,
|
|
26
23
|
scopeMaintainabilityFiles,
|
|
27
24
|
} from './mi-exemptions.js';
|
|
28
|
-
import {
|
|
29
|
-
parseLintOutput,
|
|
30
|
-
partitionFilesForLint,
|
|
31
|
-
runScopedLint,
|
|
32
|
-
} from './scoped-lint.js';
|
|
33
|
-
|
|
34
|
-
export { parseLintOutput, partitionFilesForLint, runScopedLint };
|
|
35
25
|
|
|
36
26
|
const MAINTAINABILITY_REPORT_WORKER_URL = new URL(
|
|
37
27
|
'../../workers/maintainability-report-worker.js',
|
|
@@ -244,138 +234,29 @@ export async function analyzeChangedFiles(
|
|
|
244
234
|
return results;
|
|
245
235
|
}
|
|
246
236
|
|
|
247
|
-
/**
|
|
248
|
-
* Findings come from parsed counts, never `executionFailed` (an OR across
|
|
249
|
-
* surfaces), so one absent runner cannot discard the other's errors.
|
|
250
|
-
*
|
|
251
|
-
* @param {{ errors: number, warnings: number, parsed?: boolean, skipped?: boolean, mode?: string, executionFailed?: boolean, evidenceSkipped?: boolean }} lintSummary
|
|
252
|
-
* @returns {Finding[]}
|
|
253
|
-
*/
|
|
254
|
-
export function buildLintFindings(lintSummary) {
|
|
255
|
-
if (lintSummary.mode === 'off') return [];
|
|
256
|
-
if (lintSummary.evidenceSkipped) return [];
|
|
257
|
-
if (lintSummary.skipped) return [];
|
|
258
|
-
if (lintSummary.parsed === false) return [];
|
|
259
|
-
const findings = [];
|
|
260
|
-
if (lintSummary.errors > 0) {
|
|
261
|
-
findings.push({
|
|
262
|
-
severity: 'high',
|
|
263
|
-
title: `Lint check failed (${lintSummary.errors} error(s))`,
|
|
264
|
-
body:
|
|
265
|
-
`Scoped lint reported ${lintSummary.errors} error(s) and ` +
|
|
266
|
-
`${lintSummary.warnings} warning(s) on the changed surface. ` +
|
|
267
|
-
'Fix errors before merging.',
|
|
268
|
-
category: 'lint',
|
|
269
|
-
});
|
|
270
|
-
} else if (lintSummary.warnings > 0) {
|
|
271
|
-
findings.push({
|
|
272
|
-
severity: 'suggestion',
|
|
273
|
-
title: `Lint check passed with ${lintSummary.warnings} warning(s)`,
|
|
274
|
-
body:
|
|
275
|
-
`Scoped lint reported ${lintSummary.warnings} warning(s) on the ` +
|
|
276
|
-
'changed surface. Treat as suggestions.',
|
|
277
|
-
category: 'lint',
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
return findings;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
async function runLintPhase({
|
|
284
|
-
scopeLint,
|
|
285
|
-
changedFiles,
|
|
286
|
-
runScopedLintFn,
|
|
287
|
-
logger,
|
|
288
|
-
}) {
|
|
289
|
-
if (scopeLint === 'off') {
|
|
290
|
-
logger?.info?.(
|
|
291
|
-
'[native-review] Lint scoped off (scopeLint=off); skipping.',
|
|
292
|
-
);
|
|
293
|
-
return {
|
|
294
|
-
errors: 0,
|
|
295
|
-
warnings: 0,
|
|
296
|
-
parsed: false,
|
|
297
|
-
skipped: true,
|
|
298
|
-
mode: 'off',
|
|
299
|
-
executionFailed: false,
|
|
300
|
-
degradations: [],
|
|
301
|
-
surfaces: [],
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
logger?.info?.(
|
|
305
|
-
'[native-review] Linting changed files only (biome + markdownlint, scoped to diff)...',
|
|
306
|
-
);
|
|
307
|
-
return runScopedLintFn(changedFiles, PROJECT_ROOT);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Degradation records for an `executionFailed` summary; one without
|
|
312
|
-
* per-surface rows degrades to a single gate-wide record, never silence.
|
|
313
|
-
*
|
|
314
|
-
* @param {{ executionFailed?: boolean, degradations?: Array<{ surface: string, reason: string }> }} lintSummary
|
|
315
|
-
* @returns {Array<{ tool: string, gate: string, surface: string, reason: string }>}
|
|
316
|
-
*/
|
|
317
|
-
function buildLintDegradations(lintSummary) {
|
|
318
|
-
if (!lintSummary.executionFailed) return [];
|
|
319
|
-
const rows = Array.isArray(lintSummary.degradations)
|
|
320
|
-
? lintSummary.degradations
|
|
321
|
-
: [];
|
|
322
|
-
const surfaces =
|
|
323
|
-
rows.length > 0
|
|
324
|
-
? rows
|
|
325
|
-
: [{ surface: 'scoped-lint', reason: 'unparseable-output' }];
|
|
326
|
-
return surfaces.map((row) => ({
|
|
327
|
-
tool: 'native-review-lint',
|
|
328
|
-
gate: 'scoped-lint',
|
|
329
|
-
surface: row.surface,
|
|
330
|
-
reason: row.reason,
|
|
331
|
-
}));
|
|
332
|
-
}
|
|
333
|
-
|
|
334
237
|
/**
|
|
335
238
|
* @param {{
|
|
336
239
|
* gitSpawnFn?: typeof gitSpawn,
|
|
337
|
-
* runScopedLintFn?: typeof runScopedLint,
|
|
338
240
|
* analyzeChangedFilesFn?: typeof analyzeChangedFiles,
|
|
339
|
-
* buildLintFindingsFn?: typeof buildLintFindings,
|
|
340
|
-
* emitToolDegradationFn?: typeof emitRuntimeFriction,
|
|
341
241
|
* resolveIgnoreGlobsFn?: typeof resolveMaintainabilityIgnoreGlobs,
|
|
342
242
|
* logger?: { info?: Function, warn?: Function, error?: Function },
|
|
343
|
-
* scopeLint?: 'changed-only'|'off',
|
|
344
243
|
* }} [deps]
|
|
345
244
|
* @returns {ReviewProvider}
|
|
346
245
|
*/
|
|
347
246
|
export function createNativeProvider(deps = {}) {
|
|
348
247
|
const {
|
|
349
248
|
gitSpawnFn = gitSpawn,
|
|
350
|
-
runScopedLintFn = runScopedLint,
|
|
351
249
|
analyzeChangedFilesFn = analyzeChangedFiles,
|
|
352
|
-
buildLintFindingsFn = buildLintFindings,
|
|
353
|
-
emitToolDegradationFn = emitRuntimeFriction,
|
|
354
250
|
resolveIgnoreGlobsFn = resolveMaintainabilityIgnoreGlobs,
|
|
355
251
|
logger,
|
|
356
|
-
scopeLint = 'changed-only',
|
|
357
252
|
} = deps;
|
|
358
253
|
|
|
359
|
-
/**
|
|
360
|
-
* Degradations from the latest `runReview`, travelling beside findings.
|
|
361
|
-
*
|
|
362
|
-
* @type {Array<{ tool: string, gate: string, surface: string, reason: string }>}
|
|
363
|
-
*/
|
|
364
|
-
let recordedDegradations = [];
|
|
365
|
-
|
|
366
254
|
return {
|
|
367
|
-
/**
|
|
368
|
-
* @returns {Array<{ tool: string, gate: string, surface: string, reason: string }>}
|
|
369
|
-
*/
|
|
370
|
-
getDegradations() {
|
|
371
|
-
return recordedDegradations;
|
|
372
|
-
},
|
|
373
255
|
/**
|
|
374
256
|
* @param {ReviewInput} input
|
|
375
257
|
* @returns {Promise<Finding[]>}
|
|
376
258
|
*/
|
|
377
259
|
async runReview(input) {
|
|
378
|
-
recordedDegradations = [];
|
|
379
260
|
const { scope, ticketId, baseRef, headRef } = input ?? {};
|
|
380
261
|
if (!baseRef || !headRef) {
|
|
381
262
|
throw new TypeError(
|
|
@@ -427,49 +308,8 @@ export function createNativeProvider(deps = {}) {
|
|
|
427
308
|
gitSpawnFn,
|
|
428
309
|
});
|
|
429
310
|
|
|
430
|
-
const lintSummary = await runLintPhase({
|
|
431
|
-
scopeLint,
|
|
432
|
-
changedFiles,
|
|
433
|
-
runScopedLintFn,
|
|
434
|
-
logger,
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
if (lintSummary.executionFailed) {
|
|
438
|
-
// A tool that could not execute is a degradation, recorded on the
|
|
439
|
-
// outcome and in friction telemetry — never a finding.
|
|
440
|
-
recordedDegradations = buildLintDegradations(lintSummary);
|
|
441
|
-
logger?.warn?.(
|
|
442
|
-
`[native-review] Lint runner could not execute (${recordedDegradations
|
|
443
|
-
.map((d) => `${d.surface}: ${d.reason}`)
|
|
444
|
-
.join(
|
|
445
|
-
'; ',
|
|
446
|
-
)}) — reported as a degraded gate on the review outcome and recorded as friction telemetry; the degradation itself is never a finding, and any surface that did run still reports its own errors. Verify with the canonical \`npm run lint\` before merging.`,
|
|
447
|
-
);
|
|
448
|
-
try {
|
|
449
|
-
await emitToolDegradationFn({
|
|
450
|
-
storyId: ticketId,
|
|
451
|
-
category: RUNTIME_FRICTION_CATEGORIES.TOOL_DEGRADED,
|
|
452
|
-
tool: 'native-review-lint',
|
|
453
|
-
details: {
|
|
454
|
-
surface: 'scoped-lint',
|
|
455
|
-
reason:
|
|
456
|
-
'lint runner produced no parseable output (binary missing, parse failure, or environment issue)',
|
|
457
|
-
},
|
|
458
|
-
});
|
|
459
|
-
} catch {
|
|
460
|
-
// Observability must never fail the review.
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
const lintFindings = buildLintFindingsFn(lintSummary);
|
|
465
|
-
|
|
466
311
|
// Severity order; only matters for fixture stability.
|
|
467
|
-
return [
|
|
468
|
-
...results.criticalFindings,
|
|
469
|
-
...lintFindings.filter((f) => f.severity === 'high'),
|
|
470
|
-
...results.mediumFindings,
|
|
471
|
-
...lintFindings.filter((f) => f.severity === 'suggestion'),
|
|
472
|
-
];
|
|
312
|
+
return [...results.criticalFindings, ...results.mediumFindings];
|
|
473
313
|
},
|
|
474
314
|
};
|
|
475
315
|
}
|
|
@@ -82,10 +82,22 @@ export function gatesForFailedPhase(phase, args = {}) {
|
|
|
82
82
|
return { ...gates, ...baselinesGatesObserved(args.observedGates) };
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @param {unknown} err
|
|
87
|
+
* @param {number} storyId
|
|
88
|
+
* @returns {string}
|
|
89
|
+
*/
|
|
90
|
+
function nextCommandFor(err, storyId) {
|
|
91
|
+
const tagged = err?.closeNextCommand;
|
|
92
|
+
return typeof tagged === 'string' ? tagged : NEXT_COMMANDS.recover(storyId);
|
|
93
|
+
}
|
|
94
|
+
|
|
85
95
|
/**
|
|
86
96
|
* Never throws: a build failure here must not replace the original error as
|
|
87
97
|
* the run's reported cause, so it returns null and the caller rethrows.
|
|
88
|
-
* `err.closePhase` and `err.closeGates` are tagged by the runner
|
|
98
|
+
* `err.closePhase` and `err.closeGates` are tagged by the runner; a phase
|
|
99
|
+
* that knows its own resume (a handed-back base-sync conflict re-runs close)
|
|
100
|
+
* tags `err.closeNextCommand`.
|
|
89
101
|
*
|
|
90
102
|
* @param {unknown} err
|
|
91
103
|
* @param {{ storyId?: string|number, skipValidation?: boolean, skipSync?: boolean }} args
|
|
@@ -105,7 +117,7 @@ export function failedTerminalFor(err, args = {}) {
|
|
|
105
117
|
observedGates: err?.closeGates ?? null,
|
|
106
118
|
}),
|
|
107
119
|
failure: { reason: String(err?.message ?? err) },
|
|
108
|
-
nextCommand:
|
|
120
|
+
nextCommand: nextCommandFor(err, storyId),
|
|
109
121
|
elapsedSeconds: 0,
|
|
110
122
|
phaseDurations: err?.closePhaseDurations ?? undefined,
|
|
111
123
|
});
|
|
@@ -39,6 +39,19 @@ export function isOperatorMergeReason(reason) {
|
|
|
39
39
|
return OPERATOR_MERGE_ARM_REASONS.includes(reason);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Positive evidence that close itself armed this PR — never an operator-owned
|
|
44
|
+
* merge (`--no-auto-merge`, `strict`), and never an envelope that says nothing.
|
|
45
|
+
*
|
|
46
|
+
* @param {{ autoMergeEnabled?: boolean|null, autoMergeReason?: string|null }|null|undefined} pr
|
|
47
|
+
* @returns {boolean}
|
|
48
|
+
*/
|
|
49
|
+
export function closeArmedPr(pr) {
|
|
50
|
+
return (
|
|
51
|
+
pr?.autoMergeEnabled === true && !isOperatorMergeReason(pr?.autoMergeReason)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
42
55
|
/**
|
|
43
56
|
* A `gh pr merge --delete-branch` failure whose only casualty is the LOCAL
|
|
44
57
|
* head-branch delete after the remote merge/arm already happened. Deliberately
|
|
@@ -132,6 +145,38 @@ export async function enableAutoMergeWith({
|
|
|
132
145
|
return arm({ exec, prNumber, armCwd });
|
|
133
146
|
}
|
|
134
147
|
|
|
148
|
+
/** The hand-run equivalent of the arm, for an operator-facing remedy. */
|
|
149
|
+
export function manualArmCommand({ prNumber, queueRequired = false }) {
|
|
150
|
+
return queueRequired
|
|
151
|
+
? `gh pr merge ${prNumber} --auto`
|
|
152
|
+
: `gh pr merge ${prNumber} --auto --squash --delete-branch`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Re-arm a PR a new head disarmed, from the merge wait. Same merge-queue
|
|
157
|
+
* detection as the arm phase, so a queue base gets the bare `--auto`. Lives
|
|
158
|
+
* here because `lifecycle-lint` confines `gh pr merge` to this module.
|
|
159
|
+
* Non-fatal, like the arm.
|
|
160
|
+
*
|
|
161
|
+
* @param {{ cwd: string, prNumber: number, gh?: object,
|
|
162
|
+
* readMergeQueueStateFn?: typeof readMergeQueueState }} args
|
|
163
|
+
* @returns {Promise<{ enabled: boolean, reason?: string }>}
|
|
164
|
+
*/
|
|
165
|
+
export async function rearmAutoMerge({
|
|
166
|
+
cwd,
|
|
167
|
+
prNumber,
|
|
168
|
+
gh,
|
|
169
|
+
readMergeQueueStateFn = readMergeQueueState,
|
|
170
|
+
}) {
|
|
171
|
+
const queue = await readMergeQueueStateFn({ prNumber, gh });
|
|
172
|
+
return enableAutoMergeWith({
|
|
173
|
+
cwd,
|
|
174
|
+
prNumber,
|
|
175
|
+
gh,
|
|
176
|
+
queueRequired: queue?.queueRequired === true,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
135
180
|
/**
|
|
136
181
|
* `--auto --squash --delete-branch`, falling back to a direct squash-merge
|
|
137
182
|
* only when native auto-merge is unavailable.
|