@feigi/fleet-ctl 3.37.1 → 3.37.2
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/fleet-tick.mjs +6 -12
- package/scripts/ledger-grammar.mjs +101 -13
- package/scripts/ledger.mjs +66 -21
- package/skills/run-team/SKILL.md +29 -10
package/package.json
CHANGED
package/scripts/fleet-tick.mjs
CHANGED
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
// the ledger; main() does the I/O. Split so the guard table and the reading are
|
|
62
62
|
// both unit-testable without a network.
|
|
63
63
|
|
|
64
|
-
import { parseMember, parseToken, premisesOf, rowNums, REVIEW, REVIEWED } from "./ledger-grammar.mjs";
|
|
64
|
+
import { parseMember, parseToken, premisesOf, rowNums, nextRetry, REVIEW, REVIEWED } from "./ledger-grammar.mjs";
|
|
65
65
|
|
|
66
66
|
// Every role's TARGET is its configured cap. Availability of work belongs in
|
|
67
67
|
// the ACTION, not the target: a reviewer target that shrank to the backlog
|
|
@@ -128,20 +128,14 @@ const tierCheckStep = (members) => "run ~/.fleet/bin/fleet-run tier-check.mjs --
|
|
|
128
128
|
+ JSON.stringify(members.map((member) => ({ member, session: "<session>" })));
|
|
129
129
|
|
|
130
130
|
// A mismatch clears when the next attempt on the ticket is dispatched at its
|
|
131
|
-
// row's tier: one
|
|
132
|
-
//
|
|
133
|
-
// before `-b`, ledger.mjs refuses a name already dispatched, and the highest
|
|
134
|
-
// letter is what compute-board.mjs's laterAttempt reads as the latest attempt.
|
|
135
|
-
// No suffix is the `a` attempt (ledger-grammar.mjs orders it first). `-z` is
|
|
136
|
-
// the grammar's last, so past it there is no legal name to print.
|
|
131
|
+
// row's tier: ledger-grammar.mjs's nextRetry(), one letter past the highest
|
|
132
|
+
// any impl member of that ticket has used, null past `-z`.
|
|
137
133
|
function replaceStep(held, implNames) {
|
|
138
134
|
const named = [], stuck = [];
|
|
139
135
|
for (const name of held) {
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (top === "z") stuck.push(name);
|
|
144
|
-
else named.push(`${family}-${number}-${String.fromCharCode(top.charCodeAt(0) + 1)}`);
|
|
136
|
+
const next = nextRetry(name, implNames);
|
|
137
|
+
if (next === null) stuck.push(name);
|
|
138
|
+
else named.push(next);
|
|
145
139
|
}
|
|
146
140
|
return [
|
|
147
141
|
named.length ? `dispatch ${named.join(", ")} ${named.length > 1 ? "each " : ""}at its row's tier` : "",
|
|
@@ -213,11 +213,12 @@ function added(before, after) {
|
|
|
213
213
|
|
|
214
214
|
// The runner name a new launch on PR <pr> takes: `review-pr-<pr>`, else the
|
|
215
215
|
// first letter from `b` that no runner launch on the PR's rows already uses —
|
|
216
|
-
// member or fallback, `=failed` or not
|
|
217
|
-
//
|
|
218
|
-
|
|
216
|
+
// member or fallback, `=failed` or not — and no name in `retired` holds, the
|
|
217
|
+
// names an earlier run of this omp session launched. null for a stream keyed
|
|
218
|
+
// by no PR number, or with every letter taken.
|
|
219
|
+
function nextReviewer(launches, pr, retired) {
|
|
219
220
|
if (typeof pr !== "number") return null;
|
|
220
|
-
const used = new Set(launches.filter((l) => l.kind !== "wf").map((l) => l.name));
|
|
221
|
+
const used = new Set([...launches.filter((l) => l.kind !== "wf").map((l) => l.name), ...retired]);
|
|
221
222
|
const base = `review-pr-${pr}`;
|
|
222
223
|
if (!used.has(base)) return base;
|
|
223
224
|
for (let c = "b".charCodeAt(0); c <= "z".charCodeAt(0); c++) {
|
|
@@ -275,7 +276,7 @@ export function newSplitRow(before, after) {
|
|
|
275
276
|
/**
|
|
276
277
|
* Why `ledger.mjs row` or `ledger.mjs review` must not write `line` over
|
|
277
278
|
* `oldLine` (null for a new row), `before` and `after` the ledger's rows on
|
|
278
|
-
* either side of the write —
|
|
279
|
+
* either side of the write, `retired` the ledger's `## Retired` names —
|
|
279
280
|
* or null when it may. Only a violation the write ADDS is a reason: each
|
|
280
281
|
* rule's offending entries are listed before the write and after it, and the
|
|
281
282
|
* after list must hold nothing the before list lacks, duplicates counted. Where
|
|
@@ -289,11 +290,13 @@ export function newSplitRow(before, after) {
|
|
|
289
290
|
* - paired results: every `reviewed=` answers a launch (readReviews above);
|
|
290
291
|
* - unique launches: a launch identity — a workflow's runId, a runner's name
|
|
291
292
|
* whatever its kind — appears at most once in its PR's stream;
|
|
293
|
+
* - unretired runners: no launch takes a runner name `retired` holds, which an
|
|
294
|
+
* earlier run of this omp session launched;
|
|
292
295
|
* - one open launch per PR: no launch appears while an earlier one is open;
|
|
293
296
|
* - an open launch is never removed: every launch open before the write is in
|
|
294
297
|
* its PR's stream after it, `=failed` allowed, on any of the PR's rows.
|
|
295
298
|
*/
|
|
296
|
-
export function rowWriteRefusal(before, after, oldLine, line) {
|
|
299
|
+
export function rowWriteRefusal(before, after, oldLine, line, retired = []) {
|
|
297
300
|
const names = (text) => (text === null ? [] : memberTokens(text).map((t) => t.name));
|
|
298
301
|
const dupes = (list) => list.filter((n, i) => list.indexOf(n) !== i);
|
|
299
302
|
const member = added(dupes(names(oldLine)), dupes(names(line)))[0];
|
|
@@ -319,10 +322,16 @@ export function rowWriteRefusal(before, after, oldLine, line) {
|
|
|
319
322
|
}
|
|
320
323
|
const repeated = added(b.repeated, a.repeated)[0];
|
|
321
324
|
if (repeated !== undefined) {
|
|
322
|
-
const next = nextReviewer(a.launches, id);
|
|
325
|
+
const next = nextReviewer(a.launches, id, retired);
|
|
323
326
|
return `launch '${repeated}' is already on ${where(id)}'s rows — unique launches: every launch takes an identity the PR has not used`
|
|
324
327
|
+ (next === null ? "" : `; the next free reviewer name is ${next}`);
|
|
325
328
|
}
|
|
329
|
+
const reused = a.launches.find((l) => l.kind !== "wf" && retired.includes(l.name) && !b.launches.some((o) => o.key === l.key));
|
|
330
|
+
if (reused !== undefined) {
|
|
331
|
+
const next = nextReviewer(a.launches, id, retired);
|
|
332
|
+
return `launch '${reused.id}' on ${where(id)} names a runner an earlier run of this session already used — unretired runners: omp would answer it with \`${reused.name}-2\``
|
|
333
|
+
+ (next === null ? "" : `; the next free reviewer name is ${next}`);
|
|
334
|
+
}
|
|
326
335
|
const crowded = added(b.crowded.map((c) => c.id), a.crowded.map((c) => c.id))[0];
|
|
327
336
|
if (crowded !== undefined) {
|
|
328
337
|
const { open } = a.crowded.find((c) => c.id === crowded);
|
|
@@ -421,6 +430,68 @@ export function liveOnLedger(rows, dispatched) {
|
|
|
421
430
|
return out;
|
|
422
431
|
}
|
|
423
432
|
|
|
433
|
+
// A reviewer's runner name: `review-pr-<n>` for a PR's first, `-b`, `-c`, …
|
|
434
|
+
// for each later one. The only runner names the grammar knows, so the only
|
|
435
|
+
// ones a rotate retires; a launch under any other name retires nothing.
|
|
436
|
+
const REVIEWER = /^review-pr-[1-9][0-9]*(-[b-z])?$/;
|
|
437
|
+
|
|
438
|
+
/** Whether `name` is one a `## Retired` line may hold: a member's name or a
|
|
439
|
+
* reviewer's, bare. */
|
|
440
|
+
export const isRetirable = (name) => parseMember(name) !== null || REVIEWER.test(name);
|
|
441
|
+
|
|
442
|
+
// The reviewer runner names a row's `review=member:<name>` and
|
|
443
|
+
// `review=fallback:<name>` launches took, `=failed` or answered or open. A
|
|
444
|
+
// workflow launch is named by its runId, which no hub member holds.
|
|
445
|
+
function launchedRunners(text) {
|
|
446
|
+
const out = [];
|
|
447
|
+
for (const word of text.split(/\s+/)) {
|
|
448
|
+
const m = REVIEW.exec(word);
|
|
449
|
+
if (m !== null && m.groups.kind !== "wf" && REVIEWER.test(m.groups.name)) out.push(m.groups.name);
|
|
450
|
+
}
|
|
451
|
+
return out;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* The names an `ancestor` rotate retires: every member the archive settled —
|
|
456
|
+
* in `## Dispatched` or on any row, the same two places `ledger.mjs dispatch`
|
|
457
|
+
* refuses a repeat from within a run — and every reviewer runner a row
|
|
458
|
+
* launched, that `liveOnLedger` does not carry, plus every name the archive's
|
|
459
|
+
* own `## Retired` already held (`retired`, bare retirable names — the caller
|
|
460
|
+
* validates them), once each, in that order. A retired name stays taken for
|
|
461
|
+
* the rest of the omp session: the process that ran the member still holds a
|
|
462
|
+
* peer under it, and omp answers a second task of that name with `<name>-2`
|
|
463
|
+
* while `hub send <name>` keeps reaching the first. `carried` is
|
|
464
|
+
* `{rows, dispatched}`, the texts of the rows and the `## Dispatched` entries
|
|
465
|
+
* the new ledger carries (`liveOnLedger`'s picks); a name it carries, live or
|
|
466
|
+
* as a settled copy, is on the new ledger already and is not listed twice. A
|
|
467
|
+
* row is read whether or not it parsed, but an unsettled member token on it
|
|
468
|
+
* retires nothing: only a settled name is known gone.
|
|
469
|
+
*/
|
|
470
|
+
export function retiredOnLedger(rows, dispatched, retired, carried) {
|
|
471
|
+
const seen = new Set();
|
|
472
|
+
for (const e of carried.dispatched) seen.add(parseToken(e).name);
|
|
473
|
+
for (const text of carried.rows) {
|
|
474
|
+
for (const t of memberTokens(text)) if (t.error === null) seen.add(t.name);
|
|
475
|
+
for (const name of launchedRunners(text)) seen.add(name);
|
|
476
|
+
}
|
|
477
|
+
const out = [];
|
|
478
|
+
const add = (name) => {
|
|
479
|
+
if (seen.has(name)) return;
|
|
480
|
+
seen.add(name);
|
|
481
|
+
out.push(name);
|
|
482
|
+
};
|
|
483
|
+
for (const name of retired) add(name);
|
|
484
|
+
for (const e of dispatched) {
|
|
485
|
+
const t = parseToken(e);
|
|
486
|
+
if (t !== null && t.error === null && t.outcome !== null) add(t.name);
|
|
487
|
+
}
|
|
488
|
+
for (const text of rows) {
|
|
489
|
+
for (const t of memberTokens(text)) if (t.error === null && t.outcome !== null) add(t.name);
|
|
490
|
+
for (const name of launchedRunners(text)) add(name);
|
|
491
|
+
}
|
|
492
|
+
return out;
|
|
493
|
+
}
|
|
494
|
+
|
|
424
495
|
// A ticket row is `#N <text>`; it is an Exclusion when `excluded` is the
|
|
425
496
|
// text's first word — `impl-N · … excluded …` is a row about something else.
|
|
426
497
|
// `#N excluded · behind-pr:#M` / `behind-issue:#M`: `#M` is an issue or PR
|
|
@@ -441,6 +512,7 @@ export const DISPATCHED = "## Dispatched";
|
|
|
441
512
|
export const FILED = "## Filed";
|
|
442
513
|
export const RULED = "## Ruled";
|
|
443
514
|
export const DRAIN = "## Drain";
|
|
515
|
+
export const RETIRED = "## Retired";
|
|
444
516
|
|
|
445
517
|
// What a section header looks like on disk, defined once because a second
|
|
446
518
|
// copy drifts: ledger.mjs slices sections with it, and sets its readability
|
|
@@ -465,15 +537,31 @@ export function unescapeText(s) {
|
|
|
465
537
|
}
|
|
466
538
|
|
|
467
539
|
/** The name the next merge bot takes: 1 + the highest `merge-bot-<n>` in
|
|
468
|
-
* `## Dispatched`, settled ones included
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
* carries
|
|
472
|
-
|
|
473
|
-
|
|
540
|
+
* `## Dispatched`, settled ones included, or among `names` — the other names
|
|
541
|
+
* the session holds, a retired bot's and a settled token on a row — the
|
|
542
|
+
* highest, not the count, since a rotate that carries a live bot forward
|
|
543
|
+
* carries a settled predecessor only when a carried row names it, and
|
|
544
|
+
* retires the rest by name. n restarts at 1 with every run that carries and
|
|
545
|
+
* retires no bot: a `dead` or `none` rotate, whose bots ran in an omp
|
|
546
|
+
* process that is gone. */
|
|
547
|
+
export function nextMergeBot(dispatched, names = []) {
|
|
548
|
+
const ns = [...dispatched.map(parseToken), ...names.map(parseMember)]
|
|
549
|
+
.filter((t) => t?.family === "merge-bot").map((t) => t.number);
|
|
474
550
|
return `merge-bot-${Math.max(0, ...ns) + 1}`;
|
|
475
551
|
}
|
|
476
552
|
|
|
553
|
+
/** The replacement name a member of `name`'s family and number takes next:
|
|
554
|
+
* one retry letter past the HIGHEST any of `names` on that number has used,
|
|
555
|
+
* `name` itself included — not past `name`'s own, since a controller can
|
|
556
|
+
* dispatch `-c` before `-b`. No suffix is the `a` attempt; `-z` is the
|
|
557
|
+
* grammar's last, past which there is no legal name, so null. */
|
|
558
|
+
export function nextRetry(name, names) {
|
|
559
|
+
const { family, number } = parseMember(name);
|
|
560
|
+
const top = [name, ...names].map(parseMember).filter((m) => m !== null && m.family === family && m.number === number)
|
|
561
|
+
.map((m) => m.retry ?? "a").sort().at(-1);
|
|
562
|
+
return top === "z" ? null : `${family}-${number}-${String.fromCharCode(top.charCodeAt(0) + 1)}`;
|
|
563
|
+
}
|
|
564
|
+
|
|
477
565
|
// An implementer cell is `<role>-<level>` — an omp role and a thinking
|
|
478
566
|
// level — and each cell is one definition, `fleet-implementer-<cell>`, whose
|
|
479
567
|
// `model:` is `@<role>:<level>`. Nothing is named
|
package/scripts/ledger.mjs
CHANGED
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
// dispatch and never loses or reorders one — settling annotates an entry in
|
|
21
21
|
// place — which is what lets `merge-bot-<n>` be numbered from it; a rotate
|
|
22
22
|
// that carries a run's live entries forward carries a settled one only for a
|
|
23
|
-
// member a carried row names
|
|
23
|
+
// member a carried row names, and retires every other settled name into
|
|
24
|
+
// `## Retired`, where `dispatch` and that numbering still read it.
|
|
24
25
|
//
|
|
25
26
|
// Writer policy: the controller owns run state
|
|
26
27
|
// (`row`/`settle`/`dispatch`/`review`/`drain`/`ruled`/`rotate`); filers append
|
|
@@ -38,7 +39,7 @@ import { fileURLToPath } from "node:url";
|
|
|
38
39
|
import { spawnSync, execFileSync } from "node:child_process";
|
|
39
40
|
import { makeDie, isFlagLike, hasEqualsForm, isDigits } from "./arg.mjs";
|
|
40
41
|
import { fleetFile, FleetDirUnresolvable } from "./fleet-dir.mjs";
|
|
41
|
-
import { parseMember, parseToken, memberTokens, nextMergeBot, liveOnLedger, agentDefinition, CELL, tierValues, rowPr, rowWriteRefusal, isReviewToken, addedReviewToken, newSplitRow, premisesOf, ROWS, DISPATCHED, FILED, RULED, DRAIN, headerRe, escapeText, unescapeText } from "./ledger-grammar.mjs";
|
|
42
|
+
import { parseMember, parseToken, memberTokens, nextMergeBot, nextRetry, liveOnLedger, retiredOnLedger, isRetirable, agentDefinition, CELL, tierValues, rowPr, rowWriteRefusal, isReviewToken, addedReviewToken, newSplitRow, premisesOf, ROWS, DISPATCHED, FILED, RULED, DRAIN, RETIRED, headerRe, escapeText, unescapeText } from "./ledger-grammar.mjs";
|
|
42
43
|
import { deriveRun, LedgerError, labelOffMember } from "./fleet-tick.mjs";
|
|
43
44
|
import { stateFileIn, readState, writeState, assessBeat, stallsAt } from "./fleet-state.mjs";
|
|
44
45
|
import { isDead, processSource, ancestry, controllerOf, judgeController, ProcUnreadable } from "./proc.mjs";
|
|
@@ -452,7 +453,7 @@ function sectionOf(text, name) {
|
|
|
452
453
|
}
|
|
453
454
|
|
|
454
455
|
function load() {
|
|
455
|
-
if (!existsSync(file)) return { rows: [], filed: [], ruled: [], dispatched: [], drain: null };
|
|
456
|
+
if (!existsSync(file)) return { rows: [], filed: [], ruled: [], dispatched: [], drain: null, retired: [] };
|
|
456
457
|
let text;
|
|
457
458
|
try {
|
|
458
459
|
text = readFileSync(file, "utf8");
|
|
@@ -479,12 +480,16 @@ function load() {
|
|
|
479
480
|
return {
|
|
480
481
|
rows: section(ROWS), filed: section(FILED), ruled: section(RULED),
|
|
481
482
|
dispatched: section(DISPATCHED), drain: drainEntries[0] ?? null,
|
|
483
|
+
retired: section(RETIRED),
|
|
482
484
|
};
|
|
483
485
|
}
|
|
484
486
|
|
|
485
487
|
// `## Drain` is written only once there is a marker to hold: an empty section
|
|
486
488
|
// under that name would read, to anyone scanning the file by eye, as a run
|
|
487
|
-
// that is draining.
|
|
489
|
+
// that is draining. `## Retired` likewise: only an `ancestor` rotate writes
|
|
490
|
+
// it (runRotate()), as the bare names of the members this omp session has
|
|
491
|
+
// already run and the new ledger does not carry, so a ledger without it is
|
|
492
|
+
// a session's first run.
|
|
488
493
|
function save(d) {
|
|
489
494
|
const list = (entries) => entries.map((r) => `- ${escapeText(r)}`).join("\n");
|
|
490
495
|
const out =
|
|
@@ -492,7 +497,8 @@ function save(d) {
|
|
|
492
497
|
`\n\n${DISPATCHED}\n\n` + list(d.dispatched) +
|
|
493
498
|
`\n\n${FILED}\n\n` + list(d.filed) +
|
|
494
499
|
`\n\n${RULED}\n\n` + list(d.ruled) +
|
|
495
|
-
(d.drain === null ? "" : `\n\n${DRAIN}\n\n` + list([d.drain])) +
|
|
500
|
+
(d.drain === null ? "" : `\n\n${DRAIN}\n\n` + list([d.drain])) +
|
|
501
|
+
(d.retired.length === 0 ? "" : `\n\n${RETIRED}\n\n` + list(d.retired)) + "\n";
|
|
496
502
|
try {
|
|
497
503
|
mkdirSync(dirname(file), { recursive: true });
|
|
498
504
|
// Write to a sibling temp file and rename over the target. rename is
|
|
@@ -1539,6 +1545,18 @@ function runCheck() {
|
|
|
1539
1545
|
// against the session's job list; rotate cannot, since that list is the
|
|
1540
1546
|
// controller's to read and no script's.
|
|
1541
1547
|
//
|
|
1548
|
+
// An `ancestor` rotate also writes `## Retired`: the bare name of every
|
|
1549
|
+
// member the archive settled and the new ledger does not carry, of every
|
|
1550
|
+
// reviewer runner its rows launched and the new ledger does not carry, and
|
|
1551
|
+
// every name the archive's own `## Retired` held. The omp process those
|
|
1552
|
+
// members ran in is still this run's, and it answers a second task under a
|
|
1553
|
+
// name it has used with `<name>-2` while `hub send <name>` keeps reaching the
|
|
1554
|
+
// first — so a settled name stays taken for the session, not the run:
|
|
1555
|
+
// `dispatch` and `review` refuse it (a replacement takes its own suffix) and
|
|
1556
|
+
// `nextMergeBot` numbers past it. Measured before this: a session's second
|
|
1557
|
+
// run restarted at `merge-bot-1`. A `dead` or `none` rotate retires nothing,
|
|
1558
|
+
// since the process that held those names is gone.
|
|
1559
|
+
//
|
|
1542
1560
|
// Under the write lock like every other write subcommand, so a concurrent
|
|
1543
1561
|
// writer either lands before the move (in the archive, whole) or after it (in
|
|
1544
1562
|
// the fresh skeleton) — never half in each.
|
|
@@ -1601,7 +1619,7 @@ function runRotate() {
|
|
|
1601
1619
|
}
|
|
1602
1620
|
// Read before anything moves: a ledger whose live tokens cannot be read is
|
|
1603
1621
|
// refused with nothing moved, never archived with those tokens dropped.
|
|
1604
|
-
let carry = { rows: [], dispatched: [], skipped: [] };
|
|
1622
|
+
let carry = { rows: [], dispatched: [], retired: [], skipped: [] };
|
|
1605
1623
|
if (prior === "ancestor" && exists) {
|
|
1606
1624
|
let text;
|
|
1607
1625
|
try {
|
|
@@ -1611,7 +1629,7 @@ function runRotate() {
|
|
|
1611
1629
|
}
|
|
1612
1630
|
carry = carryOf(text);
|
|
1613
1631
|
}
|
|
1614
|
-
const carrying = carry.rows.length > 0 || carry.dispatched.length > 0;
|
|
1632
|
+
const carrying = carry.rows.length > 0 || carry.dispatched.length > 0 || carry.retired.length > 0;
|
|
1615
1633
|
let archive = null;
|
|
1616
1634
|
if (exists) {
|
|
1617
1635
|
const stamp = new Date().toISOString().replace(/\.\d{3}Z$/, "Z").replaceAll(":", "");
|
|
@@ -1639,7 +1657,7 @@ function runRotate() {
|
|
|
1639
1657
|
// Nothing to carry writes nothing, so the next write starts the skeleton
|
|
1640
1658
|
// exactly as after any other verdict.
|
|
1641
1659
|
if (carrying) {
|
|
1642
|
-
save({ rows: carry.rows, dispatched: carry.dispatched, filed: [], ruled: [], drain: null });
|
|
1660
|
+
save({ rows: carry.rows, dispatched: carry.dispatched, filed: [], ruled: [], drain: null, retired: carry.retired });
|
|
1643
1661
|
}
|
|
1644
1662
|
if (archive !== null) console.error(` rotated ${file} -> ${archive}`);
|
|
1645
1663
|
for (const { line, why } of carry.skipped) {
|
|
@@ -1647,6 +1665,7 @@ function runRotate() {
|
|
|
1647
1665
|
}
|
|
1648
1666
|
if (carrying) {
|
|
1649
1667
|
console.error(` carried ${carry.rows.length} row(s) and ${carry.dispatched.length} ## Dispatched entr${carry.dispatched.length === 1 ? "y" : "ies"} from ${archive}`);
|
|
1668
|
+
console.error(` retired ${carry.retired.length} name(s) from ${archive}`);
|
|
1650
1669
|
}
|
|
1651
1670
|
// Re-read rather than reuse the read above: the heartbeat file has other
|
|
1652
1671
|
// writers, and a patch built from an older view would undo what they wrote
|
|
@@ -1658,6 +1677,7 @@ function runRotate() {
|
|
|
1658
1677
|
console.log(JSON.stringify({
|
|
1659
1678
|
rotated: archive !== null, archive,
|
|
1660
1679
|
carried: { rows: carry.rows, dispatched: carry.dispatched },
|
|
1680
|
+
retired: carry.retired,
|
|
1661
1681
|
skipped: carry.skipped.map((s) => s.line),
|
|
1662
1682
|
}));
|
|
1663
1683
|
}
|
|
@@ -1675,9 +1695,14 @@ function runRotate() {
|
|
|
1675
1695
|
// tokens, `reviewed=` and every other record on it come along, and its
|
|
1676
1696
|
// siblings' with them, and the tick's per-PR reading of the PR is unchanged;
|
|
1677
1697
|
// and the `## Dispatched` entries, settled ones among them, that keep a
|
|
1678
|
-
// carried member from reading live again.
|
|
1698
|
+
// carried member from reading live again. retiredOnLedger() names the rest:
|
|
1699
|
+
// every settled member neither travels, and every reviewer runner a row
|
|
1700
|
+
// launched, read off the parsed rows and the skipped ones alike — a row the
|
|
1701
|
+
// tick refuses still names members this session ran — and the archive's own
|
|
1702
|
+
// `## Retired`, each line of which must be a bare member or reviewer name.
|
|
1679
1703
|
function carryOf(text) {
|
|
1680
1704
|
const skipped = [];
|
|
1705
|
+
const skippedRows = [];
|
|
1681
1706
|
const rows = sectionOf(text, ROWS).filter((r) => {
|
|
1682
1707
|
try {
|
|
1683
1708
|
deriveRun({ rows: [r], dispatched: [], drain: null }, []);
|
|
@@ -1685,6 +1710,7 @@ function carryOf(text) {
|
|
|
1685
1710
|
} catch (e) {
|
|
1686
1711
|
if (!(e instanceof LedgerError)) throw e;
|
|
1687
1712
|
skipped.push({ line: r, why: e.message });
|
|
1713
|
+
skippedRows.push(r);
|
|
1688
1714
|
return false;
|
|
1689
1715
|
}
|
|
1690
1716
|
});
|
|
@@ -1694,8 +1720,15 @@ function carryOf(text) {
|
|
|
1694
1720
|
skipped.push({ line: e, why: t === null ? "not a member token" : `${t.name}: ${t.error}` });
|
|
1695
1721
|
return false;
|
|
1696
1722
|
});
|
|
1723
|
+
const archivedRetired = sectionOf(text, RETIRED).filter((name) => {
|
|
1724
|
+
if (isRetirable(name)) return true;
|
|
1725
|
+
skipped.push({ line: name, why: "not a bare member or reviewer name" });
|
|
1726
|
+
return false;
|
|
1727
|
+
});
|
|
1697
1728
|
const live = liveOnLedger(rows, dispatched);
|
|
1698
|
-
|
|
1729
|
+
const carried = { rows: live.rows.map((i) => rows[i]), dispatched: live.dispatched };
|
|
1730
|
+
const retired = retiredOnLedger([...rows, ...skippedRows], dispatched, archivedRetired, carried);
|
|
1731
|
+
return { ...carried, retired, skipped };
|
|
1699
1732
|
}
|
|
1700
1733
|
|
|
1701
1734
|
// ── dispatch / settle ────────────────────────────────────────────────────────
|
|
@@ -1799,15 +1832,17 @@ function runDispatch() {
|
|
|
1799
1832
|
refuseMalformedDispatched();
|
|
1800
1833
|
|
|
1801
1834
|
// `merge-bot` bare is the merge-bot case of this command: the ledger names
|
|
1802
|
-
// the bot, 1 + the merge-bot
|
|
1803
|
-
//
|
|
1804
|
-
// when it is that one.
|
|
1805
|
-
|
|
1835
|
+
// the bot, 1 + the highest merge-bot name this session holds — in
|
|
1836
|
+
// `## Dispatched`, on a row or in `## Retired` — so the controller never
|
|
1837
|
+
// counts. An explicit `merge-bot-<n>` is accepted only when it is that one.
|
|
1838
|
+
// `sessionNames` is every name beyond `## Dispatched` the session has used.
|
|
1839
|
+
const sessionNames = [...data.rows.flatMap(memberTokens).map((t) => t.name), ...data.retired];
|
|
1840
|
+
const member = parseMember(name === "merge-bot" ? nextMergeBot(data.dispatched, sessionNames) : name);
|
|
1806
1841
|
if (!member) die(unknownMember(name));
|
|
1807
1842
|
if (member.bound === null) {
|
|
1808
1843
|
if (key !== null) die(`merge bots work no ticket or PR — ${usage}`);
|
|
1809
|
-
const next = nextMergeBot(data.dispatched);
|
|
1810
|
-
if (member.name !== next) die(`${member.name} is not next — the next merge bot this
|
|
1844
|
+
const next = nextMergeBot(data.dispatched, sessionNames);
|
|
1845
|
+
if (member.name !== next) die(`${member.name} is not next — the next merge bot this session is ${next}; \`dispatch merge-bot\` names it`);
|
|
1811
1846
|
} else if (key === null) {
|
|
1812
1847
|
die(`${member.name} works a ticket or PR — ${usage}`);
|
|
1813
1848
|
}
|
|
@@ -1822,14 +1857,24 @@ function runDispatch() {
|
|
|
1822
1857
|
die(`the run is draining (${data.drain}) — no implementer dispatch; drain stops supply`);
|
|
1823
1858
|
}
|
|
1824
1859
|
|
|
1825
|
-
// One token per member for the whole
|
|
1826
|
-
// too — a `row`-written record the ledger never saw dispatched
|
|
1860
|
+
// One token per member for the whole omp session. A settled token on a row
|
|
1861
|
+
// counts too — a `row`-written record the ledger never saw dispatched — and
|
|
1862
|
+
// so does a name `## Retired` holds: an earlier run of this session ran it,
|
|
1863
|
+
// and omp still holds that peer under the name (see runRotate()). The
|
|
1864
|
+
// replacement's name is spelled out: one letter past the highest this
|
|
1865
|
+
// session has used on the number, wherever that name sits.
|
|
1827
1866
|
const settledOnRow = data.rows.flatMap(memberTokens).find((t) => t.name === member.name && t.outcome !== null);
|
|
1828
1867
|
const prior =
|
|
1829
1868
|
data.dispatched.find((e) => parseToken(e).name === member.name) ??
|
|
1830
|
-
(settledOnRow && `${settledOnRow.name}=${settledOnRow.outcome}`)
|
|
1869
|
+
(settledOnRow && `${settledOnRow.name}=${settledOnRow.outcome}`) ??
|
|
1870
|
+
(data.retired.includes(member.name) ? "retired by rotate" : undefined);
|
|
1831
1871
|
if (prior !== undefined) {
|
|
1832
|
-
|
|
1872
|
+
// Never a merge bot: it is accepted only as the number past every name
|
|
1873
|
+
// the session holds, so none of the three places above can name it.
|
|
1874
|
+
const used = [...data.dispatched.map((e) => parseToken(e).name), ...sessionNames];
|
|
1875
|
+
const next = nextRetry(member.name, used);
|
|
1876
|
+
die(`${member.name} was already dispatched this session (${prior}) — a replacement takes a name of its own`
|
|
1877
|
+
+ (next === null ? `, and ${member.name} has no retry letter left` : ` (${next})`));
|
|
1833
1878
|
}
|
|
1834
1879
|
|
|
1835
1880
|
// A replacement (`-b`, `-c` …) works the same ticket or PR as its
|
|
@@ -2069,7 +2114,7 @@ function runReview() {
|
|
|
2069
2114
|
: created ? `${head} ${appended.join(" · ")}`
|
|
2070
2115
|
: `${head} · ${appended.join(" · ")}`;
|
|
2071
2116
|
const after = created ? [...data.rows, line] : data.rows.with(i, line);
|
|
2072
|
-
const refusal = rowWriteRefusal(data.rows, after, oldLine, line);
|
|
2117
|
+
const refusal = rowWriteRefusal(data.rows, after, oldLine, line, data.retired);
|
|
2073
2118
|
if (refusal !== null) die(`review #${prNum}: ${refusal}`);
|
|
2074
2119
|
data.rows = after;
|
|
2075
2120
|
save(data);
|
package/skills/run-team/SKILL.md
CHANGED
|
@@ -404,12 +404,25 @@ phase, or in any later one, asks the maintainer which tickets to take.
|
|
|
404
404
|
or an open `review=` launch, whole and with every other token on it, plus
|
|
405
405
|
every unsettled `## Dispatched` entry and the settled entry of each
|
|
406
406
|
member a carried row names; exclusions, `## Filed`, `## Ruled` and the
|
|
407
|
-
drain marker are never carried.
|
|
407
|
+
drain marker are never carried. Every other settled name — in
|
|
408
|
+
`## Dispatched` or on any row — and every reviewer runner a row launched
|
|
409
|
+
goes into the new ledger's `## Retired` as a bare name, with whatever the
|
|
410
|
+
archive's own `## Retired` held: omp answers a second `task` under a name
|
|
411
|
+
this process has used with `<name>-2` while `hub send <name>` keeps
|
|
412
|
+
reaching the first, so a settled name stays taken for the session, not
|
|
413
|
+
the run. `dispatch` refuses a retired name and names the replacement — one
|
|
414
|
+
retry letter past the highest the session has used on that number,
|
|
415
|
+
`impl-42-b` for a ticket this session's earlier run worked as `impl-42` —
|
|
416
|
+
`review` refuses a retired runner name and names the next free reviewer
|
|
417
|
+
name, and `dispatch merge-bot` numbers past retired bots. The tick never
|
|
418
|
+
reads `## Retired`: a ticket an earlier run worked is not claimed by it
|
|
419
|
+
and can be shortlisted again.
|
|
408
420
|
A line it cannot parse is skipped with a warning naming it, and the
|
|
409
421
|
rotation still succeeds. It prints `{rotated, archive, carried: {rows,
|
|
410
|
-
dispatched}, skipped}`. The carried tokens keep the tick from
|
|
411
|
-
onto those members' work, keep their names taken, and give
|
|
412
|
-
results a token to settle; the stranded-claim step below
|
|
422
|
+
dispatched}, retired, skipped}`. The carried tokens keep the tick from
|
|
423
|
+
dispatching onto those members' work, keep their names taken, and give
|
|
424
|
+
their late results a token to settle; the stranded-claim step below
|
|
425
|
+
reconciles them.
|
|
413
426
|
What an unclean end left in
|
|
414
427
|
flight comes back through the ordinary per-run path: open PRs through the
|
|
415
428
|
fold-in below, `behind-pr:`/`behind-issue:` exclusions through phase 1's
|
|
@@ -3440,9 +3453,11 @@ there.
|
|
|
3440
3453
|
### Merge bot
|
|
3441
3454
|
|
|
3442
3455
|
Per pass, named `merge-bot-<n>`, never two at once. `ledger.mjs dispatch
|
|
3443
|
-
merge-bot` names it before the dispatch call — `n` is 1 + the
|
|
3444
|
-
|
|
3445
|
-
|
|
3456
|
+
merge-bot` names it before the dispatch call — `n` is 1 + the highest
|
|
3457
|
+
`merge-bot-<n>` the session holds, in the ledger's `## Dispatched` list, on a
|
|
3458
|
+
row or in `## Retired`, so it restarts at 1 only when none was carried or
|
|
3459
|
+
retired (a `dead` or `none` rotate, or a fresh start), a replacement for a
|
|
3460
|
+
dead bot takes the next `n`, and nobody counts. Dispatch
|
|
3446
3461
|
it on the tick's `DISPATCH merge-bot`: the first `ready-to-merge` label is
|
|
3447
3462
|
enough, and it never waits for the finisher's report. Tell it to read
|
|
3448
3463
|
`$(~/.fleet/bin/fleet-run --root)/commands/run-merge-bot.md` and run **one**
|
|
@@ -4088,7 +4103,8 @@ live count from it, so nobody states one. Write neither by hand:
|
|
|
4088
4103
|
mapping), a finisher's and a merge bot's are their own definitions, a
|
|
4089
4104
|
review fix-applier's is `null`, and a conflict-hold fix-applier's is
|
|
4090
4105
|
`fleet-implementer-slow-high`: its own section says how it is dispatched. It
|
|
4091
|
-
refuses a name this
|
|
4106
|
+
refuses a name this session already used — on the ledger or in its
|
|
4107
|
+
`## Retired` — and names the replacement (`-b`, `-c` …), a
|
|
4092
4108
|
second live member on one ticket or PR, any implementer once the run is
|
|
4093
4109
|
draining, an implementer whose row's `tier=` names no single definition
|
|
4094
4110
|
or one with no file under `agents/`, and a fix-applier on a ledger the tick
|
|
@@ -4120,7 +4136,8 @@ live count from it, so nobody states one. Write neither by hand:
|
|
|
4120
4136
|
the file as-is to `ledger.<UTC YYYY-MM-DDTHHMMSSZ>.md` beside it under the
|
|
4121
4137
|
same `<file>.lock`, and the next write starts the empty skeleton — unless
|
|
4122
4138
|
the previous run was this session's own, when it first writes the rows and
|
|
4123
|
-
`## Dispatched` entries still live into a new ledger
|
|
4139
|
+
`## Dispatched` entries still live into a new ledger, and every other
|
|
4140
|
+
settled name into its `## Retired` (phase 0 says which). Refused
|
|
4124
4141
|
while the recorded controller is alive and not this run's ancestor, ledger
|
|
4125
4142
|
or none — or, with no record and a ledger to move, while the heartbeat mark
|
|
4126
4143
|
is still beating — or when the archive name already exists, the process
|
|
@@ -4168,7 +4185,9 @@ maps to the PR — its settled `impl-<N>=PR#<M>` token, else its first `PR#`
|
|
|
4168
4185
|
mention, else its key — in ledger order. Every `reviewed=` answers the nearest
|
|
4169
4186
|
earlier launch that is neither answered nor `=failed`. A launch identity (a
|
|
4170
4187
|
workflow's runId, or a runner's name whichever of member or fallback launched
|
|
4171
|
-
it, `=failed` aside) appears once
|
|
4188
|
+
it, `=failed` aside) appears once, and no launch takes a runner name the
|
|
4189
|
+
ledger's `## Retired` holds — an earlier run of this session launched it —
|
|
4190
|
+
naming the next free reviewer name instead. No launch appears
|
|
4172
4191
|
while an earlier one is open — unanswered and not `=failed`. Every
|
|
4173
4192
|
`review=`/`reviewed=` parses. `row` holds the rest: a launch open before the
|
|
4174
4193
|
write is still on one of the PR's rows after it, `=failed` allowed, and a
|