@feigi/fleet-ctl 3.141.5 → 3.142.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.141.5",
3
+ "version": "3.142.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": {
@@ -164,7 +164,7 @@ export function reconcile(s) {
164
164
  // The conflict rows only ask the controller to write a record — never to
165
165
  // dispatch — so they stand outside the dispatch hold: the fix-applier a
166
166
  // conflict hold leads to obeys the hold through its own role's row. The
167
- // closed-PR rows dispatch nothing either.
167
+ // fix-failed escalation and the closed-PR rows dispatch nothing either.
168
168
  return [
169
169
  ...dispatchHold(s, [...implementers(s), ...rev.rows]),
170
170
  ...rev.conflictRows,
@@ -450,6 +450,15 @@ function reviewers(s) {
450
450
  conflictRows.push(row(`ESCALATE conflict ${prs(s.conflictEscalate)}`,
451
451
  { extra: "GitHub reads CONFLICTING again after two conflict fix-appliers landed; comment on the PR and flag it for a human — no hold, no fix-applier" }));
452
452
  }
453
+ // A PR owed a fix-applier on which two have settled `failed` since its
454
+ // latest review, none landed after them: no third, so not actionable, and
455
+ // repeated every tick until a new `reviewed=` lands or the PR closes. Like
456
+ // the conflict escalation it dispatches nothing and is no review unit.
457
+ if (s.fixEscalate.length) {
458
+ conflictRows.push(row(`ESCALATE fix-failed ${prs(s.fixEscalate.map((e) => e.pr))}`,
459
+ { extra: `${s.fixEscalate.flatMap((e) => e.members).join(", ")} settled failed since the latest review; no third fix-applier`
460
+ + " — comment on the PR once and tell the maintainer; a new review hands it back" }));
461
+ }
453
462
  if (!rows.length && !unlabelledRows.length) rows.push(row("IDLE OK"));
454
463
  rows.push(...unlabelledRows);
455
464
  return { rows, conflictRows };
@@ -830,6 +839,11 @@ export function foldLedger({ rows, dispatched }, open, { lenient = false } = {})
830
839
  // `fixMembers`: every fix-applier on this PR, wherever its token sits —
831
840
  // one still unsettled anywhere holds the PR off fixDue, since `dispatch`
832
841
  // refuses a second live one on the PR.
842
+ // `fixFailed`: every fix-applier on this PR settled `failed` after the
843
+ // latest `reviewed=` (from the first token, with none), in row order, one
844
+ // copy per member as for `fixLanded`; `fixFailures()` keeps those whose
845
+ // retry suffix sorts after every landed one's. `killed` and live members
846
+ // are not in it, and a `reviewed=` empties it, as it resets `reviewFixed`.
833
847
  // `reviewedHead`/`reviewedRun`: the latest `reviewed=<head>:…:<run>`.
834
848
  // `pastPinHalt`: the latest
835
849
  // finisher since that review settled `halted:past-pin` — any
@@ -843,7 +857,7 @@ export function foldLedger({ rows, dispatched }, open, { lenient = false } = {})
843
857
  // CONFLICT line off, since it may be pushing to the branch right now.
844
858
  const st = (pr !== null && byPr.get(pr)) || {
845
859
  inFlight: false, reviewedAny: false, survived: 0, unverified: 0, reviewFixed: false,
846
- fixMembers: new Set(), fixLanded: new Set(), conflictLanded: new Set(),
860
+ fixMembers: new Set(), fixLanded: new Set(), conflictLanded: new Set(), fixFailed: new Set(),
847
861
  conflictOpen: false, reviewedHead: null, reviewedRun: null, pastPinHalt: false, dispositions: [], workers: new Set(),
848
862
  finishers: new Set(), parked: [],
849
863
  };
@@ -864,7 +878,9 @@ export function foldLedger({ rows, dispatched }, open, { lenient = false } = {})
864
878
  if ((t.bound === "pr" && t.number === pr) || t.family === "impl") st.workers.add(t.name);
865
879
  // A settled `failed`/`killed` fix-applier leaves review findings or a
866
880
  // conflict unfixed and no successor dispatched — the PR stays fix-due
867
- // for a `-b` replacement. Only a live attempt, or one that actually
881
+ // for a `-b` replacement, unless that `failed` is the second since the
882
+ // PR's latest review with none landed after it (`fixFailed`), which
883
+ // escalates. Only a live attempt, or one that actually
868
884
  // landed (`applied:`/`no-op`), holds it off. Read the outcome off the
869
885
  // member's merged record (`members`, narrowed above) rather than this
870
886
  // row's own copy of the token: "a member settled ANYWHERE is settled",
@@ -896,14 +912,15 @@ export function foldLedger({ rows, dispatched }, open, { lenient = false } = {})
896
912
  if (t.family === "fix-pr" && t.number === pr) {
897
913
  st.fixMembers.add(t.name);
898
914
  const o = members.get(t.name).outcome;
899
- if ((o === "no-op" || /^applied:/.test(o)) && !st.fixLanded.has(t.name)
900
- && (t.outcome !== null || !settledInRow.has(t.name))) {
915
+ const placed = t.outcome !== null || !settledInRow.has(t.name);
916
+ if ((o === "no-op" || /^applied:/.test(o)) && !st.fixLanded.has(t.name) && placed) {
901
917
  st.fixLanded.add(t.name);
902
918
  if (st.conflictOpen) {
903
919
  st.conflictOpen = false;
904
920
  st.conflictLanded.add(t.name);
905
921
  } else st.reviewFixed = true;
906
922
  }
923
+ if (o === "failed" && placed) st.fixFailed.add(t.name);
907
924
  }
908
925
  if (t.family === "finisher-pr" && t.number === pr) st.finishers.add(t.name);
909
926
  if (t.family === "finisher-pr" && t.number === pr
@@ -929,7 +946,7 @@ export function foldLedger({ rows, dispatched }, open, { lenient = false } = {})
929
946
  if (!m && lenient) {
930
947
  malformed.add(i);
931
948
  latestFinisher = null;
932
- Object.assign(st, { inFlight: false, reviewedAny: true, reviewFixed: false, pastPinHalt: false });
949
+ Object.assign(st, { inFlight: false, reviewedAny: true, reviewFixed: false, pastPinHalt: false, fixFailed: new Set() });
933
950
  continue;
934
951
  }
935
952
  if (!m && REVIEWED_RUNLESS.test(tok)) {
@@ -940,7 +957,7 @@ export function foldLedger({ rows, dispatched }, open, { lenient = false } = {})
940
957
  latestFinisher = null;
941
958
  Object.assign(st, {
942
959
  inFlight: false, reviewedAny: true, survived: Number(m[2]), unverified: Number(m[4]), reviewFixed: false,
943
- reviewedHead: m[1].toLowerCase(), reviewedRun: m[5], pastPinHalt: false,
960
+ reviewedHead: m[1].toLowerCase(), reviewedRun: m[5], pastPinHalt: false, fixFailed: new Set(),
944
961
  });
945
962
  } else if (labelOffMember(tok) === null) {
946
963
  if (!lenient) throw new LedgerError(`${where}: '${tok}' is not label-off=<finisher-pr member> — fix the row with \`ledger.mjs row\``);
@@ -1135,6 +1152,29 @@ export function deriveRun({ rows, dispatched, drain, retired = [] }, prs, queued
1135
1152
  const retry = parseMember(cur.member).retry ?? "";
1136
1153
  return ![...st.fixLanded].some((n) => !st.conflictLanded.has(n) && (parseMember(n).retry ?? "") > retry);
1137
1154
  };
1155
+ // The fix-appliers settled `failed` since the PR's latest review whose retry
1156
+ // suffix sorts after that of every one on the PR that landed: a landed one
1157
+ // restarts the count, of any kind. Two of them and the fleet dispatches no
1158
+ // third fix-applier to the PR until a new review restarts it.
1159
+ const fixFailures = (st) => [...st.fixFailed].filter((n) => {
1160
+ const retry = parseMember(n).retry ?? "";
1161
+ return ![...st.fixLanded].some((l) => (parseMember(l).retry ?? "") >= retry);
1162
+ });
1163
+ const fixEscalated = (st) => fixFailures(st).length >= 2;
1164
+ // A returned review whose survived or unverified findings no review
1165
+ // fix-applier has answered — `ledger.mjs dispatch` refuses a finisher
1166
+ // on either until one has — a conflict hold no fix-applier has cleared,
1167
+ // or a dispositions mismatch no retry has answered — on a PR still open,
1168
+ // with no fix-applier working it and no newer review running. The first
1169
+ // two are answered apart here: a landed conflict fix-applier lifts the
1170
+ // hold and leaves findings it never read due for a review one.
1171
+ const fixOwed = ([n, st]) => open.has(n)
1172
+ && (((st.survived > 0 || st.unverified > 0) && !st.reviewFixed) || conflictHeld(st) || mismatchDue(st))
1173
+ && !fixRunning(st) && !st.inFlight;
1174
+ // The PRs owed a fix-applier, split below by `fixEscalated` into `fixDue`
1175
+ // and `fixEscalate`, as `conflicting` is into `conflicts` and
1176
+ // `conflictEscalate`.
1177
+ const owed = [...byPr.entries()].filter(fixOwed);
1138
1178
  // A `review=` token with no `reviewed=` after it reads as in flight, and the
1139
1179
  // ledger alone never says otherwise: a review whose own `reviewed=` write
1140
1180
  // never landed stays in flight after its PR merges, counting as a review unit
@@ -1171,18 +1211,21 @@ export function deriveRun({ rows, dispatched, drain, retired = [] }, prs, queued
1171
1211
  // The in-flight reviews of PRs the open list does not carry: the ones
1172
1212
  // the probe could retire, so the caller asks gh about these and no others.
1173
1213
  reviewsOffList: reviewing.filter(([n]) => !open.has(n)).map(([n]) => n).sort(asc),
1174
- // A returned review whose survived or unverified findings no review
1175
- // fix-applier has answered — `ledger.mjs dispatch` refuses a finisher
1176
- // on either until one has — a conflict hold no fix-applier has cleared,
1177
- // or a dispositions mismatch no retry has answered — on a PR still open,
1178
- // with no fix-applier working it and no newer review running. The first
1179
- // two are answered apart here: a landed conflict fix-applier lifts the
1180
- // hold and leaves findings it never read due for a review one.
1181
- fixDue: [...byPr.entries()]
1182
- .filter(([n, st]) => open.has(n)
1183
- && (((st.survived > 0 || st.unverified > 0) && !st.reviewFixed) || conflictHeld(st) || mismatchDue(st))
1184
- && !fixRunning(st) && !st.inFlight)
1185
- .map(([n]) => n).sort(asc),
1214
+ // Each PR a fix-applier is owed on (`fixOwed`), unless two fix-appliers
1215
+ // have settled `failed` on it since its latest review with none landed
1216
+ // after them: that PR is `fixEscalate`'s instead.
1217
+ fixDue: owed.filter(([, st]) => !fixEscalated(st)).map(([n]) => n).sort(asc),
1218
+ // Each PR a fix-applier would be owed on but for two `failed` since its
1219
+ // latest review, `{pr, members}` ascending, `members` the counted ones:
1220
+ // the reviewers row escalates it, dispatching nothing.
1221
+ fixEscalate: owed.filter(([, st]) => fixEscalated(st))
1222
+ .map(([n, st]) => ({ pr: n, members: fixFailures(st) })).sort((a, b) => a.pr - b.pr),
1223
+ // Every PR, open or not, with two `failed` fix-appliers counted, `{pr,
1224
+ // members}` ascending — the one reading of the count: `ledger.mjs
1225
+ // dispatch` refuses any fix-applier on a PR off this list, so it answers
1226
+ // with no open list, as `conflictHeld` does.
1227
+ fixFailed: [...byPr.entries()].filter(([, st]) => fixEscalated(st))
1228
+ .map(([n, st]) => ({ pr: n, members: fixFailures(st) })).sort((a, b) => a.pr - b.pr),
1186
1229
  // Open, not signed off, owned (openPrs() reads that off the PR's author
1187
1230
  // and draft flag; a PR closing no issue is as due as one closing one),
1188
1231
  // with no live or returned review on record —
@@ -2363,7 +2363,7 @@ async function runDispatch() {
2363
2363
  // conflict hold, dispositions retry — so its definition reads nothing off
2364
2364
  // the ledger.
2365
2365
  //
2366
- // The finisher's gates below turn on the tick's own verdict, not a second
2366
+ // The fix-applier's and the finisher's gates below turn on the tick's own verdict, not a second
2367
2367
  // reading of row `i`: a PR's tokens can be split across its ticket row and
2368
2368
  // its own `#<pr>` row, and a settle can live in `## Dispatched` alone, so
2369
2369
  // one row's text can read held where the tick reads cleared, and the
@@ -2379,6 +2379,19 @@ async function runDispatch() {
2379
2379
  }
2380
2380
  };
2381
2381
 
2382
+ // No third fix-applier, of any kind, on a PR where two have settled
2383
+ // `failed` since its latest review with none landed after them — read off
2384
+ // the tick's own fold, the one its `ESCALATE fix-failed` row reads, so a
2385
+ // hand-dispatched one is refused like the tick's. A new review restarts the
2386
+ // count.
2387
+ if (member.family === "fix-pr") {
2388
+ const failed = tickFold("fix-applier failure count").fixFailed.find((f) => f.pr === member.number);
2389
+ if (failed !== undefined) {
2390
+ die(`${member.name}: ${failed.members.join(", ")} settled failed on PR #${member.number} since its latest review — the fleet dispatches no third fix-applier; `
2391
+ + `a new review of PR #${member.number} (\`ledger.mjs review ${member.number} review=member:<next reviewer name>\`, dispatched as any review) restarts the count — not dispatching ${member.name}`);
2392
+ }
2393
+ }
2394
+
2382
2395
  // A finisher labels its PR `ready-to-merge`, so it is recorded only once
2383
2396
  // the PR sits on no conflict hold a fix-applier has yet to clear — a PR
2384
2397
  // known to conflict cannot merge, and a finisher would race the fix-applier
@@ -225,8 +225,8 @@ Record each ruling with `ledger.mjs ruled <pr> <decision>`, one line with its re
225
225
  - **The reviewer.** **Dispatch the review, never wait on it, and act when its result lands. That is the default path.** `DISPATCH review PR#<M>`: a `task` member named `review-pr-<pr#>`, agent `fleet-review-runner`, its prompt the five args `pr`, `branch`, `worktree`, `testCmd` and `scratch`. Record `review=member:review-pr-<pr#>` on the PR's row before the call, with `ledger.mjs review <pr> <token>`: the tick counts in-flight reviews off the ledger and nowhere else. `scratch` is the scratch root itself, never a `pr<N>` partition (`references/reviewers.md`). The runner writes the result file and reports its path and `reviewed=` token.
226
226
  A row with `review=` and no `reviewed=` is a review in flight, and the tick counts it as a live review unit unless gh reports its PR MERGED or CLOSED.
227
227
  - **The fix-applier.** `DISPATCH fix-pr PR#<M>` on a `reviewed=` count that survived or unverified findings, with no fix-applier live: name `fix-pr-<pr#>` (the next suffix if that name is on record), never the PR's implementer; render with `dispatch-prompt.mjs render fix-applier --kind review --member fix-pr-<pr#> …`, then record `ledger.mjs dispatch <pr#> fix-pr-<pr#>` before the call. Its brief carries the PR number, the worktree abs path, the PR's branch, the same `testCmd` you passed the review, and the **path** `<scratch>/pr<pr>/<run>/review.json`, `<run>` off the PR's latest `reviewed=` — never the findings. Every `<scratch>` in that brief is the absolute path `scratch-root.mjs` printed. Its rulings are the fix-applier body's (`agents/fleet-fix-applier.agent.md`); you hold none, and a refuter report that surfaces to you is its to retrieve, never yours to scan or pass on. On a PR carrying `ready-to-merge`, its push moves the head after the label: a fresh finisher, per **Failure handling**.
228
- - **The conflict hold.** `DISPATCH fix-pr PR#<M>` on a conflict hold: the row carries an unresolved `conflict-hold:#<M>`, the merge bot's or one you recorded off the tick's `CONFLICT` line. It is the same slot with a different job, and no review file to hand over. Name it `fix-pr-<M>`, or the next suffix (`-b`, `-c` …) when that name is on record; render with `dispatch-prompt.mjs render fix-applier --kind conflict --member <name> …`; dispatch with the `agent` `ledger.mjs dispatch` printed, in the PR's existing worktree. Read the definition off that output (`fleet-fix-applier` whatever the row's `tier=`), never recall it. Settle `applied:<head>`, or `no-op` if no conflict was left, which lifts the merge hold; a dispatched-but-live one does not, and `failed`/`killed` leave the PR fix-due for a replacement. It answers the hold and nothing else: review findings the row also carries get a review `DISPATCH fix-pr PR#<M>` once it lands.
229
- - **Then dispatch a red-check fixer** — on a `check`-job `failure` bound to the PR's current head that is not **solely** staleness (the five-condition note in `agents/fleet-fix-applier.agent.md`). Name `fix-pr-<M>`, or the next free suffix; render with `dispatch-prompt.mjs render fix-applier --kind red-check --member <name> …`, record with `ledger.mjs dispatch <pr#> <name>` before the call, and dispatch with the printed `agent` in the PR's existing worktree. Never while a review or a review fix-applier on the PR is live or still owes its report — a dispositions mismatch awaiting its retry and a conflict hold awaiting its fix-applier included; a red before any review still gets its review first. The tick prints no `DISPATCH` for it: reconcile it yourself, always after the review. The finisher gate applies to it as to a fix-applier. Settle it `applied:<head>` once a fix is pushed; `no-op` only when the red is not its to fix — a flake that passes on rerun, or staleness — with nothing pushed, never for "could not fix"; `failed` when it cannot reach green (**Failure handling**). Its three dispatch edges are under **The finisher gate**; their rationale is in `references/member-lifecycle.md` (The red-check fixer's three edges).
228
+ - **The conflict hold.** `DISPATCH fix-pr PR#<M>` on a conflict hold: the row carries an unresolved `conflict-hold:#<M>`, the merge bot's or one you recorded off the tick's `CONFLICT` line. It is the same slot with a different job, and no review file to hand over. Name it `fix-pr-<M>`, or the next suffix (`-b`, `-c` …) when that name is on record; render with `dispatch-prompt.mjs render fix-applier --kind conflict --member <name> …`; dispatch with the `agent` `ledger.mjs dispatch` printed, in the PR's existing worktree. Settle `applied:<head>`, or `no-op` if no conflict was left, which lifts the merge hold; a dispatched-but-live one does not, and `failed`/`killed` leave the PR fix-due for a replacement; a second `failed` since its latest review escalates. It answers the hold and nothing else: review findings the row also carries get a review `DISPATCH fix-pr PR#<M>` once it lands.
229
+ - **Then dispatch a red-check fixer** — on a `check`-job `failure` bound to the PR's current head that is not **solely** staleness (the five-condition note in `agents/fleet-fix-applier.agent.md`). Name `fix-pr-<M>`, or the next free suffix; render with `dispatch-prompt.mjs render fix-applier --kind red-check --member <name> …`, record with `ledger.mjs dispatch <pr#> <name>` before the call, and dispatch with the printed `agent` in the PR's existing worktree. `dispatch` refuses one on a `fix-failed` PR, row or not; act as on the row. Never while a review or a review fix-applier on the PR is live or still owes its report — a dispositions mismatch awaiting its retry and a conflict hold awaiting its fix-applier included; a red before any review still gets its review first. The tick prints no `DISPATCH` for it: reconcile it yourself, always after the review. The finisher gate applies to it as to a fix-applier. Settle it `applied:<head>` once a fix is pushed; `no-op` only when the red is not its to fix — a flake that passes on rerun, or staleness — with nothing pushed, never for "could not fix"; `failed` when it cannot reach green (**Failure handling**).
230
230
  - **The merge bot.** Named `merge-bot-<n>`; `ledger.mjs dispatch merge-bot` numbers it. Render `--member merge-bot-<n> --n <n> --scratch <scratch>`. Dispatch with the printed agent, omit `model`, and dispatch on the first `ready-to-merge` label without waiting for the finisher report.
231
231
  - **The finisher.** Its render and receives are in `references/finisher.md`.
232
232
 
@@ -386,6 +386,7 @@ It prints `actual/target` and a named ACTION per role. Act on each line as it re
386
386
  - `ESCALATE unlabelled PR#<M> …` — a second finisher settled `labelled` and the label is still off: not actionable, the maintainer's.
387
387
  - `CONFLICT PR#<M> …` — record the hold with `fleet-event.mjs conflict <M>`, never with the `ledger.mjs row` form; the tick then prints `DISPATCH fix-pr`.
388
388
  - `ESCALATE conflict PR#<M> …` — PR M reads CONFLICTING again after two conflict fix-appliers: comment on the PR and flag it for a human, write no hold, dispatch no fix-applier.
389
+ - `ESCALATE fix-failed PR#<M> …` — no third fix-applier: comment on the PR once, tell the maintainer; a new review hands it back.
389
390
  - `ESCALATE pr-closed #<N> PR#<M>`, `… pr-unchecked …` — the maintainer's: tell them once per ticket per run; no dispatch or comment for #N. Reopening M or closing #N clears it. Only `replace #N` (`NEED resume`, same row) or `release #N` (closed-PR `release-ticket.sh --apply`, settle `released`) acts, once no live member names M.
390
391
  - `HOLD (…)` — the row is held and its detail names the clearing step: dispatch nothing on that row until it clears; a tier mismatch is yours to clear by dispatching the replacement.
391
392
  - `AT CAP`, `IDLE OK` — nothing to do on that row.
@@ -804,7 +805,7 @@ Match the failure to its row in the table below and run that response; where the
804
805
  | Implementer bails before implementing | Act by the report's `bailCause` as the **Relabel causes** table says, then refill (**What a wake owes beyond its call**) |
805
806
  | Implementer blocked or ambiguous *mid-implementation* | Free the slot. A `blocked` report settles on the **Implementer report** wake, no label moved; with no report, `ledger.mjs settle impl-<N> blocked`, its Ending still `hollow`. Leave `in-progress`, report — the ticket is not In flight and waits for a human; its `NEED derive-recipe` is phase 0's mid-run trigger |
806
807
  | `review-pr` workflow throws or returns no tree | Retry once under the next letter (`review-pr-<pr#>-b`); still failing, report and leave the PR at review-due. Never enqueue the PR as reviewed — the workflow is not a member, so no other row here covers it |
807
- | Reviewer, fix-applier or red-check fixer cannot reach green | Report, leave the PR unlabeled, free the slot — the last two settle `failed`; a wake's `NEED derive-recipe` is phase 0's mid-run trigger |
808
+ | Reviewer, fix-applier or red-check fixer cannot reach green | Report, leave the PR unlabeled, free the slot — the last two settle `failed`; a wake's `NEED derive-recipe` is phase 0's mid-run trigger; a second `failed` fix-applier since review escalates |
808
809
  | Merge bot finds the worktree ahead of the PR head **on the local-rebase fallback** | `worktree-diverged-#<pr>`, PR stays queued. Read the stray commit; push-or-discard is yours, and the maintainer's if the evidence cannot settle it |
809
810
  | Merge bot finds the head moved after `ready-to-merge` was applied | The label binds to the head's net change, not to one SHA: a proven rebase-carry keeps the label — the bot proceeds and reports `rebase-carry-#<pr>` with the labelled and accepted SHAs, and nothing is dispatched. Any other move is `head-moved-after-label-#<pr>`, PR stays queued, label untouched. Dispatch a **fresh** finisher against the new head — the first audit verified a different tree |
810
811
  | Merge bot cannot resolve a rebase safely | Stop that PR, report, continue. On a conflict the bot has already appended `conflict-hold:#<pr>` to the PR's row; the tick prints `DISPATCH fix-pr PR#<pr>` and holds the merge until that fix-applier settles. A PR that conflicts before any bot reaches it is the tick's `CONFLICT PR#<pr>` line, whose hold you record |
@@ -194,5 +194,5 @@ A mismatch on a ticket whose issue is already CLOSED holds nothing: the tick pro
194
194
  - **The reviewer.** **Dispatch the review, never wait on it, and act when its result lands. That is the default path.** `DISPATCH review PR#<M>`: a `task` member named `review-pr-<pr#>`, agent `fleet-review-runner`, its prompt the five args `pr`, `branch`, `worktree`, `testCmd` and `scratch`. Record `review=member:review-pr-<pr#>` on the PR's row before the call. `scratch` is the scratch root itself, never a `pr<N>` partition (`references/reviewers.md`). Write the `review=` token with `ledger.mjs review <pr> <token>`; `ledger.mjs` refuses a bad grammar. The tick names every PR owed one, oldest first, and each gets one review, once per PR. The tick counts in-flight reviews off the ledger and nowhere else, so a review you launched and never recorded is one it names again. The runner writes the result file and reports its path and `reviewed=` token.
195
195
  A row with `review=` and no `reviewed=` is a review in flight, and the tick counts it as a live review unit unless gh reports its PR MERGED or CLOSED.
196
196
  - **The fix-applier.** `DISPATCH fix-pr PR#<M>` on a `reviewed=` count that survived or unverified findings, with no fix-applier live: name `fix-pr-<pr#>` (the next suffix if that name is on record), never the PR's implementer; render with `dispatch-prompt.mjs render fix-applier --kind review --member fix-pr-<pr#> …`, then record `ledger.mjs dispatch <pr#> fix-pr-<pr#>` before the call. Its brief carries the PR number, the worktree abs path, the PR's branch, the same `testCmd` you passed the review, and the **path** `<scratch>/pr<pr>/<run>/review.json`, `<run>` off the PR's latest `reviewed=` — never the findings. Every `<scratch>` in that brief is the absolute path `scratch-root.mjs` printed. Its rulings are the fix-applier body's (`agents/fleet-fix-applier.agent.md`); you hold none. It holds every finding and you hold none, so there is nothing for you to rank, relay or pre-rule — and a report from a refuter it spawns that surfaces to you is its to retrieve, never yours to scan or pass on. It answers the hold and nothing else: survived or unverified findings of a returned review the row also carries stay unanswered through its settle, so the tick prints `DISPATCH fix-pr PR#<M>` again once it lands, and that one is a review fix-applier, dispatched as above. On a PR carrying `ready-to-merge`, the push moves the head after the label, so the next merge bot refuses it `head-moved-after-label-#<M>`: a fresh finisher, per **Failure handling**.
197
- - **The conflict hold.** `DISPATCH fix-pr PR#<M>` on a conflict hold: the row carries an unresolved `conflict-hold:#<M>`, the merge bot's or one you recorded off the tick's `CONFLICT` line. It is the same slot with a different job, and no review file to hand over. Name it `fix-pr-<M>`, or the next suffix (`-b`, `-c` …) when that name is on record; render with `dispatch-prompt.mjs render fix-applier --kind conflict --member <name> …`; dispatch with the `agent` `ledger.mjs dispatch` printed, in the PR's existing worktree. Read the definition off that output (`fleet-fix-applier` whatever the row's `tier=`), never recall it. Settle `applied:<head>`, or `no-op` if no conflict was left, which lifts the merge hold; a dispatched-but-live one does not, and `failed`/`killed` leave the PR fix-due for a replacement.
198
- - **Then dispatch a red-check fixer** — on a `check`-job `failure` bound to the PR's current head that is not **solely** staleness: a `rebase-check` red, or heavy jobs `skipped`, that comes only off the behind-count gets no fixer (the five-condition note in `agents/fleet-fix-applier.agent.md` establishes that). Name `fix-pr-<M>`, or the next free suffix; render with `dispatch-prompt.mjs render fix-applier --kind red-check --member <name> …`, record with `ledger.mjs dispatch <pr#> <name>` before the call, and dispatch with the printed `agent` in the PR's existing worktree. While a review or a review fix-applier on the PR is live or still owes its report — a dispositions mismatch awaiting its retry and a conflict hold awaiting its fix-applier included — the red-check fixer does not fire: their push starts a new run, and a fixer racing them would work on a SHA that is still moving. The common case, the implementer's own first CI firing turning red before any review exists, still dispatches the review against that head as normal. The tick prints no `DISPATCH` for it, so you reconcile it yourself, and it always goes after the review, never before. It is told outright not to watch, poll or wait for CI: your persistent Monitor owns the next run on the pushed head, and the finisher gate — review returned AND fix-applier report sent — applies to this member the same way. Settle it `applied:<head>` once a fix is pushed. Settle it `no-op` only when the red turns out not to be this member's to fix — a flake that passes on rerun, or staleness — with nothing pushed; `no-op` counts as landed, so it never stands for "could not fix". Settle it `failed` when it cannot reach green, which the **Failure handling** row "Reviewer, fix-applier or red-check fixer cannot reach green" covers. Its three dispatch edges are under **The finisher gate**; their rationale is in `references/member-lifecycle.md` (The red-check fixer's three edges).
197
+ - **The conflict hold.** `DISPATCH fix-pr PR#<M>` on a conflict hold: the row carries an unresolved `conflict-hold:#<M>`, the merge bot's or one you recorded off the tick's `CONFLICT` line. It is the same slot with a different job, and no review file to hand over. Name it `fix-pr-<M>`, or the next suffix (`-b`, `-c` …) when that name is on record; render with `dispatch-prompt.mjs render fix-applier --kind conflict --member <name> …`; dispatch with the `agent` `ledger.mjs dispatch` printed, in the PR's existing worktree. Read the definition off that output (`fleet-fix-applier` whatever the row's `tier=`), never recall it. Settle `applied:<head>`, or `no-op` if no conflict was left, which lifts the merge hold; a dispatched-but-live one does not, and `failed`/`killed` leave the PR fix-due for a replacement, but a second `failed` since the PR's latest review escalates (`ESCALATE fix-failed`).
198
+ - **Then dispatch a red-check fixer** — on a `check`-job `failure` bound to the PR's current head that is not **solely** staleness: a `rebase-check` red, or heavy jobs `skipped`, that comes only off the behind-count gets no fixer (the five-condition note in `agents/fleet-fix-applier.agent.md` establishes that). Name `fix-pr-<M>`, or the next free suffix; render with `dispatch-prompt.mjs render fix-applier --kind red-check --member <name> …`, record with `ledger.mjs dispatch <pr#> <name>` before the call, and dispatch with the printed `agent` in the PR's existing worktree. `dispatch` refuses one on a PR where two fix-appliers have settled `failed` since its latest review with none landed after them, whether or not the tick prints `ESCALATE fix-failed` for it — it prints that row only while the PR is owed a fix-applier: handle that refusal as the row. While a review or a review fix-applier on the PR is live or still owes its report — a dispositions mismatch awaiting its retry and a conflict hold awaiting its fix-applier included — the red-check fixer does not fire: their push starts a new run, and a fixer racing them would work on a SHA that is still moving. The common case, the implementer's own first CI firing turning red before any review exists, still dispatches the review against that head as normal. The tick prints no `DISPATCH` for it, so you reconcile it yourself, and it always goes after the review, never before. It is told outright not to watch, poll or wait for CI: your persistent Monitor owns the next run on the pushed head, and the finisher gate — review returned AND fix-applier report sent — applies to this member the same way. Settle it `applied:<head>` once a fix is pushed. Settle it `no-op` only when the red turns out not to be this member's to fix — a flake that passes on rerun, or staleness — with nothing pushed; `no-op` counts as landed, so it never stands for "could not fix". Settle it `failed` when it cannot reach green, which the **Failure handling** row "Reviewer, fix-applier or red-check fixer cannot reach green" covers. Its three dispatch edges are under **The finisher gate**; their rationale is in `references/member-lifecycle.md` (The red-check fixer's three edges).
@@ -493,8 +493,10 @@ settled `blocked` and `fix-report` for a fix-applier settled `failed`: it is
493
493
  counted in the same once per run, a line printed while that derivation runs
494
494
  is covered by it, and one printed after its `RECIPE PROVEN` is the second
495
495
  refusal that stalls the run. What to retry for a wake's line: a fix-applier's
496
- PR is fix-due again and the tick re-dispatches it; a blocked implementer's
497
- ticket is reported to the maintainer and waits for their `replace #<N>`.
496
+ PR is fix-due again and the tick re-dispatches it, unless that `failed` was its
497
+ second since the PR's latest review, which escalates (`ESCALATE fix-failed`);
498
+ a blocked implementer's ticket is reported to the maintainer and waits for
499
+ their `replace #<N>`.
498
500
  The count is yours to keep; the ledger holds no record of it. The Install step's refusals
499
501
  fire after the claim has labelled the ticket and created its worktree, so
500
502
  release that claim with `release-ticket.sh` first (SKILL.md's Failure handling
@@ -65,6 +65,31 @@ The full text of each row `fleet-tick.mjs` prints and what it asks of the contro
65
65
  and flag it for a human; write no hold and dispatch no fix-applier. Not
66
66
  actionable; it repeats while the PR reads CONFLICTING and clears once it
67
67
  stops, closes or merges.
68
+ - `ESCALATE fix-failed PR#<M> …` — PR M is owed a fix-applier, but two
69
+ fix-appliers on it have settled `failed` since its latest `reviewed=` (from
70
+ its first token, with none), each with a retry suffix after that of every
71
+ fix-applier on the PR that landed `applied:`/`no-op`. Every kind counts —
72
+ review, conflict, dispositions retry, red-check; `killed` and live ones
73
+ neither count nor restart the count, and a landed one restarts it. The row
74
+ prints in place of `DISPATCH fix-pr PR#<M>`, its detail naming the counted
75
+ members, and `ledger.mjs dispatch` refuses a third fix-applier of any kind
76
+ on M, a hand-dispatched red-check fixer included. It refuses one on any PR
77
+ whose count reaches two, even one owed no fix-applier, for which no row
78
+ prints — two failed red-check fixers after a review with nothing to fix.
79
+ Handle that refusal as the row. Dispatch no fix-applier for M. Comment on
80
+ the PR once — read its comments for the first line before posting, since
81
+ the row repeats and the comment does not. Its first line is `**Two
82
+ fix-appliers failed on this PR since its latest review; the fleet
83
+ dispatches no third.**`; then each
84
+ counted member with what its report says (`confirmation`, and `testRun`
85
+ when not null), or `no report`; then: a new review hands the PR back, and a
86
+ draft PR is skipped by the next run. Tell the maintainer. On their word,
87
+ launch a new review with `ledger.mjs review <M> review=member:<next
88
+ reviewer name>` and dispatch it as any review: its `reviewed=` restarts the
89
+ count. Not actionable; it repeats every tick while it holds and clears once
90
+ a new `reviewed=` lands or the PR closes or merges. Nothing carries it
91
+ across runs: the next run's fold-in queues the PR for review like any Owned
92
+ PR, and a draft is not one.
68
93
  - `ESCALATE pr-closed #<N> PR#<M>` — PR M, ticket N's latest PR (the latest
69
94
  `impl-<N>…=PR#<M>` on the row), is CLOSED unmerged while issue #N is not
70
95
  read CLOSED (an issue gh cannot read counts as open), and no