@feigi/fleet-ctl 3.27.0 → 3.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,7 @@ argument-hint: [pr-number]
13
13
  3. **Run `testCmd` before you commit**, from the worktree, copied verbatim — not a runner you picked. `testCmd` is the command your dispatcher handed you; **standalone, with no dispatcher to hand you one, it is the repo's own test command**, the Test entrypoint in the repo's Recipe cache (`derive-testcmd.sh <repo> test` prints it). Read it off the repo, never invent one: "not a runner you picked" is what this step forbids, and on the standalone path nothing else defines the referent. With no usable Recipe cache (`derive-testcmd.sh` refuses), run the Recipe derivation step first — dispatch a `task` member, agent `fleet-recipe-deriver`, its prompt naming the main checkout's absolute path as `<repo>` and a scratch directory of its own; it proves both commands in a throwaway worktree and writes the cache only on proof, and its `RECIPE NOT PROVEN` is a stop, reported with its reason. Never fall back to a runner of your own choosing. `tests 0` is a FAILED run, not a pass: a glob matching nothing still exits 0. **Zero is not the only no-work count.** A run reporting **0 passes with no failures** skipped everything it collected, and a count **materially below the whole suite** means you ran a partial tree — this suite reported `tests 937` when this line was written, so compare what you get against a full run rather than against zero. The number drifts; that is the safe direction, because a stale one produces a loud false red while its absence produces a silent false green. Red, zero-test, or either no-work count → fix it or move the finding to defer; never commit over it. Then commit and push — `git push origin HEAD:<branch>`, the explicit refspec: this step also runs from a `--detach` worktree (`run-team/SKILL.md`'s worktree-recreation form), where a bare `git push` exits 128 (`fatal: You are not currently on a branch`) and any push whose destination is `HEAD` rather than a full or branch refname (`-u` or not, forced or not) exits 1 (`error: The destination you provided is not a full refname`) — and report the test result alongside the SHA. **Then reconcile the PR body with what you actually did.** It merges into the permanent record and nothing downstream re-derives it: your commit messages are yours to fix and usually get fixed, the body is neither. Removing a change, or reversing one, leaves the body asserting work the diff no longer contains. Measured twice in one run — one body kept asserting a calibration its own fix had just deleted as false, another kept claiming a hunk the fix had removed as "this diff owns it" — both caught by a finisher's reading rather than by any rule, and both would otherwise have merged intact. `gh pr edit <pr> --body-file <path>`, and re-read the body against the final diff rather than against your memory of it. **Never `--no-verify`.** The fleet runs in repos it knows nothing about: it must not assume a pre-commit hook exists, and must never bypass one that does — a hook that fails is a finding to report, not an obstacle. Nothing re-reviews what you commit here, so this run is the only gate between your edit and a merge.
14
14
  4. **Under the fleet, do not hold this wait.** The controller owns a persistent CI Monitor and dispatches a finisher once your report has arrived and CI is green — so push, then report to the controller a **final verdict** (every specialist you dispatched + its outcome + your apply/defer adjudication + the pushed SHA) and stop. A specialist that has neither reported nor been relayed to you is not a verdict line — ask the controller for it by name before ruling; see **Specialists**. The controller keys "review complete" on that verdict, **never on you merely going idle** — a slow specialist can still be running when your turn ends, and finishing off idle-alone ships a premature label (observed: a PR labelled while its contract-test specialist was still running and about to surface a vacuous pin). A turn-based reviewer re-reading `gh pr checks` each idle cycle rebuilds its whole context for nothing the Monitor lacks. **Standalone (no controller): watch** the run until the diff-validating jobs are green (bind via `ci-state.mjs` below); fix a **genuine** failure and repeat from 3. **Staleness is not a failure:** a `rebase-check` red or heavy jobs `skipped` **solely from a non-zero behind-count** never clears by waiting and must not be rebased away here — see **`skipped` is not `passed`** and **Do NOT rebase to label** below for what it looks like and why. Stop watching and go to 6. A turn-based reviewer that "waits for green" on a behind PR stalls forever and ends its turn without labelling. **`ci-state.mjs` returns `verdict: "no-ci"`** → there is no run to watch, so don't: go straight to 6 and let that step's `--declare-no-ci` branch decide.
