@feigi/fleet-ctl 0.0.0 → 3.16.3
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.
- package/agents/{fleet-implementer.agent.md → fleet-implementer-slow-high.agent.md} +23 -2
- package/agents/fleet-implementer-slow-medium.agent.md +231 -0
- package/agents/fleet-implementer-smol-high.agent.md +231 -0
- package/agents/{fleet-implementer-alt.agent.md → fleet-implementer-task-high.agent.md} +23 -2
- package/agents/fleet-implementer-task-max.agent.md +231 -0
- package/agents/fleet-review-comments.agent.md +4 -2
- package/agents/fleet-review-correctness.agent.md +2 -1
- package/agents/fleet-review-runner.agent.md +14 -10
- package/agents/fleet-review-silent-failure.agent.md +4 -3
- package/agents/fleet-review-simplify.agent.md +2 -1
- package/agents/fleet-review-snapshot.agent.md +2 -1
- package/agents/fleet-review-test-run.agent.md +29 -0
- package/agents/fleet-review-tests.agent.md +10 -5
- package/agents/fleet-review-types.agent.md +4 -2
- package/agents/fleet-review-verifier.agent.md +4 -3
- package/commands/review-and-fix.md +7 -6
- package/commands/run-merge-bot.md +14 -4
- package/package.json +4 -2
- package/scripts/agent-test.test.mjs +36 -32
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +23 -13
- package/scripts/apply-ruleset.test.mjs +4 -3
- package/scripts/arg-header-probes-prose.test.mjs +1 -0
- package/scripts/arg.test.mjs +18 -18
- package/scripts/board-cli.test.mjs +18 -21
- package/scripts/board-identity.test.mjs +9 -9
- package/scripts/board-liveness-banner.test.mjs +6 -6
- package/scripts/board-prev-shape.test.mjs +12 -13
- package/scripts/board-tryparse-null.test.mjs +7 -7
- package/scripts/board.mjs +4 -7
- package/scripts/board.test.mjs +57 -61
- package/scripts/candidates.test.mjs +228 -17
- package/scripts/ci-completes-premise-prose.test.mjs +1 -1
- package/scripts/ci-state-prose.test.mjs +2 -2
- package/scripts/ci-state.mjs +389 -187
- package/scripts/ci-state.test.mjs +458 -165
- package/scripts/citation-sweep-prose.test.mjs +59 -1
- package/scripts/claim-lifecycle.test.mjs +2 -1
- package/scripts/claim-ticket.test.mjs +35 -34
- package/scripts/closing-keyword-prose.test.mjs +1 -1
- package/scripts/cockpit-tick-nonblocking.test.mjs +8 -8
- package/scripts/compute-board.mjs +13 -3
- package/scripts/compute-board.test.mjs +64 -1
- package/scripts/compute-spend.mjs +46 -8
- package/scripts/compute-spend.test.mjs +64 -10
- package/scripts/cross-repo-citation-prose.test.mjs +18 -19
- package/scripts/delete-merged-branch.sh +218 -0
- package/scripts/delete-merged-branch.test.mjs +576 -0
- package/scripts/derive-testcmd.sh +18 -7
- package/scripts/derive-testcmd.test.mjs +9 -8
- package/scripts/diff-stats.mjs +2 -2
- package/scripts/diff-stats.test.mjs +7 -11
- package/scripts/dispatch-block-golden-prose.test.mjs +111 -6
- package/scripts/dispatch-block-pins-prose.test.mjs +5 -5
- package/scripts/dispositions-check.mjs +507 -0
- package/scripts/dispositions-check.test.mjs +843 -0
- package/scripts/dispositions-gate-prose.test.mjs +114 -0
- package/scripts/drop-merged-label.test.mjs +3 -4
- package/scripts/exec-stub.mjs +93 -0
- package/scripts/exec-stub.test.mjs +69 -0
- package/scripts/filing-bar-seat-prose.test.mjs +1 -1
- package/scripts/finisher-test-verdict-prose.test.mjs +102 -0
- package/scripts/fix-applier-correction-rules-prose.test.mjs +11 -10
- package/scripts/fleet-bootstrap +5 -20
- package/scripts/fleet-bootstrap.test.mjs +75 -0
- package/scripts/fleet-heartbeat.mjs +2 -2
- package/scripts/fleet-provenance +15 -24
- package/scripts/fleet-provenance.test.mjs +86 -12
- package/scripts/fleet-run.test.mjs +5 -5
- package/scripts/fleet-state.mjs +33 -11
- package/scripts/fleet-state.test.mjs +90 -3
- package/scripts/fleet-tick.mjs +346 -70
- package/scripts/fleet-tick.test.mjs +566 -16
- package/scripts/force-with-lease-reason-prose.test.mjs +1 -1
- package/scripts/frontmatter-check.mjs +3 -2
- package/scripts/frontmatter-check.test.mjs +6 -6
- package/scripts/immutable-body-claim-prose.test.mjs +53 -262
- package/scripts/implementer-model-tier.test.mjs +98 -506
- package/scripts/inflight.test.mjs +18 -127
- package/scripts/is-cli.mjs +26 -0
- package/scripts/is-cli.test.mjs +99 -0
- package/scripts/json.test.mjs +3 -3
- package/scripts/ledger-dispatch.test.mjs +368 -7
- package/scripts/ledger-grammar.mjs +85 -1
- package/scripts/ledger-grammar.test.mjs +86 -1
- package/scripts/ledger-read-require-file.test.mjs +7 -7
- package/scripts/ledger-rotate.test.mjs +142 -0
- package/scripts/ledger.mjs +181 -17
- package/scripts/ledger.test.mjs +12 -130
- package/scripts/main-checkout.mjs +312 -0
- package/scripts/main-checkout.test.mjs +332 -0
- package/scripts/member-outcomes-header.test.mjs +3 -3
- package/scripts/member-outcomes.mjs +4 -5
- package/scripts/member-outcomes.test.mjs +92 -18
- package/scripts/member-prompt-prose.test.mjs +17 -13
- package/scripts/member-record.mjs +8 -3
- package/scripts/member-record.test.mjs +5 -5
- package/scripts/member-write-guard.mjs +5 -5
- package/scripts/member-write-guard.test.mjs +6 -3
- package/scripts/no-undo-audit.sh +24 -21
- package/scripts/no-undo-audit.test.mjs +9 -13
- package/scripts/pointer-target-prose.test.mjs +1 -1
- package/scripts/pr-overlap.test.mjs +6 -9
- package/scripts/prompt-renderer.mjs +10 -9
- package/scripts/prose-pin.mjs +10 -11
- package/scripts/prove-merge.test.mjs +3 -3
- package/scripts/quiet-payload-prose.test.mjs +1 -1
- package/scripts/reap.test.mjs +3 -4
- package/scripts/release-label-split-prose.test.mjs +17 -2
- package/scripts/release-ticket.test.mjs +35 -44
- package/scripts/review-core-cwd-isolation.test.mjs +7 -6
- package/scripts/review-core-reads.test.mjs +1 -1
- package/scripts/review-core-scratch-refusal.test.mjs +64 -0
- package/scripts/review-core-shared-test-run.test.mjs +238 -0
- package/scripts/review-core-snapshot-path.test.mjs +59 -12
- package/scripts/review-core-specialist-scratch.test.mjs +12 -10
- package/scripts/review-core-testcmd.test.mjs +76 -45
- package/scripts/review-core-unrun.test.mjs +154 -168
- package/scripts/review-core.mjs +250 -56
- package/scripts/review-eval.mjs +11 -4
- package/scripts/review-host-fixture.mjs +12 -3
- package/scripts/review-in-run-retry.test.mjs +27 -3
- package/scripts/review-runner-spawns.test.mjs +5 -3
- package/scripts/review-runner.test.mjs +14 -3
- package/scripts/review-tier-audit.test.mjs +1 -1
- package/scripts/run-merge-bot-prose.test.mjs +29 -6
- package/scripts/scratch-partition-invariant-prose.test.mjs +1 -1
- package/scripts/section-between-guard-prose.test.mjs +4 -3
- package/scripts/select-dimensions.test.mjs +1 -1
- package/scripts/shell-traps-prose.test.mjs +6 -9
- package/scripts/shortlist.mjs +4 -1
- package/scripts/shortlist.test.mjs +30 -16
- package/scripts/snapshot-repo.test.mjs +177 -4
- package/scripts/stash-prohibition-prose.test.mjs +1 -1
- package/scripts/temp-dir.mjs +47 -0
- package/scripts/tier-check.mjs +95 -28
- package/scripts/tier-check.test.mjs +131 -29
- package/scripts/tier-outcomes-header.test.mjs +11 -54
- package/scripts/tier-outcomes.mjs +34 -12
- package/scripts/tier-outcomes.test.mjs +157 -4
- package/scripts/tier-roles.mjs +118 -29
- package/scripts/tier-roles.test.mjs +226 -61
- package/scripts/tracker-block-copy-prose.test.mjs +3 -3
- package/scripts/verify-sha.test.mjs +4 -5
- package/scripts/watcher-degraded-block.test.mjs +5 -8
- package/scripts/within-run-pair-prose.test.mjs +43 -75
- package/scripts/worktree-audit.test.mjs +2 -1
- package/skills/next-ticket/SKILL.md +2 -2
- package/skills/run-team/SKILL.md +433 -303
- package/skills/run-team/references/ci-and-staleness.md +7 -6
- package/skills/run-team/references/correction-tickets.md +3 -3
- package/skills/run-team/references/isolation.md +1 -1
- package/skills/sizing-a-ticket/SKILL.md +8 -8
- package/scripts/tier-guard-gate-prose.test.mjs +0 -216
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
// `agent()`/`phase()`/`log()` prelude globals and cannot run under node.
|
|
18
18
|
import { test } from "node:test";
|
|
19
19
|
import assert from "node:assert/strict";
|
|
20
|
-
import { existsSync,
|
|
21
|
-
import {
|
|
20
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
21
|
+
import { tempDir } from "./temp-dir.mjs";
|
|
22
22
|
import { join } from "node:path";
|
|
23
23
|
import { runReviewToFile } from "./review-eval.mjs";
|
|
24
24
|
import { DIGEST_KEYS } from "./review-core.mjs";
|
|
@@ -38,7 +38,7 @@ const RESULT = {
|
|
|
38
38
|
unverified: [{ claim: "u1" }, { claim: "u2" }, { claim: "u3" }],
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
const scratch = () =>
|
|
41
|
+
const scratch = () => tempDir("review-runner-");
|
|
42
42
|
|
|
43
43
|
// A `run` that answers from a script, one entry per call; an `Error` entry is
|
|
44
44
|
// thrown. Counts calls so a test can say how many reviews it cost.
|
|
@@ -146,6 +146,17 @@ test("a scratch that is missing or relative is refused before any review runs",
|
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
+
// #2323. A scratch the controller already partitioned is a dispatch mistake,
|
|
150
|
+
// not a review failure: runReview would throw it, and without this the runner
|
|
151
|
+
// would retry it and name a fallback reviewer for a review that never ran.
|
|
152
|
+
test("a scratch already ending in pr<N> is refused before any review runs, not retried", async () => {
|
|
153
|
+
for (const bad of ["/x/pr7", "/x/pr7/", "/x/pr42"]) {
|
|
154
|
+
const { run, calls } = scriptedRun([RESULT]);
|
|
155
|
+
await assert.rejects(runReviewToFile({ pr: 7, scratch: bad, worktree: "/wt" }, run), /pass the scratch root/, bad);
|
|
156
|
+
assert.equal(calls.length, 0, `${bad}: a partitioned scratch reached the review`);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
149
160
|
test("a pr that is not a PR number is refused before any review runs", async () => {
|
|
150
161
|
for (const bad of [undefined, "my-branch", "7/../../x", -7]) {
|
|
151
162
|
const { run, calls } = scriptedRun([RESULT]);
|
|
@@ -25,7 +25,7 @@ const FILES = {
|
|
|
25
25
|
// FIRST `{` after the call's opening paren to its matching close. Comments
|
|
26
26
|
// stripped first so a commented-out `model:` cannot satisfy or defeat this —
|
|
27
27
|
// the same policy every other pin in this directory takes with `stripComments`
|
|
28
|
-
// (
|
|
28
|
+
// (strip-comments.mjs's header explains the measured reason).
|
|
29
29
|
function agentCallOptionBlocks(code) {
|
|
30
30
|
const blocks = [];
|
|
31
31
|
const callRe = /\bagent\(/g;
|
|
@@ -10,7 +10,7 @@ import { test } from "node:test";
|
|
|
10
10
|
import assert from "node:assert/strict";
|
|
11
11
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
12
12
|
import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
|
-
import {
|
|
13
|
+
import { tempDir } from "./temp-dir.mjs";
|
|
14
14
|
import { join } from "node:path";
|
|
15
15
|
import { between, paragraph, phrase } from "./prose-pin.mjs";
|
|
16
16
|
|
|
@@ -39,6 +39,23 @@ test("step 4 says a failed removal must be reported, never swallowed", () => {
|
|
|
39
39
|
assert.match(step4(), /a removal failed — report it as `label-drop-failed-#<issue>`, never swallow it/);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
// #2196: the bot deletes the merged head branch itself rather than leaning on
|
|
43
|
+
// the repo's auto-delete setting, and a branch left behind is a report, not a
|
|
44
|
+
// silence — reap.sh only ever reaps a `[gone]` branch.
|
|
45
|
+
test("step 4 deletes the head branch itself and reports a failed delete", () => {
|
|
46
|
+
assert.match(step4(), /delete-merged-branch\.sh <pr>/);
|
|
47
|
+
assert.match(step4(), /report it as `branch-delete-failed-#<pr>`, never swallow it/);
|
|
48
|
+
assert.doesNotMatch(step4(), /GitHub removes the remote branch anyway/);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// #2295: exit 3 is a deliberate keep — another open PR uses the branch — and
|
|
52
|
+
// step 4 must say so, or a bot reads it as one more failure to report or retry.
|
|
53
|
+
test("step 4 treats a kept branch as a keep, never a failure or a retry", () => {
|
|
54
|
+
assert.match(step4(), /\*\*Exit 3 the branch is kept on purpose — another open PR uses it as its head or its base\*\*/);
|
|
55
|
+
assert.match(step4(), /one `branch-kept-#<pr>` line per such PR/);
|
|
56
|
+
assert.match(step4(), /A deliberate keep, not a failure: never retry it, and never report it as `branch-delete-failed`/);
|
|
57
|
+
});
|
|
58
|
+
|
|
42
59
|
test("the drop runs only after the merge is confirmed, never before", () => {
|
|
43
60
|
assert.match(step4(), /call this only after the merge is confirmed/);
|
|
44
61
|
});
|
|
@@ -308,9 +325,9 @@ test("step 1 names the correct upstream for proving a post-rebase worktree stale
|
|
|
308
325
|
// separate rots follow from that, and each is pinned to its own contiguous
|
|
309
326
|
// string rather than to a word appearing somewhere in step 1.
|
|
310
327
|
//
|
|
311
|
-
// (a) The ORDERING must ride in the same sentence as the command.
|
|
312
|
-
// deletes the remote branch
|
|
313
|
-
// existing at the merge and a probe run afterwards dies on a missing ref —
|
|
328
|
+
// (a) The ORDERING must ride in the same sentence as the command. Step 4
|
|
329
|
+
// deletes the remote branch once the PR lands (#2196), so `origin/<branch>`
|
|
330
|
+
// stops existing at the merge and a probe run afterwards dies on a missing ref —
|
|
314
331
|
// which reads like the divergence it was meant to rule out. A constraint
|
|
315
332
|
// parked in a later paragraph is one a reader can reach the command without
|
|
316
333
|
// having read, so the assertion below spans command and constraint as one
|
|
@@ -321,7 +338,7 @@ test("step 1's staleness probe carries its ordering constraint in the same sente
|
|
|
321
338
|
/run `git cherry origin\/<branch> HEAD` from the worktree \*\*before the merge, never after\*\*/,
|
|
322
339
|
);
|
|
323
340
|
// the reason, without which the constraint is an unexplained rule
|
|
324
|
-
assert.match(step1(), /
|
|
341
|
+
assert.match(step1(), /step 4 deletes the remote branch once the PR lands/);
|
|
325
342
|
assert.match(step1(), /fails on a missing ref/);
|
|
326
343
|
});
|
|
327
344
|
|
|
@@ -999,7 +1016,7 @@ const STEP1_FIRE_SCRIPT = STEP1_STUBS + STEP1_FIRE[0].replaceAll("<pr>", "42");
|
|
|
999
1016
|
const step1PollScript = ({ rc, branch, pre }) =>
|
|
1000
1017
|
STEP1_STUBS + STEP1_POLL[0].replaceAll("<pr>", "42").replaceAll("<rc>", rc).replaceAll("<branch>", branch).replaceAll("<pre>", pre);
|
|
1001
1018
|
|
|
1002
|
-
const STEP1_DIR =
|
|
1019
|
+
const STEP1_DIR = tempDir("merge-bot-step1-");
|
|
1003
1020
|
|
|
1004
1021
|
const step1HasShell = (s) => {
|
|
1005
1022
|
try {
|
|
@@ -1215,6 +1232,12 @@ test("the report vocabulary includes rebase-fallback", () => {
|
|
|
1215
1232
|
assert.match(DOC, /^Report merged [^\n]*rebase-fallback-#X/m);
|
|
1216
1233
|
});
|
|
1217
1234
|
|
|
1235
|
+
// #2295: step 4 tells the bot to report each kept branch, so the token has to
|
|
1236
|
+
// be in the vocabulary the bot reports from. Bounded to the Report line, as above.
|
|
1237
|
+
test("the report vocabulary includes branch-kept", () => {
|
|
1238
|
+
assert.match(DOC, /^Report merged [^\n]*branch-kept-#X/m);
|
|
1239
|
+
});
|
|
1240
|
+
|
|
1218
1241
|
// #1806 (spec 2026-09-24 § 5, ADR 0012 Decision 3). Step 3 is ONE script run
|
|
1219
1242
|
// twice, and the merge rests on the second run: a conclusion can invert under
|
|
1220
1243
|
// a fixed run id and a CI wait sits between the two readings. Sliced to step 3
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// files green — the defect #1150 exists to rule out has no pin anywhere.
|
|
13
13
|
//
|
|
14
14
|
// This mirrors dispatch-block-pins-prose.test.mjs's treatment of the
|
|
15
|
-
// identical invariant in fleet-implementer
|
|
15
|
+
// identical invariant in the fleet-implementer-<cell> body's child-dispatch block
|
|
16
16
|
// (that file pins the *implementer's* own instance of this rule; this one
|
|
17
17
|
// pins the two general statements of it that the implementer, fix-applier
|
|
18
18
|
// and review-side members are all read against).
|
|
@@ -48,15 +48,16 @@
|
|
|
48
48
|
// and the function does something (`endsFile`'s EOF tolerance) `between()`
|
|
49
49
|
// cannot.
|
|
50
50
|
//
|
|
51
|
-
// finisher-pin-race-prose.test.mjs's `fallbackSection()` and
|
|
52
|
-
// review-pr-citation-prose.test.mjs
|
|
51
|
+
// finisher-pin-race-prose.test.mjs's `fallbackSection()` and the `specialists()`
|
|
52
|
+
// in `ed9f2967^:plugin/scripts/review-pr-citation-prose.test.mjs` looked like
|
|
53
|
+
// two more —
|
|
53
54
|
// a search from `at` instead of `at + start.length`, and a literal-anchor
|
|
54
55
|
// call this detector cannot even see, respectively — but a before/after
|
|
55
56
|
// byte comparison against their real inputs (RUN_TEAM / REVIEW_AND_FIX)
|
|
56
57
|
// proved both output-identical to `between()`: neither pair's end anchor
|
|
57
58
|
// ever occurs inside its own start anchor's text, so the narrower contract
|
|
58
59
|
// `fallbackSection()`'s own header once claimed never actually diverges.
|
|
59
|
-
// Both
|
|
60
|
+
// Both became `import { between }` call sites like every other consumer,
|
|
60
61
|
// not documented exceptions.
|
|
61
62
|
//
|
|
62
63
|
// THE FLOOR: an empty or near-empty directory listing (a broken glob, or
|
|
@@ -541,7 +541,7 @@ test("runReview actually calls resolveDimensions, then selectDimensions, to pick
|
|
|
541
541
|
// The workflow cannot be imported to test this by execution: it runs a
|
|
542
542
|
// top-level `await pipeline(...)` and compiles as a function body (#538), so
|
|
543
543
|
// source position is the observable. Same shape as
|
|
544
|
-
// review-
|
|
544
|
+
// review-core-snapshot-path.test.mjs's guard-ordering pin.
|
|
545
545
|
test("an unresolvable override is refused before the snapshot agent is dispatched", () => {
|
|
546
546
|
const resolveAt = SOURCE.indexOf("const explicitDimensions = resolveDimensions(A.dimensions, DEFAULT_DIMENSIONS);");
|
|
547
547
|
const guardAt = SOURCE.indexOf('if (!pr || !worktree) throw new Error("review-pr: args.pr and args.worktree are required");');
|
|
@@ -26,23 +26,20 @@
|
|
|
26
26
|
import { test } from "node:test";
|
|
27
27
|
import assert from "node:assert/strict";
|
|
28
28
|
import { execFileSync } from "node:child_process";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
29
|
+
import { mkdirSync, writeFileSync, readFileSync } from "node:fs";
|
|
30
|
+
import { tempDir } from "./temp-dir.mjs";
|
|
31
31
|
import { join } from "node:path";
|
|
32
|
+
import { writeExecStub } from "./exec-stub.mjs";
|
|
32
33
|
|
|
33
34
|
const SKILLS = join(import.meta.dirname, "..", "skills");
|
|
34
35
|
const SKILL = readFileSync(join(SKILLS, "run-team", "SKILL.md"), "utf8");
|
|
35
36
|
const MERGE_BOT = readFileSync(join(import.meta.dirname, "..", "commands", "run-merge-bot.md"), "utf8");
|
|
36
37
|
|
|
37
|
-
const DIR =
|
|
38
|
+
const DIR = tempDir("shell-traps-");
|
|
38
39
|
const BIN = join(DIR, "bin");
|
|
39
40
|
mkdirSync(BIN);
|
|
40
41
|
|
|
41
|
-
const stub = (name, body) =>
|
|
42
|
-
const p = join(BIN, name);
|
|
43
|
-
writeFileSync(p, body);
|
|
44
|
-
chmodSync(p, 0o755);
|
|
45
|
-
};
|
|
42
|
+
const stub = (name, body) => writeExecStub(join(BIN, name), body);
|
|
46
43
|
|
|
47
44
|
const hasShell = (s) => {
|
|
48
45
|
try {
|
|
@@ -275,7 +272,7 @@ if [ "$n" -le 1 ]; then printf '849\\n850\\n'; else printf '849\\n850\\n852\\n';
|
|
|
275
272
|
stub("sleep", "#!/bin/sh\nexit 0\n");
|
|
276
273
|
|
|
277
274
|
const runMonitor = (shell, body, ticks = 2) => {
|
|
278
|
-
const calls =
|
|
275
|
+
const calls = tempDir("shell-traps-calls-");
|
|
279
276
|
const capped = body.replace(WATCH_LOOP, `tick=0\nwhile tick=$((tick+1)); [ "$tick" -le ${ticks} ]; do`);
|
|
280
277
|
return sh(shell, capped, { CALLS: calls });
|
|
281
278
|
};
|
package/scripts/shortlist.mjs
CHANGED
|
@@ -337,7 +337,10 @@ async function main() {
|
|
|
337
337
|
writeFileSync(tmp, `${JSON.stringify(payload)}\n`);
|
|
338
338
|
renameSync(tmp, file);
|
|
339
339
|
} catch (e) {
|
|
340
|
-
|
|
340
|
+
// Best-effort: when mkdirSync was the failure, tmp sits under a path
|
|
341
|
+
// component that is not a directory and this rmSync throws ENOTDIR, which
|
|
342
|
+
// would replace the real cause below with an "unexpected failure" stack.
|
|
343
|
+
try { rmSync(tmp, { force: true }); } catch {}
|
|
341
344
|
die(`cannot write ${file}: ${e.message}`);
|
|
342
345
|
}
|
|
343
346
|
log(`${NAME}: ${payload.shortlist.length} of ${payload.scanned} scanned → ${file}`);
|
|
@@ -30,21 +30,23 @@ import { test } from "node:test";
|
|
|
30
30
|
import assert from "node:assert/strict";
|
|
31
31
|
import { spawnSync } from "node:child_process";
|
|
32
32
|
import {
|
|
33
|
-
mkdtempSync, mkdirSync, writeFileSync, readFileSync, copyFileSync, chmodSync, existsSync, rmSync, realpathSync,
|
|
33
|
+
mkdtempSync, mkdirSync, writeFileSync, readFileSync, copyFileSync, chmodSync, existsSync, rmSync, realpathSync, readdirSync,
|
|
34
34
|
} from "node:fs";
|
|
35
35
|
import { tmpdir } from "node:os";
|
|
36
36
|
import { join } from "node:path";
|
|
37
37
|
import { fileURLToPath } from "node:url";
|
|
38
38
|
import { gitEnv } from "./git-env.mjs";
|
|
39
|
+
import { writeExecStub } from "./exec-stub.mjs";
|
|
39
40
|
|
|
40
41
|
const HERE = fileURLToPath(new URL(".", import.meta.url));
|
|
41
42
|
// Every file the copied shortlist.mjs reaches at run time: its own imports,
|
|
42
43
|
// and the two sibling scripts it spawns for real. A missing import is a
|
|
43
44
|
// MODULE_NOT_FOUND at startup, so add a row whenever any of these gains one.
|
|
44
|
-
const COPIED = ["shortlist.mjs", "candidates.mjs", "ledger.mjs", "ledger-grammar.mjs", "arg.mjs", "git-env.mjs"
|
|
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"];
|
|
45
48
|
|
|
46
49
|
const GH_STUB = `#!/bin/sh
|
|
47
|
-
case " $* " in *" --fleet-warm "*) exit 0 ;; esac
|
|
48
50
|
case "$1 $2" in
|
|
49
51
|
"issue list")
|
|
50
52
|
[ -n "$ISSUE_LIST_FAIL" ] && { echo "gh: HTTP 502" >&2; exit 1; }
|
|
@@ -130,19 +132,10 @@ function fixture(t) {
|
|
|
130
132
|
const bin = join(root, "bin");
|
|
131
133
|
mkdirSync(bin);
|
|
132
134
|
const gh = join(bin, "gh");
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
// outside the bound shortlist.mjs puts on each gh probe.
|
|
138
|
-
//
|
|
139
|
-
// 120 s, not 30 s: a warm-up killed mid-scan leaves the scan unpaid for the
|
|
140
|
-
// gh probe after it — PR #2224 measured 15-16 s first execs under load ~25,
|
|
141
|
-
// and a first exec killed at 500 ms still took 14.5-15.0 s next time (#2229).
|
|
142
|
-
// GH_STUB's `--fleet-warm` arm exits 0 before any other line, so no stub
|
|
143
|
-
// stall can hide in the longer bound; it only lets the scan finish, and stays
|
|
144
|
-
// finite so a truly hung exec still ends the case.
|
|
145
|
-
spawnSync(gh, ["--fleet-warm"], { timeout: 120_000 });
|
|
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);
|
|
146
139
|
const issuesFile = join(root, "issues.json");
|
|
147
140
|
const statesFile = join(root, "states.json");
|
|
148
141
|
const shortlistFile = join(repo, ".fleet", "shortlist.json");
|
|
@@ -364,3 +357,24 @@ test("a failed scan, an unreadable ledger or a stray argument refuses at exit 2
|
|
|
364
357
|
assert.match(unread.stderr, /shortlist: ledger\.mjs read exited 2/);
|
|
365
358
|
assert.equal(readFileSync(f.shortlistFile, "utf8"), before);
|
|
366
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
|
+
});
|
|
@@ -32,12 +32,13 @@
|
|
|
32
32
|
import { test } from "node:test";
|
|
33
33
|
import assert from "node:assert/strict";
|
|
34
34
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
35
|
-
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, utimesSync, writeFileSync } from "node:fs";
|
|
35
|
+
import { chmodSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, symlinkSync, utimesSync, writeFileSync } from "node:fs";
|
|
36
36
|
import { tmpdir } from "node:os";
|
|
37
37
|
import { dirname, join } from "node:path";
|
|
38
38
|
import { environmentNote } from "./review-core.mjs";
|
|
39
39
|
import { between, phrase } from "./prose-pin.mjs";
|
|
40
40
|
import { stripComments } from "./strip-comments.mjs";
|
|
41
|
+
import { writeExecStub } from "./exec-stub.mjs";
|
|
41
42
|
|
|
42
43
|
const REPO = join(import.meta.dirname, "..");
|
|
43
44
|
const SOURCES = [["scripts/review-core.mjs", join(REPO, "scripts", "review-core.mjs")]];
|
|
@@ -161,6 +162,59 @@ function pruneLine(path) {
|
|
|
161
162
|
const renderPrune = (path, runRootParent) =>
|
|
162
163
|
new Function("runRootParent", "return `" + pruneLine(path) + "`")(runRootParent);
|
|
163
164
|
|
|
165
|
+
/**
|
|
166
|
+
* A `run-` root under `parent` holding a `locked` directory with no permission
|
|
167
|
+
* bits at all, aged `days`. On darwin, optionally, the file inside it carries
|
|
168
|
+
* `uchg` (`immutableFile`), or `locked` itself does (`immutableDir`) — set
|
|
169
|
+
* after the mode, so the directory's mode cannot be changed back until the
|
|
170
|
+
* flag is gone. Aged last: creating children sets the root's mtime to now.
|
|
171
|
+
*/
|
|
172
|
+
function lockedRunRoot(parent, name, days, { immutableFile = false, immutableDir = false } = {}) {
|
|
173
|
+
const root = join(parent, name);
|
|
174
|
+
const locked = join(root, "locked");
|
|
175
|
+
mkdirSync(locked, { recursive: true });
|
|
176
|
+
writeFileSync(join(locked, "inner.txt"), "");
|
|
177
|
+
if (immutableFile) execFileSync("chflags", ["uchg", join(locked, "inner.txt")]);
|
|
178
|
+
chmodSync(locked, 0);
|
|
179
|
+
if (immutableDir) execFileSync("chflags", ["uchg", locked]);
|
|
180
|
+
const when = (Date.now() - days * DAY) / 1000;
|
|
181
|
+
utimesSync(root, when, when);
|
|
182
|
+
return root;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Undoes `lockedRunRoot` so the scratch teardown can remove what a prune left.
|
|
187
|
+
* The second `chmod` is for `immutableDir`: its mode is only changeable once
|
|
188
|
+
* `chflags` has cleared the flag.
|
|
189
|
+
*/
|
|
190
|
+
function unlock(parent) {
|
|
191
|
+
spawnSync("sh", ["-c", 'chmod -R u+rwx "$1"; if command -v chflags >/dev/null; then chflags -R nouchg "$1"; chmod -R u+rwx "$1"; fi; :', "sh", parent], { env: ENV });
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The snapshot block's whole first shell block — from the ambient-var clearing
|
|
196
|
+
* line down to the node_modules symlink, the prune and everything around it —
|
|
197
|
+
* rendered with the script's own `${runRootParent}`/`${runRootPrefix}`
|
|
198
|
+
* derivation lifted from the source, so a stray mutation anywhere in it runs
|
|
199
|
+
* here rather than only one on the lines `pruneLine` lifts.
|
|
200
|
+
*/
|
|
201
|
+
function snapshotBlock(path, scratchRoot, pr, worktree) {
|
|
202
|
+
const code = stripComments(readFileSync(path, "utf8"));
|
|
203
|
+
const derive = code.match(/^\s*const runRootParent = .+\n\s*const runRootPrefix = .+$/m);
|
|
204
|
+
assert.ok(derive, `${path} no longer derives \`runRootParent\` and \`runRootPrefix\` as adjacent statements — reshaped past what this test lifts`);
|
|
205
|
+
const { runRootParent, runRootPrefix } = new Function("scratch", "pr", `${derive[0]}\nreturn { runRootParent, runRootPrefix };`)(scratchRoot, pr);
|
|
206
|
+
const from = code.search(/^ *unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_TEMPLATE_DIR *$/m);
|
|
207
|
+
const to = code.search(/^ *if \[ -n "\$SNAP" \] && \[ -d \$\{worktree\}\/node_modules \]/m);
|
|
208
|
+
assert.ok(from !== -1 && to > from, `${path} no longer runs from the ambient-var clearing line down to the node_modules symlink — the block was reshaped past what this test lifts`);
|
|
209
|
+
const script = new Function("scratch", "runRootParent", "runRootPrefix", "worktree", "return `" + code.slice(from, code.indexOf("\n", to)) + "`")(
|
|
210
|
+
scratchRoot,
|
|
211
|
+
runRootParent,
|
|
212
|
+
runRootPrefix,
|
|
213
|
+
worktree,
|
|
214
|
+
);
|
|
215
|
+
return { runRootParent, script };
|
|
216
|
+
}
|
|
217
|
+
|
|
164
218
|
/**
|
|
165
219
|
* `cutLines`'s slice, prefixed with the block's own ambient-var clearing
|
|
166
220
|
* line — pulled from the source by its literal text rather than assumed, so
|
|
@@ -253,9 +307,7 @@ function remoteFixture(t, { branchRef = true, pullRef = true } = {}) {
|
|
|
253
307
|
function tracingGit(t) {
|
|
254
308
|
const dir = scratch(t, "snapshot-refs-bin-");
|
|
255
309
|
const log = join(dir, "calls.log");
|
|
256
|
-
|
|
257
|
-
mode: 0o755,
|
|
258
|
-
});
|
|
310
|
+
writeExecStub(join(dir, "git"), `#!/bin/sh\nprintf '%s\\n' "$*" >> ${JSON.stringify(log)}\nexec ${JSON.stringify(REAL_GIT)} "$@"\n`);
|
|
259
311
|
return {
|
|
260
312
|
dir,
|
|
261
313
|
reads: () => (existsSync(log) ? readFileSync(log, "utf8").split("\n").filter((l) => l.includes("ls-remote")) : []),
|
|
@@ -541,6 +593,127 @@ for (const [name, path] of SOURCES) {
|
|
|
541
593
|
);
|
|
542
594
|
});
|
|
543
595
|
|
|
596
|
+
// #2322. A fixture that drops its own read bit, or a darwin file carrying the
|
|
597
|
+
// user-immutable flag, made the plain `rm -rf` fail on that root — so it
|
|
598
|
+
// stayed forever and every later review of the PR printed
|
|
599
|
+
// SNAPSHOT_PRUNE_FAILED. The prune now restores owner rwx and clears `uchg`
|
|
600
|
+
// on the roots it SELECTED, then removes them.
|
|
601
|
+
test(`${name}: the prune removes an aged run root a chmod 000 directory used to wedge`, (t) => {
|
|
602
|
+
const parent = join(scratch(t, "snapshot-repo-prune-perm-"), "pr7");
|
|
603
|
+
const stale = lockedRunRoot(parent, "run-staleaa", 9);
|
|
604
|
+
try {
|
|
605
|
+
const r = spawnSync("sh", ["-c", renderPrune(path, parent)], { env: ENV, encoding: "utf8" });
|
|
606
|
+
|
|
607
|
+
assert.doesNotMatch(r.stdout ?? "", /SNAPSHOT_PRUNE_FAILED/, `the prune named a failure on a root it can normalise: ${r.stderr}`);
|
|
608
|
+
assert.equal(r.status, 0, `the prune exited non-zero: ${r.stderr}`);
|
|
609
|
+
assert.ok(!existsSync(stale), "an aged run root holding a chmod 000 directory survived the prune — it now stays forever and every later review prints SNAPSHOT_PRUNE_FAILED");
|
|
610
|
+
} finally {
|
|
611
|
+
unlock(parent);
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
// The other half: normalising is a mutation, and one applied before
|
|
616
|
+
// selection, or to the whole parent, would rewrite modes in trees a
|
|
617
|
+
// fix-applier still reads — pinned by mode rather than by existence. Run
|
|
618
|
+
// through the whole first shell block, not the prune line alone: a stray
|
|
619
|
+
// `chmod -R` on the parent on a line of its own never runs in a test that
|
|
620
|
+
// lifts only the prune. SNAPSHOT_TREE_MATCH is the control that the block
|
|
621
|
+
// ran to its end, past every line that could have done it.
|
|
622
|
+
test(`${name}: the snapshot block leaves the modes inside a run root younger than the cut-off alone`, (t) => {
|
|
623
|
+
const worktree = reviewedRepo(t);
|
|
624
|
+
const { runRootParent, script } = snapshotBlock(path, scratch(t, "snapshot-repo-block-"), 7, worktree);
|
|
625
|
+
const stale = lockedRunRoot(runRootParent, "run-staleaa", 9);
|
|
626
|
+
const recent = lockedRunRoot(runRootParent, "run-recentb", 5);
|
|
627
|
+
try {
|
|
628
|
+
const r = spawnSync("sh", ["-c", script], { env: ENV, encoding: "utf8" });
|
|
629
|
+
|
|
630
|
+
assert.match(r.stdout ?? "", /SNAPSHOT_TREE_MATCH/, `the block did not run to its end, so it measured nothing past the line it stopped on: ${r.stdout}${r.stderr}`);
|
|
631
|
+
assert.doesNotMatch(r.stdout ?? "", /SNAPSHOT_PRUNE_FAILED/, `the prune named a failure on a root it can normalise: ${r.stderr}`);
|
|
632
|
+
assert.ok(!existsSync(stale), "the aged run root survived the block, so its prune selected nothing and the young root's modes prove nothing");
|
|
633
|
+
assert.equal(
|
|
634
|
+
statSync(join(recent, "locked")).mode & 0o777,
|
|
635
|
+
0,
|
|
636
|
+
"the snapshot block changed a mode inside a run root younger than the cut-off — normalisation reached a tree the prune did not select",
|
|
637
|
+
);
|
|
638
|
+
} finally {
|
|
639
|
+
unlock(runRootParent);
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
test(`${name}: on darwin the prune removes an aged run root holding a uchg file inside a chmod 000 directory`, { skip: process.platform !== "darwin" && "chflags/uchg is darwin's" }, (t) => {
|
|
644
|
+
const parent = join(scratch(t, "snapshot-repo-prune-uchg-"), "pr7");
|
|
645
|
+
const stale = lockedRunRoot(parent, "run-staleaa", 9, { immutableFile: true });
|
|
646
|
+
try {
|
|
647
|
+
const r = spawnSync("sh", ["-c", renderPrune(path, parent)], { env: ENV, encoding: "utf8" });
|
|
648
|
+
|
|
649
|
+
assert.doesNotMatch(r.stdout ?? "", /SNAPSHOT_PRUNE_FAILED/, `the prune named a failure on a root it can normalise: ${r.stderr}`);
|
|
650
|
+
assert.ok(!existsSync(stale), "an aged run root holding a uchg file survived the prune — the immutable flag wedges `rm -rf` (EPERM) and the root stays forever");
|
|
651
|
+
} finally {
|
|
652
|
+
unlock(parent);
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
// The flag on the DIRECTORY rather than on a file in it: `chmod -R` cannot
|
|
657
|
+
// restore a `uchg` directory's mode, and `chflags -R` clears the flag but
|
|
658
|
+
// cannot read the `000` directory it just unflagged — so the mode is only
|
|
659
|
+
// restorable after the flag step, which is why the prune runs `chmod` again.
|
|
660
|
+
test(`${name}: on darwin the prune removes an aged run root holding a directory that is both uchg and chmod 000`, { skip: process.platform !== "darwin" && "chflags/uchg is darwin's" }, (t) => {
|
|
661
|
+
const parent = join(scratch(t, "snapshot-repo-prune-uchgdir-"), "pr7");
|
|
662
|
+
const stale = lockedRunRoot(parent, "run-staleaa", 9, { immutableDir: true });
|
|
663
|
+
try {
|
|
664
|
+
const r = spawnSync("sh", ["-c", renderPrune(path, parent)], { env: ENV, encoding: "utf8" });
|
|
665
|
+
|
|
666
|
+
assert.doesNotMatch(r.stdout ?? "", /SNAPSHOT_PRUNE_FAILED/, `the prune named a failure on a root it can normalise: ${r.stderr}`);
|
|
667
|
+
assert.ok(!existsSync(stale), "an aged run root holding a uchg, chmod 000 directory survived the prune — its mode was never restored after the flag was cleared, so `rm -rf` cannot read it");
|
|
668
|
+
} finally {
|
|
669
|
+
unlock(parent);
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
// The accept case on a host without `chflags`: the flag step is skipped, not
|
|
674
|
+
// treated as a failure, so the permission case still succeeds there.
|
|
675
|
+
test(`${name}: without chflags on PATH the prune still removes an aged run root holding a chmod 000 directory`, (t) => {
|
|
676
|
+
const parent = join(scratch(t, "snapshot-repo-prune-noflags-"), "pr7");
|
|
677
|
+
const stale = lockedRunRoot(parent, "run-staleaa", 9);
|
|
678
|
+
const bin = scratch(t, "snapshot-repo-prune-bin-");
|
|
679
|
+
for (const tool of ["sh", "find", "chmod", "rm"]) {
|
|
680
|
+
const real = execFileSync("sh", ["-c", `command -v ${tool}`], { env: ENV, encoding: "utf8" }).trim();
|
|
681
|
+
symlinkSync(real, join(bin, tool));
|
|
682
|
+
}
|
|
683
|
+
const env = { ...ENV, PATH: bin };
|
|
684
|
+
try {
|
|
685
|
+
const probe = spawnSync(join(bin, "sh"), ["-c", "command -v chflags"], { env, encoding: "utf8" });
|
|
686
|
+
assert.notEqual(probe.status, 0, "chflags is still reachable on the narrowed PATH, so this case measures nothing");
|
|
687
|
+
|
|
688
|
+
const r = spawnSync(join(bin, "sh"), ["-c", renderPrune(path, parent)], { env, encoding: "utf8" });
|
|
689
|
+
|
|
690
|
+
assert.doesNotMatch(r.stdout ?? "", /SNAPSHOT_PRUNE_FAILED/, `a host without chflags reported a prune failure: ${r.stderr}`);
|
|
691
|
+
assert.equal(r.status, 0, `the prune exited non-zero without chflags: ${r.stderr}`);
|
|
692
|
+
assert.ok(!existsSync(stale), "without chflags the prune left an aged run root holding a chmod 000 directory");
|
|
693
|
+
} finally {
|
|
694
|
+
unlock(parent);
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
// A removal normalisation cannot rescue still refuses by name, and the
|
|
699
|
+
// snapshot step goes on: a parent the prune cannot write is outside what it
|
|
700
|
+
// normalises, so `rm -rf` genuinely fails there.
|
|
701
|
+
test(`${name}: a removal that still fails prints SNAPSHOT_PRUNE_FAILED and the step continues`, { skip: process.getuid?.() === 0 && "root ignores the read-only parent" }, (t) => {
|
|
702
|
+
const parent = join(scratch(t, "snapshot-repo-prune-fail-"), "pr7");
|
|
703
|
+
const stale = lockedRunRoot(parent, "run-staleaa", 9);
|
|
704
|
+
chmodSync(parent, 0o555);
|
|
705
|
+
try {
|
|
706
|
+
const r = spawnSync("sh", ["-c", `${renderPrune(path, parent)}\necho AFTER_PRUNE`], { env: ENV, encoding: "utf8" });
|
|
707
|
+
|
|
708
|
+
assert.match(r.stdout ?? "", /SNAPSHOT_PRUNE_FAILED/, `a run root the prune could not remove went unreported: ${r.stdout}`);
|
|
709
|
+
assert.match(r.stdout ?? "", /AFTER_PRUNE/, "a failed prune stopped the snapshot step");
|
|
710
|
+
assert.equal(r.status, 0, `a failed prune ended the step non-zero: ${r.stderr}`);
|
|
711
|
+
assert.ok(existsSync(stale), "the fixture's run root was removed, so this case exercised no failure");
|
|
712
|
+
} finally {
|
|
713
|
+
unlock(parent);
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
|
|
544
717
|
// #1616. The ref-head operand, measured where it is PRODUCED rather than
|
|
545
718
|
// where it is consumed — the two guards that compare against it were never
|
|
546
719
|
// the defect, and this ticket changed neither. Six shapes, because the
|
|
@@ -101,7 +101,7 @@ const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf
|
|
|
101
101
|
// 2026-09-24 § 2 Decision 2): the body is what each harness injects as the
|
|
102
102
|
// member's system prompt, and SKILL.md's phase 2 no longer re-pastes it. The
|
|
103
103
|
// fix-applier's copy is still a quote block in SKILL.md's Reviewers section.
|
|
104
|
-
const IMPLEMENTER_BODY = readFileSync(join(REPO, "agents", "fleet-implementer.agent.md"), "utf8").split("---").slice(2).join("---");
|
|
104
|
+
const IMPLEMENTER_BODY = readFileSync(join(REPO, "agents", "fleet-implementer-slow-high.agent.md"), "utf8").split("---").slice(2).join("---");
|
|
105
105
|
|
|
106
106
|
// `>` gutter and `**` emphasis stripped, whitespace collapsed — mirrors
|
|
107
107
|
// `dispatch-block-pins-prose.test.mjs`'s `flatten`, so a pin here survives the
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Temp directories for test fixtures that are removed when the process exits.
|
|
2
|
+
//
|
|
3
|
+
// A fixture builder deep inside a helper often has no node:test context to
|
|
4
|
+
// hang a `t.after()` on, and a bare `mkdtempSync(join(tmpdir(), …))` there
|
|
5
|
+
// leaves its directory behind for good: across the suite that was hundreds of
|
|
6
|
+
// directories per run. Each one made here is recorded and removed at process
|
|
7
|
+
// exit instead — one process per test file under `node --test`, so the
|
|
8
|
+
// directories live exactly as long as the file that made them.
|
|
9
|
+
//
|
|
10
|
+
// Removal restores owner permissions first when a plain remove fails: a
|
|
11
|
+
// fixture that chmods a directory unsearchable and then fails before its own
|
|
12
|
+
// restore would otherwise make `rmSync` throw and the directory survive.
|
|
13
|
+
//
|
|
14
|
+
// Deliberately not a `.test.mjs`, so `node --test` never loads it as a suite.
|
|
15
|
+
|
|
16
|
+
import { spawnSync } from "node:child_process";
|
|
17
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
18
|
+
import { tmpdir } from "node:os";
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
|
|
21
|
+
const made = [];
|
|
22
|
+
|
|
23
|
+
function remove(dir) {
|
|
24
|
+
try {
|
|
25
|
+
rmSync(dir, { recursive: true, force: true });
|
|
26
|
+
} catch {
|
|
27
|
+
spawnSync("chmod", ["-R", "u+rwX", dir]);
|
|
28
|
+
try {
|
|
29
|
+
rmSync(dir, { recursive: true, force: true });
|
|
30
|
+
} catch (e) {
|
|
31
|
+
// An exception thrown from an exit handler would replace the run's own
|
|
32
|
+
// exit status, so a directory that still cannot go is reported instead.
|
|
33
|
+
process.stderr.write(`temp-dir: could not remove ${dir}: ${e.message}\n`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
process.on("exit", () => {
|
|
39
|
+
for (const dir of made) remove(dir);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/** `mkdtempSync(join(tmpdir(), prefix))`, removed when this process exits. */
|
|
43
|
+
export function tempDir(prefix) {
|
|
44
|
+
const dir = mkdtempSync(join(tmpdir(), prefix));
|
|
45
|
+
made.push(dir);
|
|
46
|
+
return dir;
|
|
47
|
+
}
|