@feigi/fleet-ctl 3.23.37 → 3.23.39

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.23.37",
3
+ "version": "3.23.39",
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": {
@@ -66,7 +66,7 @@ import { readFileSync } from "node:fs";
66
66
  import { makeDie, defineFlags } from "./arg.mjs";
67
67
  import { isCLI } from "./is-cli.mjs";
68
68
  import { CELL, POLICY_CELL } from "./ledger-grammar.mjs";
69
- import { parseTsv as parseMemberTsv } from "./member-outcomes.mjs";
69
+ import { formatTsv as formatMemberTsv, parseTsv as parseMemberTsv } from "./member-outcomes.mjs";
70
70
  import { parseFeatures } from "./pr-cost.mjs";
71
71
  import { VERDICT, VERDICT_COLUMNS } from "./tier-outcomes.mjs";
72
72
 
@@ -103,16 +103,33 @@ function admissibleMember(pull, members) {
103
103
  return m;
104
104
  }
105
105
 
106
+ // One member row per session+agent. A key repeated with different fields is
107
+ // refused rather than collapsed to whichever row came last; an identical
108
+ // repeat is one row.
109
+ function indexMembers(members) {
110
+ const byKey = new Map();
111
+ for (const m of members) {
112
+ const k = key(m.session, m.agent);
113
+ const held = byKey.get(k);
114
+ if (held && formatMemberTsv([held]) !== formatMemberTsv([m])) {
115
+ throw new Error(`member-outcomes session ${m.session} agent ${m.agent} has two rows with different fields`);
116
+ }
117
+ if (!held) byKey.set(k, m);
118
+ }
119
+ return byKey;
120
+ }
121
+
106
122
  /**
107
123
  * `cells`: one entry per cell other than the policy cell that has a
108
124
  * ticket-features row, `{ cell, comparisons, runDates, dates, models, gated }`,
109
125
  * sorted by cell. `dates` is the comparisons' distinct run_dates, sorted;
110
126
  * `models` maps each resolved model of the cell's admissible rows to its row
111
127
  * count, largest first. `unjoined` counts Pulls with no member row. Throws on
112
- * two ticket-features rows of one session+agent naming different cells.
128
+ * two ticket-features rows of one session+agent naming different cells, and on
129
+ * a member-outcomes session+agent repeated with different fields.
113
130
  */
