@feigi/fleet-ctl 3.154.6 → 3.154.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.154.6",
3
+ "version": "3.154.8",
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": {
@@ -1996,36 +1996,35 @@ function dispositionsRefusal(pr, review) {
1996
1996
  return null;
1997
1997
  }
1998
1998
 
1999
- // PR `pr`'s ruling, as `{tickets, ruling, tsv, refusal}`: `tickets` the
2000
- // tickets a settled `impl-<N>=PR#<pr>` token on a row names — the token
2001
- // tier-outcomes.mjs `append` resolves a ticket from — and `ruling` the PR's
2002
- // latest row in `tsv`, the main checkout's tier-outcomes.tsv, or null when
2003
- // `refusal` is set or `tickets` is empty. `refusal` says why the
1999
+ // PR `pr`'s ruling gate, as `{tickets, refusal}`: `tickets` the tickets a
2000
+ // settled `impl-<N>=PR#<pr>` token on a row names — the token
2001
+ // tier-outcomes.mjs `append` resolves a ticket from. `refusal` says why the
2004
2002
  // finisher waits, or is null when it does not: the PR is an implementer's and
2005
- // the file has no row whose `pr` is it. Any row passes, whatever its date or
2006
- // verdicts, so a replacement finisher is never held once the first passed.
2003
+ // the main checkout's tier-outcomes.tsv has no row whose `pr` is it. Any row
2004
+ // passes, whatever its date or verdicts, so a replacement finisher is never
2005
+ // held once the first passed: no verdict decides the gate.
2007
2006
  // The ledger lives in the main checkout's `.fleet/` (fleet-dir.mjs), so the
2008
2007
  // file is found beside that directory — no git, no gh. A missing file is no
2009
- // row (`append` creates it); one that cannot be read or parsed refuses,
2010
- // naming it, and is never a pass.
2008
+ // row (`append` creates it); one that cannot be read or parsed — a row with a
2009
+ // malformed verdict cell included, which parseTierOutcomes() throws on —
2010
+ // refuses, naming it, and is never a pass.
2011
2011
  // tier-outcomes.mjs is imported here, not at the top: its import graph is
2012
2012
  // several modules no other subcommand loads.
