@feigi/fleet-ctl 3.23.35 → 3.23.37

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 (204) hide show
  1. package/package.json +1 -1
  2. package/scripts/main-checkout.mjs +1 -1
  3. package/scripts/member-write-guard.mjs +1 -1
  4. package/scripts/repo-root.mjs +1 -1
  5. package/skills/run-team/references/reaping.md +1 -1
  6. package/scripts/agent-test-dir-prose.test.mjs +0 -59
  7. package/scripts/agent-test.test.mjs +0 -1640
  8. package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
  9. package/scripts/ambient-git-vars-prose.test.mjs +0 -192
  10. package/scripts/ancestry-check-position-prose.test.mjs +0 -175
  11. package/scripts/apply-ruleset.test.mjs +0 -421
  12. package/scripts/arg-header-probes-prose.test.mjs +0 -394
  13. package/scripts/arg.test.mjs +0 -1354
  14. package/scripts/board-cli.test.mjs +0 -710
  15. package/scripts/board-identity.test.mjs +0 -429
  16. package/scripts/board-liveness-banner.test.mjs +0 -119
  17. package/scripts/board-prev-shape.test.mjs +0 -228
  18. package/scripts/board-tryparse-null.test.mjs +0 -119
  19. package/scripts/board.test.mjs +0 -3121
  20. package/scripts/brief-after-cut-prose.test.mjs +0 -53
  21. package/scripts/candidates-exit3-prose.test.mjs +0 -302
  22. package/scripts/candidates.test.mjs +0 -2312
  23. package/scripts/caveat-unification-prose.test.mjs +0 -98
  24. package/scripts/cell-readout.test.mjs +0 -615
  25. package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
  26. package/scripts/ci-completes-premise-prose.test.mjs +0 -257
  27. package/scripts/ci-state-prose.test.mjs +0 -113
  28. package/scripts/ci-state.test.mjs +0 -1933
  29. package/scripts/ci-vacuous-green.test.mjs +0 -368
  30. package/scripts/citation-sweep-prose.test.mjs +0 -1712
  31. package/scripts/claim-lifecycle.test.mjs +0 -187
  32. package/scripts/claim-ticket.test.mjs +0 -1122
  33. package/scripts/closing-keyword-prose.test.mjs +0 -193
  34. package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
  35. package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
  36. package/scripts/compute-board.test.mjs +0 -1214
  37. package/scripts/compute-spend.test.mjs +0 -517
  38. package/scripts/consumer-technology-prose.test.mjs +0 -126
  39. package/scripts/cross-repo-citation-prose.test.mjs +0 -155
  40. package/scripts/cwd-isolation-pins.mjs +0 -83
  41. package/scripts/dedupe-guard-prose.test.mjs +0 -243
  42. package/scripts/delete-merged-branch.test.mjs +0 -576
  43. package/scripts/derive-testcmd.test.mjs +0 -595
  44. package/scripts/diff-stats.test.mjs +0 -404
  45. package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
  46. package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
  47. package/scripts/dispositions-check.test.mjs +0 -936
  48. package/scripts/dispositions-gate-prose.test.mjs +0 -129
  49. package/scripts/drop-merged-label.test.mjs +0 -479
  50. package/scripts/exec-stub.mjs +0 -93
  51. package/scripts/exec-stub.test.mjs +0 -69
  52. package/scripts/expected-jobs-prose.test.mjs +0 -80
  53. package/scripts/fan-out-authorization-prose.test.mjs +0 -80
  54. package/scripts/filing-bar-seat-prose.test.mjs +0 -242
  55. package/scripts/filing-claim-bar-prose.test.mjs +0 -166
  56. package/scripts/finisher-died-prose.test.mjs +0 -31
  57. package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
  58. package/scripts/finisher-halt-prose.test.mjs +0 -106
  59. package/scripts/finisher-name-prose.test.mjs +0 -134
  60. package/scripts/finisher-own-tree-prose.test.mjs +0 -299
  61. package/scripts/finisher-pin-race-prose.test.mjs +0 -339
  62. package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
  63. package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
  64. package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
  65. package/scripts/fleet-bootstrap.test.mjs +0 -75
  66. package/scripts/fleet-heartbeat.test.mjs +0 -450
  67. package/scripts/fleet-provenance.test.mjs +0 -138
  68. package/scripts/fleet-run.test.mjs +0 -90
  69. package/scripts/fleet-state.test.mjs +0 -460
  70. package/scripts/fleet-tick-prose.test.mjs +0 -300
  71. package/scripts/fleet-tick.test.mjs +0 -2444
  72. package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
  73. package/scripts/frontmatter-check.test.mjs +0 -436
  74. package/scripts/git-env.test.mjs +0 -149
  75. package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
  76. package/scripts/gone-walk.test.mjs +0 -213
  77. package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
  78. package/scripts/head-moved-after-label-prose.test.mjs +0 -233
  79. package/scripts/immutable-body-claim-prose.test.mjs +0 -204
  80. package/scripts/implementer-model-tier.test.mjs +0 -235
  81. package/scripts/inflight-citation-prose.test.mjs +0 -144
  82. package/scripts/inflight-exit2-prose.test.mjs +0 -81
  83. package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
  84. package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
  85. package/scripts/inflight.test.mjs +0 -2882
  86. package/scripts/injection-control-prose.test.mjs +0 -404
  87. package/scripts/install-root-audit.test.mjs +0 -464
  88. package/scripts/instrument-check-prose.test.mjs +0 -235
  89. package/scripts/instruments.test.mjs +0 -787
  90. package/scripts/is-cli.test.mjs +0 -99
  91. package/scripts/issue-tracker-prose.test.mjs +0 -71
  92. package/scripts/json.test.mjs +0 -364
  93. package/scripts/ledger-dispatch.test.mjs +0 -927
  94. package/scripts/ledger-grammar.test.mjs +0 -227
  95. package/scripts/ledger-read-require-file.test.mjs +0 -197
  96. package/scripts/ledger-rotate.test.mjs +0 -142
  97. package/scripts/ledger.test.mjs +0 -3436
  98. package/scripts/line-distance-prose.test.mjs +0 -245
  99. package/scripts/liveness-rationale-prose.test.mjs +0 -83
  100. package/scripts/locale-pin-prose.test.mjs +0 -189
  101. package/scripts/main-checkout.test.mjs +0 -332
  102. package/scripts/member-outcome-prose.test.mjs +0 -167
  103. package/scripts/member-outcomes-header.test.mjs +0 -129
  104. package/scripts/member-outcomes-prose.test.mjs +0 -63
  105. package/scripts/member-outcomes.test.mjs +0 -638
  106. package/scripts/member-prompt-prose.test.mjs +0 -165
  107. package/scripts/member-record.test.mjs +0 -541
  108. package/scripts/member-write-guard.test.mjs +0 -214
  109. package/scripts/merge-commit-probe-prose.test.mjs +0 -122
  110. package/scripts/merge-gate.test.mjs +0 -613
  111. package/scripts/muted-git-guard-sweep.test.mjs +0 -493
  112. package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
  113. package/scripts/net-watchdog-prose.test.mjs +0 -79
  114. package/scripts/net.test.mjs +0 -211
  115. package/scripts/no-ci-gate-prose.test.mjs +0 -108
  116. package/scripts/no-undo-audit.test.mjs +0 -3961
  117. package/scripts/no-wave.test.mjs +0 -138
  118. package/scripts/node-floor-sweep.test.mjs +0 -611
  119. package/scripts/pointer-target-prose.test.mjs +0 -186
  120. package/scripts/pr-cost.test.mjs +0 -521
  121. package/scripts/pr-overlap.test.mjs +0 -692
  122. package/scripts/printf-die-sweep.test.mjs +0 -384
  123. package/scripts/prompt-renderer.mjs +0 -40
  124. package/scripts/prompt-renderer.test.mjs +0 -68
  125. package/scripts/prose-pin.mjs +0 -807
  126. package/scripts/prose-pin.test.mjs +0 -1034
  127. package/scripts/prove-merge.test.mjs +0 -995
  128. package/scripts/pull-table-relabel-prose.test.mjs +0 -60
  129. package/scripts/quiet-payload-prose.test.mjs +0 -222
  130. package/scripts/reap-cherry-check-prose.test.mjs +0 -80
  131. package/scripts/reap.test.mjs +0 -4432
  132. package/scripts/reaping-prose.test.mjs +0 -239
  133. package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
  134. package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
  135. package/scripts/recipe-derivation-prose.test.mjs +0 -112
  136. package/scripts/recipe-prove.test.mjs +0 -1042
  137. package/scripts/refuter-scratch-prose.test.mjs +0 -135
  138. package/scripts/release-label-required-prose.test.mjs +0 -71
  139. package/scripts/release-label-split-prose.test.mjs +0 -184
  140. package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
  141. package/scripts/release-ticket.test.mjs +0 -5099
  142. package/scripts/renovate-release-contract.test.mjs +0 -379
  143. package/scripts/repo-root.test.mjs +0 -873
  144. package/scripts/reporter-output-rule-prose.test.mjs +0 -208
  145. package/scripts/review-agent-report-only.test.mjs +0 -49
  146. package/scripts/review-core-booking.test.mjs +0 -35
  147. package/scripts/review-core-cwd-isolation.test.mjs +0 -374
  148. package/scripts/review-core-reads.test.mjs +0 -478
  149. package/scripts/review-core-refuter-scratch.test.mjs +0 -148
  150. package/scripts/review-core-scratch-refusal.test.mjs +0 -64
  151. package/scripts/review-core-shared-test-run.test.mjs +0 -275
  152. package/scripts/review-core-snapshot-path.test.mjs +0 -830
  153. package/scripts/review-core-specialist-scratch.test.mjs +0 -191
  154. package/scripts/review-core-testcmd.test.mjs +0 -335
  155. package/scripts/review-core-unrun.test.mjs +0 -566
  156. package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
  157. package/scripts/review-eval-resolver-path.test.mjs +0 -55
  158. package/scripts/review-host-fixture.mjs +0 -89
  159. package/scripts/review-in-run-retry.test.mjs +0 -211
  160. package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
  161. package/scripts/review-path-default.test.mjs +0 -796
  162. package/scripts/review-runner-spawns.test.mjs +0 -95
  163. package/scripts/review-runner.test.mjs +0 -166
  164. package/scripts/review-tier-audit.test.mjs +0 -140
  165. package/scripts/run-artifact-pr-prose.test.mjs +0 -341
  166. package/scripts/run-merge-bot-prose.test.mjs +0 -1413
  167. package/scripts/run-team-local-hook.test.mjs +0 -442
  168. package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
  169. package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
  170. package/scripts/section-between-guard-prose.test.mjs +0 -379
  171. package/scripts/select-dimensions.test.mjs +0 -674
  172. package/scripts/shared-refusal.test.mjs +0 -388
  173. package/scripts/shell-traps-prose.test.mjs +0 -504
  174. package/scripts/shortlist.test.mjs +0 -380
  175. package/scripts/slow-transport.mjs +0 -72
  176. package/scripts/snapshot-repo.test.mjs +0 -1006
  177. package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
  178. package/scripts/spend-view.test.mjs +0 -312
  179. package/scripts/staleness-qualifier-prose.test.mjs +0 -251
  180. package/scripts/staleness-verdict-prose.test.mjs +0 -142
  181. package/scripts/staleness.test.mjs +0 -893
  182. package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
  183. package/scripts/stash-prohibition-prose.test.mjs +0 -313
  184. package/scripts/strip-comments.mjs +0 -44
  185. package/scripts/temp-dir.mjs +0 -47
  186. package/scripts/ticket-router.test.mjs +0 -981
  187. package/scripts/tier-check.test.mjs +0 -828
  188. package/scripts/tier-outcomes-header.test.mjs +0 -518
  189. package/scripts/tier-outcomes.test.mjs +0 -572
  190. package/scripts/tier-roles.test.mjs +0 -535
  191. package/scripts/tracker-block-copy-prose.test.mjs +0 -288
  192. package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
  193. package/scripts/unattended-git-sweep.test.mjs +0 -142
  194. package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
  195. package/scripts/verify-sha.test.mjs +0 -692
  196. package/scripts/watcher-degraded-block.test.mjs +0 -369
  197. package/scripts/watcher-key-prose.test.mjs +0 -106
  198. package/scripts/within-run-pair-prose.test.mjs +0 -212
  199. package/scripts/worktree-audit.test.mjs +0 -1408
  200. package/scripts/worktree-head-prose.test.mjs +0 -276
  201. package/scripts/worktree-listing-sweep.test.mjs +0 -217
  202. package/scripts/worktree-model-prose.test.mjs +0 -216
  203. package/scripts/worktree-porcelain.mjs +0 -35
  204. package/scripts/worktree-porcelain.test.mjs +0 -102
