@feigi/fleet-ctl 3.16.3 → 3.16.5

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.16.3",
3
+ "version": "3.16.5",
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": {
@@ -629,13 +629,27 @@ test("build: an internal fault exits 70 with a stack, where a refusal exits 2 wi
629
629
  // ledger read, then `gh`) and can take single-digit SECONDS on a loaded
630
630
  // machine, against ~50ms once the OS/file caches are warm (measured on this
631
631
  // machine) — noise far larger than the retry loop's own cost. A discarded
632
- // warm-up run of the IDENTICAL fixture before both timed runs cancels that
632
+ // warm-up run of the IDENTICAL fixture before the timed pairs cancels that
633
633
  // noise; what is left is the loop's own cost. Measured on this machine: the
634
634
  // real loop adds ~300-360ms over a from-/dev/null baseline of the same
635
- // fixture; a body that calls writeSync once and swallows the exception adds
636
- // ~20-30ms. FAULT_RETRY_FLOOR_MS sits an order of magnitude above the
637
- // bare-call ceiling and well under the real loop's floor.
635
+ // fixture; a body that calls writeSync once and swallows the exception added
636
+ // ~20-30ms in that single pre-change sample, which is not a bound.
637
+ // FAULT_RETRY_FLOOR_MS sits several times above that bare-call figure and
638
+ // below the real loop's lowest delta measured after #2385 (216ms, below), so
639
+ // the margin on the real-loop side is narrow.
640
+ //
641
+ // #2385: one sample of each was not enough on a loaded CI runner, where a
642
+ // real loop measured BASE=0.221 SAT=0.370 — 149ms, one under the floor.
643
+ // Scheduler noise only ever ADDS time to a run, so the harness takes
644
+ // FAULT_TIMING_PAIRS interleaved baseline/saturated pairs and compares the
645
+ // fastest of each: one slow tick no longer moves either side. Measured on
646
+ // this machine after the change: the real loop's fastest-vs-fastest delta
647
+ // read 216-429ms. A bare-call body's read -244 to +127ms across repeated
648
+ // runs on a host that was never idle (load average 80-140 on 14 cores, some
649
+ // runs with two `yes > /dev/null` per core added) — the sign flips from run
650
+ // to run, so that delta is noise, not a cost.
638
651
  const FAULT_RETRY_FLOOR_MS = 150;
652
+ const FAULT_TIMING_PAIRS = 5;
639
653
 
640
654
  test("fault()'s writeSync loop spends real time retrying a saturated stderr, not the ~30ms a bare call would take", (t) => {
641
655
  if (spawnSync("python3", ["-c", ""]).status !== 0) return t.skip("needs python3");
@@ -645,9 +659,9 @@ test("fault()'s writeSync loop spends real time retrying a saturated stderr, not
645
659
  "import fcntl, os, subprocess, sys, time",
646
660
  "argv = sys.argv[1:]",
647
661
  "def run_baseline():",
648
- " t0 = time.time()",
662
+ " t0 = time.monotonic()",
649
663
  " r = subprocess.run(argv, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=60)",
650
- " return time.time() - t0, r.returncode",
664
+ " return time.monotonic() - t0, r.returncode",
651
665
  "def run_saturated():",
652
666
  " r, w = os.pipe()",
653
667
  " fcntl.fcntl(w, fcntl.F_SETFL, fcntl.fcntl(w, fcntl.F_GETFL) | os.O_NONBLOCK)",
@@ -656,31 +670,36 @@ test("fault()'s writeSync loop spends real time retrying a saturated stderr, not
656
670
  " os.write(w, b'x' * 65536)",
657
671
  " except BlockingIOError:",
658
672
  " pass",
659
- " t0 = time.time()",
673
+ " t0 = time.monotonic()",
660
674
  " proc = subprocess.Popen(argv, stderr=w, stdout=subprocess.DEVNULL)",
661
675
  " os.close(w)",
662
676
  " proc.wait(timeout=60)",
663
- " elapsed = time.time() - t0",
677
+ " elapsed = time.monotonic() - t0",
664
678
  " os.close(r)",
665
679
  " return elapsed, proc.returncode",
666
680
  "run_baseline()",
667
- "base_t, base_code = run_baseline()",
668
- "sat_t, sat_code = run_saturated()",
669
- "print(f'BASE={base_t:.3f} BASE_EXIT={base_code} SAT={sat_t:.3f} SAT_EXIT={sat_code}')",
681
+ `for _ in range(${FAULT_TIMING_PAIRS}):`,
682
+ " base_t, base_code = run_baseline()",
683
+ " print(f'BASE={base_t:.3f} EXIT={base_code}')",
684
+ " sat_t, sat_code = run_saturated()",
685
+ " print(f'SAT={sat_t:.3f} EXIT={sat_code}')",
670
686
  ].join("\n");
671
687
 
672
688
  const r = spawnSync("python3", ["-c", harness, process.execPath, ...argv], { cwd, env, encoding: "utf8", timeout: 120_000 });
673
689
  assert.equal(r.status, 0, `harness itself failed: ${r.stderr}`);
674
- const m = r.stdout.match(/^BASE=(\d+\.\d+) BASE_EXIT=(-?\d+) SAT=(\d+\.\d+) SAT_EXIT=(-?\d+)$/m);
675
- assert.ok(m, `harness printed no timing line: stdout=${r.stdout} stderr=${r.stderr}`);
676
- const [, baseS, baseExit, satS, satExit] = m;
677
- assert.equal(Number(baseExit), 70, `baseline run did not reach the fault exit: ${r.stdout}`);
678
- assert.equal(Number(satExit), 70, `saturated run did not reach the fault exit: ${r.stdout}`);
679
- const deltaMs = (Number(satS) - Number(baseS)) * 1000;
690
+ const samples = { BASE: [], SAT: [] };
691
+ for (const [, kind, s, exit] of r.stdout.matchAll(/^(BASE|SAT)=(\d+\.\d+) EXIT=(-?\d+)$/gm)) {
692
+ assert.equal(Number(exit), 70, `a ${kind} run did not reach the fault exit: ${r.stdout}`);
693
+ samples[kind].push(Number(s));
694
+ }
695
+ assert.equal(samples.BASE.length, FAULT_TIMING_PAIRS, `harness printed the wrong number of baseline samples: stdout=${r.stdout} stderr=${r.stderr}`);
696
+ assert.equal(samples.SAT.length, FAULT_TIMING_PAIRS, `harness printed the wrong number of saturated samples: stdout=${r.stdout} stderr=${r.stderr}`);
697
+ const deltaMs = (Math.min(...samples.SAT) - Math.min(...samples.BASE)) * 1000;
680
698
  assert.ok(
681
699
  deltaMs > FAULT_RETRY_FLOOR_MS,
682
- `fault() against a saturated stderr took only ${deltaMs.toFixed(0)}ms more than baseline — the retry ` +
683
- `loop must spend real time on EAGAIN, not return almost immediately like a bare call: ${r.stdout}`,
700
+ `fault() against a saturated stderr took only ${deltaMs.toFixed(0)}ms more than baseline (fastest of ` +
701
+ `${FAULT_TIMING_PAIRS} each) — the retry loop must spend real time on EAGAIN, not return almost ` +
702
+ `immediately like a bare call: ${r.stdout}`,
684
703
  );
685
704
  // No upper bound here: MAX_EAGAIN_RETRIES capping the loop rather than
686
705
  // spinning forever against a reader that never drains is board.test.mjs's