@feigi/fleet-ctl 3.158.5 → 3.158.7

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.158.5",
3
+ "version": "3.158.7",
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": {
@@ -113,6 +113,13 @@ export function memberTokens(text) {
113
113
  return text.split(/\s+/).filter(Boolean).map(parseToken).filter(Boolean);
114
114
  }
115
115
 
116
+ /** Whether `word` is a settled member token: one parseToken() reads with no
117
+ * error and an outcome. */
118
+ function isSettledToken(word) {
119
+ const t = parseToken(word);
120
+ return t !== null && t.error === null && t.outcome !== null;
121
+ }
122
+
116
123
  /** The dispatch-prompt.mjs role a member of `family` is rendered as. */
117
124
  export function memberRole(family) {
118
125
  return FAMILIES[family].role;
@@ -511,6 +518,24 @@ export function gateVerdictRefusal(oldLine, line) {
511
518
  return `reorders its Gate verdicts — ${carried}`;
512
519
  }
513
520
 
521
+ /**
522
+ * Why `ledger.mjs row` must not write `line` over `oldLine` (null for a new
523
+ * row), or null when it may: every settled member token the row holds — a
524
+ * token parseToken() reads with no error and an outcome — must be on the
525
+ * rewrite as the row holds it, duplicates counted. A token whose outcome
526
+ * changed is a dropped one, since its old text is gone. The reason names the
527
+ * first dropped token, in the row's order. A live member token may come or go,
528
+ * and a malformed one may be dropped (adding one is refused by the caller's
529
+ * own malformed-token check), so a row can still be repaired.
530
+ */
531
+ export function settledMemberRefusal(oldLine, line) {
532
+ const settled = (text) => (text === null ? [] : text.split(/\s+/).filter(isSettledToken));
533
+ const lost = added(settled(line), settled(oldLine))[0];
534
+ if (lost === undefined) return null;
535
+ return `drops settled member token '${lost}' — a rewrite must carry every settled member token as the row holds it; `
536
+ + "pass the complete reconstructed line, use `ledger.mjs token` to add a non-member token, and `ledger.mjs read` to look a row up";
537
+ }
538
+
514
539
  // Every row key a ledger's rows map to each PR number under rowNums(), in
515
540
  // ledger order.
516
541
  function prRowKeys(rows) {
@@ -634,8 +659,7 @@ export function rowWriteRefusal(before, after, oldLine, line, retired = []) {
634
659
  export function settledOnLedger(rows, dispatched) {
635
660
  const settled = new Set();
636
661
  for (const e of dispatched) {
637
- const t = parseToken(e);
638
- if (t !== null && t.error === null && t.outcome !== null) settled.add(t.name);
662
+ if (isSettledToken(e)) settled.add(parseToken(e).name);
639
663
  }
640
664
  for (const text of rows) {
641
665
  const { pr } = rowNums(text);
@@ -45,9 +45,12 @@
45
45
  // and `review --result` for the third, which it derives from the review's
46
46
  // result file and refuses as an argument. `token`
47
47
  // refuses all three, and `row` carries every Gate verdict exactly as the row
48
- // holds it, so no other verb adds, changes or drops one. `filed` appends
49
- // filings, and all writes are serialized by `<file>.lock`; the other tokens
50
- // of a row are freeform to the writers that have them (`row`/`token`/
48
+ // holds it, so no other verb adds, changes or drops one. `row` likewise
49
+ // carries every settled member token — a member token with an outcome — as
50
+ // the row holds it, so a `row` call made as a lookup cannot erase the row's
51
+ // PR mapping; a live or malformed member token it may still drop. `filed`
52
+ // appends filings, and all writes are serialized by `<file>.lock`; the other
53
+ // tokens of a row are freeform to the writers that have them (`row`/`token`/
51
54
  // `settle`/`dispatch`/`drain`/`ruled`/`rotate`). Every write subcommand
52
55
  // except `rotate` — which moves the file whole and never loads it, see
53
56
  // runRotate() — rewrites the WHOLE file
@@ -71,7 +74,7 @@ import { spawnSync, execFileSync } from "node:child_process";
71
74
  import { makeDie, isFlagLike, hasEqualsForm, isDigits, writeAll } from "./arg.mjs";
72
75
  import { fleetFile, FleetDirUnresolvable } from "./fleet-dir.mjs";
73
76
  import { readReceipt } from "./phase0-receipt.mjs";
74
- import { parseMember, parseToken, memberTokens, nextMergeBot, nextRetry, liveOnLedger, settledOnLedger, retiredOnLedger, retiredName, readRetired, agentDefinition, expectedDefinition, CELL, POLICY_CELL, tierValues, cellValues, decidingCell, rowPr, rowNums, rowWriteRefusal, isReviewToken, addedReviewToken, isDispositionsWord, gateVerdictWriter, gateVerdictRefusal, newSplitRow, splitRowClause, added, premisesOf, MEMBER_FAMILIES, HALT_CAUSES, ROWS, DISPATCHED, ROUTED, FILED, RULED, DRAIN, RETIRED, RECEIPT, archiveStamp, receiptArchiveName, CLOSEOUT_RECEIPT, closeoutArchiveName, BRIEFS, briefsArchiveName, memberRole, parseDispatchedEntry, dispatchedEntry, parseRouting, parseRoutedEntry, routedEntry, headerRe, escapeText, ledgerSection, nextReviewerName, isOmpSessionDirName } from "./ledger-grammar.mjs";
77
+ import { parseMember, parseToken, memberTokens, nextMergeBot, nextRetry, liveOnLedger, settledOnLedger, retiredOnLedger, retiredName, readRetired, agentDefinition, expectedDefinition, CELL, POLICY_CELL, tierValues, cellValues, decidingCell, rowPr, rowNums, rowWriteRefusal, isReviewToken, addedReviewToken, isDispositionsWord, gateVerdictWriter, gateVerdictRefusal, settledMemberRefusal, newSplitRow, splitRowClause, added, premisesOf, MEMBER_FAMILIES, HALT_CAUSES, ROWS, DISPATCHED, ROUTED, FILED, RULED, DRAIN, RETIRED, RECEIPT, archiveStamp, receiptArchiveName, CLOSEOUT_RECEIPT, closeoutArchiveName, BRIEFS, briefsArchiveName, memberRole, parseDispatchedEntry, dispatchedEntry, parseRouting, parseRoutedEntry, routedEntry, headerRe, escapeText, ledgerSection, nextReviewerName, isOmpSessionDirName } from "./ledger-grammar.mjs";
75
78
  import { deriveRun, LedgerError, labelOffMember, CONFLICT_HOLD, PARKED } from "./fleet-tick.mjs";
76
79
  import { stateFileIn, readState, writeState, assessBeat, stallsAt } from "./fleet-state.mjs";
77
80
  import { processSource, ancestry, controllerOf, judgeController, ProcUnreadable } from "./proc.mjs";
@@ -812,6 +815,11 @@ if (cmd === "read") {
812
815
  // also refuses a whole-row wipe of a row that holds one.
813
816
  const gateWhy = gateVerdictRefusal(oldRow, line);
814
817
  if (gateWhy !== null) die(`row ${key}: ${gateWhy}`);
818
+ // Every settled member token is the PR's mapping and the member's record, so
819
+ // a rewrite carries each as the row holds it — a `row` call made as a lookup
820
+ // would otherwise sever the PR from its ticket.
821
+ const settledWhy = settledMemberRefusal(oldRow, line);
822
+ if (settledWhy !== null) die(`row ${key}: ${settledWhy}`);
815
823
  // Every token about a PR lives on the PR's row, so a write that makes a PR
816
824
  // map to a second row splits its history across two rows the tick reads in
817
825
  // row order, not write order. Added only: a split already on disk is
@@ -194,7 +194,7 @@
194
194
 
195
195
  import { spawn, spawnSync } from "node:child_process";
196
196
  import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
197
- import { dirname, join, resolve } from "node:path";
197
+ import { basename, dirname, isAbsolute, join, resolve } from "node:path";
198
198
  import { fileURLToPath } from "node:url";
199
199
  import { makeDie, defineFlags, isDigits } from "./arg.mjs";
200
200
  import { alarmFile } from "./controller-alarm.mjs";
@@ -599,10 +599,24 @@ function shortlist({ cwd }) {
599
599
  return ok("shortlist built");
600
600
  }
601
601
 
602
+ // The same `.fleet/` by the directory it names: the checkout holding it is
603
+ // resolved through symlinks and the `.fleet` name kept, so it works before
604
+ // `.fleet/` exists. A path that is not absolute, or whose checkout does not
605
+ // resolve, stays as given.
606
+ function fleetIdentity(path) {
607
+ if (typeof path !== "string" || !isAbsolute(path)) return path;
608
+ try {
609
+ return join(realpathSync(dirname(path)), basename(path));
610
+ } catch {
611
+ return path;
612
+ }
613
+ }
614
+
602
615
  // The controller alarm: this omp's own record that its timer is armed against
603
616
  // this checkout's `.fleet/` (controller-alarm.mjs writes it at session_start).
604
617
  // The record is read, not trusted: it must name this omp's pid and start time
605
- // and this `.fleet/`.
618
+ // and this `.fleet/` — the same directory, whichever way omp and this process
619
+ // each spell the path to it. Messages print both as spelled.
606
620
  function alarm({ fleetDir }) {
607
621
  const tail = " — restart omp";
608
622
  let controller;
@@ -633,7 +647,7 @@ function alarm({ fleetDir }) {
633
647
  if (missing.length > 0) return failed(`controller alarm file ${path} lacks ${missing.join(", ")}${tail}`);
634
648
  if (rec.pid !== controller.pid) return failed(`controller alarm file ${path} names pid ${rec.pid}, but this omp is pid ${controller.pid}${tail}`);
635
649
  if (rec.lstart !== controller.lstart) return failed(`controller alarm file ${path} was written by a process started at "${rec.lstart}", but this omp started at "${controller.lstart}"${tail}`);
636
- if (rec.fleet !== fleetDir) return failed(`controller alarm file ${path} names fleet "${rec.fleet}", not ${fleetDir}${tail}`);
650
+ if (fleetIdentity(rec.fleet) !== fleetIdentity(fleetDir)) return failed(`controller alarm file ${path} names fleet "${rec.fleet}", not ${fleetDir}${tail}`);
637
651
  return ok(`controller alarm armed: pid ${controller.pid}, ${fleetDir}`);
638
652
  }
639
653
 
@@ -213,7 +213,7 @@ Write each state change through `ledger.mjs` before you act on it, never by hand
213
213
 
214
214
  Compaction parks every in-flight member and nothing reports it, so on resume take the registry census first (**Member unaccounted**, in **Failure handling**) before you trust a live token.
215
215
 
216
- `ledger.mjs token <key> <token>…` adds a token and keeps every token already on the row but a `tier=` it replaces; `row` drops the tokens you do not restate. Write member tokens and `review=` tokens only through `ledger.mjs`, never by hand.
216
+ `ledger.mjs token <key> <token>…` adds a token and keeps every token already on the row but a `tier=` it replaces; `row` drops tokens you omit but refuses to drop a settled member token. Write member and `review=` tokens only through `ledger.mjs`.
217
217
 
218
218
  Never rotate the ledger mid-run: it is phase 0's step alone.
219
219
 
@@ -118,4 +118,4 @@ The ledger half reports its own readability as its own field, `ledger.ok`, the p
118
118
 
119
119
  ## Adding a token
120
120
 
121
- Token additions go through `ledger.mjs token`. `ledger.mjs token <key> <token>…` adds a token and keeps every token already on the row. A `tier=` replaces the row's `tier=` instead and keeps every other token, a `cell=` beside it included, which the `tier=` then overrides; while the row's implementer has not settled, `token` and `row` both refuse a write that changes the row's cell. Re-typing the row with `row` replaces the whole line, so it drops the tokens you do not restate.
121
+ Token additions go through `ledger.mjs token`. `ledger.mjs token <key> <token>…` adds a token and keeps every token already on the row. A `tier=` replaces the row's `tier=` instead and keeps every other token, a `cell=` beside it included, which the `tier=` then overrides; while the row's implementer has not settled, `token` and `row` both refuse a write that changes the row's cell. Re-typing the row with `row` replaces the whole line, so it drops the tokens you do not restate — except a settled member token (`impl-<N>=PR#<M>`, `fix-pr-<M>=applied:<head>`, `finisher-pr-<M>=labelled`, any well-formed member token carrying an outcome), which `row` refuses to drop: it exits 2 and writes nothing for a rewrite that omits one or changes its outcome, naming the first, so a rewrite carries every settled member token as the row holds it, in any order. A live member token, and a malformed one, may still be dropped; every other dropped token is written and listed on stderr. `row` is not a lookup: read a row with `ledger.mjs read`, which writes nothing.
@@ -659,8 +659,12 @@ files under `<scratch>/impl-<N>/`). Record it the ordinary way —
659
659
  "impl-<N>-b"`, then `dispatch-prompt.mjs render implementer --member
660
660
  impl-<N>-b …`, then `ledger.mjs dispatch <N> impl-<N>-b`, then the `task`
661
661
  call naming the `agent` it printed, then the tier check — and never
662
- `claim-ticket.sh`: the claim already stands. A re-run finds the need met
663
- once its row is written. A `report` goes to the
662
+ `claim-ticket.sh`: the claim already stands. A `replace #N` writes onto a
663
+ row that already stands, holding the closed PR's settled `impl-<N>=PR#<M>`,
664
+ which `row` refuses to drop, so its row write carries the row whole, the
665
+ way `release #N`'s does: `ledger.mjs row <N> "<text> · impl-<N>-b"`,
666
+ `<text>` the row as `ledger.mjs read` prints it, past its leading `#<N>`.
667
+ A re-run finds the need met once its row is written. A `report` goes to the
664
668
  maintainer as `#<N> — <why>` and nothing else: no dispatch, no label change,
665
669
  no release. One whose `why` reads `PR #<M> closed unmerged` waits on the
666
670
  maintainer's `replace #<N>` or `release #<N>`, the two words the tick's