114
131
  export function readout({ features, members }) {
115
- const byKey = new Map(members.map((m) => [key(m.session, m.agent), m]));
132
+ const byKey = indexMembers(members);
116
133
  const pulls = pullsOf(features);
117
134
  const sessions = new Map();
118
135
  const cells = new Map();
@@ -152,11 +169,12 @@ export function readout({ features, members }) {
152
169
  * sorted by ticket, `run_date` the ruling's; `stop` is whether the stopping
153
170
  * rule withdraws the cell. `verdicts` are parsed tier-outcomes.tsv rows.
154
171
  * Throws on a counted ruling whose `closed_own_ticket` or `minted_false_claim`
155
- * is not `yes` or `no`, and on a non-blank ruling row of a Pulled ticket whose
156
- * `run_date` is not `YYYY-MM-DD`.
172
+ * is not `yes` or `no`, on a non-blank ruling row of a Pulled ticket whose
173
+ * `run_date` is not `YYYY-MM-DD`, and on a member-outcomes session+agent
174
+ * repeated with different fields.
157
175
  */
158
176
  export function stoppingRule({ features, members, verdicts, added }) {
159
- const byKey = new Map(members.map((m) => [key(m.session, m.agent), m]));
177
+ const byKey = indexMembers(members);
160
178
  const rulings = new Map();
161
179
  for (const v of verdicts) {
162
180
  if (VERDICT_COLUMNS.every((c) => v[c] === "")) continue;
@@ -217,12 +235,21 @@ function main() {
217
235
  try { return parse(text); }
218
236
  catch (e) { die(`${path}: ${e.message}`); }
219
237
  };
220
- const features = load(featuresPath, parseFeatures);
221
- const members = load(membersPath, parseMemberTsv);
238
+ // A repeated session+agent naming different cells, or a member-outcomes one
239
+ // repeated with different fields, is refused while its file is loaded, so the
240
+ // refusal names the path that was read.
241
+ const features = load(featuresPath, (text) => {
242
+ const rows = parseFeatures(text);
243
+ pullsOf(rows);
244
+ return rows;
245
+ });
246
+ const members = load(membersPath, (text) => {
247
+ const rows = parseMemberTsv(text);
248
+ indexMembers(rows);
249
+ return rows;
250
+ });
222
251
 
223
- let cells, unjoined;
224
- try { ({ cells, unjoined } = readout({ features, members })); }
225
- catch (e) { die(`${featuresPath}: ${e.message}`); }
252
+ const { cells, unjoined } = readout({ features, members });
226
253
  const lines = [];
227
254
  const notes = [];
228
255
  if (unjoined > 0) {
@@ -804,30 +804,30 @@ install that rewrites the tree in a throwaway worktree corrupts it for everyone.
804
804
  No cache is phase 0's Recipe derivation step not having run; an invalid one is
805
805
  its re-derive-once rule.
806
806
 
807
- **Materialize the isolation envelope as a file, not a briefing.** The runner is
808
- tracked at the repo root since #55, so every checkout has one; it derives its
809
- ports from the worktree's own `<N>-slug` directory name (so collisions stay
810
- impossible) and materializes the current runner from the one emitter rather than
811
- carrying a copy of it. Brief members with `./agent-test
812
- <file-or-dir>` and nothing else — anyone who finds the worktree finds the
813
- runner, including grandchildren you never dispatched. A directory works too and
814
- expands to the test files under it; one holding none refuses rather than passing
815
- vacuously, so a mistyped file or directory path cannot come back green. See
807
+ **Materialize the isolation envelope as a file, not a briefing.** The claim
808
+ writes the runner, `agent-test`, into the fresh worktree it creates: an exec of
809
+ the Recipe's Test entrypoint that exports one port triple derived from `<N>`
810
+ (so collisions stay impossible), kept out of `git status` through the
811
+ repository's exclude file. A repository that tracks its own `agent-test` keeps
812
+ it byte-identical, with whatever isolation that repository built. Brief members
813
+ with `./agent-test` and nothing else — anyone who finds the worktree finds the
814
+ runner, including grandchildren you never dispatched. Its arguments land after
815
+ the Test entrypoint, so what one may name — a test file, a test name — is that
816
+ entrypoint's to say, and nothing in the runner refuses one that selects no
817
+ test: a run of zero tests is a failed run, not a pass. See
816
818
  references/isolation.md.
817
819
 
818
- **A reused worktree may lack the runner** — no longer here, and still can
819
- elsewhere. `claim-ticket.sh` used to write `agent-test` only when it claimed a
820
- *fresh* worktree, so a worktree carried over from a prior run, or an already-open
821
- PR's worktree you sent a rebaser/resolver into, had no `./agent-test` and the
822
- member stalled on a missing script (observed with a rebase-resolver in a
823
- prior-run worktree). #55 tracked the runner, so any worktree checked out from
824
- `origin/main` now carries it. A tree that is NOT a checkout — a `git archive`
825
- snapshot, a `cp -R` subset — still has whatever was copied into it, and a repo
826
- that tracks no runner never had one: there, tell the member the runner is absent
827
- and to run docker-free suites directly — the Recipe's Test entrypoint
828
- (`~/.fleet/bin/fleet-run derive-testcmd.sh <main checkout> test` prints it) only
829
- when it brings up no shared stack to collide on, else that repo's own stack-free
830
- command.
820
+ **A reused worktree may lack the runner.** `claim-ticket.sh` writes
821
+ `agent-test` only into the fresh worktree it claims, so a tree no claim
822
+ built — an already-open PR's worktree you sent a rebaser/resolver into,
823
+ a `git archive` snapshot, a `cp -R` subset — has no `./agent-test`
824
+ unless the repository tracks its own, and a member told to run one
825
+ stalls on a missing script (observed with a rebase-resolver in a
826
+ prior-run worktree). There, tell the member the runner is absent and to
827
+ run docker-free suites directly — the Recipe's Test entrypoint
828
+ (`~/.fleet/bin/fleet-run derive-testcmd.sh <main checkout> test` prints
829
+ it) only when it brings up no shared stack to collide on, else that
830
+ repo's own stack-free command.
831
831
 
832
832
  **A reused worktree may also be on the wrong COMMIT.** `git worktree add <path>
833
833
  <branch>` checks out the existing LOCAL branch and never consults the remote, so
@@ -2667,9 +2667,9 @@ a minute apart showed *different* mutants, so a member's report and any single
2667
2667
  because the dirt may be someone's only copy. Here nothing in it is anyone's.
2668
2668
  Nothing sweeps a leak for you either: `reap.sh`'s branchless sweep is bounded
2669
2669
  to the fleet's worktree home, so a tree under `<scratch>` is a `kept` entry
2670
- it reports and never collects. The tree you added is a checkout, so since #55
2671
- it carries the tracked `./agent-test` like any other — run either that or
2672
- `<testCmd>` in it, per **A reused worktree may lack the runner** above.
2670
+ it reports and never collects. No claim built the tree you added, so it has
2671
+ `./agent-test` only if the repository tracks one — run that or `<testCmd>`
2672
+ in it, per **A reused worktree may lack the runner** above.
2673
2673
 
2674
2674
  **None of this licenses a write to the owned worktree.** Duty 1 is a read;
2675
2675
  you never restore that tree, because you never wrote to it. A controller
@@ -3465,10 +3465,10 @@ failures arrive as *wrong findings*, not errors:
3465
3465
  truncates, and the truncation reads as an absence): an invocation carrying an
3466
3466
  **absolute** path puts a member-unique string in argv, while one carrying
3467
3467
  repo-relative filenames is byte-identical across members. Which of the two you
3468
- get is not yours to choose — members are briefed on `./agent-test
3469
- <file-or-dir>` over the suite under `plugin/scripts/`, and that runner `exec`s
3470
- node with the file list its caller's shell already expanded, never a literal
3471
- glob. Clearing your own leftover process needs its PID, not a pattern.
3468
+ get is not yours to choose — members are briefed on `./agent-test` with the
3469
+ arguments the Test entrypoint takes, and the runner hands them on exactly as
3470
+ its caller's shell expanded them. Clearing your own leftover process needs its
3471
+ PID, not a pattern.
3472
3472
 
3473
3473
  Members report a stalled run to the controller instead of pattern-killing it,
3474
3474
  and the controller re-checks any measurement taken in the window.
@@ -3497,19 +3497,19 @@ failures arrive as *wrong findings*, not errors:
3497
3497
  It owns the object-store rule, the two-tree split, snapshot provisioning, and
3498
3498
  which suites a snapshot cannot validly run. Your only duty is to *not*
3499
3499
  contradict it.
3500
- - **Filesystem isolation is not stack isolation.** A private copy of the tree and
3501
- a test command solve different problems; the compose project name comes from
3502
- the environment, not the working directory, so three agents on three snapshots
3503
- still collide on one postgres. "I'm on my own copy" is exactly the intuition
3504
- that skips the command — say both, every time. Which command depends on the
3505
- audience: a member in a worktree uses `./agent-test`; a specialist on a
3506
- snapshot does not — the runner that bootstrap materializes derives its
3507
- isolation triple from the directory name, and a snapshot is not a claimed
3508
- worktree, so every snapshot in the fleet gets the same fixed ports — and
3509
- takes the one `review-and-fix.md` hands out. The bootstrap itself now
3510
- SUCCEEDS there (the snapshot is a git repository since #1056), which is why
3511
- the reason to hand out a different command is the stack and not a
3512
- materialization failure. See references/isolation.md.
3500
+ - **Filesystem isolation is not stack isolation.** A private copy of the
3501
+ tree and a test command solve different problems; the compose project
3502
+ name comes from the environment, not the working directory, so three
3503
+ agents on three snapshots still collide on one postgres. "I'm on my own
3504
+ copy" is exactly the intuition that skips the command — say both, every
3505
+ time. Which command depends on the audience: a member in a worktree
3506
+ uses `./agent-test`; a specialist on a snapshot does not, and takes the
3507
+ one `review-and-fix.md` hands out. Which runner the worktree holds
3508
+ decides why: the runner a claim writes is untracked, so a `git archive`
3509
+ snapshot never carries it; one the repository tracks does ride along,
3510
+ but no claim exported ports into it — its isolation is whatever that
3511
+ repository built, not one triple per snapshot. See
3512
+ references/isolation.md.
3513
3513
  - **Scratchpad paths need two levels — the member's own partition, then one
3514
3514
  directory per child it dispatches — and nothing outside them.** An
3515
3515
  implementer partitions at `<scratch>/impl-<N>/`; the review side's partition
@@ -4,13 +4,13 @@ Why isolation envelope file not briefing, why private filesystem not private sta
4
4
 
5
5
  ## Materialize the isolation envelope as a file, not a briefing
6
6
 
7
- Env vars in prompt missed five times in one run — including briefed member, and specialist whose parent briefed but did not pass down. So the runner is a file, and since #55 a TRACKED one: `agent-test` sits at the repo root and comes with every checkout, worktree and clone. It is a bootstrap — it materializes the current runner from `claim-ticket.sh --write-runner` into the gitignored `.agent-test.sh` beside it and execs that — so there is still exactly one emitter, and no committed copy to freeze. Brief members with `./agent-test <file-or-dir>` and nothing else: anyone who finds worktree finds runner — including grandchildren you never dispatched. A directory works too and expands to the test files under it; one holding none refuses rather than passing vacuously — appending nothing leaves argv empty, and bare `node --test` then discovers whole worktree: green for suite nobody asked for. Ports derive from `<N>`, so collisions impossible not discouraged — difference between safeguard and rule.
7
+ Env vars in prompt missed five times in one run — including briefed member, and specialist whose parent briefed but did not pass down. So the runner is a file in the worktree. A claim writes `agent-test` into the fresh worktree it creates: an exec of the Recipe's Test entrypoint that exports one port triple derived from `<N>`, kept out of `git status` through the repository's exclude file. A repository that tracks its own `agent-test` keeps it byte-identical — the claim exports nothing into it, so its isolation is whatever that repository built, and any convenience beyond exec'ing the Test entrypoint is that runner's own to document. Brief members with `./agent-test` and nothing else: anyone who finds worktree finds runner — including grandchildren you never dispatched. Its arguments land after the Test entrypoint, so what one may name — a test file, a test name — is that entrypoint's to say, and nothing in the runner refuses one that selects no test: a run of zero tests is a failed run, not a pass. That triple makes collisions impossible, not discouraged — difference between safeguard and rule.
8
8
 
9
- The runner is re-materialized on every invocation, so no copy of it survives a run to go stale — which is what #55 bought beyond a runner in a fresh clone. Before it, the runner was written once at claim time and never rewritten, and every copy under `.worktrees/` was frozen at whenever that worktree was claimed; reading or measuring one measured that build, not what the current emitter produces. A copy that predates #55 is still such a build, and so is any runner a repo that tracks no bootstrap gets. Line 2 is what tells a reader which build they are holding: `# agent-test template: <cksum>`. Reproduce the number from the installed script (`cksum $(~/.fleet/bin/fleet-run --path claim-ticket.sh)`) or from any revision of it (`git show <rev>:plugin/scripts/claim-ticket.sh | cksum`) and compare the first field — `cksum` also prints a byte count, and the path when it is given a file. It checksums the whole emitting script, not the runner template inside it, so it over-reports: a mismatch means only that `claim-ticket.sh`'s bytes differ from the ones you checksummed — a reworded die message or an edited comment moves it while the runner it produces stays byte-identical — not "the template changed", and not "older" either, because `cksum` carries no order: over `claim-ticket.sh`'s own history both the checksum and the byte count fall as well as rise. It under-reports too, so a match is not the freshness proof it looks like. The stamp covers `claim-ticket.sh` and nothing else, while the entrypoint the runner `exec`s — and whether the directory-expansion shim is emitted at all — comes from the sibling `derive-testcmd.sh`, which is not checksummed: two byte-identical copies of `claim-ticket.sh` differing only in that sibling emit visibly different runners under one identical stamp. So read a match as "this runner came from these bytes of `claim-ticket.sh`", and re-materialize when you need the current runner rather than a matching number. Nothing reads the stamp and nothing refuses on a mismatch; it makes staleness legible to a human, it gates nothing.
9
+ The runner a claim writes is written once and never rewritten — a claim refuses a worktree that already exists — so every copy under `.worktrees/` is frozen at whenever that worktree was claimed; reading or measuring one measures that build, not what the current emitter produces. Line 2 is what tells a reader which build they are holding: `# agent-test template: <cksum>`. Reproduce the number from the installed script (`cksum $(~/.fleet/bin/fleet-run --path claim-ticket.sh)`) or from any revision of it (`git show <rev>:plugin/scripts/claim-ticket.sh | cksum`) and compare the first field — `cksum` also prints a byte count, and the path when it is given a file. It checksums the whole emitting script, not the runner template inside it, so it over-reports: a mismatch means only that `claim-ticket.sh`'s bytes differ from the ones you checksummed — a reworded die message or an edited comment moves it while the runner it produces stays byte-identical — not "the template changed", and not "older" either, because `cksum` carries no order: over `claim-ticket.sh`'s own history both the checksum and the byte count fall as well as rise. It under-reports too, so a match is not the freshness proof it looks like. The stamp covers `claim-ticket.sh` and nothing else, while the command the runner `exec`s is the Recipe cache's Test entrypoint, which it does not cover: two claims under one stamp exec different commands once the Recipe is re-derived between them. So read a match as "this runner came from these bytes of `claim-ticket.sh`"; only a fresh claim writes the current runner. Nothing reads the stamp and nothing refuses on a mismatch; it makes staleness legible to a human, it gates nothing.
10
10
 
11
11
  ## Filesystem isolation is not stack isolation
12
12
 
13
- Private copy and test command solve different problems; conflating them is how second gets skipped: compose project name comes from environment, not working directory, so three agents on three snapshots still collide on one postgres. Symlinking installed dependencies in does not help. "I'm on my own copy" is exactly the intuition that skips command — say both, every time. Which command depends on audience: member in worktree uses `./agent-test`; specialist on snapshot does not — the runner that bootstrap (#55) materializes derives its isolation triple from the directory name, and a snapshot is not a claimed worktree, so every snapshot gets the same fixed ports (measured in a snapshot: `ports derive from the issue number: postgres=16000 ollama=22000`) — and takes one `review-and-fix.md` hands out. The bootstrap no longer FAILS there: since #1056 the snapshot is a git repository, so `claim-ticket.sh --write-runner` succeeds in it, and the reason to hand a specialist a different command is the stack rather than a missing repo.
13
+ Private copy and test command solve different problems; conflating them is how second gets skipped: compose project name comes from environment, not working directory, so three agents on three snapshots still collide on one postgres. Symlinking installed dependencies in does not help. "I'm on my own copy" is exactly the intuition that skips command — say both, every time. Which command depends on audience: member in worktree uses `./agent-test`; specialist on snapshot does not, takes one `review-and-fix.md` hands out. Which runner the worktree holds decides why: the runner a claim writes is untracked, so a `git archive` snapshot never carries it; one the repository tracks does ride along, but no claim exported ports into it — its isolation is whatever that repository built, not one triple per snapshot.
14
14
 
15
15
  ## Scratchpad paths need two levels — the member's own partition, then one directory per child it dispatches
16
16
 
@@ -60,7 +60,7 @@ So nothing in the run cleans it up. Next run, the in-flight probe's local-worktr
60
60
 
61
61
  **The delete is `git update-ref -d`'s compare-and-swap (ADR 0018) here too, and for reap's reason** — authorized by the `ahead` and `git cherry` checks above, plus the `ahead` recount re-run against `origin/main` immediately before the delete itself (a commit can land across the `gh issue view` between the checks and the delete; `git cherry` is not re-run, because such a commit is ahead of `origin/main` by construction), plus a fresh check, re-read immediately before the delete, that no worktree holds the branch (`update-ref` consults no worktree, where `-D` refused a held branch; a worktree it cannot resolve, or a listing that will not re-read, stops the delete too), and by nothing else. A claim used to carry `origin/main` as its upstream, so `-d` compared against *that* and forgave a behind local main; since #760 `claim-ticket.sh` passes `--no-track` (so `@{u}` cannot silently answer about main), a claim has no upstream until its first `push -u`, and `-d` falls back to comparing against local `HEAD`. Measured: with local `main` behind `origin/main`, `-d` refuses a pristine claim — half-releasing it, worktree deleted and branch stranded with `in-progress` still on the ticket. The two checks above are strictly stronger than what `-d` would have asked, and both measure against `origin/main` rather than a local ref.
62
62
 
63
- **`worktree remove` without `--force`** refuses on modified and untracked files and deletes ignored files silently (verified, git 2.50.1). Ignored-silently is what is wanted: `./agent-test` materializes `.agent-test.sh` beside itself in every worktree it runs in (and before #55, `claim-ticket.sh` wrote an untracked `agent-test` into every worktree it claimed), so treating ignored files as dirt would strand every release. The same asymmetry is why the runner itself is tracked as a BOOTSTRAP rather than committed as a copy: a claim that overwrote a tracked `agent-test` would leave a modified tracked path, which this refusal does not forgive. Its refusal is the dirty check recomputed by git at the moment of the delete — for the live-directory case ONLY. `worktree remove` gates that clean check on the same `stat` the guard does, so it is not an independent second opinion: where the path cannot be stat'ed git reaches the same "gone" by the same means, accepts the entry at rc 0 and deregisters a worktree whose files are still on disk (measured, git 2.50.1: an untracked file in a worktree under a `chmod 000` parent). There the `gone` guard is sole arbiter — which is why it establishes absence instead of inferring it from a failed `-e`, and why the fail-open fixed in `1e54bac` survived being reasoned about: guard and backstop fail on the same inputs.
63
+ **`worktree remove` without `--force`** refuses on modified and untracked files and deletes ignored files silently (verified, git 2.50.1). Ignored-silently is what is wanted: `claim-ticket.sh` writes an `agent-test` into each fresh worktree it claims of a repository that tracks none, and ignores it through the repository's exclude file, so treating ignored files as dirt would strand every such release. The same asymmetry is why a claim never writes over a tracked `agent-test`: that write would leave a modified tracked path, which this refusal does not forgive. Its refusal is the dirty check recomputed by git at the moment of the delete — for the live-directory case ONLY. `worktree remove` gates that clean check on the same `stat` the guard does, so it is not an independent second opinion: where the path cannot be stat'ed git reaches the same "gone" by the same means, accepts the entry at rc 0 and deregisters a worktree whose files are still on disk (measured, git 2.50.1: an untracked file in a worktree under a `chmod 000` parent). There the `gone` guard is sole arbiter — which is why it establishes absence instead of inferring it from a failed `-e`, and why the fail-open fixed in `1e54bac` survived being reasoned about: guard and backstop fail on the same inputs.
64
64
 
65
65
  **A worktree that wandered off the branch blocks too.** The worktree is located by the branch it has checked out, and it does not stay there — an interrupted rebase leaves it detached, a member can switch it. The lookup then finds nothing, which reads as "no worktree of ours": the dirty check is skipped entirely and the release reports success while the worktree stands with the member's work in it, so the next run's probe still reads the ticket as taken. So a linked worktree at `claim-ticket.sh`'s `.worktrees/<issue>-<slug>` that is *not* on the branch is its own blocker — which remedy it names is the next paragraph, and is not always a hand-release. The path is read as the whole rest of the `worktree list --porcelain` line, never the first whitespace field, or every checkout under a directory with a space in its name reads as a different path.
66
66