@feigi/fleet-ctl 3.18.7 → 3.18.9

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.18.7",
3
+ "version": "3.18.9",
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": {
@@ -71,15 +71,17 @@
71
71
  // Without a ledger the record is judged all the same and the exit status is
72
72
  // the whole verdict: no token is written, no row is read, and `token` in the
73
73
  // stdout payload is null. That is the shape of a standalone `/review-and-fix`
74
- // with no controller, and it is chosen, never inferred — pass `--no-ledger`.
74
+ // with no controller, chosen by `--no-ledger` or by a ledger path that does
75
+ // not exist.
75
76
  // A repository's `.fleet/ledger.md` outlives the fleet run that wrote it, so a
76
77
  // standalone member in a worktree of such a repository would otherwise find
77
78
  // the previous run's ledger, and a ledger that exists is never skipped: one
78
79
  // holding no row for the member is a fault (exit 2), as is a ledger path that
79
80
  // cannot be looked up (a parent that is a file, no permission, a symlink loop).
80
- // Only a path that does not exist is "no ledger". `--no-ledger` names that
81
- // state outright: no ledger is looked for, whatever the repository holds, and
82
- // it contradicts `--ledger`.
81
+ // Only a path that does not exist is "no ledger": the default path, or one
82
+ // `--ledger` names, which also prints a note on stderr that no token was
83
+ // written. `--no-ledger` names that state outright: no ledger is looked for,
84
+ // whatever the repository holds, and it contradicts `--ledger`.
83
85
 
84
86
  import { readFileSync, existsSync, lstatSync } from "node:fs";
85
87
  import { execFileSync } from "node:child_process";
