@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
@@ -17,6 +17,7 @@ import { mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
17
17
  import { tmpdir } from "node:os";
18
18
  import { join } from "node:path";
19
19
  import { fileURLToPath } from "node:url";
20
+ import { writeExecStub } from "./exec-stub.mjs";
20
21
 
21
22
  const CLAIM = fileURLToPath(new URL("./claim-ticket.sh", import.meta.url));
22
23
  const REAP = fileURLToPath(new URL("./reap.sh", import.meta.url));
@@ -53,7 +54,7 @@ function fixture(t) {
53
54
  execFileSync("git", ["-c", "init.defaultBranch=main", "init", "-q", "--bare", origin], { env: BASE_ENV });
54
55
  execFileSync("git", ["clone", "-q", origin, w], { env: BASE_ENV });
55
56
  execFileSync("mkdir", ["-p", bin]);
56
- writeFileSync(join(bin, "gh"), '#!/bin/sh\ncase "$*" in *"issue view"*) echo in-progress;; esac\nexit 0\n', { mode: 0o755 });
57
+ writeExecStub(join(bin, "gh"), '#!/bin/sh\ncase "$*" in *"issue view"*) echo in-progress;; esac\nexit 0\n');
57
58
  const env = { ...BASE_ENV, PATH: `${bin}:${process.env.PATH}` };
58
59
  const git = (cwd, ...a) => execFileSync("git", a, { cwd, env, encoding: "utf8" }).trim();
59
60
  writeFileSync(join(w, "README.md"), "fixture\n");
@@ -3,7 +3,9 @@ import assert from "node:assert/strict";
3
3
  import { execFileSync, spawnSync } from "node:child_process";
4
4
  import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, chmodSync, existsSync, symlinkSync, copyFileSync } from "node:fs";
5
5
  import { tmpdir } from "node:os";
6
+ import { tempDir } from "./temp-dir.mjs";
6
7
  import { join, dirname } from "node:path";
8
+ import { writeExecStub } from "./exec-stub.mjs";
7
9
 
8
10
  const SCRIPT = join(import.meta.dirname, "claim-ticket.sh");
9
11
 
@@ -26,7 +28,7 @@ const FIXTURE_ENV = { ...process.env, GIT_DIR: undefined, GIT_WORK_TREE: undefin
26
28
  // overridable; `null` writes no cache at all. The default is the smallest
27
29
  // Recipe that runs anywhere: nothing to install, nothing to fail.
28
30
  function repo(files, local = {}, recipe = {}) {
29
- const dir = mkdtempSync(join(tmpdir(), "claim-"));
31
+ const dir = tempDir("claim-");
30
32
  const git = (...a) => execFileSync("git", a, { cwd: dir, stdio: "pipe", env: FIXTURE_ENV, encoding: "utf8" });
31
33
  git("init", "-q");
32
34
  git("config", "user.email", "t@t");
@@ -77,8 +79,8 @@ const TESTS = "run-tests.sh";
77
79
  // template.
78
80
  function apply(files, script = SCRIPT, recipe = {}) {
79
81
  const dir = repo(files, {}, recipe);
80
- const bin = mkdtempSync(join(tmpdir(), "claim-bin-"));
81
- writeFileSync(join(bin, "gh"), "#!/bin/sh\nexit 0\n", { mode: 0o755 });
82
+ const bin = tempDir("claim-bin-");
83
+ writeExecStub(join(bin, "gh"), "#!/bin/sh\nexit 0\n");
82
84
  const r = spawnSync("sh", [script, "42", "slug", "fix", "--apply"], {
83
85
  cwd: dir,
84
86
  encoding: "utf8",
@@ -226,7 +228,7 @@ test("runner: the stamp is stable across claims of the same template", () => {
226
228
  // script and the stamp must move. Copying rather than editing the real
227
229
  // script in place keeps this test from mutating the file under test.
228
230
  test("runner: the stamp changes when the script's content changes", () => {
229
- const scriptDir = mkdtempSync(join(tmpdir(), "claim-script-"));
231
+ const scriptDir = tempDir("claim-script-");
230
232
  const editedScript = join(scriptDir, "claim-ticket.sh");
231
233
  writeFileSync(editedScript, readFileSync(SCRIPT, "utf8") + "\n# a harmless edit\n");
232
234
  // claim-ticket.sh resolves three siblings relative to itself
@@ -236,8 +238,7 @@ test("runner: the stamp changes when the script's content changes", () => {
236
238
  // edited copy or the script refuses before it emits anything — which is the
237
239
  // guard working, not a regression.
238
240
  const sibling = join(scriptDir, "derive-testcmd.sh");
239
- copyFileSync(join(import.meta.dirname, "derive-testcmd.sh"), sibling);
240
- chmodSync(sibling, 0o755);
241
+ writeExecStub(sibling, readFileSync(join(import.meta.dirname, "derive-testcmd.sh"), "utf8"));
241
242
  for (const lib of ["json.sh", "worktree.sh"]) {
242
243
  copyFileSync(join(import.meta.dirname, lib), join(scriptDir, lib));
243
244
  }
@@ -303,7 +304,7 @@ for (const [what, stub] of [
303
304
  ]) {
304
305
  test(`a checksum that ${what} refuses before anything is claimed, in both modes`, () => {
305
306
  const dir = repo({ [TESTS]: "" });
306
- const bin = mkdtempSync(join(tmpdir(), "claim cksum-"));
307
+ const bin = tempDir("claim cksum-");
307
308
  assert.match(bin, / /, "fixture: the stub's directory must hold a space, or this pins nothing");
308
309
  const ghLog = join(bin, "gh.log");
309
310
  // `>> "$GH_LOG"`, not the interpolated path (#880). The path comes from
@@ -314,8 +315,8 @@ for (const [what, stub] of [
314
315
  // ci-state.test.mjs's GH_STUB form keeps the path out of the script text.
315
316
  // The prefix above now holds a space so this shape is exercised on every
316
317
  // machine, not only one whose TMPDIR has one.
317
- writeFileSync(join(bin, "gh"), `#!/bin/sh\necho "$@" >> "$GH_LOG"\nexit 0\n`, { mode: 0o755 });
318
- writeFileSync(join(bin, "cksum"), stub, { mode: 0o755 });
318
+ writeExecStub(join(bin, "gh"), `#!/bin/sh\necho "$@" >> "$GH_LOG"\nexit 0\n`);
319
+ writeExecStub(join(bin, "cksum"), stub);
319
320
  const env = { ...process.env, PATH: `${bin}:${process.env.PATH}`, GH_LOG: ghLog };
320
321
 
321
322
  const r = spawnSync("sh", [SCRIPT, "42", "slug", "fix", "--apply"], { cwd: dir, encoding: "utf8", env });
@@ -370,9 +371,9 @@ test("an absent Recipe cache refuses the claim before anything is claimed, namin
370
371
  assert.match(dry.err, /claim-ticket: derive-testcmd: no Recipe cache at .*\/\.fleet\/recipe\.json/);
371
372
  assert.match(dry.err, /run the Recipe derivation step \(run-team phase 0/);
372
373
 
373
- const bin = mkdtempSync(join(tmpdir(), "claim-bin-"));
374
+ const bin = tempDir("claim-bin-");
374
375
  const ghLog = join(bin, "gh.log");
375
- writeFileSync(join(bin, "gh"), '#!/bin/sh\necho "$@" >> "$GH_LOG"\nexit 0\n', { mode: 0o755 });
376
+ writeExecStub(join(bin, "gh"), '#!/bin/sh\necho "$@" >> "$GH_LOG"\nexit 0\n');
376
377
  const r = spawnSync("sh", [SCRIPT, "42", "slug", "fix", "--apply"], {
377
378
  cwd: dir, encoding: "utf8", env: { ...process.env, PATH: `${bin}:${process.env.PATH}`, GH_LOG: ghLog },
378
379
  });
@@ -405,8 +406,8 @@ test("a repo with no origin/main refuses before anything is claimed", () => {
405
406
  // Install step only runs under --apply.
406
407
  function applyRecipe(recipe, files = { [TESTS]: "" }, local = {}) {
407
408
  const dir = repo(files, local, recipe);
408
- const bin = mkdtempSync(join(tmpdir(), "claim-bin-"));
409
- writeFileSync(join(bin, "gh"), "#!/bin/sh\nexit 0\n", { mode: 0o755 });
409
+ const bin = tempDir("claim-bin-");
410
+ writeExecStub(join(bin, "gh"), "#!/bin/sh\nexit 0\n");
410
411
  const r = spawnSync("sh", [SCRIPT, "42", "slug", "fix", "--apply"], {
411
412
  cwd: dir, encoding: "utf8", env: { ...process.env, PATH: `${bin}:${process.env.PATH}` },
412
413
  });
@@ -442,8 +443,8 @@ test("an Install step that writes only ignored files claims cleanly", () => {
442
443
  test("an Install step that cannot run is named an invalid cache; one that fails is named failing", () => {
443
444
  const dir = repo({ [TESTS]: "" }, { "setup.sh": "#!/bin/sh\n" }, { install: "./setup.sh" });
444
445
  chmodSync(join(dir, "setup.sh"), 0o755);
445
- const bin = mkdtempSync(join(tmpdir(), "claim-bin-"));
446
- writeFileSync(join(bin, "gh"), "#!/bin/sh\nexit 0\n", { mode: 0o755 });
446
+ const bin = tempDir("claim-bin-");
447
+ writeExecStub(join(bin, "gh"), "#!/bin/sh\nexit 0\n");
447
448
  const env = { ...process.env, PATH: `${bin}:${process.env.PATH}` };
448
449
  const r = spawnSync("sh", [SCRIPT, "42", "slug", "fix", "--apply"], { cwd: dir, encoding: "utf8", env });
449
450
  assert.equal(r.status, 2, r.stdout + r.stderr);
@@ -469,8 +470,8 @@ test("an Install step that cannot run is named an invalid cache; one that fails
469
470
  test("an Install step present but not executable is also named an invalid cache (exit 126)", () => {
470
471
  const dir = repo({ [TESTS]: "", "setup.sh": "#!/bin/sh\n" }, {}, { install: "./setup.sh" });
471
472
  chmodSync(join(dir, "setup.sh"), 0o755);
472
- const bin = mkdtempSync(join(tmpdir(), "claim-bin-"));
473
- writeFileSync(join(bin, "gh"), "#!/bin/sh\nexit 0\n", { mode: 0o755 });
473
+ const bin = tempDir("claim-bin-");
474
+ writeExecStub(join(bin, "gh"), "#!/bin/sh\nexit 0\n");
474
475
  const env = { ...process.env, PATH: `${bin}:${process.env.PATH}` };
475
476
  const r = spawnSync("sh", [SCRIPT, "42", "slug", "fix", "--apply"], { cwd: dir, encoding: "utf8", env });
476
477
  assert.equal(r.status, 2, r.stdout + r.stderr);
@@ -514,8 +515,8 @@ test("an install that creates an UNTRACKED file is caught under status.showUntra
514
515
  const dir = repo({ [TESTS]: "" }, {}, { install: "printf '{}' > yarn.lock" });
515
516
  // On the repo's own config, so the linked worktree the check runs in shares it.
516
517
  execFileSync("git", ["config", "status.showUntrackedFiles", "no"], { cwd: dir, stdio: "pipe" });
517
- const bin = mkdtempSync(join(tmpdir(), "claim-bin-"));
518
- writeFileSync(join(bin, "gh"), "#!/bin/sh\nexit 0\n", { mode: 0o755 });
518
+ const bin = tempDir("claim-bin-");
519
+ writeExecStub(join(bin, "gh"), "#!/bin/sh\nexit 0\n");
519
520
  const r = spawnSync("sh", [SCRIPT, "42", "slug", "fix", "--apply"], {
520
521
  cwd: dir,
521
522
  encoding: "utf8",
@@ -645,10 +646,10 @@ test("--apply refuses an unreadable ancestor BEFORE the in-progress label", (t)
645
646
  // above (#880): interpolated unquoted, this marker path word-split under a
646
647
  // spaced `TMPDIR` and recorded nothing, turning the assertion below into a
647
648
  // pin that passes hardest exactly when the stub is broken.
648
- const bin = mkdtempSync(join(tmpdir(), "claim bin-"));
649
+ const bin = tempDir("claim bin-");
649
650
  assert.match(bin, / /, "fixture: the stub's directory must hold a space, or this pins nothing");
650
651
  const marker = join(bin, "gh-ran");
651
- writeFileSync(join(bin, "gh"), `#!/bin/sh\necho "$@" >> "$GH_LOG"\nexit 0\n`, { mode: 0o755 });
652
+ writeExecStub(join(bin, "gh"), `#!/bin/sh\necho "$@" >> "$GH_LOG"\nexit 0\n`);
652
653
  const env = { ...process.env, PATH: `${bin}:${process.env.PATH}`, GH_LOG: marker };
653
654
 
654
655
  const r = spawnSync("sh", [SCRIPT, "42", "slug", "fix", "--apply"], {
@@ -741,10 +742,10 @@ test("an ordinary slug is byte-identical — the escaping accepts what it should
741
742
  // before a worktree, a label or a runner exists.
742
743
  test("a missing json.sh is exit 2, before anything is created", () => {
743
744
  const dir = repo({ [TESTS]: "" });
744
- const lone = mkdtempSync(join(tmpdir(), "claim-nolib-"));
745
+ const lone = tempDir("claim-nolib-");
745
746
  copyFileSync(SCRIPT, join(lone, "claim-ticket.sh"));
746
- const bin = mkdtempSync(join(tmpdir(), "claim-nolib-bin-"));
747
- writeFileSync(join(bin, "gh"), "#!/bin/sh\nexit 0\n", { mode: 0o755 });
747
+ const bin = tempDir("claim-nolib-bin-");
748
+ writeExecStub(join(bin, "gh"), "#!/bin/sh\nexit 0\n");
748
749
 
749
750
  const r = spawnSync("sh", [join(lone, "claim-ticket.sh"), "42", "slug", "fix", "--apply"], {
750
751
  cwd: dir, encoding: "utf8", env: { ...process.env, PATH: `${bin}:${process.env.PATH}` },
@@ -761,11 +762,11 @@ test("a missing json.sh is exit 2, before anything is created", () => {
761
762
  // (#727's fourth caller of `gone()`) — json.sh present, worktree.sh absent.
762
763
  test("a missing worktree.sh is exit 2, before anything is created", () => {
763
764
  const dir = repo({ [TESTS]: "" });
764
- const lone = mkdtempSync(join(tmpdir(), "claim-nowt-"));
765
+ const lone = tempDir("claim-nowt-");
765
766
  copyFileSync(SCRIPT, join(lone, "claim-ticket.sh"));
766
767
  copyFileSync(join(dirname(SCRIPT), "json.sh"), join(lone, "json.sh"));
767
- const bin = mkdtempSync(join(tmpdir(), "claim-nowt-bin-"));
768
- writeFileSync(join(bin, "gh"), "#!/bin/sh\nexit 0\n", { mode: 0o755 });
768
+ const bin = tempDir("claim-nowt-bin-");
769
+ writeExecStub(join(bin, "gh"), "#!/bin/sh\nexit 0\n");
769
770
 
770
771
  const r = spawnSync("sh", [join(lone, "claim-ticket.sh"), "42", "slug", "fix", "--apply"], {
771
772
  cwd: dir, encoding: "utf8", env: { ...process.env, PATH: `${bin}:${process.env.PATH}` },
@@ -813,8 +814,8 @@ const REAL_SED = execFileSync("sh", ["-c", "command -v sed"], { encoding: "utf8"
813
814
 
814
815
  /** A dir holding a `sed` shim with the given body, prepended to PATH. */
815
816
  function sedShim(body) {
816
- const bin = mkdtempSync(join(tmpdir(), "claim-sed-shim-"));
817
- writeFileSync(join(bin, "sed"), `#!/bin/sh\n${body}\n`, { mode: 0o755 });
817
+ const bin = tempDir("claim-sed-shim-");
818
+ writeExecStub(join(bin, "sed"), `#!/bin/sh\n${body}\n`);
818
819
  return `${bin}:${process.env.PATH}`;
819
820
  }
820
821
 
@@ -891,7 +892,7 @@ test("a shadowed `sed` that works claims normally — the guard refuses only a r
891
892
  // derive-testcmd.sh's stderr capture.
892
893
  const SHIMMED = ["sh", "git", "sed", "tr", "python3", "dirname", "cksum", "grep", "mktemp", "cat", "rm"];
893
894
  function shimPath({ node }) {
894
- const bin = mkdtempSync(join(tmpdir(), "claim-path-"));
895
+ const bin = tempDir("claim-path-");
895
896
  for (const name of SHIMMED) {
896
897
  const real = execFileSync("sh", ["-c", `command -v ${name}`], { encoding: "utf8" }).trim();
897
898
  symlinkSync(real, join(bin, name));
@@ -943,10 +944,10 @@ function ghSpy() {
943
944
  // the same job is what lets the unquoted one look normal, and the
944
945
  // `ran() === true` assertion in the accept test below is what holds the env
945
946
  // threading here honest.
946
- const bin = mkdtempSync(join(tmpdir(), "claim ghspy-"));
947
+ const bin = tempDir("claim ghspy-");
947
948
  assert.match(bin, / /, "fixture: the stub's directory must hold a space, or this pins nothing");
948
949
  const marker = join(bin, "ran");
949
- writeFileSync(join(bin, "gh"), `#!/bin/sh\necho "$@" >> "$GH_LOG"\nexit 0\n`, { mode: 0o755 });
950
+ writeExecStub(join(bin, "gh"), `#!/bin/sh\necho "$@" >> "$GH_LOG"\nexit 0\n`);
950
951
  return { env: { ...process.env, PATH: `${bin}:${process.env.PATH}`, GH_LOG: marker }, ran: () => existsSync(marker) };
951
952
  }
952
953
 
@@ -1093,8 +1094,8 @@ test("an ambient GIT_WORK_TREE does not make a mutated tree look clean (#1020)",
1093
1094
  // cross-platform optional deps out of a lockfile is the header's own example.
1094
1095
  const files = { [TESTS]: "", ".gitignore": ".fleet/\n.worktrees/\n" };
1095
1096
  const recipe = { install: "echo MUTATED >> run-tests.sh" };
1096
- const bin = mkdtempSync(join(tmpdir(), "claim-bin-"));
1097
- writeFileSync(join(bin, "gh"), "#!/bin/sh\nexit 0\n", { mode: 0o755 });
1097
+ const bin = tempDir("claim-bin-");
1098
+ writeExecStub(join(bin, "gh"), "#!/bin/sh\nexit 0\n");
1098
1099
  const env = (extra) => ({ ...FIXTURE_ENV, PATH: `${bin}:${process.env.PATH}`, ...extra });
1099
1100
 
1100
1101
  // The control, and it is not optional: it proves the install really mutates
@@ -150,7 +150,7 @@ test("a reflowed section still matches", () => {
150
150
  // anchors as force-with-lease-reason-prose.test.mjs's step-7 slice.
151
151
  const NEXT_TICKET = readFileSync(join(REPO, "plugin", "skills", "next-ticket", "SKILL.md"), "utf8");
152
152
  const step7 = (text = NEXT_TICKET) =>
153
- between(text, "## 7. When the superpowers path reports done", "## Red flags", "next-ticket/SKILL.md step 7");
153
+ between(text, "## 7. When the sizing-a-ticket path reports done", "## Red flags", "next-ticket/SKILL.md step 7");
154
154
 
155
155
  test("next-ticket step 7 says one keyword per intended close, and that several such closes are fine", () => {
156
156
  // The per-issue half and the multi-close example are one span: a rewrite to
@@ -25,13 +25,14 @@
25
25
  import { test } from "node:test";
26
26
  import assert from "node:assert/strict";
27
27
  import { spawn, spawnSync } from "node:child_process";
28
- import { mkdtempSync, writeFileSync, chmodSync, symlinkSync, rmSync, realpathSync, existsSync } from "node:fs";
28
+ import { symlinkSync, rmSync, realpathSync, existsSync } from "node:fs";
29
29
  import { createServer } from "node:net";
30
- import { tmpdir } from "node:os";
30
+ import { tempDir } from "./temp-dir.mjs";
31
31
  import { join } from "node:path";
32
32
  import { fileURLToPath } from "node:url";
33
33
  import { resolveCockpitInstance, cockpitPorts, probeCockpitWorkspace } from "./board.mjs";
34
34
  import { gitEnv } from "./git-env.mjs";
35
+ import { writeExecStub } from "./exec-stub.mjs";
35
36
 
36
37
  const SCRIPT = fileURLToPath(new URL("./board.mjs", import.meta.url));
37
38
 
@@ -61,12 +62,11 @@ const slowGh = (mark) => "#!/bin/sh\ncase \"$1 $2\" in\n"
61
62
  // ledger.mjs — the same shim board-identity.test.mjs uses, and no row here
62
63
  // asserts a ticket.
63
64
  function shimPath(mark) {
64
- const bin = mkdtempSync(join(tmpdir(), "tick-bin-"));
65
+ const bin = tempDir("tick-bin-");
65
66
  const real = spawnSync("sh", ["-c", "command -v git"], { encoding: "utf8" });
66
67
  assert.equal(real.status, 0, "test setup: no git on PATH to shim, so the derived-port arm cannot be reached");
67
68
  symlinkSync(real.stdout.trim(), join(bin, "git"));
68
- writeFileSync(join(bin, "gh"), slowGh(mark));
69
- chmodSync(join(bin, "gh"), 0o755);
69
+ writeExecStub(join(bin, "gh"), slowGh(mark));
70
70
  return bin;
71
71
  }
72
72
 
@@ -74,7 +74,7 @@ function shimPath(mark) {
74
74
  // which is a symlink to /private/var, and resolveCockpitInstance canonicalises
75
75
  // the workspace it derives.
76
76
  function gitRepo(prefix) {
77
- const dir = realpathSync(mkdtempSync(join(tmpdir(), prefix)));
77
+ const dir = realpathSync(tempDir(prefix));
78
78
  // GIT_DIR/GIT_WORK_TREE scrubbed off the fixture: under an ambient one `git
79
79
  // init` exits 0 having re-inited whichever directory the variable names.
80
80
  const init = spawnSync("git", ["init", "-q"], { cwd: dir, stdio: "ignore", env: gitEnv() });
@@ -148,9 +148,9 @@ const boardJson = async (port) => {
148
148
  // candidate and never exits, so spawnSync reports the timeout instead of 0.
149
149
  test("CLI: a relaunch that lands mid-gather() is answered within 1s and reuses the live cockpit", async () => {
150
150
  const repo = gitRepo("tick-block-");
151
- const mark = join(mkdtempSync(join(tmpdir(), "tick-mark-")), "gathering");
151
+ const mark = join(tempDir("tick-mark-"), "gathering");
152
152
  const bin = shimPath(mark);
153
- const home = mkdtempSync(join(tmpdir(), "tick-home-"));
153
+ const home = tempDir("tick-home-");
154
154
  const instance = resolveCockpitInstance({ cwd: repo, gitCommonDir: join(repo, ".git") });
155
155
  const expected = await firstFreePort(cockpitPorts(instance));
156
156
  const first = serveProcess(repo, bin, home);
@@ -25,7 +25,7 @@
25
25
  // here, main() being guarded on argv[1].
26
26
  import { assessBeat, isStalled, stallReport } from "./fleet-state.mjs";
27
27
  import { parseToken, HALT_CAUSES } from "./ledger-grammar.mjs";
28
- import { PR_MENTION, REVIEWED } from "./fleet-tick.mjs";
28
+ import { PR_MENTION, REVIEWED, unlabelledFinishers } from "./fleet-tick.mjs";
29
29
 
30
30
  // A ledger row is freeform, controller-authored text. Two real examples:
31
31
  // #332 impl-332=PR#344 → PR#344 → MERGED 73b356de
@@ -65,6 +65,13 @@ import { PR_MENTION, REVIEWED } from "./fleet-tick.mjs";
65
65
  // finisher tokens bound to the row's own PR: a live `-b` after the halt
66
66
  // clears it.
67
67
  //
68
+ // #2331: a PR whose finisher settled `labelled` while the open list shows no
69
+ // `ready-to-merge` on it carries a severity-4 `unlabelled` flag in REVIEW —
70
+ // fleet-tick.mjs's own reading (unlabelledFinishers: the latest attempt since
71
+ // the last `label-off=`), off the same `## Dispatched` and row tokens the tick
72
+ // reads, so the card is flagged whenever the tick is repairing it or escalated
73
+ // it — including after a whole-line `row` rewrite dropped the settled token.
74
+ //
68
75
  // A PR's review is not a member (#1773 §7): `review=wf:<runId>` is a Workflow
69
76
  // with nobody to name, while `review=member:<name>` and
70
77
  // `review=fallback:<name>` name a runner member, live until the token is
@@ -288,6 +295,7 @@ export function deriveFlags(parsed, ctx) {
288
295
  // gap the other way: still counted due for a fresh review while this flag
289
296
  // is up and the head has not caught up to what was reviewed.
290
297
  if (parsed.finisherOutcome?.startsWith("halted:") && ctx.column === "REVIEW") flags.push(parsed.finisherOutcome);
298
+ if (ctx.unlabelled && ctx.column === "REVIEW") flags.push("unlabelled");
291
299
  const limit = STALE_MS[ctx.column];
292
300
  if (limit != null && ctx.sinceEnteredStage != null && ctx.now - ctx.sinceEnteredStage > limit) {
293
301
  flags.push("stale");
@@ -316,7 +324,7 @@ function titleFor(issue, pr, issues) {
316
324
  }
317
325
 
318
326
  const FLAG_SEVERITY = {
319
- "red-ci": 5, "ledger-error": 5, killed: 4, "tier-mismatch": 4, blocked: 4, "sha-off-branch": 4,
327
+ "red-ci": 5, "ledger-error": 5, killed: 4, "tier-mismatch": 4, blocked: 4, "sha-off-branch": 4, unlabelled: 4,
320
328
  ...Object.fromEntries(HALT_CAUSES.map((c) => [`halted:${c}`, 4])),
321
329
  stale: 1,
322
330
  };
@@ -444,6 +452,8 @@ export function computeBoard(inputs) {
444
452
  }
445
453
 
446
454
  const parsed = (ledger.rows || []).map(parseRow).filter(Boolean);
455
+ const unqueued = new Set(prs.filter((p) => p.state === "OPEN" && !(p.labels || []).includes("ready-to-merge")).map((p) => p.number));
456
+ const unlabelled = new Set(unlabelledFinishers({ rows: ledger.rows || [], dispatched: ledger.dispatched || [] }, unqueued).map((u) => u.pr));
447
457
  const rowIssues = new Set();
448
458
  const tickets = [];
449
459
 
@@ -458,7 +468,7 @@ export function computeBoard(inputs) {
458
468
  rowIssues.add(p.issue);
459
469
  const sinceEnteredStage = stageEntry(prevTicket, column, now);
460
470
  const ciState = p.pr != null ? (ci[p.pr] ?? "unknown") : null;
461
- const flags = deriveFlags(p, { ci: ciState, column, sinceEnteredStage, now });
471
+ const flags = deriveFlags(p, { ci: ciState, column, sinceEnteredStage, now, unlabelled: unlabelled.has(p.pr) });
462
472
  tickets.push({
463
473
  issue: p.issue,
464
474
  title: titleFor(p.issue, pr, issues),
@@ -596,7 +596,8 @@ test("#2083: a later finisher attempt decides — a live or labelled `-b` clears
596
596
  for (const [row, flags] of [
597
597
  ["#941 impl-941=PR#931 · finisher-pr-931=halted:past-pin · finisher-pr-931-b", []],
598
598
  ["#941 impl-941=PR#931 · finisher-pr-931-b · finisher-pr-931=halted:past-pin", []],
599
- ["#941 impl-941=PR#931 · finisher-pr-931=halted:live-editor · finisher-pr-931-b=labelled", []],
599
+ // The halt clears; the `-b` labelled a PR that still has no label (#2331).
600
+ ["#941 impl-941=PR#931 · finisher-pr-931=halted:live-editor · finisher-pr-931-b=labelled", ["unlabelled"]],
600
601
  ["#941 impl-941=PR#931 · finisher-pr-931=failed · finisher-pr-931-b=halted:rebase", ["halted:rebase"]],
601
602
  // A bare copy beside the settled token is what a whole-line rewrite
602
603
  // leaves; the member is still settled halted.
@@ -620,6 +621,68 @@ test("#2083: a halt a human already resolved — PR labelled or merged — flags
620
621
  assert.deepEqual(card(merged, 941).flags, []);
621
622
  });
622
623
 
624
+ // #2331: a finisher settled `labelled` on a PR the open list shows without
625
+ // `ready-to-merge` — the tick's reading, flagged at severity 4 whether the tick
626
+ // is repairing it or has escalated it.
627
+ test("#2331: a labelled finisher on a PR without ready-to-merge flags unlabelled, ranked exactly at severity 4", () => {
628
+ const b = computeBoard(reproInputs({
629
+ rows: ["#904 impl-904=killed", "#941 impl-941=PR#931 · finisher-pr-931=labelled", "#942 impl-942=killed",
630
+ "#943 impl-943=PR#932 · held-behind:#931"],
631
+ prev: { tickets: [] },
632
+ }));
633
+ assert.equal(card(b, 941).column, "REVIEW");
634
+ assert.deepEqual(card(b, 941).flags, ["unlabelled"]);
635
+ assert.deepEqual(b.attention.map((t) => t.issue), [904, 941, 942, 943]);
636
+ // Escalated (a second labelled attempt) flags the same.
637
+ assert.deepEqual(cardFor("#941 impl-941=PR#931 · finisher-pr-931=labelled · finisher-pr-931-b=labelled", 941).card.flags, ["unlabelled"]);
638
+ });
639
+
640
+ test("#2331: the label present, a live repair, a label-off'd attempt, or a closed PR flags nothing", () => {
641
+ const ready = computeBoard(reproInputs({ rows: ["#941 impl-941=PR#931 · finisher-pr-931=labelled"],
642
+ prs: [openPr(931, ["ready-to-merge"])], prev: { tickets: [] } }));
643
+ assert.equal(card(ready, 941).column, "READY");
644
+ assert.deepEqual(card(ready, 941).flags, []);
645
+ for (const row of [
646
+ "#941 impl-941=PR#931 · finisher-pr-931=labelled · finisher-pr-931-b",
647
+ "#941 impl-941=PR#931 · finisher-pr-931=labelled label-off=finisher-pr-931",
648
+ "#941 impl-941=PR#931 · finisher-pr-931",
649
+ ]) {
650
+ assert.deepEqual(cardFor(row, 941).card.flags, [], row);
651
+ }
652
+ const merged = computeBoard(reproInputs({ rows: ["#941 impl-941=PR#931 · finisher-pr-931=labelled"], prs: [], merged: [931], prev: { tickets: [] } }));
653
+ assert.deepEqual(card(merged, 941).flags, []);
654
+ // gh still lists the PR but not as open — no open list to read a missing label off.
655
+ for (const state of ["CLOSED", "MERGED"]) {
656
+ const shut = computeBoard(reproInputs({ rows: ["#941 impl-941=PR#931 · finisher-pr-931=labelled"],
657
+ prs: [{ ...openPr(931), state }], prev: { tickets: [] } }));
658
+ assert.deepEqual(card(shut, 941).flags, [], state);
659
+ }
660
+ // REVIEW only: a card the row already carries past review flags nothing, even unlabelled.
661
+ const past = cardFor("#941 impl-941=PR#931 → MERGED abc1234 · finisher-pr-931=labelled", 941).card;
662
+ assert.equal(past.column, "MERGED");
663
+ assert.deepEqual(past.flags, []);
664
+ });
665
+
666
+ // The tick reads `## Dispatched` as well as the rows, and a whole-line `row`
667
+ // rewrite can drop a settled finisher token from the row while `## Dispatched`
668
+ // keeps it. The cockpit reads the same two places, so the card the tick is
669
+ // repairing or escalating is the card it flags — and a label-off on the row
670
+ // clears both alike.
671
+ test("#2331: the cockpit reads `## Dispatched` as the tick does — a settled finisher a row rewrite dropped still flags", () => {
672
+ const dispatched = ["impl-941=PR#931", "finisher-pr-931=labelled"];
673
+ const open = [{ number: 931, labels: [], closingIssuesReferences: [{ number: 941 }], headRefOid: "abc1234abc1234abc1234abc1234abc1234abcd" }];
674
+ for (const [rows, flags] of [
675
+ [["#941 impl-941=PR#931 → PR#931 · reviewed=abc1234:0/0/0"], ["unlabelled"]],
676
+ [["#941 impl-941=PR#931 → PR#931 · reviewed=abc1234:0/0/0 label-off=finisher-pr-931"], []],
677
+ ]) {
678
+ const tick = deriveRun({ rows, dispatched, drain: null }, open).unlabelled;
679
+ assert.deepEqual(tick.map((u) => u.pr), flags.length ? [931] : [], rows[0]);
680
+ const b = computeBoard(reproInputs({ rows, ledger: { rows, dispatched, filed: [], ruled: [] }, prev: { tickets: [] } }));
681
+ assert.equal(card(b, 941).column, "REVIEW", rows[0]);
682
+ assert.deepEqual(card(b, 941).flags, flags, rows[0]);
683
+ }
684
+ });
685
+
623
686
  test("#1820: a live implementer is IMPLEMENTING, and still earns stale", () => {
624
687
  const b = computeBoard(reproInputs());
625
688
  assert.equal(card(b, 906).column, "IMPLEMENTING");
@@ -9,6 +9,11 @@
9
9
  // expensive. cache_creation is what actually tracks spend, so it is the sort key
10
10
  // and the percentage base; the rest is carried for context, never for ranking.
11
11
 
12
+ import { CELL_DEF } from "./ledger-grammar.mjs";
13
+
14
+ // The implementer definitions #2129 retired — see classifyRole's `def` branch.
15
+ const RETIRED_IMPLEMENTER_DEF = /^fleet-implementer(-alt)?$/;
16
+
12
17
  // A fleet agent's role is not recorded anywhere as a field — it has to be
13
18
  // recovered from how the controller named the work. Depth first: anything the
14
19
  // controller did not spawn directly is a specialist, whatever it calls itself.
@@ -17,10 +22,11 @@
17
22
  // `finisher-pr-<n>`, `merge-bot-<n>`).
18
23
  //
19
24
  // TWO IDENTITY SIGNALS, NEVER ONE (#1505). `agentDefinition` is the agent
20
- // DEFINITION the dispatch recorded — `memory-housekeeper`, `fleet-implementer`,
21
- // `fleet-review-verifier` — and `""` when it recorded none. `memberName` is
22
- // what the member was CALLED (`impl-387`, `brain-housekeeping`), `""` for an
23
- // unnamed dispatch. They used to arrive as ONE `agentType` parameter,
25
+ // DEFINITION the dispatch recorded — `memory-housekeeper`,
26
+ // `fleet-implementer-slow-high`, `fleet-review-verifier` — and `""` when it
27
+ // recorded none. `memberName` is what the member was CALLED (`impl-387`,
28
+ // `brain-housekeeping`), `""` for an unnamed dispatch. They used to arrive as
29
+ // ONE `agentType` parameter,
24
30
  // documented as "the DISPATCH's identity for the member" but sometimes
25
31
  // carrying the definition and sometimes the member's own name depending on
26
32
  // which was available — so every rule below silently read whichever value
@@ -43,7 +49,7 @@
43
49
  // measurement (#326).
44
50
  export function classifyRole(signals) {
45
51
  const def = String(signals?.agentDefinition ?? "");
46
- const name = String(signals?.memberName ?? "");
52
+ const name = canonicalMemberName(signals?.memberName);
47
53
  const desc = String(signals?.description ?? "");
48
54
 
49
55
  // Not fleet work at all — the memory system. Before everything else so it can
@@ -98,8 +104,17 @@ export function classifyRole(signals) {
98
104
  // The review side is a PREFIX and the implementer side is EXACT, deliberately:
99
105
  // the fan-out's dimensions are an open set that `review-core.mjs` sizes per
100
106
  // PR, so a dimension added tomorrow must not silently fall back to prose,
101
- // while the implementer definitions are closed at two by the alternate-tier
102
- // pairing that depends on exactly those two names existing.
107
+ // while the implementer definitions are closed to the `CELL` grammar
108
+ // (`fleet-implementer-<role>-<level>`, ledger-grammar.mjs): a name outside
109
+ // it is no implementer definition, however it starts.
110
+ //
111
+ // Except the pre-cell pair #2129 deleted, `fleet-implementer` and
112
+ // `fleet-implementer-alt`, matched for the same reason the finisher branch
113
+ // keeps old spellings: deliberate compatibility with recorded history.
114
+ // Measured on docs/metrics/member-outcomes.tsv at #2129: 20 of the 303 rows
115
+ // under those two definitions carried no `impl-` name (`Impl1133`,
116
+ // `FixPr1568`, …) and booked `implementer` off the definition alone — a
117
+ // re-scrape of their sessions would have moved them to "other".
103
118
  //
104
119
  // One definition under that prefix is NOT fan-out: `fleet-review-runner`
105
120
  // (#1802) is the member that HOLDS an omp review — dispatched as
@@ -108,7 +123,7 @@ export function classifyRole(signals) {
108
123
  // and is booked "specialist" by the depth check above.
109
124
  if (/^fleet-review-runner$/.test(def)) return "reviewer";
110
125
  if (/^fleet-review-/.test(def)) return "specialist";
111
- if (/^fleet-implementer(-alt)?$/.test(def)) return "implementer";
126
+ if (CELL_DEF.test(def) || RETIRED_IMPLEMENTER_DEF.test(def)) return "implementer";
112
127
 
113
128
  // The dispatch NAME is checked alone, in this same fixed order, before the
114
129
  // prose blend below ever runs (#1506). Both readers now hand a canonical
@@ -182,6 +197,29 @@ function roleFromNamePatterns(hay) {
182
197
  // `roleFromNamePatterns`'s own bare-word check already uses.
183
198
  export const CANONICAL_MEMBER_NAME_PREFIXES = "impl|fix-pr|finish(?:er)?|review-pr|merge-bot";
184
199
 
200
+ // One member family name in any spelling a controller has dispatched it
201
+ // under — PascalCase, mixed case, hyphens dropped (`Impl676`, `FixPr1568`,
202
+ // `Review-pr-1449`, `ReviewPR77`, `FinisherPr1567b`, all in
203
+ // docs/metrics/member-outcomes.tsv) — rewritten to the lower-kebab form every
204
+ // name pattern in this file and in member-record.mjs's parseMemberName is
205
+ // written against (#2396). omp task names are free-form, so nothing upstream
206
+ // guarantees the kebab spelling, and an unmatched spelling lost both its role
207
+ // and its tier-outcomes.tsv join key.
208
+ //
209
+ // Only a WHOLE name of that shape is rewritten — family, number, at most one
210
+ // retry suffix — and anything else is returned as given. Kebab-casing every
211
+ // CamelCase name would turn a generated word pair like `FinishSetupDocs` into
212
+ // `finish-setup-docs`, which classifyRole's `^finish-` books as a finisher.
213
+ const MEMBER_NAME_SPELLING_RE = /^(impl|(?:fix|review|resolve|finish(?:er)?)-?pr|finish(?:er)?|merge-?bot)-?(\d+)(-?(?:v\d+|[a-z])|-\d+)?$/i;
214
+ export function canonicalMemberName(name) {
215
+ const s = String(name ?? "").trim();
216
+ const m = MEMBER_NAME_SPELLING_RE.exec(s);
217
+ if (!m) return s;
218
+ const family = m[1].replace(/^(.*?)-?(pr|bot)$/i, "$1-$2");
219
+ const suffix = m[3] ? `-${m[3].replace(/^-/, "")}` : "";
220
+ return `${family}-${m[2]}${suffix}`.toLowerCase();
221
+ }
222
+
185
223
  // Seeds the rollup buckets and breaks ties in the report, which is otherwise
186
224
  // sorted by spend — so this is not the order the UI shows. Review roles lead so
187
225
  // that at equal spend they still read first.
@@ -1,7 +1,7 @@
1
1
  import { test } from "node:test";
2
2
  import assert from "node:assert/strict";
3
- import { classifyRole, computeSpend, attributeTools, mergeTools } from "./compute-spend.mjs";
4
- import { foldOmpTranscript } from "./member-record.mjs";
3
+ import { classifyRole, computeSpend, attributeTools, mergeTools, canonicalMemberName, CANONICAL_MEMBER_NAME_PREFIXES } from "./compute-spend.mjs";
4
+ import { foldOmpTranscript, parseMemberName } from "./member-record.mjs";
5
5
 
6
6
  const agent = (o) => ({ label: "x", role: "other", cacheWrite: 0, output: 0, cacheRead: 0, ...o });
7
7
 
@@ -286,6 +286,56 @@ test("implementers classify off the member NAME, which is where `impl-` actually
286
286
  assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "impl-332", description: "whatever" }), "other");
287
287
  });
288
288
 
289
+ test("a member family spelled PascalCase or without hyphens classifies off the name like its kebab form (#2396)", () => {
290
+ // omp task names are free-form, and controllers have dispatched the same
291
+ // families as `Impl327`, `FixPr774`, `Fix-pr-766`, `ReviewPR77`. The
292
+ // descriptions carry no role word, so only the name can carry the match.
293
+ const role = (memberName) => classifyRole({ spawnDepth: 0, memberName, description: "whatever" });
294
+ assert.equal(role("Impl327"), "implementer");
295
+ assert.equal(role("FixPr774"), "reviewer");
296
+ assert.equal(role("Fix-pr-766"), "reviewer");
297
+ assert.equal(role("ReviewPR77"), "reviewer");
298
+ assert.equal(role("ResolvePr1232"), "reviewer");
299
+ assert.equal(role("FinisherPr1567b"), "finisher");
300
+ assert.equal(role("Finish436"), "finisher");
301
+ assert.equal(role("MergeBot12"), "merge-bot");
302
+ // What it must still REFUSE: a generated word pair that merely starts with a
303
+ // family word is not that family. Kebab-casing these wholesale would turn
304
+ // `FinishSetupDocs` into `finish-setup-docs`, which `^finish-` books.
305
+ assert.equal(role("FinishSetupDocs"), "other");
306
+ assert.equal(role("Implementer5"), "other");
307
+ assert.equal(role("ImplPlan"), "other");
308
+ });
309
+
310
+ test("canonicalMemberName rewrites only a whole family-number name (#2396)", () => {
311
+ // The start anchor: a name that merely ENDS in a family spelling is not one.
312
+ assert.equal(canonicalMemberName("Xfix-pr-5"), "Xfix-pr-5");
313
+ assert.equal(canonicalMemberName("Setup-Impl3"), "Setup-Impl3");
314
+ // The number is required: a bare family word has no ticket to name.
315
+ for (const bare of ["Impl", "FixPr", "ReviewPr", "MergeBot"]) {
316
+ assert.equal(canonicalMemberName(bare), bare);
317
+ assert.equal(classifyRole({ spawnDepth: 0, memberName: bare, description: "whatever" }), "other");
318
+ }
319
+ // Surrounding whitespace is dropped before matching, for the join key and the role alike.
320
+ assert.equal(canonicalMemberName(" Impl327 "), "impl-327");
321
+ assert.equal(parseMemberName(" Impl327 ").ticket, "327");
322
+ assert.equal(parseMemberName(" impl-327 ").ticket, "327");
323
+ assert.equal(classifyRole({ spawnDepth: 0, memberName: " impl-327 ", description: "whatever" }), "implementer");
324
+ });
325
+
326
+ test("every canonical member-name prefix round-trips from its PascalCase and hyphenless spellings (#2396)", () => {
327
+ // A family added to the prefix list that the spelling pattern does not cover
328
+ // would be a stem member-record accepts but this rewrite leaves blank.
329
+ const stems = CANONICAL_MEMBER_NAME_PREFIXES.replace("finish(?:er)?", "finish|finisher").split("|");
330
+ assert.ok(stems.includes("fix-pr") && stems.includes("finisher"), "the expansion above must still yield the stems it is checked against");
331
+ for (const stem of stems) {
332
+ const pascal = stem.split("-").map((w) => w[0].toUpperCase() + w.slice(1)).join("");
333
+ for (const spelling of [`${pascal}12`, `${stem.replaceAll("-", "")}12`, `${stem}-12`]) {
334
+ assert.equal(canonicalMemberName(spelling), `${stem}-12`, spelling);
335
+ }
336
+ }
337
+ });
338
+
289
339
  test("the omp review fan-out classifies off its agent DEFINITION — depth cannot reach it there", () => {
290
340
  // The depth check above books a nested fan-out whose specialists are the
291
341
  // reviewer's grandchildren under that shape. omp has no such nesting: its
@@ -336,7 +386,7 @@ test("a definition name in the dispatch PROSE is not a dispatch — the fleet br
336
386
  });
337
387
 
338
388
  test("the fleet implementer definitions classify as implementer, independent of the `^impl-` name pattern", () => {
339
- // `agentDefinition`-based classification (`fleet-implementer(-alt)`) is
389
+ // `agentDefinition`-based classification (`fleet-implementer-<cell>`) is
340
390
  // checked BEFORE the `^impl-` name/description pattern below it, so it must
341
391
  // not depend on a canonically-shaped member name to fire — this pin
342
392
  // exercises classifyRole directly, on `agentDefinition` alone, so it stays
@@ -353,12 +403,16 @@ test("the fleet implementer definitions classify as implementer, independent of
353
403
  // split 73 other, 7 merge-bot, 5 finisher, 5 reviewer, none of them
354
404
  // implementer — the gap was in what omp handed classifyRole, not in the
355
405
  // classifier's own patterns.
356
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-implementer", description: "Ticket #1486. Worktree: .worktrees/1486-classify" }), "implementer");
357
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-implementer-alt", description: "Ticket #1486. Worktree: .worktrees/1486-classify" }), "implementer");
358
- // EXACT, unlike the review prefix above: the alternate-tier pairing is closed
359
- // at these two names, so a third `fleet-implementer-`-prefixed definition is a
360
- // deliberate addition and not something to classify in advance.
361
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-implementer-probe", description: "whatever" }), "other");
406
+ // Every cell, and the pre-cell pair #2129 retired: recorded history still
407
+ // carries rows dispatched under those two, and books them by definition.
408
+ for (const def of ["fleet-implementer-slow-high", "fleet-implementer-slow-medium", "fleet-implementer-task-high", "fleet-implementer-task-max", "fleet-implementer-smol-high", "fleet-implementer", "fleet-implementer-alt"]) {
409
+ assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: def, description: "Ticket #1486. Worktree: .worktrees/1486-classify" }), "implementer", def);
410
+ }
411
+ // EXACT, unlike the review prefix above: a `fleet-implementer-`-prefixed
412
+ // name outside the `CELL` grammar is not an implementer definition.
413
+ for (const def of ["fleet-implementer-probe", "fleet-implementer-slow-ultra", "fleet-implementer-alt-2"]) {
414
+ assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: def, description: "whatever" }), "other", def);
415
+ }
362
416
  });
363
417
 
364
418
  test("depth still outranks the definition — a fleet member's own fan-out is not another implementer", () => {
@@ -366,7 +420,7 @@ test("depth still outranks the definition — a fleet member's own fan-out is no
366
420
  // implementer dispatched is the specialist it structurally is rather than
367
421
  // inheriting its parent's definition. Move either branch above the depth
368
422
  // check and this goes red.
369
- assert.equal(classifyRole({ spawnDepth: 1, agentDefinition: "fleet-implementer", description: "whatever" }), "specialist");
423
+ assert.equal(classifyRole({ spawnDepth: 1, agentDefinition: "fleet-implementer-slow-high", description: "whatever" }), "specialist");
370
424
  // And memory still outranks both, which is the rule that keeps memory-system
371
425
  // work out of review spend.
372
426
  assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "memory-proxy", description: "Review PR 1353 correctness" }), "memory");