15
15
  5. File each deferred finding: `gh issue create --label <ready-for-agent|needs-triage>` with the finding, `file:line`, why deferred, `Deferred from PR #<pr> review`, and **the finding's `dimension` in the issue body** — the review returns it on every finding, and a backlog that does not carry it cannot be attributed to the specialist that generated it. **The label follows the finding's state, not this step** — but it is never omitted; an unlabelled issue is invisible to both `candidates.mjs --require-label` and the cockpit's pool query, reachable only by a human. **The bar here is whether the DEFECT is confirmed — never whether the remedy is settled.** Confirmed defect with the remedy still open → `ready-for-agent`, and say in the body that the remedy is open. Torn → `needs-triage`, narrowed: torn means **unsure anything is broken**, not unsure how to fix it. **A finding a refuter CHECKED and did not survive is neither** — it is not a confirmed defect, and you are not unsure whether anything is broken: you measured that nothing is. Refutations go as **one issue per review, titled `PR #<pr> review: the suggestion band, checked`, labelled `wontfix`, and CLOSED** — a run that files them open instead has to be corrected afterwards, as one was on 2026-08-27. Left open they read as queued agent work and rot into filing artifacts; a measured triage pass found a quarter of its `needs-triage` backlog was refuted records, bulk-closable by title shape. Closed is still a durable home — `check` reads the tracker at `--state all`, so a future run re-deriving the finding lands on the evidence rather than re-litigating it. Split the band only where an entry is **not** a refutation: a residual the refuter surfaced, or a finding refused as out of scope and never checked, is real deferred work — and real deferred work earns its own open issue only past a second bar. **Worth a claim: a finding whose own claim is that correct code could be shaped better — style, naming, layout, redundancy, a micro-simplification — never gets its own open issue.** Its only open question is "is this worth doing?", which answers itself under the repriced triage bar: measured 2026-08-15→31, 133 issues were triage-closed `wontfix` in sixteen days, 121 of them review deferrals, mostly this shape. Append it to the same closed record issue under a `Below the claim bar` heading — `file:line`, dimension, the claim, and a re-open trigger per entry. Closed is a durable home for these too: `check` reads `--state all`, so a run re-deriving the finding lands on the record instead of re-filing — and a later review returning the same finding as `survived`, or a maintainer hitting it, is the promotion signal: file it open then, citing the record. **An in-scope rediscovery step 2 applied is that same promotion signal, and it files nothing** — so the record carries no mark unless you write one: run `check` over each finding step 2 applied as well, and where its tracker rows put one on a `Below the claim bar` entry, comment on that record issue, opening `Promoted — applied, not filed`, and name the entry, that its refuter let it through, and the commit carrying the fix. That comment is the promotion mark this path leaves, and it is **not** a cross-reference — measured on this tracker, a comment mints `cross-referenced` on the issue its own text *names*, never on the issue it sits under (a comment citing a second issue landed on that issue's timeline and nowhere else), so the fixed opening is what carries the signal instead. **The bar reads the finding's claim, never its review band** — a finding that alleges wrong behavior, whatever band it sat in, `unverified`-with-crashed-refuters included, is above this bar and files open under the confirmed/torn split, which is why a band cannot carry this decision. Do **not** reach for phase 0's **decided?** test here. That is a *consumption* gate, priced for a seat where implementer divergence costs a claim, a worktree and a dispatch; at filing time divergence costs one PR review the maintainer already runs. Same test, two seats, opposite correct answers — and reading it in this seat took `needs-triage` from 11 to 135 before it was repriced (ruled 2026-08-18). **Dedupe through `~/.fleet/bin/fleet-run ledger.mjs check "<subject>"`, never a bare `gh issue list --search`** — the duplicate class that guard exists to catch was filed from *here*: the ledger row for the finding rediscovered five times in one measured run carries a reviewer's own source tag, `(review-pr-108)`. `check` reads this run's filed list *and* the tracker at `--state all`, so a closed duplicate still counts. Exit **1** is already filed in this run; exit **3** is a clean ledger with matching tracker rows that score against the subject — read the ones it prints and comment on the existing follow-up rather than filing a second issue. **Exit 0 is not automatically "safe to file"**: it covers `clean`, `soft-hit` and `unverified` alike, and an unreachable `gh` degrades to a ledger-only answer that says `TRACKER NOT CHECKED`, so read the stdout `verdict` to tell a tracker that was searched and clean from one nobody read — under `unverified`, search it yourself before filing — or, for the applied-promotion comment above, before treating a tracker nobody could read as a reason to skip it. **`soft-hit` is the answer that costs most to misread**: it means related rows were found and none of them was established as a duplicate — a near-miss above the floor, or tracker rows the scorer rates 0.00 — so read the rows it printed and decide, and never treat that exit 0 as permission. Exit **2** is a usage error, meaning nothing was checked at all: fix the invocation and re-run, never read it as a duplicate. Full exit-code and `verdict` semantics live in `$(~/.fleet/bin/fleet-run --root)/skills/run-team/SKILL.md`'s **Run ledger** section — read them there rather than restating them here. **The guard dedupes, it never drops:** a duplicate becomes a comment on the issue that already covers it, never a dropped finding. **Record every issue you create, at once:** immediately after each `gh issue create`, run `~/.fleet/bin/fleet-run ledger.mjs filed <N> "<subject>"` — `<N>` the number `gh issue create` printed, and **the same subject string you passed to `check`**, so the next `check` for that finding meets it in the filed list instead of scoring a rewording. Without it the guard's ledger half never holds a row, and its exit **1** can never fire. If `filed` fails, retry it once; if it fails again, leave the issue alone — it exists and is correct — and report it as `unrecorded: #N <subject>`, so the controller runs `filed` for it. Report `filed: #N <subject>` for every issue you created — under the fleet, in your report to the controller. **The one window the guard cannot see:** `check` → `gh issue create` → `filed` is three commands, and the ledger's lock covers each alone, so two filers can both read `clean` in the seconds before either records. That gap is accepted, never a reason to skip `filed`. Post the numbers as one PR comment.
