@feigi/fleet-ctl 3.23.29 → 3.23.31

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.29",
3
+ "version": "3.23.31",
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": {
@@ -167,9 +167,11 @@ git rev-parse --verify "origin/main^{commit}" >/dev/null \
167
167
  # Recipe cache by derive-testcmd.sh — the one reader, reused rather than
168
168
  # reimplemented, so the claim and the review snapshot cannot disagree about
169
169
  # the cache's shape or what makes it usable. Nothing here infers either
170
- # command: an absent, unproven or unrunnable cache is derive-testcmd.sh's own
171
- # refusal, passed through in its own words, which name the step that derives
172
- # the Recipe.
170
+ # command: every derive-testcmd.sh refusal is passed through in its own words.
171
+ # A refusal about the cache (absent, unproven or invalid) names the step that
172
+ # derives the Recipe; an exit-3 refusal names an environment fault, and the
173
+ # caller fixes that instead of deriving. Both leave here as this script's exit
174
+ # 2, so only the words tell them apart.
173
175
  #
174
176
  # `2>&1` so the reason travels: the child refuses on its STDERR and `$(...)`
175
177
  # captures stdout only, so without the merge `die` fires with an empty
@@ -163,15 +163,20 @@ function parseArgs(argv) {
163
163
  // its own refusal. But it has no exit status and mostly no stderr, so `err`
164
164
  // names the kill, after whatever git did write — a caller quoting `err` would
165
165
  // otherwise quote an empty reason.
166
+ //
167
+ // A git that ignores the buffer kill can still exit 0, with no signal, after
168
+ // its output was cut off: any `error` on a git that ran fails it, whatever its
169
+ // exit status, and `err` names that error without claiming a kill.
166
170
  function git(args, cwd) {
167
171
  const r = spawnSync("git", args, { cwd, env: ENV, encoding: "utf8" });
168
172
  if (r.error && !r.pid) throw cannot(`could not start git: ${r.error.message}`);
169
173
  const err = (r.stderr ?? "").trim();
170
- const killed = r.signal && `git was killed by ${r.signal}${killCause(r.error)}`;
171
- return { ok: r.status === 0, out: (r.stdout ?? "").replace(/\n$/, ""), err: [err, killed].filter(Boolean).join("; ") };
174
+ const failed = r.signal ? `git was killed by ${r.signal}` : r.error && `git exited ${r.status} after an error`;
175
+ const note = failed && `${failed}${errorCause(r.error)}`;
176
+ return { ok: r.status === 0 && !r.error, out: (r.stdout ?? "").replace(/\n$/, ""), err: [err, note].filter(Boolean).join("; ") };
172
177
  }
173
178
 
174
- function killCause(error) {
179
+ function errorCause(error) {
175
180
  if (!error) return "";
176
181
  if (error.code === "ENOBUFS") return " (ENOBUFS: its output outgrew the spawn buffer)";
177
182
  return ` (${error.code ?? error.message})`;
@@ -595,6 +595,32 @@ test("a git that exits non-zero is refused with exactly its stderr, naming no si
595
595
  assert.doesNotMatch(r.err, /killed/);
596
596
  });
597
597
 
598
+ // A `status` stub that ignores SIGTERM — and so does every command it starts —
599
+ // writes `?? ` and then `bytes` x's, and exits 0.
600
+ const trapTermStatus = (bytes) => `trap '' TERM; printf '?? '; head -c ${bytes} /dev/zero | tr '\\0' x; exit 0`;
601
+
602
+ // Past spawnSync's default 1 MiB buffer the kill that ENOBUFS sends is
603
+ // ignored: git exits 0 with no signal, but its output was cut off. That is a
604
+ // failed git, refused with a reason naming the overrun — read as ok, the
605
+ // truncated status would pass for a dirty tree.
606
+ test("a git that exits 0 after outgrowing the spawn buffer is refused, naming the overrun", () => {
607
+ const { dir } = repo(MAVEN_FILES);
608
+ const r = prove(dir, COUNT_PROOF, { env: { PATH: fakeGit("status*", trapTermStatus(2_000_000)) } });
609
+ assert.equal(r.status, 1, r.err);
610
+ assert.match(r.err, /NOT PROVEN — could not read the tree state in the throwaway worktree: git exited 0 after an error \(ENOBUFS: its output outgrew the spawn buffer\); install output: /);
611
+ assert.doesNotMatch(r.err, /killed|could not start git/);
612
+ });
613
+
614
+ // The control: the same stub writing 1000 bytes is a git that succeeded, its
615
+ // output read whole — here, one untracked path the Install step left.
616
+ test("the same SIGTERM-trapping git with small output is ok, its output intact", () => {
617
+ const { dir } = repo(MAVEN_FILES);
618
+ const r = prove(dir, COUNT_PROOF, { env: { PATH: fakeGit("status*", trapTermStatus(997)) } });
619
+ assert.equal(r.status, 1, r.err);
620
+ assert.match(r.err, /NOT PROVEN — the Install step changed the tree \(first: \?\? x{997}\); /);
621
+ assert.doesNotMatch(r.err, /ENOBUFS|could not read the tree state/);
622
+ });
623
+
598
624
  // A killed `worktree remove` is a failed one: cleanup falls back to the plain
599
625
  // delete, and the proof's own NOT PROVEN — which keeps its log directory,
600
626
  // the throwaway worktree's parent — stands.
@@ -199,6 +199,22 @@ test("the snapshot agent is told to derive testCmd AND the schema declares it",
199
199
  );
200
200
  });
