@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
@@ -48,22 +48,42 @@
48
48
  // An implementer (`impl-<N>`, ledger-grammar.mjs's name) is judged on the
49
49
  // ledger's terms, not the caller's (#1398): the definition it should have
50
50
  // run under is derived from its ticket row's `tier=` token
51
- // (`expectedDefinition`), the agent type it was actually dispatched as is
51
+ // (ledger-grammar.mjs's `expectedDefinition` — the same function
52
+ // `ledger.mjs dispatch` prints the definition from, #2208), the agent type
53
+ // it was actually dispatched as is
52
54
  // read off its own transcript and must BE that definition — a generic `task`
53
55
  // dispatch fails even when its model happens to match — and the verdict
54
56
  // lands on the ledger either way: `tier-ok=impl-<N>:<definition>` on the
55
57
  // row on a pass, `ledger.mjs settle impl-<N> tier-mismatch` on a failure.
56
58
  // fleet-tick.mjs holds the next Pull on the newest implementer of a ticket
57
- // carrying neither.
58
-
59
- import { readFileSync, existsSync } from "node:fs";
59
+ // carrying none of the three verdicts — those two, or `tier-unverifiable=`
60
+ // below.
61
+ //
62
+ // Exit status: 0 every member passed; 1 any member mismatched; 2 usage — a
63
+ // bad batch, flag or config, an unreadable ledger, or a member whose
64
+ // transcript cannot be found, before anything is written; 3 no mismatch, but
65
+ // at least one implementer was recorded `tier-unverifiable=impl-<N>:no-transcript`
66
+ // — settled `killed` or `released` anywhere on the ledger (a row or
67
+ // `## Dispatched`) while its `session` names an existing directory holding no
68
+ // `<member>.jsonl`, the trace of a dispatch that failed before a transcript
69
+ // was written. That token clears the tick's unchecked hold without claiming
70
+ // the tier was right. Every other case with no transcript is still exit 2: a
71
+ // LIVE member may yet write one; a member settled `PR#M`, `bailed` or
72
+ // `tier-mismatch` ran, so its transcript exists and the `session` is the
73
+ // wrong directory; a `session` that is omitted, empty, missing or not a
74
+ // directory is exit 2 whether the member is live or settled; and a session
75
+ // directory that cannot be searched (EACCES) is exit 2 naming the errno,
76
+ // never read as holding no transcript.
77
+
78
+ import { readFileSync, existsSync, statSync } from "node:fs";
60
79
  import { execFileSync } from "node:child_process";
61
80
  import { join, dirname, isAbsolute } from "node:path";
62
- import { fileURLToPath, pathToFileURL } from "node:url";
81
+ import { fileURLToPath } from "node:url";
82
+ import { isCLI } from "./is-cli.mjs";
63
83
  import { makeDie, defineFlags } from "./arg.mjs";
64
84
  import { foldOmpTranscript, parseMemberName } from "./member-record.mjs";
65
85
  import { parseFrontmatter, expectedOmpModel, modelsEqual, readOmpConfigValue } from "./tier-roles.mjs";
66
- import { parseMember, parseToken, memberTokens } from "./ledger-grammar.mjs";
86
+ import { parseMember, parseToken, memberTokens, expectedDefinition } from "./ledger-grammar.mjs";
67
87
 
68
88
  const NAME = "tier-check";
69
89
  const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
@@ -168,24 +188,6 @@ export function appendedLedgerText(existingText, mismatchNote) {
168
188
  return `${trimmed} · ${mismatchNote}`;
169
189
  }
170
190
 
171
- // #1398: the definition an implementer should have run under, off its
172
- // ticket row's `tier=` token — none means `fleet-implementer`, `tier=<x>`
173
- // means `fleet-implementer-<x>`: `alt` (phase 2's every-5th-Pull alternate)
174
- // and every #2030 per-cell name (`slow-high`) alike. The value becomes a
175
- // file name under `agents/`, so it is held to `[a-z0-9]` words joined by
176
- // `-` rather than joined into a path as written, and two different `tier=`
177
- // values on one row name no single definition — refused, never resolved by
178
- // position.
179
- const TIER_SUFFIX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
180
- export function expectedDefinition(rowText) {
181
- const values = [...new Set(String(rowText ?? "").split(/\s+/)
182
- .filter((t) => t.startsWith("tier=")).map((t) => t.slice("tier=".length)))];
183
- if (values.length === 0) return "fleet-implementer";
184
- if (values.length > 1) throw new Error(`row carries conflicting tier= tokens (${values.map((v) => `tier=${v}`).join(", ")})`);
185
- if (!TIER_SUFFIX.test(values[0])) throw new Error(`tier=${values[0]} is not a definition suffix — expected [a-z0-9] words joined by '-'`);
186
- return `fleet-implementer-${values[0]}`;
187
- }
188
-
189
191
  // The agent-type half of an implementer's verdict: the definition the
