@feigi/fleet-ctl 0.0.0 → 3.16.2

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.
Files changed (152) hide show
  1. package/agents/{fleet-implementer.agent.md → fleet-implementer-slow-high.agent.md} +23 -2
  2. package/agents/fleet-implementer-slow-medium.agent.md +231 -0
  3. package/agents/fleet-implementer-smol-high.agent.md +231 -0
  4. package/agents/{fleet-implementer-alt.agent.md → fleet-implementer-task-high.agent.md} +23 -2
  5. package/agents/fleet-implementer-task-max.agent.md +231 -0
  6. package/agents/fleet-review-comments.agent.md +4 -2
  7. package/agents/fleet-review-correctness.agent.md +2 -1
  8. package/agents/fleet-review-runner.agent.md +14 -10
  9. package/agents/fleet-review-silent-failure.agent.md +4 -3
  10. package/agents/fleet-review-simplify.agent.md +2 -1
  11. package/agents/fleet-review-snapshot.agent.md +2 -1
  12. package/agents/fleet-review-test-run.agent.md +29 -0
  13. package/agents/fleet-review-tests.agent.md +10 -5
  14. package/agents/fleet-review-types.agent.md +4 -2
  15. package/agents/fleet-review-verifier.agent.md +4 -3
  16. package/commands/review-and-fix.md +7 -6
  17. package/commands/run-merge-bot.md +14 -4
  18. package/package.json +4 -2
  19. package/scripts/agent-test.test.mjs +36 -32
  20. package/scripts/ambient-git-vars-mjs-prose.test.mjs +23 -13
  21. package/scripts/apply-ruleset.test.mjs +4 -3
  22. package/scripts/arg-header-probes-prose.test.mjs +1 -0
  23. package/scripts/arg.test.mjs +18 -18
  24. package/scripts/board-cli.test.mjs +18 -21
  25. package/scripts/board-identity.test.mjs +9 -9
  26. package/scripts/board-liveness-banner.test.mjs +6 -6
  27. package/scripts/board-prev-shape.test.mjs +12 -13
  28. package/scripts/board-tryparse-null.test.mjs +7 -7
  29. package/scripts/board.mjs +4 -7
  30. package/scripts/board.test.mjs +57 -61
  31. package/scripts/candidates.test.mjs +228 -17
  32. package/scripts/ci-completes-premise-prose.test.mjs +1 -1
  33. package/scripts/ci-state-prose.test.mjs +2 -2
  34. package/scripts/ci-state.mjs +389 -187
  35. package/scripts/ci-state.test.mjs +458 -165
  36. package/scripts/claim-lifecycle.test.mjs +2 -1
  37. package/scripts/claim-ticket.test.mjs +35 -34
  38. package/scripts/closing-keyword-prose.test.mjs +1 -1
  39. package/scripts/cockpit-tick-nonblocking.test.mjs +8 -8
  40. package/scripts/compute-board.mjs +13 -3
  41. package/scripts/compute-board.test.mjs +64 -1
  42. package/scripts/compute-spend.mjs +46 -8
  43. package/scripts/compute-spend.test.mjs +64 -10
  44. package/scripts/cross-repo-citation-prose.test.mjs +18 -19
  45. package/scripts/delete-merged-branch.sh +218 -0
  46. package/scripts/delete-merged-branch.test.mjs +576 -0
  47. package/scripts/derive-testcmd.sh +18 -7
  48. package/scripts/derive-testcmd.test.mjs +9 -8
  49. package/scripts/diff-stats.mjs +2 -2
  50. package/scripts/diff-stats.test.mjs +7 -11
  51. package/scripts/dispatch-block-golden-prose.test.mjs +111 -6
  52. package/scripts/dispatch-block-pins-prose.test.mjs +5 -5
  53. package/scripts/dispositions-check.mjs +507 -0
  54. package/scripts/dispositions-check.test.mjs +843 -0
  55. package/scripts/dispositions-gate-prose.test.mjs +114 -0
  56. package/scripts/drop-merged-label.test.mjs +3 -4
  57. package/scripts/exec-stub.mjs +93 -0
  58. package/scripts/exec-stub.test.mjs +69 -0
  59. package/scripts/filing-bar-seat-prose.test.mjs +1 -1
  60. package/scripts/finisher-test-verdict-prose.test.mjs +102 -0
  61. package/scripts/fix-applier-correction-rules-prose.test.mjs +11 -10
  62. package/scripts/fleet-bootstrap +5 -20
  63. package/scripts/fleet-bootstrap.test.mjs +75 -0
  64. package/scripts/fleet-heartbeat.mjs +2 -2
  65. package/scripts/fleet-provenance +15 -24
  66. package/scripts/fleet-provenance.test.mjs +86 -12
  67. package/scripts/fleet-run.test.mjs +5 -5
  68. package/scripts/fleet-state.mjs +33 -11
  69. package/scripts/fleet-state.test.mjs +90 -3
  70. package/scripts/fleet-tick.mjs +346 -70
  71. package/scripts/fleet-tick.test.mjs +566 -16
  72. package/scripts/force-with-lease-reason-prose.test.mjs +1 -1
  73. package/scripts/frontmatter-check.mjs +3 -2
  74. package/scripts/frontmatter-check.test.mjs +6 -6
  75. package/scripts/immutable-body-claim-prose.test.mjs +53 -262
  76. package/scripts/implementer-model-tier.test.mjs +98 -506
  77. package/scripts/inflight.test.mjs +18 -127
  78. package/scripts/is-cli.mjs +26 -0
  79. package/scripts/is-cli.test.mjs +99 -0
  80. package/scripts/json.test.mjs +3 -3
  81. package/scripts/ledger-dispatch.test.mjs +368 -7
  82. package/scripts/ledger-grammar.mjs +85 -1
  83. package/scripts/ledger-grammar.test.mjs +86 -1
  84. package/scripts/ledger-read-require-file.test.mjs +7 -7
  85. package/scripts/ledger-rotate.test.mjs +142 -0
  86. package/scripts/ledger.mjs +181 -17
  87. package/scripts/ledger.test.mjs +12 -130
  88. package/scripts/main-checkout.mjs +312 -0
  89. package/scripts/main-checkout.test.mjs +332 -0
  90. package/scripts/member-outcomes-header.test.mjs +3 -3
  91. package/scripts/member-outcomes.mjs +4 -5
  92. package/scripts/member-outcomes.test.mjs +92 -18
  93. package/scripts/member-prompt-prose.test.mjs +17 -13
  94. package/scripts/member-record.mjs +8 -3
  95. package/scripts/member-record.test.mjs +5 -5
  96. package/scripts/member-write-guard.mjs +5 -5
  97. package/scripts/member-write-guard.test.mjs +6 -3
  98. package/scripts/no-undo-audit.sh +24 -21
  99. package/scripts/no-undo-audit.test.mjs +9 -13
  100. package/scripts/pointer-target-prose.test.mjs +1 -1
  101. package/scripts/pr-overlap.test.mjs +6 -9
  102. package/scripts/prompt-renderer.mjs +10 -9
  103. package/scripts/prose-pin.mjs +10 -11
  104. package/scripts/prove-merge.test.mjs +3 -3
  105. package/scripts/quiet-payload-prose.test.mjs +1 -1
  106. package/scripts/reap.test.mjs +3 -4
  107. package/scripts/release-label-split-prose.test.mjs +17 -2
  108. package/scripts/release-ticket.test.mjs +35 -44
  109. package/scripts/review-core-cwd-isolation.test.mjs +7 -6
  110. package/scripts/review-core-reads.test.mjs +1 -1
  111. package/scripts/review-core-scratch-refusal.test.mjs +64 -0
  112. package/scripts/review-core-shared-test-run.test.mjs +238 -0
  113. package/scripts/review-core-snapshot-path.test.mjs +59 -12
  114. package/scripts/review-core-specialist-scratch.test.mjs +12 -10
  115. package/scripts/review-core-testcmd.test.mjs +76 -45
  116. package/scripts/review-core-unrun.test.mjs +154 -168
  117. package/scripts/review-core.mjs +250 -56
  118. package/scripts/review-eval.mjs +11 -4
  119. package/scripts/review-host-fixture.mjs +12 -3
  120. package/scripts/review-in-run-retry.test.mjs +27 -3
  121. package/scripts/review-runner-spawns.test.mjs +5 -3
  122. package/scripts/review-runner.test.mjs +14 -3
  123. package/scripts/review-tier-audit.test.mjs +1 -1
  124. package/scripts/run-merge-bot-prose.test.mjs +29 -6
  125. package/scripts/scratch-partition-invariant-prose.test.mjs +1 -1
  126. package/scripts/section-between-guard-prose.test.mjs +4 -3
  127. package/scripts/select-dimensions.test.mjs +1 -1
  128. package/scripts/shell-traps-prose.test.mjs +6 -9
  129. package/scripts/shortlist.mjs +4 -1
  130. package/scripts/shortlist.test.mjs +30 -16
  131. package/scripts/snapshot-repo.test.mjs +177 -4
  132. package/scripts/stash-prohibition-prose.test.mjs +1 -1
  133. package/scripts/temp-dir.mjs +47 -0
  134. package/scripts/tier-check.mjs +95 -28
  135. package/scripts/tier-check.test.mjs +131 -29
  136. package/scripts/tier-outcomes-header.test.mjs +11 -54
  137. package/scripts/tier-outcomes.mjs +34 -12
  138. package/scripts/tier-outcomes.test.mjs +157 -4
  139. package/scripts/tier-roles.mjs +118 -29
  140. package/scripts/tier-roles.test.mjs +226 -61
  141. package/scripts/tracker-block-copy-prose.test.mjs +3 -3
  142. package/scripts/verify-sha.test.mjs +4 -5
  143. package/scripts/watcher-degraded-block.test.mjs +5 -8
  144. package/scripts/within-run-pair-prose.test.mjs +43 -75
  145. package/scripts/worktree-audit.test.mjs +2 -1
  146. package/skills/next-ticket/SKILL.md +2 -2
  147. package/skills/run-team/SKILL.md +433 -303
  148. package/skills/run-team/references/ci-and-staleness.md +7 -6
  149. package/skills/run-team/references/correction-tickets.md +3 -3
  150. package/skills/run-team/references/isolation.md +1 -1
  151. package/skills/sizing-a-ticket/SKILL.md +8 -8
  152. package/scripts/tier-guard-gate-prose.test.mjs +0 -216
