@feigi/fleet-ctl 3.39.5 → 3.39.6

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.39.5",
3
+ "version": "3.39.6",
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": {
@@ -273,6 +273,11 @@ export function newSplitRow(before, after) {
273
273
  return null;
274
274
  }
275
275
 
276
+ /** The refusal clause for a `newSplitRow` result, shared by every writer that refuses one. */
277
+ export function splitRowClause({ pr, row }) {
278
+ return `PR #${pr} would map to more than one row — its PR's row is ${row}`;
279
+ }
280
+
276
281
  /**
277
282
  * Why `ledger.mjs row` or `ledger.mjs review` must not write `line` over
278
283
  * `oldLine` (null for a new row), `before` and `after` the ledger's rows on
@@ -45,7 +45,7 @@ import { fileURLToPath } from "node:url";
45
45
  import { spawnSync, execFileSync } from "node:child_process";
46
46
  import { makeDie, isFlagLike, hasEqualsForm, isDigits } from "./arg.mjs";
47
47
  import { fleetFile, FleetDirUnresolvable } from "./fleet-dir.mjs";
48
- import { parseMember, parseToken, memberTokens, nextMergeBot, nextRetry, liveOnLedger, retiredOnLedger, isRetirable, agentDefinition, CELL, tierValues, rowPr, rowWriteRefusal, isReviewToken, addedReviewToken, newSplitRow, premisesOf, ROWS, DISPATCHED, FILED, RULED, DRAIN, RETIRED, headerRe, escapeText, unescapeText } from "./ledger-grammar.mjs";
48
+ import { parseMember, parseToken, memberTokens, nextMergeBot, nextRetry, liveOnLedger, retiredOnLedger, isRetirable, agentDefinition, CELL, tierValues, rowPr, rowWriteRefusal, isReviewToken, addedReviewToken, newSplitRow, splitRowClause, premisesOf, ROWS, DISPATCHED, FILED, RULED, DRAIN, RETIRED, headerRe, escapeText, unescapeText } from "./ledger-grammar.mjs";
49
49
  import { deriveRun, LedgerError, labelOffMember } from "./fleet-tick.mjs";
50
50
  import { stateFileIn, readState, writeState, assessBeat, stallsAt } from "./fleet-state.mjs";
51
51
  import { isDead, processSource, ancestry, controllerOf, judgeController, ProcUnreadable } from "./proc.mjs";
@@ -842,7 +842,7 @@ if (cmd === "read") {
842
842
  // carried.
843
843
  const split = newSplitRow(data.rows, after);
844
844
  if (split !== null) {
845
- die(`row ${key}: PR #${split.pr} would map to more than one row — its PR's row is ${split.row}; rewrite that row instead`);
845
+ die(`row ${key}: ${splitRowClause(split)}; rewrite that row instead`);
846
846
  }
847
847
  // A PR's review record is read off its rows — every row mapping to it, in
848
848
  // ledger order — so a write that drops an open launch makes the tick lose
@@ -2048,12 +2048,10 @@ function runSettle() {
2048
2048
  return;
2049
2049
  }
2050
2050
 
2051
- // Capture whether the row this settle is about to write to already
2052
- // named a PR, before the rewrite below touches it. The fold further down
2053
- // must refuse to run once a row already has PR-specific content on it —
2054
- // see the fold's own comment for why.
2055
- const targetBefore = liveRows[0] ?? memberRowIndex(parsed);
2056
- const priorPr = targetBefore === -1 ? null : rowPr(data.rows[targetBefore]);
2051
+ // The rows before any write below: the fold's guard reads the row this
2052
+ // settle writes to as it stood, and the one-row-per-PR check after the
2053
+ // fold compares against them.
2054
+ const before = [...data.rows];
2057
2055
  // A live token `row` wrote is settled like one `dispatch` wrote; `##
2058
2056
  // Dispatched` only records what `dispatch` did.
2059
2057
  if (liveEntry) data.dispatched[di] = token;
@@ -2090,7 +2088,7 @@ function runSettle() {
2090
2088
  // an unrelated ticket's premise on a mistyped PR number, and folding it
2091
2089
  // would delete state a settled member can never restore.
2092
2090
  const prNum = outcome.startsWith("PR#") ? Number(outcome.slice("PR#".length)) : null;
2093
- const j = prNum === null || i === -1 || priorPr !== null ? -1
2091
+ const j = prNum === null || i === -1 || rowPr(before[i]) !== null ? -1
2094
2092
  : data.rows.findIndex((r) => rowKey(r) === `#${prNum}` && !memberTokens(r).some((t) => t.family === "impl") && premisesOf(r) === null);
2095
2093
  if (j !== -1) {
2096
2094
  const tail = data.rows[j].slice(`#${prNum}`.length).trim();
@@ -2098,6 +2096,12 @@ function runSettle() {
2098
2096
  data.rows.splice(j, 1);
2099
2097
  if (j < i) i -= 1;
2100
2098
  }
2099
+ // A PR has one row, so a settle that makes a PR map to a second row is
2100
+ // refused, as `row` refuses one: judged on the folded ledger, so the fold's
2101
+ // own row is no split, and added only, so a split already on disk is
2102
+ // carried. The refused member settles `=bailed` or to a PR of its own.
2103
+ const split = newSplitRow(before, data.rows);
2104
+ if (split !== null) die(`settle ${token}: ${splitRowClause(split)}; settle ${name} =bailed or to a PR of its own`);
2101
2105
  save(data);
2102
2106
  console.error(` settled ${token}`);
2103
2107
  console.log(JSON.stringify(payload(i, true)));
@@ -4161,7 +4161,9 @@ live count from it, so nobody states one. Write neither by hand:
4161
4161
  each PR from then on — but only when `#N`'s row named no PR before this
4162
4162
  write (a second `PR#` on it would misattribute the fold, or bury `#N`'s own
4163
4163
  fresher `review=` state under an older one) and no implementer claims `#M`'s
4164
- row as its own.
4164
+ row as its own. `settle impl-N=PR#M` refuses a settle after which a PR maps
4165
+ to more than one row when it did not before, judged after the fold — a PR
4166
+ has one row, the PR's row; a split already on disk is carried.
4165
4167
  - **`ledger.mjs review <pr> <token>…`** — the only writer of `review=` and
4166
4168
  `reviewed=` (below): appends each to the PR's row — the ticket row once
4167
4169
  `settle impl-<N>=PR#M` has run, else `#M`, created when neither exists —
@@ -4192,7 +4194,7 @@ permanent settle. It refuses a write that adds a `review=`/`reviewed=` token
4192
4194
  (one the row already holds is carried), and one after which a PR maps to more
4193
4195
  than one row when it did not before — `row <M>` creating `#M` for a PR a ticket
4194
4196
  row maps, or a rewrite adding a `PR#M` mention to another row — naming the
4195
- PR's row.
4197
+ PR's row (`settle impl-N=PR#M` applies the same rule after its fold).
4196
4198
 
4197
4199
  `→ PR#M` stays as the human-readable arrow; the tick reads only the `=`
4198
4200
  tokens. `tier=<cell>` marks an Exploration Pull's cell and `route=<REASON>` a router fallback (phase 2), and `excluded ·