190
192
  // transcript's `session_init` says the member was DISPATCHED AS
191
193
  // (`folded.agent` — the value member-record.mjs records as `subagent_type`)
@@ -216,13 +218,21 @@ export function implementerFailures(r) {
216
218
  return lines;
217
219
  }
218
220
 
219
- // The two verdict tokens fleet-tick.mjs reads. Neither parses as a member
220
- // token (ledger-grammar.mjs's parseMember refuses a `tier-ok`/`tier-mismatch`
221
+ // The verdict tokens fleet-tick.mjs reads. None parses as a member token
222
+ // (ledger-grammar.mjs's parseMember refuses a `tier-ok`/`tier-mismatch`
221
223
  // name), so `ledger.mjs row` passes them as free text. `tier-mismatch=` is
222
224
  // written only for a member already settled some other way — `settle`
223
225
  // refuses to re-settle it, and the mismatch must still hold the next Pull.
224
226
  export const tierOkToken = (member, definition) => `tier-ok=${member}:${definition}`;
225
227
  export const tierMismatchToken = (member, definition) => `tier-mismatch=${member}:${definition}`;
228
+ // The third verdict: an implementer settled `killed` or `released` whose
229
+ // `<session>/<member>.jsonl` does not exist under a session directory that
230
+ // does — a dispatch that failed before any transcript was written. It clears
231
+ // the tick's unchecked hold and is never read as `tier-ok=`
232
+ // (tier-outcomes.mjs falls through past it). The check exits
233
+ // UNVERIFIABLE_EXIT when it records one.
234
+ export const tierUnverifiableToken = (member) => `tier-unverifiable=${member}:no-transcript`;
235
+ export const UNVERIFIABLE_EXIT = 3;
226
236
 
227
237
  // A single-token append, idempotent on the token's PRESENCE anywhere in the
228
238
  // row — unlike appendedLedgerText's trailing-segment rule, which is for
@@ -279,6 +289,29 @@ function resolveViaSession(repoRoot, sessionPath, member) {
279
289
  return readFileSync(flat, "utf8");
280
290
  }
281
291
 
