@feigi/fleet-ctl 3.154.7 → 3.155.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.154.7",
3
+ "version": "3.155.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": {
@@ -14,12 +14,21 @@
14
14
  // A TREE, for `evictTrees(root)`, is a directory that holds `.git` at its own
15
15
  // top level and whose `git rev-parse --show-toplevel` resolves, by realpath,
16
16
  // to that same directory. A directory that resolves to an enclosing repository
17
- // — one with no `.git` of its own, or with one git cannot read — is never
18
- // stripped, and git is never asked about a directory with no `.git`. The walk
19
- // goes down from `root` at any depth and never follows a symlink, never enters
20
- // a `.git`, and never enters a path it removes (or, in a dry run, would
21
- // remove) as ignored, so a repository inside `node_modules` goes with that
22
- // directory and is not a tree of its own.
17
+ // is never stripped, and git is never asked about a directory with no `.git`.
18
+ // A directory that holds a `.git` of its own but that git does not resolve to
19
+ // itself — git errors, times out or exits non-zero (an unreadable `.git`, a
20
+ // `.git` with no HEAD, dubious ownership), the realpath comparison throws, or
21
+ // git names another top-level — is SKIPPED: not evicted, and named with its
22
+ // reason in `skipped`, never in `failed`. So is a directory the walk cannot
23
+ // look in for a `.git` (any error but ENOENT or ENOTDIR — a parent with no
24
+ // search permission), or cannot list because of EACCES or EPERM, the root
25
+ // included; a directory with more than one reason is named once, the reasons
26
+ // joined. A directory with no `.git` of its own, and one whose listing fails
27
+ // with ENOENT or ENOTDIR, are neither. The walk goes down from `root` at any
28
+ // depth and never follows a symlink, never enters a `.git`, and never enters a
29
+ // path it removes (or, in a dry run, would remove) as ignored, so a repository
30
+ // inside `node_modules` goes with that directory and is not a tree of its own,
31
+ // nor skipped. A skipped directory does not stop the walk.
23
32
  //
24
33
  // No status check, no mark, no restore: a tree is evicted whatever `git status`
25
34
  // says. A claim tree's status check and its mark are evict.mjs's own.
@@ -87,39 +96,57 @@ export function removeIgnored(tree, ignored) {
87
96
  return errors.length ? `could not remove ${errors.join("; ")}` : null;
88
97
  }
89
98
 
90
- // Whether `dir` is a tree: a `.git` of its own, and git answering for this
91
- // directory rather than for an enclosing repository.
92
- function isTree(dir) {
99
+ // What `dir` is to the walk: `{tree: false}` when it holds no `.git` of its
100
+ // own, `{tree: true}` when it does and git answers for this directory rather
101
+ // than for an enclosing repository, and `{skip}` — why — when it holds one and
102
+ // git does not, or when looking for one fails for any reason but its absence.
103
+ function treeVerdict(dir) {
93
104
  try {
94
105
  lstatSync(join(dir, ".git"));
95
- } catch {
96
- return false;
106
+ } catch (e) {
107
+ if (e.code === "ENOENT" || e.code === "ENOTDIR") return { tree: false };
108
+ return { skip: `cannot look for a .git in it (${e.code ?? e.message})` };
97
109
  }
98
110
  const r = git(dir, ["rev-parse", "--show-toplevel"]);
99
- if (r.error || r.status !== 0) return false;
111
+ if (r.error || r.status !== 0) return { skip: `git rev-parse --show-toplevel did not answer for it (${how(r)})` };
112
+ const top = r.stdout.replace(/\n$/, "");
100
113
  try {
101
- return realpathSync(r.stdout.replace(/\n$/, "")) === realpathSync(dir);
102
- } catch {
103
- return false;
114
+ if (realpathSync(top) === realpathSync(dir)) return { tree: true };
115
+ } catch (e) {
116
+ return { skip: `comparing git's top-level ${top} with it failed (${e.code ?? e.message})` };
104
117
  }
118
+ return { skip: `git resolves it to the top-level ${top}, not to itself` };
105
119
  }
106
120
 
121
+ const byPath = (a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
122
+
107
123
  /**
108
- * Evict every tree under `root`, `root` itself included: `{evicted, failed}`.
124
+ * Evict every tree under `root`, `root` itself included:
125
+ * `{evicted, failed, skipped}`.
109
126
  * `evicted` is `[{path, ignored}]` for each tree that held ignored paths — in a
110
127
  * dry run, what `apply` would remove — and a tree holding none is in neither.
111
128
  * `failed` is `[{path, error}]`: a tree whose ignored paths cannot be listed or
112
129
  * all removed, or a directory whose listing fails for any reason but its being
113
- * gone, not a directory, or unreadable. Best-effort: the walk goes on.
130
+ * gone, not a directory, or unreadable. `skipped` is `[{path, reason}]`: a
131
+ * directory the walk cannot evaluate, and so leaves as it is — one that holds
132
+ * a `.git` of its own which git does not resolve to that directory (rev-parse
133
+ * errors, times out or exits non-zero, the realpath comparison throws, or
134
+ * another top-level), one it cannot look in for a `.git`, and one whose listing
135
+ * fails with EACCES or EPERM, each named once with every reason it has. Never a
136
+ * failure, and never a path inside an ignored directory the walk removes.
137
+ * Best-effort: the walk goes on.
114
138
  */
115
139
  export function evictTrees(root, { apply }) {
116
140
  const evicted = [];
117
141
  const failed = [];
142
+ const skipped = [];
118
143
  const skip = new Set();
119
144
  const stack = [root];
120
145
  while (stack.length) {
121
146
  const dir = stack.pop();
122
- if (isTree(dir)) {
147
+ const verdict = treeVerdict(dir);
148
+ const reasons = verdict.skip === undefined ? [] : [verdict.skip];
149
+ if (verdict.tree) {
123
150
  let ignored;
124
151
  try {
125
152
  ignored = ignoredPaths(dir);
@@ -139,16 +166,18 @@ export function evictTrees(root, { apply }) {
139
166
  entries = readdirSync(dir, { withFileTypes: true });
140
167
  } catch (e) {
141
168
  // A directory the walk cannot list or search holds no tree it can reach:
142
- // skipped, as freshUnder() skips one it cannot read, and never a failure.
143
- if (!["ENOENT", "ENOTDIR", "EACCES", "EPERM"].includes(e.code)) failed.push({ path: dir, error: `cannot list it (${e.code ?? e.message})` });
144
- continue;
169
+ // skipped and named, as freshUnder() skips one it cannot read, and never
170
+ // a failure.
171
+ if (e.code === "EACCES" || e.code === "EPERM") reasons.push(`cannot list it (${e.code})`);
172
+ else if (e.code !== "ENOENT" && e.code !== "ENOTDIR") failed.push({ path: dir, error: `cannot list it (${e.code ?? e.message})` });
145
173
  }
174
+ if (reasons.length > 0) skipped.push({ path: dir, reason: reasons.join("; ") });
175
+ if (entries === undefined) continue;
146
176
  for (const e of entries) {
147
177
  if (e.name === ".git" || !e.isDirectory()) continue;
148
178
  const path = join(dir, e.name);
149
179
  if (!skip.has(path)) stack.push(path);
150
180
  }
151
181
  }
152
- const byPath = (a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
153
- return { evicted: evicted.sort(byPath), failed: failed.sort(byPath) };
182
+ return { evicted: evicted.sort(byPath), failed: failed.sort(byPath), skipped: skipped.sort(byPath) };
154
183
  }
@@ -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}`);
@@ -121,7 +121,12 @@
121
121
  // The sibling pass's kept entries also carry "idle": true when nothing under
122
122
  // the key was found modified within the retention, false otherwise.
123
123
  // `--pr` mode adds `"evicted":[{"path","reason","ignored"}]` after `removed`:
124
- // each tree that held ignored paths, `ignored` naming them.
124
+ // each tree that held ignored paths, `ignored` naming them, and
125
+ // `"skipped":[{"path","reason"}]` after `failed`: each directory in a kept run
126
+ // root that evict-tree.mjs could not evaluate — one with a `.git` git does not
127
+ // resolve to it, one it cannot look in for a `.git`, or one it cannot list for
128
+ // EACCES or EPERM. A skipped directory is never in `failed`, so the snapshot
129
+ // step's marker, which reads `failed`, does not fire for it.
125
130
  // `ledger` is the file read, or null when none was (`--pr` mode, or
126
131
  // `--after-rotate` with no file) — so "never read" stays distinct from "read
127
132
  // and found empty". A dry run prints the same receipt with "applied":false,
@@ -686,8 +691,9 @@ function main() {
686
691
 
687
692
  const now = Date.now();
688
693
  let ledger = null;
689
- // `--pr` mode's evictions; null in every other mode.
690
- let evicted = null;
694
+ // `--pr` mode's evictions and skipped directories, in its receipt only.
695
+ const evicted = [];
696
+ const skipped = [];
691
697
  let remove;
692
698
  let kept = [];
693
699
  const failed = [];
@@ -700,11 +706,11 @@ function main() {
700
706
  failed.push({ path: parent, error: e.message });
701
707
  }
702
708
  // `--pr` mode also evicts the trees in every run root it keeps.
703
- evicted = [];
704
709
  for (const run of kept) {
705
710
  const done = evictTrees(run.path, { apply });
706
711
  for (const t of done.evicted) evicted.push({ path: t.path, reason: "a tree in a kept review run root", ignored: t.ignored });
707
712
  failed.push(...done.failed);
713
+ skipped.push(...done.skipped);
708
714
  }
709
715
  } else if (siblings) {
710
716
  if (apply) {
@@ -759,7 +765,7 @@ function main() {
759
765
  if (error === null) removed.push(entry);
760
766
  else failed.push({ path: entry.path, error });
761
767
  }
762
- const receipt = { applied: apply, ledger, removed, ...(evicted === null ? {} : { evicted }), kept, failed };
768
+ const receipt = { applied: apply, ledger, removed, ...(pr === null ? {} : { evicted }), kept, failed, ...(pr === null ? {} : { skipped }) };
763
769
  writeAll(1, `${JSON.stringify(receipt)}\n`);
764
770
  }
765
771
 
@@ -993,10 +993,11 @@ function standaloneScratchRoot() {
993
993
  * run root of this PR, it evicts every tree in that run root: the snapshot and
994
994
  * each specialist's and refuter's copy lose every path git ignores in them,
995
995
  * and nothing restores them. The run root's other files stay, review.json
996
- * among them. A failed eviction, and a reported run root it refuses to touch,
997
- * are logged; neither, nor a log that throws, changes what the review returns
998
- * or throws. A snapshot step that reported no run root evicts nothing and
999
- * logs nothing.
996
+ * among them. A failed eviction, a directory the eviction skips, and a
997
+ * reported run root it refuses to touch, are logged — a skip worded as a skip,
998
+ * not a failure; none of them, nor a log that throws, changes what the review
999
+ * returns or throws. A snapshot step that reported no run root evicts nothing
1000
+ * and logs nothing.
1000
1001
  */
1001
1002
  export async function runReview(host, args) {
1002
1003
  const run = { partition: null, runRoot: null };
@@ -1041,6 +1042,7 @@ function evictRunRoot(log, { partition, runRoot }) {
1041
1042
  }
1042
1043
  const done = evictTrees(runRoot, { apply: true });
1043
1044
  for (const f of done.failed) say(`eviction at the end of the review failed in ${f.path}: ${f.error}`);
1045
+ for (const s of done.skipped) say(`eviction at the end of the review skipped ${s.path}: ${s.reason}`);
1044
1046
  } catch (e) {
1045
1047
  say(`eviction at the end of the review failed in ${runRoot}: ${e?.message ?? e}`);
1046
1048
  }
@@ -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
@@ -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