@@ -410,8 +412,10 @@ function runLedger(ledgerFile, args, what) {
410
412
  // where `ledger.mjs dispatch` wrote the member's row. The path is handed to
411
413
  // `ledger.mjs` as `--file`, so the existence probe and the calls that follow
412
414
  // answer for one file. Only ENOENT means "there is none": any other failure
413
- // to look the path up is a fault, not a standalone run. `lstat`, not `stat`, so
414
- // a dangling symlink is a ledger that cannot be read rather than an absent one.
415
+ // to look the path up is a fault, not a standalone run. An absent path named
416
+ // by `--ledger` is announced on stderr; an absent default path is not.
417
+ // `lstat`, not `stat`, so a dangling symlink is a ledger that cannot be read
418
+ // rather than an absent one.
415
419
  function ledgerInUse(explicit, repo) {
416
420
  const file = explicit ?? join(
417
421
  workspaceDirFromGitCommonDir(git(repo, ["rev-parse", "--git-common-dir"], "find the git common dir"), repo)
@@ -422,7 +426,10 @@ function ledgerInUse(explicit, repo) {
422
426
  lstatSync(file);
423
427
  return file;
424
428
  } catch (e) {
425
- if (e.code === "ENOENT") return null;
429
+ if (e.code === "ENOENT") {
430
+ if (explicit !== null) console.error(`${NAME}: no ledger at ${file} (named by --ledger) — judged with no ledger, so no token was written; pass --no-ledger to choose that`);
431
+ return null;
432
+ }
426
433
  die(`could not look for the ledger ${file}: ${e.message}`);
427
434
  }
428
435
  }
@@ -376,6 +376,7 @@ test("with no ledger the exit status is the verdict, and nothing is written to a
376
376
  okVerdict(r);
377
377
  assert.equal(r.json.token, null);
378
378
  assert.deepEqual(r.json.violations, []);
379
+ assert.equal(r.stderr, "", "no --ledger and no default ledger is a standalone run that prints nothing");
379
380
 
380
381
  const bad = f.baseEntries();
381
382
  bad[0] = f.entry("survived", 0, { disposition: "defer" });
@@ -392,7 +393,7 @@ test("with no ledger the exit status is the verdict, and nothing is written to a
392
393
  assert.equal(readFileSync(join(f.dir, "ledger.md"), "utf8"), ledgerBefore, "a ledger elsewhere is not this run's and is not touched");
393
394
  });
394
395
 
395
- test("an explicit --ledger naming no file is no ledger either: the default ledger is not borrowed, and nothing is created", (t) => {
396
+ test("an explicit --ledger naming no file is no ledger either: the default ledger is not borrowed, nothing is created, and stderr says so", (t) => {
396
397
  const f = fixture(t);
397
398
  const own = seedOwnLedger(f);
398
399
  const ownBefore = readFileSync(own, "utf8");
@@ -403,6 +404,16 @@ test("an explicit --ledger naming no file is no ledger either: the default ledge
403
404
  assert.equal(r.json.token, null);
404
405
  assert.equal(readFileSync(own, "utf8"), ownBefore);
405
406
  assert.equal(existsSync(join(f.dir, "absent")), false);
407
+ const lines = r.stderr.split("\n").filter(Boolean);
408
+ assert.equal(lines.length, 1, r.stderr);
409
+ assert.ok(lines[0].startsWith(`dispositions-check: no ledger at ${absent} `), lines[0]);
410
+ assert.match(lines[0], /no token was written.*--no-ledger/);
411
+
412
+ // A --ledger that exists is used, and draws no such note.
413
+ const present = standalone(f, "--repo", f.repo, "--ledger", own);
414
+ okVerdict(present);
415
+ assert.equal(present.json.token, `dispositions-ok=fix-pr-40:${f.head}`);
416
+ assert.doesNotMatch(present.stderr, /no ledger at/);
406
417
  });
407
418
 
408
419
  // Writes `f.repo`'s own `.fleet/ledger.md` with the member's row, as a fleet
@@ -479,6 +490,7 @@ test("--no-ledger is a standalone run whatever ledger the repository holds: a st
479
490
  const r = standalone(f, "--repo", wt, "--no-ledger");
480
491
  okVerdict(r);
481
492
  assert.equal(r.json.token, null);
493
+ assert.equal(r.stderr, "", "--no-ledger is a chosen standalone run and prints nothing");
482
494
  assert.equal(readFileSync(stale, "utf8"), before);
483
495
 
484
496
  const bad = f.baseEntries();
@@ -495,6 +507,7 @@ test("--no-ledger leaves a ledger that holds the member's row unwritten, and con
495
507
  const r = standalone(f, "--no-ledger");
496
508
  okVerdict(r);
497
509
  assert.equal(r.json.token, null);
510
+ assert.equal(r.stderr, "");
498
511
  assert.equal(readFileSync(ledger, "utf8"), before);
499
512
 
500
513
  const both = standalone(f, "--no-ledger", "--ledger", ledger);
@@ -2849,11 +2849,18 @@ test("an ambient GIT_DIR does not ask another repository whether the ticket is t
2849
2849
  // The fixture's own positive control: if the other repository happened to
2850
2850
  // carry a worktree for #77 too, looking in the wrong place would give the
2851
2851
  // right answer and this case would pass while pinning nothing.
2852
- assert.doesNotMatch(
2853
- execFileSync("git", ["-C", elsewhere.repo, "worktree", "list"], { encoding: "utf8" }),
2854
- /77/,
2855
- "fixture: the other repository must hold nothing for #77",
2856
- );
2852
+ //
2853
+ // Matched against each worktree's basename and branch, never the whole
2854
+ // listing: the listing carries the fixture's mkdtemp path, whose random
2855
+ // suffix can itself contain `77` (#2512). The main worktree's basename is
2856
+ // fixture()'s fixed `repo`, so no random byte reaches what is matched.
2857
+ const elsewhereNames = execFileSync("git", ["-C", elsewhere.repo, "worktree", "list", "--porcelain"],
2858
+ { encoding: "utf8" })
2859
+ .split("\n")
2860
+ .flatMap((l) => l.startsWith("worktree ") ? [l.slice(9).replace(/.*\//, "")]
2861
+ : l.startsWith("branch refs/heads/") ? [l.slice(18)] : []);
2862
+ assert.ok(!elsewhereNames.some((name) => /77/.test(name)),
2863
+ `fixture: the other repository must hold nothing for #77; it lists ${JSON.stringify(elsewhereNames)}`);
2857
2864
 
2858
2865
  const r = spawnSync("sh", [SCRIPT, "77"], {
2859
2866
  cwd: here.repo,