16
+ **A duplicate that should hold an open deferral is relabelled up, never down.** Where the guard lands a finding whose home is an open issue on an existing one that is open and labelled `needs-triage` while the finding's state calls for `ready-for-agent` — a defect its refuters confirmed — relabel it with `gh issue edit <N> --remove-label needs-triage --add-label ready-for-agent`, and cite the refuters' verdict in the comment you leave there. Never relabel `ready-for-agent` down to `needs-triage`: a `ready-for-agent` issue already holds a `needs-triage` finding, and a later run's crashed refuters are no reason to send a confirmed defect back to triage. A closed one cannot hold it: file a new open issue citing it, as the promotion rule above does for the closed record.
16
17
  **Name where each deferral went, in the disposition record.** Every entry you defer carries `issue`: the number of the issue you filed it to, commented it onto, or appended it to — the closed `PR #<pr> review: the suggestion band, checked` record included. An in-scope `suggestion`'s entry — an `unverified` finding with `refutersDispatched` of zero — also carries `verdictPath`, applied or deferred: the absolute path of a file holding its refuter's verdict as JSON, `{"refuted": <boolean>, "reason": "<string>"}`, under your own `<scratch>/pr<N>/fix-XXXXXXXX/<finding>/` run root. `dispositions-check.mjs` reads each named issue back through `gh issue view --json labels,state,title` and each verdict file off disk; a mismatch names the row of its filing table the entry broke, so move or relabel that filing to the home the row names and run the check again. With `gh` unreachable, or an issue it cannot read, that filing goes unchecked: with nothing else broken the verdict is `unchecked` — never `ok`, and it exits 1 — so run the check again once `gh` answers.
