@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,380 +0,0 @@
1
- // Regression gate for shortlist.mjs — the Shortlist as a script (ADR 0013 §1,
2
- // §3): candidates.mjs's oldest-first rows, minus open blockers, minus live
3
- // Exclusions, minus whatever inflight.sh reports taken or cannot answer,
4
- // written to `.fleet/shortlist.json` under the git common dir.
5
- //
6
- // What is real and what is stubbed, and why:
7
- //
8
- // - candidates.mjs and ledger.mjs are the REAL scripts, copied beside the
9
- // script under test. candidates.mjs is what orders the rows and extracts
10
- // `d` from a body, so a stub there would pin a sort and a dependency scan
11
- // this file never ran; ledger.mjs is the only writer of the `excluded ·`
12
- // rows the exclusion rule reads, so every row below is written by it
13
- // rather than hand-spelled in a format that could drift from the real one.
14
- // - `gh` is a PATH stub. `issue list` applies the jq expression gh was
15
- // handed to a fixture (the fleet-tick.test.mjs pattern), and answers `[]`
16
- // unless the search carries `label:"ready-for-agent"` — so every case that
17
- // expects rows back also proves the label was asked for. `issue view` and
18
- // `pr view` answer `{"state": …}` from a per-case state table, and fail the
19
- // way real gh does for a number or branch the table does not name. It is
20
- // NOT env-blind: `issue view`/`pr view` ask `git rev-parse --git-common-dir`
21
- // of their own inherited env first, the way real gh's remote resolution
22
- // follows an ambient GIT_DIR too (#1811 review), and answer from a SECOND
23
- // table when that resolves to a decoy repository — so a probe call that
24
- // forgot to scrub GIT_DIR/GIT_WORK_TREE answers for the wrong one here
25
- // exactly as it would for the real gh.
26
- // - inflight.sh is a stub, because the real one needs a remote, a PR list and
27
- // python3 to say anything; its own suite is inflight.test.mjs. The stub
28
- // keeps the real exit contract: 0 free, 1 taken, 2 could not answer.
29
- import { test } from "node:test";
30
- import assert from "node:assert/strict";
31
- import { spawnSync } from "node:child_process";
32
- import {
33
- mkdtempSync, mkdirSync, writeFileSync, readFileSync, copyFileSync, chmodSync, existsSync, rmSync, realpathSync, readdirSync,
34
- } from "node:fs";
35
- import { tmpdir } from "node:os";
36
- import { join } from "node:path";
37
- import { fileURLToPath } from "node:url";
38
- import { gitEnv } from "./git-env.mjs";
39
- import { writeExecStub } from "./exec-stub.mjs";
40
-
41
- const HERE = fileURLToPath(new URL(".", import.meta.url));
42
- // Every file the copied shortlist.mjs reaches at run time: its own imports,
43
- // and the two sibling scripts it spawns for real. A missing import is a
44
- // MODULE_NOT_FOUND at startup, so add a row whenever any of these gains one.
45
- const COPIED = ["shortlist.mjs", "candidates.mjs", "ledger.mjs", "ledger-grammar.mjs", "arg.mjs", "git-env.mjs", "is-cli.mjs",
46
- // ledger.mjs reads a fix-applier's conflict hold off fleet-tick.mjs's deriveRun (#2299).
47
- "fleet-tick.mjs", "fleet-state.mjs", "main-checkout.mjs"];
48
-
49
- const GH_STUB = `#!/bin/sh
50
- case "$1 $2" in
51
- "issue list")
52
- [ -n "$ISSUE_LIST_FAIL" ] && { echo "gh: HTTP 502" >&2; exit 1; }
53
- expr=""
54
- search=""
55
- while [ $# -gt 0 ]; do
56
- case "$1" in
57
- --jq) shift; expr="$1" ;;
58
- --search) shift; search="$1" ;;
59
- esac
60
- shift
61
- done
62
- case "$search" in
63
- *'label:"ready-for-agent"'*) exec jq -c "$expr" "$FIXTURE_ISSUES" ;;
64
- *) echo '[]' ;;
65
- esac ;;
66
- "issue view"|"pr view")
67
- # Real gh's own remote resolution follows an ambient GIT_DIR/GIT_WORK_TREE
68
- # exactly as git's does (#1811 review) — so this stub asks git too, with
69
- # the identical probe shortlistPath() uses, --git-common-dir (measured:
70
- # unlike --show-toplevel, it DOES follow GIT_DIR alone, no GIT_WORK_TREE
71
- # needed) — and answers from FIXTURE_OTHER_STATES instead of
72
- # FIXTURE_STATES whenever that resolves to FIXTURE_OTHER_GITDIR, the way
73
- # a genuinely unscrubbed gh call would silently answer for the wrong
74
- # repository.
75
- gitdir=$(git rev-parse --git-common-dir 2>/dev/null)
76
- if [ -n "$FIXTURE_OTHER_GITDIR" ] && [ "$gitdir" = "$FIXTURE_OTHER_GITDIR" ]; then
77
- states="$FIXTURE_OTHER_STATES"
78
- else
79
- states="$FIXTURE_STATES"
80
- fi
81
- state=$(jq -r --arg k "$1" --arg id "$3" '.[$k][$id] // ""' "$states")
82
- case "$state" in
83
- "") echo "GraphQL: Could not resolve to an issue or pull request with the number of $3." >&2; exit 1 ;;
84
- FAIL) echo "gh: HTTP 502 Bad Gateway" >&2; exit 1 ;;
85
- esac
86
- printf '{"state":"%s"}\\n' "$state" ;;
87
- *) echo "unexpected gh $*" >&2; exit 1 ;;
88
- esac
89
- `;
90
-
91
- const INFLIGHT_STUB = `#!/bin/sh
92
- for t in $INFLIGHT_SLOW; do [ "$t" = "$1" ] && sleep 1; done
93
- for t in $INFLIGHT_TAKEN; do
94
- [ "$t" = "$1" ] && { printf '{"issue":%s,"taken":true,"hits":["pr"],"unknown":[]}\\n' "$1"; exit 1; }
95
- done
96
- for t in $INFLIGHT_UNKNOWN; do
97
- [ "$t" = "$1" ] && { printf '{"issue":%s,"taken":false,"hits":[],"unknown":["gh pr list failed"]}\\n' "$1"; exit 2; }
98
- done
99
- printf '{"issue":%s,"taken":false,"hits":[],"unknown":[]}\\n' "$1"
100
- `;
101
-
102
- const git = (cwd, ...args) => {
103
- const r = spawnSync("git", args, { cwd, encoding: "utf8", env: gitEnv() });
104
- assert.equal(r.status, 0, `git ${args.join(" ")}: ${r.stderr}`);
105
- return r.stdout;
106
- };
107
-
108
- // `blockedBy` becomes a `## Blocked by` list in the body — the shape
109
- // to-tickets publishes — so the real candidates.mjs extracts `d` from it.
110
- const issue = (number, blockedBy = []) => ({
111
- number,
112
- title: `t${number}`,
113
- labels: [{ name: "ready-for-agent" }],
114
- body: blockedBy.length ? `## Blocked by\n\n${blockedBy.map((b) => `- #${b}`).join("\n")}\n` : "",
115
- });
116
-
117
- // One throwaway workspace: a git repository (the run's workspace), a
118
- // directory of scripts (shortlist.mjs and what it reaches), and a bin/ holding
119
- // the gh stub. realpath, because on macOS tmpdir() sits behind a symlink and
120
- // git answers --git-common-dir with the resolved path.
121
- function fixture(t) {
122
- const root = realpathSync(mkdtempSync(join(tmpdir(), "shortlist-")));
123
- t.after(() => rmSync(root, { recursive: true, force: true }));
124
- const repo = join(root, "repo");
125
- mkdirSync(repo);
126
- git(repo, "init", "-q");
127
- git(repo, "-c", "user.name=t", "-c", "user.email=t@t", "commit", "-q", "--allow-empty", "-m", "init");
128
- const scripts = join(root, "scripts");
129
- mkdirSync(scripts);
130
- for (const f of COPIED) copyFileSync(join(HERE, f), join(scripts, f));
131
- writeFileSync(join(scripts, "inflight.sh"), INFLIGHT_STUB);
132
- const bin = join(root, "bin");
133
- mkdirSync(bin);
134
- const gh = join(bin, "gh");
135
- // No warm-up exec: `writeExecStub` links the trampoline exec-stub.mjs already
136
- // exec'd at import, so the first gh probe pays no OS scan inside the bound
137
- // shortlist.mjs puts on it.
138
- writeExecStub(gh, GH_STUB);
139
- const issuesFile = join(root, "issues.json");
140
- const statesFile = join(root, "states.json");
141
- const shortlistFile = join(repo, ".fleet", "shortlist.json");
142
-
143
- return {
144
- root, repo, shortlistFile,
145
- run({ issues = [], states = {}, env = {}, cwd = repo, args = [] } = {}) {
146
- writeFileSync(issuesFile, JSON.stringify(issues));
147
- writeFileSync(statesFile, JSON.stringify({ issue: {}, pr: {}, ...states }));
148
- const r = spawnSync(process.execPath, [join(scripts, "shortlist.mjs"), ...args], {
149
- cwd, encoding: "utf8",
150
- env: {
151
- ...gitEnv(), PATH: `${bin}:${process.env.PATH}`,
152
- FIXTURE_ISSUES: issuesFile, FIXTURE_STATES: statesFile, ...env,
153
- },
154
- });
155
- return r;
156
- },
157
- // Written by the real ledger.mjs, into the real default ledger the
158
- // workspace resolves — the same file shortlist.mjs has to find.
159
- row(ticket, text) {
160
- const r = spawnSync(process.execPath, [join(scripts, "ledger.mjs"), "row", String(ticket), text], {
161
- cwd: repo, encoding: "utf8", env: gitEnv(),
162
- });
163
- assert.equal(r.status, 0, `ledger.mjs row ${ticket}: ${r.stderr}`);
164
- },
165
- written() {
166
- return JSON.parse(readFileSync(shortlistFile, "utf8"));
167
- },
168
- };
169
- }
170
-
171
- const numbers = (payload) => payload.shortlist.map((e) => e.n);
172
- const ok = (r) => assert.equal(r.status, 0, `exit ${r.status}\n${r.stderr}`);
173
-
174
- test("writes the oldest-first survivors and the scanned count to .fleet/shortlist.json", (t) => {
175
- const f = fixture(t);
176
- // #1730 is dropped (an unreadable blocker) so `scanned` and
177
- // `shortlist.length` diverge — otherwise a `scanned: survivors.length` bug
178
- // would still pass this test (#1811 review).
179
- const r = f.run({ issues: [issue(1720), issue(1701), issue(1710), issue(1730, [99])] });
180
- ok(r);
181
- assert.deepEqual(f.written(), {
182
- scanned: 4,
183
- shortlist: [{ n: 1701, t: "t1701" }, { n: 1710, t: "t1710" }, { n: 1720, t: "t1720" }],
184
- });
185
- // stdout is the same payload, plus where it was written.
186
- assert.deepEqual(JSON.parse(r.stdout), { file: f.shortlistFile, ...f.written() });
187
- });
188
-
189
- test("a linked worktree writes the workspace's one shortlist, not a copy of its own", (t) => {
190
- const f = fixture(t);
191
- const wt = join(f.repo, ".worktrees", "1701-x");
192
- git(f.repo, "worktree", "add", "-q", "-b", "x", wt);
193
- const r = f.run({ issues: [issue(1701)], cwd: wt });
194
- ok(r);
195
- assert.deepEqual(numbers(f.written()), [1701]);
196
- assert.equal(existsSync(join(wt, ".fleet", "shortlist.json")), false, "the worktree grew its own shortlist");
197
- });
198
-
199
- test("an ambient GIT_DIR naming another repository cannot move the shortlist there", (t) => {
200
- const f = fixture(t);
201
- const other = join(f.root, "other");
202
- mkdirSync(other);
203
- git(other, "init", "-q");
204
- const r = f.run({ issues: [issue(1701)], env: { GIT_DIR: join(other, ".git") } });
205
- ok(r);
206
- assert.deepEqual(numbers(f.written()), [1701]);
207
- assert.equal(existsSync(join(other, ".fleet")), false, "the shortlist followed GIT_DIR into another repository");
208
- });
209
-
210
- // Regression (#1811 review): probeState()'s own `gh … view` call must be
211
- // scrubbed exactly as shortlistPath()'s git call above is — gh's own remote
212
- // resolution follows an ambient GIT_DIR/GIT_WORK_TREE too (ledger.mjs's
213
- // tracker-query probe measured this first), so an unscrubbed probeState
214
- // could answer a blocker or exclusion-premise check from a DIFFERENT
215
- // repository while `.fleet/shortlist.json` still landed in the right one.
216
- test("an inherited GIT_DIR cannot retarget probeState's gh calls to another repository", (t) => {
217
- const f = fixture(t);
218
- const other = join(f.root, "other");
219
- mkdirSync(other);
220
- git(other, "init", "-q");
221
- const otherStates = join(f.root, "other-states.json");
222
- // In `other`, PR #60 reads MERGED — the opposite of `repo`'s OPEN — so a
223
- // gh call retargeted there would wrongly lift #1702's exclusion.
224
- writeFileSync(otherStates, JSON.stringify({ issue: {}, pr: { 60: "MERGED" } }));
225
- f.row(1702, "excluded · behind-pr:#60");
226
- const r = f.run({
227
- issues: [issue(1701), issue(1702)],
228
- states: { pr: { 60: "OPEN" } },
229
- env: { GIT_DIR: join(other, ".git"), FIXTURE_OTHER_GITDIR: join(other, ".git"), FIXTURE_OTHER_STATES: otherStates },
230
- });
231
- ok(r);
232
- assert.deepEqual(numbers(f.written()), [1701]);
233
- assert.match(r.stderr, /#1702 dropped — excluded · behind-pr:#60, which is OPEN/);
234
- });
235
-
236
- test("dependency scan: an open blocker drops the ticket; a closed or merged one does not", (t) => {
237
- const f = fixture(t);
238
- const r = f.run({
239
- issues: [
240
- issue(1701, [50]), // open issue
241
- issue(1702, [51]), // closed issue
242
- issue(1703, [52]), // merged PR — `gh issue view` answers a PR's state too
243
- issue(1704, [53]), // state unreadable
244
- issue(1705, [1707]), // blocked by another candidate, which is open by construction
245
- issue(1706, [1706]), // names itself: not a blocker
246
- issue(1707),
247
- ],
248
- states: { issue: { 50: "OPEN", 51: "CLOSED", 52: "MERGED", 53: "FAIL" } },
249
- });
250
- ok(r);
251
- assert.deepEqual(f.written(), {
252
- scanned: 7,
253
- shortlist: [1702, 1703, 1706, 1707].map((n) => ({ n, t: `t${n}` })),
254
- });
255
- assert.match(r.stderr, /#1701 dropped — open blocker #50\b/);
256
- assert.match(r.stderr, /#1704 dropped — blocker #53's state could not be read/);
257
- assert.match(r.stderr, /#1705 dropped — open blocker #1707\b/);
258
- });
259
-
260
- test("inflight.sh exit 1 (taken) and exit 2 (unanswered) drop the ticket; exit 2 is logged by number", (t) => {
261
- const f = fixture(t);
262
- const r = f.run({
263
- issues: [issue(1701), issue(1702), issue(1703), issue(1704), issue(1705)],
264
- // The probes run concurrently and 1701 and 1703 answer last, so verdicts
265
- // gathered in completion order rather than candidate order either hand
266
- // 1701's `taken` to a free ticket or put 1703 at the tail — both red.
267
- env: { INFLIGHT_TAKEN: "1701", INFLIGHT_UNKNOWN: "1702", INFLIGHT_SLOW: "1701 1703" },
268
- });
269
- ok(r);
270
- assert.deepEqual(numbers(f.written()), [1703, 1704, 1705]);
271
- assert.equal(f.written().scanned, 5);
272
- assert.match(r.stderr, /#1701 dropped — taken \(inflight\.sh exit 1/);
273
- assert.match(r.stderr, /#1702 dropped — in-flight check could not answer \(inflight\.sh exit 2\): gh pr list failed/);
274
- });
275
-
276
- test("a live exclusion drops the ticket, and it re-enters in its oldest-first slot once the premise closes", (t) => {
277
- const f = fixture(t);
278
- f.row(1702, "excluded · behind-pr:#60");
279
- f.row(1703, "excluded · behind-pr:#62");
280
- f.row(1704, "excluded · behind-issue:#61");
281
- const issues = [1701, 1702, 1703, 1704, 1705].map((n) => issue(n));
282
-
283
- const held = f.run({ issues, states: { pr: { 60: "OPEN", 62: "CLOSED" }, issue: { 61: "OPEN" } } });
284
- ok(held);
285
- // An abandoned (CLOSED, unmerged) PR lifts a behind-pr premise as surely
286
- // as a merge does, so #1703 is admitted from the start.
287
- assert.deepEqual(numbers(f.written()), [1701, 1703, 1705]);
288
- assert.equal(f.written().scanned, 5);
289
- assert.match(held.stderr, /#1702 dropped — excluded · behind-pr:#60, which is OPEN/);
290
- assert.match(held.stderr, /#1704 dropped — excluded · behind-issue:#61, which is OPEN/);
291
-
292
- const lifted = f.run({ issues, states: { pr: { 60: "MERGED", 62: "CLOSED" }, issue: { 61: "CLOSED" } } });
293
- ok(lifted);
294
- assert.deepEqual(numbers(f.written()), [1701, 1702, 1703, 1704, 1705]);
295
- assert.match(lifted.stderr, /#1702 lifted — behind-pr:#60 is MERGED/);
296
- assert.match(lifted.stderr, /#1704 lifted — behind-issue:#61 is CLOSED/);
297
- });
298
-
299
- // The other half of the exclusion rule: what it must ADMIT. Only a row whose
300
- // text opens with `excluded` is an exclusion, and a premise may name the
301
- // branch a PR is not yet open for (ADR 0013 §3), which gh resolves by name.
302
- test("only an `excluded` row excludes; a branch premise resolves through gh pr view; an unreadable premise stands", (t) => {
303
- const f = fixture(t);
304
- f.row(1701, "impl-1701 · class=routine");
305
- f.row(1702, "excluded · behind-pr:#implementer/1690-slug");
306
- f.row(1703, "excluded · behind-pr:#implementer/1691-slug");
307
- f.row(1704, "excluded · collides with something, no premise recorded");
308
- f.row(1705, "impl-1705 · previously excluded · behind-pr:#60");
309
- f.row(9999, "excluded · behind-pr:#60");
310
- const r = f.run({
311
- issues: [1701, 1702, 1703, 1704, 1705, 1706].map((n) => issue(n)),
312
- // No entry for implementer/1691-slug: gh answers "no pull requests found",
313
- // which is a premise nobody could read, not one that closed.
314
- states: { pr: { "implementer/1690-slug": "MERGED", 60: "OPEN" } },
315
- });
316
- ok(r);
317
- assert.deepEqual(numbers(f.written()), [1701, 1702, 1705, 1706]);
318
- assert.match(r.stderr, /#1702 lifted — behind-pr:#implementer\/1690-slug is MERGED/);
319
- assert.match(r.stderr, /#1703 dropped — excluded · behind-pr:#implementer\/1691-slug, whose state could not be read/);
320
- assert.match(r.stderr, /#1704 dropped — excluded with no behind-pr:\/behind-issue: premise/);
321
- });
322
-
323
- test("an empty queue is an answer: exit 0, and the file says so", (t) => {
324
- const f = fixture(t);
325
- mkdirSync(join(f.repo, ".fleet"));
326
- writeFileSync(f.shortlistFile, JSON.stringify({ scanned: 1, shortlist: [{ n: 1, t: "stale" }] }));
327
- const r = f.run({ issues: [] });
328
- ok(r);
329
- assert.deepEqual(f.written(), { scanned: 0, shortlist: [] });
330
- });
331
-
332
- // Every refusal leaves the previous file exactly as it was: an empty
333
- // shortlist written in its place would read as "no work" to the tick.
334
- test("a failed scan, an unreadable ledger or a stray argument refuses at exit 2 and leaves the file untouched", (t) => {
335
- const f = fixture(t);
336
- mkdirSync(join(f.repo, ".fleet"));
337
- const before = JSON.stringify({ scanned: 1, shortlist: [{ n: 1701, t: "t1701" }] });
338
- writeFileSync(f.shortlistFile, before);
339
- const issues = [issue(1701)];
340
-
341
- const scan = f.run({ issues, env: { ISSUE_LIST_FAIL: "1" } });
342
- assert.equal(scan.status, 2, scan.stderr);
343
- assert.match(scan.stderr, /shortlist: candidates\.mjs exited 2/);
344
- assert.equal(readFileSync(f.shortlistFile, "utf8"), before);
345
-
346
- const stray = f.run({ issues, args: ["--bogus"] });
347
- assert.equal(stray.status, 2, stray.stderr);
348
- assert.match(stray.stderr, /shortlist: takes no arguments, got --bogus/);
349
- assert.equal(readFileSync(f.shortlistFile, "utf8"), before);
350
-
351
- if (process.getuid?.() === 0) return t.skip("root reads a mode-000 file, so the ledger refusal cannot be staged");
352
- f.row(1701, "excluded · behind-pr:#60");
353
- const ledger = join(f.repo, ".fleet", "ledger.md");
354
- chmodSync(ledger, 0o000);
355
- const unread = f.run({ issues, states: { pr: { 60: "OPEN" } } });
356
- assert.equal(unread.status, 2, unread.stderr);
357
- assert.match(unread.stderr, /shortlist: ledger\.mjs read exited 2/);
358
- assert.equal(readFileSync(f.shortlistFile, "utf8"), before);
359
- });
360
-
361
- test("a shortlist directory that cannot be created is reported as the write failure, not an unexpected one", (t) => {
362
- const f = fixture(t);
363
- // A regular file where `.fleet/` belongs: mkdirSync fails, and the cleanup of
364
- // the temp file under it fails too (ENOTDIR) — the first error must survive.
365
- writeFileSync(join(f.repo, ".fleet"), "not a directory");
366
- const r = f.run({ issues: [issue(1701)] });
367
- assert.equal(r.status, 2, r.stderr);
368
- assert.match(r.stderr, /shortlist: cannot write .*shortlist\.json: /);
369
- assert.doesNotMatch(r.stderr, /unexpected failure/);
370
- });
371
-
372
- test("a rename that fails after the temp file is written removes the temp file", (t) => {
373
- const f = fixture(t);
374
- // A directory where shortlist.json belongs: mkdir and the write succeed, the rename fails.
375
- mkdirSync(f.shortlistFile, { recursive: true });
376
- const r = f.run({ issues: [issue(1701)] });
377
- assert.equal(r.status, 2, r.stderr);
378
- assert.match(r.stderr, /shortlist: cannot write .*shortlist\.json: /);
379
- assert.deepEqual(readdirSync(join(f.repo, ".fleet")).filter((n) => n.endsWith(".tmp")), []);
380
- });
@@ -1,72 +0,0 @@
1
- // The slow-but-working git transport that every bounded-fetch caller's
2
- // end-to-end pair is measured against (#346, #347, #1039).
3
- //
4
- // An ssh stub that sleeps and then serves a REAL bare repo through
5
- // `git upload-pack`, so refs genuinely come back: the accept path is exercised
6
- // against a working transport, not a mock of one. Paired with a budget under
7
- // the delay — and neither half is worth much alone, because an accept-only
8
- // case passes just as well against a watchdog that never fires, which is to
9
- // say against no watchdog at all.
10
- //
11
- // A module rather than a copy per suite. Each caller of net.sh asserts its OWN
12
- // stalled wording, so the wording is the part that cannot be shared and this
13
- // fixture is the part that can; two copies of the stub are how the copies come
14
- // to disagree about what "slow but working" means, the argument net.sh's own
15
- // header makes about restating net_stalled's signal set.
16
- //
17
- // Deliberately not a `.test.mjs`: `node --test plugin/scripts/*.test.mjs` does
18
- // not load it as a suite, and importing a test file to reach a fixture inside
19
- // it would register that file's own tests a second time in whichever suite
20
- // imported it.
21
-
22
- // No executable is written here, and that is the load-bearing part (#2221).
23
- // macOS scans a freshly written executable on its FIRST exec, and that scan is
24
- // a system-daemon latency with no bound under load — measured at 15.0-16.0s
25
- // per fresh file at load average ~25 on 14 cores, against 1.0s for the same
26
- // one-second script exec'd a second time, run as `sh <file>`, or run as
27
- // `sh -c` with no file at all. The stub used to be such a file, exec'd from
28
- // INSIDE the region each caller's budget bounds. #1099 moved that scan out
29
- // with a warm-up exec under a 10s timeout, but the scan outgrew the timeout
30
- // under load, and a first exec killed before it finishes leaves the scan
31
- // unpaid: the next exec of that file measured 14.5-15.0s again. So the
32
- // bounded call paid it anyway, and a ~6s transport crossed a 20s budget — the
33
- // two slow-but-working failures #2221 reports, from a full-suite run.
34
-
35
- // Seconds the stub sleeps before it serves anything. Module-internal on
36
- // purpose: no consumer computes a budget from it, so exporting it would only
37
- // create a second place for the number to be read from.
38
- const SLOW_DELAY_S = 3;
39
-
40
- /**
41
- * The ssh-shaped URL a fixture points `origin` at.
42
- *
43
- * `example.invalid` is never resolved: GIT_SSH_COMMAND replaces ssh outright.
44
- * The URL only has to be ssh-SHAPED, which is what routes git to it at all.
45
- */
46
- export const SSH_URL = "ssh://git@example.invalid/x/y.git";
47
-
48
- /**
49
- * A GIT_SSH_COMMAND value for an ssh stub that sleeps `SLOW_DELAY_S` before it
50
- * serves the bare repo at `origin` through `git upload-pack`.
51
- *
52
- * `SLOW_DELAY_S` (3s) is the sleep PER INVOCATION, not the cost a bounded
53
- * caller actually pays: git's ssh transport invokes this stub TWICE for
54
- * every network command routed through it — once with `-G` to resolve the
55
- * connection before it opens one, once for the real session — for a fetch
56
- * and an ls-remote alike (measured, git 2.50.1). So the region a caller's
57
- * budget bounds really costs ~2 × SLOW_DELAY_S (~6s measured), and that
58
- * doubled number, not the 3s constant alone, is what each caller's pair is
59
- * chosen against: one budget above it, one under.
60
- *
61
- * A command line rather than a script path, so the only programs it execs are
62
- * `sh`, `sleep` and `git`, none of them freshly written (see the header). git
63
- * runs the value through a shell and appends its own arguments — `-G`, the
64
- * host, the remote command, and whatever `-o` options the caller under test
65
- * adds — which land after `$0` and are ignored; `$0` is `origin`, single-
66
- * quote-escaped before interpolation so an origin containing `'` cannot
67
- * break out of the quoted argument.
68
- */
69
- export function slowTransport(origin) {
70
- const safeOrigin = origin.replace(/'/g, "'\\''");
71
- return `sh -c 'sleep ${SLOW_DELAY_S}; exec git upload-pack "$0"' '${safeOrigin}'`;
72
- }