@@ -3,8 +3,9 @@
3
3
  // dir and asserts it serves board.json and the page.
4
4
  import { test } from "node:test";
5
5
  import assert from "node:assert/strict";
6
- import { mkdtempSync, mkdirSync, writeFileSync, utimesSync, statSync, chmodSync, rmSync, readFileSync, existsSync, symlinkSync, realpathSync } from "node:fs";
6
+ import { mkdirSync, writeFileSync, utimesSync, statSync, chmodSync, rmSync, readFileSync, existsSync, symlinkSync, realpathSync } from "node:fs";
7
7
  import { tmpdir } from "node:os";
8
+ import { tempDir } from "./temp-dir.mjs";
8
9
  import { dirname, join } from "node:path";
9
10
  import { spawnSync, spawn } from "node:child_process";
10
11
  import { createServer } from "node:net";
@@ -13,6 +14,7 @@ import { createBoardServer, mapCi, encodeProjectDir, findSubagentsDir, spendDirP
13
14
  import { readOmpMember } from "./member-record.mjs";
14
15
  import { stripComments } from "./strip-comments.mjs";
15
16
  import { gitEnv } from "./git-env.mjs";
17
+ import { writeExecStub } from "./exec-stub.mjs";
16
18
 
17
19
  const SCRIPT = fileURLToPath(new URL("./board.mjs", import.meta.url));
18
20
 
@@ -175,14 +177,13 @@ test("an unparseable payload warns ONCE per PR across ticks, and a second PR is
175
177
  // that spends one line per process and one that spends one per tick are
176
178
  // indistinguishable inside a single-tick, single-PR run.
177
179
  function gatherCi({ ciStateBody, prevCi, prs = [42], ticks = 1 }) {
178
- const cwd = mkdtempSync(join(tmpdir(), "board-gather-"));
179
- const bin = mkdtempSync(join(tmpdir(), "board-gather-bin-"));
180
- const scriptDir = mkdtempSync(join(tmpdir(), "board-gather-scripts-"));
180
+ const cwd = tempDir("board-gather-");
181
+ const bin = tempDir("board-gather-bin-");
182
+ const scriptDir = tempDir("board-gather-scripts-");
181
183
  writeFileSync(join(scriptDir, "ci-state.mjs"), ciStateBody);
182
184
  const rows = JSON.stringify(prs.map((n) => ({ number: n, state: "OPEN", labels: [], title: "t" })));
183
- writeFileSync(join(bin, "gh"),
185
+ writeExecStub(join(bin, "gh"),
184
186
  `#!/bin/sh\ncase "$1 $2" in\n"pr list") echo '${rows}' ;;\n*) exit 1 ;;\nesac\n`);
185
- chmodSync(join(bin, "gh"), 0o755);
186
187
  writeFileSync(join(cwd, "prev.json"), JSON.stringify({ tickets: prs.map((n) => ({ pr: n, ci: prevCi })) }));
187
188
  // serve()'s shape, not a loop for its own sake: one process, gather() called
188
189
  // again per tick, which is the only place a warn-once gate is observable.
@@ -390,7 +391,7 @@ test("gather: the real call site still hands mapCi the PR number, not just the p
390
391
  // its first invocation and exit-0-truncated on its second, for the SAME PR —
391
392
  // both warnings must print.
392
393
  test("gather: a PR that hits the exit-1 salvage then the exit-0 guard gets BOTH warnings, not just the first", () => {
393
- const markerDir = mkdtempSync(join(tmpdir(), "board-dualarm-"));
394
+ const markerDir = tempDir("board-dualarm-");
394
395
  const marker = join(markerDir, "tick");
395
396
  const DUAL_ARM = `import { writeSync, existsSync, writeFileSync } from "node:fs";
396
397
  const marker = ${JSON.stringify(marker)};
@@ -422,13 +423,12 @@ process.exit(first ? 1 : 0);`;
422
423
  // tests pin. Out of process for the same reason as gatherCi: gather() reads
423
424
  // process.argv and would otherwise read the test runner's.
424
425
  function gatherRows({ issuesJson, prsJson }) {
425
- const cwd = mkdtempSync(join(tmpdir(), "board-gather-rows-"));
426
- const bin = mkdtempSync(join(tmpdir(), "board-gather-rows-bin-"));
427
- const scriptDir = mkdtempSync(join(tmpdir(), "board-gather-rows-scripts-"));
426
+ const cwd = tempDir("board-gather-rows-");
427
+ const bin = tempDir("board-gather-rows-bin-");
428
+ const scriptDir = tempDir("board-gather-rows-scripts-");
428
429
  writeFileSync(join(scriptDir, "ci-state.mjs"), "process.stdout.write('{}');\n");
429
- writeFileSync(join(bin, "gh"),
430
+ writeExecStub(join(bin, "gh"),
430
431
  `#!/bin/sh\ncase "$1 $2" in\n"issue list") echo '${issuesJson}' ;;\n"pr list") echo '${prsJson}' ;;\n*) exit 1 ;;\nesac\n`);
431
- chmodSync(join(bin, "gh"), 0o755);
432
432
  const driver = `const { gather } = await import(${JSON.stringify(SCRIPT)});
433
433
  const r = await gather({ ledgerFile: ${JSON.stringify(join(cwd, "nope.md"))},
434
434
  prevFile: null, scriptDir: ${JSON.stringify(scriptDir)}, interval: 15 });
@@ -486,13 +486,13 @@ test("gather: a PR row with no number is dropped, loudly, not placed as undefine
486
486
  // for a full page would render the cut list as the whole one. The driver runs
487
487
  // the real computeBoard() over gather()'s answer: the board is the subject.
488
488
  function gatherCapped({ issues, prs }) {
489
- const cwd = mkdtempSync(join(tmpdir(), "board-gather-capped-"));
490
- const bin = mkdtempSync(join(tmpdir(), "board-gather-capped-bin-"));
491
- const scriptDir = mkdtempSync(join(tmpdir(), "board-gather-capped-scripts-"));
489
+ const cwd = tempDir("board-gather-capped-");
490
+ const bin = tempDir("board-gather-capped-bin-");
491
+ const scriptDir = tempDir("board-gather-capped-scripts-");
492
492
  writeFileSync(join(scriptDir, "ci-state.mjs"), "process.stdout.write('{}');\n");
493
493
  writeFileSync(join(scriptDir, "ledger.mjs"),
494
494
  `process.stdout.write(${JSON.stringify(JSON.stringify({ rows: [], filed: [], ruled: [] }))});\n`);
495
- writeFileSync(join(bin, "gh"), `#!/usr/bin/env node
495
+ writeExecStub(join(bin, "gh"), `#!/usr/bin/env node
496
496
  const a = process.argv.slice(2);
497
497
  const i = a.indexOf("--limit");
498
498
  const limit = i === -1 ? 30 : Number(a[i + 1]);
@@ -501,7 +501,6 @@ if (a[0] === "issue" && a[1] === "list") process.stdout.write(JSON.stringify(row
501
501
  else if (a[0] === "pr" && a[1] === "list") process.stdout.write(JSON.stringify(rows(${prs}, (n) => ({ number: 1000 + n, state: "OPEN", title: "t", labels: [] }))));
502
502
  else process.exit(1);
503
503
  `);
504
- chmodSync(join(bin, "gh"), 0o755);
505
504
  const driver = `const { gather } = await import(${JSON.stringify(SCRIPT)});
506
505
  const { computeBoard } = await import(${JSON.stringify(fileURLToPath(new URL("./compute-board.mjs", import.meta.url)))});
507
506
  const inputs = await gather({ ledgerFile: ${JSON.stringify(join(cwd, "ledger.md"))},
@@ -575,16 +574,16 @@ test("#2108: a pool read AND an open-PR read that both fill their --limit are bo
575
574
  // argv is logged, so a test can count merged reads. The driver runs the real
576
575
  // computeBoard() over gather()'s answer: the card's column is the subject.
577
576
  function gatherMerged({ rows, prs = [], prev = null, states = {}, fail = false, emptyRepo = false }) {
578
- const cwd = mkdtempSync(join(tmpdir(), "board-gather-merged-"));
579
- const bin = mkdtempSync(join(tmpdir(), "board-gather-merged-bin-"));
580
- const scriptDir = mkdtempSync(join(tmpdir(), "board-gather-merged-scripts-"));
577
+ const cwd = tempDir("board-gather-merged-");
578
+ const bin = tempDir("board-gather-merged-bin-");
579
+ const scriptDir = tempDir("board-gather-merged-scripts-");
581
580
  const log = join(cwd, "gh-calls.jsonl");
582
581
  writeFileSync(join(scriptDir, "ci-state.mjs"), "process.stdout.write('{}');\n");
583
582
  writeFileSync(join(scriptDir, "ledger.mjs"),
584
583
  `process.stdout.write(${JSON.stringify(JSON.stringify({ rows, filed: [], ruled: [] }))});\n`);
585
584
  const window = Array.from({ length: 100 }, (_, i) => ({ number: 5000 + i, state: "MERGED" }));
586
585
  const config = { prs: prs.map((n) => ({ number: n, state: "OPEN", title: "t", labels: [] })), window, states, fail, emptyRepo, log };
587
- writeFileSync(join(bin, "gh"), `#!/usr/bin/env node
586
+ writeExecStub(join(bin, "gh"), `#!/usr/bin/env node
588
587
  const fs = require("node:fs");
589
588
  const c = ${JSON.stringify(config)};
590
589
  const a = process.argv.slice(2);
@@ -608,7 +607,6 @@ else if (a[0] === "api" && a[1] === "graphql") {
608
607
  }
609
608
  else process.exit(1);
610
609
  `);
611
- chmodSync(join(bin, "gh"), 0o755);
612
610
  const prevFile = join(cwd, "prev.json");
613
611
  if (prev) writeFileSync(prevFile, JSON.stringify(prev));
614
612
  const driver = `const { gather } = await import(${JSON.stringify(SCRIPT)});
@@ -772,7 +770,7 @@ test("gather: a malformed element inside labels is dropped, not the whole row",
772
770
  });
773
771
 
774
772
  test("createBoardServer serves board.json and the page", async () => {
775
- const dir = mkdtempSync(join(tmpdir(), "board-"));
773
+ const dir = tempDir("board-");
776
774
  writeFileSync(join(dir, "board.json"), JSON.stringify({ generatedAt: 1, tickets: [], attention: [] }));
777
775
  writeFileSync(join(dir, "board.html"), "<!doctype html><title>cockpit</title>");
778
776
  const server = createBoardServer(dir);
@@ -799,7 +797,7 @@ test("createBoardServer serves board.json and the page", async () => {
799
797
  // failed silently as "panel hidden" or "plausible but 3x too big".
800
798
 
801
799
  test("findSubagentsDir picks the session with the newest transcript", () => {
802
- const home = mkdtempSync(join(tmpdir(), "spend-home-"));
800
+ const home = tempDir("spend-home-");
803
801
  const proj = join(home, ".omp", "agent", "sessions", "-x");
804
802
  const older = join(proj, "2026-09-08T13-13-27-300Z_11111111-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
805
803
  const newer = join(proj, "2026-09-09T02-00-00-000Z_22222222-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
@@ -835,7 +833,7 @@ test("session ranking uses transcript mtime, not directory mtime", () => {
835
833
  // with the fix fully reverted. Stamp all four times explicitly, files before
836
834
  // dirs: creating a file is the one operation that moves its parent's mtime,
837
835
  // and rewriting an existing file's mtime does not.
838
- const home = mkdtempSync(join(tmpdir(), "spend-home-"));
836
+ const home = tempDir("spend-home-");
839
837
  const proj = join(home, ".omp", "agent", "sessions", "-x");
840
838
  const busy = join(proj, "2026-09-08T13-13-27-300Z_aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"); // spawned its agents early, still appending
841
839
  const idle = join(proj, "2026-09-09T02-00-00-000Z_bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"); // spawned one last agent, then went quiet
@@ -861,7 +859,7 @@ test("one unreadable session directory loses the ranking instead of sinking the
861
859
  // The bad sibling is a regular FILE where a directory is expected: EISDIR/
862
860
  // ENOTDIR is the same uncaught throw and, unlike a permission bit, it still
863
861
  // throws when the suite runs as root.
864
- const home = mkdtempSync(join(tmpdir(), "spend-home-"));
862
+ const home = tempDir("spend-home-");
865
863
  const proj = join(home, ".omp", "agent", "sessions", "-x");
866
864
  const good = join(proj, "2026-09-08T13-13-27-300Z_aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
867
865
  mkdirSync(good, { recursive: true });
@@ -902,7 +900,7 @@ function ompTranscript({ agent, task, model = "claude-opus-5", turns = [] } = {}
902
900
  // home-relative form (`-dev-repo`) and needs no realpath of a cwd that does
903
901
  // not exist. encodeProjectDir is the real encoder, not a hand-rolled path.
904
902
  function ompHome() {
905
- const home = mkdtempSync(join(tmpdir(), "spend-omp-home-"));
903
+ const home = tempDir("spend-omp-home-");
906
904
  const cwd = join(home, "dev", "repo");
907
905
  const proj = join(home, ".omp", "agent", "sessions", encodeProjectDir(cwd, { home }));
908
906
  mkdirSync(proj, { recursive: true });
@@ -963,8 +961,8 @@ test("findSubagentsDir: an EACCES resolving the omp encoding (not ENOENT) surfac
963
961
  // swallow ENOENT ("this cwd doesn't exist" — the documented case). Any
964
962
  // other error (EACCES on an ancestor, here) is a real fault and must
965
963
  // propagate, never be silently relabelled as "no omp session".
966
- const home = mkdtempSync(join(tmpdir(), "spend-eacces-home-"));
967
- const outer = mkdtempSync(join(tmpdir(), "spend-eacces-outer-"));
964
+ const home = tempDir("spend-eacces-home-");
965
+ const outer = tempDir("spend-eacces-outer-");
968
966
  const blocked = join(outer, "blocked");
969
967
  mkdirSync(blocked);
970
968
  const cwd = join(blocked, "sub", "repo");
@@ -979,7 +977,7 @@ test("findSubagentsDir: an EACCES resolving the omp encoding (not ENOENT) surfac
979
977
  });
980
978
 
981
979
  test("with no session tree present the lookup is an error that names where it looked", () => {
982
- const home = mkdtempSync(join(tmpdir(), "spend-omp-home-"));
980
+ const home = tempDir("spend-omp-home-");
983
981
  const r = findSubagentsDir(home, join(home, "dev", "repo"));
984
982
  assert.match(r.error, /\.omp[\\/]agent[\\/]sessions/);
985
983
  });
@@ -1200,7 +1198,7 @@ test("an omp session whose only transcript is a live write's torn first line is
1200
1198
  // drive that distinction directly instead of assuming "the first non-null
1201
1199
  // answer" was always safe to cache.
1202
1200
  test("the pin does not latch a session that predates it — it keeps following the heuristic until one writes on its watch", () => {
1203
- const home = mkdtempSync(join(tmpdir(), "spend-home-"));
1201
+ const home = tempDir("spend-home-");
1204
1202
  const proj = join(home, ".omp", "agent", "sessions", "-x");
1205
1203
  const mine = join(proj, "2026-09-08T13-13-27-300Z_aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
1206
1204
  const theirs = join(proj, "2026-09-09T02-00-00-000Z_bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
@@ -1236,7 +1234,7 @@ test("no session at launch is not an answer to pin — the first one to write on
1236
1234
  // spend panel for the entire run — the existing degradation is "hidden until
1237
1235
  // agents land", not "hidden for good", and this is the assertion that keeps
1238
1236
  // the pin from being written as "whatever the first call returned".
1239
- const home = mkdtempSync(join(tmpdir(), "spend-home-"));
1237
+ const home = tempDir("spend-home-");
1240
1238
  const proj = join(home, ".omp", "agent", "sessions", "-x");
1241
1239
  mkdirSync(proj, { recursive: true });
1242
1240
  const pin = spendDirPin(undefined, home, join(home, "x"));
@@ -1286,7 +1284,7 @@ test("a transcript stamped a few ms before launchMs is followed, never latched
1286
1284
  // free hedge, leaving no fractional part for a seconds conversion to lose.
1287
1285
  const launchMs = Date.UTC(2026, 0, 1);
1288
1286
  const stamp = (f, ms) => utimesSync(f, new Date(ms), new Date(ms));
1289
- const home = mkdtempSync(join(tmpdir(), "spend-home-"));
1287
+ const home = tempDir("spend-home-");
1290
1288
  const proj = join(home, ".omp", "agent", "sessions", "-x");
1291
1289
  const mine = join(proj, "2026-09-08T13-13-27-300Z_aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
1292
1290
  const theirs = join(proj, "2026-09-09T02-00-00-000Z_bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
@@ -1330,7 +1328,7 @@ test("an unresolvable transcript tree is never pinned — one stderr line across
1330
1328
  // the one-line-per-fault promise can no longer come from caching upstream —
1331
1329
  // it comes from gatherSpend's own warnOnce gate, keyed on the message,
1332
1330
  // which needs nothing cached above it to hold.
1333
- const home = mkdtempSync(join(tmpdir(), "spend-home-"));
1331
+ const home = tempDir("spend-home-");
1334
1332
  const pin = spendDirPin(undefined, home, "/nonexistent");
1335
1333
 
1336
1334
  let first, second;
@@ -1352,7 +1350,7 @@ test("an unresolvable transcript tree recovers on its very next tick, because {
1352
1350
  // directory mid permission-change, EMFILE, EIO — not just the "project dir
1353
1351
  // absent" case the original comment reasoned about) hid the panel forever
1354
1352
  // even once the tree became readable again.
1355
- const home = mkdtempSync(join(tmpdir(), "spend-home-"));
1353
+ const home = tempDir("spend-home-");
1356
1354
  const proj = join(home, ".omp", "agent", "sessions", "-x");
1357
1355
  const sess = join(proj, "2026-09-08T13-13-27-300Z_aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
1358
1356
  mkdirSync(sess, { recursive: true });
@@ -1374,11 +1372,11 @@ test("--spend-dir's directory replaces the heuristic outright, including one the
1374
1372
  // a tie-breaker, a fallback, or a second opinion. The fixture gives the
1375
1373
  // heuristic a perfectly resolvable session to pick so that "the explicit one
1376
1374
  // wins" is a real preference and not the absence of an alternative.
1377
- const home = mkdtempSync(join(tmpdir(), "spend-home-"));
1375
+ const home = tempDir("spend-home-");
1378
1376
  const heuristic = join(home, ".omp", "agent", "sessions", "-x", "2026-09-08T13-13-27-300Z_aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
1379
1377
  mkdirSync(heuristic, { recursive: true });
1380
1378
  writeFileSync(join(heuristic, "agent-a.jsonl"), "");
1381
- const named = mkdtempSync(join(tmpdir(), "spend-named-"));
1379
+ const named = tempDir("spend-named-");
1382
1380
 
1383
1381
  assert.equal(findSubagentsDir(home, join(home, "x")), heuristic, "the heuristic has an answer of its own here");
1384
1382
  const pin = spendDirPin(named, home, join(home, "x"));
@@ -1393,7 +1391,7 @@ test("gatherSpend reads a handed-in null as a resolution, not as an absent argum
1393
1391
  // which is the unpinned source this ticket exists to remove. The fixture
1394
1392
  // makes that observable: $HOME here DOES hold a resolvable session, so a
1395
1393
  // re-resolve would return a panel instead of nothing.
1396
- const home = mkdtempSync(join(tmpdir(), "spend-home-"));
1394
+ const home = tempDir("spend-home-");
1397
1395
  const live = join(home, ".omp", "agent", "sessions", encodeProjectDir(process.cwd(), { home }), "2026-09-08T13-13-27-300Z_aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
1398
1396
  mkdirSync(live, { recursive: true });
1399
1397
  writeFileSync(join(live, "agent-x.jsonl"), TURN.map((l) => JSON.stringify(l)).join("\n") + "\n");
@@ -1422,14 +1420,13 @@ test("CLI: a live serve keeps the panel on the session that wrote first on its w
1422
1420
  // realpath, not the bare mkdtemp path: on darwin $TMPDIR is under /var, a
1423
1421
  // symlink to /private/var, and the child's process.cwd() reports the RESOLVED
1424
1422
  // form — encoding the unresolved one puts the fixture where nothing looks.
1425
- const cwd = realpathSync(mkdtempSync(join(tmpdir(), "spend-pin-cwd-")));
1426
- const home = mkdtempSync(join(tmpdir(), "spend-pin-home-"));
1427
- const bin = mkdtempSync(join(tmpdir(), "spend-pin-bin-"));
1423
+ const cwd = realpathSync(tempDir("spend-pin-cwd-"));
1424
+ const home = tempDir("spend-pin-home-");
1425
+ const bin = tempDir("spend-pin-bin-");
1428
1426
  // gh fails on every call and the reads degrade, so this stays offline and off
1429
1427
  // this repo's live issue list. Prepended rather than replacing PATH: gather()
1430
1428
  // shells out to `node` for the ledger read.
1431
- writeFileSync(join(bin, "gh"), "#!/bin/sh\nexit 1\n");
1432
- chmodSync(join(bin, "gh"), 0o755);
1429
+ writeExecStub(join(bin, "gh"), "#!/bin/sh\nexit 1\n");
1433
1430
  const proj = join(home, ".omp", "agent", "sessions", encodeProjectDir(cwd, { home }));
1434
1431
  const mine = join(proj, "2026-09-08T13-13-27-300Z_aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
1435
1432
  const theirs = join(proj, "2026-09-09T02-00-00-000Z_bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
@@ -1502,7 +1499,7 @@ const TURN = [
1502
1499
  ];
1503
1500
 
1504
1501
  function fixture(lines) {
1505
- const dir = mkdtempSync(join(tmpdir(), "spend-"));
1502
+ const dir = tempDir("spend-");
1506
1503
  writeFileSync(join(dir, "agent-x.jsonl"), lines.map((l) => JSON.stringify(l)).join("\n") + "\n");
1507
1504
  return dir;
1508
1505
  }
@@ -1577,7 +1574,7 @@ function withStderr(fn) {
1577
1574
  }
1578
1575
 
1579
1576
  function rawFixture(text) {
1580
- const dir = mkdtempSync(join(tmpdir(), "spend-"));
1577
+ const dir = tempDir("spend-");
1581
1578
  writeFileSync(join(dir, "agent-x.jsonl"), text);
1582
1579
  return dir;
1583
1580
  }
@@ -1621,8 +1618,8 @@ test("a torn LAST line stays silent — the tear every tick legitimately produce
1621
1618
  // this is the only test in the file that fails — dir B's line never prints,
1622
1619
  // because dir A's identical-basename skip already claimed the (mutated) key.
1623
1620
  test("two session dirs whose transcripts share a basename each get their own skip line", () => {
1624
- const dirA = mkdtempSync(join(tmpdir(), "spend-collide-a-"));
1625
- const dirB = mkdtempSync(join(tmpdir(), "spend-collide-b-"));
1621
+ const dirA = tempDir("spend-collide-a-");
1622
+ const dirB = tempDir("spend-collide-b-");
1626
1623
  mkdirSync(join(dirA, "agent-x.jsonl")); // directory where a file is expected -> EISDIR, unreadable
1627
1624
  mkdirSync(join(dirB, "agent-x.jsonl")); // same basename, different session dir
1628
1625
  const errs = withStderr(() => {
@@ -1774,7 +1771,7 @@ test("every gatherSpend return carries the tag the page routes on (#959)", () =>
1774
1771
  // The unresolvable-dir return.
1775
1772
  assert.equal(gatherSpend({ dir: { error: "no session directory for this cwd" } }).ok, false);
1776
1773
  // The all-unreadable return: a dir holding only a transcript that cannot be read.
1777
- const allBad = mkdtempSync(join(tmpdir(), "spend-"));
1774
+ const allBad = tempDir("spend-");
1778
1775
  mkdirSync(join(allBad, "agent-trap.jsonl")); // a directory where a file is expected
1779
1776
  let bad;
1780
1777
  withStderr(() => { bad = gatherSpend({ dir: allBad }); }); // it warns; the warning is not what is under test
@@ -1783,7 +1780,7 @@ test("every gatherSpend return carries the tag the page routes on (#959)", () =>
1783
1780
  // The success return.
1784
1781
  assert.equal(gatherSpend({ dir: fixture(TURN) }).ok, true);
1785
1782
  // And the one return that is deliberately NOT an object: nothing yet.
1786
- assert.equal(gatherSpend({ dir: mkdtempSync(join(tmpdir(), "spend-")) }), null);
1783
+ assert.equal(gatherSpend({ dir: tempDir("spend-") }), null);
1787
1784
  });
1788
1785
 
1789
1786
  // #169: `arg()` is CLI-internal (not exported), so this pins the trailing-flag
@@ -2009,8 +2006,8 @@ test("CLI: a malformed --port with no subcommand names the flag, not the usage l
2009
2006
  // fresh mkdtemp cwd what keeps them from sharing a state directory.
2010
2007
  const serveArgs = (args) => [SCRIPT, "serve", ...args];
2011
2008
  const serveOpts = () => ({
2012
- cwd: mkdtempSync(join(tmpdir(), "board-serve-")),
2013
- env: { ...process.env, PATH: mkdtempSync(join(tmpdir(), "board-nobin-")) },
2009
+ cwd: tempDir("board-serve-"),
2010
+ env: { ...process.env, PATH: tempDir("board-nobin-") },
2014
2011
  encoding: "utf8",
2015
2012
  timeout: 20000,
2016
2013
  });
@@ -2053,8 +2050,8 @@ function muteHolder() {
2053
2050
  test("CLI: a derived port held by anything is fatal on the degrade arm — there is no identity to scan for", async () => {
2054
2051
  const blocker = createServer();
2055
2052
  await new Promise((res) => { blocker.once("error", res); blocker.listen(8123, res); });
2056
- const nobin = mkdtempSync(join(tmpdir(), "board-nobin-"));
2057
- const cwd = mkdtempSync(join(tmpdir(), "board-serve-"));
2053
+ const nobin = tempDir("board-nobin-");
2054
+ const cwd = tempDir("board-serve-");
2058
2055
  try {
2059
2056
  const r = serveSync(cwd, nobin, ["--interval", "3600"]);
2060
2057
  assert.equal(r.status, 2, `a held derived port on the degrade arm must refuse, not scan past it: ${r.stderr}`);
@@ -2138,7 +2135,7 @@ test("CLI: serve --spend-dir reads the named directory's spend into every tick,
2138
2135
  // refuses a --spend-dir whose own basename is not an omp session dir
2139
2136
  // (#1302-style guard), so this fixture must look like one to keep testing
2140
2137
  // what it says it tests — the named directory's data reaching the panel.
2141
- const root = mkdtempSync(join(tmpdir(), "spend-named-"));
2138
+ const root = tempDir("spend-named-");
2142
2139
  const dir = join(root, "2026-08-25T09-00-00-000Z_abcdef12-3456-7890-abcd-ef1234567890");
2143
2140
  mkdirSync(dir, { recursive: true });
2144
2141
  writeFileSync(join(dir, "named.jsonl"), TURN.map((l) => JSON.stringify(l)).join("\n") + "\n");
@@ -2352,7 +2349,7 @@ test("resolveCockpitInstance: a fixed workspace pins the FNV-1a-with-Math.imul p
2352
2349
  // SECOND port and a second state directory for a workspace already being
2353
2350
  // served, which is the collision this ticket exists to prevent.
2354
2351
  test("resolveCockpitInstance: a symlinked route to one workspace derives the canonical form's port", () => {
2355
- const root = mkdtempSync(join(tmpdir(), "board-ws-link-"));
2352
+ const root = tempDir("board-ws-link-");
2356
2353
  try {
2357
2354
  const real = join(root, "repo");
2358
2355
  mkdirSync(join(real, ".git"), { recursive: true });
@@ -2425,7 +2422,7 @@ test("resolveCockpitInstance: an explicit port survives the degrade path too", (
2425
2422
  // `git rev-parse`, while gh and node must stay unreachable so these spawns
2426
2423
  // remain offline and fast — the same intent serveOpts()'s empty PATH has.
2427
2424
  function gitOnlyPath() {
2428
- const bin = mkdtempSync(join(tmpdir(), "board-gitbin-"));
2425
+ const bin = tempDir("board-gitbin-");
2429
2426
  const real = spawnSync("sh", ["-c", "command -v git"], { encoding: "utf8" });
2430
2427
  assert.equal(real.status, 0, "test setup: no git on PATH to shim, so the resolved arm cannot be reached");
2431
2428
  symlinkSync(real.stdout.trim(), join(bin, "git"));
@@ -2433,7 +2430,7 @@ function gitOnlyPath() {
2433
2430
  }
2434
2431
 
2435
2432
  function gitRepo(prefix) {
2436
- const dir = mkdtempSync(join(tmpdir(), prefix));
2433
+ const dir = tempDir(prefix);
2437
2434
  // GIT_DIR/GIT_WORK_TREE scrubbed off the FIXTURE too: under an ambient one
2438
2435
  // `git init` exits 0 having re-inited whichever directory the variable
2439
2436
  // names, leaving this one silently not a repository (ledger.test.mjs hit
@@ -2632,7 +2629,7 @@ async function holderOn(dir, port = 0) {
2632
2629
  }
2633
2630
 
2634
2631
  const boardDir = (payload) => {
2635
- const dir = mkdtempSync(join(tmpdir(), "board-holder-"));
2632
+ const dir = tempDir("board-holder-");
2636
2633
  if (payload !== undefined) writeFileSync(join(dir, "board.json"), payload);
2637
2634
  return dir;
2638
2635
  };
@@ -2741,8 +2738,7 @@ function launcherBin(launchers) {
2741
2738
  const bin = gitOnlyPath();
2742
2739
  const log = join(bin, "launched.log");
2743
2740
  for (const [name, code] of Object.entries(launchers)) {
2744
- writeFileSync(join(bin, name), `#!/bin/sh\necho "${name} $*" >> '${log}'\nexit ${code}\n`);
2745
- chmodSync(join(bin, name), 0o755);
2741
+ writeExecStub(join(bin, name), `#!/bin/sh\necho "${name} $*" >> '${log}'\nexit ${code}\n`);
2746
2742
  }
2747
2743
  return { bin, launched: () => (existsSync(log) ? readFileSync(log, "utf8").split("\n").filter(Boolean) : []) };
2748
2744
  }
@@ -2882,7 +2878,7 @@ for (const [platform, launchers, ran, warns] of [
2882
2878
  ]) {
2883
2879
  const onPath = Object.entries(launchers).map(([n, c]) => (c ? `${n} (exit ${c})` : n)).join(", ");
2884
2880
  test(`CLI: a fresh --open launch on ${platform} with ${onPath} on PATH runs ${ran.join(" ") || "no launcher"}${warns ? " and warns with the URL" : ""}`, async () => {
2885
- const rig = launcherBin(launchers), cwd = mkdtempSync(join(tmpdir(), "board-open-"));
2881
+ const rig = launcherBin(launchers), cwd = tempDir("board-open-");
2886
2882
  const launch = serveOn(platform, cwd, rig.bin);
2887
2883
  const exited = new Promise((res) => launch.p.on("exit", (code, signal) => res({ code, signal })));
2888
2884
  try {