mandrel 2.80.0 → 2.82.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/audit-checklists/security.md +15 -1
- package/.agents/docs/agentrc-reference.json +1 -0
- package/.agents/docs/configuration.md +3 -2
- package/.agents/docs/execution-reference.md +25 -5
- package/.agents/docs/workflows.md +1 -1
- package/.agents/schemas/agentrc.schema.json +12 -2
- package/.agents/schemas/audit-rules.json +10 -1
- package/.agents/scripts/deliver-run.js +43 -8
- package/.agents/scripts/lib/audit-to-stories/parse-audit-md.js +49 -24
- package/.agents/scripts/lib/baselines/duplication-scanner.js +16 -6
- package/.agents/scripts/lib/baselines/refresh-service.js +6 -0
- package/.agents/scripts/lib/bootstrap/manifest.js +128 -159
- package/.agents/scripts/lib/cli-args.js +16 -2
- package/.agents/scripts/lib/config/gates/duplication.schema.js +10 -2
- package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
- package/.agents/scripts/lib/observability/close-telemetry.js +17 -2
- package/.agents/scripts/lib/orchestration/complexity-gate.js +58 -11
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/cli.js +31 -27
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/render.js +25 -21
- package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +51 -6
- package/.agents/scripts/lib/orchestration/plan-persist/source-rewrite.js +177 -0
- package/.agents/scripts/lib/orchestration/plan-persist/story-ops.js +174 -43
- package/.agents/scripts/lib/orchestration/plan-persist/supersede-ops.js +57 -15
- package/.agents/scripts/lib/orchestration/pr-watch-poll.js +107 -0
- package/.agents/scripts/lib/orchestration/pr-watch.js +168 -235
- package/.agents/scripts/lib/orchestration/reassert-status-column.js +102 -72
- package/.agents/scripts/lib/orchestration/resolve-stories.js +12 -3
- package/.agents/scripts/lib/orchestration/resume-effort.js +121 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/options.js +13 -2
- package/.agents/scripts/lib/orchestration/single-story-close/phases/post-land.js +21 -3
- package/.agents/scripts/lib/orchestration/single-story-close/phases/pre-gate-steps.js +44 -2
- package/.agents/scripts/lib/orchestration/single-story-close/runner.js +10 -2
- package/.agents/scripts/lib/orchestration/story-close/duplication-close-rescore.js +257 -0
- package/.agents/scripts/lib/orchestration/story-close/ratchet-shrink-writeback.js +341 -0
- package/.agents/scripts/lib/orchestration/ticketing/reads.js +3 -0
- package/.agents/scripts/lib/orchestration/ticketing.js +0 -9
- package/.agents/scripts/plan-persist.js +20 -6
- package/.agents/scripts/providers/github/tickets.js +2 -1
- package/.agents/scripts/resolve-stories.js +8 -2
- package/.agents/scripts/single-story-close.js +11 -3
- package/.agents/workflows/audit-security.md +136 -49
- package/.agents/workflows/helpers/deliver-reference.md +7 -2
- package/.agents/workflows/helpers/deliver-story.md +5 -3
- package/.agents/workflows/helpers/plan-reference.md +42 -2
- package/.agents/workflows/mandrel-deliver.md +9 -4
- package/.agents/workflows/mandrel-plan.md +7 -1
- package/docs/CHANGELOG.md +35 -0
- package/package.json +2 -1
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ratchet-shrink-writeback.js — at close, bank the burn-down of the dead-export
|
|
3
|
+
* (default and `--production`) and cyclomatic ratchets, whose checks exit 0 on
|
|
4
|
+
* removals so a burnt-down row would otherwise linger as slack.
|
|
5
|
+
*
|
|
6
|
+
* Shrink only: a baseline is rewritten only when its recomputed rows are a
|
|
7
|
+
* strict subset of (cyclomatic: no worse than) the committed rows, so a write
|
|
8
|
+
* never adds a row or raises a value. Rows come from each check's own
|
|
9
|
+
* machinery. One `baseline-refresh:` commit; every failure is a named skip.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import fs from 'node:fs';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
diffRows as defaultDiffDeadExportRows,
|
|
17
|
+
loadBaseline as loadJsonBaseline,
|
|
18
|
+
} from '../../../check-dead-exports.js';
|
|
19
|
+
import { getQuality } from '../../config-resolver.js';
|
|
20
|
+
import {
|
|
21
|
+
DEFAULT_CYCLOMATIC_BASELINE,
|
|
22
|
+
scanCyclomatic as defaultScanCyclomatic,
|
|
23
|
+
diffCyclomaticRows,
|
|
24
|
+
resolveCyclomaticPolicy,
|
|
25
|
+
} from '../../cyclomatic-ceiling.js';
|
|
26
|
+
import { resolveScanScope as defaultResolveScanScope } from '../../cyclomatic-scope.js';
|
|
27
|
+
import {
|
|
28
|
+
runKnip as defaultRunKnip,
|
|
29
|
+
extractRowsFromKnip,
|
|
30
|
+
} from '../../dead-exports-knip.js';
|
|
31
|
+
import { resolveDeadExportsMode } from '../../dead-exports-mode.js';
|
|
32
|
+
import { gitSync as defaultGitSync } from '../../git-utils.js';
|
|
33
|
+
import { Logger as DefaultLogger } from '../../Logger.js';
|
|
34
|
+
import { currentBranch, listDirtyPaths } from './format-autofix.js';
|
|
35
|
+
|
|
36
|
+
const TAG = '[ratchet-shrink]';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Carries the `baseline-refresh:` marker `refresh-ack.js` recognises.
|
|
40
|
+
*
|
|
41
|
+
* @param {number|string} storyId
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
function buildCommitSubject(storyId) {
|
|
45
|
+
return `chore(baselines): baseline-refresh: drop burnt-down ratchet rows (story #${storyId})`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {Array<{ relPath: string, lines: string[] }>} shrinks
|
|
50
|
+
* @returns {string}
|
|
51
|
+
*/
|
|
52
|
+
function buildCommitBody(shrinks) {
|
|
53
|
+
const out = [
|
|
54
|
+
'Dead-export and cyclomatic rows this branch burnt down, banked so the',
|
|
55
|
+
'ratchet stops holding slack the tree no longer spends. Additions and',
|
|
56
|
+
'rises are never written here.',
|
|
57
|
+
];
|
|
58
|
+
for (const s of shrinks) out.push('', `${s.relPath}:`, ...s.lines);
|
|
59
|
+
return out.join('\n');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @param {object} logger
|
|
64
|
+
* @param {string} reason
|
|
65
|
+
*/
|
|
66
|
+
function skip(logger, reason) {
|
|
67
|
+
logger.info?.(`${TAG} no write-back (${reason}).`);
|
|
68
|
+
return { ran: false, committed: false, reason };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* One dead-export mode: the shrunk envelope, or a skip reason.
|
|
73
|
+
*
|
|
74
|
+
* @param {{ workTree: string, production: boolean, runKnip: Function, diffRows: Function }} ctx
|
|
75
|
+
* @returns {{ relPath: string, envelope?: object, lines?: string[], reason?: string }}
|
|
76
|
+
*/
|
|
77
|
+
function planDeadExportShrink({
|
|
78
|
+
workTree,
|
|
79
|
+
production,
|
|
80
|
+
runKnip = defaultRunKnip,
|
|
81
|
+
diffRows = defaultDiffDeadExportRows,
|
|
82
|
+
}) {
|
|
83
|
+
const { baseline } = resolveDeadExportsMode(production);
|
|
84
|
+
const relPath = baseline.split(path.sep).join('/');
|
|
85
|
+
const committed = loadJsonBaseline(path.join(workTree, baseline));
|
|
86
|
+
if (!Array.isArray(committed?.rows))
|
|
87
|
+
return { relPath, reason: 'no-baseline' };
|
|
88
|
+
const report = runKnip({ cwd: workTree, production });
|
|
89
|
+
// A failed or unrecognised report reads as "every row removed" — never shrink on it.
|
|
90
|
+
if (!report?.ok) return { relPath, reason: 'knip-failed' };
|
|
91
|
+
if (!Array.isArray(report.envelope?.issues)) {
|
|
92
|
+
return { relPath, reason: 'knip-report-unusable' };
|
|
93
|
+
}
|
|
94
|
+
const diff = diffRows(committed.rows, extractRowsFromKnip(report.envelope));
|
|
95
|
+
if (diff.added.length > 0) return { relPath, reason: 'not-a-shrink' };
|
|
96
|
+
if (diff.removed.length === 0) return { relPath, reason: 'no-shrink' };
|
|
97
|
+
const gone = new Set(diff.removed.map((r) => `${r.file}\0${r.symbol}`));
|
|
98
|
+
return {
|
|
99
|
+
relPath,
|
|
100
|
+
envelope: {
|
|
101
|
+
...committed,
|
|
102
|
+
rows: committed.rows.filter((r) => !gone.has(`${r.file}\0${r.symbol}`)),
|
|
103
|
+
},
|
|
104
|
+
lines: diff.removed.map((r) => `- ${r.file}: ${r.symbol}`),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Lower each improved row to the measured values; never above the prior.
|
|
110
|
+
*
|
|
111
|
+
* @param {Array<object>} rows committed rows
|
|
112
|
+
* @param {{ removed: Array<object>, improved: Array<object> }} diff
|
|
113
|
+
* @returns {Array<object>}
|
|
114
|
+
*/
|
|
115
|
+
function shrinkCyclomaticRows(rows, diff) {
|
|
116
|
+
const gone = new Set(diff.removed.map((r) => r.file));
|
|
117
|
+
const lowered = new Map(diff.improved.map((r) => [r.file, r]));
|
|
118
|
+
const out = [];
|
|
119
|
+
for (const row of rows) {
|
|
120
|
+
if (gone.has(row.file)) continue;
|
|
121
|
+
const cur = lowered.get(row.file);
|
|
122
|
+
out.push(
|
|
123
|
+
cur
|
|
124
|
+
? {
|
|
125
|
+
...row,
|
|
126
|
+
methodsAboveCeiling: Math.min(
|
|
127
|
+
row.methodsAboveCeiling,
|
|
128
|
+
cur.methodsAboveCeiling,
|
|
129
|
+
),
|
|
130
|
+
maxCyclomatic: Math.min(row.maxCyclomatic, cur.maxCyclomatic),
|
|
131
|
+
}
|
|
132
|
+
: row,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The cyclomatic shrink: the lowered envelope, or a skip reason.
|
|
140
|
+
*
|
|
141
|
+
* @param {{ workTree: string, config: object, scanCyclomatic: Function, resolveScanScope: Function }} ctx
|
|
142
|
+
* @returns {{ relPath: string, envelope?: object, lines?: string[], reason?: string }}
|
|
143
|
+
*/
|
|
144
|
+
function planCyclomaticShrink({
|
|
145
|
+
workTree,
|
|
146
|
+
config,
|
|
147
|
+
scanCyclomatic = defaultScanCyclomatic,
|
|
148
|
+
resolveScanScope = defaultResolveScanScope,
|
|
149
|
+
}) {
|
|
150
|
+
const relPath = DEFAULT_CYCLOMATIC_BASELINE;
|
|
151
|
+
const committed = loadJsonBaseline(path.join(workTree, relPath));
|
|
152
|
+
if (!Array.isArray(committed?.rows))
|
|
153
|
+
return { relPath, reason: 'no-baseline' };
|
|
154
|
+
const policy = resolveCyclomaticPolicy(getQuality(config));
|
|
155
|
+
if (committed.ceiling !== policy.mustFix) {
|
|
156
|
+
return { relPath, reason: 'ceiling-mismatch' };
|
|
157
|
+
}
|
|
158
|
+
const scan = scanCyclomatic({
|
|
159
|
+
targetDirs: policy.targetDirs,
|
|
160
|
+
ignoreGlobs: policy.ignoreGlobs,
|
|
161
|
+
ceiling: policy.mustFix,
|
|
162
|
+
cwd: workTree,
|
|
163
|
+
scopeFiles: resolveScanScope({
|
|
164
|
+
cwd: workTree,
|
|
165
|
+
config,
|
|
166
|
+
baselineRows: committed.rows,
|
|
167
|
+
}),
|
|
168
|
+
});
|
|
169
|
+
// An unparseable file yields no row, which would read as a burnt-down one.
|
|
170
|
+
if (scan.parseErrors > 0) return { relPath, reason: 'parse-errors' };
|
|
171
|
+
const diff = diffCyclomaticRows(committed.rows, scan.rows);
|
|
172
|
+
if (diff.added.length + diff.worsened.length > 0) {
|
|
173
|
+
return { relPath, reason: 'not-a-shrink' };
|
|
174
|
+
}
|
|
175
|
+
if (diff.removed.length + diff.improved.length === 0) {
|
|
176
|
+
return { relPath, reason: 'no-shrink' };
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
relPath,
|
|
180
|
+
envelope: {
|
|
181
|
+
...committed,
|
|
182
|
+
rows: shrinkCyclomaticRows(committed.rows, diff),
|
|
183
|
+
},
|
|
184
|
+
lines: [
|
|
185
|
+
...diff.removed.map((r) => `- ${r.file}: removed`),
|
|
186
|
+
...diff.improved.map(
|
|
187
|
+
(r) =>
|
|
188
|
+
`- ${r.file}: ${r.baselineCount}/${r.baselineMax} -> ${r.methodsAboveCeiling}/${r.maxCyclomatic}`,
|
|
189
|
+
),
|
|
190
|
+
],
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Run a planner; a throw becomes a named skip for that baseline only.
|
|
196
|
+
*
|
|
197
|
+
* @param {string} relPath
|
|
198
|
+
* @param {() => object} plan
|
|
199
|
+
* @returns {object}
|
|
200
|
+
*/
|
|
201
|
+
function safePlan(relPath, plan) {
|
|
202
|
+
try {
|
|
203
|
+
return plan();
|
|
204
|
+
} catch (err) {
|
|
205
|
+
return { relPath, reason: `failed: ${err?.message ?? err}` };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Write every shrunk envelope and fold them into one commit. On a rejected
|
|
211
|
+
* commit the files are restored so the gates score the tree the close found.
|
|
212
|
+
*
|
|
213
|
+
* @param {{ workTree: string, git: Function, shrinks: object[], storyId: number|string }} args
|
|
214
|
+
* @returns {string} the short sha
|
|
215
|
+
*/
|
|
216
|
+
function commitShrinks({ workTree, git, shrinks, storyId }) {
|
|
217
|
+
const paths = shrinks.map((s) => s.relPath);
|
|
218
|
+
for (const s of shrinks) {
|
|
219
|
+
fs.writeFileSync(
|
|
220
|
+
path.join(workTree, s.relPath),
|
|
221
|
+
`${JSON.stringify(s.envelope, null, 2)}\n`,
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
git(['add', '--', ...paths], { cwd: workTree });
|
|
225
|
+
try {
|
|
226
|
+
git(
|
|
227
|
+
[
|
|
228
|
+
'commit',
|
|
229
|
+
'-m',
|
|
230
|
+
buildCommitSubject(storyId),
|
|
231
|
+
'-m',
|
|
232
|
+
buildCommitBody(shrinks),
|
|
233
|
+
],
|
|
234
|
+
{ cwd: workTree },
|
|
235
|
+
);
|
|
236
|
+
} catch (err) {
|
|
237
|
+
git(['restore', '--staged', '--worktree', '--', ...paths], {
|
|
238
|
+
cwd: workTree,
|
|
239
|
+
});
|
|
240
|
+
throw err;
|
|
241
|
+
}
|
|
242
|
+
return String(
|
|
243
|
+
git(['rev-parse', '--short', 'HEAD'], { cwd: workTree }) ?? '',
|
|
244
|
+
).trim();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Adapt `gitSync(cwd, ...args)` to the `(args, opts)` shape format-autofix uses.
|
|
249
|
+
*
|
|
250
|
+
* @param {(cwd: string, ...args: string[]) => string} gitSync
|
|
251
|
+
* @param {string} workTree
|
|
252
|
+
* @returns {(args: string[], opts?: { cwd?: string }) => string}
|
|
253
|
+
*/
|
|
254
|
+
function bindGit(gitSync, workTree) {
|
|
255
|
+
return (args, opts = {}) => gitSync(opts.cwd ?? workTree, ...args);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* @param {{
|
|
260
|
+
* cwd: string,
|
|
261
|
+
* worktreePath?: string|null,
|
|
262
|
+
* storyId: number|string,
|
|
263
|
+
* storyBranch?: string,
|
|
264
|
+
* config?: object,
|
|
265
|
+
* logger?: object,
|
|
266
|
+
* gitSync?: (cwd: string, ...args: string[]) => string,
|
|
267
|
+
* runKnip?: typeof defaultRunKnip,
|
|
268
|
+
* scanCyclomatic?: typeof defaultScanCyclomatic,
|
|
269
|
+
* resolveScanScope?: typeof defaultResolveScanScope,
|
|
270
|
+
* }} opts
|
|
271
|
+
* @returns {{ ran: boolean, committed: boolean, sha?: string, baselines?: string[], skipped?: Record<string, string>, reason?: string }}
|
|
272
|
+
*/
|
|
273
|
+
export function runRatchetShrinkWriteback({
|
|
274
|
+
cwd,
|
|
275
|
+
worktreePath,
|
|
276
|
+
storyId,
|
|
277
|
+
storyBranch,
|
|
278
|
+
config,
|
|
279
|
+
logger = DefaultLogger,
|
|
280
|
+
gitSync = defaultGitSync,
|
|
281
|
+
runKnip = defaultRunKnip,
|
|
282
|
+
scanCyclomatic = defaultScanCyclomatic,
|
|
283
|
+
resolveScanScope = defaultResolveScanScope,
|
|
284
|
+
} = {}) {
|
|
285
|
+
if (!cwd || !storyBranch) return skip(logger, 'missing-context');
|
|
286
|
+
const workTree = worktreePath || cwd;
|
|
287
|
+
const git = bindGit(gitSync, workTree);
|
|
288
|
+
const relPaths = [
|
|
289
|
+
resolveDeadExportsMode(false).baseline,
|
|
290
|
+
resolveDeadExportsMode(true).baseline,
|
|
291
|
+
DEFAULT_CYCLOMATIC_BASELINE,
|
|
292
|
+
].map((p) => p.split(path.sep).join('/'));
|
|
293
|
+
try {
|
|
294
|
+
if (currentBranch(workTree, git) !== storyBranch) {
|
|
295
|
+
return skip(logger, 'wrong-branch');
|
|
296
|
+
}
|
|
297
|
+
const dirty = listDirtyPaths(workTree, git);
|
|
298
|
+
if (relPaths.some((p) => dirty.includes(p))) {
|
|
299
|
+
return skip(logger, 'dirty-tree');
|
|
300
|
+
}
|
|
301
|
+
} catch (err) {
|
|
302
|
+
return skip(logger, `git-failed: ${err?.message ?? err}`);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const plans = [
|
|
306
|
+
safePlan(relPaths[0], () =>
|
|
307
|
+
planDeadExportShrink({ workTree, production: false, runKnip }),
|
|
308
|
+
),
|
|
309
|
+
safePlan(relPaths[1], () =>
|
|
310
|
+
planDeadExportShrink({ workTree, production: true, runKnip }),
|
|
311
|
+
),
|
|
312
|
+
safePlan(relPaths[2], () =>
|
|
313
|
+
planCyclomaticShrink({
|
|
314
|
+
workTree,
|
|
315
|
+
config,
|
|
316
|
+
scanCyclomatic,
|
|
317
|
+
resolveScanScope,
|
|
318
|
+
}),
|
|
319
|
+
),
|
|
320
|
+
];
|
|
321
|
+
const shrinks = plans.filter((p) => p.envelope);
|
|
322
|
+
const skipped = Object.fromEntries(
|
|
323
|
+
plans.filter((p) => p.reason).map((p) => [p.relPath, p.reason]),
|
|
324
|
+
);
|
|
325
|
+
if (shrinks.length === 0) {
|
|
326
|
+
const detail = Object.entries(skipped)
|
|
327
|
+
.map(([p, r]) => `${path.basename(p)}=${r}`)
|
|
328
|
+
.join(', ');
|
|
329
|
+
return { ...skip(logger, `no-shrink: ${detail}`), skipped };
|
|
330
|
+
}
|
|
331
|
+
try {
|
|
332
|
+
const sha = commitShrinks({ workTree, git, shrinks, storyId });
|
|
333
|
+
const baselines = shrinks.map((s) => s.relPath);
|
|
334
|
+
logger.warn?.(
|
|
335
|
+
`${TAG} dropped burnt-down rows from ${baselines.join(', ')} on story #${storyId}; committed as ${sha}.`,
|
|
336
|
+
);
|
|
337
|
+
return { ran: true, committed: true, sha, baselines, skipped };
|
|
338
|
+
} catch (err) {
|
|
339
|
+
return { ...skip(logger, `git-failed: ${err?.message ?? err}`), skipped };
|
|
340
|
+
}
|
|
341
|
+
}
|
|
@@ -60,6 +60,9 @@ export const STRUCTURED_COMMENT_TYPES = Object.freeze([
|
|
|
60
60
|
// Posted before closing a superseded source issue; the marker keeps
|
|
61
61
|
// re-runs from double-commenting.
|
|
62
62
|
'superseded-by',
|
|
63
|
+
// The source ticket's pre-plan title and body, posted once before a
|
|
64
|
+
// one-for-one rewrite; first write wins, so re-plans keep the original.
|
|
65
|
+
'plan-rewrite',
|
|
63
66
|
]);
|
|
64
67
|
|
|
65
68
|
export const WAVE_TYPE_PATTERN = WAVE_MARKER_RE;
|
|
@@ -6,24 +6,15 @@
|
|
|
6
6
|
export {
|
|
7
7
|
__resetParentCascadeLocks,
|
|
8
8
|
__setCascadeRetryDelays,
|
|
9
|
-
logCascadePartialFailures,
|
|
10
9
|
} from './ticketing/bulk.js';
|
|
11
10
|
export {
|
|
12
|
-
_peekStructuredCommentCache,
|
|
13
11
|
_resetStructuredCommentCache,
|
|
14
12
|
assertValidStructuredCommentType,
|
|
15
|
-
buildStorylessTicketSnapshot,
|
|
16
13
|
findStructuredComment,
|
|
17
|
-
isValidStructuredCommentType,
|
|
18
14
|
STATE_LABELS,
|
|
19
|
-
STRUCTURED_COMMENT_TYPES,
|
|
20
|
-
structuredCommentMarker,
|
|
21
|
-
WAVE_TYPE_PATTERN,
|
|
22
15
|
} from './ticketing/reads.js';
|
|
23
16
|
export {
|
|
24
17
|
postStructuredComment,
|
|
25
|
-
toggleTasklistCheckbox,
|
|
26
|
-
transitionStoryDirect,
|
|
27
18
|
transitionTicketState,
|
|
28
19
|
upsertStructuredComment,
|
|
29
20
|
} from './ticketing/state.js';
|
|
@@ -56,6 +56,8 @@ const CLI_OPTIONS = {
|
|
|
56
56
|
'source-tickets': { type: 'string' },
|
|
57
57
|
'close-superseded': { type: 'boolean', default: true },
|
|
58
58
|
'no-close-superseded': { type: 'boolean', default: false },
|
|
59
|
+
'rewrite-source': { type: 'boolean', default: true },
|
|
60
|
+
'no-rewrite-source': { type: 'boolean', default: false },
|
|
59
61
|
'dry-run': { type: 'boolean', default: false },
|
|
60
62
|
'force-review': { type: 'boolean', default: false },
|
|
61
63
|
'epic-title': { type: 'string' },
|
|
@@ -66,7 +68,7 @@ const CLI_OPTIONS = {
|
|
|
66
68
|
const USAGE =
|
|
67
69
|
'Usage: plan-persist.js --stories <file> ' +
|
|
68
70
|
'[--tech-spec <file>] [--plan-dir <dir>] [--plan-context <file>] ' +
|
|
69
|
-
'[--source-tickets <ids>] [--no-close-superseded] ' +
|
|
71
|
+
'[--source-tickets <ids>] [--no-close-superseded] [--no-rewrite-source] ' +
|
|
70
72
|
'[--dry-run] [--force-review] ' +
|
|
71
73
|
'[--epic-title <text> --epic-goal <text> | --epic <id>]';
|
|
72
74
|
|
|
@@ -182,6 +184,17 @@ export function resolveEpicAdoptionId(values) {
|
|
|
182
184
|
return id;
|
|
183
185
|
}
|
|
184
186
|
|
|
187
|
+
/**
|
|
188
|
+
* A `--x` / `--no-x` pair: the negation always wins.
|
|
189
|
+
*
|
|
190
|
+
* @param {object} values
|
|
191
|
+
* @param {string} name
|
|
192
|
+
* @returns {boolean}
|
|
193
|
+
*/
|
|
194
|
+
function negatableFlag(values, name) {
|
|
195
|
+
return values[`no-${name}`] !== true && values[name] !== false;
|
|
196
|
+
}
|
|
197
|
+
|
|
185
198
|
/**
|
|
186
199
|
* Where envelope-derived source ids meet the engine; a break here silently
|
|
187
200
|
* un-wires `--tickets` superseding.
|
|
@@ -206,11 +219,8 @@ export function buildPersistOptions(values, paths, planContextEnvelope) {
|
|
|
206
219
|
sourceTicketOrigin: source.origin,
|
|
207
220
|
epic: resolveEpicRequest(values),
|
|
208
221
|
adoptEpicId: resolveEpicAdoptionId(values),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
values['no-close-superseded'] === true
|
|
212
|
-
? false
|
|
213
|
-
: values['close-superseded'] !== false,
|
|
222
|
+
closeSuperseded: negatableFlag(values, 'close-superseded'),
|
|
223
|
+
rewriteSource: negatableFlag(values, 'rewrite-source'),
|
|
214
224
|
};
|
|
215
225
|
}
|
|
216
226
|
|
|
@@ -429,6 +439,10 @@ runAsCli(import.meta.url, main, {
|
|
|
429
439
|
['--source-tickets <ids>', 'Ticket ids this plan supersedes.'],
|
|
430
440
|
['--dry-run', 'Validate and report; create nothing.'],
|
|
431
441
|
['--no-close-superseded', 'Leave superseded source tickets open.'],
|
|
442
|
+
[
|
|
443
|
+
'--no-rewrite-source',
|
|
444
|
+
'File a new Story for a one-for-one plan instead of rewriting its source ticket in place.',
|
|
445
|
+
],
|
|
432
446
|
[
|
|
433
447
|
'--force-review',
|
|
434
448
|
'Require the review gate even when it would be skipped.',
|
|
@@ -361,12 +361,13 @@ export class TicketGateway {
|
|
|
361
361
|
*
|
|
362
362
|
* @field-manifest POST /repos/{owner}/{repo}/issues/{n}/assignees: assignees
|
|
363
363
|
* @field-manifest PATCH /repos/{owner}/{repo}/issues/{n}:
|
|
364
|
-
* body, assignees, state, state_reason, labels
|
|
364
|
+
* title, body, assignees, state, state_reason, labels
|
|
365
365
|
*/
|
|
366
366
|
/* node:coverage ignore next */
|
|
367
367
|
async updateTicket(ticketId, mutations) {
|
|
368
368
|
await this._addAssignees(ticketId, mutations.addAssignees);
|
|
369
369
|
const patch = {};
|
|
370
|
+
if (mutations.title !== undefined) patch.title = mutations.title;
|
|
370
371
|
if (mutations.body !== undefined) patch.body = mutations.body;
|
|
371
372
|
if (mutations.assignees) patch.assignees = mutations.assignees;
|
|
372
373
|
if (mutations.state !== undefined) patch.state = mutations.state;
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
readNativeBlockedBy,
|
|
33
33
|
toStoryRecord,
|
|
34
34
|
} from './lib/orchestration/resolve-stories.js';
|
|
35
|
+
import { resolveRunDispatchInputs } from './lib/orchestration/resume-effort.js';
|
|
35
36
|
import { createProvider } from './lib/provider-factory.js';
|
|
36
37
|
import { concurrentMap } from './lib/util/concurrent-map.js';
|
|
37
38
|
import { paginateRest } from './providers/github/request-helpers.js';
|
|
@@ -189,12 +190,13 @@ export async function resolveForeignDone({ provider, dag, inSetIds }) {
|
|
|
189
190
|
/**
|
|
190
191
|
* @param {{ ids: string, native?: boolean, pretty?: boolean,
|
|
191
192
|
* allowUnlabelled?: boolean }} args
|
|
192
|
-
* @param {{ provider: object, config: object, stdout?: { write(s: string): void }
|
|
193
|
+
* @param {{ provider: object, config: object, stdout?: { write(s: string): void },
|
|
194
|
+
* countPriorBlocksFn?: Function }} deps
|
|
193
195
|
* @returns {Promise<number>}
|
|
194
196
|
*/
|
|
195
197
|
export async function runResolveStories(
|
|
196
198
|
{ ids: rawIds, native = true, pretty = false, allowUnlabelled = false },
|
|
197
|
-
{ provider, config, stdout = process.stdout },
|
|
199
|
+
{ provider, config, stdout = process.stdout, countPriorBlocksFn },
|
|
198
200
|
) {
|
|
199
201
|
const ids = parseIds(rawIds);
|
|
200
202
|
const owner = config.github?.owner;
|
|
@@ -221,6 +223,10 @@ export async function runResolveStories(
|
|
|
221
223
|
nativeEdges,
|
|
222
224
|
foreignDone,
|
|
223
225
|
warn: () => {},
|
|
226
|
+
...(await resolveRunDispatchInputs(stories, {
|
|
227
|
+
config,
|
|
228
|
+
countFn: countPriorBlocksFn,
|
|
229
|
+
})),
|
|
224
230
|
});
|
|
225
231
|
|
|
226
232
|
stdout.write(
|
|
@@ -18,13 +18,17 @@
|
|
|
18
18
|
* [--override-review-block <reason>]
|
|
19
19
|
* [--worker-tokens <n>]
|
|
20
20
|
* [--worker-model <model>]
|
|
21
|
+
* [--worker-effort <level>]
|
|
21
22
|
*
|
|
22
23
|
* `--worker-tokens <n>` is the story-worker's host-reported token total,
|
|
23
24
|
* recorded best-effort in the close result's `telemetry` (absent or invalid →
|
|
24
25
|
* `null` plus a warning; never a change of status or exit code).
|
|
25
26
|
* `--worker-model <model>` is the dispatched story-worker's resolved model,
|
|
26
|
-
* which deliver-run renders on
|
|
27
|
-
* an inline close omits it and records `null`).
|
|
27
|
+
* which deliver-run renders on every worker-dispatched close
|
|
28
|
+
* (`telemetry.workerModel`; an inline close omits it and records `null`).
|
|
29
|
+
* `--worker-effort <level>` is the per-call effort a resumed story-worker ran
|
|
30
|
+
* at (`telemetry.workerEffort`), rendered beside it when the Story resumed
|
|
31
|
+
* after a prior block.
|
|
28
32
|
* `--override-review-block <reason>` is the audited escape past a code-review
|
|
29
33
|
* CRITICAL blocker (instead of a hand-merge with no record).
|
|
30
34
|
* `--merge-watch-mode async` is passed per close by the orchestrator, the only
|
|
@@ -144,7 +148,11 @@ runAsCli(import.meta.url, main, {
|
|
|
144
148
|
],
|
|
145
149
|
[
|
|
146
150
|
'--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
|
|
151
|
+
'The dispatched story-worker’s resolved model, recorded in the close result’s `telemetry.workerModel` beside `workerTokens`. deliver-run renders it on every worker-dispatched close (a multi-Story run, or a one-Story resume); 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.',
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
'--worker-effort <level>',
|
|
155
|
+
'The per-call effort (low|medium|high|xhigh|max) the dispatched story-worker ran at, recorded in the close result’s `telemetry.workerEffort` beside `workerModel`. deliver-run renders it when the Story resumed after a prior block; absent, it records null. Best-effort: an invalid value records null with a warning and never changes the status or exit code.',
|
|
148
156
|
],
|
|
149
157
|
],
|
|
150
158
|
notes: [
|