@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.
- package/package.json +1 -1
- package/scripts/main-checkout.mjs +1 -1
- package/scripts/member-write-guard.mjs +1 -1
- package/scripts/repo-root.mjs +1 -1
- package/skills/run-team/references/reaping.md +1 -1
- package/scripts/agent-test-dir-prose.test.mjs +0 -59
- package/scripts/agent-test.test.mjs +0 -1640
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
- package/scripts/ambient-git-vars-prose.test.mjs +0 -192
- package/scripts/ancestry-check-position-prose.test.mjs +0 -175
- package/scripts/apply-ruleset.test.mjs +0 -421
- package/scripts/arg-header-probes-prose.test.mjs +0 -394
- package/scripts/arg.test.mjs +0 -1354
- package/scripts/board-cli.test.mjs +0 -710
- package/scripts/board-identity.test.mjs +0 -429
- package/scripts/board-liveness-banner.test.mjs +0 -119
- package/scripts/board-prev-shape.test.mjs +0 -228
- package/scripts/board-tryparse-null.test.mjs +0 -119
- package/scripts/board.test.mjs +0 -3121
- package/scripts/brief-after-cut-prose.test.mjs +0 -53
- package/scripts/candidates-exit3-prose.test.mjs +0 -302
- package/scripts/candidates.test.mjs +0 -2312
- package/scripts/caveat-unification-prose.test.mjs +0 -98
- package/scripts/cell-readout.test.mjs +0 -615
- package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
- package/scripts/ci-completes-premise-prose.test.mjs +0 -257
- package/scripts/ci-state-prose.test.mjs +0 -113
- package/scripts/ci-state.test.mjs +0 -1933
- package/scripts/ci-vacuous-green.test.mjs +0 -368
- package/scripts/citation-sweep-prose.test.mjs +0 -1712
- package/scripts/claim-lifecycle.test.mjs +0 -187
- package/scripts/claim-ticket.test.mjs +0 -1122
- package/scripts/closing-keyword-prose.test.mjs +0 -193
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
- package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
- package/scripts/compute-board.test.mjs +0 -1214
- package/scripts/compute-spend.test.mjs +0 -517
- package/scripts/consumer-technology-prose.test.mjs +0 -126
- package/scripts/cross-repo-citation-prose.test.mjs +0 -155
- package/scripts/cwd-isolation-pins.mjs +0 -83
- package/scripts/dedupe-guard-prose.test.mjs +0 -243
- package/scripts/delete-merged-branch.test.mjs +0 -576
- package/scripts/derive-testcmd.test.mjs +0 -595
- package/scripts/diff-stats.test.mjs +0 -404
- package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
- package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
- package/scripts/dispositions-check.test.mjs +0 -936
- package/scripts/dispositions-gate-prose.test.mjs +0 -129
- package/scripts/drop-merged-label.test.mjs +0 -479
- package/scripts/exec-stub.mjs +0 -93
- package/scripts/exec-stub.test.mjs +0 -69
- package/scripts/expected-jobs-prose.test.mjs +0 -80
- package/scripts/fan-out-authorization-prose.test.mjs +0 -80
- package/scripts/filing-bar-seat-prose.test.mjs +0 -242
- package/scripts/filing-claim-bar-prose.test.mjs +0 -166
- package/scripts/finisher-died-prose.test.mjs +0 -31
- package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
- package/scripts/finisher-halt-prose.test.mjs +0 -106
- package/scripts/finisher-name-prose.test.mjs +0 -134
- package/scripts/finisher-own-tree-prose.test.mjs +0 -299
- package/scripts/finisher-pin-race-prose.test.mjs +0 -339
- package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
- package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
- package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
- package/scripts/fleet-bootstrap.test.mjs +0 -75
- package/scripts/fleet-heartbeat.test.mjs +0 -450
- package/scripts/fleet-provenance.test.mjs +0 -138
- package/scripts/fleet-run.test.mjs +0 -90
- package/scripts/fleet-state.test.mjs +0 -460
- package/scripts/fleet-tick-prose.test.mjs +0 -300
- package/scripts/fleet-tick.test.mjs +0 -2444
- package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
- package/scripts/frontmatter-check.test.mjs +0 -436
- package/scripts/git-env.test.mjs +0 -149
- package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
- package/scripts/gone-walk.test.mjs +0 -213
- package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
- package/scripts/head-moved-after-label-prose.test.mjs +0 -233
- package/scripts/immutable-body-claim-prose.test.mjs +0 -204
- package/scripts/implementer-model-tier.test.mjs +0 -235
- package/scripts/inflight-citation-prose.test.mjs +0 -144
- package/scripts/inflight-exit2-prose.test.mjs +0 -81
- package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
- package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
- package/scripts/inflight.test.mjs +0 -2882
- package/scripts/injection-control-prose.test.mjs +0 -404
- package/scripts/install-root-audit.test.mjs +0 -464
- package/scripts/instrument-check-prose.test.mjs +0 -235
- package/scripts/instruments.test.mjs +0 -787
- package/scripts/is-cli.test.mjs +0 -99
- package/scripts/issue-tracker-prose.test.mjs +0 -71
- package/scripts/json.test.mjs +0 -364
- package/scripts/ledger-dispatch.test.mjs +0 -927
- package/scripts/ledger-grammar.test.mjs +0 -227
- package/scripts/ledger-read-require-file.test.mjs +0 -197
- package/scripts/ledger-rotate.test.mjs +0 -142
- package/scripts/ledger.test.mjs +0 -3436
- package/scripts/line-distance-prose.test.mjs +0 -245
- package/scripts/liveness-rationale-prose.test.mjs +0 -83
- package/scripts/locale-pin-prose.test.mjs +0 -189
- package/scripts/main-checkout.test.mjs +0 -332
- package/scripts/member-outcome-prose.test.mjs +0 -167
- package/scripts/member-outcomes-header.test.mjs +0 -129
- package/scripts/member-outcomes-prose.test.mjs +0 -63
- package/scripts/member-outcomes.test.mjs +0 -638
- package/scripts/member-prompt-prose.test.mjs +0 -165
- package/scripts/member-record.test.mjs +0 -541
- package/scripts/member-write-guard.test.mjs +0 -214
- package/scripts/merge-commit-probe-prose.test.mjs +0 -122
- package/scripts/merge-gate.test.mjs +0 -613
- package/scripts/muted-git-guard-sweep.test.mjs +0 -493
- package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
- package/scripts/net-watchdog-prose.test.mjs +0 -79
- package/scripts/net.test.mjs +0 -211
- package/scripts/no-ci-gate-prose.test.mjs +0 -108
- package/scripts/no-undo-audit.test.mjs +0 -3961
- package/scripts/no-wave.test.mjs +0 -138
- package/scripts/node-floor-sweep.test.mjs +0 -611
- package/scripts/pointer-target-prose.test.mjs +0 -186
- package/scripts/pr-cost.test.mjs +0 -521
- package/scripts/pr-overlap.test.mjs +0 -692
- package/scripts/printf-die-sweep.test.mjs +0 -384
- package/scripts/prompt-renderer.mjs +0 -40
- package/scripts/prompt-renderer.test.mjs +0 -68
- package/scripts/prose-pin.mjs +0 -807
- package/scripts/prose-pin.test.mjs +0 -1034
- package/scripts/prove-merge.test.mjs +0 -995
- package/scripts/pull-table-relabel-prose.test.mjs +0 -60
- package/scripts/quiet-payload-prose.test.mjs +0 -222
- package/scripts/reap-cherry-check-prose.test.mjs +0 -80
- package/scripts/reap.test.mjs +0 -4432
- package/scripts/reaping-prose.test.mjs +0 -239
- package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
- package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
- package/scripts/recipe-derivation-prose.test.mjs +0 -112
- package/scripts/recipe-prove.test.mjs +0 -1042
- package/scripts/refuter-scratch-prose.test.mjs +0 -135
- package/scripts/release-label-required-prose.test.mjs +0 -71
- package/scripts/release-label-split-prose.test.mjs +0 -184
- package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
- package/scripts/release-ticket.test.mjs +0 -5099
- package/scripts/renovate-release-contract.test.mjs +0 -379
- package/scripts/repo-root.test.mjs +0 -873
- package/scripts/reporter-output-rule-prose.test.mjs +0 -208
- package/scripts/review-agent-report-only.test.mjs +0 -49
- package/scripts/review-core-booking.test.mjs +0 -35
- package/scripts/review-core-cwd-isolation.test.mjs +0 -374
- package/scripts/review-core-reads.test.mjs +0 -478
- package/scripts/review-core-refuter-scratch.test.mjs +0 -148
- package/scripts/review-core-scratch-refusal.test.mjs +0 -64
- package/scripts/review-core-shared-test-run.test.mjs +0 -275
- package/scripts/review-core-snapshot-path.test.mjs +0 -830
- package/scripts/review-core-specialist-scratch.test.mjs +0 -191
- package/scripts/review-core-testcmd.test.mjs +0 -335
- package/scripts/review-core-unrun.test.mjs +0 -566
- package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
- package/scripts/review-eval-resolver-path.test.mjs +0 -55
- package/scripts/review-host-fixture.mjs +0 -89
- package/scripts/review-in-run-retry.test.mjs +0 -211
- package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
- package/scripts/review-path-default.test.mjs +0 -796
- package/scripts/review-runner-spawns.test.mjs +0 -95
- package/scripts/review-runner.test.mjs +0 -166
- package/scripts/review-tier-audit.test.mjs +0 -140
- package/scripts/run-artifact-pr-prose.test.mjs +0 -341
- package/scripts/run-merge-bot-prose.test.mjs +0 -1413
- package/scripts/run-team-local-hook.test.mjs +0 -442
- package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
- package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
- package/scripts/section-between-guard-prose.test.mjs +0 -379
- package/scripts/select-dimensions.test.mjs +0 -674
- package/scripts/shared-refusal.test.mjs +0 -388
- package/scripts/shell-traps-prose.test.mjs +0 -504
- package/scripts/shortlist.test.mjs +0 -380
- package/scripts/slow-transport.mjs +0 -72
- package/scripts/snapshot-repo.test.mjs +0 -1006
- package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
- package/scripts/spend-view.test.mjs +0 -312
- package/scripts/staleness-qualifier-prose.test.mjs +0 -251
- package/scripts/staleness-verdict-prose.test.mjs +0 -142
- package/scripts/staleness.test.mjs +0 -893
- package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
- package/scripts/stash-prohibition-prose.test.mjs +0 -313
- package/scripts/strip-comments.mjs +0 -44
- package/scripts/temp-dir.mjs +0 -47
- package/scripts/ticket-router.test.mjs +0 -981
- package/scripts/tier-check.test.mjs +0 -828
- package/scripts/tier-outcomes-header.test.mjs +0 -518
- package/scripts/tier-outcomes.test.mjs +0 -572
- package/scripts/tier-roles.test.mjs +0 -535
- package/scripts/tracker-block-copy-prose.test.mjs +0 -288
- package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
- package/scripts/unattended-git-sweep.test.mjs +0 -142
- package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
- package/scripts/verify-sha.test.mjs +0 -692
- package/scripts/watcher-degraded-block.test.mjs +0 -369
- package/scripts/watcher-key-prose.test.mjs +0 -106
- package/scripts/within-run-pair-prose.test.mjs +0 -212
- package/scripts/worktree-audit.test.mjs +0 -1408
- package/scripts/worktree-head-prose.test.mjs +0 -276
- package/scripts/worktree-listing-sweep.test.mjs +0 -217
- package/scripts/worktree-model-prose.test.mjs +0 -216
- package/scripts/worktree-porcelain.mjs +0 -35
- package/scripts/worktree-porcelain.test.mjs +0 -102
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
// Regression gate for #484: `echo` expands backslash escapes in its operand,
|
|
2
|
-
// so every fleet script that reported caller-supplied text through
|
|
3
|
-
// `die() { echo "$NAME: $1" >&2; … }` could truncate its own refusal.
|
|
4
|
-
//
|
|
5
|
-
// The mechanism, measured rather than inferred (dash on CI's ubuntu-latest and
|
|
6
|
-
// macOS `sh` both do this):
|
|
7
|
-
//
|
|
8
|
-
// $ sh -c 'a="x \cy"; echo "n: $a"' | od -c
|
|
9
|
-
// 0000000 n : x
|
|
10
|
-
//
|
|
11
|
-
// `\c` truncates the line AND swallows the newline, so the next stderr line
|
|
12
|
-
// collides with it. `\t \n \b \f \r \v \\ \0` mangle in their own ways.
|
|
13
|
-
//
|
|
14
|
-
// The trap this file exists to avoid: **unknown escapes like `\s` pass through
|
|
15
|
-
// unharmed.** A fixture spelled `back\slash` exercises the safe member of the
|
|
16
|
-
// class, reads as coverage, and catches nothing — `no-undo-audit.test.mjs` had
|
|
17
|
-
// exactly such a fixture and was blind to five live defects (#480). Every
|
|
18
|
-
// fixture below therefore uses `\c`, the member that actually truncates.
|
|
19
|
-
//
|
|
20
|
-
// Two directions are pinned, because a suite that only feeds valid input pins
|
|
21
|
-
// neither:
|
|
22
|
-
// - REJECT: a `\c` message must arrive verbatim (the bug).
|
|
23
|
-
// - ACCEPT: a `%`-carrying message must arrive verbatim too (the fix's own
|
|
24
|
-
// regression risk — `printf "$msg\n"` would eat it; `printf '%s\n' "$msg"`
|
|
25
|
-
// does not).
|
|
26
|
-
//
|
|
27
|
-
// Zero deps: `node --test plugin/scripts/printf-die-sweep.test.mjs`.
|
|
28
|
-
|
|
29
|
-
import { test } from "node:test";
|
|
30
|
-
import assert from "node:assert/strict";
|
|
31
|
-
import { execFileSync, spawnSync } from "node:child_process";
|
|
32
|
-
import { mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync, mkdirSync } from "node:fs";
|
|
33
|
-
import { tmpdir } from "node:os";
|
|
34
|
-
import { join } from "node:path";
|
|
35
|
-
import { fileURLToPath } from "node:url";
|
|
36
|
-
|
|
37
|
-
const DIR = fileURLToPath(new URL(".", import.meta.url));
|
|
38
|
-
|
|
39
|
-
// Pin identity and cut the developer's ~/.gitconfig out of the fixture, so a
|
|
40
|
-
// local `pull.rebase` or hook cannot change what these repos look like.
|
|
41
|
-
const ENV = {
|
|
42
|
-
...process.env,
|
|
43
|
-
GIT_DIR: undefined,
|
|
44
|
-
GIT_WORK_TREE: undefined,
|
|
45
|
-
GIT_TEMPLATE_DIR: undefined,
|
|
46
|
-
GIT_INDEX_FILE: undefined,
|
|
47
|
-
GIT_AUTHOR_NAME: "t",
|
|
48
|
-
GIT_AUTHOR_EMAIL: "t@example.com",
|
|
49
|
-
GIT_COMMITTER_NAME: "t",
|
|
50
|
-
GIT_COMMITTER_EMAIL: "t@example.com",
|
|
51
|
-
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
52
|
-
GIT_CONFIG_SYSTEM: "/dev/null",
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const git = (cwd, ...args) =>
|
|
56
|
-
execFileSync("git", args, { cwd, env: ENV, encoding: "utf8" }).trim();
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Bare origin + working clone with one commit on main. Returns the clone dir.
|
|
60
|
-
*
|
|
61
|
-
* realpath'd: on macOS `$TMPDIR` sits under the `/var` → `/private/var`
|
|
62
|
-
* symlink, and `git worktree list --porcelain` reports the RESOLVED path. An
|
|
63
|
-
* unresolved fixture path never matches what the scripts print, which reads as
|
|
64
|
-
* a truncation failure and hides whether the escaping is right.
|
|
65
|
-
*/
|
|
66
|
-
function repo(t) {
|
|
67
|
-
const root = realpathSync(mkdtempSync(join(tmpdir(), "printf-die-")));
|
|
68
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
69
|
-
const origin = join(root, "origin.git");
|
|
70
|
-
const work = join(root, "work");
|
|
71
|
-
execFileSync("git", ["init", "-q", "--bare", "-b", "main", origin], { env: ENV });
|
|
72
|
-
execFileSync("git", ["clone", "-q", origin, work], { env: ENV });
|
|
73
|
-
writeFileSync(join(work, "f.txt"), "x\n");
|
|
74
|
-
git(work, "add", "f.txt");
|
|
75
|
-
git(work, "commit", "-q", "-m", "init");
|
|
76
|
-
git(work, "push", "-q", "origin", "main");
|
|
77
|
-
return work;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const run = (cwd, script, args, extraEnv = {}) =>
|
|
81
|
-
spawnSync("sh", [join(DIR, script), ...args], {
|
|
82
|
-
cwd,
|
|
83
|
-
env: { ...ENV, ...extraEnv },
|
|
84
|
-
encoding: "utf8",
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// One reachable `die()` per script, chosen so the message interpolates text the
|
|
88
|
-
// CALLER supplied — the only text that can carry a backslash. `$NAME: ` is
|
|
89
|
-
// prefixed by `die` itself, so asserting the whole line also pins the prefix.
|
|
90
|
-
//
|
|
91
|
-
// `exit` codes are asserted because they are part of each script's contract and
|
|
92
|
-
// a `printf` substitution must not disturb them: eight scripts refuse at 2,
|
|
93
|
-
// `derive-testcmd.sh` at 1. The ticket does not mention that asymmetry.
|
|
94
|
-
const CASES = [
|
|
95
|
-
{
|
|
96
|
-
// The `\c` sits in the BRANCH slot, not the sha slot. Both reach `die()`,
|
|
97
|
-
// but only the branch reaches verify-sha.sh's fetch trace — the one line
|
|
98
|
-
// in these scripts where raw argv is printed before any git command has
|
|
99
|
-
// accepted it. With the escape in the sha slot the suite was green over
|
|
100
|
-
// that line: the sha is read after the fetch, so it can never get there.
|
|
101
|
-
// `trace` below is what pins it.
|
|
102
|
-
script: "verify-sha.sh",
|
|
103
|
-
args: ["back\\clue", "deadbee"],
|
|
104
|
-
exit: 2,
|
|
105
|
-
line: "verify-sha: cannot fetch origin/back\\clue",
|
|
106
|
-
trace: "$ git fetch --quiet origin back\\clue",
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
script: "drop-merged-label.sh",
|
|
110
|
-
args: ["back\\clue"],
|
|
111
|
-
exit: 2,
|
|
112
|
-
line: "drop-merged-label: pr must be a number, got 'back\\clue'",
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
script: "inflight.sh",
|
|
116
|
-
args: ["back\\clue"],
|
|
117
|
-
exit: 2,
|
|
118
|
-
line: "inflight: issue must be a number, got 'back\\clue'",
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
script: "claim-ticket.sh",
|
|
122
|
-
args: ["back\\clue", "slug", "fix"],
|
|
123
|
-
exit: 2,
|
|
124
|
-
line: "claim-ticket: issue must be a number, got 'back\\clue'",
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
script: "worktree-audit.sh",
|
|
128
|
-
args: [],
|
|
129
|
-
env: { BASE_REF: "origin/back\\clue" },
|
|
130
|
-
exit: 2,
|
|
131
|
-
line: "worktree-audit: origin/back\\clue does not resolve",
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
script: "release-ticket.sh",
|
|
135
|
-
args: ["back\\clue", "slug", "fix"],
|
|
136
|
-
exit: 2,
|
|
137
|
-
line: "release-ticket: issue must be a number, got 'back\\clue'",
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
script: "reap.sh",
|
|
141
|
-
args: [],
|
|
142
|
-
env: { BASE_REF: "origin/back\\clue" },
|
|
143
|
-
exit: 2,
|
|
144
|
-
line: "reap: origin/back\\clue does not resolve",
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
script: "prove-merge.sh",
|
|
148
|
-
args: ["back\\clue", "deadbee", "deadbee"],
|
|
149
|
-
exit: 2,
|
|
150
|
-
line: "prove-merge: cannot resolve back\\clue to a commit in this repository",
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
// The one script that refuses at 1, not 2.
|
|
154
|
-
script: "derive-testcmd.sh",
|
|
155
|
-
args: ["back\\clue-nope", "test"],
|
|
156
|
-
exit: 1,
|
|
157
|
-
line: "derive-testcmd: back\\clue-nope is not a git repository",
|
|
158
|
-
},
|
|
159
|
-
];
|
|
160
|
-
|
|
161
|
-
for (const c of CASES) {
|
|
162
|
-
test(`${c.script}: die() reports a \\c-carrying message verbatim`, (t) => {
|
|
163
|
-
const w = repo(t);
|
|
164
|
-
// The fixture is only useful if it really carries the escape that breaks.
|
|
165
|
-
// `\s` would pass through `echo` unharmed and pin nothing.
|
|
166
|
-
assert.ok(
|
|
167
|
-
c.line.includes("\\c"),
|
|
168
|
-
"fixture must carry a `\\c`, the escape that truncates — not an inert one",
|
|
169
|
-
);
|
|
170
|
-
const r = run(w, c.script, c.args, c.env);
|
|
171
|
-
assert.equal(
|
|
172
|
-
r.status,
|
|
173
|
-
c.exit,
|
|
174
|
-
`${c.script} must still refuse at ${c.exit}; got ${r.status}, stderr ${JSON.stringify(r.stderr)}`,
|
|
175
|
-
);
|
|
176
|
-
// Whole line, anchored, WITH its newline: `echo` drops both the tail and
|
|
177
|
-
// the trailing newline at the `\c`, so a substring match on the surviving
|
|
178
|
-
// head would pass against the very defect this pins.
|
|
179
|
-
assert.ok(
|
|
180
|
-
r.stderr.includes(`${c.line}\n`),
|
|
181
|
-
`\`echo\` truncates this refusal at the \`\\c\` — it must arrive verbatim and newline-terminated.\nwant: ${JSON.stringify(`${c.line}\n`)}\ngot: ${JSON.stringify(r.stderr)}`,
|
|
182
|
-
);
|
|
183
|
-
// A trace line ABOVE the refusal, where the script names the command it is
|
|
184
|
-
// about to run. Only verify-sha.sh has one carrying unvalidated argv, and
|
|
185
|
-
// the newline is the half that matters most: `echo` eats it, so git's own
|
|
186
|
-
// `fatal:` lands welded to the tail of the trace and stops anchoring `^`.
|
|
187
|
-
if (c.trace) {
|
|
188
|
-
assert.ok(
|
|
189
|
-
r.stderr.includes(`${c.trace}\n`),
|
|
190
|
-
`the trace line must name the command verbatim and keep its newline.\nwant: ${JSON.stringify(`${c.trace}\n`)}\ngot: ${JSON.stringify(r.stderr)}`,
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// The other direction. `printf` treats its FIRST argument as a format string,
|
|
197
|
-
// which `echo` never did, so the fix introduces a hazard of its own: a message
|
|
198
|
-
// holding `%s` or `%d` is silently rewritten by `printf "$msg\n"` — measured,
|
|
199
|
-
// `100% done %s %d` comes out as `100 0one 0`. `printf '%s\n' "$msg"` is
|
|
200
|
-
// immune. Nothing else in the suite feeds a `%`, so without this the fix could
|
|
201
|
-
// regress to the format-string form and stay green.
|
|
202
|
-
test("a %-carrying message is passed through, not interpreted as a format", (t) => {
|
|
203
|
-
const w = repo(t);
|
|
204
|
-
const r = run(w, "drop-merged-label.sh", ["100% done %s %d"]);
|
|
205
|
-
assert.equal(r.status, 2);
|
|
206
|
-
assert.ok(
|
|
207
|
-
r.stderr.includes("drop-merged-label: pr must be a number, got '100% done %s %d'\n"),
|
|
208
|
-
`the message must survive verbatim — \`printf "$msg\\n"\` would consume the %-specifiers; got ${JSON.stringify(r.stderr)}`,
|
|
209
|
-
);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
// A plain message must still work — and this is the only case in the suite that
|
|
213
|
-
// notices if drop-merged-label.sh stops refusing ordinary input at all.
|
|
214
|
-
// Measured: widening its numeric guard's class (`*[!0-9]*` → `*[!0-9a-z]*`)
|
|
215
|
-
// reds this test ALONE, because `back\clue` and `100% done %s %d` fall outside
|
|
216
|
-
// any widened class and go on being refused, while `notanumber` does not.
|
|
217
|
-
//
|
|
218
|
-
// The "refuses everything" direction this was written for is already covered
|
|
219
|
-
// twice over — that mutant reds the `\c` and the `%` test as well — so it is
|
|
220
|
-
// the ordinary-input reachability above, not the accept direction, that makes
|
|
221
|
-
// this worth its fixture (#707 review).
|
|
222
|
-
test("an ordinary message with no escapes is unaffected", (t) => {
|
|
223
|
-
const w = repo(t);
|
|
224
|
-
const r = run(w, "drop-merged-label.sh", ["notanumber"]);
|
|
225
|
-
assert.equal(r.status, 2);
|
|
226
|
-
assert.ok(
|
|
227
|
-
r.stderr.includes("drop-merged-label: pr must be a number, got 'notanumber'\n"),
|
|
228
|
-
`got ${JSON.stringify(r.stderr)}`,
|
|
229
|
-
);
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
// ---------------------------------------------------------------------------
|
|
233
|
-
// Path-carrying sites: the same class, reached through operator output rather
|
|
234
|
-
// than through `die()`. A worktree path is caller-supplied and a backslash is
|
|
235
|
-
// legal in one, which is what makes these reachable at all.
|
|
236
|
-
// ---------------------------------------------------------------------------
|
|
237
|
-
|
|
238
|
-
test("worktree-audit: a worktree path holding a backslash reaches the status line whole", (t) => {
|
|
239
|
-
const w = repo(t);
|
|
240
|
-
const wt = join(w, "back\\clue-wt");
|
|
241
|
-
git(w, "worktree", "add", "-q", "-b", "fix/1-thing", wt);
|
|
242
|
-
const r = run(w, "worktree-audit.sh", []);
|
|
243
|
-
assert.equal(r.status, 0, `stderr: ${r.stderr}`);
|
|
244
|
-
assert.ok(
|
|
245
|
-
r.stderr.includes(`${wt} branch=fix/1-thing`),
|
|
246
|
-
`\`echo\` truncates the status line at the \`\\c\` — the path must arrive verbatim; got ${JSON.stringify(r.stderr)}`,
|
|
247
|
-
);
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
test("worktree-audit: a worktree gone from disk is named verbatim as MISSING", (t) => {
|
|
251
|
-
const w = repo(t);
|
|
252
|
-
const wt = join(w, "back\\clue-gone");
|
|
253
|
-
git(w, "worktree", "add", "-q", "-b", "fix/2-thing", wt);
|
|
254
|
-
rmSync(wt, { recursive: true, force: true });
|
|
255
|
-
const r = run(w, "worktree-audit.sh", []);
|
|
256
|
-
// Status first, as the test above already does. Without it an unrelated
|
|
257
|
-
// early refusal — the script dying before it ever reaches this line — is
|
|
258
|
-
// reported under the escaping headline below, naming a cause it did not have.
|
|
259
|
-
assert.equal(r.status, 0, `stderr: ${r.stderr}`);
|
|
260
|
-
assert.ok(
|
|
261
|
-
r.stderr.includes(`MISSING on disk: ${wt}\n`),
|
|
262
|
-
`the missing path must arrive verbatim; got ${JSON.stringify(r.stderr)}`,
|
|
263
|
-
);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
// `keep()`'s reason is the one line reap.sh's refusals converge on, and a
|
|
267
|
-
// worktree path is interpolated into it from more than one of them — which is
|
|
268
|
-
// the property this test rests on: the escaping belongs in `keep()`, where every
|
|
269
|
-
// such reason passes through `jfield` once, and not at any call site, where it
|
|
270
|
-
// would have to be repeated and would be forgotten at the next one added.
|
|
271
|
-
//
|
|
272
|
-
// No count in this prose, deliberately, and that is this comment's own history
|
|
273
|
-
// rather than a rule imported from elsewhere. It shipped two counts and a list
|
|
274
|
-
// of sites cited by line number; the line numbers had drifted off what they
|
|
275
|
-
// pointed at before anyone noticed, and the counts then went stale again the
|
|
276
|
-
// next time a call site was added — silently, because nothing goes red when a
|
|
277
|
-
// number in a comment stops being true. Name the property, and re-derive the
|
|
278
|
-
// numbers from the tree at the moment you need them (#129):
|
|
279
|
-
// grep -c 'keep "\$b"' reap.sh
|
|
280
|
-
// grep 'keep "\$b"' reap.sh | grep -c '\$wt'
|
|
281
|
-
// reap only considers a branch whose
|
|
282
|
-
// upstream reads `[gone]`, so the fixture has to push the branch and then
|
|
283
|
-
// delete it on origin — reap's own `fetch --prune` is what marks it gone.
|
|
284
|
-
test("reap: a KEEP reason holding a backslashed path reaches the operator whole", (t) => {
|
|
285
|
-
const w = repo(t);
|
|
286
|
-
const wt = join(w, "back\\clue-dirty");
|
|
287
|
-
git(w, "worktree", "add", "-q", "-b", "fix/3-thing", wt);
|
|
288
|
-
// Pushed with -u so the branch has an upstream, then deleted on origin so
|
|
289
|
-
// that upstream becomes `[gone]`. No commit of its own: reap must get PAST
|
|
290
|
-
// the unmerged check to reach a reason that names the worktree.
|
|
291
|
-
git(wt, "push", "-q", "-u", "origin", "fix/3-thing");
|
|
292
|
-
git(w, "push", "-q", "origin", "--delete", "fix/3-thing");
|
|
293
|
-
writeFileSync(join(wt, "g.txt"), "uncommitted\n"); // dirty → `dirty worktree $wt`
|
|
294
|
-
const r = run(w, "reap.sh", []);
|
|
295
|
-
assert.equal(r.status, 0, `stderr: ${r.stderr}`);
|
|
296
|
-
assert.ok(
|
|
297
|
-
r.stderr.includes(`KEEP fix/3-thing — dirty worktree ${wt}\n`),
|
|
298
|
-
`\`echo\` truncates the KEEP line at the \`\\c\` — the worktree path must arrive verbatim; got ${JSON.stringify(r.stderr)}`,
|
|
299
|
-
);
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
test("claim-ticket: the dry-run plan names a backslashed worktree path verbatim", (t) => {
|
|
303
|
-
const w = repo(t);
|
|
304
|
-
// A claim needs the repository's Recipe cache (ADR 0015); the smallest
|
|
305
|
-
// proven one, untracked in the checkout's own `.fleet/`.
|
|
306
|
-
mkdirSync(join(w, ".fleet"), { recursive: true });
|
|
307
|
-
writeFileSync(join(w, ".fleet", "recipe.json"), JSON.stringify({
|
|
308
|
-
install: "true", test: "true", derivedAt: git(w, "rev-parse", "HEAD").trim(), installClean: true, testCount: 1,
|
|
309
|
-
}));
|
|
310
|
-
const r = run(w, "claim-ticket.sh", ["7", "back\\clue", "fix"]);
|
|
311
|
-
assert.equal(r.status, 0, `stderr: ${r.stderr}`);
|
|
312
|
-
assert.ok(
|
|
313
|
-
r.stderr.includes("would: git worktree add --no-track .worktrees/7-back\\clue -b fix/7-back\\clue origin/main\n"),
|
|
314
|
-
`the planned path and branch must arrive verbatim — \`echo\` truncates both at the \`\\c\`; got ${JSON.stringify(r.stderr)}`,
|
|
315
|
-
);
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
// ---------------------------------------------------------------------------
|
|
319
|
-
// The fix's own regression risk, at every site at once.
|
|
320
|
-
//
|
|
321
|
-
// The fixtures above are behavioural and cost a git repo each, so they pin one
|
|
322
|
-
// line per script. This pins the invariant the whole sweep rests on across all
|
|
323
|
-
// of them, statically: `printf` must be handed a LITERAL format, never one
|
|
324
|
-
// built by interpolation.
|
|
325
|
-
//
|
|
326
|
-
// Why a static test is the only thing that can catch it: `printf "$msg\n"` is
|
|
327
|
-
// the regression that reopens BOTH halves of #484, and every `\c` fixture above
|
|
328
|
-
// stays green over it. Measured on /bin/sh and /bin/dash — POSIX printf expands
|
|
329
|
-
// `\c` only under `%b`, never in the format it was handed, so
|
|
330
|
-
// `printf "$NAME: back\clue\n"` prints `back\clue` intact while
|
|
331
|
-
// `printf '%s\n' "back\clue"` does too. Only a `%`-carrying message tells them
|
|
332
|
-
// apart, and feeding one to all ~35 sites would need a fixture per site. Under
|
|
333
|
-
// that mutation the die() sites of verify-sha.sh and inflight.sh were reverted
|
|
334
|
-
// and the full suite stayed green.
|
|
335
|
-
//
|
|
336
|
-
// Not delegated to shellcheck: SC2059 is exactly this check, but it reports at
|
|
337
|
-
// `info`, and CI runs `shellcheck -x -S warning`, which filters it out before
|
|
338
|
-
// it is printed. Raising that floor is a change to a workflow file this ticket
|
|
339
|
-
// has no business in.
|
|
340
|
-
//
|
|
341
|
-
// It does NOT catch a revert to `echo` — nothing static can, since two thirds
|
|
342
|
-
// of the `echo` calls in these scripts interpolate values that are safe by
|
|
343
|
-
// construction (numbers, SHAs, refs git already accepted). That direction is
|
|
344
|
-
// what the behavioural fixtures above, and the per-script path fixtures in
|
|
345
|
-
// inflight.test.mjs and release-ticket.test.mjs, are for.
|
|
346
|
-
test("every printf in the fleet scripts is handed a literal format string", () => {
|
|
347
|
-
// The format argument is the first token after `printf`: a single-quoted run
|
|
348
|
-
// (literal through and through), a double-quoted run honouring `\"`, or a
|
|
349
|
-
// bare word. Full-line comments are skipped — several of them quote the very
|
|
350
|
-
// form being banned.
|
|
351
|
-
const FORMAT = /(?:^|[;&|(){}\s])printf[ \t]+('[^']*'|"(?:[^"\\]|\\.)*"|[^\s;&|)]+)/g;
|
|
352
|
-
// Single quotes cannot interpolate at all. Anything else does the moment it
|
|
353
|
-
// carries an unescaped `$` or a backtick — `"\$arg"` is a literal dollar and
|
|
354
|
-
// stays legal, which is what the agent-test runner claim-ticket.sh writes
|
|
355
|
-
// through a heredoc relies on.
|
|
356
|
-
const interpolates = (tok) => {
|
|
357
|
-
if (tok.startsWith("'")) return false;
|
|
358
|
-
const body = tok.startsWith('"') ? tok.slice(1, -1) : tok;
|
|
359
|
-
return /(?:^|[^\\])[$`]/.test(body);
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
const scripts = readdirSync(DIR).filter((n) => n.endsWith(".sh")).sort();
|
|
363
|
-
// A glob that matches nothing passes every assertion below it. Same failure
|
|
364
|
-
// as `tests 0`, and the same reading rule: no scripts is a broken test.
|
|
365
|
-
assert.ok(scripts.length >= 9, `expected the fleet scripts, found ${scripts.length}`);
|
|
366
|
-
|
|
367
|
-
const bad = [];
|
|
368
|
-
let checked = 0;
|
|
369
|
-
for (const name of scripts) {
|
|
370
|
-
readFileSync(join(DIR, name), "utf8").split("\n").forEach((line, i) => {
|
|
371
|
-
if (/^\s*#/.test(line)) return;
|
|
372
|
-
for (const m of line.matchAll(FORMAT)) {
|
|
373
|
-
checked++;
|
|
374
|
-
if (interpolates(m[1])) bad.push(`${name}:${i + 1} ${m[1]}`);
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
assert.ok(checked >= 100, `expected to find the sweep's printf calls, found ${checked}`);
|
|
379
|
-
assert.deepEqual(
|
|
380
|
-
bad,
|
|
381
|
-
[],
|
|
382
|
-
`these printf calls build their format by interpolation, which consumes any \`%\` in the message and re-opens #484:\n ${bad.join("\n ")}`,
|
|
383
|
-
);
|
|
384
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { between } from "./prose-pin.mjs";
|
|
4
|
-
import { stripComments } from "./strip-comments.mjs";
|
|
5
|
-
|
|
6
|
-
// #1552. The extract-then-compile idiom — read a workflow's source, strip its
|
|
7
|
-
// comments so a block-commented call cannot render as live text, find a
|
|
8
|
-
// template literal's start/end anchors, trim its wrapping backticks, and
|
|
9
|
-
// compile it with `new Function` — existed independently in three test files,
|
|
10
|
-
// each around a different anchor pair:
|
|
11
|
-
// `835ef5d03c^:plugin/scripts/review-pr-specialist-scratch.test.mjs`,
|
|
12
|
-
// `835ef5d03c^:plugin/scripts/review-pr-refuter-scratch.test.mjs`, and
|
|
13
|
-
// injection-control-prose.test.mjs. One of the three (the specialist twin)
|
|
14
|
-
// already delegated the anchor-finding half to prose-pin.mjs's `between()`;
|
|
15
|
-
// the other two reimplemented the same `indexOf`/`assert.notEqual` pair by
|
|
16
|
-
// hand. Commit 835ef5d03c moved only the extraction MACHINERY here; the
|
|
17
|
-
// prompt RULE PROSE itself stays inline in review-core.mjs per #496's brief
|
|
18
|
-
// against a shared source for the rules themselves.
|
|
19
|
-
const REPO = join(import.meta.dirname, "..");
|
|
20
|
-
|
|
21
|
-
// `file` is relative to the plugin root (e.g. "scripts/review-core.mjs").
|
|
22
|
-
// Extraction runs against the comment-stripped text, not the raw source: a
|
|
23
|
-
// block-commented `agent(...)` call still contains the whole template, so
|
|
24
|
-
// extracting from raw source would render dead text and report every
|
|
25
|
-
// criterion satisfied — the vacuity class strip-comments.mjs exists for.
|
|
26
|
-
export function workflowCode(file) {
|
|
27
|
-
return stripComments(readFileSync(join(REPO, file), "utf8"));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Extracts the template literal between `start` and `end` out of `file` (via
|
|
31
|
-
// prose-pin.mjs's `between()`, which owns the bounded-slice extraction and
|
|
32
|
-
// both failure messages), trims the wrapping backticks, and compiles the
|
|
33
|
-
// result into a renderer bound to `scope`'s free names. Compiling is half the
|
|
34
|
-
// assertion: an unescaped `${` in the prescribed array expansion either
|
|
35
|
-
// throws here or silently interpolates away the very spelling the rule
|
|
36
|
-
// exists to teach.
|
|
37
|
-
export function promptRenderer({ file, start, end, scope, what }) {
|
|
38
|
-
const slice = between(workflowCode(file), start, end, what);
|
|
39
|
-
return new Function(...scope, "return `" + slice.slice(1, slice.lastIndexOf("`")) + "`");
|
|
40
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// #1552. prompt-renderer.mjs's `workflowCode()` runs the file it reads through
|
|
2
|
-
// `stripComments()` before extraction — its own header comment (lines 17-21)
|
|
3
|
-
// documents this as the defense against a block-commented dead `agent()` call
|
|
4
|
-
// being extracted and rendered as live text, the exact vacuity class
|
|
5
|
-
// strip-comments.mjs exists for (measured twice on the pre-cutover review
|
|
6
|
-
// host before this module existed, per the comment above `workflowCode`).
|
|
7
|
-
// Nothing pinned that wrapper: review-core-cwd-isolation.test.mjs and
|
|
8
|
-
// injection-control-prose.test.mjs both extract from `review-core.mjs`,
|
|
9
|
-
// which carries no dead duplicate today, so neither can red if the
|
|
10
|
-
// `stripComments()` call is dropped. This file pins the guard directly with
|
|
11
|
-
// a synthetic fixture, once, for both consumers.
|
|
12
|
-
import { test } from "node:test";
|
|
13
|
-
import assert from "node:assert/strict";
|
|
14
|
-
import { mkdtempSync, writeFileSync, rmSync } from "node:fs";
|
|
15
|
-
import { tmpdir } from "node:os";
|
|
16
|
-
import { join, relative } from "node:path";
|
|
17
|
-
import { promptRenderer, workflowCode } from "./prompt-renderer.mjs";
|
|
18
|
-
|
|
19
|
-
const REPO = join(import.meta.dirname, "..");
|
|
20
|
-
|
|
21
|
-
// A dead `agent()` call, block-commented on one line (matching
|
|
22
|
-
// strip-comments.mjs's line-based stripping), sits BEFORE the live one — the
|
|
23
|
-
// same first-occurrence hazard `between()`'s "no longer contains" pin never
|
|
24
|
-
// catches, since the dead text satisfies indexOf just as well as the live
|
|
25
|
-
// text and comes first.
|
|
26
|
-
const TEMPLATE_START = "`Try to REFUTE this finding from PR #";
|
|
27
|
-
const TEMPLATE_END = "{ label: `verify:";
|
|
28
|
-
const FIXTURE = [
|
|
29
|
-
"/* agent(`Try to REFUTE this finding from PR #999`, { label: `verify:dead` }); */",
|
|
30
|
-
"agent(`Try to REFUTE this finding from PR #1`, { label: `verify:live` });",
|
|
31
|
-
"",
|
|
32
|
-
].join("\n");
|
|
33
|
-
|
|
34
|
-
function withFixture(fn) {
|
|
35
|
-
const dir = mkdtempSync(join(tmpdir(), "prompt-renderer-test-"));
|
|
36
|
-
try {
|
|
37
|
-
const file = join(dir, "fixture-workflow.js");
|
|
38
|
-
writeFileSync(file, FIXTURE, "utf8");
|
|
39
|
-
return fn(relative(REPO, file));
|
|
40
|
-
} finally {
|
|
41
|
-
rmSync(dir, { recursive: true, force: true });
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
test("workflowCode() strips a block-commented dead call before extraction, so a stale earlier occurrence cannot win", () => {
|
|
46
|
-
withFixture((relFile) => {
|
|
47
|
-
const code = workflowCode(relFile);
|
|
48
|
-
assert.ok(!code.includes("PR #999"), "the block-commented dead PR #999 call survived stripComments() — extraction would prefer it over the live call below it");
|
|
49
|
-
assert.ok(code.includes("PR #1"), "the live PR #1 call was stripped along with the dead comment — stripComments() over-blanked");
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test("promptRenderer() renders the live occurrence, not a block-commented dead one that appears first", () => {
|
|
54
|
-
withFixture((relFile) => {
|
|
55
|
-
const RENDER = promptRenderer({
|
|
56
|
-
file: relFile,
|
|
57
|
-
start: TEMPLATE_START,
|
|
58
|
-
end: TEMPLATE_END,
|
|
59
|
-
scope: [],
|
|
60
|
-
what: "fixture template",
|
|
61
|
-
});
|
|
62
|
-
assert.equal(
|
|
63
|
-
RENDER(),
|
|
64
|
-
"Try to REFUTE this finding from PR #1",
|
|
65
|
-
"promptRenderer() extracted the block-commented dead template instead of the live one — workflowCode() is no longer stripping comments before extraction",
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
});
|