@feigi/fleet-ctl 3.71.12 → 3.71.13

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.
@@ -227,6 +227,6 @@ cause is one word of the ledger's `halted:<cause>` vocabulary:
227
227
  duty 1's verdict names it, and `other` for every other halt — that
228
228
  verdict's own `other`, and a halt at duty 2, duty 3 or the instrument
229
229
  re-check. A duty 1 halt's `evidence` carries the verdict as
230
- printed, the JSON line, so a `rebase` halt's carries the output of
231
- `git cherry <pin> HEAD origin/main`. Then send the one line your brief gives,
230
+ printed, the JSON line, so a `rebase` halt's carries `replay`,
231
+ `rangeDiff` and `remote`. Then send the one line your brief gives,
232
232
  `<your name>: <outcome> <path>`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.71.12",
3
+ "version": "3.71.13",
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": {
@@ -72,8 +72,19 @@
72
72
  // newest entry is the move that put HEAD where it is.
73
73
  // - a `reset` or `rebase` entry: `rebase`. The branch replayed onto a new
74
74
  // base - its own commits on a new parent, content-identical only on a
75
- // conflict-free replay. Evidence: the reflog line and the output of
76
- // `git cherry <pin> HEAD origin/main`, run in the worktree.
75
+ // conflict-free replay. Evidence: `replay`, the verdict of `git range-diff
76
+ // --no-patch origin/main <pin> HEAD` run in the worktree; `rangeDiff`, that
77
+ // output (or the error that stopped it); and `remote`, read as `past-pin`
78
+ // reads it. `pure` only when every pinned commit pairs with an unchanged
79
+ // one. A dropped, edited or added commit, or a stale `origin/main`, is
80
+ // `changed`; a listing that cannot be read is `unknown`. `range-diff`
81
+ // lists non-merge commits only, so a merge commit in either range is
82
+ // `changed` as well: its own content - an evil merge, a conflict resolved
83
+ // inside it - would otherwise leave no line. Not `git cherry`: it lists
84
+ // only the head-side commits, reads a whitespace-only edit as unchanged,
85
+ // and reads a conflict resolved to main's side as nothing at all.
86
+ // `range-diff` pairs both sides of the replay, so each of those is an
87
+ // unpaired line.
77
88
  // - a plain `commit` entry: `past-pin`. A member kept working after the
78
89
  // dispatch. Evidence: `git log -1 --format='%h %s'` and whether that
79
90
  // commit is pushed, unpushed or unknown, read from `git ls-remote origin
@@ -210,6 +221,34 @@ function git(step, args, { soft = false, timeout } = {}) {
210
221
  return { ok: true, out: r.stdout, error: null };
211
222
  }
212
223
 
224
+ // The remote ref of `branch`, the row's, against `head`. Only a successful read
225
+ // settles pushed against unpushed; a failed read, a timeout, or a detached HEAD
226
+ // is `unknown`.
227
+ function remoteState(branch, head) {
228
+ if (typeof branch !== "string" || branch === "" || branch === "DETACHED") {
229
+ return { state: "unknown", error: "detached HEAD: no branch to ask the remote about" };
230
+ }
231
+ const ref = `refs/heads/${branch}`;
232
+ const r = git("ls-remote", ["ls-remote", "origin", ref], { soft: true, timeout: LS_REMOTE_TIMEOUT_MS });
233
+ if (!r.ok) return { state: "unknown", ref, error: r.error };
234
+ const line = r.out.split("\n").find((l) => l.split("\t")[1] === ref);
235
+ const sha = line === undefined ? null : line.split("\t")[0];
236
+ return { state: sha === head ? "pushed" : "unpushed", ref, sha };
237
+ }
238
+
239
+ // `git range-diff` prints one line per pairing, `<n>: <sha> <marker> <m>: <sha>
240
+ // <subject>`, with `-:` on the side a commit is missing from, and nothing after
241
+ // the second sha for a commit whose subject is empty. The replay is pure only
242
+ // when every line is a pairing marked `=`; an empty listing pairs nothing and
243
+ // is not pure. A merge commit never gets a line, so `merges`, the count of
244
+ // them in either range, above zero is not pure either.
245
+ const RANGE_PAIR = /^\s*\S+:\s+\S+\s+([=!<>])\s+\S+:\s+\S+(?:\s|$)/;
246
+ function replayVerdict(rangeDiff, merges) {
247
+ if (!rangeDiff.ok) return "unknown";
248
+ const lines = rangeDiff.out.split("\n").filter((l) => l.trim() !== "");
249
+ return merges === 0 && lines.length > 0 && lines.every((l) => RANGE_PAIR.exec(l)?.[1] === "=") ? "pure" : "changed";
250
+ }
251
+
213
252
  // --- 1: the row --------------------------------------------------------------
214
253
  const audit = run("sh", [AUDIT], { cwd: repo });