@@ -1,442 +0,0 @@
1
- // The repo-local run-team hook, .omp/skills/run-team-local/hook.mjs, run as
2
- // the CLI against a fixture workspace: a clone of a bare origin whose main
3
- // carries the metrics corpus, the router table and the cell definitions, and
4
- // a stub `gh` that answers from a fixture file and logs every call it gets.
5
- import { test } from "node:test";
6
- import assert from "node:assert/strict";
7
- import { execFileSync, spawnSync } from "node:child_process";
8
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
9
- import { dirname, join } from "node:path";
10
- import { fileURLToPath } from "node:url";
11
- import { tempDir } from "./temp-dir.mjs";
12
- import { writeExecStub } from "./exec-stub.mjs";
13
- import { COLUMNS as MEMBER_COLUMNS, formatTsv } from "./member-outcomes.mjs";
14
- import { COLUMNS as TIER_COLUMNS, formatRow } from "./tier-outcomes.mjs";
15
- import { FEATURE_COLUMNS, WINDOW_START, MIN_N } from "./pr-cost.mjs";
16
- import { FIT_EVERY_MERGED } from "./ticket-router.mjs";
17
- import { STOP } from "./cell-readout.mjs";
18
-
19
- const HOOK = fileURLToPath(new URL("../../.omp/skills/run-team-local/hook.mjs", import.meta.url));
20
- const DAY = WINDOW_START;
21
- const SESSION = "2026-10-03T10-00-00-000Z_01a00000-0000-7000-8000-000000000000";
22
- const STAGE1 = ["slow-high", "task-high", "smol-high"];
23
- const PENDING = join(".fleet", "ticket-features.pending.tsv");
24
- const FEATURES = join("docs", "metrics", "ticket-features.tsv");
25
- const GUARD = join(".fleet", "cost-guard.json");
26
- const TABLE = join("plugin", "scripts", "router-table.json");
27
-
28
- // Pinned identity, no developer config, no inherited repo pointers.
29
- const ENV = {
30
- ...process.env,
31
- GIT_DIR: undefined, GIT_WORK_TREE: undefined, GIT_INDEX_FILE: undefined, GIT_TEMPLATE_DIR: undefined,
32
- GIT_AUTHOR_NAME: "t", GIT_AUTHOR_EMAIL: "t@example.com", GIT_COMMITTER_NAME: "t", GIT_COMMITTER_EMAIL: "t@example.com",
33
- GIT_CONFIG_GLOBAL: "/dev/null", GIT_CONFIG_SYSTEM: "/dev/null",
34
- };
35
- const git = (cwd, args, env = {}) => execFileSync("git", ["-C", cwd, ...args], { env: { ...ENV, ...env }, encoding: "utf8" }).trim();
36
-
37
- const MODEL_ROLES = { slow: "anthropic/claude-opus-5", task: "anthropic/claude-sonnet-5", smol: "anthropic/claude-haiku-4-5" };
38
- const CATALOG = {
39
- models: [
40
- { selector: "anthropic/claude-opus-5", thinking: ["low", "medium", "high", "xhigh", "max"] },
41
- { selector: "anthropic/claude-sonnet-5", thinking: ["low", "medium", "high", "xhigh", "max"] },
42
- { selector: "anthropic/claude-haiku-4-5", thinking: ["minimal", "low", "medium", "high", "xhigh"] },
43
- ],
44
- };
45
- const MODEL_OF = { slow: "claude-opus-5", task: "claude-sonnet-5", smol: "claude-haiku-4-5" };
46
-
47
- const pull = (o) => ({
48
- run_date: DAY, session: SESSION, policy_cell: "slow-high", chosen_cell: "slow-high", exploration_draw: "",
49
- sizing_src: "rule", sizing_pre: "", router_usd: "", brief_chars: "100", criteria: "1", comments: "0",
50
- age_days: "0", paths: "0", test_paths: "0", xrefs: "0", kind: "enhancement", ...o,
51
- });
52
- const member = (o) => ({
53
- session: SESSION, run_date: DAY, role: "implementer", member: o.agent, model: "claude-opus-5", effort: "high",
54
- ticket: "", pr: "", tokensCacheCreate: 0, tokensOut: 0, wallS: 0, turns: 1, harness: "omp", subagentType: "",
55
- tokensIn: 0, tokensCacheRead: 0, tokensCacheWrite1h: 0, cost: 0, ...o,
56
- });
57
- const tier = (o) => ({
58
- run_date: DAY, class: "", tier: "", closed_own_ticket: "yes", minted_false_claim: "no", note: "n",
59
- sizing: "light", profile: "small", loc: "10", files: "1", ...o,
60
- });
61
- const corpus = () => ({ features: [], members: [], tiers: [] });
62
- // One ruled Pull at `cell`: its features row, its admissible member row, its verdict.
63
- function ruled(rows, { ticket, cell = "slow-high", fail = false, date = DAY }) {
64
- const [role, level] = cell.split("-");
65
- const agent = `impl-${ticket}`;
66
- rows.features.push(pull({ ticket: String(ticket), agent, chosen_cell: cell, run_date: date }));
67
- rows.members.push(member({ agent, ticket: String(ticket), run_date: date, effort: level, model: MODEL_OF[role], subagentType: `fleet-implementer-${cell}` }));
68
- rows.tiers.push(tier({ ticket: String(ticket), pr: String(ticket + 5000), run_date: date, minted_false_claim: fail ? "yes" : "no" }));
69
- }
70
-
71
- const featuresTsv = (rows, cols = FEATURE_COLUMNS) => [cols.join("\t"), ...rows.map((r) => cols.map((c) => r[c] ?? "").join("\t"))].join("\n") + "\n";
72
- const membersTsv = (rows) => `# ${MEMBER_COLUMNS.join("\t")}\n${rows.length ? formatTsv(rows) : ""}`;
73
- const tiersTsv = (rows) => `# ${TIER_COLUMNS.join("\t")}\n${rows.map((r) => `${formatRow(r)}\n`).join("")}`;
74
- const routerTable = (over = {}) => ({
75
- window_start: null, fitted_through: "2026-10-01", n_rows: 0, stage: 1, cells: [...STAGE1], burn_in: true,
76
- rows: { "*": "slow-high" }, classifier: { b: null, tau: null }, estimates: {}, guard: { tripped: [], n: {} }, ...over,
77
- });
78
- const agentMd = (cell) => {
79
- const [role, level] = cell.split("-");
80
- return `---\nname: fleet-implementer-${cell}\ndescription: fixture\nmodel: "@${role}:${level}"\n---\n\nbody\n`;
81
- };
82
-
83
- // Answers `pr list` (pr-cost's merged-state read, or the open re-fit PR read),
84
- // `issue list` (raw text instead of JSON when the fixture has `issuesRaw`),
85
- // and the two writes, from GH_FIXTURE; logs each argv to GH_LOG.
86
- const GH_STUB = `#!/usr/bin/env node
87
- const fs = require("node:fs");
88
- const args = process.argv.slice(2);
89
- fs.appendFileSync(process.env.GH_LOG, JSON.stringify(args) + "\\n");
90
- const fx = JSON.parse(fs.readFileSync(process.env.GH_FIXTURE, "utf8"));
91
- const json = args[args.indexOf("--json") + 1];
92
- const out = (v) => process.stdout.write(JSON.stringify(v));
93
- const cmd = args.slice(0, 2).join(" ");
94
- if (cmd === "pr list") out(json === "number,headRefName" ? fx.openPrs : fx.prs);
95
- else if (cmd === "issue list") { if (fx.issuesRaw !== undefined) process.stdout.write(fx.issuesRaw); else out(fx.issues); }
96
- else if (cmd === "issue create") console.log("https://github.com/o/r/issues/901");
97
- else if (cmd === "pr create") console.log("https://github.com/o/r/pull/902");
98
- else { process.stderr.write("gh stub: unexpected " + args.join(" ")); process.exit(9); }
99
- `;
100
-
101
- function write(root, rel, text) {
102
- mkdirSync(dirname(join(root, rel)), { recursive: true });
103
- writeFileSync(join(root, rel), text);
104
- }
105
-
106
- // `readded`: cell → the date its definition is deleted and added back on main.
107
- function fixture({ rows = corpus(), table = routerTable(), cells = STAGE1, readded = {}, pending = null, guardBefore = null, gh = {} } = {}) {
108
- const root = tempDir("run-team-local-");
109
- const origin = join(root, "origin.git");
110
- const seed = join(root, "seed");
111
- git(root, ["init", "--quiet", "--bare", "-b", "main", origin]);
112
- git(root, ["init", "--quiet", "-b", "main", seed]);
113
- const commit = (msg, at) => git(seed, ["commit", "--quiet", "-m", msg], { GIT_AUTHOR_DATE: at, GIT_COMMITTER_DATE: at });
114
- write(seed, ".gitignore", ".fleet/\n");
115
- for (const cell of cells) write(seed, `plugin/agents/fleet-implementer-${cell}.agent.md`, agentMd(cell));
116
- git(seed, ["add", "-A"]);
117
- commit("cells", "2026-09-01T00:00:00Z");
118
- for (const [cell, at] of Object.entries(readded)) {
119
- git(seed, ["rm", "--quiet", `plugin/agents/fleet-implementer-${cell}.agent.md`]);
120
- commit(`withdraw ${cell}`, at);
121
- write(seed, `plugin/agents/fleet-implementer-${cell}.agent.md`, agentMd(cell));
122
- git(seed, ["add", "-A"]);
123
- commit(`reinstate ${cell}`, at);
124
- }
125
- write(seed, FEATURES, featuresTsv(rows.features));
126
- write(seed, "docs/metrics/member-outcomes.tsv", membersTsv(rows.members));
127
- write(seed, "docs/metrics/tier-outcomes.tsv", tiersTsv(rows.tiers));
128
- write(seed, TABLE, `${JSON.stringify(table, null, 2)}\n`);
129
- git(seed, ["add", "-A"]);
130
- commit("corpus", "2026-10-03T12:00:00Z");
131
- git(seed, ["push", "--quiet", origin, "main"]);
132
- const repo = join(root, "repo");
133
- git(root, ["clone", "--quiet", origin, repo]);
134
- if (pending !== null) write(repo, PENDING, pending);
135
- if (guardBefore !== null) write(repo, GUARD, JSON.stringify(guardBefore));
136
- mkdirSync(join(root, "bin"));
137
- writeExecStub(join(root, "bin", "gh"), GH_STUB);
138
- writeFileSync(join(root, "gh.json"), JSON.stringify({ prs: [], openPrs: [], issues: [], ...gh }));
139
- writeFileSync(join(root, "model-roles.json"), JSON.stringify(MODEL_ROLES));
140
- writeFileSync(join(root, "catalog.json"), JSON.stringify(CATALOG));
141
- const log = join(root, "gh.log");
142
- return {
143
- root, origin, repo,
144
- run(phase, extra = [], { cwd = repo, repoFlag = true } = {}) {
145
- const args = [HOOK, phase, ...(repoFlag ? ["--repo", repo] : []),
146
- "--model-roles", join(root, "model-roles.json"), "--catalog", join(root, "catalog.json"), ...extra];
147
- return spawnSync(process.execPath, args, {
148
- cwd, encoding: "utf8",
149
- env: { ...ENV, PATH: `${join(root, "bin")}:${process.env.PATH}`, GH_FIXTURE: join(root, "gh.json"), GH_LOG: log },
150
- });
151
- },
152
- ghCalls: () => (existsSync(log) ? readFileSync(log, "utf8").trim().split("\n").map((l) => JSON.parse(l)) : []),
153
- };
154
- }
155
- const calls = (f, cmd) => f.ghCalls().filter((c) => c.slice(0, 2).join(" ") === cmd);
156
- const worktrees = (repo) => git(repo, ["worktree", "list", "--porcelain"]).split("\n").filter((l) => l.startsWith("worktree ")).length;
157
- const escape = (s) => s.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
158
-
159
- // ---------------------------------------------------------------------------
160
- // phase-0
161
-
162
- test("phase-0: drains the pending TSV into ticket-features.tsv, deduped on session + agent, and writes a fresh cost-guard.json", () => {
163
- const rows = corpus();
164
- ruled(rows, { ticket: 1 });
165
- const fresh = [pull({ ticket: "2", agent: "impl-2" }), pull({ ticket: "3", agent: "impl-3", chosen_cell: "task-high", exploration_draw: "2/3" })];
166
- // Read by column name: a pending header in another order drains the same rows.
167
- const pending = featuresTsv([rows.features[0], fresh[0], ...fresh], [...FEATURE_COLUMNS].reverse());
168
- const f = fixture({ rows, pending, guardBefore: { computed_at: "2000-01-01T00:00:00.000Z", verdict: "ok", tripped: [], cells: [] } });
169
- const started = Date.now();
170
- const r = f.run("phase-0");
171
- assert.equal(r.status, 0, r.stderr);
172
- assert.equal(readFileSync(join(f.repo, FEATURES), "utf8"), featuresTsv([rows.features[0], ...fresh]));
173
- assert.equal(existsSync(join(f.repo, PENDING)), false, "the drained pending file is gone");
174
- assert.match(r.stdout, /drain: 2 rows from \.fleet\/ticket-features\.pending\.tsv into docs\/metrics\/ticket-features\.tsv \(2 already there\)/);
175
- const guard = JSON.parse(readFileSync(join(f.repo, GUARD), "utf8"));
176
- assert.ok(Date.parse(guard.computed_at) >= started - 1000, `a fresh guard, not the stale one: ${guard.computed_at}`);
177
- assert.equal(guard.verdict, "none");
178
- assert.match(r.stdout, /cost guard: verdict none, pr-cost\.mjs exit 4/, "no verdict yet is a verdict, not a failure");
179
- assert.match(r.stdout, /drift notice: every cell's last admissible row ran its role's current target/);
180
- assert.deepEqual(f.ghCalls().map((c) => c.slice(0, 2).join(" ")), ["pr list"], "phase 0 writes nothing to GitHub");
181
- });
182
-
183
- test("phase-0: with no --repo it works on the main checkout of the cwd's repository; a second run finds nothing pending and changes nothing", () => {
184
- const rows = corpus();
185
- ruled(rows, { ticket: 1 });
186
- const fresh = pull({ ticket: "2", agent: "impl-2" });
187
- const f = fixture({ rows, pending: featuresTsv([fresh]) });
188
- const wt = join(f.root, "wt");
189
- git(f.repo, ["worktree", "add", "--quiet", wt]);
190
- const r = f.run("phase-0", [], { cwd: wt, repoFlag: false });
191
- assert.equal(r.status, 0, r.stderr);
192
- const drained = readFileSync(join(f.repo, FEATURES), "utf8");
193
- assert.equal(drained, featuresTsv([rows.features[0], fresh]));
194
- assert.equal(existsSync(join(f.repo, GUARD)), true);
195
- assert.equal(existsSync(join(wt, ".fleet")), false, "nothing is written under the linked worktree");
196
-
197
- const again = f.run("phase-0", [], { cwd: wt, repoFlag: false });
198
- assert.equal(again.status, 0, again.stderr);
199
- assert.match(again.stdout, /drain: nothing pending in \.fleet\/ticket-features\.pending\.tsv/);
200
- assert.equal(readFileSync(join(f.repo, FEATURES), "utf8"), drained);
201
- });
202
-
203
- test("phase-0: a tripped guard is a verdict and the hook goes on; a guard that cannot be computed fails the hook there", () => {
204
- const rows = corpus();
205
- const prs = [];
206
- for (let i = 0; i < MIN_N; i++) {
207
- ruled(rows, { ticket: 1000 + i, cell: "slow-high", fail: i < 6 });
208
- ruled(rows, { ticket: 2000 + i, cell: "task-high", fail: i < 9 });
209
- prs.push({ number: 6000 + i, state: "MERGED", mergedAt: `${DAY}T12:00:00Z` }, { number: 7000 + i, state: "MERGED", mergedAt: `${DAY}T12:00:00Z` });
210
- }
211
- const tripped = fixture({ rows, gh: { prs } });
212
- const t = tripped.run("phase-0");
213
- assert.equal(t.status, 0, t.stderr);
214
- assert.match(t.stdout, /cost guard: verdict tripped \(tripped: task-high\), pr-cost\.mjs exit 3/);
215
- assert.match(t.stdout, /drift notice:/, "the duty after the guard ran");
216
-
217
- const broken = fixture({ rows: corpus() });
218
- writeFileSync(join(broken.repo, "docs", "metrics", "member-outcomes.tsv"), "short\trow\n");
219
- const b = broken.run("phase-0");
220
- assert.equal(b.status, 1);
221
- assert.match(b.stderr, /run-team-local: cost guard failed: pr-cost\.mjs --guard exited 2/);
222
- assert.doesNotMatch(b.stdout, /drift notice/, "the duties after a failed one do not run");
223
- });
224
-
225
- test("phase-0: the drift notice names a cell whose last admissible row ran another model than its role now resolves, and a cell whose level that target does not run", () => {
226
- const rows = corpus();
227
- rows.members.push(
228
- member({ agent: "impl-1", run_date: "2026-10-01", session: "s1", model: "claude-sonnet-5", effort: "high", subagentType: "fleet-implementer-task-high" }),
229
- member({ agent: "impl-2", run_date: "2026-10-02", session: "s2", model: "claude-sonnet-4-5", effort: "high", subagentType: "fleet-implementer-task-high" }),
230
- // Newer, but clamped to another effort: never admissible, so never the last admissible row.
231
- member({ agent: "impl-3", run_date: "2026-10-05", session: "s3", model: "claude-sonnet-5", effort: "medium", subagentType: "fleet-implementer-task-high" }),
232
- // The role's target spelled with its provider prefix is the same model.
233
- member({ agent: "impl-4", run_date: "2026-10-02", session: "s4", model: "claude-opus-5", effort: "high", subagentType: "fleet-implementer-slow-high" }),
234
- member({ agent: "impl-5", run_date: "2026-10-01", session: "s5", model: "claude-haiku-4-5", effort: "high", subagentType: "fleet-implementer-smol-high" }),
235
- member({ agent: "impl-6", run_date: "2026-10-09", session: "s6", model: "claude-haiku-3", effort: "high", subagentType: "task" }),
236
- );
237
- const f = fixture({ rows, cells: [...STAGE1, "smol-max"] });
238
- const r = f.run("phase-0");
239
- assert.equal(r.status, 0, r.stderr);
240
- assert.deepEqual(r.stdout.split("\n").filter((l) => l.startsWith("tier-roles: notice: ")), [
241
- "tier-roles: notice: fleet-implementer-smol-max runs at max; modelRoles.smol now resolves anthropic/claude-haiku-4-5, which does not run at max (thinking: minimal, low, medium, high, xhigh)",
242
- "tier-roles: notice: fleet-implementer-task-high last ran claude-sonnet-4-5; modelRoles.task now resolves anthropic/claude-sonnet-5 — cell history spans two models",
243
- ]);
244
- });
245
-
246
- test("phase-0: a role with no target in modelRoles raises no notice for its cells, and the cells whose role resolves are still checked", () => {
247
- const rows = corpus();
248
- rows.members.push(
249
- member({ agent: "impl-1", run_date: "2026-10-01", session: "s1", model: "claude-haiku-3", effort: "high", subagentType: "fleet-implementer-smol-high" }),
250
- member({ agent: "impl-2", run_date: "2026-10-01", session: "s2", model: "claude-sonnet-4-5", effort: "high", subagentType: "fleet-implementer-task-high" }),
251
- );
252
- const f = fixture({ rows });
253
- const { smol, ...withoutSmol } = MODEL_ROLES;
254
- writeFileSync(join(f.root, "model-roles.json"), JSON.stringify(withoutSmol));
255
- const r = f.run("phase-0");
256
- assert.equal(r.status, 0, r.stderr);
257
- assert.deepEqual(r.stdout.split("\n").filter((l) => l.startsWith("tier-roles: notice: ")), [
258
- "tier-roles: notice: fleet-implementer-task-high last ran claude-sonnet-4-5; modelRoles.task now resolves anthropic/claude-sonnet-5 — cell history spans two models",
259
- ]);
260
- });
261
-
262
- test("phase-0: of the rows dated the same day the drift notice follows the higher session, in whichever order the rows come", () => {
263
- const rows = corpus();
264
- const sameDay = (agent, session, model, cell) => member({ agent, run_date: "2026-10-02", session, model, effort: "high", subagentType: `fleet-implementer-${cell}` });
265
- rows.members.push(
266
- // The lower session ran another model and comes first.
267
- sameDay("impl-1", "s1", "claude-haiku-3", "smol-high"),
268
- sameDay("impl-2", "s2", "claude-haiku-4-5", "smol-high"),
269
- // The higher session comes first.
270
- sameDay("impl-3", "s4", "claude-sonnet-5", "task-high"),
271
- sameDay("impl-4", "s3", "claude-sonnet-4-5", "task-high"),
272
- );
273
- const r = fixture({ rows }).run("phase-0");
274
- assert.equal(r.status, 0, r.stderr);
275
- assert.doesNotMatch(r.stdout, /tier-roles: notice:/);
276
- assert.match(r.stdout, /drift notice: every cell's last admissible row ran its role's current target/);
277
- });
278
-
279
- // ---------------------------------------------------------------------------
280
- // close-out: the stopping rule
281
-
282
- // smol-high at ten verdicts, eight failing the floor; task-high at three, all failing.
283
- function floorFailing() {
284
- const rows = corpus();
285
- for (let i = 0; i < STOP.verdicts; i++) ruled(rows, { ticket: 100 + i, cell: "smol-high", fail: i < 8 });
286
- for (let i = 0; i < 3; i++) ruled(rows, { ticket: 200 + i, cell: "task-high", fail: true });
287
- return rows;
288
- }
289
- const TITLE = "Withdraw exploration cell smol-high: 8/10 floor failures";
290
-
291
- test("close-out --dry-run: a cell at ten verdicts and eight floor failures would file its withdrawal issue; a cell under the rule continues", () => {
292
- const f = fixture({ rows: floorFailing() });
293
- const r = f.run("close-out", ["--dry-run"]);
294
- assert.equal(r.status, 0, r.stderr);
295
- assert.match(r.stdout, new RegExp(`stopping rule: smol-high 8/10 floor failures since 2026-09-01 — would file "${escape(TITLE)}" \\(ready-for-human\\)`));
296
- assert.match(r.stdout, /stopping rule: task-high 3\/3 floor failures since 2026-09-01 — continues/);
297
- const lists = calls(f, "issue list");
298
- assert.equal(lists.length, 1, "only the stopping cell is looked up");
299
- assert.deepEqual(lists[0].slice(2, 6), ["--state", "open", "--search", `"${TITLE}" in:title`]);
300
- assert.deepEqual(calls(f, "issue create"), [], "a dry run files nothing");
301
- });
302
-
303
- test("close-out: an open issue with the same title dedupes the withdrawal; an open one with other counts does not, and the issue is filed", () => {
304
- const decoy = { number: 78, title: "Withdraw exploration cell smol-high: 7/9 floor failures" };
305
- const open = { number: 77, title: TITLE };
306
- const dup = fixture({ rows: floorFailing(), gh: { issues: [decoy, open] } });
307
- const d = dup.run("close-out");
308
- assert.equal(d.status, 0, d.stderr);
309
- assert.match(d.stdout, new RegExp(`stopping rule: smol-high 8/10 floor failures since 2026-09-01 — withdrawal issue already open, #${open.number}$`, "m"));
310
- assert.deepEqual(calls(dup, "issue create"), []);
311
-
312
- const fresh = fixture({ rows: floorFailing(), gh: { issues: [decoy] } });
313
- const r = fresh.run("close-out");
314
- assert.equal(r.status, 0, r.stderr);
315
- assert.match(r.stdout, /stopping rule: smol-high 8\/10 floor failures since 2026-09-01 — filed https:\/\/github\.com\/o\/r\/issues\/901/);
316
- const [create] = calls(fresh, "issue create");
317
- const flag = (name) => create[create.indexOf(name) + 1];
318
- assert.equal(flag("--title"), TITLE);
319
- assert.equal(flag("--label"), "ready-for-human");
320
- // One verdict-table row per ticket: ticket and PR as references, the ruling's date and both floor fields.
321
- const row = (ticket, minted, floor) => `| #${ticket} | #${ticket + 5000} | 2026-10-03 | yes | ${minted} | ${floor} |`;
322
- const body = flag("--body").split("\n");
323
- assert.ok(body.includes(row(100, "yes", "fail")), flag("--body"));
324
- assert.ok(body.includes(row(109, "no", "pass")), flag("--body"));
325
- const tickets = body.filter((l) => l.startsWith("| #")).map((l) => Number(l.match(/^\| #(\d+) /)[1]));
326
- assert.deepEqual(tickets, [100, 101, 102, 103, 104, 105, 106, 107, 108, 109], "rows run in ascending ticket order");
327
- });
328
-
329
- test("close-out: the count restarts on the day a cell's definition was most recently added", () => {
330
- const f = fixture({ rows: floorFailing(), readded: { "smol-high": "2026-10-04T00:00:00Z" } });
331
- const r = f.run("close-out", ["--dry-run"]);
332
- assert.equal(r.status, 0, r.stderr);
333
- assert.match(r.stdout, /stopping rule: smol-high 0\/0 floor failures since 2026-10-04 — continues/);
334
- assert.deepEqual(calls(f, "issue list"), []);
335
- });
336
-
337
- test("close-out: a definition no commit adds fails the stopping rule naming it, after the cells that can be judged are reported, and the re-fit does not run", () => {
338
- const f = fixture({ rows: floorFailing() });
339
- // On disk beside the committed definitions, never committed.
340
- writeFileSync(join(f.repo, "plugin", "agents", "fleet-implementer-smol-max.agent.md"), agentMd("smol-max"));
341
- const r = f.run("close-out", ["--dry-run"]);
342
- assert.equal(r.status, 1, r.stdout);
343
- assert.match(r.stdout, new RegExp(`stopping rule: smol-high 8/10 floor failures since 2026-09-01 — would file "${escape(TITLE)}"`));
344
- assert.match(r.stderr, /run-team-local: stopping rule failed: not judged — no commit adds fleet-implementer-smol-max\.agent\.md$/m);
345
- assert.doesNotMatch(r.stdout, /router fit/);
346
- });
347
-
348
- test("close-out: a gh that prints something other than JSON fails the duty naming the gh command and what it printed", () => {
349
- const f = fixture({ rows: floorFailing(), gh: { issuesRaw: "<html>rate limited</html>" } });
350
- const r = f.run("close-out", ["--dry-run"]);
351
- assert.equal(r.status, 1, r.stdout);
352
- assert.match(r.stderr, /stopping rule failed: gh issue list printed non-JSON \(.*\): "<html>rate limited<\/html>"$/m);
353
- });
354
-
355
- test("close-out --dry-run: a both-blank tier-outcomes row after a ticket's real ruling leaves the count as it was, and the router fit still runs", () => {
356
- const rows = floorFailing();
357
- rows.tiers.push(tier({ ticket: "100", pr: "1392", closed_own_ticket: "", minted_false_claim: "" }));
358
- const f = fixture({ rows });
359
- const r = f.run("close-out", ["--dry-run"]);
360
- assert.equal(r.status, 0, r.stderr);
361
- assert.match(r.stdout, new RegExp(`stopping rule: smol-high 8/10 floor failures since 2026-09-01 — would file "${escape(TITLE)}"`));
362
- assert.match(r.stdout, /^run-team-local: router fit: /m);
363
- });
364
-
365
- // ---------------------------------------------------------------------------
366
- // close-out: the router re-fit cadence
367
-
368
- // FIT_EVERY_MERGED Pulls on main dated after the table's fitted_through, `n` of them ruled.
369
- function merged(n) {
370
- const rows = corpus();
371
- for (let i = 1; i <= FIT_EVERY_MERGED; i++) {
372
- rows.features.push(pull({ ticket: String(i), agent: `impl-${i}`, run_date: "2026-10-05" }));
373
- if (i <= n) rows.tiers.push(tier({ ticket: String(i), pr: String(500 + i), run_date: "2026-10-05" }));
374
- }
375
- return rows;
376
- }
377
-
378
- test("close-out --dry-run: fifty merged PRs since fitted_through run ticket-router.mjs fit in a throwaway checkout; forty-nine do not", () => {
379
- const below = fixture({ rows: merged(FIT_EVERY_MERGED - 1) });
380
- const b = below.run("close-out", ["--dry-run"]);
381
- assert.equal(b.status, 0, b.stderr);
382
- assert.match(b.stdout, /router fit: DUE=no MERGED=49\/50 — not due/);
383
- assert.doesNotMatch(b.stdout, /ticket-router: fitted/);
384
-
385
- const at = fixture({ rows: merged(FIT_EVERY_MERGED) });
386
- const before = readFileSync(join(at.repo, TABLE), "utf8");
387
- const a = at.run("close-out", ["--dry-run"]);
388
- assert.equal(a.status, 0, a.stderr);
389
- assert.match(a.stdout, /^run-team-local: router fit: DUE=yes MERGED=50\/50 — ticket-router: fitted \d+ tickets through 2026-10-05; .*; would open a chore PR from chore\/router-fit-\d{4}-\d{2}-\d{2}$/m);
390
- assert.equal(readFileSync(join(at.repo, TABLE), "utf8"), before, "the checkout's own table is untouched");
391
- assert.equal(worktrees(at.repo), 1, "the throwaway checkout is gone");
392
- assert.equal(git(at.origin, ["branch", "--list", "chore/*"]), "", "a dry run pushes nothing");
393
- assert.deepEqual(calls(at, "pr create"), []);
394
- });
395
-
396
- test("close-out: a relative --repo reaches the re-fit as the absolute one does", () => {
397
- const f = fixture({ rows: merged(FIT_EVERY_MERGED) });
398
- const r = f.run("close-out", ["--repo", ".", "--dry-run"], { cwd: f.repo, repoFlag: false });
399
- assert.equal(r.status, 0, r.stderr);
400
- assert.match(r.stdout, /router fit: DUE=yes MERGED=50\/50 — .*; would open a chore PR from chore\/router-fit-/);
401
- });
402
-
403
- test("close-out: a due re-fit is pushed to its own chore branch and opened as a PR labelled patch, never onto main — and not while an earlier re-fit PR is open", () => {
404
- const f = fixture({ rows: merged(FIT_EVERY_MERGED) });
405
- const r = f.run("close-out");
406
- assert.equal(r.status, 0, r.stderr);
407
- const branch = /opened https:\/\/github\.com\/o\/r\/pull\/902 from (chore\/router-fit-\S+)$/m.exec(r.stdout)?.[1];
408
- assert.ok(branch, r.stdout);
409
- assert.equal(JSON.parse(git(f.origin, ["show", `${branch}:${TABLE}`])).fitted_through, "2026-10-05");
410
- assert.equal(JSON.parse(git(f.origin, ["show", `main:${TABLE}`])).fitted_through, "2026-10-01", "main itself is untouched");
411
- const [create] = calls(f, "pr create");
412
- assert.equal(create[create.indexOf("--base") + 1], "main");
413
- assert.equal(create[create.indexOf("--head") + 1], branch);
414
- assert.equal(create[create.indexOf("--label") + 1], "patch", "labelled by the create itself, not by an edit that can fail after it");
415
- assert.deepEqual(calls(f, "pr edit"), []);
416
- assert.equal(git(f.repo, ["branch", "--list", "chore/*"]), "", "the checkout's repository keeps no local branch of the PR's");
417
- assert.doesNotMatch(git(f.repo, ["config", "--local", "--list"]), /^branch\.chore/m, "and no upstream config for it");
418
- assert.equal(worktrees(f.repo), 1);
419
-
420
- const earlier = { number: 55, headRefName: "chore/router-fit-2026-10-01" };
421
- const held = fixture({ rows: merged(FIT_EVERY_MERGED), gh: { openPrs: [earlier] } });
422
- const h = held.run("close-out");
423
- assert.equal(h.status, 0, h.stderr);
424
- assert.match(h.stdout, new RegExp(`router fit: DUE=yes MERGED=50/50 — re-fit PR #${earlier.number} \\(${escape(earlier.headRefName)}\\) is still open$`, "m"));
425
- assert.deepEqual(calls(held, "pr create"), []);
426
- assert.equal(git(held.origin, ["branch", "--list", "chore/*"]), "");
427
- });
428
-
429
- // ---------------------------------------------------------------------------
430
- // usage
431
-
432
- test("usage: exactly one phase, and only the declared flags, else exit 2", () => {
433
- const f = fixture();
434
- for (const extra of [[], ["phase-0", "close-out"], ["phase-0", "--bogus"]]) {
435
- const r = spawnSync(process.execPath, [HOOK, ...extra, "--repo", f.repo], { encoding: "utf8", env: ENV });
436
- assert.equal(r.status, 2, `${extra.join(" ")}: ${r.stderr}`);
437
- }
438
- // A flag's value that spells a phase is not the phase.
439
- const value = spawnSync(process.execPath, [HOOK, "--repo", "phase-0", "--dry-run"], { encoding: "utf8", env: ENV, cwd: f.repo });
440
- assert.equal(value.status, 2, value.stderr);
441
- assert.match(value.stderr, /usage: hook\.mjs phase-0\|close-out/);
442
- });
@@ -1,74 +0,0 @@
1
- // #1150. The PR that landed this repo's two-sided scratch-partition rule —
2
- // "any member that dispatches a child writes an absolute directory under its
3
- // own partition into that child's prompt, one per child and never shared, and
4
- // a child never derives its own" (run-team/SKILL.md's "Scratchpad paths need
5
- // two levels" bullet) and its twin in references/isolation.md's "The axis is
6
- // two-sided" paragraph — shipped with NO test coverage for either sentence.
7
- // Measured directly: `grep -rn "and a child never derives its own\|any member
8
- // that dispatches a child writes" plugin/scripts` found zero matches before
9
- // this file, and inverting the rule in a scratch copy ("a member that
10
- // dispatches a child may let the child derive its own directory under the
11
- // shared partition") left every test in all five of that PR's diff-touched
12
- // files green — the defect #1150 exists to rule out has no pin anywhere.
13
- //
14
- // This mirrors dispatch-block-pins-prose.test.mjs's treatment of the
15
- // identical invariant in the fleet-implementer-<cell> body's child-dispatch block
16
- // (that file pins the *implementer's* own instance of this rule; this one
17
- // pins the two general statements of it that the implementer, fix-applier
18
- // and review-side members are all read against).
19
- //
20
- // THE CEILING: a phrase()-based presence pin over one paragraph each. A
21
- // carve-out sentence appended AFTER the pinned clause, or a rewording that
22
- // keeps every pinned word but drops the parent-writes/child-never-derives
23
- // relationship between them, is not caught here — see dispatch-block-golden-
24
- // prose.test.mjs for that stronger, whole-block mechanism; this file's job is
25
- // only to stop the clause from being deleted or inverted unnoticed, which is
26
- // the shape #1150 measured.
27
- import { test } from "node:test";
28
- import assert from "node:assert/strict";
29
- import { readFileSync } from "node:fs";
30
- import { join } from "node:path";
31
- import { between, phrase } from "./prose-pin.mjs";
32
-
33
- const REPO = join(import.meta.dirname, "..");
34
- const read = (...p) => readFileSync(join(REPO, ...p), "utf8");
35
- const RUN_TEAM = read("skills", "run-team", "SKILL.md");
36
- const ISOLATION = read("skills", "run-team", "references", "isolation.md");
37
-
38
- const SKILL_BULLET = () =>
39
- between(
40
- RUN_TEAM,
41
- "**Scratchpad paths need two levels",
42
- "**IDE/harness diagnostics attribute",
43
- "run-team/SKILL.md's scratchpad-paths bullet",
44
- );
45
-
46
- const SKILL_CLAUSE =
47
- "any member that dispatches a child writes an absolute directory under its own partition into that child's prompt, one per child and never shared, and a child never derives its own";
48
-
49
- test("run-team/SKILL.md's scratchpad-paths bullet pins the parent-writes, child-never-derives rule", () => {
50
- assert.match(
51
- SKILL_BULLET(),
52
- phrase(SKILL_CLAUSE),
53
- "the bullet no longer states that any member dispatching a child writes an absolute directory into that child's prompt, one per child and never shared, with the child never deriving its own — the exact rule #1150 exists to establish, and inverting it left the diff-touched suite green before this pin existed",
54
- );
55
- });
56
-
57
- const ISOLATION_PARAGRAPH = () =>
58
- between(
59
- ISOLATION,
60
- "The axis is two-sided",
61
- "## IDE/harness diagnostics attribute",
62
- "references/isolation.md's two-sided-axis paragraph",
63
- );
64
-
65
- const ISOLATION_CLAUSE =
66
- "every agent it dispatches gets a directory under that one, unique to that child and never shared, written into the child's prompt as an absolute path; a child never derives its own";
67
-
68
- test("references/isolation.md's two-sided-axis paragraph pins the same parent-writes, child-never-derives rule", () => {
69
- assert.match(
70
- ISOLATION_PARAGRAPH(),
71
- phrase(ISOLATION_CLAUSE),
72
- "the paragraph no longer states that every dispatched agent gets a directory under its parent's own, unique and never shared, written in as an absolute path with the child never deriving its own — isolation.md's statement of the same #1150 rule SKILL.md's bullet carries",
73
- );
74
- });
@@ -1,73 +0,0 @@
1
- // #1378. Documentation and test-file headers across this repo cited the test
2
- // suite as living at `scripts/<file>` — a path that does not exist. The real
3
- // suite root is `plugin/scripts/`. 32 tracked files carried the stale form
4
- // before this ticket corrected every one: 27 test-file header comments
5
- // citing themselves, 2 comments in non-test source files (`repo-root.mjs`
6
- // citing its sibling `repo-root.test.mjs`, `strip-comments.mjs` inside an
7
- // example string) rather than a test file citing itself, one prose citation
8
- // in `references/reaping.md`, and the load-bearing pair in
9
- // `commands/review-and-fix.md` and `skills/run-team/SKILL.md` that hand the
10
- // command to a dispatched agent as an instruction, not a comment. This file
11
- // is what keeps the stale form from creeping back in one file at a time,
12
- // the way it crept in 32 times before anyone swept for it.
13
- //
14
- // A DIFFERENT citation class from #516's own sweep
15
- // (citation-sweep-prose.test.mjs, `path.ext:NNN` line numbers) and does not
16
- // reach it: that file polices a fixed per-file table of stale/live pairs,
17
- // this one asks git what ships and reads every one of them, because
18
- // enumerating by hand is the shape that let this exact defect recur 32 times
19
- // silently.
20
- //
21
- // Composed, never written contiguously: the two fragments the check joins
22
- // below only spell the stale citation once concatenated, so this file's own
23
- // source — itself tracked under `plugin/` — cannot satisfy the check it
24
- // performs. A plain string literal holding the whole stale form would report
25
- // this file as its own first offender the moment it landed under `plugin/`.
26
- //
27
- // repo-root.mjs's `trackedPaths`, not a directory walk: an untracked scratch
28
- // file must never become a false positive, and a tracked file that moves out
29
- // of `plugin/` must fall out of the sweep with it — same premise `repo-root.mjs`
30
- // states for the sibling `*-sweep.test.mjs` files in this directory.
31
- //
32
- // KNOWN LIMIT, same as those siblings: needs an ambient `.git` to ask what
33
- // ships. Absent one — a bare `git archive` extraction, how review specialists
34
- // used to measure this very suite (#1056; the review snapshot carries a `.git`
35
- // since then) — the tests below DECLINE with a reason rather than running;
36
- // nothing here polices a tree it cannot see.
37
- //
38
- // Zero deps: `node --test plugin/scripts/scripts-path-citation-sweep.test.mjs`.
39
-
40
- import { test } from "node:test";
41
- import assert from "node:assert/strict";
42
- import { readFileSync } from "node:fs";
43
- import { join } from "node:path";
44
- import { fileURLToPath } from "node:url";
45
- import { repoRoot, skipWithoutRepo, trackedPaths } from "./repo-root.mjs";
46
-
47
- const DIR = fileURLToPath(new URL(".", import.meta.url));
48
- const ROOT = repoRoot(DIR);
49
- const SKIP_WITHOUT_REPO = skipWithoutRepo(ROOT, "the sweep for the nonexistent scripts/ citation");
50
-
51
- // Never written as one literal — see the header's "composed" note.
52
- const STALE_CITATION = ["node --test", " scripts/"].join("");
53
-
54
- /** Every tracked path under `plugin/`, repo-relative — what actually ships. */
55
- const FILES = ROOT === null ? [] : trackedPaths(ROOT, ["plugin"]);
56
-
57
- test("the sweep sees the tree it is supposed to police", { skip: SKIP_WITHOUT_REPO }, () => {
58
- assert.ok(
59
- FILES.length > 150,
60
- `trackedPaths(ROOT, ["plugin"]) returned only ${FILES.length} entries — too few to be this plugin's real tree, and the check below would pass vacuously over an empty or near-empty list`,
61
- );
62
- });
63
-
64
- test("no tracked file under plugin/ cites the nonexistent scripts/ suite root", { skip: SKIP_WITHOUT_REPO }, () => {
65
- const offenders = FILES.filter((relPath) =>
66
- readFileSync(join(ROOT, relPath), "utf8").includes(STALE_CITATION),
67
- );
68
- assert.deepEqual(
69
- offenders,
70
- [],
71
- `these files cite a bare "scripts/" test path that does not exist — the suite root is "plugin/scripts/": ${offenders.join(", ")}`,
72
- );
73
- });