@feigi/fleet-ctl 3.63.1 → 3.64.1
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/package.json +1 -1
- package/scripts/closeout.mjs +37 -2
- package/scripts/ledger-grammar.mjs +5 -0
- package/scripts/phase0.mjs +4 -5
- package/scripts/pull.mjs +120 -25
- package/skills/run-team/SKILL.md +15 -17
package/package.json
CHANGED
package/scripts/closeout.mjs
CHANGED
|
@@ -45,6 +45,15 @@
|
|
|
45
45
|
// the PR once it exists, are kept in the receipt: a re-run
|
|
46
46
|
// after a failed push or PR resumes on that branch and never
|
|
47
47
|
// opens a second PR.
|
|
48
|
+
// phase0-receipt moves `.fleet/phase0.json` to `.fleet/phase0.previous.json`,
|
|
49
|
+
// the name `phase0.mjs` holds a previous run's receipt under,
|
|
50
|
+
// so a run that ended here leaves no phase-0 receipt for the
|
|
51
|
+
// next run in this session to resume, and that run's rotation
|
|
52
|
+
// files it as `phase0.<UTC stamp>.json` beside the ledger
|
|
53
|
+
// archive. After the tick, which reads the caps from it, and
|
|
54
|
+
// before the stop. No `phase0.json` is nothing to move and is
|
|
55
|
+
// `ok`; a held receipt already there that is not this one is
|
|
56
|
+
// a failed step.
|
|
48
57
|
// heartbeat-stop `fleet-heartbeat.mjs --stop "<reason>"`, last, because
|
|
49
58
|
// every reader takes a recorded stop as the end of the run.
|
|
50
59
|
//
|
|
@@ -70,7 +79,7 @@
|
|
|
70
79
|
// Zero deps: node builtins and sibling scripts only.
|
|
71
80
|
|
|
72
81
|
import { spawnSync } from "node:child_process";
|
|
73
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync } from "node:fs";
|
|
82
|
+
import { existsSync, linkSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
74
83
|
import { homedir } from "node:os";
|
|
75
84
|
import { dirname, join } from "node:path";
|
|
76
85
|
import { fileURLToPath } from "node:url";
|
|
@@ -78,7 +87,7 @@ import { makeDie, defineFlags } from "./arg.mjs";
|
|
|
78
87
|
import { FleetDirUnresolvable, fleetFile } from "./fleet-dir.mjs";
|
|
79
88
|
import { gitEnv } from "./git-env.mjs";
|
|
80
89
|
import { isCLI } from "./is-cli.mjs";
|
|
81
|
-
import { CLOSEOUT_RECEIPT, memberTokens, rowPr } from "./ledger-grammar.mjs";
|
|
90
|
+
import { CLOSEOUT_RECEIPT, RECEIPT, RECEIPT_HELD, memberTokens, rowPr } from "./ledger-grammar.mjs";
|
|
82
91
|
import { encodeProjectDir, isOmpSessionDirName } from "./member-record.mjs";
|
|
83
92
|
import { tickCaps } from "./phase0-receipt.mjs";
|
|
84
93
|
|
|
@@ -334,6 +343,31 @@ function stepCommitAndPR({ reason, branch, receipt, save }) {
|
|
|
334
343
|
return result;
|
|
335
344
|
}
|
|
336
345
|
|
|
346
|
+
// The receipt `phase0.mjs` resumes would otherwise outlive the run it describes.
|
|
347
|
+
// It is set aside under the name `phase0.mjs` holds a previous run's receipt
|
|
348
|
+
// under, which the next run's rotation restores and archives with the ledger.
|
|
349
|
+
// Linked, then unlinked, so a held receipt already there is refused rather than
|
|
350
|
+
// overwritten; one that is this very file, left by a crash between the two, is
|
|
351
|
+
// finished off.
|
|
352
|
+
function stepPhase0Receipt({ fleetDir }) {
|
|
353
|
+
const from = join(fleetDir, RECEIPT);
|
|
354
|
+
if (!existsSync(from)) return ok(`no ${RECEIPT} to move`);
|
|
355
|
+
const to = join(fleetDir, RECEIPT_HELD);
|
|
356
|
+
try {
|
|
357
|
+
linkSync(from, to);
|
|
358
|
+
} catch (e) {
|
|
359
|
+
if (e.code !== "EEXIST") return failed(`cannot move ${from} to ${to}: ${e.message}`);
|
|
360
|
+
const [a, b] = [statSync(from), statSync(to)];
|
|
361
|
+
if (a.dev !== b.dev || a.ino !== b.ino) return failed(`${to} already holds another receipt — move it out of the way, then run finish again`);
|
|
362
|
+
}
|
|
363
|
+
try {
|
|
364
|
+
unlinkSync(from);
|
|
365
|
+
} catch (e) {
|
|
366
|
+
return failed(`moved ${from} to ${to} but could not remove it: ${e.message} — remove it by hand before the next run`);
|
|
367
|
+
}
|
|
368
|
+
return ok(`${from} -> ${to}`);
|
|
369
|
+
}
|
|
370
|
+
|
|
337
371
|
function stepHeartbeatStop({ cwd, reason }) {
|
|
338
372
|
const r = node("fleet-heartbeat.mjs", ["--stop", reason], { cwd });
|
|
339
373
|
return r.status === 0 ? ok(r.stdout) : failed(`fleet-heartbeat.mjs --stop failed: ${detail(r)}`);
|
|
@@ -348,6 +382,7 @@ const FINISH = {
|
|
|
348
382
|
"tier-outcomes": stepTierOutcomes,
|
|
349
383
|
metrics: stepMetrics,
|
|
350
384
|
"commit-and-pr": stepCommitAndPR,
|
|
385
|
+
"phase0-receipt": stepPhase0Receipt,
|
|
351
386
|
"heartbeat-stop": stepHeartbeatStop,
|
|
352
387
|
};
|
|
353
388
|
const STEP_NAMES = [...Object.keys(BEGIN), ...Object.keys(FINISH)];
|
|
@@ -29,6 +29,11 @@ import { createHash } from "node:crypto";
|
|
|
29
29
|
// way, so the format lives here once.
|
|
30
30
|
const RECEIPT_STEM = "phase0";
|
|
31
31
|
export const RECEIPT = `${RECEIPT_STEM}.json`;
|
|
32
|
+
// Where a previous run's receipt waits, beside the ledger, until the next run's
|
|
33
|
+
// rotation files it: `phase0.mjs` holds a receipt there at startup, and
|
|
34
|
+
// `closeout.mjs finish` sets the run's own there, so a run that ended cleanly
|
|
35
|
+
// leaves no receipt for the next run to resume.
|
|
36
|
+
export const RECEIPT_HELD = `${RECEIPT_STEM}.previous.json`;
|
|
32
37
|
export const archiveStamp = () => new Date().toISOString().replace(/\.\d{3}Z$/, "Z").replaceAll(":", "");
|
|
33
38
|
export const receiptArchiveName = (stamp) => `${RECEIPT_STEM}.${stamp}.json`;
|
|
34
39
|
const CLOSEOUT_STEM = "closeout";
|
package/scripts/phase0.mjs
CHANGED
|
@@ -76,7 +76,8 @@
|
|
|
76
76
|
// writes the next, so the previous run's receipt still matches it, and a
|
|
77
77
|
// re-run that trusted `run` alone would skip `rotate`. The session rule closes
|
|
78
78
|
// a new session. A receipt of any other run (a `run` that is set and does not
|
|
79
|
-
// match, or a different session) is held as `phase0.previous.json
|
|
79
|
+
// match, or a different session) is held as `phase0.previous.json`, where
|
|
80
|
+
// `closeout.mjs finish` also leaves a finished run's receipt, and the
|
|
80
81
|
// script starts at `branch`; this run's own receipt is written at
|
|
81
82
|
// `phase0.json` after every step. A receipt whose rotation has not run is
|
|
82
83
|
// simply overwritten: every step before `rotate` is idempotent and is re-run
|
|
@@ -122,7 +123,7 @@ import { FleetDirUnresolvable, fleetFile } from "./fleet-dir.mjs";
|
|
|
122
123
|
import { readState, stateFileIn } from "./fleet-state.mjs";
|
|
123
124
|
import { gitEnv } from "./git-env.mjs";
|
|
124
125
|
import { isCLI } from "./is-cli.mjs";
|
|
125
|
-
import { RECEIPT, archiveStamp, receiptArchiveName, rowNums } from "./ledger-grammar.mjs";
|
|
126
|
+
import { RECEIPT, RECEIPT_HELD, archiveStamp, receiptArchiveName, rowNums } from "./ledger-grammar.mjs";
|
|
126
127
|
|
|
127
128
|
const NAME = "phase0";
|
|
128
129
|
const SCRIPTS = dirname(fileURLToPath(import.meta.url));
|
|
@@ -131,8 +132,6 @@ const NETWORK_TIMEOUT_MS = 120_000;
|
|
|
131
132
|
const PR_LIMIT = 1000;
|
|
132
133
|
// The tail of a child's output is the part that says why it stopped.
|
|
133
134
|
const OUTPUT_MAX = 16_000;
|
|
134
|
-
// The previous run's receipt, set aside at startup until the rotation files it.
|
|
135
|
-
const HELD = "phase0.previous.json";
|
|
136
135
|
const RULESET_SPEC = join(".github", "rulesets", "main.json");
|
|
137
136
|
const RULESET_CHECK = join(".github", "scripts", "apply-ruleset.sh");
|
|
138
137
|
|
|
@@ -479,7 +478,7 @@ function main() {
|
|
|
479
478
|
const scratch = root.stdout;
|
|
480
479
|
|
|
481
480
|
const receiptPath = join(fleetDir, RECEIPT);
|
|
482
|
-
const held = join(fleetDir,
|
|
481
|
+
const held = join(fleetDir, RECEIPT_HELD);
|
|
483
482
|
const state = readState(stateFileIn(fleetDir), NAME);
|
|
484
483
|
if (state.degraded) {
|
|
485
484
|
// The record decides whether a receipt is the previous run's, and a record
|
package/scripts/pull.mjs
CHANGED
|
@@ -53,9 +53,19 @@
|
|
|
53
53
|
// the brief.
|
|
54
54
|
// 4 Q2 decided `decided`, or a cause whose comment is posted and whose
|
|
55
55
|
// label replaces `ready-for-agent`.
|
|
56
|
-
// 5 Q3 collision
|
|
57
|
-
//
|
|
58
|
-
//
|
|
56
|
+
// 5 Q3 collision the scan first: the brief's paths, and every path a
|
|
57
|
+
// `paths <p>…` answer added, against each open PR's `gh pr diff
|
|
58
|
+
// <M> --name-only` and each live worktree branch's `git diff
|
|
59
|
+
// --name-only -z origin/main...<branch>` — `main` excepted, and
|
|
60
|
+
// a branch whose upstream is gone, its PR already merged or
|
|
61
|
+
// closed. A path matches a changed file of that path, one
|
|
62
|
+
// under it as a directory, or, with no `/`, one of that name.
|
|
63
|
+
// One line per PR or branch sharing a path, `no overlap` when
|
|
64
|
+
// none, and `could not look: <which>` for one that could not be
|
|
65
|
+
// read; the `#N` refs of the brief's Out of scope section are
|
|
66
|
+
// printed as the behind-issue candidates. Then `clear`,
|
|
67
|
+
// `behind-pr:#M`, `behind-issue:#M`, or `paths <p>…`, which
|
|
68
|
+
// scans again and asks again. An exclusion is a ledger row.
|
|
59
69
|
// 6 claim `claim-ticket.sh <N> impl-<N> implementer --apply`.
|
|
60
70
|
// 7 route `ticket-router.mjs route …`; a router that refuses releases
|
|
61
71
|
// the claim, and a release that fails is exit 2 with the claim
|
|
@@ -96,7 +106,7 @@ const SCRIPTS = dirname(fileURLToPath(import.meta.url));
|
|
|
96
106
|
const die = makeDie(NAME);
|
|
97
107
|
const MAX_BUFFER = 64 * 1024 * 1024;
|
|
98
108
|
const NETWORK_TIMEOUT_MS = 120_000;
|
|
99
|
-
const PR_LIMIT =
|
|
109
|
+
const PR_LIMIT = 200;
|
|
100
110
|
// A command's stdout and each of its arguments are kept to this many characters
|
|
101
111
|
// in the record, the tail kept: the end of a child's output says why it stopped.
|
|
102
112
|
const RECORD_MAX = 4000;
|
|
@@ -193,6 +203,17 @@ export function outOfScope(text) {
|
|
|
193
203
|
return all.slice(at, end).join("\n").trim();
|
|
194
204
|
}
|
|
195
205
|
|
|
206
|
+
/** The ticket's `Out of scope` section: the brief's, else the body's; null when neither holds one. */
|
|
207
|
+
function scopeOf(issue) {
|
|
208
|
+
return outOfScope(briefText(issue).trim()) ?? outOfScope(String(issue.body ?? ""));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** The `#N` refs in `section`, each once, in the order they first appear; `owner/repo#N` is another repository's and none. */
|
|
212
|
+
export function issueRefs(section) {
|
|
213
|
+
if (section === null) return [];
|
|
214
|
+
return [...new Set([...section.matchAll(/(?<![\w/.-])#(\d+)\b/g)].map((m) => `#${m[1]}`))];
|
|
215
|
+
}
|
|
216
|
+
|
|
196
217
|
// The placeholders the implementer's brief template declares. dispatch-prompt.mjs
|
|
197
218
|
// refuses a value that spells one, and a ticket's text is a value: one that
|
|
198
219
|
// names `<N>` would stop every render, with the claim standing.
|
|
@@ -237,6 +258,20 @@ function spawn(cmd, args, { cwd, env, timeoutMs } = {}) {
|
|
|
237
258
|
|
|
238
259
|
const GH_ENV = { GH_REPO: "" };
|
|
239
260
|
const withText = (head, r) => (r.text ? `${head}\n${r.text}` : head);
|
|
261
|
+
// How a child failed, with the first line of what it said.
|
|
262
|
+
const failure = (r) => `${r.how}${r.stderr === "" ? "" : `: ${r.stderr.split("\n")[0]}`}`;
|
|
263
|
+
|
|
264
|
+
/** The branches `git worktree list --porcelain -z` names; a detached worktree names none. */
|
|
265
|
+
function worktreeBranches(out) {
|
|
266
|
+
const head = "branch refs/heads/";
|
|
267
|
+
return out.split("\0").filter((f) => f.startsWith(head)).map((f) => f.slice(head.length));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** The local branches whose upstream is gone, from `git for-each-ref --format=%(refname:short)%09%(upstream:track)`. */
|
|
271
|
+
function goneBranches(out) {
|
|
272
|
+
const mark = "\t[gone]";
|
|
273
|
+
return new Set(out.split("\n").filter((l) => l.endsWith(mark)).map((l) => l.slice(0, -mark.length)));
|
|
274
|
+
}
|
|
240
275
|
|
|
241
276
|
// ── the state ────────────────────────────────────────────────────────────────
|
|
242
277
|
|
|
@@ -253,7 +288,8 @@ function fresh(ticket, session) {
|
|
|
253
288
|
answers: [],
|
|
254
289
|
staleness: [],
|
|
255
290
|
close: null,
|
|
256
|
-
|
|
291
|
+
addedPaths: [],
|
|
292
|
+
scans: [],
|
|
257
293
|
session,
|
|
258
294
|
commented: null,
|
|
259
295
|
route: null,
|
|
@@ -281,6 +317,14 @@ function readPull(path) {
|
|
|
281
317
|
&& Number.isInteger(s.ticket) && typeof s.stage === "string" && typeof s.status === "string"
|
|
282
318
|
&& Array.isArray(s.commands) && Array.isArray(s.questions) && Array.isArray(s.answers);
|
|
283
319
|
if (!ok) throw new Refusal(`${path} is not a Pull record — move it aside and run again`);
|
|
320
|
+
// A record written before the collision scan holds neither field.
|
|
321
|
+
s.scans ??= [];
|
|
322
|
+
s.addedPaths ??= [];
|
|
323
|
+
if (!Array.isArray(s.scans) || !Array.isArray(s.addedPaths)) throw new Refusal(`${path} is not a Pull record — move it aside and run again`);
|
|
324
|
+
// A collision question is printed from the latest scan, so one standing with no scan behind it cannot be.
|
|
325
|
+
if (s.pending?.qid === "collision" && s.scans.length === 0) {
|
|
326
|
+
throw new Refusal(`${path} holds a collision question that no scan of this script asked — move it aside and run again`);
|
|
327
|
+
}
|
|
284
328
|
return s;
|
|
285
329
|
}
|
|
286
330
|
|
|
@@ -312,7 +356,12 @@ const DECIDED_TOKENS = [
|
|
|
312
356
|
"ready-for-human-fork <the options, verbatim from the brief>",
|
|
313
357
|
"ready-for-human-hands <external access|manual testing|judgment> <one line>",
|
|
314
358
|
];
|
|
315
|
-
const COLLISION_TOKENS = [
|
|
359
|
+
const COLLISION_TOKENS = [
|
|
360
|
+
"clear",
|
|
361
|
+
"behind-pr:#M an open PR, or a branch with no PR yet by its name",
|
|
362
|
+
"behind-issue:#M an open issue the brief's Out of scope sequences this one after",
|
|
363
|
+
"paths <p>… adds paths to the scan, which runs again",
|
|
364
|
+
];
|
|
316
365
|
|
|
317
366
|
const TOKEN_LINES = { staleness: STALENESS_TOKENS, close: CLOSE_TOKENS, decided: DECIDED_TOKENS, collision: COLLISION_TOKENS };
|
|
318
367
|
|
|
@@ -346,6 +395,7 @@ export function parseAnswer(qid, token, rest) {
|
|
|
346
395
|
if (qid === "collision") {
|
|
347
396
|
const m = /^behind-(pr|issue):#?(\S+)$/.exec(token);
|
|
348
397
|
if (token === "clear") spec = {};
|
|
398
|
+
else if (token === "paths") spec = { text: true };
|
|
349
399
|
else if (m !== null && !m[2].startsWith("-") && (m[1] === "pr" || isDigits(m[2]))) {
|
|
350
400
|
spec = {};
|
|
351
401
|
said = `behind-${m[1]}:#${m[2]}`;
|
|
@@ -454,7 +504,7 @@ class Pull {
|
|
|
454
504
|
brief() {
|
|
455
505
|
const issue = this.issue();
|
|
456
506
|
const text = briefText(issue).trim();
|
|
457
|
-
const found =
|
|
507
|
+
const found = scopeOf(issue);
|
|
458
508
|
const paths = briefPaths(text);
|
|
459
509
|
return [
|
|
460
510
|
`TICKET #${this.st.ticket}: ${issue.title}`,
|
|
@@ -496,12 +546,17 @@ class Pull {
|
|
|
496
546
|
];
|
|
497
547
|
}
|
|
498
548
|
|
|
549
|
+
// The latest scan, line by line, and the behind-issue candidates.
|
|
499
550
|
collisionContext() {
|
|
500
|
-
const paths =
|
|
501
|
-
const
|
|
551
|
+
const { paths, overlaps, unread } = this.st.scans.at(-1);
|
|
552
|
+
const refs = issueRefs(scopeOf(this.issue()));
|
|
553
|
+
const who = (o) => (o.branch === undefined ? `PR #${o.pr}` : `branch ${o.branch}${o.pr === null ? "" : ` (PR #${o.pr})`}`);
|
|
502
554
|
return [
|
|
503
|
-
`paths
|
|
504
|
-
|
|
555
|
+
`paths scanned: ${paths.length === 0 ? "(none)" : paths.join(" ")}`,
|
|
556
|
+
...overlaps.map((o) => `${who(o)}: ${o.paths.join(" ")}`),
|
|
557
|
+
...unread.map((u) => `could not look: ${u}`),
|
|
558
|
+
...(overlaps.length === 0 ? ["no overlap"] : []),
|
|
559
|
+
`behind-issue candidates (Out of scope): ${refs.length === 0 ? "(none)" : refs.join(" ")}`,
|
|
505
560
|
];
|
|
506
561
|
}
|
|
507
562
|
|
|
@@ -568,22 +623,57 @@ class Pull {
|
|
|
568
623
|
return this.ask("decided", []);
|
|
569
624
|
}
|
|
570
625
|
|
|
626
|
+
// The scan runs every time this stage does: after Q2, and after each `paths` answer.
|
|
571
627
|
stage_collision() {
|
|
572
628
|
const { st } = this;
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
629
|
+
const r = this.gh("collision", ["pr", "list", "--state", "open", "--limit", String(PR_LIMIT), "--json", "number,headRefName"]);
|
|
630
|
+
if (r.status !== 0) return this.stop(withText(`gh pr list failed (${r.how})`, r));
|
|
631
|
+
let prs;
|
|
632
|
+
try {
|
|
633
|
+
prs = JSON.parse(r.stdout);
|
|
634
|
+
} catch (e) {
|
|
635
|
+
return this.stop(`could not parse gh pr list: ${e.message}`);
|
|
636
|
+
}
|
|
637
|
+
if (!Array.isArray(prs) || !prs.every((p) => Number.isInteger(p?.number) && typeof p.headRefName === "string")) {
|
|
638
|
+
return this.stop("gh pr list did not print a JSON array of PRs with their number and head branch");
|
|
639
|
+
}
|
|
640
|
+
if (prs.length >= PR_LIMIT) return this.stop(`gh pr list came back at its cap of ${PR_LIMIT} — it may hold more PRs than it showed`);
|
|
641
|
+
const wt = this.exec("collision", "git", "git", [], ["worktree", "list", "--porcelain", "-z"]);
|
|
642
|
+
if (wt.status !== 0) return this.stop(withText(`git worktree list failed (${wt.how})`, wt));
|
|
643
|
+
const refs = this.exec("collision", "git", "git", [], ["for-each-ref", "--format=%(refname:short)%09%(upstream:track)", "refs/heads"]);
|
|
644
|
+
if (refs.status !== 0) return this.stop(withText(`git for-each-ref failed (${refs.how})`, refs));
|
|
645
|
+
const gone = goneBranches(refs.stdout);
|
|
646
|
+
|
|
647
|
+
const paths = [...new Set([...briefPaths(briefText(this.issue()).trim()), ...st.addedPaths])];
|
|
648
|
+
// A path names a changed file, a directory above it (with or without its trailing `/`), or, with no `/`, a file by its name.
|
|
649
|
+
const hits = (p, f) => {
|
|
650
|
+
const q = p.replace(/\/+$/, "");
|
|
651
|
+
return f === q || f.startsWith(`${q}/`) || (!q.includes("/") && f.split("/").pop() === q);
|
|
652
|
+
};
|
|
653
|
+
const shared = (stdout, sep) => {
|
|
654
|
+
const files = stdout.split(sep).filter((f) => f !== "");
|
|
655
|
+
return paths.filter((p) => files.some((f) => hits(p, f)));
|
|
656
|
+
};
|
|
657
|
+
const overlaps = [];
|
|
658
|
+
const unread = [];
|
|
659
|
+
for (const pr of prs.map((p) => p.number).sort((a, b) => a - b)) {
|
|
660
|
+
const d = this.gh("collision", ["pr", "diff", String(pr), "--name-only"]);
|
|
661
|
+
const common = shared(d.stdout, "\n");
|
|
662
|
+
if (d.status !== 0) unread.push(`gh pr diff ${pr} (${failure(d)})`);
|
|
663
|
+
// Fail closed, as pr-overlap.mjs does: a PR with no changed file is a query that did not work, never "no overlap".
|
|
664
|
+
else if (d.stdout === "") unread.push(`gh pr diff ${pr} (printed no file)`);
|
|
665
|
+
else if (common.length > 0) overlaps.push({ pr, paths: common });
|
|
666
|
+
}
|
|
667
|
+
const heads = new Map(prs.map((p) => [p.headRefName, p.number]));
|
|
668
|
+
for (const branch of worktreeBranches(wt.stdout).filter((b) => b !== "main" && !gone.has(b)).sort()) {
|
|
669
|
+
const range = `origin/main...${branch}`;
|
|
670
|
+
// NUL-separated: git quotes a non-ASCII path in the newline form, and a quoted name equals no path the brief spells.
|
|
671
|
+
const d = this.exec("collision", "git", "git", [], ["diff", "--name-only", "-z", range, "--"]);
|
|
672
|
+
const common = shared(d.stdout, "\0");
|
|
673
|
+
if (d.status !== 0) unread.push(`git diff --name-only ${range} (${failure(d)})`);
|
|
674
|
+
else if (common.length > 0) overlaps.push({ branch, pr: heads.get(branch) ?? null, paths: common });
|
|
586
675
|
}
|
|
676
|
+
st.scans.push({ at: now(), paths, overlaps, unread });
|
|
587
677
|
return this.ask("collision", this.collisionContext());
|
|
588
678
|
}
|
|
589
679
|
|
|
@@ -774,12 +864,17 @@ class Pull {
|
|
|
774
864
|
return this.leave(`relabelled ${label}: ${token}`);
|
|
775
865
|
}
|
|
776
866
|
|
|
777
|
-
answer_collision(token) {
|
|
867
|
+
answer_collision(token, text) {
|
|
778
868
|
const { st } = this;
|
|
779
869
|
if (token === "clear") {
|
|
780
870
|
st.stage = "claim";
|
|
781
871
|
return null;
|
|
782
872
|
}
|
|
873
|
+
// The stage stays at collision, so the scan runs again and the question is asked again.
|
|
874
|
+
if (token === "paths") {
|
|
875
|
+
for (const p of text.split(/\s+/)) if (!st.addedPaths.includes(p)) st.addedPaths.push(p);
|
|
876
|
+
return null;
|
|
877
|
+
}
|
|
783
878
|
const r = this.script("exclude", "ledger.mjs", ["row", String(st.ticket), `excluded · ${token}`]);
|
|
784
879
|
if (r.status !== 0) return this.stop(withText(`ledger.mjs row failed (${r.how})`, r));
|
|
785
880
|
return this.leave(`excluded · ${token}`);
|
package/skills/run-team/SKILL.md
CHANGED
|
@@ -382,7 +382,8 @@ retries one that failed while applying an answer (the question stands), and
|
|
|
382
382
|
after a router refusal `next --head <N>` starts the ticket over; exit 3 is a
|
|
383
383
|
usage mistake, or an answer the question does not take, and records nothing.
|
|
384
384
|
The record is `<scratch>/impl-<N>/pull.json`. The steps below are what
|
|
385
|
-
the driver runs, and the guidance for answering `staleness` and
|
|
385
|
+
the driver runs, and the guidance for answering `staleness`, `decided` and
|
|
386
|
+
`collision`.
|
|
386
387
|
|
|
387
388
|
One free implementer slot is one Pull. The tick names the heads — `PULL #<n>
|
|
388
389
|
#<m>`, one per free slot — and each Pull runs this sequence on its head,
|
|
@@ -592,22 +593,19 @@ terminating in exactly one dispatch or an empty shortlist:
|
|
|
592
593
|
|
|
593
594
|
No sizing agent here. `sizing-a-ticket` picks the *process path*, and that is
|
|
594
595
|
phase 2's call, after the ticket is claimed.
|
|
595
|
-
4. **Collision scan against open PRs and live branches** —
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
brief, is invisible to the dependency scan, and oldest-first order puts a
|
|
609
|
-
chain's members next to each other, where two consecutive numbers read as
|
|
610
|
-
two independent tickets.
|
|
596
|
+
4. **Collision scan against open PRs and live branches** — `pull.mjs` runs it
|
|
597
|
+
before Q3 and prints one line per open PR or live worktree branch that shares
|
|
598
|
+
a path with the brief, `no overlap` when none, and `could not look: <which>`
|
|
599
|
+
for one it could not read. Answer Q3 off those lines: an overlap →
|
|
600
|
+
`behind-pr:#M`, a branch with no PR yet by its name; a target file the brief
|
|
601
|
+
does not spell as a path → `paths <p>…`, which scans again and asks again. A
|
|
602
|
+
PR the scan could not read is still yours to judge, and `behind-pr` on it is
|
|
603
|
+
taken. `pr-overlap.mjs` is **PR-vs-PR only** — it runs `gh pr diff` on both
|
|
604
|
+
args and errors on an issue number, so never run it on a ticket here.
|
|
605
|
+
5. **Sequence check** — the `#N` refs of the brief's `Out of scope` section are
|
|
606
|
+
printed beside Q3 as the candidates: one naming an open ticket this one
|
|
607
|
+
sequences after → `behind-issue:#M`. No overlap and no such ticket →
|
|
608
|
+
`clear`.
|
|
611
609
|
6. **Claim** — `~/.fleet/bin/fleet-run claim-ticket.sh <N> impl-<N> implementer
|
|
612
610
|
--apply` (below). Exit 2 → treat it as taken, next entry.
|
|
613
611
|
7. **Route, row, then dispatch** — `~/.fleet/bin/fleet-run ticket-router.mjs route
|