292
+ // True only for a session path that IS a directory and holds no
293
+ // `<member>.jsonl`: the one shape that can mean a dispatch which never wrote
294
+ // a transcript. A path that does not exist, or is not a directory, is a
295
+ // caller's mistake and stays resolveViaSession's refusal. Only ENOENT reads
296
+ // as "no transcript": a directory that cannot be searched throws (EACCES),
297
+ // which main() dies on by name — `existsSync` would swallow it and record a
298
+ // transcript that exists as one that never was.
299
+ function sessionLacksTranscript(repoRoot, sessionPath, member) {
300
+ const root = resolvePath(repoRoot, sessionPath);
301
+ if (statSync(root, { throwIfNoEntry: false })?.isDirectory() !== true) return false;
302
+ return statSync(join(root, `${member}.jsonl`), { throwIfNoEntry: false }) === undefined;
303
+ }
304
+
305
+ // The settle outcomes a dispatch that failed before writing a transcript can
306
+ // carry: `killed` (the Member-killed row — spend limit, API error, crash) and
307
+ // `released` (a drain releases every claim that never became a PR). `PR#M`,
308
+ // `bailed` and `tier-mismatch` each prove the member ran — it opened a PR,
309
+ // reported its own bail, or had its transcript read by this check — so for
310
+ // them a missing `<member>.jsonl` means the `session` is the wrong directory,
311
+ // and recording `tier-unverifiable` would clear the hold on a member whose
312
+ // tier can still be judged.
313
+ const NO_TRANSCRIPT_OUTCOMES = new Set(["killed", "released"]);
314
+
282
315
  function runLedger(ledgerFile, args, what) {
283
316
  try {
284
317
  return execFileSync(process.execPath, [LEDGER_SCRIPT, ...(ledgerFile ? ["--file", ledgerFile] : []), ...args], { encoding: "utf8" });
@@ -337,6 +370,21 @@ function recordImplementer(ledgerFile, r) {
337
370
  if (outcome === null) runLedger(ledgerFile, ["settle", r.member, "tier-mismatch"], `settle ${r.member} tier-mismatch`);
338
371
  }
339
372
 
373
+ // A settled implementer whose transcript does not exist can never be judged,
374
+ // and holding the tick on it forever is the deadlock this verdict ends: the
375
+ // token clears `HOLD (tier unchecked …)` without claiming the tier was right,
376
+ // which is why it is neither `tier-ok=` nor `tier-mismatch=`. Only for a
377
+ // member settled one of NO_TRANSCRIPT_OUTCOMES. Appended once, on the
378
+ // ticket's row, under the same presence rule as the other two.
379
+ function recordUnverifiable(ledgerFile, r) {
380
+ const token = tierUnverifiableToken(r.member);
381
+ console.error(`${r.member}: settled ${r.outcome} with no ${r.member}.jsonl under --session ${r.session} — nothing to check; recorded ${token}`);
382
+ const existing = rowText(readLedger(ledgerFile), r.ticket);
383
+ const updated = withToken(existing, token);
384
+ if (updated === existing) console.error(` ${r.member}: row #${r.ticket} already carries ${token} — not written again`);
385
+ else writeLedgerRow(ledgerFile, r.ticket, updated);
386
+ }
387
+
340
388
  function main() {
341
389
  const batchPath = arg("batch");
342
390
  if (!batchPath) die("usage: tier-check.mjs --batch <path-to-json> [--ledger <path>] [--repo <path>] [--model-roles <path>]");
@@ -412,6 +460,18 @@ function main() {
412
460
  // the agent type it was dispatched as lives only there.
413
461
  if (impl || !hasJobRecord) {
414
462
  if (raw.session) {
463
+ // A member settled `killed` or `released` with no transcript under
464
+ // a session directory that does exist: its dispatch failed before
465
+ // one was written, so there is nothing to judge. Recorded, not
466
+ // refused — see recordUnverifiable. A live member, one on the
467
+ // ledger nowhere, or a session path that is not a directory still
468
+ // refuses below; one settled any other way ran, so its missing
469
+ // transcript names the wrong session and refuses here.
470
+ if (impl && sessionLacksTranscript(repoRoot, raw.session, raw.member)) {
471
+ const outcome = memberOutcome(ledgerData, raw.member);
472
+ if (NO_TRANSCRIPT_OUTCOMES.has(outcome)) return { impl: true, unverifiable: true, member: raw.member, ticket, outcome, session: raw.session };
473
+ if (outcome) throw new Error(`settled ${outcome} with no ${raw.member}.jsonl under --session ${raw.session} — a member settled ${outcome} ran, so its transcript exists: name the session directory that dispatched it`);
474
+ }
415
475
  transcriptText = resolveViaSession(repoRoot, raw.session, raw.member);
416
476
  } else if (raw.transcript) {
417
477
  transcriptText = readFileSync(resolvePath(repoRoot, raw.transcript), "utf8");
@@ -440,6 +500,10 @@ function main() {
440
500
  });
441
501
 
442
502
  for (const r of results) {
503
+ if (r.unverifiable) {
504
+ recordUnverifiable(ledgerFile, r);
505
+ continue;
506
+ }
443
507
  if (r.impl) {
444
508
  recordImplementer(ledgerFile, r);
445
509
  continue;
@@ -462,7 +526,10 @@ function main() {
462
526
  writeLedgerRow(ledgerFile, ticket, updated);
463
527
  }
464
528
 
465
- process.exit(results.some((r) => !r.ok) ? 1 : 0);
529
+ // A mismatch outranks an unverifiable member in a mixed batch: it is the
530
+ // one the controller must act on.
531
+ const failed = results.some((r) => !r.unverifiable && !r.ok);
532
+ process.exit(failed ? 1 : results.some((r) => r.unverifiable) ? UNVERIFIABLE_EXIT : 0);
466
533
  }
467
534
 
468
- if (import.meta.url === pathToFileURL(process.argv[1] || "").href) main();
535
+ if (isCLI(import.meta.url)) main();
@@ -1,15 +1,15 @@
1
1
  import { test } from "node:test";
2
2
  import assert from "node:assert/strict";
3
3
  import { spawnSync, execFileSync } from "node:child_process";
4
- import { mkdtempSync, mkdirSync, writeFileSync, existsSync } from "node:fs";
5
- import { tmpdir } from "node:os";
4
+ import { mkdirSync, writeFileSync, existsSync, readFileSync, chmodSync } from "node:fs";
5
+ import { tempDir } from "./temp-dir.mjs";
6
6
  import { join } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
 
9
9
  import {
10
10
  declaredPairFor,
11
11
  resolveActual, evaluateMember,
12
- formatMismatch, formatOmpExpectation, appendedLedgerText, expectedDefinition, withToken,
12
+ formatMismatch, formatOmpExpectation, appendedLedgerText, withToken,
13
13
  } from "./tier-check.mjs";
14
14
  import { parseFrontmatter } from "./tier-roles.mjs";
15
15
  import { deriveRun } from "./fleet-tick.mjs";
@@ -61,7 +61,7 @@ function ompTranscript(resolvedModelIdentity, thinkingLevel, { withTurn = true,
61
61
  }
62
62
 
63
63
  function dir() {
64
- return mkdtempSync(join(tmpdir(), "tier-check-"));
64
+ return tempDir("tier-check-");
65
65
  }
66
66
 
67
67
  // The measured real `modelRoles` shape (ADR 0011/0014) used by every fixture
@@ -432,7 +432,7 @@ test("CLI: no --model-roles and no `omp` on PATH refuses naming the config read"
432
432
  writeFileSync(join(d, "omp-impl.jsonl"), ompTranscript("anthropic/claude-opus-5", "xhigh"));
433
433
  const batch = [{ member: "NoPathOmp", agentFile: "fleet-implementer.agent.md", transcript: "omp-impl.jsonl" }];
434
434
  writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
435
- const emptyPath = mkdtempSync(join(tmpdir(), "tier-check-empty-path-"));
435
+ const emptyPath = tempDir("tier-check-empty-path-");
436
436
  const r = spawnSync(process.execPath, [SCRIPT, "--batch", "batch.json", "--repo", d], {
437
437
  cwd: d, encoding: "utf8", env: { ...process.env, PATH: emptyPath },
438
438
  });
@@ -497,8 +497,8 @@ const ledgerCli = (file, ...args) => execFileSync(process.execPath, [LEDGER_SCRI
497
497
  // `session` lookup phase 2 hands the check.
498
498
  function implWorld({
499
499
  ticket = 7, member = `impl-${ticket}`, row = `${member} · class=routine`,
500
- definitions = { "fleet-implementer": "@slow:high" },
501
- agent = "fleet-implementer", model = "anthropic/claude-opus-5", level = "high",
500
+ definitions = { "fleet-implementer-slow-high": "@slow:high" },
501
+ agent = "fleet-implementer-slow-high", model = "anthropic/claude-opus-5", level = "high",
502
502
  } = {}) {
503
503
  const d = dir();
504
504
  mkdirSync(join(d, "agents"));
@@ -521,12 +521,12 @@ test("implementer pass: exit 0 writes tier-ok=impl-<N>:<definition> onto the row
521
521
  const w = implWorld();
522
522
  const r = w.check();
523
523
  assert.equal(r.status, 0, r.stdout + r.stderr);
524
- assert.equal(w.row(), "#7 impl-7 · class=routine · tier-ok=impl-7:fleet-implementer");
524
+ assert.equal(w.row(), "#7 impl-7 · class=routine · tier-ok=impl-7:fleet-implementer-slow-high");
525
525
  assert.equal(w.check().status, 0);
526
- assert.equal(w.row(), "#7 impl-7 · class=routine · tier-ok=impl-7:fleet-implementer", "a re-run grew the row");
526
+ assert.equal(w.row(), "#7 impl-7 · class=routine · tier-ok=impl-7:fleet-implementer-slow-high", "a re-run grew the row");
527
527
  // The token is no longer the row's tail once the member settles and the
528
528
  // controller writes past it — a re-run still finds it.
529
- ledgerCli(w.ledger, "row", "7", "impl-7 · class=routine · tier-ok=impl-7:fleet-implementer · → PR#9");
529
+ ledgerCli(w.ledger, "row", "7", "impl-7 · class=routine · tier-ok=impl-7:fleet-implementer-slow-high · → PR#9");
530
530
  assert.equal(w.check().status, 0);
531
531
  assert.equal(w.row().split("tier-ok=").length - 1, 1, w.row());
532
532
  });
@@ -544,24 +544,24 @@ test("implementer mismatch: exit 1 settles the member tier-mismatch on the ledge
544
544
  assert.equal(w.row(), row, "a re-run on an unchanged mismatch changed the row");
545
545
  });
546
546
 
547
- test("implementer: the expected definition follows the row's tier= — none, alt, and any other <cell>", () => {
548
- for (const [tier, definition] of [[null, "fleet-implementer"], ["alt", "fleet-implementer-alt"], ["slow-medium", "fleet-implementer-slow-medium"]]) {
547
+ test("implementer: the expected definition follows the row's tier= — none is the policy cell, any other <cell> its own", () => {
548
+ for (const [tier, definition] of [[null, "fleet-implementer-slow-high"], ["task-high", "fleet-implementer-task-high"], ["slow-medium", "fleet-implementer-slow-medium"]]) {
549
549
  const w = implWorld({
550
550
  row: `impl-7 · class=routine${tier ? ` · tier=${tier}` : ""}`,
551
- definitions: { "fleet-implementer": "@slow:high", "fleet-implementer-alt": "@slow:high", "fleet-implementer-slow-medium": "@slow:high" },
551
+ definitions: { "fleet-implementer-slow-high": "@slow:high", "fleet-implementer-task-high": "@slow:high", "fleet-implementer-slow-medium": "@slow:high" },
552
552
  agent: definition,
553
553
  });
554
554
  const r = w.check();
555
555
  assert.equal(r.status, 0, `${tier}: ${r.stdout}${r.stderr}`);
556
556
  assert.ok(w.row().endsWith(` · tier-ok=impl-7:${definition}`), `${tier}: ${w.row()}`);
557
557
  }
558
- // The row's tier, not the dispatch, names the definition: an alt row whose
559
- // member ran the default definition fails even though that definition's
558
+ // The row's tier, not the dispatch, names the definition: a task-high row
559
+ // whose member ran the policy cell fails even though that definition's
560
560
  // tier resolved exactly.
561
- const w = implWorld({ row: "impl-7 · tier=alt", definitions: { "fleet-implementer": "@slow:high", "fleet-implementer-alt": "@task:high" } });
561
+ const w = implWorld({ row: "impl-7 · tier=task-high", definitions: { "fleet-implementer-slow-high": "@slow:high", "fleet-implementer-task-high": "@task:high" } });
562
562
  const r = w.check();
563
563
  assert.equal(r.status, 1, r.stdout + r.stderr);
564
- assert.match(r.stderr, /impl-7: dispatched fleet-implementer, expected fleet-implementer-alt/);
564
+ assert.match(r.stderr, /impl-7: dispatched fleet-implementer-slow-high, expected fleet-implementer-task-high/);
565
565
  });
566
566
 
567
567
  test("implementer: a cell with no definition file under agents/ fails as a mismatch rather than crashing the check", () => {
@@ -576,7 +576,7 @@ test("implementer: a `task` dispatch fails even when the model and level it reso
576
576
  const w = implWorld({ agent: "task" });
577
577
  const r = w.check();
578
578
  assert.equal(r.status, 1, r.stdout + r.stderr);
579
- assert.match(r.stderr, /impl-7: dispatched task, expected fleet-implementer/);
579
+ assert.match(r.stderr, /impl-7: dispatched task, expected fleet-implementer-slow-high/);
580
580
  assert.doesNotMatch(r.stderr, /declared @slow/, "the model half passed and must not be reported as a mismatch");
581
581
  assert.match(w.row(), /impl-7=tier-mismatch/);
582
582
  });
@@ -586,7 +586,7 @@ test("implementer: a member already settled another way records tier-mismatch as
586
586
  assert.deepEqual(w.tick().tierUnchecked, ["impl-7"], "a settled member with no verdict must hold as unchecked");
587
587
  const r = w.check();
588
588
  assert.equal(r.status, 1, r.stdout + r.stderr);
589
- assert.equal(w.row(), "#7 impl-7=bailed · class=routine · tier-mismatch=impl-7:fleet-implementer · impl-7: dispatched task, expected fleet-implementer");
589
+ assert.equal(w.row(), "#7 impl-7=bailed · class=routine · tier-mismatch=impl-7:fleet-implementer-slow-high · impl-7: dispatched task, expected fleet-implementer-slow-high");
590
590
  assert.deepEqual([w.tick().tierMismatch, w.tick().tierUnchecked], [["impl-7"], []]);
591
591
  assert.equal(w.check().status, 1);
592
592
  assert.equal(w.row().split("tier-mismatch=").length - 1, 1, "a re-run wrote the token twice");
@@ -600,10 +600,111 @@ test("tick: a settled, unchecked implementer holds; a later tier-check writes ti
600
600
  assert.deepEqual([w.tick().tierMismatch, w.tick().tierUnchecked], [[], []]);
601
601
  });
602
602
 
603
- test("expectedDefinition refuses a tier= it cannot name one definition file by", () => {
604
- assert.throws(() => expectedDefinition("impl-7 · tier=alt · tier=slow-high"), /conflicting tier= tokens \(tier=alt, tier=slow-high\)/);
605
- assert.throws(() => expectedDefinition("impl-7 · tier=../../etc"), /is not a definition suffix/);
606
- assert.equal(expectedDefinition("impl-7 · tier=alt · tier=alt"), "fleet-implementer-alt");
603
+ // A dispatch whose `task` call failed before any transcript was written: the
604
+ // member is on the ledger — `dispatch` runs before the call — and the session
605
+ // directory exists, but `<session>/<member>.jsonl` does not.
606
+ function noTranscriptWorld({ settle = "killed" } = {}) {
607
+ const d = dir();
608
+ mkdirSync(join(d, "agents"));
609
+ writeFileSync(join(d, "agents", "fleet-implementer-slow-high.agent.md"), agentMd("@slow:high"));
610
+ const ledger = join(d, "ledger.md");
611
+ ledgerCli(ledger, "dispatch", "7", "impl-7");
612
+ if (settle) ledgerCli(ledger, "settle", "impl-7", settle);
613
+ mkdirSync(join(d, "session"));
614
+ const read = () => JSON.parse(ledgerCli(ledger, "read"));
615
+ return {
616
+ d, ledger,
617
+ bytes: () => readFileSync(ledger, "utf8"),
618
+ check: (entries = [{ member: "impl-7", session: "session" }]) => {
619
+ writeFileSync(join(d, "batch.json"), JSON.stringify(entries));
620
+ return runCli(["--batch", "batch.json", "--repo", d, "--ledger", ledger, "--model-roles", modelRolesFile(d)], d);
621
+ },
622
+ row: () => read().rows.find((r) => r.split(/\s/)[0] === "#7"),
623
+ tick: () => deriveRun({ ...read(), drain: null }, []),
624
+ };
625
+ }
626
+
627
+ test("no transcript, member settled: tier-unverifiable is appended once, exit 3, and the tick's unchecked hold clears", () => {
628
+ const w = noTranscriptWorld();
629
+ assert.deepEqual(w.tick().tierUnchecked, ["impl-7"]);
630
+ const r = w.check();
631
+ assert.equal(r.status, 3, r.stdout + r.stderr);
632
+ assert.equal(w.row(), "#7 impl-7=killed · tier-unverifiable=impl-7:no-transcript");
633
+ assert.deepEqual([w.tick().tierUnchecked, w.tick().tierMismatch], [[], []]);
634
+ const before = w.bytes();
635
+ assert.equal(w.check().status, 3);
636
+ assert.equal(w.bytes(), before, "a re-run grew the row");
637
+ });
638
+
639
+ test("no transcript, member live: still an error — exit 2, nothing written, still unchecked", () => {
640
+ const w = noTranscriptWorld({ settle: null });
641
+ const before = w.bytes();
642
+ const r = w.check();
643
+ assert.equal(r.status, 2, r.stdout + r.stderr);
644
+ assert.match(r.stderr, /no impl-7\.jsonl found under --session/);
645
+ assert.equal(w.bytes(), before);
646
+ assert.deepEqual(w.tick().tierUnchecked, ["impl-7"]);
647
+ });
648
+
649
+ test("no transcript: a session omitted, empty, missing or not a directory is a usage error for live and settled members alike", () => {
650
+ for (const settle of [null, "killed"]) {
651
+ const w = noTranscriptWorld({ settle });
652
+ const before = w.bytes();
653
+ for (const session of [undefined, "", "no-such-dir", join("agents", "fleet-implementer.agent.md")]) {
654
+ const r = w.check([{ member: "impl-7", ...(session === undefined ? {} : { session }) }]);
655
+ assert.equal(r.status, 2, `${settle} ${JSON.stringify(session)}: ${r.stdout}${r.stderr}`);
656
+ assert.equal(w.bytes(), before, `${settle} ${JSON.stringify(session)}: the ledger changed`);
657
+ }
658
+ }
659
+ });
660
+
661
+ test("no transcript beside a mismatch in one batch: the mismatch's exit 1 wins over exit 3", () => {
662
+ const w = noTranscriptWorld();
663
+ ledgerCli(w.ledger, "dispatch", "8", "impl-8");
664
+ writeFileSync(join(w.d, "session", "impl-8.jsonl"), ompTranscript("anthropic/claude-sonnet-5", "high", { agent: "fleet-implementer" }));
665
+ const r = w.check([{ member: "impl-7", session: "session" }, { member: "impl-8", session: "session" }]);
666
+ assert.equal(r.status, 1, r.stdout + r.stderr);
667
+ assert.match(w.row(), /tier-unverifiable=impl-7:no-transcript/);
668
+ assert.deepEqual(w.tick().tierMismatch, ["impl-8"]);
669
+ });
670
+
671
+ test("no transcript: only `killed` and `released` are a failed dispatch — a member settled any way that proves it ran is a wrong session, exit 2", () => {
672
+ for (const settle of ["killed", "released"]) {
673
+ const w = noTranscriptWorld({ settle });
674
+ const r = w.check();
675
+ assert.equal(r.status, 3, `${settle}: ${r.stdout}${r.stderr}`);
676
+ assert.equal(w.row(), `#7 impl-7=${settle} · tier-unverifiable=impl-7:no-transcript`);
677
+ }
678
+ // A PR, a bail report and a mismatch verdict each prove the member ran and
679
+ // wrote a transcript, so an existing session directory without it is the
680
+ // wrong directory — never a verdict that clears the hold unchecked.
681
+ for (const settle of ["PR#20", "bailed", "tier-mismatch"]) {
682
+ const w = noTranscriptWorld({ settle });
683
+ const before = w.bytes();
684
+ const r = w.check();
685
+ assert.equal(r.status, 2, `${settle}: ${r.stdout}${r.stderr}`);
686
+ assert.match(r.stderr, new RegExp(`impl-7: settled ${settle} with no impl-7\\.jsonl under --session session — .*name the session directory that dispatched it`));
687
+ assert.equal(w.bytes(), before, `${settle}: the ledger changed`);
688
+ }
689
+ });
690
+
691
+ test("no transcript: a session directory that cannot be searched is exit 2 naming EACCES, never a recorded tier-unverifiable", (t) => {
692
+ if (process.getuid?.() === 0) return t.skip("root searches every directory");
693
+ const w = noTranscriptWorld();
694
+ // The transcript EXISTS — only the search bit is gone.
695
+ writeFileSync(join(w.d, "session", "impl-7.jsonl"), ompTranscript("anthropic/claude-opus-5", "high", { agent: "fleet-implementer" }));
696
+ const before = w.bytes();
697
+ chmodSync(join(w.d, "session"), 0o000);
698
+ let r;
699
+ try {
700
+ r = w.check();
701
+ } finally {
702
+ chmodSync(join(w.d, "session"), 0o755);
703
+ }
704
+ assert.equal(r.status, 2, r.stdout + r.stderr);
705
+ assert.match(r.stderr, /impl-7: .*EACCES/);
706
+ assert.equal(w.bytes(), before, "an unsearchable session was recorded as no transcript");
707
+ assert.deepEqual(w.tick().tierUnchecked, ["impl-7"]);
607
708
  });
608
709
 
609
710
  test("ledger append: a mismatch on a member with no derivable ticket (an omp AgentId) still exits 1 but writes no ledger row", () => {
@@ -647,18 +748,19 @@ test("CLI: an impl- entry carrying agentFile refuses — the definition is the l
647
748
  assert.match(r.stderr, /impl-1: an impl- entry carries no agentFile/);
648
749
  });
649
750
 
650
- test("CLI: --repo defaults to the script's own plugin/ root, so the real agents/fleet-implementer.agent.md is found without --repo", () => {
751
+ test("CLI: --repo defaults to the script's own plugin/ root, so the real agents/fleet-implementer-slow-high.agent.md is found without --repo", () => {
651
752
  const d = dir();
652
753
  const ledger = join(d, "ledger.md");
653
754
  ledgerCli(ledger, "row", "1", "impl-1");
654
- writeFileSync(join(d, "omp-impl.jsonl"), ompTranscript("anthropic/claude-opus-5", "high", { agent: "fleet-implementer" }));
755
+ writeFileSync(join(d, "omp-impl.jsonl"), ompTranscript("anthropic/claude-opus-5", "high", { agent: "fleet-implementer-slow-high" }));
655
756
  const batch = [{ member: "impl-1", transcript: join(d, "omp-impl.jsonl") }];
656
757
  writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
657
758
  const r = runCli(["--batch", join(d, "batch.json"), "--ledger", ledger], d, ["--model-roles", modelRolesFile(d)]);
658
- // The real fleet-implementer declares @slow:high (implementer-model-tier.test.mjs
659
- // pins this) — this fixture's transcript matches it, so a correctly
660
- // resolved --repo default exits 0. A wrong default (or none) finds no
661
- // definition file and fails as a mismatch instead.
759
+ // A row with no `tier=` runs at the policy cell, and the real
760
+ // fleet-implementer-slow-high declares @slow:high (implementer-model-tier
761
+ // .test.mjs pins the name ⇒ route derivation) — this fixture's transcript
762
+ // matches it, so a correctly resolved --repo default exits 0. A wrong
763
+ // default (or none) finds no definition file and fails as a mismatch instead.
662
764
  assert.equal(r.status, 0, r.stdout + r.stderr);
663
765
  });
664
766
 
@@ -327,7 +327,7 @@ test("the dispatch brief tells the member to emit the Sizing line the ruling ste
327
327
  // apart from the reader above so dropping either end reds. The brief is the
328
328
  // implementer agent body since #1804 (spec 2026-09-24 § 2 Decision 2) — the
329
329
  // member's system prompt, where run-team's phase 2 used to paste it.
330
- const brief = readFileSync(join(REPO, "plugin", "agents", "fleet-implementer.agent.md"), "utf8").split("---").slice(2).join("---");
330
+ const brief = readFileSync(join(REPO, "plugin", "agents", "fleet-implementer-slow-high.agent.md"), "utf8").split("---").slice(2).join("---");
331
331
  assert.match(
332
332
  brief,
333
333
  /`Sizing: light` or `Sizing: heavy`/,
@@ -380,16 +380,16 @@ test("the ruling step refuses to record a sizing verdict it cannot date", () =>
380
380
  );
381
381
  });
382
382
 
383
- // #1071: `run_date` is DERIVED in `member-outcomes.tsv` (a transcript mtime)
384
- // and STAMPED AT RULING here, and phase 2 states TWO floors that each count
385
- // distinct `run_date`s — three PRs across two dates over this file, ten pairs
386
- // across five dates over the other. The ticket's filer read the ten/five floor
387
- // as a count over THIS file. It is not one, and nothing in this header said so.
383
+ // `run_date` is DERIVED in `member-outcomes.tsv` (a transcript mtime) and
384
+ // STAMPED AT RULING here, and phase 2's pairing floor counts distinct
385
+ // `run_date`s — ten pairs across five dates — over the other file, never this
386
+ // one. Read as a count over THIS file, it answers a different question, and
387
+ // nothing in this header used to say so.
388
388
  //
389
389
  // The paragraph that now says it makes claims about files this one does not
390
390
  // contain, which is the shape that rots silently: it stays true only while
391
391
  // member-outcomes.tsv keeps carrying the pairing query, `member-outcomes.mjs`
392
- // keeps stamping dates off an mtime, and SKILL.md keeps both floors' numbers.
392
+ // keeps stamping dates off an mtime, and SKILL.md keeps the floor's numbers.
393
393
  // So the pins below DERIVE each claim from its real source — the same reason
394
394
  // the `profile` pin above derives the enum instead of restating it.
395
395
  const MEMBER_TSV = readFileSync(join(REPO, "docs", "metrics", "member-outcomes.tsv"), "utf8");
@@ -411,15 +411,10 @@ const runDateSources = () =>
411
411
  test("the header says which file each distinct-`run_date` count is read from, and that the two columns differ", () => {
412
412
  const block = runDateSources();
413
413
 
414
- // Each floor bound to its file in ONE span. Split into a mention of the
414
+ // The floor bound to its file in ONE span. Split into a mention of the
415
415
  // number and a separate mention of the file, a reader counting the ten/five
416
416
  // floor over this file satisfies both halves and is wrong anyway — which is
417
417
  // the defect, not a wording preference.
418
- assert.match(
419
- block,
420
- phrase("at least three `class=routine` PRs spanning two or more distinct `run_date`s — IS this file's `run_date`"),
421
- "the header no longer says the revert floor's distinct-date count is read from THIS file",
422
- );
423
418
  assert.match(
424
419
  block,
425
420
  phrase(
@@ -465,33 +460,6 @@ test("the header says which file each distinct-`run_date` count is read from, an
465
460
  test("the header's `run_date` source claims still hold against the query, the scraper and the guard", () => {
466
461
  const block = runDateSources();
467
462
 
468
- // The floor half: SKILL.md's own recount accumulates distinct dates keyed on
469
- // a positional field of THIS file. Resolve that `$n` against the column list
470
- // rather than trusting the paragraph's word for it — the mutation this must
471
- // survive is repointing the recount at another column.
472
- const floorAwk = between(RUN_TEAM, "grep -vc '^#' docs/metrics/tier-outcomes.tsv", "```", "SKILL.md's recount block");
473
- const floorKey = /d\[\$(\d+)\]=1/.exec(floorAwk);
474
- assert.ok(floorKey, "SKILL.md's recount no longer accumulates the floor's distinct dates");
475
- assert.match(floorAwk, /length\(d\)/, "SKILL.md's recount no longer prints the floor's distinct-date count");
476
- assert.equal(COLUMNS[floorKey[1] - 1], "run_date", "the floor's distinct-date count is not this file's `run_date`");
477
- assert.ok(
478
- block.includes(floorKey[0]),
479
- `the header cites an idiom for the floor's date key that SKILL.md no longer uses (\`${floorKey[0]}\`)`,
480
- );
481
-
482
- // The header's own prose also names WHICH column that count reads
483
- // ("column 1 here") — a positional claim nothing above checked, since
484
- // `floorKey[0]` only pins the awk idiom, not the number the header prints
485
- // beside it in English. Resolve it against the same `$n` the recount
486
- // above actually keys on.
487
- const floorColumnCite = /column (\d+) here/.exec(block);
488
- assert.ok(floorColumnCite, "the header no longer names which column the revert floor's distinct-date count reads");
489
- assert.equal(
490
- Number(floorColumnCite[1]),
491
- Number(floorKey[1]),
492
- "the header's `column N here` cite no longer matches the column SKILL.md's recount actually keys on",
493
- );
494
-
495
463
  // The pairing half: the query lives in the OTHER file's header and keys its
496
464
  // dates off the other file's own columns, so resolve it against that file's
497
465
  // COLUMNS export. This is the claim that makes the paragraph load-bearing —
@@ -559,25 +527,14 @@ test("the header's `run_date` source claims still hold against the query, the sc
559
527
  // SKILL.md duty: tier-outcomes.test.mjs runs `append` and pins the date it
560
528
  // writes to the day it ran.
561
529
 
562
- // Both floors' numbers, as the paragraph quotes them. It names four figures
563
- // it does not own; a threshold changed in SKILL.md alone leaves this header
530
+ // The floor's numbers, as the paragraph quotes them. It names figures it
531
+ // does not own; a threshold changed in SKILL.md alone leaves this header
564
532
  // quietly citing the old one.
565
- const guard = unemphasized(RUN_TEAM);
566
- assert.match(
567
- guard,
568
- phrase("Floor: the file holds at least three `class=routine` PRs spanning two or more distinct `run_date`s"),
569
- "SKILL.md's revert floor is no longer three PRs across two dates — the header quotes those numbers",
570
- );
571
533
  assert.match(
572
- guard,
534
+ unemphasized(RUN_TEAM),
573
535
  phrase("there are at least ten of them across five or more distinct `run_date`s"),
574
536
  "SKILL.md's pairing floor is no longer ten pairs across five dates — the header quotes those numbers",
575
537
  );
576
- assert.match(
577
- block,
578
- phrase("at least three `class=routine` PRs spanning two or more"),
579
- "the header no longer states the revert floor it attributes to this file",
580
- );
581
538
  assert.match(
582
539
  block,
583
540
  phrase("at least ten within-run pairs across five or more"),