201
201
 
202
+ // derive-testcmd.sh's exit-3 refusals are about the environment and name no
203
+ // derivation step, so the prompt must not tell the snapshot agent that every
204
+ // refusal does.
205
+ test("the snapshot agent is told a cache refusal names the derivation step and an exit-3 refusal names an environment fault", () => {
206
+ const snapshot = between(CODE, "const snap = await agent(", "if (snap) {", "the snapshot agent dispatch");
207
+ assert.match(snapshot, /a\s+refusal\s+about\s+the\s+cache\s+names\s+the\s+step\s+that\s+derives\s+it/);
208
+ assert.match(snapshot, /an\s+exit-3\s+refusal\s+names\s+an\s+environment\s+fault,\s+and\s+the\s+caller\s+fixes\s+that\s+instead\s+of\s+deriving/);
209
+ // The two clauses above are the only places the prompt may speak of a
210
+ // refusal: any other sentence about one, however worded or capitalised, is a
211
+ // fresh chance to say that every refusal names the derivation step.
212
+ const outside = snapshot
213
+ .replace(/a\s+refusal\s+about\s+the\s+cache\s+names\s+the\s+step\s+that\s+derives\s+it/, "")
214
+ .replace(/an\s+exit-3\s+refusal\s+names\s+an\s+environment\s+fault/, "");
215
+ assert.doesNotMatch(outside, /\brefusals?\b/i, "the prompt speaks of a refusal outside the two clauses that say which kind names the derivation step");
216
+ });
217
+
202
218
  // #2315. The prompt that RUNS the command is the shared test run's — every
203
219
  // specialist used to run it, which made one review up to six full sweeps.
204
220
  // Bounded at both ends: an unbounded slice runs to EOF, where the specialist
@@ -270,8 +270,10 @@ reads carried 434 KB.`;
270
270
 
271
271
  // The step a missing Test entrypoint is derived by, named in the refusal so the
272
272
  // caller — a controller or a reviewer — knows what to run rather than what went
273
- // wrong (ADR 0015). derive-testcmd.sh's own refusals name the same step; this
274
- // one covers the case where the snapshot agent reported no reason at all.
273
+ // wrong (ADR 0015). derive-testcmd.sh's refusals about the cache name the same
274
+ // step; its exit-3 refusals name an environment fault instead, which the caller
275
+ // fixes rather than deriving. This one covers the case where the snapshot agent
276
+ // reported no reason at all.
275
277
  const DERIVATION_STEP =
276
278
  "run the Recipe derivation step (run-team phase 0, before the first claim — ADR 0015) to derive, prove and write the Recipe cache";
277
279
 
@@ -823,8 +825,9 @@ Then read this repository's Test entrypoint out of its Recipe cache:
823
825
 
824
826
  Report \`testCmd\` = its stdout ONLY if it exited 0. If it exited non-zero,
825
827
  report \`testCmdError\` = its stderr and omit \`testCmd\`. Never derive or
826
- guess a command yourself: a refusal names the step that writes the cache, and
827
- the caller acts on it.
828
+ guess a command yourself: a refusal about the cache names the step that
829
+ derives it; an exit-3 refusal names an environment fault, and the caller fixes
830
+ that instead of deriving.
828
831
 
829
832
  Then size the diff:
830
833