2013
2013
  async function rulingOf(pr) {
2014
2014
  const { parseTierOutcomes, implementerClaims } = await import("./tier-outcomes.mjs");
2015
2015
  const tickets = [...new Set(implementerClaims(data, pr).map((c) => c.ticket))];
2016
- if (tickets.length === 0) return { tickets, ruling: null, refusal: null };
2016
+ if (tickets.length === 0) return { tickets, refusal: null };
2017
2017
  const tsv = join(dirname(dirname(resolve(file))), "docs", "metrics", "tier-outcomes.tsv");
2018
2018
  if (existsSync(tsv)) {
2019
2019
  let rows;
2020
2020
  try {
2021
2021
  rows = parseTierOutcomes(readFileSync(tsv, "utf8"));
2022
2022
  } catch (e) {
2023
- return { tickets, ruling: null, refusal: `cannot read the PR's ruling off ${tsv}: ${e.code ?? e.message} — fix the file, then dispatch the finisher again` };
2023
+ return { tickets, refusal: `cannot read the PR's ruling off ${tsv}: ${e.code ?? e.message} — fix the file, then dispatch the finisher again` };
2024
2024
  }
2025
- const ruling = rows.findLast((r) => r.pr === String(pr));
2026
- if (ruling !== undefined) return { tickets, ruling, tsv, refusal: null };
2025
+ if (rows.some((r) => r.pr === String(pr))) return { tickets, refusal: null };
2027
2026
  }
2028
- return { tickets, ruling: null, refusal: `PR #${pr}, the implementer PR of ${tickets.length === 1 ? "ticket" : "tickets"} ${tickets.map((n) => `#${n}`).join(", ")}, has no ruling — `
2027
+ return { tickets, refusal: `PR #${pr}, the implementer PR of ${tickets.length === 1 ? "ticket" : "tickets"} ${tickets.map((n) => `#${n}`).join(", ")}, has no ruling — `
2029
2028
  + `${tsv} has no row for it; rule its review with \`~/.omp/plugins/node_modules/@feigi/fleet-ctl/scripts/fleet-run tier-outcomes.mjs append ${pr}\`, `
2030
2029
  + "then dispatch the finisher again" };
2031
2030
  }
@@ -2165,43 +2164,34 @@ function checkReaders(where) {
2165
2164
  // read off the PR's closingIssuesReferences in its own repository — a
2166
2165
  // reference into another repository closes no issue here, whatever its
2167
2166
  // number — its head branch, and the titles and labels of the issues they
2168
- // name; its second argument is rulingOf()'s answer, which let the PR through.
2169
- // Check 1, when a settled implementer's token names the PR: each ticket it
2170
- // names is closed by the body when the PR's ruling is closed_own_ticket=yes,
2171
- // and is not when the ruling is no. Check 2, for every PR: no reference may
2172
- // be the suggestion-band record of this PR's review — an issue whose title,
2173
- // trimmed, is recordTitle(), as dispositions-check.mjs finds the record.
2174
- // Check 3, for every PR, Ticketless ones included: no reference besides the
2175
- // PR's own tickets may be a ticket another claim holds, its issue carrying
2176
- // the Label map's in-progress string (claimedElsewhere()). The PR's own
2177
- // tickets are the ones its settled tokens name and, when its head is a claim
2178
- // branch (stranded.mjs's CLAIM_BRANCH), that claim's ticket — a PR a run
2179
- // inherited carries no token, and its own claim holds its ticket until it
2180
- // merges. Returns `{refs, failures}`: the issue numbers the PR closes, its
2181
- // own suggestion-band record aside — that one is a failure here, not a
2182
- // ticket — and one line per failure. A read the checks need dies, naming the
2183
- // read, and writes nothing.
2184
- async function closingRefusals(member, { tickets, ruling, tsv }) {
2167
+ // name; `tickets` are the ones rulingOf() found settled implementer tokens
2168
+ // naming the PR for. Check 1, for every PR: each of its own tickets is among
2169
+ // its closing references, so an implementer PR closes its own ticket whatever
2170
+ // its Ruling, which judges the work as first submitted. Check 2, for every PR:
2171
+ // no reference may be the suggestion-band record of this PR's review — an
2172
+ // issue whose title, trimmed, is recordTitle(), as dispositions-check.mjs
2173
+ // finds the record. Check 3, for every PR, Ticketless ones included: no
2174
+ // reference besides the PR's own tickets may be a ticket another claim holds,
2175
+ // its issue carrying the Label map's in-progress string (claimedElsewhere()).
2176
+ // The PR's own tickets are the ones its settled tokens name and, when its
2177
+ // head is a claim branch (stranded.mjs's CLAIM_BRANCH), that claim's ticket —
2178
+ // a PR a run inherited carries no token, and its own claim holds its ticket
2179
+ // until it merges. Returns `{refs, failures}`: the issue numbers the PR
2180
+ // closes, its own suggestion-band record aside — that one is a failure here,
2181
+ // not a ticket — and one line per failure. A read the checks need dies,
2182
+ // naming the read, and writes nothing.
2183
+ async function closingRefusals(member, tickets) {
2185
2184
  const pr = member.number;
2186
2185
  const where = `dispatch ${member.name}`;
2187
2186
  const { recordTitle } = await import("./dispositions-check.mjs");
2188
2187
  const { CLAIM_BRANCH } = await import("./stranded.mjs");
2189
2188
  const { prViewClosing, issueRead, claimedElsewhere } = checkReaders(where);
2190
2189
  const { view, numbers: refs } = prViewClosing(pr, "closingIssuesReferences,url,headRefName");
2190
+ const claim = CLAIM_BRANCH.exec(view.headRefName);
2191
+ const ownTickets = [...new Set(claim === null ? tickets : [...tickets, Number(claim[1])])];
2191
2192
  const failures = [];
2192
- if (tickets.length > 0) {
2193
- const verdict = ruling.closed_own_ticket;
2194
- if (verdict === "") {
2195
- failures.push(`PR #${pr}'s row in ${tsv} has no closed_own_ticket verdict, so its closing references cannot be checked — set the verdict in that row, then dispatch the finisher again`);
2196
- } else if (verdict === "yes") {
2197
- for (const n of tickets) {
2198
- if (!refs.includes(n)) failures.push(`PR #${pr} does not close #${n}, ruled closed_own_ticket=yes — add "Closes #${n}" to its body (gh pr edit ${pr} --body-file …)`);
2199
- }
2200
- } else {
2201
- for (const n of tickets) {
2202
- if (refs.includes(n)) failures.push(`PR #${pr} closes #${n}, ruled closed_own_ticket=no — rephrase it as "Refs #${n}"`);
2203
- }
2204
- }
2193
+ for (const n of ownTickets) {
2194
+ if (!refs.includes(n)) failures.push(`PR #${pr} does not close #${n}, its own ticket — add "Closes #${n}" to its body (gh pr edit ${pr} --body-file …)`);
2205
2195
  }
2206
2196
  const own = recordTitle(pr);
2207
2197
  // The label names of each issue the PR closes, its own record aside.
@@ -2215,8 +2205,6 @@ async function closingRefusals(member, { tickets, ruling, tsv }) {
2215
2205
  }
2216
2206
  }
2217
2207
  const closed = [...labels.keys()];
2218
- const claim = CLAIM_BRANCH.exec(view.headRefName);
2219
- const ownTickets = claim === null ? tickets : [...tickets, Number(claim[1])];
2220
2208
  for (const n of claimedElsewhere(closed, ownTickets, (m) => labels.get(m))) {
2221
2209
  failures.push(`PR #${pr} closes #${n}, which another claim holds — rephrase it as "Refs #${n}"`);
2222
2210
  }
@@ -2461,11 +2449,12 @@ async function runDispatch() {
2461
2449
  // review file: neither is gated on a verdict. Then an implementer's PR
2462
2450
  // waits on its ruling, its tier-outcomes row, written while the PR is open
2463
2451
  // and its review evidence still in scratch; see rulingOf(). Last, the
2464
- // PR's closing references must match that ruling and exclude its own
2465
- // suggestion-band record, and the PR must carry no `ready-to-merge` and
2466
- // exactly one release label, all read off gh from the ledger's repository; see closingRefusals() and
2467
- // labelRefusal(). Refused here, before anything is written, so no
2468
- // check can be skipped by forgetting to run it.
2452
+ // PR must close its own tickets, whatever its ruling, and no closing
2453
+ // reference may be its own suggestion-band record or a ticket another
2454
+ // claim holds, and the PR must carry no `ready-to-merge` and exactly one
2455
+ // release label, all read off gh from the ledger's repository; see
2456
+ // closingRefusals() and labelRefusal(). Refused here, before anything is
2457
+ // written, so no check can be skipped by forgetting to run it.
2469
2458
  if (member.family === "finisher-pr") {
2470
2459
  const fold = tickFold("conflict hold and dispositions verdict");
2471
2460
  if (fold.conflictHeld.includes(member.number)) {
@@ -2477,7 +2466,7 @@ async function runDispatch() {
2477
2466
  if (disposed !== null) die(`${member.name}: ${disposed} — not dispatching ${member.name}`);
2478
2467
  const ruled = await rulingOf(member.number);
2479
2468
  if (ruled.refusal !== null) die(`${member.name}: ${ruled.refusal} — not dispatching ${member.name}`);
2480
- const closing = await closingRefusals(member, ruled);
2469
+ const closing = await closingRefusals(member, ruled.tickets);
2481
2470
  const labelFailure = labelRefusal(member, ruled.tickets, closing.refs);
2482
2471
  const failures = labelFailure === null ? closing.failures : [...closing.failures, labelFailure];
2483
2472
  if (failures.length > 0) die(`${member.name}: ${failures.join("; ")} — not dispatching ${member.name}`);
@@ -2755,13 +2744,15 @@ function recordFiled(id, subject) {
2755
2744
  // from it, and an outcome that asserts a git or GitHub state has that state
2756
2745
  // checked before anything is written:
2757
2746
  //
2758
- // impl-N=PR#M verify-sha.sh <branch> <head> exits 0; PR M
2747
+ // impl-N=PR#M the report's branch is implementer/N-impl-N; PR M
2759
2748
  // reads OPEN and its closingIssuesReferences in its
2760
2749
  // own repository name N; no other closing
2761
2750
  // reference there is a ticket another claim holds,
2762
2751
  // its issue carrying in-progress; its head branch
2763
- // is implementer/N-impl-N;
2764
- // the Check-step record (below) holds for <head>
2752
+ // is implementer/N-impl-N. Last, and only when
2753
+ // every other check passed: verify-sha.sh <branch>
2754
+ // <head> exits 0, and the Check-step record
2755
+ // (below) holds for <head>
2765
2756
  // impl-N=bailed bailCause is not null; the receipt names it.
2766
2757
  // report-schema.mjs already refuses a bail that
2767
2758
  // names a pr or a head
@@ -2941,9 +2932,15 @@ async function runSettleFromReport() {
2941
2932
  if (report.pr === null) invalid('$.pr: null is not a PR number, with outcome "pr"');
2942
2933
  if (report.head === null) invalid('$.head: null, with outcome "pr"');
2943
2934
  outcome = `PR#${report.pr}`;
2944
- const sha = verifyShaOf(report.branch, report.head);
2945
- check(`verify-sha.sh ${report.branch} ${report.head} exits 0`, sha.status === 0);
2946
- recipeGate(report.head);
2935
+ // The claim's branch comes from the ticket: the Pull claims with member
2936
+ // impl-N, so its branch is implementer/N-impl-N, and close-out releases
2937
+ // impl-N. Never from the settling member's name or its report — a
2938
+ // replacement impl-N-x holds the same claim as impl-N — and the report's
2939
+ // `branch` must name it: the head verified below is then the head of the
2940
+ // branch the PR is checked to be on. This check reads nothing, so a report
2941
+ // naming another branch is refused whatever origin holds.
2942
+ const claimBranch = `implementer/${live.number}-impl-${live.number}`;
2943
+ check(`the report's branch is ${claimBranch} (report: ${report.branch})`, report.branch === claimBranch);
2947
2944
  const { view: pr, numbers } = prViewClosing(report.pr, "state,closingIssuesReferences,url,headRefName");
2948
2945
  check(`PR #${report.pr} reads OPEN`, pr.state === "OPEN");
2949
2946
  check(`PR #${report.pr} closes #${live.number}`, numbers.includes(live.number));
@@ -2956,12 +2953,15 @@ async function runSettleFromReport() {
2956
2953
  const held = claimedElsewhere(numbers, [live.number], issueLabels);
2957
2954
  check(`PR #${report.pr} closes no ticket another claim holds (in-progress: ${held.length === 0 ? "none" : held.map((n) => `#${n}`).join(", ")})`, held.length === 0);
2958
2955
  }
2959
- // The claim's branch comes from the ticket: the Pull claims with member
2960
- // impl-N, so its branch is implementer/N-impl-N, and close-out releases
2961
- // impl-N. Never from the settling member's name or its report: a
2962
- // replacement impl-N-x holds the same claim as impl-N.
2963
- const claimBranch = `implementer/${live.number}-impl-${live.number}`;
2964
2956
  check(`PR #${report.pr}'s head is ${claimBranch} (GitHub: ${pr.headRefName})`, pr.headRefName === claimBranch);
2957
+ // git is read last, and only once every check above has passed: a
2958
+ // branch origin lacks, or a PR that is closed with its branch gone, is
2959
+ // a refusal of the claim, never a verify-sha.sh that could not look.
2960
+ if (checks.every((c) => c.ok)) {
2961
+ const sha = verifyShaOf(claimBranch, report.head);
2962
+ check(`verify-sha.sh ${claimBranch} ${report.head} exits 0`, sha.status === 0);
2963
+ recipeGate(report.head);
2964
+ }
2965
2965
  } else if (report.outcome === "blocked") {
2966
2966
  outcome = "blocked";
2967
2967
  } else {
@@ -561,7 +561,7 @@ Dispatch a finisher only when every test here passes at once — the review retu
561
561
  **This bullet and the one above are a pair, and on a clean PR this one carries the
562
562
  whole route to a finisher**: a `no-op` report satisfies the gate above by
563
563
  itself, so nothing further is owed and no further event is coming.
564
- - **The PR's closing references match its ruling and exclude its own suggestion-band record and every ticket another claim holds** → `ledger.mjs dispatch` refuses the finisher otherwise, naming the PR and ticket: `gh pr edit <M>` fixes the body; dispatch again.
564
+ - **The PR closes its own tickets, and no closing reference is its own suggestion-band record or a ticket another claim holds** → `ledger.mjs dispatch` refuses the finisher otherwise, naming the PR and ticket: `gh pr edit <M>` fixes the body; dispatch again.
565
565
  - **The PR carries exactly one release label, or its repo defines none** → `ledger.mjs dispatch` refuses the finisher otherwise, except a Ticketless PR with none, which `finisher-label.mjs` labels `patch`. Fix them; dispatch again. In full: references/finisher.md.
566
566
  - **`ci-state.mjs --pr <N>` reads `verdict: "no-ci"`** → the CI edge never
567
567
  fires: dispatch the finisher off the reviewer's final verdict the moment it
@@ -13,9 +13,10 @@ literal outcome
13
13
  ---
14
14
  Implement ticket <N>. You are ALREADY in worktree `<abs-path>`, whose PR branch is
15
15
  `<branch>`: commit on it and open your PR from it, even when the ticket below names
16
- another branch; the settle refuses a PR from any other branch. If the ticket names
17
- one, say in the PR body that you used `<branch>`. Label names in this file are roles;
18
- the Label map gives the string to type; a member never derives the map. Close no ticket
16
+ another branch; the settle refuses a PR from any other branch, and a report that names
17
+ one. If the ticket names one, say in the PR body that you used `<branch>`. Label names
18
+ in this file are roles; the Label map gives the string to type; a member never derives
19
+ the map. Close no ticket
19
20
  another claim holds — one whose issue carries the in-progress label — even when the
20
21
  ticket below asks for one PR with it: write `Refs #M` instead; the settle refuses a PR
21
22
  that closes one. Your scratch directory is `<scratch>/impl-<N>/`; outside the worktree,
@@ -72,7 +73,7 @@ maintainer.
72
73
 
73
74
  Your report is a file, `<scratch>/reports/<your name>.json`, `<your name>` the
74
75
  `impl-<N>[-x]` you were dispatched as, in the shape
75
- `~/.omp/plugins/node_modules/@feigi/fleet-ctl/scripts/fleet-run report-schema.mjs print impl` prints. Write it before
76
+ `~/.omp/plugins/node_modules/@feigi/fleet-ctl/scripts/fleet-run report-schema.mjs print impl` prints, with `branch` `<branch>`. Write it before
76
77
  your final message, and send nothing until
77
78
  `~/.omp/plugins/node_modules/@feigi/fleet-ctl/scripts/fleet-run report-schema.mjs validate impl <scratch>/reports/<your name>.json`
78
79
  answers `valid`. Your final message is then one line,
@@ -119,7 +119,7 @@ and will act on it. Relay everything — reversals too — then dispatch.
119
119
  append` command to run. Any row for the PR passes, so a replacement finisher
120
120
  is never held once the first passed; a PR no such token names is not gated.
121
121
  No flag skips it: a PR `append` refuses is fixed on the ledger, as at close-out.
122
- - **The PR's closing references match its ruling and exclude its own suggestion-band record and every ticket another claim holds** → `ledger.mjs dispatch` reads the PR's `closingIssuesReferences` from `gh pr view <M>` before it dispatches any finisher, counting only those in the PR's own repository: a reference into another repository closes none of this repository's tickets, whatever its number. When the ruled row says `closed_own_ticket=yes`, each ticket a settled `impl-<N>=PR#<M>` token names must be closed by the body (`Closes #<N>`); when it says `no`, none may be, and no reference may be the PR's own suggestion-band record. A blank verdict is refused until it is set. Whatever the ruling, and for a Ticketless PR too, no reference besides those tickets may be one another claim holds — one whose issue carries the in-progress label, as the Label map spells it; the same `gh issue view` read of each reference answers it. A refusal names the PR and the ticket, and for a ticket another claim holds says to write `Refs #<M>`. The controller repairs the body itself with `gh pr edit <M> --body-file <file>`, then dispatches the finisher again. A `gh` read that fails refuses the dispatch and writes nothing.
122
+ - **The PR closes its own tickets, and no closing reference is its own suggestion-band record or a ticket another claim holds** → `ledger.mjs dispatch` reads the PR's `closingIssuesReferences` from `gh pr view <M>` before it dispatches any finisher, counting only those in the PR's own repository: a reference into another repository closes none of this repository's tickets, whatever its number. Each of the PR's own tickets must be closed by the body (`Closes #<N>`): the tickets a settled `impl-<N>=PR#<M>` token names, and, when the PR's head is a claim branch (`implementer/<N>-impl-<N>[-<x>]`), that claim's ticket — so a PR a run inherited, which carries no token, is held to it too. The ruling does not decide this: it judges the work as first submitted, and a finding the fix-applier defers is filed on an issue of its own, so an implementer PR closes its own ticket whatever its ruling. No reference may be the PR's own suggestion-band record. For every PR, a Ticketless one too, no reference besides its own tickets may be one another claim holds — one whose issue carries the in-progress label, as the Label map spells it; the same `gh issue view` read of each reference answers it. A refusal names the PR and the ticket, and for a ticket another claim holds says to write `Refs #<M>`. The controller repairs the body itself with `gh pr edit <M> --body-file <file>`, then dispatches the finisher again. A `gh` read that fails refuses the dispatch and writes nothing.
123
123
  - **The PR carries exactly one release label** → `ledger.mjs dispatch` reads the PR's labels from `gh pr view <M>` before it dispatches any finisher, and refuses unless exactly one of `patch`, `minor` and `major` is among them — the count `finisher-label.mjs` makes before it labels. A repository whose label list defines none of the three is not gated. A Ticketless PR with none is not refused: `finisher-label.mjs` adds `patch` to it before its count. Any other PR with none is refused naming the tickets it closes, and any PR with several naming the labels found — the bump, or which label stays, is not picked for the controller. The controller adds or removes the label itself, then dispatches the finisher again. A `gh` read that fails or answers malformed refuses the dispatch, saying the labels could not be read, and writes nothing.
124
124
  - **The PR carries no `ready-to-merge`** → the same `gh pr view <M>` read of the PR's labels answers it, and `ledger.mjs dispatch` refuses any finisher while the label is on, writing nothing and naming `fleet-event.mjs label-off <M>`. A finisher runs on an unlabelled PR: the label a merge bot's `head-moved-after-label` refusal left comes off with its report's settle, and the command takes off any other. A repair finisher's PR lacks the label by definition, so it passes.
125
125