@feigi/fleet-ctl 3.24.1 → 3.24.3
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/arg.mjs +59 -56
- package/scripts/board.html +22 -22
- package/scripts/board.mjs +143 -145
- package/scripts/candidates.mjs +48 -48
- package/scripts/compute-board.mjs +39 -38
- package/scripts/git-env.mjs +21 -22
- package/scripts/repo-root.mjs +35 -32
package/scripts/candidates.mjs
CHANGED
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
// reduction that did not apply, a capped result). 3 = the query succeeded,
|
|
20
20
|
// returned at least one row, and every row was removed by the to-spec
|
|
21
21
|
// filter — distinct from 1 so a caller such as run-team's phase 0 can say
|
|
22
|
-
// "the only labeled items are specs, run to-tickets" instead of "no work"
|
|
23
|
-
//
|
|
22
|
+
// "the only labeled items are specs, run to-tickets" instead of "no work".
|
|
23
|
+
// Exit 3 describes the FINAL query attempt only — with
|
|
24
24
|
// `--allow-fallback`, a labeled all-specs pass that falls back to a
|
|
25
25
|
// genuinely empty unfiltered pass is exit 1, not 3; the drop count is never
|
|
26
26
|
// carried across the two attempts.
|
|
@@ -32,7 +32,7 @@ import { makeDie, makeArg, makeHas } from "./arg.mjs";
|
|
|
32
32
|
const NAME = "candidates";
|
|
33
33
|
|
|
34
34
|
// die()/arg()/has() shared with the other fleet scripts — see arg.mjs for
|
|
35
|
-
// the fail-open
|
|
35
|
+
// the fail-open and pipe-safety rationale.
|
|
36
36
|
// No caller of THIS file is a hand-typed CLI. Two are markdown re-read by a
|
|
37
37
|
// model each run (next-ticket/SKILL.md, run-team/SKILL.md), which is why a
|
|
38
38
|
// malformed invocation is more plausible here than the shared guard's shape
|
|
@@ -54,14 +54,14 @@ const limit = Number(arg("limit") ?? 500);
|
|
|
54
54
|
if (!Number.isInteger(limit) || limit < 1) die(`--limit must be a positive integer, got '${arg("limit")}'`);
|
|
55
55
|
|
|
56
56
|
// The accepted flag set, declared once, and the only check on flag NAMES.
|
|
57
|
-
//
|
|
57
|
+
// Before this check, an unrecognised flag was ignored, so
|
|
58
58
|
// `--label ready-for-agent` — the spelling run-team's own phase 0 rule carried
|
|
59
59
|
// — ran the UNFILTERED query at exit 0, the widening `--require-label` exists
|
|
60
60
|
// to prevent.
|
|
61
61
|
//
|
|
62
62
|
// Runs BELOW the value guards, deliberately: where both would refuse — notably
|
|
63
63
|
// `--require-label` and `--limit` given with no value — arriving second leaves
|
|
64
|
-
// the refusal to
|
|
64
|
+
// the refusal to arg()'s wording above rather than Node's. Nothing above emits
|
|
65
65
|
// output or runs a query, so refusing this late is still refusing before gh.
|
|
66
66
|
//
|
|
67
67
|
// The catch is unconditional, and THAT is the guard. Testing `e.code` for
|
|
@@ -96,8 +96,9 @@ try {
|
|
|
96
96
|
|
|
97
97
|
if (allowFallback && !requireLabel) die("--allow-fallback is meaningless without --require-label");
|
|
98
98
|
|
|
99
|
-
//
|
|
100
|
-
// label is QUOTED into the search term, so a `"`
|
|
99
|
+
// The label quoting's other half, and the half that quoting (query() below)
|
|
100
|
+
// newly makes possible: the label is QUOTED into the search term, so a `"`
|
|
101
|
+
// inside it closes that quote
|
|
101
102
|
// early and the remainder becomes free text — the same misparse, with the fix
|
|
102
103
|
// applied. A `\` breaks the same term from the other side, because GitHub
|
|
103
104
|
// DOES honour `\"` as an escaped quote inside a qualifier: measured against
|
|
@@ -108,7 +109,7 @@ if (allowFallback && !requireLabel) die("--allow-fallback is meaningless without
|
|
|
108
109
|
// having eaten the closing quote and swallowed the whole following qualifier.
|
|
109
110
|
// Doubling does not escape it. Here the label term is LAST, so a trailing
|
|
110
111
|
// backslash leaves its value unterminated and the query answers zero rows at
|
|
111
|
-
// HTTP 200, no error —
|
|
112
|
+
// HTTP 200, no error — the unquoted label's silent empty, with the fix applied. Neither
|
|
112
113
|
// character can be represented, so refuse both at exit 2 ("the query broke")
|
|
113
114
|
// rather than send a query whose empty answer would read as exit 1.
|
|
114
115
|
if (requireLabel && /["\\]/.test(requireLabel)) die(`--require-label cannot contain a double quote or a backslash, got '${requireLabel}'`);
|
|
@@ -117,7 +118,7 @@ if (requireLabel && /["\\]/.test(requireLabel)) die(`--require-label cannot cont
|
|
|
117
118
|
// GitHub's search has no `-label:"wayfinder:*"` — and none is quoted despite
|
|
118
119
|
// the colon each value carries. Measured 2026-09-08 against feigi/fleet-plugin:
|
|
119
120
|
// negating `wayfinder:map` alone excludes exactly one more issue than the
|
|
120
|
-
// unfiltered open count
|
|
121
|
+
// unfiltered open count — a colon inside a label
|
|
121
122
|
// value is parsed as part of the label, not as a delimiter that ends it early
|
|
122
123
|
// and spills the remainder into free text, the failure mode `label:"…"`
|
|
123
124
|
// quoting exists for a SPACE (see `query()`'s comment below). Stated as a
|
|
@@ -133,7 +134,7 @@ const EXCLUDE =
|
|
|
133
134
|
"-label:in-progress -label:onhold -label:wontfix -label:needs-triage -label:needs-info -label:wayfinder:map -label:wayfinder:research -label:wayfinder:prototype -label:wayfinder:grilling -label:wayfinder:task";
|
|
134
135
|
// `d` walks the body line by line rather than one regex over the whole
|
|
135
136
|
// string, because RE2 (gojq's engine — gh applies `--jq` with gojq, not the
|
|
136
|
-
// system jq this file's own tests stub
|
|
137
|
+
// system jq this file's own tests stub) has no lookahead, so
|
|
137
138
|
// "capture every ref up to the next heading" cannot be expressed as a single
|
|
138
139
|
// pattern. A heading line (`^#{1,6}[ \t]`) toggles a running "inside a
|
|
139
140
|
// blocking section" flag on when its text DECLARES one: any of the verb
|
|
@@ -144,15 +145,15 @@ const EXCLUDE =
|
|
|
144
145
|
// `:` aside. The noun form cannot be given the verb forms' tolerance:
|
|
145
146
|
// `## Dependency injection` is an ordinary section title in a code repo, and
|
|
146
147
|
// arming on it would turn every `#N` in its bullets into a blocker the body
|
|
147
|
-
// never declared
|
|
148
|
-
//
|
|
148
|
+
// never declared. The noun form cannot be dropped either: a real brief headed
|
|
149
|
+
// its section with it, and a gate naming the verbs alone opened nothing there.
|
|
149
150
|
//
|
|
150
151
|
// Either form may carry EMPHASIS, which markdown puts outside the words:
|
|
151
152
|
// `## **Dependencies**` names a dependency exactly as `## Dependencies` does,
|
|
152
153
|
// and read without the `\*` runs it armed no section at all, so every ref its
|
|
153
|
-
// bullets declared was dropped — exit 0, nothing on stderr,
|
|
154
|
+
// bullets declared was dropped — exit 0, nothing on stderr, a silent
|
|
154
155
|
// wrong admission reached through this gate rather than through the inline
|
|
155
|
-
// label separator
|
|
156
|
+
// label separator. The runs are
|
|
156
157
|
// `\**` rather than `\*{0,2}` because `*`, `**` and `***` are all emphasis a
|
|
157
158
|
// heading is written with, and the noun form needs one on EACH side of its
|
|
158
159
|
// optional colon: markdown closes the bold before it (`**Dependencies**:`)
|
|
@@ -162,8 +163,7 @@ const EXCLUDE =
|
|
|
162
163
|
// the runs go AROUND it, and they match asterisks ONLY, so
|
|
163
164
|
// `## **Dependency injection**` still arms nothing. Widen either run to a
|
|
164
165
|
// general wildcard and that heading arms, which is the whole distinction the
|
|
165
|
-
// anchor exists to hold;
|
|
166
|
-
// engines.
|
|
166
|
+
// anchor exists to hold; a test pins both directions, on both engines.
|
|
167
167
|
//
|
|
168
168
|
// `after` is an inline label only, because `## After the migration` is
|
|
169
169
|
// ordinary narrative and arming on it invents a blocker, while a heading that
|
|
@@ -182,7 +182,7 @@ const EXCLUDE =
|
|
|
182
182
|
// match. The separator is a combined `[\s*]*` run rather than asterisk groups
|
|
183
183
|
// flanking the colon: those groups sat ahead of the separating whitespace, so
|
|
184
184
|
// they matched only asterisks flush against the phrase, and a space before the
|
|
185
|
-
// bold — where markdown actually puts it — dropped the ref
|
|
185
|
+
// bold — where markdown actually puts it — dropped the ref. Both passes
|
|
186
186
|
// are strictly line-local, which the removed `(?:depends on|…)\s+#\d+` regex
|
|
187
187
|
// was not: its `\s+` crossed newlines, so a
|
|
188
188
|
// phrase ending one line with its ref opening the next was collected and now
|
|
@@ -192,20 +192,20 @@ const EXCLUDE =
|
|
|
192
192
|
// restriction above closes. A ref elsewhere in the body — not under a
|
|
193
193
|
// heading section, not after a label — is not collected: neither pass reaches
|
|
194
194
|
// it. Verified against real gojq (`go install
|
|
195
|
-
// github.com/itchyny/gojq/cmd/gojq@v0.12.19`) on every form in
|
|
196
|
-
//
|
|
195
|
+
// github.com/itchyny/gojq/cmd/gojq@v0.12.19`) on every form in the
|
|
196
|
+
// suite's dependency-forms fixtures, not only the system jq the
|
|
197
197
|
// STUB there execs. The engines now agree on every one of those forms,
|
|
198
198
|
// including the ones that used to split. The separator is `[\t \p{Zs}*]*`
|
|
199
199
|
// and not `[\s*]*`, so `Blocked by:<U+00A0>#12` collects `[12]` under BOTH
|
|
200
200
|
// engines where it used to collect `[12]` under Oniguruma and `[]` under RE2
|
|
201
|
-
// —
|
|
201
|
+
// — the ref is ruled a real blocker, because GFM renders that line as
|
|
202
202
|
// `Blocked by: #12` and autolinks the ref, so a reader sees a dependency and
|
|
203
203
|
// an admission gate must not miss one. Since no fixture splits any more, the
|
|
204
204
|
// gated tests can no longer identify their engine by disagreement: the STUB
|
|
205
205
|
// records which binary it executed and they assert that recording is gojq.
|
|
206
206
|
// The per-position rulings are set out above the JQ declaration below.
|
|
207
207
|
//
|
|
208
|
-
// `depmiss` is the diagnostic half
|
|
208
|
+
// `depmiss` is the diagnostic half, and it is deliberately LOOSER
|
|
209
209
|
// than the gate: any heading MENTIONING the concept that the gate did not
|
|
210
210
|
// arm. The gate's own pattern is named `armed` and both halves call it, so
|
|
211
211
|
// "did not arm" is the exact complement of what opened the section rather
|
|
@@ -234,10 +234,10 @@ const EXCLUDE =
|
|
|
234
234
|
// because the only whitespace that would disturb the line this prints is the
|
|
235
235
|
// CR of a CRLF body (what GitHub's web textarea writes), and a regex there
|
|
236
236
|
// would buy cosmetics at the price of one more regex position to rule on and
|
|
237
|
-
// keep portable
|
|
238
|
-
// at the `JSON.stringify` below, because this is a stderr signal and
|
|
239
|
-
//
|
|
240
|
-
// ENGINE-PORTABLE CLASSES
|
|
237
|
+
// keep portable. `dh` never reaches stdout: the payload is stripped of it
|
|
238
|
+
// at the `JSON.stringify` below, because this is a stderr signal and a
|
|
239
|
+
// payload field is ruled out of scope.
|
|
240
|
+
// ENGINE-PORTABLE CLASSES. The program below contains no `\\s`, `\\d` or
|
|
241
241
|
// `\\b`: every position spells an explicit class. It has to, because the suite
|
|
242
242
|
// applies this expression with system jq (Oniguruma, all three Unicode-aware)
|
|
243
243
|
// while gh applies it with its embedded gojq (Go RE2, where `\\s` is
|
|
@@ -267,7 +267,7 @@ const EXCLUDE =
|
|
|
267
267
|
// Unlike `armed`/`depmiss` above, this one also has to recognize a
|
|
268
268
|
// BARE marker-only heading — no title text follows, so `[ \t]` alone
|
|
269
269
|
// never matches it, and the old open section wrongly kept collecting
|
|
270
|
-
// refs past it (
|
|
270
|
+
// refs past it (over-collection). GFM still renders a bare `##`
|
|
271
271
|
// as a real (empty) `<h2>`, so it must still close the section: `$`
|
|
272
272
|
// admits end-of-line, `\r?` admits the same position just before a
|
|
273
273
|
// CRLF line's trailing `\r` (the one `split("\n")` leaves behind).
|
|
@@ -307,18 +307,18 @@ const EXCLUDE =
|
|
|
307
307
|
// escaping below — jq's `\\p{Zs}` is `\\\\p{Zs}` in this JS source string.
|
|
308
308
|
//
|
|
309
309
|
// Measured over 24 fixtures on jq-1.7.1-apple and gojq 0.12.19: zero splits.
|
|
310
|
-
//
|
|
310
|
+
// The suite pins the rows that used to split, on both engines, and
|
|
311
311
|
// proves which engine each gated test actually reached.
|
|
312
312
|
//
|
|
313
|
-
// NATIVE EDGES
|
|
313
|
+
// NATIVE EDGES. `d` is the UNION of the body scan above and the
|
|
314
314
|
// numbers on the issue's native "blocked by" edges, which ride the same
|
|
315
|
-
// query as gh's `blockedBy` field — no extra round trip, the cost
|
|
316
|
-
// deferred
|
|
315
|
+
// query as gh's `blockedBy` field — no extra round trip, the cost they were
|
|
316
|
+
// once deferred on — merged and sorted by the final `unique`. Union, not
|
|
317
317
|
// replacement: to-tickets still writes blockers only as body text, and a
|
|
318
318
|
// hand-written body can name a blocker nobody wired as an edge, so dropping
|
|
319
319
|
// the scan would silently un-block both. The edges close the opposite miss:
|
|
320
|
-
//
|
|
321
|
-
// cross, and only
|
|
320
|
+
// a body can chain its blocker as `**#N**` behind a parenthetical the scan
|
|
321
|
+
// cannot cross, and then only the native edge carries it. `d` stays RAW — a closed
|
|
322
322
|
// blocker's number is kept although the edge carries its state, exactly as
|
|
323
323
|
// the scan keeps one, because the consumers (run-team / next-ticket step 2)
|
|
324
324
|
// judge openness and a `d` whose two halves meant different things would
|
|
@@ -389,7 +389,7 @@ const JQ =
|
|
|
389
389
|
|
|
390
390
|
function query(label) {
|
|
391
391
|
// The label is a VALUE in GitHub's query language, not part of its syntax,
|
|
392
|
-
// so it is quoted rather than interpolated raw
|
|
392
|
+
// so it is quoted rather than interpolated raw. Unquoted, a value
|
|
393
393
|
// ends at the FIRST SPACE and every word after it becomes a free-text term
|
|
394
394
|
// instead — measured 2026-08-17, `label:ready-for-agent candidates` returns
|
|
395
395
|
// strictly fewer issues here than `label:ready-for-agent`, and on
|
|
@@ -398,7 +398,7 @@ function query(label) {
|
|
|
398
398
|
// the narrowed result as the label's own answer, and an empty one as exit 1,
|
|
399
399
|
// "the query worked and there is no work" — against a queue that is not
|
|
400
400
|
// empty. Reachable wherever a repo remapped its triage labels, which
|
|
401
|
-
//
|
|
401
|
+
// a per-repo triage-label mapping exists to invite. Stated as relationships
|
|
402
402
|
// rather than counts on purpose: the queue churns hourly, so a pinned digit
|
|
403
403
|
// is wrong within a day and reads as the fix having regressed.
|
|
404
404
|
//
|
|
@@ -511,7 +511,7 @@ function refuseIfCapped(rows, description) {
|
|
|
511
511
|
// worth a fence parser: every drop is logged by number, so a false positive is
|
|
512
512
|
// loud rather than silent.
|
|
513
513
|
//
|
|
514
|
-
//
|
|
514
|
+
// Two shapes the predicate leaves undecided by accident, now decided.
|
|
515
515
|
// Depth is `#{2,6}`, not `##` — two or more `#`, not exactly two, and capped
|
|
516
516
|
// where CommonMark caps an ATX heading, same as `depnums`' own `#{1,6}` above:
|
|
517
517
|
// a line of seven `#` is not a heading and must not read as the signature.
|
|
@@ -526,7 +526,7 @@ function refuseIfCapped(rows, description) {
|
|
|
526
526
|
// tagged). The separator between marker and text is `[ \t]+` — horizontal
|
|
527
527
|
// whitespace only, not `\s+` — so a heading can never span a line break: a
|
|
528
528
|
// body whose line is exactly `##` with `User Stories` starting the next
|
|
529
|
-
// line no longer reads as the same heading. That is also
|
|
529
|
+
// line no longer reads as the same heading. That is also the ruling for
|
|
530
530
|
// this position, on GFM's own rule: only a space or a tab opens a heading, so
|
|
531
531
|
// `##<U+00A0>User Stories` renders as a PARAGRAPH and is not a spec at all.
|
|
532
532
|
//
|
|
@@ -538,7 +538,7 @@ function refuseIfCapped(rows, description) {
|
|
|
538
538
|
// the `\r` of a CRLF body — what GitHub's web textarea writes — and leak that
|
|
539
539
|
// spec silently. It is spelled out rather than left as `\s*` because `\s` is
|
|
540
540
|
// the one construct here whose meaning changes with the engine (Oniguruma
|
|
541
|
-
// reads it Unicode-aware, RE2 as `[\t\n\f\r ]`), and
|
|
541
|
+
// reads it Unicode-aware, RE2 as `[\t\n\f\r ]`), and the position is ruled
|
|
542
542
|
// by what GFM renders: `## User Stories` padded with U+00A0, EM SPACE or
|
|
543
543
|
// IDEOGRAPHIC SPACE are all real `<h2>`s, so all three are still to-spec specs
|
|
544
544
|
// and all three are dropped. `\p{Zs}` is exactly "renders as a blank" and both
|
|
@@ -548,8 +548,8 @@ function refuseIfCapped(rows, description) {
|
|
|
548
548
|
// is not dropped. Before the ruling this position diverged — a U+00A0-padded
|
|
549
549
|
// heading was a spec under the system jq the suite execs and NOT one under the
|
|
550
550
|
// gojq gh applies, so in production dropSpecs never fired and the spec shipped
|
|
551
|
-
// as a claimable ticket. Pinned against real gojq
|
|
552
|
-
// which
|
|
551
|
+
// as a claimable ticket. Pinned against real gojq by a test that also pins
|
|
552
|
+
// which engine it reached.
|
|
553
553
|
//
|
|
554
554
|
// This is the ONLY line of defence — nothing downstream catches a spec. A
|
|
555
555
|
// leaked one is decided and needs no human hands, so it passes both of phase
|
|
@@ -561,7 +561,7 @@ function refuseIfCapped(rows, description) {
|
|
|
561
561
|
// unfiltered query is a SUPERSET of the labeled one, and every spec dropped in
|
|
562
562
|
// pass 1 is dropped again in pass 2. Unattributed, that reads as the same spec
|
|
563
563
|
// counted twice; named, a reader can tell "2 drops, 1 spec, seen both passes"
|
|
564
|
-
// from "2 drops, 2 specs" at a glance. Deliberately not deduplicated
|
|
564
|
+
// from "2 drops, 2 specs" at a glance. Deliberately not deduplicated.
|
|
565
565
|
function dropSpecs(rows, pass) {
|
|
566
566
|
const kept = [];
|
|
567
567
|
for (const { spec, ...rest } of rows) {
|
|
@@ -582,13 +582,13 @@ refuseIfCapped(rows, requireLabel ? ` with label:${requireLabel}` : "");
|
|
|
582
582
|
// After refuseIfCapped, never before: filtering first can shrink the array below
|
|
583
583
|
// `limit` and the cap check would stop seeing a truncated list. Before the
|
|
584
584
|
// emptiness test below, never after: a queue whose every row was filtered out
|
|
585
|
-
// IS an empty queue
|
|
586
|
-
// one, for a caller reading only the exit code, is
|
|
585
|
+
// IS an empty queue. Telling that case apart from a genuinely empty
|
|
586
|
+
// one, for a caller reading only the exit code, is exit 3's job — set at
|
|
587
587
|
// the foot of this file, which is what the raw count below is captured for.
|
|
588
588
|
// Raw count captured just before the filter that can empty `rows` out, so
|
|
589
589
|
// `allFilteredOut` below can tell "nothing came back" from "rows came back
|
|
590
590
|
// and the filter ate them all". Reassigned wholesale in the fallback branch,
|
|
591
|
-
// never OR'd/summed with pass 1's value —
|
|
591
|
+
// never OR'd/summed with pass 1's value — exit 3's edge case is exactly a pass 1
|
|
592
592
|
// all-filtered (raw>0) whose fallback pass is genuinely empty (raw=0), which
|
|
593
593
|
// must read as the fallback's own facts (exit 1), not a merge of the two.
|
|
594
594
|
const rawCount1 = rows.length;
|
|
@@ -614,7 +614,7 @@ if (rows.length === 0 && allowFallback && requireLabel) {
|
|
|
614
614
|
// next-ticket step 2), not here, and to-tickets publishes chains blockers-first
|
|
615
615
|
// so lower numbers are the blockers anyway. `d` covers every body form
|
|
616
616
|
// to-tickets publishes — heading + list, bold/inline label, the original bare
|
|
617
|
-
// phrasings —
|
|
617
|
+
// phrasings — and GitHub's native blocked-by edges too, so
|
|
618
618
|
// a chain wired only as edges reaches this sort with its blockers in `d`.
|
|
619
619
|
// Native sub-issue links are still not read: parent/child is hierarchy, not
|
|
620
620
|
// blocking, so a blocker recorded only as one reaches it with none.
|
|
@@ -622,7 +622,7 @@ rows.sort((a, b) => a.n - b.n);
|
|
|
622
622
|
|
|
623
623
|
for (const r of rows) {
|
|
624
624
|
console.error(` #${r.n} [${r.l.join(",")}] ${r.t}${r.d.length ? ` deps:${r.d.join(";")}` : ""}`);
|
|
625
|
-
//
|
|
625
|
+
// A SECOND line, never a field on the row above: that row's format is
|
|
626
626
|
// what phase 0 reads and it stays byte-identical, `deps:` suppressed on an
|
|
627
627
|
// empty list and all. Indented under the row it belongs to, and repeating
|
|
628
628
|
// `#N` so a reader who greps the wording still gets the candidate with it.
|
|
@@ -650,8 +650,8 @@ for (const r of rows) {
|
|
|
650
650
|
//
|
|
651
651
|
// `dh` is dropped here rather than never collected: the heading text exists
|
|
652
652
|
// only inside gh's process, where the reduction runs, so the only way to it is
|
|
653
|
-
// a field on the row — and
|
|
654
|
-
// stderr signal being the whole of what
|
|
653
|
+
// a field on the row — and a payload field is ruled out of scope, the
|
|
654
|
+
// stderr signal being the whole of what this diagnostic asks for. Here, and not in
|
|
655
655
|
// `dropSpecs`' destructure where the row's other stderr-only field (`spec`)
|
|
656
656
|
// leaves the payload: that runs BEFORE the per-candidate lines above, which
|
|
657
657
|
// are what `dh` is for. A replacer, not a rebuilt array: it drops the key
|
|
@@ -662,7 +662,7 @@ console.log(JSON.stringify(rows, (k, v) => (k === "dh" ? undefined : v)));
|
|
|
662
662
|
|
|
663
663
|
// Exit 1 for a successful query with no survivors, exit 3 when those zero
|
|
664
664
|
// survivors are the filter's doing rather than the query's — see the
|
|
665
|
-
// exit-code contract in the file header
|
|
665
|
+
// exit-code contract in the file header. `allFilteredOut` already
|
|
666
666
|
// describes only the final attempt (see above), so no further branching on
|
|
667
667
|
// requireLabel/allowFallback is needed here.
|
|
668
668
|
//
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Pure board-model builder. No I/O and no clock read — `now` is passed in, so
|
|
2
2
|
// dwell/staleness is deterministic and unit-testable. board.mjs does the gh/
|
|
3
3
|
// ledger I/O and calls computeBoard(); every stage-derivation and flag decision
|
|
4
|
-
// lives here and is exercised by
|
|
4
|
+
// lives here and is exercised by its unit tests (`node --test`).
|
|
5
5
|
//
|
|
6
|
-
//
|
|
6
|
+
// The THREE imports this module takes, all pure ones.
|
|
7
7
|
// fleet-state.mjs owns the heartbeat's `beat` key, and the rule for reading
|
|
8
8
|
// that key travels with it rather than being copied here. That module's own
|
|
9
9
|
// I/O (its path probe, its file read) is never called from this file; only
|
|
@@ -16,26 +16,27 @@
|
|
|
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
18
|
// fleet-tick.mjs owns a row's PR reading, PR_MENTION, and a row with no impl
|
|
19
|
-
// token is read through it (
|
|
20
|
-
// the same PR for the same text, for a row that
|
|
19
|
+
// token is read through it (see the paragraph below on a row with no `impl`
|
|
20
|
+
// token) so both readers name the same PR for the same text, for a row that
|
|
21
|
+
// carries a PR-bound signal —
|
|
21
22
|
// an unsignaled row (no mention, no PR-bound member, no review=/reviewed=)
|
|
22
23
|
// still gets pr: null here while fleet-tick.mjs's own row-key fallback keys
|
|
23
|
-
// it to its ticket number regardless; see the
|
|
24
|
+
// it to its ticket number regardless; see the same paragraph below. The
|
|
24
25
|
// regex is all this file takes from it: the tick's I/O and main() never run
|
|
25
26
|
// here, main() being guarded on argv[1].
|
|
26
27
|
import { assessBeat, isStalled, stallReport } from "./fleet-state.mjs";
|
|
27
28
|
import { parseToken, HALT_CAUSES } from "./ledger-grammar.mjs";
|
|
28
29
|
import { PR_MENTION, REVIEWED, latestFinisherAttempts } from "./fleet-tick.mjs";
|
|
29
30
|
|
|
30
|
-
// A ledger row is freeform, controller-authored text. Two
|
|
31
|
-
//
|
|
32
|
-
//
|
|
31
|
+
// A ledger row is freeform, controller-authored text. Two example shapes:
|
|
32
|
+
// #<n> impl-<n>=PR#<m> → PR#<m> → MERGED 73b356de
|
|
33
|
+
// #<n> impl-<n>=PR#<m> → PR#<m> · fix-pr-<m> · ruled:6-applies · held-behind:#<k>
|
|
33
34
|
// Extract by token, never by position — the controller reorders and appends
|
|
34
35
|
// tokens freely. Unknown text is ignored, never fatal.
|
|
35
36
|
//
|
|
36
|
-
// Member tokens are ledger-grammar.mjs's
|
|
37
|
+
// Member tokens are ledger-grammar.mjs's. On a row that has one, the
|
|
37
38
|
// row's latest `impl` attempt decides the card — the greatest retry suffix,
|
|
38
|
-
// wherever it sits (
|
|
39
|
+
// wherever it sits (laterAttempt below): live → IMPLEMENTING, `=PR#M`
|
|
39
40
|
// → that PR decides, `=released`/`=bailed` → no card of
|
|
40
41
|
// the row's own (the POOL loop shows the ticket if it is still
|
|
41
42
|
// `ready-for-agent`), `=killed`/`=tier-mismatch` → IMPLEMENTING with that
|
|
@@ -46,7 +47,7 @@ import { PR_MENTION, REVIEWED, latestFinisherAttempts } from "./fleet-tick.mjs";
|
|
|
46
47
|
// nothing enforces that order, so on such a row the arrow is never a value
|
|
47
48
|
// either reader may rely on.
|
|
48
49
|
//
|
|
49
|
-
//
|
|
50
|
+
// A row with no `impl` token at all has no outcome to
|
|
50
51
|
// read, so it takes the tick's reading. `ledger.mjs dispatch <pr> fix-pr-<pr>` /
|
|
51
52
|
// `finisher-pr-<pr>` appends `#<pr> <member>` for a PR this run's
|
|
52
53
|
// implementers did not open. Once such a row carries a PR-bound signal — a
|
|
@@ -57,7 +58,7 @@ import { PR_MENTION, REVIEWED, latestFinisherAttempts } from "./fleet-tick.mjs";
|
|
|
57
58
|
// A member settled anywhere on the row is settled — a bare copy beside
|
|
58
59
|
// `<member>=<outcome>` is what a whole-line `row` rewrite leaves.
|
|
59
60
|
//
|
|
60
|
-
//
|
|
61
|
+
// A PR whose latest finisher attempt settled `halted:<cause>` carries
|
|
61
62
|
// that outcome as a severity-4 flag while the PR sits in REVIEW. The halt is
|
|
62
63
|
// the finisher working correctly — it refused to label — so the PR has no
|
|
63
64
|
// `ready-to-merge` until the controller resolves the cause; the flag is what
|
|
@@ -66,7 +67,7 @@ import { PR_MENTION, REVIEWED, latestFinisherAttempts } from "./fleet-tick.mjs";
|
|
|
66
67
|
// `## Dispatched` tokens): a live `-b` after the halt clears it, and a later
|
|
67
68
|
// attempt settled anywhere replaces it.
|
|
68
69
|
//
|
|
69
|
-
//
|
|
70
|
+
// A PR whose finisher settled `labelled` while the open list shows no
|
|
70
71
|
// `ready-to-merge` on it carries a severity-4 `unlabelled` flag in REVIEW —
|
|
71
72
|
// fleet-tick.mjs's own reading (unlabelledFinishers: the latest attempt since
|
|
72
73
|
// the last `label-off=`), off the same `## Dispatched` and row tokens the tick
|
|
@@ -80,12 +81,12 @@ import { PR_MENTION, REVIEWED, latestFinisherAttempts } from "./fleet-tick.mjs";
|
|
|
80
81
|
// dispatches nothing for these; the flag is what puts the PR in front of a
|
|
81
82
|
// human. The names are not the bare `killed` flag, which is the implementer's.
|
|
82
83
|
//
|
|
83
|
-
// A PR's review is not a member
|
|
84
|
+
// A PR's review is not a member: `review=wf:<runId>` is a Workflow
|
|
84
85
|
// with nobody to name, while `review=member:<name>` and
|
|
85
86
|
// `review=fallback:<name>` name a runner member, live until the token is
|
|
86
87
|
// settled `=failed` or a later `reviewed=` records its result.
|
|
87
88
|
//
|
|
88
|
-
//
|
|
89
|
+
// A `review=` token puts the PR under review only while
|
|
89
90
|
// it is live. A settled `review=…=failed` is a dead review and the PR is owed
|
|
90
91
|
// one again, as run-team SKILL.md defines review-due and as fleet-tick.mjs's
|
|
91
92
|
// `reviewedAny` reads the token: the PR is owed none while the row carries
|
|
@@ -105,7 +106,7 @@ const PREMISE = /\bbehind-(pr|issue):#?([^\s,;]+)/g;
|
|
|
105
106
|
// what each kind means and how `=failed` settles it.
|
|
106
107
|
const REVIEW = /^review=(wf|member|fallback):([^=\s]+?)(=failed)?$/;
|
|
107
108
|
|
|
108
|
-
//
|
|
109
|
+
// Which of two well-formed impl tokens is the later attempt for THIS
|
|
109
110
|
// row's ticket. A token whose number matches the row's own ticket always
|
|
110
111
|
// outranks one that does not: a retry suffix only orders attempts on ONE
|
|
111
112
|
// number (ledger-grammar.mjs's MEMBER regex comment — "Attempts on one
|
|
@@ -158,8 +159,8 @@ export function parseRow(row) {
|
|
|
158
159
|
const finishers = []; // well-formed finisher tokens, for the row's PR below
|
|
159
160
|
let anyImpl = false;
|
|
160
161
|
let prMember = false;
|
|
161
|
-
let review = false; // any review= token: a PR-bound signal
|
|
162
|
-
let reviewLive = false; // one not settled `=failed
|
|
162
|
+
let review = false; // any review= token: a PR-bound signal on a row with no impl token
|
|
163
|
+
let reviewLive = false; // one not settled `=failed`: a live review
|
|
163
164
|
let reviewed = false;
|
|
164
165
|
let reviewedHead = null;
|
|
165
166
|
let runners = [];
|
|
@@ -194,7 +195,7 @@ export function parseRow(row) {
|
|
|
194
195
|
}
|
|
195
196
|
} else if (tok.startsWith("reviewed=")) {
|
|
196
197
|
reviewed = true;
|
|
197
|
-
//
|
|
198
|
+
// The head that review actually read — the cockpit's own copy
|
|
198
199
|
// of fleet-tick.mjs's `reviewedHead`, needed below to tell a past-pin
|
|
199
200
|
// halt already answered by this review apart from one still owed a
|
|
200
201
|
// fresh one.
|
|
@@ -208,7 +209,7 @@ export function parseRow(row) {
|
|
|
208
209
|
const implOutcome = lastImpl ? (implOutcomes.get(lastImpl.name) ?? null) : null;
|
|
209
210
|
const prM = implOutcome && /^PR#(\d+)$/.exec(implOutcome);
|
|
210
211
|
let pr = prM ? Number(prM[1]) : null;
|
|
211
|
-
//
|
|
212
|
+
// A row with NO impl token — a malformed one still
|
|
212
213
|
// counts, since that row's key is a ticket — is keyed, once THIS row
|
|
213
214
|
// carries a PR-bound signal, the way fleet-tick.mjs's PR_MENTION-then-
|
|
214
215
|
// row-key logic would: its first PR_MENTION (itself a signal), else the
|
|
@@ -249,7 +250,7 @@ export function parseRow(row) {
|
|
|
249
250
|
// released or bailed implementer: the ticket went back to the tracker, and the
|
|
250
251
|
// POOL loop shows it if it is still `ready-for-agent`). An Exclusion is POOL.
|
|
251
252
|
// MERGED is an explicit `MERGED <sha>` token or, failing one, `prState.merged`
|
|
252
|
-
// — gh's answer for a row PR absent from the open list, or
|
|
253
|
+
// — gh's answer for a row PR absent from the open list, or a
|
|
253
254
|
// carry-forward of the previous board's MERGED for that SAME PR on that
|
|
254
255
|
// ticket: MERGED is terminal, so a merged PR never reopens regardless of
|
|
255
256
|
// what this run's merged read says — but a ticket retried under a NEW PR
|
|
@@ -276,7 +277,7 @@ export const STALE_MS = {
|
|
|
276
277
|
READY: 15 * 60 * 1000,
|
|
277
278
|
};
|
|
278
279
|
|
|
279
|
-
// An Exclusion's badges are its premises, `excluded
|
|
280
|
+
// An Exclusion's badges are its premises, `excluded:#<n>` for a number and
|
|
280
281
|
// `excluded:<branch>` for a branch name, and nothing else: it is supply, so no
|
|
281
282
|
// dwell clock and no cause applies. isBadge() keeps them out of `attention`.
|
|
282
283
|
export function deriveFlags(parsed, ctx) {
|
|
@@ -352,7 +353,7 @@ function splitNumbered(line) {
|
|
|
352
353
|
return m ? { issue: Number(m[1]), subject: m[2] } : { issue: null, subject: line };
|
|
353
354
|
}
|
|
354
355
|
|
|
355
|
-
// The stall surface, or null when there is nothing to say.
|
|
356
|
+
// The stall surface, or null when there is nothing to say.
|
|
356
357
|
//
|
|
357
358
|
// The two facts the report needs beyond the mark itself — what is claimed and
|
|
358
359
|
// whether the pool still has supply — are read off THIS model rather than
|
|
@@ -386,7 +387,7 @@ function stall(beat, ticked, tickets, pool, { ledgerOk, poolOk }, now) {
|
|
|
386
387
|
return { ...verdict, claimed, supply, text: stallReport(verdict, { claimed, supply }) };
|
|
387
388
|
}
|
|
388
389
|
|
|
389
|
-
//
|
|
390
|
+
// Which of gather()'s `gh ... list` reads came back exactly as long as
|
|
390
391
|
// its own `--limit` — and so may have been cut there, gh saying nothing — as
|
|
391
392
|
// one rendered line, or null when neither did. The pool's count carries its
|
|
392
393
|
// own `n+` besides (computeBoard below); this line is for what a count cannot
|
|
@@ -401,7 +402,7 @@ function capNotice({ poolCapped, prsCapped }) {
|
|
|
401
402
|
return parts.length ? parts.join("; ") : null;
|
|
402
403
|
}
|
|
403
404
|
|
|
404
|
-
//
|
|
405
|
+
// The previous board already showed this SAME PR MERGED on this
|
|
405
406
|
// ticket. MERGED is terminal, so that verdict stands whatever this run's
|
|
406
407
|
// merged read says. Keyed on the PR, not just the ticket: a ticket retried
|
|
407
408
|
// under a NEW PR after its earlier one merged carries no MERGED verdict
|
|
@@ -412,7 +413,7 @@ function carriedMerged(prevTicket, p) {
|
|
|
412
413
|
return prevTicket?.column === "MERGED" && prevTicket.pr === p.pr;
|
|
413
414
|
}
|
|
414
415
|
|
|
415
|
-
//
|
|
416
|
+
// The row PRs whose merged status gather() has to ask gh about this
|
|
416
417
|
// tick — exactly those computeBoard() would consult `merged` for and cannot
|
|
417
418
|
// already place: a row PR absent from the open list `prs`, on a row that is
|
|
418
419
|
// not an Exclusion (always POOL), carries no `MERGED <sha>` token, has a PR
|
|
@@ -441,15 +442,15 @@ export function mergedReadPrs({ ledger, prs, prev }) {
|
|
|
441
442
|
return [...need].sort((a, b) => a - b);
|
|
442
443
|
}
|
|
443
444
|
|
|
444
|
-
// `merged`
|
|
445
|
+
// `merged` is gh's list of merged PR numbers, consulted only for a row
|
|
445
446
|
// PR absent from the open list `prs`; absent means none known, and a PR in
|
|
446
447
|
// neither list (closed unmerged, or a failed read) keeps REVIEW — unless
|
|
447
|
-
//
|
|
448
|
+
// carriedMerged() holds for it, in which case it stays MERGED
|
|
448
449
|
// whether this run's merged read failed outright or simply succeeded
|
|
449
450
|
// without listing it. A PR that IS in the open list is never eligible for
|
|
450
451
|
// this carry-forward — only the "absent from both `prs` and (maybe)
|
|
451
452
|
// `merged`" branch below ever consults it. gather() asks gh only about
|
|
452
|
-
// mergedReadPrs()'s set
|
|
453
|
+
// mergedReadPrs()'s set, so `merged` never lists more than that.
|
|
453
454
|
export function computeBoard(inputs) {
|
|
454
455
|
const { ledger, issues, prs, ci, prev, now } = inputs;
|
|
455
456
|
const prByNum = new Map(prs.map((p) => [p.number, p]));
|
|
@@ -492,8 +493,8 @@ export function computeBoard(inputs) {
|
|
|
492
493
|
});
|
|
493
494
|
}
|
|
494
495
|
|
|
495
|
-
// A wayfinder:* ticket is documentation-only regardless of its triage role
|
|
496
|
-
//
|
|
496
|
+
// A wayfinder:* ticket is documentation-only regardless of its triage role:
|
|
497
|
+
// candidates.mjs's dispatch scan never surfaces one even carrying
|
|
497
498
|
// `ready-for-agent`, so this POOL column must not either, or an
|
|
498
499
|
// undispatchable ticket inflates the operator's read of available work.
|
|
499
500
|
// Filtered HERE rather than out of gather()'s gh query: `issues` also feeds
|
|
@@ -515,8 +516,8 @@ export function computeBoard(inputs) {
|
|
|
515
516
|
.sort((a, b) => severity(b.flags) - severity(a.flags));
|
|
516
517
|
|
|
517
518
|
// Backlog is a PR nobody has reviewed and nobody is reviewing: no live
|
|
518
|
-
// `review=` (
|
|
519
|
-
// `reviewed=`, and no live fix-applier or finisher on the row — or
|
|
519
|
+
// `review=` (a settled `=failed` one is no review), no
|
|
520
|
+
// `reviewed=`, and no live fix-applier or finisher on the row — or
|
|
520
521
|
// a returned review whose finisher halted `past-pin` against a head it
|
|
521
522
|
// never read: owed again until the head catches up to what `reviewed=`
|
|
522
523
|
// recorded, the same rule fleet-tick.mjs's reviewDue reads off headRefOid
|
|
@@ -530,7 +531,7 @@ export function computeBoard(inputs) {
|
|
|
530
531
|
return t.column === "REVIEW" && !p.underReview && (!p.reviewed || pastPinBacklog(p));
|
|
531
532
|
}).length;
|
|
532
533
|
const cardsInPool = tickets.filter((t) => t.column === "POOL").length;
|
|
533
|
-
//
|
|
534
|
+
// A capped pool read makes this count a floor, and it says so the way
|
|
534
535
|
// fleet-tick.mjs's claimed count does — `"100+"`, never a bare 100 that
|
|
535
536
|
// reads as exact. stall() below receives the same value, so the stall line
|
|
536
537
|
// and the footer cannot disagree about it.
|
|
@@ -541,13 +542,13 @@ export function computeBoard(inputs) {
|
|
|
541
542
|
interval: inputs.interval ?? 15,
|
|
542
543
|
repo: inputs.repo ?? null,
|
|
543
544
|
repoUrl: inputs.repoUrl ?? null,
|
|
544
|
-
//
|
|
545
|
+
// Which workspace this board describes and which port served it.
|
|
545
546
|
// Pass-through, exactly like repo/repoUrl above and for the same reason —
|
|
546
547
|
// resolveCockpitInstance() answers both at the gather boundary, and this
|
|
547
548
|
// module reads no cwd, no git and no socket, so it cannot re-derive either
|
|
548
549
|
// and must not try. Defaulted to null rather than left undefined: a
|
|
549
550
|
// missing key and a null one are the same value to a reader in JS but not
|
|
550
|
-
// in the JSON on disk, and
|
|
551
|
+
// in the JSON on disk, and the launch handshake reads `workspace` off
|
|
551
552
|
// that JSON — a dropped key would make every board anonymous to it.
|
|
552
553
|
workspace: inputs.workspace ?? null,
|
|
553
554
|
port: inputs.port ?? null,
|
|
@@ -557,7 +558,7 @@ export function computeBoard(inputs) {
|
|
|
557
558
|
filed: (ledger.filed || []).map(splitNumbered),
|
|
558
559
|
// Not derivable from anything else in this model: a ledger that was never
|
|
559
560
|
// read, one read empty, and one whose payload would not parse all reduce to
|
|
560
|
-
// the same empty lists
|
|
561
|
+
// the same empty lists. gather() is the
|
|
561
562
|
// only caller that can tell them apart, so it says so and this carries the
|
|
562
563
|
// answer to the page. Defaulted rather than required — every other caller
|
|
563
564
|
// of computeBoard builds its inputs by hand and means a ledger it read.
|
|
@@ -569,7 +570,7 @@ export function computeBoard(inputs) {
|
|
|
569
570
|
// which would read as "this run was free", and shows the error, which is
|
|
570
571
|
// a bug the operator has to act on.
|
|
571
572
|
spend: inputs.spend ?? null,
|
|
572
|
-
//
|
|
573
|
+
// Telemetry beside `spend`, and under the same rule: a liveness
|
|
573
574
|
// input can only ever POPULATE or OMIT this field, and nothing above it
|
|
574
575
|
// reads `inputs.beat` — no column, no flag, no dwell clock, no attention
|
|
575
576
|
// row. A dead controller does not move a ticket; it means nobody is
|