@feigi/fleet-ctl 3.39.4 → 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.
@@ -82,7 +82,7 @@ const RATE_LIMITED = /rate limit|abuse detection/i;
82
82
  // on this payload's own fields — `verdict`, `behind`, `missing`, the per-job
83
83
  // conclusions, and `prHead == runHeadSha` — and an absent `missing` refuses
84
84
  // that gate where an empty array would have told it nothing was missing.
85
- // board.mjs is not that reader — it takes exit 2 as a failed read whatever
85
+ // board-gather.mjs is not that reader — it takes exit 2 as a failed read whatever
86
86
  // was printed on the way out, and carries its previous CI value for the PR
87
87
  // forward instead.
88
88
  //
@@ -925,7 +925,7 @@ if (behind === null) {
925
925
  }
926
926
 
927
927
  // no-ci is its own verdict, distinguishable from both green and not-green —
928
- // board.mjs's mapCi() and any other caller that reads `verdict` by string
928
+ // board-gather.mjs's mapCi() and any other caller that reads `verdict` by string
929
929
  // value sees "no-ci" rather than either, so it cannot be silently folded into
930
930
  // a pass or a red. reasons.length is never 0 here: the no-ci branch above
931
931
  // always pushes exactly one, whichever way --declare-no-ci went.
@@ -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";
@@ -148,7 +148,7 @@ const GIT_TIMEOUT_MS = gitBudget(10, process.env.LEDGER_GIT_TIMEOUT);
148
148
  // worktree) instead, with GIT_DIR/GIT_WORK_TREE scrubbed so an ambient one
149
149
  // cannot put the run's ledger under another repository; only the bound, the
150
150
  // warning and the fallback below are this caller's own. No canonicalisation
151
- // is asked for: that is board.mjs's opt-in, and taking it here would change
151
+ // is asked for: that is board-server.mjs's opt-in, and taking it here would change
152
152
  // the path `check` prints without changing which file it names.
153
153
  function defaultLedgerPath() {
154
154
  try {
@@ -764,7 +764,7 @@ const data = cmd === "rotate" ? null : load();
764
764
  // discards whatever is still queued, so a payload past the buffer arrives cut
765
765
  // — at exit 0, which types a corrupt read as a successful one.
766
766
  // candidates.mjs states the same reason at its own exit line; this was the
767
- // second script on that shape. The consumer that made it visible is board.mjs,
767
+ // second script on that shape. The consumer that made it visible is board-gather.mjs,
768
768
  // which reads `read` through execFileSync — a pipe — and accepts its ledger
769
769
  // only as a path, so nothing on the caller's side could work around it: a
770
770
  // grown ledger served a cockpit whose board was empty at HTTP 200.
@@ -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)));
@@ -1451,15 +1451,14 @@ four for that row alone.
1451
1451
  directory for this cwd, not one:
1452
1452
 
1453
1453
  ```bash
1454
- PROJECT_DIR="$(node -e 'import("./scripts/board.mjs").then(m => console.log(m.encodeProjectDir(process.cwd())))')"
1454
+ PROJECT_DIR="$(node -e 'import("./scripts/member-record.mjs").then(m => console.log(m.encodeProjectDir(process.cwd())))')"
1455
1455
  for d in "$HOME/.omp/agent/sessions/$PROJECT_DIR"/*/; do
1456
1456
  node scripts/member-outcomes.mjs "$d"
1457
1457
  done
1458
1458
  ```
1459
1459
 
1460
- `encodeProjectDir` (defined in `scripts/member-record.mjs`, re-exported by
1461
- `scripts/board.mjs`) encodes the cwd exactly as omp names its session
1462
- directories — see its comment for the rule — and hand-guessing that path is why
1460
+ `encodeProjectDir` (defined in `scripts/member-record.mjs`) encodes the cwd
1461
+ exactly as omp names its session directories — see its comment for the rule — and hand-guessing that path is why
1463
1462
  the fleet's own panel once rendered nothing here. The trailing `/` on the glob matters:
1464
1463
  the same encoded-cwd directory also holds this cwd's own top-level session
1465
1464
  transcripts as loose FILES sibling to the per-session directories, and a
@@ -4162,7 +4161,9 @@ live count from it, so nobody states one. Write neither by hand:
4162
4161
  each PR from then on — but only when `#N`'s row named no PR before this
4163
4162
  write (a second `PR#` on it would misattribute the fold, or bury `#N`'s own
4164
4163
  fresher `review=` state under an older one) and no implementer claims `#M`'s
4165
- 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.
4166
4167
  - **`ledger.mjs review <pr> <token>…`** — the only writer of `review=` and
4167
4168
  `reviewed=` (below): appends each to the PR's row — the ticket row once
4168
4169
  `settle impl-<N>=PR#M` has run, else `#M`, created when neither exists —
@@ -4193,7 +4194,7 @@ permanent settle. It refuses a write that adds a `review=`/`reviewed=` token
4193
4194
  (one the row already holds is carried), and one after which a PR maps to more
4194
4195
  than one row when it did not before — `row <M>` creating `#M` for a PR a ticket
4195
4196
  row maps, or a rewrite adding a `PR#M` mention to another row — naming the
4196
- PR's row.
4197
+ PR's row (`settle impl-N=PR#M` applies the same rule after its fold).
4197
4198
 
4198
4199
  `→ PR#M` stays as the human-readable arrow; the tick reads only the `=`
4199
4200
  tokens. `tier=<cell>` marks an Exploration Pull's cell and `route=<REASON>` a router fallback (phase 2), and `excluded ·