215
254
  if (audit.error || audit.signal || audit.status !== 0) {
@@ -266,27 +305,17 @@ const subject = move === null ? "" : (/^\S+ [^\s:]*@\{\d+\}: (.*)$/.exec(move)?.
266
305
  evidence.reflog = move;
267
306
 
268
307
  if (/^(reset|rebase)\b/.test(subject)) {
269
- const cherry = git("cherry", ["cherry", pin, "HEAD", "origin/main"], { soft: true });
270
- evidence.cherry = cherry.ok ? cherry.out : { error: cherry.error };
308
+ const rangeDiff = git("range-diff", ["range-diff", "--no-color", "--no-patch", "--creation-factor=60", "origin/main", pin, "HEAD"], { soft: true });
309
+ const merges = rangeDiff.ok ? Number(git("merges", ["rev-list", "--merges", "--count", "^origin/main", pin, "HEAD"]).out.trim()) : 0;
310
+ evidence.replay = replayVerdict(rangeDiff, merges);
311
+ evidence.rangeDiff = rangeDiff.ok ? rangeDiff.out : { error: rangeDiff.error };
312
+ evidence.remote = remoteState(row.branch, head);
271
313
  halt("rebase");
272
314
  }
273
315
 
274
316
  if (/^commit\b/.test(subject)) {
275
317
  evidence.commit = git("log", ["log", "-1", "--format=%h %s"]).out.trim();
276
- const branch = row.branch === "DETACHED" ? null : row.branch;
277
- if (typeof branch !== "string" || branch === "") {
278
- evidence.remote = { state: "unknown", error: "detached HEAD: no branch to ask the remote about" };
279
- } else {
280
- const ref = `refs/heads/${branch}`;
281
- const r = git("ls-remote", ["ls-remote", "origin", ref], { soft: true, timeout: LS_REMOTE_TIMEOUT_MS });
282
- if (!r.ok) {
283
- evidence.remote = { state: "unknown", ref, error: r.error };
284
- } else {
285
- const line = r.out.split("\n").find((l) => l.split("\t")[1] === ref);
286
- const sha = line === undefined ? null : line.split("\t")[0];
287
- evidence.remote = { state: sha === head ? "pushed" : "unpushed", ref, sha };
288
- }
289
- }
318
+ evidence.remote = remoteState(row.branch, head);
290
319
  halt("past-pin");
291
320
  }
292
321
 
@@ -1118,7 +1118,7 @@ decides the rest — two resolve automatically, every other one escalates:
1118
1118
  |---|---|
1119
1119
  | `live-editor` | **Automatic.** Ask the live member **by name** for its report, wait for it, then dispatch `finisher-pr-<M>-b` at the current head. If the head moved in the meantime, resolve it as `past-pin` instead. |
1120
1120
  | `past-pin` | **Automatic, through the tick: re-review.** The head carries commits no reviewer read. The tick prints `DISPATCH review PR#<M>` for a PR whose latest finisher is `halted:past-pin` and whose latest `reviewed=<head>` is not its current head, until a review of it is running or has returned; record that review's tokens as any review's, with `ledger.mjs review <M>` onto the PR's row, its runner under the next letter the PR's rows do not carry yet (`review-pr-<M>-b`, or `-c` where a retry already took `-b`) — `review` refuses a second `review-pr-<M>` and names the free one — and its result reaches a fresh finisher through the same gate. |
1121
- | `rebase` | **Escalate** — comment and flag, nothing more. Read the report's `git cherry <pin> HEAD origin/main`: only `-` lines is a clean rebase, and a `+` line is a conflict resolution that changed content or a commit past the pin. No automatic rule until a live halt shows the case recurring. |
1121
+ | `rebase` | **Escalate** — comment and flag, nothing more. The report's `evidence.replay` reads `pure` only when `git range-diff origin/main <pin> HEAD` pairs every pinned commit with an unchanged one; `changed` (a commit dropped, edited or added, or a stale `origin/main`) or `unknown` means read `evidence.rangeDiff` before acting, and `evidence.remote.state` says whether that head is on the PR. No automatic rule until a live halt shows the case recurring. |
1122
1122
  | `unreadable`, `missing`, `absent`, `other` | **Escalate** — comment and flag, no automatic retry. |
1123
1123
 
1124
1124
  ### Why a `past-pin` halt needs the tick
@@ -1904,8 +1904,8 @@ refuses a finisher brief rendered without it.
1904
1904
  duty 1's verdict names it, and `other` for every other halt — that
1905
1905
  verdict's own `other`, and a halt at duty 2, duty 3, the instrument
1906
1906
  re-check or the CI gate. A duty 1 halt's report carries the verdict as
1907
- printed, the JSON line, so a `rebase` halt's report carries the output of
1908
- `git cherry <pin> HEAD origin/main` that its `evidence` holds.
1907
+ printed, the JSON line, so a `rebase` halt's report carries `replay`,
1908
+ `rangeDiff` and `remote` from its `evidence`.
1909
1909
 
1910
1910
  **Once the label is on, take it off before you approve any push.** The label is a
1911
1911
  verdict on the tree the finisher read, and a GitHub label does not follow the