17
18
  6. Diff-check green (run-bound per `ci-state.mjs`; under staleness see **`skipped` is not `passed`** for what the label then rests on) **and** deferrals filed **and** the PR carrying exactly one release label (`patch`/`minor`/`major`, counting only those three; **required on every PR** — `release-label.yml` auto-adds `patch` when none is present and hard-fails on more than one, so this never needs to check whether the repo defines the gate at all, and `gh label list` settles nothing here any more) **and** `dispositions-check.mjs --member fix-pr-<pr> --scratch <scratch>` run over your own record exiting 0 (standalone that is yours to run, from the worktree, after step 2 writes `<scratch>/dispositions-<pr>.json`; it reads the review file beside it, which you write yourself from the findings step 1 collected, in the shape **The review result file** describes — `pr`, `head`, `snapshot`, `counts` and the `survived`, `refuted` and `unverified` buckets; standalone you pass `--no-ledger`, so it writes no token and the exit status is the verdict — a `.fleet/ledger.md` the repository already holds is a previous run's, and without the flag it exits 2 for a ledger with no row for you; under the fleet `ledger.mjs dispatch` has already refused a finisher without it) → `gh pr edit <pr> --add-label ready-to-merge`. Do not merge. A non-zero dispositions exit halts you before the label, and you report the violations it printed. Zero or more than one release label halts you before the label, naming which you found — a timed-out `gh pr create` opens the PR with its `--label` unapplied and no exit status to react to, and nothing after this step re-derives the release label. **Under the fleet a finisher does this** — a fresh small agent the controller dispatches (after your final verdict, never on your bare idle). Gate it on the diff-validating **`check`** job, **not** on `ci-state --quiet` exit 0, which a behind PR — the normal case once any sibling merges — never reaches: a `rebase-check` red or heavy jobs `skipped` off the behind-count hold it short of full green, so an exit-0 gate strands every behind PR unlabelled. Label when `check` is present and green **and no heavy job (the diff-validating suites — *not* the `rebase-check` currency gate) is in `failure`** — a `skipped` heavy job is behind-count staleness and fine — **solely** off that count, which is a condition to establish rather than infer, see the five-condition note in `$(~/.fleet/bin/fleet-run --root)/skills/run-team/SKILL.md`'s fix-applier prompt block. A `failure` is the diff's own fault and blocks the label, else a genuinely broken PR gets labelled off a green `check` and burns a merge-bot rebase+CI cycle before the failure resurfaces. Read per-job state for this: run `ci-state.mjs` **without** `--quiet`, or read its `jobs` — the `--quiet` payload drops the per-job `jobs`/`missing` and the `dropped` list, keeping `reasons` (which still distinguishes `is failure` from `is skipped`). You reach step 6 yourself only when green is already in hand at push time.
18
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.27.0",
3
+ "version": "3.28.0",
4
4
  "description": "Agent fleet: run-team controller, merge bot, PR reviewer, and the ticket pipeline they share",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -79,24 +79,28 @@
79
79
  // mismatch names the row the entry broke:
80
80
  //
81
81
  // row finding home
82
- // 1 survived, deferred for an allowed reason other open, ready-for-agent
83
- // than false-rationale
84
- // 2 survived, deferred false-rationale closed suggestion-band record
82
+ // 1 survived, in scope, deferred for an allowed open, ready-for-agent
83
+ // reason other than false-rationale
84
+ // 2 survived, in scope, deferred false-rationale closed suggestion-band record
85
85
  // 3 unverified, its refuters dispatched and crashed open, needs-triage
86
86
  // 4 in-scope suggestion, its refuter refuted it closed suggestion-band record
87
87
  // 5 in-scope suggestion, its refuter let it survive applied, or deferred as row 1
88
88
  // 6 out-of-scope suggestion alleging wrong behavior open, needs-triage
89
89
  // 7 claimKind shape, below the claim bar closed suggestion-band record
90
+ // 8 survived, out of scope, whatever its reason open, ready-for-agent
90
91
  //
91
92
  // Row 4 outranks row 7, and row 7 every other row. A row-5 deferral is
92
93
  // held to row 1's reasons: one of ALLOWED_DEFER other than
93
- // false-rationale, `remedy-outside-diff` under the rule above. An open
94
- // home carries its row's triage label and not the other one; the closed
95
- // suggestion-band record is the closed issue titled `PR #<pr> review: the
96
- // suggestion band, checked`, labelled `wontfix`. `claimKind` is trusted:
97
- // the script never judges whether a claim is about shape. A survived
98
- // finding out of scope has no row, and its deferral's filing is not
99
- // judged.
94
+ // false-rationale, `remedy-outside-diff` under the rule above. A row-8
95
+ // deferral is held to no reason and escalates nothing, whatever its
96
+ // severity. An open home carries exactly one triage label, its row's or
97
+ // a stronger one: `ready-for-agent` answers a `needs-triage` row, and
98
+ // `needs-triage` never answers a `ready-for-agent` one. The closed
99
+ // suggestion-band record is the closed issue titled `PR #<pr> review:
100
+ // the suggestion band, checked`, labelled `wontfix`. `claimKind` is
101
+ // trusted: the script never judges whether a claim is about shape. A
102
+ // deferral no row holds — a reversed refutation whose claim is about
103
+ // behavior — is a mismatch naming no filing-table row.
100
104
  //
101
105
  // Unchecked: `gh` unreachable, or a deferral's issue it cannot read, leaves
102
106
  // that entry's filing unjudged. With no rule broken and nothing escalated the
@@ -151,29 +155,47 @@ const BUCKETS = [...COVERED, "refuted"];
151
155
  const ENUMS = { scope: ["in", "out"], claimKind: ["behavior", "shape"], disposition: ["apply", "defer"] };
152
156
 
153
157
  // The filing table: a deferral's home by its finding's state. `record` is the
154
- // closed suggestion-band record; `open` the triage label an open home carries.
158
+ // closed suggestion-band record; `open` the weakest triage label an open home may carry.
155
159
  export const FILING_ROWS = Object.freeze({
156
- 1: { finding: "a survived finding deferred for an allowed reason other than false-rationale", open: "ready-for-agent" },
157
- 2: { finding: "a survived finding deferred false-rationale", record: true },
160
+ 1: { finding: "an in-scope survived finding deferred for an allowed reason other than false-rationale", open: "ready-for-agent" },
161
+ 2: { finding: "an in-scope survived finding deferred false-rationale", record: true },
158
162
  3: { finding: "an unverified finding whose refuters crashed", open: "needs-triage" },
159
163
  4: { finding: "an in-scope suggestion its refuter refuted", record: true },
160
164
  5: { finding: "an in-scope suggestion its refuter let survive", open: "ready-for-agent" },
161
165
  6: { finding: "an out-of-scope suggestion alleging wrong behavior", open: "needs-triage" },
162
166
  7: { finding: "a finding whose claim is about shape, below the claim bar", record: true },
167
+ 8: { finding: "an out-of-scope survived finding, whatever its reason", open: "ready-for-agent" },
163
168
  });
169
+ // Strongest first: an open home may carry a label above its row's, never below.
164
170
  const TRIAGE_LABELS = ["ready-for-agent", "needs-triage"];
165
171
  // Row 1's reasons, which a row-5 deferral is held to.
166
172
  const ROW_1_DEFER = ALLOWED_DEFER.filter((r) => r !== "false-rationale");
167
173
  export const recordTitle = (pr) => `PR #${pr} review: the suggestion band, checked`;
168
174
 
169
175
  function homeText(row, pr) {
170
- return row.record ? `the closed "${recordTitle(pr)}" issue, labelled wontfix` : `an open issue labelled ${row.open}`;
176
+ if (row.record) return `the closed "${recordTitle(pr)}" issue, labelled wontfix`;
177
+ return `an open issue labelled ${TRIAGE_LABELS.slice(0, TRIAGE_LABELS.indexOf(row.open) + 1).reverse().join(" or ")}`;
171
178
  }
172
179
 
173
180
  // Whether an issue `{state, title, labels}` is `row`'s home on PR `pr`.
174
181
  function homeHolds(row, { state, title, labels }, pr) {
175
182
  if (row.record) return state === "CLOSED" && title.trim() === recordTitle(pr) && labels.includes("wontfix");
176
- return state === "OPEN" && labels.includes(row.open) && !labels.includes(TRIAGE_LABELS.find((l) => l !== row.open));
183
+ const triage = labels.filter((l) => TRIAGE_LABELS.includes(l));
184
+ return state === "OPEN" && triage.length === 1 && TRIAGE_LABELS.indexOf(triage[0]) <= TRIAGE_LABELS.indexOf(row.open);
185
+ }
186
+
187
+ // The row a deferral's finding state puts it on, by precedence, or null when
188
+ // no row holds it: only a reversed refutation (the refuted bucket) whose claim
189
+ // is not about shape. `refuted` is an in-scope suggestion's refuter verdict,
190
+ // null for any other finding.
191
+ function filingRow({ bucket, inScope, crashed, refuted, shape, reason }) {
192
+ if (refuted === true) return 4;
193
+ if (shape) return 7;
194
+ if (bucket === "refuted") return null;
195
+ if (crashed) return 3;
196
+ if (!inScope) return bucket === "survived" ? 8 : 6;
197
+ if (bucket === "unverified") return 5;
198
+ return reason === "false-rationale" ? 2 : 1;
177
199
  }
178
200
 
179
201
  function describeIssue({ state, title, labels }) {
@@ -402,15 +424,14 @@ export function checkDispositions({ review, record, recordProblem = null, touche
402
424
  at(bucket, index, `malformed entry — ${errors.join("; ")}`);
403
425
  return;
404
426
  }
405
- if (bucket === "refuted") {
406
- if (!e.reason?.trim()) at(bucket, index, "a reversed refutation names its evidence in reason, and this one names none");
427
+ if (bucket === "refuted" && !e.reason?.trim()) {
428
+ at(bucket, index, "a reversed refutation names its evidence in reason, and this one names none");
407
429
  return;
408
430
  }
409
- if (bucket === "survived" && e.disposition !== "defer") return;
431
+ if (bucket !== "unverified" && e.disposition !== "defer") return;
410
432
  const finding = review[bucket][index];
411
433
  const presumed = presumedInScope(finding, touched, roots);
412
434
  const inScope = presumed !== null || e.scope === "in";
413
- if (bucket === "survived" && !inScope) return;
414
435
  const why = presumed === null ? "its entry declares scope in" : `${presumed}, so it is in scope whatever its entry declares`;
415
436
  const crashed = bucket === "unverified" && finding.refutersDispatched > 0;
416
437
  // An in-scope suggestion's refuter verdict is the evidence a refuter ran.
@@ -435,8 +456,9 @@ export function checkDispositions({ review, record, recordProblem = null, touche
435
456
  const shape = e.claimKind === "shape";
436
457
  // A finding that stands defers only for a reason: an in-scope survivor
437
458
  // for one of ALLOWED_DEFER, a suggestion its refuter let through for one
438
- // of row 1's — unless row 7 takes it.
439
- if (bucket === "survived" || (refuted === false && !shape)) {
459
+ // of row 1's — unless row 7 takes it. An out-of-scope survivor defers for
460
+ // any reason, and escalates nothing.
461
+ if ((bucket === "survived" && inScope) || (refuted === false && !shape)) {
440
462
  const allowed = bucket === "survived" ? ALLOWED_DEFER : ROW_1_DEFER;
441
463
  if (!allowed.includes(e.reason)) {
442
464
  const reason = e.reason === undefined || e.reason === "" ? "no reason" : `reason ${JSON.stringify(e.reason)}`;
@@ -460,9 +482,11 @@ export function checkDispositions({ review, record, recordProblem = null, touche
460
482
  }
461
483
  }
462
484
  // Where the deferral must be filed. `claimKind` is trusted, never judged.
463
- const rowNo = refuted === true ? 4 : shape ? 7
464
- : bucket === "survived" ? (e.reason === "false-rationale" ? 2 : 1)
465
- : crashed ? 3 : inScope ? 5 : 6;
485
+ const rowNo = filingRow({ bucket, inScope, crashed, refuted, shape, reason: e.reason });
486
+ if (rowNo === null) {
487
+ at(bucket, index, `no filing-table row holds a deferred ${bucket} finding, scope ${inScope ? "in" : "out"}, claimKind ${e.claimKind} — the table names no home for it`);
488
+ return;
489
+ }
466
490
  const row = FILING_ROWS[rowNo];
467
491
  const { pr, issue: readIssue } = filingOf();
468
492
  if (e.issue === undefined) {