@feigi/fleet-ctl 3.29.2 → 3.29.4
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/commands/run-merge-bot.md +1 -1
- package/package.json +1 -1
- package/scripts/compute-board.mjs +19 -20
- package/scripts/fleet-tick.mjs +14 -16
- package/scripts/ledger-grammar.mjs +22 -0
- package/scripts/ledger.mjs +9 -16
- package/scripts/tier-outcomes.mjs +5 -6
- package/scripts/worktree.sh +18 -0
|
@@ -187,7 +187,7 @@ For each labeled PR clearing the hold rule, lowest first:
|
|
|
187
187
|
~/.fleet/bin/fleet-run ledger.mjs row <key> "<text> · conflict-hold:#<pr> (conflict: <path1>, <path2>)"
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
-
`<text>` is everything after the key, verbatim — `row` rewrites the whole line, so a token you drop is gone. `#<pr>` is this PR, never the one it conflicts with; the tick refuses a hold naming another PR. The `(conflict: …)` note is free text, comma-joined paths from the `diff --name-only` read above — placed *after* the token, never before, so it cannot
|
|
190
|
+
`<text>` is everything after the key, verbatim — `row` rewrites the whole line, so a token you drop is gone. `#<pr>` is this PR, never the one it conflicts with; the tick refuses a hold naming another PR. The `(conflict: …)` note is free text, comma-joined paths from the `diff --name-only` read above — placed *after* the token, never before, so it cannot become the first `PR#` mention a row with no `impl-` token is read by (`ledger-grammar.mjs`'s `rowPr`) or fall inside `CONFLICT_HOLD`'s own pattern. From then on the tick prints `DISPATCH fix-pr PR#<pr>` for it and counts it in `held=` until a fix-applier dispatched after the hold settles `applied:`/`no-op`. Skip the `row` write on an already-unresolved hold, per the paragraph above — nothing else about this path changes: still report `rebase-fallback-#<pr>`, still hand it back.
|
|
191
191
|
|
|
192
192
|
**The fallback's "verified" needs a clean main-gain check on the local rebased head.** Save the PR body to `<scratch>/pr<N>/merge-bot-<n>/body.md` (`gh pr view <pr> --json body -q .body`) and, from the main checkout, run `~/.fleet/bin/fleet-run main-gain.mjs --head "$(git -C <worktree> rev-parse HEAD)" --body-file <scratch>/pr<N>/merge-bot-<n>/body.md`. Exit 0 is the only clean result; name every `acknowledged[]` entry, with its reason, in the hand-back. Exit 1 (a line `main` gained after the PR began would be removed) or exit 2 (it could not answer) is reported inside `rebase-fallback-#<pr>` — the hits and each one's `ack` line to copy, or the `reason` it could not answer — and the fallback is never reported verified.
|
|
193
193
|
|
package/package.json
CHANGED
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
// `<member>=<outcome>` settled) and has no I/O at all; parseToken is read
|
|
16
16
|
// from it for the same reason — one grammar, one reader, so the cockpit and
|
|
17
17
|
// fleet-tick.mjs cannot disagree about which members are live.
|
|
18
|
-
//
|
|
19
|
-
// token is read through it (see the paragraph below on a row with no
|
|
20
|
-
// token) so
|
|
21
|
-
// carries a PR-bound signal —
|
|
18
|
+
// ledger-grammar.mjs owns a row's PR reading too, rowPr(), and a row with no
|
|
19
|
+
// impl token is read through it (see the paragraph below on a row with no
|
|
20
|
+
// `impl` token) so the cockpit and fleet-tick.mjs name the same PR for the
|
|
21
|
+
// same text, for a row that carries a PR-bound signal —
|
|
22
22
|
// an unsignaled row (no mention, no PR-bound member, no review=/reviewed=)
|
|
23
23
|
// still gets pr: null here while fleet-tick.mjs's own row-key fallback keys
|
|
24
|
-
// it to its ticket number regardless; see the same paragraph below.
|
|
25
|
-
//
|
|
26
|
-
//
|
|
24
|
+
// it to its ticket number regardless; see the same paragraph below.
|
|
25
|
+
// fleet-tick.mjs's I/O and main() never run here, main() being guarded on
|
|
26
|
+
// argv[1].
|
|
27
27
|
import { assessBeat, isStalled, stallReport } from "./fleet-state.mjs";
|
|
28
|
-
import { parseToken, HALT_CAUSES } from "./ledger-grammar.mjs";
|
|
29
|
-
import {
|
|
28
|
+
import { parseToken, rowPr, HALT_CAUSES } from "./ledger-grammar.mjs";
|
|
29
|
+
import { REVIEWED, latestFinisherAttempts } from "./fleet-tick.mjs";
|
|
30
30
|
|
|
31
31
|
// A ledger row is freeform, controller-authored text. Two example shapes:
|
|
32
32
|
// #<n> impl-<n>=PR#<m> → PR#<m> → MERGED 73b356de
|
|
@@ -40,19 +40,18 @@ import { PR_MENTION, REVIEWED, latestFinisherAttempts } from "./fleet-tick.mjs";
|
|
|
40
40
|
// → that PR decides, `=released`/`=bailed` → no card of
|
|
41
41
|
// the row's own (the POOL loop shows the ticket if it is still
|
|
42
42
|
// `ready-for-agent`), `=killed`/`=tier-mismatch` → IMPLEMENTING with that
|
|
43
|
-
// outcome as a flag. There the `→ PR#M` arrow
|
|
44
|
-
// parseRow reads only the settled impl
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
// either reader may rely on.
|
|
43
|
+
// outcome as a flag. There a `PR#` mention — the `→ PR#M` arrow or any
|
|
44
|
+
// other prose — is human-readable only; parseRow reads only the settled impl
|
|
45
|
+
// token's outcome, as rowPr() does for every reader. rowPr() takes the row's
|
|
46
|
+
// first settled `=PR#M` impl token, this card its latest attempt: the two
|
|
47
|
+
// differ only on a row carrying more than one impl token.
|
|
49
48
|
//
|
|
50
49
|
// A row with no `impl` token at all has no outcome to
|
|
51
50
|
// read, so it takes the tick's reading. `ledger.mjs dispatch <pr> fix-pr-<pr>` /
|
|
52
51
|
// `finisher-pr-<pr>` appends `#<pr> <member>` for a PR this run's
|
|
53
52
|
// implementers did not open. Once such a row carries a PR-bound signal — a
|
|
54
53
|
// `PR#M` mention, a `fix-pr-`/`finisher-pr-` member, `review=` or `reviewed=`
|
|
55
|
-
// — its PR is
|
|
54
|
+
// — its PR is rowPr()'s, else the row key, and that PR decides the card as
|
|
56
55
|
// `=PR#M` does. An Exclusion never takes one.
|
|
57
56
|
//
|
|
58
57
|
// A member settled anywhere on the row is settled — a bare copy beside
|
|
@@ -211,16 +210,16 @@ export function parseRow(row) {
|
|
|
211
210
|
let pr = prM ? Number(prM[1]) : null;
|
|
212
211
|
// A row with NO impl token — a malformed one still
|
|
213
212
|
// counts, since that row's key is a ticket — is keyed, once THIS row
|
|
214
|
-
// carries a PR-bound signal, the way fleet-tick.mjs's
|
|
215
|
-
// row-key logic would:
|
|
213
|
+
// carries a PR-bound signal, the way fleet-tick.mjs's rowPr-then-
|
|
214
|
+
// row-key logic would: rowPr()'s first `PR#` mention (itself a signal), else the
|
|
216
215
|
// row key when the first word is exactly `#N`. fleet-tick.mjs's own
|
|
217
216
|
// row-key fallback (deriveRun) is NOT itself gated on a signal — this
|
|
218
217
|
// module's extra gate exists so an ordinary unclaimed ticket never
|
|
219
218
|
// borrows its own number as a phantom PR. An Exclusion is supply and
|
|
220
219
|
// never takes a PR, whatever text it carries.
|
|
221
220
|
if (!anyImpl && !ex) {
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
221
|
+
const own = rowPr(row);
|
|
222
|
+
if (own !== null) pr = own;
|
|
224
223
|
else if ((prMember || review || reviewed) && row.split(/\s/)[0] === issueM[0]) pr = Number(issueM[1]);
|
|
225
224
|
}
|
|
226
225
|
let lastFinisher = null;
|
package/scripts/fleet-tick.mjs
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
// the ledger; main() does the I/O. Split so the guard table and the reading are
|
|
60
60
|
// both unit-testable without a network.
|
|
61
61
|
|
|
62
|
-
import { parseMember, parseToken } from "./ledger-grammar.mjs";
|
|
62
|
+
import { parseMember, parseToken, rowPr } from "./ledger-grammar.mjs";
|
|
63
63
|
|
|
64
64
|
// Every role's TARGET is its configured cap. Availability of work belongs in
|
|
65
65
|
// the ACTION, not the target: a reviewer target that shrank to the backlog
|
|
@@ -340,17 +340,6 @@ export function actionable(rows) {
|
|
|
340
340
|
|
|
341
341
|
export class LedgerError extends Error {}
|
|
342
342
|
|
|
343
|
-
// A row's PR is its first `PR#<n>` mention — ledger.mjs rowPr()'s reading, so
|
|
344
|
-
// both the `→ PR#<n>` arrow and a settled `impl-<N>=PR#<n>` name it. A row
|
|
345
|
-
// with none is keyed by the PR's own number when it is about a PR at all (a PR
|
|
346
|
-
// this run's implementers did not open) — this is ledger.mjs's
|
|
347
|
-
// memberRowIndex() fallback specifically, which gates on the member being
|
|
348
|
-
// PR-bound before it ever reaches this fallback. deriveRun below applies the
|
|
349
|
-
// same row-key fallback to every row's own bookkeeping unconditionally,
|
|
350
|
-
// signal or not; only memberRowIndex()'s caller already knows it holds a
|
|
351
|
-
// PR-bound member. Ticket and PR numbers share GitHub's one number
|
|
352
|
-
// space, so a ticket's key never names an open PR.
|
|
353
|
-
export const PR_MENTION = /\bPR\s*#(\d+)\b/;
|
|
354
343
|
// shortlist.mjs's own spelling of an Exclusion row and its premises.
|
|
355
344
|
const EXCLUDED_ROW = /^#[0-9]+[ \t]+excluded(?=[ \t]|$)([\s\S]*)$/;
|
|
356
345
|
const PREMISE = /\bbehind-(pr|issue):#?([^\s,;]+)/g;
|
|
@@ -429,13 +418,22 @@ export function labelOffMember(tok) {
|
|
|
429
418
|
return m !== null && m.family === "finisher-pr" ? m : null;
|
|
430
419
|
}
|
|
431
420
|
|
|
432
|
-
// A row's key number and its PR
|
|
433
|
-
//
|
|
421
|
+
// A row's key number and its PR: the PR every PR-bound token on the row
|
|
422
|
+
// speaks for. That PR is ledger-grammar.mjs's rowPr(): on a row carrying an
|
|
423
|
+
// `impl-` token, its settled `impl-<N>=PR#<n>` token's PR, never a prose
|
|
424
|
+
// `PR#` mention; on any other row, its first `PR#<n>` mention. A row with
|
|
425
|
+
// none is keyed by the PR's own number when it is about a PR at all (a PR
|
|
426
|
+
// this run's implementers did not open) — this is ledger.mjs's
|
|
427
|
+
// memberRowIndex() fallback specifically, which gates on the member being
|
|
428
|
+
// PR-bound before it ever reaches this fallback. deriveRun below applies the
|
|
429
|
+
// same row-key fallback to every row's own bookkeeping unconditionally,
|
|
430
|
+
// signal or not; only memberRowIndex()'s caller already knows it holds a
|
|
431
|
+
// PR-bound member. Ticket and PR numbers share GitHub's one number
|
|
432
|
+
// space, so a ticket's key never names an open PR.
|
|
434
433
|
export function rowNums(text) {
|
|
435
434
|
const key = text.split(/\s/)[0];
|
|
436
435
|
const keyNum = /^#[0-9]+$/.test(key) ? Number(key.slice(1)) : null;
|
|
437
|
-
|
|
438
|
-
return { keyNum, pr: mention ? Number(mention[1]) : keyNum };
|
|
436
|
+
return { keyNum, pr: rowPr(text) ?? keyNum };
|
|
439
437
|
}
|
|
440
438
|
|
|
441
439
|
// PRs whose finisher attempts are read off the ledger while the open list shows
|
|
@@ -81,6 +81,28 @@ export function memberTokens(text) {
|
|
|
81
81
|
return text.split(/\s+/).filter(Boolean).map(parseToken).filter(Boolean);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
// `PR#<n>` as a word of a row's text, `PR #<n>` too.
|
|
85
|
+
const PR_MENTION = /\bPR\s*#(\d+)\b/;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The PR a row's text is about, or null when it names none of its own — the
|
|
89
|
+
* one reading of it every ledger reader keys PR state by. A row carrying an
|
|
90
|
+
* `impl-` token, live, settled or malformed, is its first well-formed settled
|
|
91
|
+
* `impl-<N>=PR#<M>` token's PR in row order, and no PR while it has none: a
|
|
92
|
+
* `PR#` mention in its prose, an `→ PR#M` arrow included, never decides it,
|
|
93
|
+
* wherever it sits. A row with no `impl-` token is its first `PR#<n>`
|
|
94
|
+
* mention's. Falling back to the row's `#<n>` key is each caller's own.
|
|
95
|
+
*/
|
|
96
|
+
export function rowPr(text) {
|
|
97
|
+
const impls = memberTokens(text).filter((t) => t.family === "impl");
|
|
98
|
+
if (impls.length > 0) {
|
|
99
|
+
const settled = impls.find((t) => t.error === null && t.outcome?.startsWith("PR#"));
|
|
100
|
+
return settled ? Number(settled.outcome.slice("PR#".length)) : null;
|
|
101
|
+
}
|
|
102
|
+
const m = PR_MENTION.exec(text);
|
|
103
|
+
return m ? Number(m[1]) : null;
|
|
104
|
+
}
|
|
105
|
+
|
|
84
106
|
/** The name the next merge bot takes: 1 + the `merge-bot-` entries in
|
|
85
107
|
* `## Dispatched`, settled ones included. One ledger per run, so n restarts
|
|
86
108
|
* at 1 with every run. */
|
package/scripts/ledger.mjs
CHANGED
|
@@ -35,7 +35,7 @@ import { fileURLToPath } from "node:url";
|
|
|
35
35
|
import { spawnSync, execFileSync } from "node:child_process";
|
|
36
36
|
import { makeDie, isFlagLike, hasEqualsForm, isDigits } from "./arg.mjs";
|
|
37
37
|
import { fleetFile, FleetDirUnresolvable } from "./fleet-dir.mjs";
|
|
38
|
-
import { parseMember, parseToken, memberTokens, nextMergeBot, agentDefinition, CELL, tierValues } from "./ledger-grammar.mjs";
|
|
38
|
+
import { parseMember, parseToken, memberTokens, nextMergeBot, agentDefinition, CELL, tierValues, rowPr } from "./ledger-grammar.mjs";
|
|
39
39
|
import { deriveRun, LedgerError, labelOffMember } from "./fleet-tick.mjs";
|
|
40
40
|
import { stateFileIn, readState, assessBeat, stallsAt } from "./fleet-state.mjs";
|
|
41
41
|
|
|
@@ -1584,15 +1584,6 @@ function rowKey(r) {
|
|
|
1584
1584
|
return r.split(/\s/)[0];
|
|
1585
1585
|
}
|
|
1586
1586
|
|
|
1587
|
-
// A row's PR is its first `PR#<n>` mention: the `→ PR#<n>` arrow or the
|
|
1588
|
-
// implementer's settled `impl-<N>=PR#<n>` token, which name the same PR.
|
|
1589
|
-
// compute-board.mjs parseRow() reads the settled token, so the row a
|
|
1590
|
-
// PR-bound member lands on is the card the cockpit shows that PR on.
|
|
1591
|
-
function rowPr(r) {
|
|
1592
|
-
const m = /\bPR\s*#(\d+)\b/.exec(r);
|
|
1593
|
-
return m ? Number(m[1]) : null;
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
1587
|
// Whether a row carries the member's token — live only, settled only, or
|
|
1597
1588
|
// either when `live` is not given.
|
|
1598
1589
|
function carries(row, name, live) {
|
|
@@ -1600,8 +1591,9 @@ function carries(row, name, live) {
|
|
|
1600
1591
|
}
|
|
1601
1592
|
|
|
1602
1593
|
// The row a member's token belongs on: an implementer's is its ticket's row; a
|
|
1603
|
-
// PR-bound member's is the row whose PR is its PR
|
|
1604
|
-
//
|
|
1594
|
+
// PR-bound member's is the row whose PR is its PR — ledger-grammar.mjs's
|
|
1595
|
+
// rowPr(), the reading the tick folds that PR's state by — else one keyed by
|
|
1596
|
+
// that PR's own number (a PR this run's implementers did not open). -1 when there is
|
|
1605
1597
|
// none yet. A merge bot works no ticket and never has one.
|
|
1606
1598
|
function memberRowIndex(member) {
|
|
1607
1599
|
if (member.bound === null) return -1;
|
|
@@ -1876,10 +1868,11 @@ function runSettle() {
|
|
|
1876
1868
|
// Fold that row's tokens onto this one, in order, so later PR-bound writes
|
|
1877
1869
|
// find the one row through rowPr(). Only
|
|
1878
1870
|
// an implementer settles to `PR#M` (ledger-grammar.mjs), and only when the
|
|
1879
|
-
// settling row named NO PR before this write: `rowPr()`
|
|
1880
|
-
//
|
|
1881
|
-
// already named one — this PR via a hand-written `→ PR#M` arrow
|
|
1882
|
-
// different PR from an earlier attempt
|
|
1871
|
+
// settling row named NO PR before this write: `rowPr()` is the tick's
|
|
1872
|
+
// reading of a row's PR too, so a row that
|
|
1873
|
+
// already named one — this PR via a hand-written `→ PR#M` arrow on a row
|
|
1874
|
+
// with no impl token, or a different PR from an earlier attempt's settled
|
|
1875
|
+
// token — would let the fold misattribute
|
|
1883
1876
|
// its content to the wrong PR, or bury the row's own fresher
|
|
1884
1877
|
// `review=`/`reviewed=` state under the folded row's older one (the tick
|
|
1885
1878
|
// reads only the LAST). The candidate row must itself carry a live or
|
|
@@ -58,9 +58,8 @@ import { fileURLToPath } from "node:url";
|
|
|
58
58
|
import { isCLI } from "./is-cli.mjs";
|
|
59
59
|
import { makeDie, defineFlags, isDigits } from "./arg.mjs";
|
|
60
60
|
import { parseTsv as parseMemberTsv } from "./member-outcomes.mjs";
|
|
61
|
-
import { parseMember, parseToken, memberTokens } from "./ledger-grammar.mjs";
|
|
61
|
+
import { parseMember, parseToken, memberTokens, rowPr } from "./ledger-grammar.mjs";
|
|
62
62
|
import { rowText } from "./tier-check.mjs";
|
|
63
|
-
import { PR_MENTION } from "./fleet-tick.mjs";
|
|
64
63
|
|
|
65
64
|
const NAME = "tier-outcomes";
|
|
66
65
|
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
@@ -321,16 +320,16 @@ export function checkRows(rows, memberRows) {
|
|
|
321
320
|
}
|
|
322
321
|
|
|
323
322
|
// The ledger half of `check`: every PR a run-ledger row marks `reviewed=` that
|
|
324
|
-
// has no row here. The row's PR is read the way fleet-tick.mjs reads it —
|
|
325
|
-
//
|
|
323
|
+
// has no row here. The row's PR is read the way fleet-tick.mjs reads it —
|
|
324
|
+
// ledger-grammar.mjs's rowPr(), else the row's own key.
|
|
326
325
|
export function unrecordedReviewedPrs(ledger, rows) {
|
|
327
326
|
const have = new Set(rows.map((r) => r.pr));
|
|
328
327
|
const missing = new Set();
|
|
329
328
|
for (const text of ledger?.rows ?? []) {
|
|
330
329
|
if (!text.split(/\s+/).some((t) => t.startsWith("reviewed="))) continue;
|
|
331
330
|
const key = text.split(/\s/)[0];
|
|
332
|
-
const
|
|
333
|
-
const pr =
|
|
331
|
+
const own = rowPr(text);
|
|
332
|
+
const pr = own !== null ? String(own) : /^#[0-9]+$/.test(key) ? key.slice(1) : null;
|
|
334
333
|
if (pr && !have.has(pr)) missing.add(Number(pr));
|
|
335
334
|
}
|
|
336
335
|
return [...missing].sort((a, b) => a - b);
|
package/scripts/worktree.sh
CHANGED
|
@@ -888,10 +888,28 @@ wt_counts() {
|
|
|
888
888
|
# listing (`$wt_list` empty or unset) skips this question. Counted in shell,
|
|
889
889
|
# line by line, so the question adds no external command whose failure would
|
|
890
890
|
# be a new way for a caller to refuse.
|
|
891
|
+
#
|
|
892
|
+
# Trailing slashes and `/.` components come off $1 first, a lone `/` kept:
|
|
893
|
+
# `[ -L "link/" ]` and `[ -L "link/." ]` follow the link and are false, and
|
|
894
|
+
# `worktree link/` is no listing record, so such a spelling would skip both
|
|
895
|
+
# questions above and pass the `-ef` compare.
|
|
891
896
|
# shellcheck disable=SC2034
|
|
892
897
|
wt_linkage() {
|
|
898
|
+
while :; do
|
|
899
|
+
case $1 in
|
|
900
|
+
?*/) set -- "${1%/}" ;;
|
|
901
|
+
?*/.) set -- "${1%/.}" ;;
|
|
902
|
+
*) break ;;
|
|
903
|
+
esac
|
|
904
|
+
done
|
|
893
905
|
wt_why=
|
|
894
906
|
wt_lk_n=0
|
|
907
|
+
# `git -C ""` reads the cwd's own repository, so an empty path is refused
|
|
908
|
+
# here, named, rather than judged as the cwd.
|
|
909
|
+
if [ -z "$1" ]; then
|
|
910
|
+
wt_why="an empty path names no worktree"
|
|
911
|
+
return 1
|
|
912
|
+
fi
|
|
895
913
|
if [ -n "${wt_list:-}" ]; then
|
|
896
914
|
# Whole records, one per line (`wt_listing` swapped any newline inside a
|
|
897
915
|
# path), so equality against `worktree $1` is the path compare, and a path
|