@feigi/fleet-ctl 0.0.0
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/.claude-plugin/plugin.json +9 -0
- package/LICENSE +202 -0
- package/NOTICE +18 -0
- package/agents/fleet-finisher.agent.md +7 -0
- package/agents/fleet-implementer-alt.agent.md +210 -0
- package/agents/fleet-implementer.agent.md +210 -0
- package/agents/fleet-merge-bot.agent.md +7 -0
- package/agents/fleet-review-comments.agent.md +40 -0
- package/agents/fleet-review-correctness.agent.md +43 -0
- package/agents/fleet-review-runner.agent.md +73 -0
- package/agents/fleet-review-silent-failure.agent.md +49 -0
- package/agents/fleet-review-simplify.agent.md +46 -0
- package/agents/fleet-review-snapshot.agent.md +24 -0
- package/agents/fleet-review-tests.agent.md +46 -0
- package/agents/fleet-review-types.agent.md +41 -0
- package/agents/fleet-review-verifier.agent.md +29 -0
- package/commands/review-and-fix.md +98 -0
- package/commands/run-merge-bot.md +357 -0
- package/commands/run-team-help.md +17 -0
- package/package.json +23 -0
- package/scripts/agent-test-dir-prose.test.mjs +59 -0
- package/scripts/agent-test.test.mjs +1636 -0
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +354 -0
- package/scripts/ambient-git-vars-prose.test.mjs +192 -0
- package/scripts/ancestry-check-position-prose.test.mjs +175 -0
- package/scripts/apply-ruleset.test.mjs +420 -0
- package/scripts/arg-header-probes-prose.test.mjs +393 -0
- package/scripts/arg.mjs +600 -0
- package/scripts/arg.test.mjs +1354 -0
- package/scripts/board-cli.test.mjs +694 -0
- package/scripts/board-identity.test.mjs +429 -0
- package/scripts/board-liveness-banner.test.mjs +119 -0
- package/scripts/board-prev-shape.test.mjs +229 -0
- package/scripts/board-tryparse-null.test.mjs +119 -0
- package/scripts/board.html +471 -0
- package/scripts/board.mjs +2037 -0
- package/scripts/board.test.mjs +3086 -0
- package/scripts/brief-after-cut-prose.test.mjs +53 -0
- package/scripts/candidates-exit3-prose.test.mjs +302 -0
- package/scripts/candidates.mjs +674 -0
- package/scripts/candidates.test.mjs +2101 -0
- package/scripts/caveat-unification-prose.test.mjs +98 -0
- package/scripts/ci-comment-rot-prose.test.mjs +2025 -0
- package/scripts/ci-completes-premise-prose.test.mjs +257 -0
- package/scripts/ci-state-prose.test.mjs +113 -0
- package/scripts/ci-state.mjs +761 -0
- package/scripts/ci-state.test.mjs +1640 -0
- package/scripts/ci-vacuous-green.test.mjs +368 -0
- package/scripts/citation-sweep-prose.test.mjs +1572 -0
- package/scripts/claim-lifecycle.test.mjs +185 -0
- package/scripts/claim-ticket.sh +417 -0
- package/scripts/claim-ticket.test.mjs +1121 -0
- package/scripts/closing-keyword-prose.test.mjs +193 -0
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +165 -0
- package/scripts/cockpit-tick-nonblocking.test.mjs +210 -0
- package/scripts/compute-board.mjs +579 -0
- package/scripts/compute-board.test.mjs +1060 -0
- package/scripts/compute-spend.mjs +329 -0
- package/scripts/compute-spend.test.mjs +451 -0
- package/scripts/cross-repo-citation-prose.test.mjs +156 -0
- package/scripts/cwd-isolation-pins.mjs +83 -0
- package/scripts/dedupe-guard-prose.test.mjs +243 -0
- package/scripts/derive-testcmd.sh +239 -0
- package/scripts/derive-testcmd.test.mjs +380 -0
- package/scripts/diff-stats.mjs +231 -0
- package/scripts/diff-stats.test.mjs +408 -0
- package/scripts/dispatch-block-golden-prose.test.mjs +1024 -0
- package/scripts/dispatch-block-pins-prose.test.mjs +615 -0
- package/scripts/drop-merged-label.sh +173 -0
- package/scripts/drop-merged-label.test.mjs +480 -0
- package/scripts/expected-jobs-prose.test.mjs +80 -0
- package/scripts/filing-bar-seat-prose.test.mjs +242 -0
- package/scripts/filing-claim-bar-prose.test.mjs +166 -0
- package/scripts/finisher-dispatch-premise-prose.test.mjs +312 -0
- package/scripts/finisher-halt-prose.test.mjs +106 -0
- package/scripts/finisher-name-prose.test.mjs +134 -0
- package/scripts/finisher-own-tree-prose.test.mjs +285 -0
- package/scripts/finisher-pin-race-prose.test.mjs +339 -0
- package/scripts/fix-applier-correction-rules-prose.test.mjs +201 -0
- package/scripts/fix-applier-result-file-prose.test.mjs +100 -0
- package/scripts/fleet-bootstrap +155 -0
- package/scripts/fleet-heartbeat.mjs +272 -0
- package/scripts/fleet-heartbeat.test.mjs +450 -0
- package/scripts/fleet-provenance +207 -0
- package/scripts/fleet-provenance.test.mjs +64 -0
- package/scripts/fleet-run +148 -0
- package/scripts/fleet-run.test.mjs +90 -0
- package/scripts/fleet-state.mjs +400 -0
- package/scripts/fleet-state.test.mjs +373 -0
- package/scripts/fleet-tick-prose.test.mjs +299 -0
- package/scripts/fleet-tick.mjs +832 -0
- package/scripts/fleet-tick.test.mjs +1332 -0
- package/scripts/force-with-lease-reason-prose.test.mjs +184 -0
- package/scripts/frontmatter-allowlist.json +64 -0
- package/scripts/frontmatter-check.mjs +256 -0
- package/scripts/frontmatter-check.test.mjs +436 -0
- package/scripts/git-env.mjs +124 -0
- package/scripts/git-env.test.mjs +149 -0
- package/scripts/git-status-untracked-mode-sweep.test.mjs +216 -0
- package/scripts/gone-walk.test.mjs +213 -0
- package/scripts/gp-sep-invariant-prose.test.mjs +188 -0
- package/scripts/head-moved-after-label-prose.test.mjs +233 -0
- package/scripts/immutable-body-claim-prose.test.mjs +413 -0
- package/scripts/implementer-model-tier.test.mjs +643 -0
- package/scripts/inflight-citation-prose.test.mjs +144 -0
- package/scripts/inflight-exit2-prose.test.mjs +81 -0
- package/scripts/inflight-probe-guard-prose.test.mjs +109 -0
- package/scripts/inflight-scan-scope-prose.test.mjs +57 -0
- package/scripts/inflight.sh +1106 -0
- package/scripts/inflight.test.mjs +2984 -0
- package/scripts/injection-control-prose.test.mjs +404 -0
- package/scripts/install-root-audit.test.mjs +464 -0
- package/scripts/instrument-check-prose.test.mjs +235 -0
- package/scripts/instruments.sh +394 -0
- package/scripts/instruments.test.mjs +787 -0
- package/scripts/issue-tracker-prose.test.mjs +71 -0
- package/scripts/json.sh +248 -0
- package/scripts/json.test.mjs +364 -0
- package/scripts/ledger-dispatch.test.mjs +516 -0
- package/scripts/ledger-grammar.mjs +85 -0
- package/scripts/ledger-grammar.test.mjs +142 -0
- package/scripts/ledger-read-require-file.test.mjs +197 -0
- package/scripts/ledger.mjs +1753 -0
- package/scripts/ledger.test.mjs +3554 -0
- package/scripts/line-distance-prose.test.mjs +245 -0
- package/scripts/liveness-rationale-prose.test.mjs +83 -0
- package/scripts/locale-pin-prose.test.mjs +189 -0
- package/scripts/member-outcome-prose.test.mjs +167 -0
- package/scripts/member-outcomes-header.test.mjs +148 -0
- package/scripts/member-outcomes-prose.test.mjs +63 -0
- package/scripts/member-outcomes.mjs +231 -0
- package/scripts/member-outcomes.test.mjs +507 -0
- package/scripts/member-prompt-prose.test.mjs +161 -0
- package/scripts/member-record.mjs +605 -0
- package/scripts/member-record.test.mjs +516 -0
- package/scripts/member-write-guard.mjs +279 -0
- package/scripts/member-write-guard.test.mjs +211 -0
- package/scripts/merge-commit-probe-prose.test.mjs +122 -0
- package/scripts/merge-gate.mjs +262 -0
- package/scripts/merge-gate.test.mjs +613 -0
- package/scripts/muted-git-guard-sweep.test.mjs +493 -0
- package/scripts/net-ssh-precedence-prose.test.mjs +91 -0
- package/scripts/net-watchdog-prose.test.mjs +79 -0
- package/scripts/net.sh +409 -0
- package/scripts/net.test.mjs +211 -0
- package/scripts/no-ci-gate-prose.test.mjs +108 -0
- package/scripts/no-undo-audit.sh +1134 -0
- package/scripts/no-undo-audit.test.mjs +3965 -0
- package/scripts/no-wave.test.mjs +138 -0
- package/scripts/node-floor-sweep.test.mjs +611 -0
- package/scripts/pointer-target-prose.test.mjs +186 -0
- package/scripts/pr-overlap.mjs +417 -0
- package/scripts/pr-overlap.test.mjs +695 -0
- package/scripts/printf-die-sweep.test.mjs +384 -0
- package/scripts/prompt-renderer.mjs +39 -0
- package/scripts/prompt-renderer.test.mjs +68 -0
- package/scripts/prose-pin.mjs +808 -0
- package/scripts/prose-pin.test.mjs +1034 -0
- package/scripts/prove-merge.sh +228 -0
- package/scripts/prove-merge.test.mjs +995 -0
- package/scripts/pull-table-relabel-prose.test.mjs +60 -0
- package/scripts/quiet-payload-prose.test.mjs +222 -0
- package/scripts/reap.sh +1768 -0
- package/scripts/reap.test.mjs +4395 -0
- package/scripts/reaping-prose.test.mjs +159 -0
- package/scripts/refuter-scratch-prose.test.mjs +135 -0
- package/scripts/release-label-required-prose.test.mjs +71 -0
- package/scripts/release-label-split-prose.test.mjs +169 -0
- package/scripts/release-ticket.sh +1716 -0
- package/scripts/release-ticket.test.mjs +5106 -0
- package/scripts/renovate-release-contract.test.mjs +379 -0
- package/scripts/repo-root.mjs +544 -0
- package/scripts/repo-root.test.mjs +873 -0
- package/scripts/reporter-output-rule-prose.test.mjs +208 -0
- package/scripts/review-agent-report-only.test.mjs +49 -0
- package/scripts/review-core-cwd-isolation.test.mjs +374 -0
- package/scripts/review-core-reads.test.mjs +478 -0
- package/scripts/review-core-refuter-scratch.test.mjs +148 -0
- package/scripts/review-core-snapshot-path.test.mjs +777 -0
- package/scripts/review-core-specialist-scratch.test.mjs +189 -0
- package/scripts/review-core-testcmd.test.mjs +288 -0
- package/scripts/review-core-unrun.test.mjs +530 -0
- package/scripts/review-core-unverified-discriminant.test.mjs +208 -0
- package/scripts/review-core.mjs +1028 -0
- package/scripts/review-eval-resolver-path.test.mjs +55 -0
- package/scripts/review-eval.mjs +197 -0
- package/scripts/review-host-fixture.mjs +73 -0
- package/scripts/review-in-run-retry.test.mjs +187 -0
- package/scripts/review-no-vendor-dispatch.test.mjs +45 -0
- package/scripts/review-path-default.test.mjs +796 -0
- package/scripts/review-runner-spawns.test.mjs +93 -0
- package/scripts/review-runner.test.mjs +155 -0
- package/scripts/review-tier-audit.test.mjs +140 -0
- package/scripts/run-artifact-pr-prose.test.mjs +341 -0
- package/scripts/run-merge-bot-prose.test.mjs +1391 -0
- package/scripts/scratch-partition-invariant-prose.test.mjs +74 -0
- package/scripts/scripts-path-citation-sweep.test.mjs +73 -0
- package/scripts/section-between-guard-prose.test.mjs +378 -0
- package/scripts/select-dimensions.test.mjs +674 -0
- package/scripts/shared-refusal.test.mjs +388 -0
- package/scripts/shell-traps-prose.test.mjs +507 -0
- package/scripts/shortlist.mjs +355 -0
- package/scripts/shortlist.test.mjs +366 -0
- package/scripts/slow-transport.mjs +72 -0
- package/scripts/snapshot-repo.test.mjs +772 -0
- package/scripts/snapshot-runner-audience-prose.test.mjs +129 -0
- package/scripts/spend-view.test.mjs +312 -0
- package/scripts/staleness-qualifier-prose.test.mjs +251 -0
- package/scripts/staleness-verdict-prose.test.mjs +142 -0
- package/scripts/staleness.mjs +414 -0
- package/scripts/staleness.test.mjs +893 -0
- package/scripts/stalled-member-liveness-prose.test.mjs +219 -0
- package/scripts/stash-prohibition-prose.test.mjs +313 -0
- package/scripts/strip-comments.mjs +44 -0
- package/scripts/tier-check.mjs +468 -0
- package/scripts/tier-check.test.mjs +726 -0
- package/scripts/tier-guard-gate-prose.test.mjs +216 -0
- package/scripts/tier-outcomes-header.test.mjs +586 -0
- package/scripts/tier-outcomes.mjs +441 -0
- package/scripts/tier-outcomes.test.mjs +342 -0
- package/scripts/tier-roles.mjs +250 -0
- package/scripts/tier-roles.test.mjs +316 -0
- package/scripts/tracker-block-copy-prose.test.mjs +288 -0
- package/scripts/triage-labels-gloss-prose.test.mjs +97 -0
- package/scripts/unattended-git-sweep.test.mjs +142 -0
- package/scripts/verify-sha-exit2-prose.test.mjs +269 -0
- package/scripts/verify-sha.sh +117 -0
- package/scripts/verify-sha.test.mjs +693 -0
- package/scripts/watcher-degraded-block.test.mjs +372 -0
- package/scripts/watcher-key-prose.test.mjs +106 -0
- package/scripts/within-run-pair-prose.test.mjs +208 -0
- package/scripts/worktree-audit.sh +482 -0
- package/scripts/worktree-audit.test.mjs +1407 -0
- package/scripts/worktree-head-prose.test.mjs +276 -0
- package/scripts/worktree-listing-sweep.test.mjs +217 -0
- package/scripts/worktree-model-prose.test.mjs +216 -0
- package/scripts/worktree.sh +470 -0
- package/skills/next-ticket/SKILL.md +138 -0
- package/skills/run-team/SKILL.md +3603 -0
- package/skills/run-team/references/ci-and-staleness.md +75 -0
- package/skills/run-team/references/correction-tickets.md +37 -0
- package/skills/run-team/references/isolation.md +23 -0
- package/skills/run-team/references/member-lifecycle.md +73 -0
- package/skills/run-team/references/reaping.md +73 -0
- package/skills/sizing-a-ticket/SKILL.md +39 -0
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
// #854. `run-team/SKILL.md`'s **Shell traps** section is the single seat for the
|
|
2
|
+
// zsh family, and the one thing a pin here has to stop is the rule being written
|
|
3
|
+
// BACKWARDS. The ticket was filed naming `for x in $(…)` as the hazard — that is
|
|
4
|
+
// the form that works — and a member acted on the uncorrected version and
|
|
5
|
+
// reported a working bounded poll as broken. A string-matching pin cannot tell
|
|
6
|
+
// the two directions apart: both spellings contain the same words.
|
|
7
|
+
//
|
|
8
|
+
// So this file RUNS them. It lifts the forms the document calls hazardous and
|
|
9
|
+
// safe and executes each under zsh, asserting the document's own claim about
|
|
10
|
+
// iteration counts. Invert the section and the test reddens because zsh
|
|
11
|
+
// disagrees with it, not because a string moved. Same discipline as
|
|
12
|
+
// watcher-degraded-block.test.mjs, one document over.
|
|
13
|
+
//
|
|
14
|
+
// It also runs `run-merge-bot.md`'s **Then stay armed** monitor, lifted from the
|
|
15
|
+
// fence rather than copied, because that block carried a live instance of this
|
|
16
|
+
// exact defect until this ticket.
|
|
17
|
+
//
|
|
18
|
+
// THE CEILING: the document's whole contract — the rule's direction included —
|
|
19
|
+
// is asserted without a shell, so CI enforces it on ubuntu-latest, which ships
|
|
20
|
+
// no zsh. The MEASUREMENTS behind it are zsh-only and announce themselves as
|
|
21
|
+
// skipped there rather than passing; the monitor's sh and bash arms still run.
|
|
22
|
+
// So a green on ubuntu proves the text, and a green here proves the text and
|
|
23
|
+
// the shell agree. Nothing in this file contacts GitHub: the monitor's `gh` is
|
|
24
|
+
// a stub, and `sleep` is a no-op, so this measures loop mechanics and not
|
|
25
|
+
// timing.
|
|
26
|
+
import { test } from "node:test";
|
|
27
|
+
import assert from "node:assert/strict";
|
|
28
|
+
import { execFileSync } from "node:child_process";
|
|
29
|
+
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, chmodSync } from "node:fs";
|
|
30
|
+
import { tmpdir } from "node:os";
|
|
31
|
+
import { join } from "node:path";
|
|
32
|
+
|
|
33
|
+
const SKILLS = join(import.meta.dirname, "..", "skills");
|
|
34
|
+
const SKILL = readFileSync(join(SKILLS, "run-team", "SKILL.md"), "utf8");
|
|
35
|
+
const MERGE_BOT = readFileSync(join(import.meta.dirname, "..", "commands", "run-merge-bot.md"), "utf8");
|
|
36
|
+
|
|
37
|
+
const DIR = mkdtempSync(join(tmpdir(), "shell-traps-"));
|
|
38
|
+
const BIN = join(DIR, "bin");
|
|
39
|
+
mkdirSync(BIN);
|
|
40
|
+
|
|
41
|
+
const stub = (name, body) => {
|
|
42
|
+
const p = join(BIN, name);
|
|
43
|
+
writeFileSync(p, body);
|
|
44
|
+
chmodSync(p, 0o755);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const hasShell = (s) => {
|
|
48
|
+
try {
|
|
49
|
+
execFileSync(s, ["-c", "exit 0"], { stdio: "ignore" });
|
|
50
|
+
return true;
|
|
51
|
+
} catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Runs a script and returns stdout. `env` is merged so the monitor case can
|
|
57
|
+
// point its stub at a per-case call counter.
|
|
58
|
+
const sh = (shell, script, env = {}) => {
|
|
59
|
+
const p = join(DIR, "case.sh");
|
|
60
|
+
writeFileSync(p, script);
|
|
61
|
+
return execFileSync(shell, [p], {
|
|
62
|
+
encoding: "utf8",
|
|
63
|
+
env: { ...process.env, ...env, PATH: `${BIN}:${process.env.PATH}` },
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Slice to the section, so a sentence elsewhere in a 3000-line file can never
|
|
68
|
+
// stand in for one here. Anchored on the heading text, never on an offset.
|
|
69
|
+
const section = (doc, heading) => {
|
|
70
|
+
const start = doc.indexOf(`\n## ${heading}\n`);
|
|
71
|
+
assert.notEqual(start, -1, `run-team/SKILL.md no longer has a '## ${heading}' section — this ticket put it there`);
|
|
72
|
+
const rest = doc.slice(start + 1);
|
|
73
|
+
const end = rest.indexOf("\n## ", 1);
|
|
74
|
+
return end === -1 ? rest : rest.slice(0, end);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const TRAPS = section(SKILL, "Shell traps");
|
|
78
|
+
|
|
79
|
+
// The three-value list the section's own table is measured against.
|
|
80
|
+
const LIST = "849\\n850\\n852\\n";
|
|
81
|
+
|
|
82
|
+
// A literal phrase as a regex that tolerates re-wrapping: every run of
|
|
83
|
+
// whitespace matches any run. The CLAIM is what these tests pin; where the
|
|
84
|
+
// editor's line breaks fall is not, and a pin that reddens on a reflow is one
|
|
85
|
+
// the next reader weakens instead of reading.
|
|
86
|
+
const phrase = (s) => new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\s+/g, "\\s+"));
|
|
87
|
+
|
|
88
|
+
test("the section exists and is the only place the zsh loop family is stated, in either document", () => {
|
|
89
|
+
// The mechanism sentence lives once. The two seats that consume it cite the
|
|
90
|
+
// section instead of restating it — that is #854's placement ruling, and the
|
|
91
|
+
// drift it prevents is a second copy going stale against the first, whether
|
|
92
|
+
// that copy lands back in SKILL.md or in run-merge-bot.md, the document this
|
|
93
|
+
// ticket edits most heavily and whose own brief bullet was replaced by a
|
|
94
|
+
// pointer.
|
|
95
|
+
const mechanism = phrase("word-splits an unquoted command substitution's result; it does NOT split an unquoted parameter expansion");
|
|
96
|
+
assert.match(TRAPS, mechanism, "the Shell traps section dropped the mechanism sentence");
|
|
97
|
+
|
|
98
|
+
const elsewhere = SKILL.replace(TRAPS, "") + MERGE_BOT;
|
|
99
|
+
assert.ok(
|
|
100
|
+
!/zsh has no `PIPESTATUS`/.test(elsewhere),
|
|
101
|
+
"a second copy of the PIPESTATUS trap is back outside Shell traps — #854 collapsed them into one seat",
|
|
102
|
+
);
|
|
103
|
+
assert.ok(
|
|
104
|
+
!/is a READ-ONLY variable in zsh/.test(elsewhere),
|
|
105
|
+
"a second copy of the read-only-`status` trap is back outside Shell traps",
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test("both consumer seats reach the section instead of restating it", () => {
|
|
110
|
+
// Phase 3 writes the CI watcher's loop; the merge-bot brief is where a bot
|
|
111
|
+
// gets the same traps. The ticket's ruling is that neither carries its own
|
|
112
|
+
// copy, so each has to name the section.
|
|
113
|
+
const watcher = SKILL.slice(SKILL.indexOf("**Guard every probe, not just the ones with a verdict field.**"));
|
|
114
|
+
const watcherPara = watcher.slice(0, watcher.indexOf("\n\n**Judge `ci-state`"));
|
|
115
|
+
// The citation is the section NAME, in whatever emphasis the sentence wants.
|
|
116
|
+
// Pinning `**Shell traps**` exactly would fail on a bold span that opens
|
|
117
|
+
// earlier in the clause, which is a rewording rather than a lost pointer.
|
|
118
|
+
assert.match(
|
|
119
|
+
watcherPara,
|
|
120
|
+
/\bShell traps\b/,
|
|
121
|
+
"phase 3's monitor paragraph no longer points at Shell traps — it either lost the pointer or grew its own copy of the mechanism",
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
// The brief's one bullet since #1806 retired the gate traps into
|
|
125
|
+
// merge-gate.mjs: sliced to that paragraph alone.
|
|
126
|
+
const at = SKILL.indexOf("**Put the shell traps in the bot's brief");
|
|
127
|
+
assert.notEqual(at, -1, "the merge bot's shell-traps brief paragraph moved — re-anchor this test");
|
|
128
|
+
const briefPara = SKILL.slice(at, SKILL.indexOf("\n\n", at));
|
|
129
|
+
assert.match(
|
|
130
|
+
briefPara,
|
|
131
|
+
/\bShell traps\b/,
|
|
132
|
+
"the merge bot's brief no longer points at Shell traps, so a dispatched bot never receives them",
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// CI runs ubuntu-latest, which ships no zsh. So the document's whole contract
|
|
137
|
+
// is asserted in tests that need no shell — including the rule's DIRECTION,
|
|
138
|
+
// which is the one thing #854 exists to keep straight — and only the
|
|
139
|
+
// measurements behind it are shell-gated, announced with `t.skip` rather than
|
|
140
|
+
// returning green on a cell that never ran.
|
|
141
|
+
const needs = (t, shell) => {
|
|
142
|
+
if (hasShell(shell)) return true;
|
|
143
|
+
t.skip(`no ${shell} on PATH — this cell measures a ${shell}-specific behaviour and cannot run here`);
|
|
144
|
+
return false;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
test("the section states the rule in the corrected direction", () => {
|
|
148
|
+
// The half the original ticket got backwards, and the half that matters most:
|
|
149
|
+
// a reader who takes `$(…)` for the hazard avoids the form that works and
|
|
150
|
+
// keeps the one that collapses. Both directions are pinned, because dropping
|
|
151
|
+
// either one leaves a reader able to infer the wrong discriminator.
|
|
152
|
+
assert.match(
|
|
153
|
+
TRAPS,
|
|
154
|
+
phrase("hazard is the **assigned-variable** form, never `$(…)`"),
|
|
155
|
+
"Shell traps no longer names the assigned-variable form as the hazard — #854's whole correction is that direction",
|
|
156
|
+
);
|
|
157
|
+
assert.match(TRAPS, phrase("`$(…)` splits. Leave it alone."), "Shell traps stopped blessing the command-substitution form");
|
|
158
|
+
assert.match(
|
|
159
|
+
TRAPS,
|
|
160
|
+
phrase("Capture-then-loop needs `while IFS= read -r` fed by a heredoc"),
|
|
161
|
+
"Shell traps no longer prescribes the heredoc-fed `while IFS= read -r` remedy",
|
|
162
|
+
);
|
|
163
|
+
assert.match(
|
|
164
|
+
TRAPS,
|
|
165
|
+
phrase("`</dev/null` every command inside a `while read` loop"),
|
|
166
|
+
"Shell traps dropped the `</dev/null` rule — the remedy it prescribes is unsafe without it",
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test("zsh agrees with the table: the assigned-variable form collapses", (t) => {
|
|
171
|
+
if (!needs(t, "zsh")) return;
|
|
172
|
+
// The hazard row, run for real rather than quoted. This is what a string pin
|
|
173
|
+
// cannot do: if the section is ever reworded to bless the broken form, the
|
|
174
|
+
// measurement it claims stops holding and this reddens on the shell's own
|
|
175
|
+
// behaviour instead of on a diff.
|
|
176
|
+
const out = sh("zsh", `prs=$(printf '${LIST}')\ni=0; for pr in $prs; do i=$((i+1)); done; echo "$i"`);
|
|
177
|
+
assert.equal(
|
|
178
|
+
out.trim(),
|
|
179
|
+
"1",
|
|
180
|
+
"zsh no longer collapses `for pr in $prs` — the section's hazard row is now false and the rule needs re-measuring",
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("zsh agrees with the table: both command-substitution rows split", (t) => {
|
|
185
|
+
if (!needs(t, "zsh")) return;
|
|
186
|
+
const inline = sh("zsh", `i=0; for pr in $(printf '${LIST}'); do i=$((i+1)); done; echo "$i"`);
|
|
187
|
+
assert.equal(inline.trim(), "3", "zsh no longer splits an inline command substitution — the section's safe row is now false");
|
|
188
|
+
const seq = sh("zsh", `j=0; for _ in $(seq 1 60); do j=$((j+1)); done; echo "$j"`);
|
|
189
|
+
assert.equal(seq.trim(), "60", "the bounded-poll row is false — `for _ in $(seq 1 60)` no longer runs 60 times");
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test("bash and sh split BOTH forms — which is why the bug hides", (t) => {
|
|
193
|
+
// The table's third column. Without it the section reads as a fact about
|
|
194
|
+
// loops rather than about zsh, and the reason a bash-tested loop ships broken
|
|
195
|
+
// goes unstated.
|
|
196
|
+
let ran = 0;
|
|
197
|
+
for (const shell of ["sh", "bash"]) {
|
|
198
|
+
if (!hasShell(shell)) continue;
|
|
199
|
+
ran++;
|
|
200
|
+
const out = execFileSync(shell, ["-c", `prs=$(printf '${LIST}'); i=0; for pr in $prs; do i=$((i+1)); done; echo "$i"`], {
|
|
201
|
+
encoding: "utf8",
|
|
202
|
+
});
|
|
203
|
+
assert.equal(out.trim(), "3", `${shell} no longer splits a bare parameter expansion; the table's bash/sh column is wrong`);
|
|
204
|
+
}
|
|
205
|
+
if (!ran) t.skip("neither sh nor bash on PATH");
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
test("the prescribed remedy is line-exact where `$(printf …)` is not", (t) => {
|
|
209
|
+
if (!needs(t, "zsh")) return;
|
|
210
|
+
// Why the remedy is `while IFS= read -r` and not "either form": the inline
|
|
211
|
+
// one splits on every whitespace character, so it is safe for PR numbers and
|
|
212
|
+
// wrong for anything that can contain a space. Measured, not asserted.
|
|
213
|
+
const blob = `blob=$(printf 'two words\\nsecond\\n')`;
|
|
214
|
+
const viaSubst = sh("zsh", `${blob}\ni=0; for x in $(printf '%s\\n' "$blob"); do i=$((i+1)); done; echo "$i"`);
|
|
215
|
+
const viaRead = sh("zsh", `${blob}\ni=0; while IFS= read -r x; do i=$((i+1)); done <<EOF\n$blob\nEOF\necho "$i"`);
|
|
216
|
+
assert.equal(viaSubst.trim(), "3", "`$(printf …)` stopped splitting on the space inside a value; the section's caveat is stale");
|
|
217
|
+
assert.equal(viaRead.trim(), "2", "`while IFS= read -r` stopped being line-exact; the prescribed remedy no longer holds");
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
test("an inner command without `</dev/null` eats the loop's stdin", (t) => {
|
|
221
|
+
if (!needs(t, "zsh")) return;
|
|
222
|
+
// The half nothing in this repo carried before #854, and the reason it
|
|
223
|
+
// matters: the failure signature is IDENTICAL to the word-split bug, so a
|
|
224
|
+
// reader who fixes the loop correctly and omits this sees no change and
|
|
225
|
+
// concludes the fix did not work.
|
|
226
|
+
const loop = (inner) => `i=0; while IFS= read -r n; do i=$((i+1)); ${inner}; done <<EOF\n849\n850\n852\nEOF\necho "$i"`;
|
|
227
|
+
assert.equal(sh("zsh", loop("cat >/dev/null")).trim(), "1", "an unredirected inner reader no longer eats the loop's stdin; re-measure the rule");
|
|
228
|
+
assert.equal(sh("zsh", loop("cat >/dev/null </dev/null")).trim(), "3", "`</dev/null` no longer protects the loop's stdin");
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test("the probe-could-not-look rule is stated as its own instruction", () => {
|
|
232
|
+
// #854's third ruling. It is a sentence, not a clause hanging off the loop
|
|
233
|
+
// rule, because a monitor that `continue`s on an unreadable probe is blind
|
|
234
|
+
// whether or not its loop iterates.
|
|
235
|
+
assert.match(
|
|
236
|
+
TRAPS,
|
|
237
|
+
phrase("**A probe that could not look emits an event; it never `continue`s.**"),
|
|
238
|
+
"Shell traps lost the probe-could-not-look instruction",
|
|
239
|
+
);
|
|
240
|
+
assert.match(
|
|
241
|
+
TRAPS,
|
|
242
|
+
/transition event, not silence/,
|
|
243
|
+
"the probe rule no longer routes to phase 3's full statement, so the sentence is all a reader gets",
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// --- run-merge-bot.md's monitor, lifted from the fence and executed ----------
|
|
248
|
+
|
|
249
|
+
// Anchored on what the block contains, never on its ordinal. Exactly one fence
|
|
250
|
+
// in that document emits the label event.
|
|
251
|
+
const monitorBlocks = [...MERGE_BOT.matchAll(/```bash\n([\s\S]*?)```/g)]
|
|
252
|
+
.map((m) => m[1])
|
|
253
|
+
.filter((b) => b.includes("ready-to-merge label added"));
|
|
254
|
+
assert.equal(
|
|
255
|
+
monitorBlocks.length,
|
|
256
|
+
1,
|
|
257
|
+
`expected exactly one bash block emitting the ready-to-merge event, found ${monitorBlocks.length} — update this test`,
|
|
258
|
+
);
|
|
259
|
+
const MONITOR = monitorBlocks[0];
|
|
260
|
+
|
|
261
|
+
const WATCH_LOOP = "while true; do";
|
|
262
|
+
assert.ok(MONITOR.includes(WATCH_LOOP), `the monitor no longer opens with '${WATCH_LOOP}'; the harness caps the run on that line — update this test`);
|
|
263
|
+
|
|
264
|
+
// `gh` returns 849,850 on the seed call and 849,850,852 after it: one PR whose
|
|
265
|
+
// label genuinely appeared after arming. `sleep` is a no-op so the cap is the
|
|
266
|
+
// tick count, not wall time.
|
|
267
|
+
stub(
|
|
268
|
+
"gh",
|
|
269
|
+
`#!/bin/sh
|
|
270
|
+
c="$CALLS/n"
|
|
271
|
+
n=$(cat "$c" 2>/dev/null || echo 0); n=$((n+1)); echo "$n" >"$c"
|
|
272
|
+
if [ "$n" -le 1 ]; then printf '849\\n850\\n'; else printf '849\\n850\\n852\\n'; fi
|
|
273
|
+
`,
|
|
274
|
+
);
|
|
275
|
+
stub("sleep", "#!/bin/sh\nexit 0\n");
|
|
276
|
+
|
|
277
|
+
const runMonitor = (shell, body, ticks = 2) => {
|
|
278
|
+
const calls = mkdtempSync(join(tmpdir(), "shell-traps-calls-"));
|
|
279
|
+
const capped = body.replace(WATCH_LOOP, `tick=0\nwhile tick=$((tick+1)); [ "$tick" -le ${ticks} ]; do`);
|
|
280
|
+
return sh(shell, capped, { CALLS: calls });
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const events = (out) => out.split("\n").filter((l) => l.includes("ready-to-merge label added")).map((l) => l.trim());
|
|
284
|
+
|
|
285
|
+
// A loop whose operand is a bare parameter — `for n in $cur`, `for n in ${cur}`.
|
|
286
|
+
// `$(` is deliberately excluded: that is the form that splits, and refusing it
|
|
287
|
+
// would be this ticket's own inversion re-committed as a test.
|
|
288
|
+
const COLLAPSING_LOOP = /for\s+\w+\s+in\s+\$\{?\w/;
|
|
289
|
+
|
|
290
|
+
// Line continuations are folded to a space FIRST: a backslash-newline breaks
|
|
291
|
+
// the regex's `\s+` run (the literal `\` is not whitespace), so a wrapped
|
|
292
|
+
// `for n in \` / ` $cur` reads as safe when it collapses under zsh exactly
|
|
293
|
+
// like the unwrapped form. Comments are stripped second: both blocks NAME the
|
|
294
|
+
// forbidden form in a comment so the next editor sees the rule at the line it
|
|
295
|
+
// applies to, and matching that would make the fix look like the defect.
|
|
296
|
+
// Removing text can only delete matches, never create one, so the crude sweep
|
|
297
|
+
// is safe here even where it clips the tail of a string containing `#`.
|
|
298
|
+
const code = (block) => block.replace(/\\\n/g, " ").replace(/(^|\s)#.*$/gm, "$1");
|
|
299
|
+
|
|
300
|
+
test("no prescriptive loop in either document iterates a bare parameter", () => {
|
|
301
|
+
// The behavioural tests above catch this only where zsh exists, and CI runs
|
|
302
|
+
// ubuntu-latest, which ships none: measured, reverting the monitor to `for n
|
|
303
|
+
// in $cur` leaves the whole suite GREEN on a zsh-less runner, because sh and
|
|
304
|
+
// bash split it correctly. That is the same "the bug hides in whichever shell
|
|
305
|
+
// you tested in" mechanism one level up, aimed at the pin instead of the
|
|
306
|
+
// runbook — so the shape gets an assertion that needs no shell at all.
|
|
307
|
+
const blocks = [
|
|
308
|
+
["run-merge-bot.md's stay-armed monitor", MONITOR],
|
|
309
|
+
["run-team/SKILL.md's degraded-watcher block", (() => {
|
|
310
|
+
const b = [...SKILL.matchAll(/```sh\n([\s\S]*?)```/g)].map((m) => m[1]).filter((x) => x.includes("WATCHER DEGRADED"));
|
|
311
|
+
assert.equal(b.length, 1, `expected exactly one sh block emitting WATCHER DEGRADED, found ${b.length} — update this test`);
|
|
312
|
+
return b[0];
|
|
313
|
+
})()],
|
|
314
|
+
];
|
|
315
|
+
for (const [name, block] of blocks) {
|
|
316
|
+
const hit = code(block).match(COLLAPSING_LOOP);
|
|
317
|
+
assert.equal(
|
|
318
|
+
hit,
|
|
319
|
+
null,
|
|
320
|
+
`${name} iterates a bare parameter (\`${hit?.[0]}\`). Under zsh that runs ONCE with the whole list glued into one value — measured. Feed it from a heredoc with \`while IFS= read -r\`, or iterate \`$(printf '%s\\n' "$var")\`; see run-team/SKILL.md's Shell traps.`,
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
test("the stay-armed monitor reports the ONE new PR, under zsh as well as sh", () => {
|
|
326
|
+
for (const shell of ["sh", "bash", "zsh"]) {
|
|
327
|
+
if (!hasShell(shell)) continue;
|
|
328
|
+
const got = events(runMonitor(shell, MONITOR));
|
|
329
|
+
assert.deepEqual(
|
|
330
|
+
got,
|
|
331
|
+
["ready-to-merge label added: PR #852"],
|
|
332
|
+
// Two different regressions land here and the message has to tell them
|
|
333
|
+
// apart, or it teaches the wrong discriminator — this ticket's own
|
|
334
|
+
// failure mode. ONE event naming several numbers is the #854 collapse:
|
|
335
|
+
// the loop iterated once over the whole list. SEVERAL events, or one
|
|
336
|
+
// naming an already-handled PR, is the `seen` seed missing instead.
|
|
337
|
+
`${shell}: expected exactly one event naming PR #852, got ${JSON.stringify(got)}. One event naming several numbers = the #854 loop collapse; extra events naming 849/850 = the \`seen\` seed is gone.`,
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// Restores the two-phase stub the tests above rely on, so a case that swaps it
|
|
343
|
+
// for a fixed one cannot leak into whatever runs next.
|
|
344
|
+
const restoreGh = () =>
|
|
345
|
+
stub(
|
|
346
|
+
"gh",
|
|
347
|
+
`#!/bin/sh
|
|
348
|
+
c="$CALLS/n"
|
|
349
|
+
n=$(cat "$c" 2>/dev/null || echo 0); n=$((n+1)); echo "$n" >"$c"
|
|
350
|
+
if [ "$n" -le 1 ]; then printf '849\\n850\\n'; else printf '849\\n850\\n852\\n'; fi
|
|
351
|
+
`,
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
const SHELLS = ["sh", "bash", "zsh"].filter(hasShell);
|
|
355
|
+
|
|
356
|
+
test("the monitor stays silent when no label appeared", (t) => {
|
|
357
|
+
if (!SHELLS.length) return t.skip("no shell on PATH");
|
|
358
|
+
// The positive control's other half: a monitor that fires on an unchanged
|
|
359
|
+
// list is noise, and the seeded `seen` is what prevents it. Without this, a
|
|
360
|
+
// loop that emitted an event per tick would pass the test above on tick 1.
|
|
361
|
+
// Every shell, not just zsh — the seed is not a zsh concern.
|
|
362
|
+
stub("gh", "#!/bin/sh\nprintf '849\\n850\\n'\n");
|
|
363
|
+
try {
|
|
364
|
+
for (const shell of SHELLS) {
|
|
365
|
+
assert.deepEqual(events(runMonitor(shell, MONITOR, 3)), [], `${shell}: the monitor re-fires on an unchanged labeled set`);
|
|
366
|
+
}
|
|
367
|
+
} finally {
|
|
368
|
+
restoreGh();
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
test("the monitor does not fire on an empty labeled set", (t) => {
|
|
373
|
+
if (!SHELLS.length) return t.skip("no shell on PATH");
|
|
374
|
+
// The blank-line guard. A heredoc fed an empty `cur` still delivers one empty
|
|
375
|
+
// line, so without `[ -n "$n" ]` the block emits `PR #` — an event naming no
|
|
376
|
+
// PR, which is the same class of garbage the collapse produced.
|
|
377
|
+
stub("gh", "#!/bin/sh\nexit 0\n");
|
|
378
|
+
try {
|
|
379
|
+
for (const shell of SHELLS) {
|
|
380
|
+
const out = runMonitor(shell, MONITOR, 2);
|
|
381
|
+
assert.deepEqual(events(out), [], `${shell}: an empty labeled set produced an event:\n${out}`);
|
|
382
|
+
}
|
|
383
|
+
} finally {
|
|
384
|
+
restoreGh();
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
test("a failed poll is skipped without losing `seen` — the seed/tick guard is load-bearing", (t) => {
|
|
389
|
+
if (!SHELLS.length) return t.skip("no shell on PATH");
|
|
390
|
+
// #854 silently made `if cur=$(poll)` (and the seed's mirror of it) load-
|
|
391
|
+
// bearing for the FIRST time by moving `| tr` out of `poll()` and onto the
|
|
392
|
+
// call sites. Nothing pinned that before this test: fold `| tr` back INTO
|
|
393
|
+
// `poll()` — a "natural tidy-up", since `tr` now appears twice at the call
|
|
394
|
+
// sites — and `poll`'s exit status becomes `tr`'s, which is 0 regardless of
|
|
395
|
+
// whether the `gh` call underneath it failed. The guard stops guarding: a
|
|
396
|
+
// failed poll then reads as an empty labeled set, `seen` gets reassigned to
|
|
397
|
+
// blank, and the next successful poll fires one event per already-seen PR
|
|
398
|
+
// instead of staying silent on the ones it already reported.
|
|
399
|
+
stub(
|
|
400
|
+
"gh",
|
|
401
|
+
`#!/bin/sh
|
|
402
|
+
c="$CALLS/n"
|
|
403
|
+
n=$(cat "$c" 2>/dev/null || echo 0); n=$((n+1)); echo "$n" >"$c"
|
|
404
|
+
if [ "$n" -eq 1 ]; then printf '849\\n850\\n'
|
|
405
|
+
elif [ "$n" -eq 2 ]; then exit 1
|
|
406
|
+
else printf '849\\n850\\n852\\n'
|
|
407
|
+
fi
|
|
408
|
+
`,
|
|
409
|
+
);
|
|
410
|
+
try {
|
|
411
|
+
for (const shell of SHELLS) {
|
|
412
|
+
const out = runMonitor(shell, MONITOR, 2);
|
|
413
|
+
assert.deepEqual(
|
|
414
|
+
events(out),
|
|
415
|
+
["ready-to-merge label added: PR #852"],
|
|
416
|
+
`${shell}: a poll that fails on one tick must not fire an event on that tick, and must not lose \`seen\` — expected exactly one event (PR #852) on the next successful poll, not a replay of 849/850:\n${out}`,
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
} finally {
|
|
420
|
+
restoreGh();
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
// #2108. A stub `gh` that stops at `--limit` the way gh does — 30 when the
|
|
425
|
+
// flag is absent, exit 0, no warning — holding `totals[k]` labelled PRs
|
|
426
|
+
// (numbered from 1) on its k-th call and the last entry thereafter.
|
|
427
|
+
const cappingGh = (totals) =>
|
|
428
|
+
stub(
|
|
429
|
+
"gh",
|
|
430
|
+
`#!/bin/sh
|
|
431
|
+
c="$CALLS/n"
|
|
432
|
+
n=$(cat "$c" 2>/dev/null || echo 0); n=$((n+1)); echo "$n" >"$c"
|
|
433
|
+
limit=30
|
|
434
|
+
while [ $# -gt 0 ]; do [ "$1" = --limit ] && limit=$2; shift; done
|
|
435
|
+
total=$(echo "${totals.join(" ")}" | awk -v k="$n" '{ print (k <= NF) ? $k : $NF }')
|
|
436
|
+
i=0; while [ "$i" -lt "$total" ] && [ "$i" -lt "$limit" ]; do i=$((i+1)); echo "$i"; done
|
|
437
|
+
`,
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
test("#2108: a poll that fills its --limit says so once, clears once, and fires no label event for it", (t) => {
|
|
441
|
+
if (!SHELLS.length) return t.skip("no shell on PATH");
|
|
442
|
+
// Two runs. 250 labelled on the seed and tick 1, then 5: the cap sustained
|
|
443
|
+
// across polls must still speak once. 250 on the seed alone, then 5: a
|
|
444
|
+
// monitor that arms on a capped seed must say so at arming, not wait for a
|
|
445
|
+
// capped tick that never comes. Every one of the 5 is already in `seen`, so
|
|
446
|
+
// the only lines either run may print are the cap's own pair.
|
|
447
|
+
for (const [totals, ticks] of [[[250, 250, 5], 3], [[250, 5], 1]]) {
|
|
448
|
+
cappingGh(totals);
|
|
449
|
+
try {
|
|
450
|
+
for (const shell of SHELLS) {
|
|
451
|
+
const lines = runMonitor(shell, MONITOR, ticks).split("\n");
|
|
452
|
+
const said = (s) => lines.filter((l) => l.includes(s)).length;
|
|
453
|
+
const run = `${shell}, totals ${totals.join("/")}`;
|
|
454
|
+
assert.equal(said("hit its --limit 200"), 1, `${run}: a full page must be reported exactly once:\n${lines.join("\n")}`);
|
|
455
|
+
assert.equal(said("under its --limit 200"), 1, `${run}: a poll back under the cap must clear the latch exactly once:\n${lines.join("\n")}`);
|
|
456
|
+
assert.deepEqual(events(lines.join("\n")), [], `${run}: the cap's lines were read as label events`);
|
|
457
|
+
}
|
|
458
|
+
} finally {
|
|
459
|
+
restoreGh();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
test("#2108: a labelled set past gh's bare default of 30 is read whole, and says nothing about a cap", (t) => {
|
|
465
|
+
if (!SHELLS.length) return t.skip("no shell on PATH");
|
|
466
|
+
// The input the guard must ACCEPT. 35 seeded, then #36 labelled: a poll cut
|
|
467
|
+
// at 30 would never see #36, and 36 is far under the explicit limit.
|
|
468
|
+
cappingGh([35, 36]);
|
|
469
|
+
try {
|
|
470
|
+
for (const shell of SHELLS) {
|
|
471
|
+
const out = runMonitor(shell, MONITOR, 2);
|
|
472
|
+
assert.deepEqual(events(out), ["ready-to-merge label added: PR #36"], `${shell}: the poll no longer reads past gh's default of 30:\n${out}`);
|
|
473
|
+
assert.doesNotMatch(out, /--limit/, `${shell}: a poll under its limit reported a cap:\n${out}`);
|
|
474
|
+
}
|
|
475
|
+
} finally {
|
|
476
|
+
restoreGh();
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
test("#2108: a poll one short of its explicit --limit is read whole, and says nothing about a cap", (t) => {
|
|
481
|
+
if (!SHELLS.length) return t.skip("no shell on PATH");
|
|
482
|
+
// The input the guard must ACCEPT: 199 is a whole answer, not a capped one,
|
|
483
|
+
// and every one of them fires its own label event — unlike the 35/36 case
|
|
484
|
+
// above, which only clears gh's bare default of 30 and never approaches the
|
|
485
|
+
// 200 this monitor actually asks for.
|
|
486
|
+
cappingGh([0, 199]);
|
|
487
|
+
try {
|
|
488
|
+
for (const shell of SHELLS) {
|
|
489
|
+
const out = runMonitor(shell, MONITOR, 2);
|
|
490
|
+
assert.equal(events(out).length, 199, `${shell}: a poll one short of its limit reported fewer label events than PRs returned:\n${out}`);
|
|
491
|
+
assert.doesNotMatch(out, /--limit/, `${shell}: a poll under its limit reported a cap:\n${out}`);
|
|
492
|
+
}
|
|
493
|
+
} finally {
|
|
494
|
+
restoreGh();
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
test("run-merge-bot.md's bounded poll is left alone — it is not an instance", () => {
|
|
499
|
+
// The ticket's filer retracted the claim that step 1's poll was a second
|
|
500
|
+
// instance of this bug, and a later reader "fixing" it would be acting on the
|
|
501
|
+
// retracted version. Pin the form so that edit has to argue with a test.
|
|
502
|
+
assert.match(
|
|
503
|
+
MERGE_BOT,
|
|
504
|
+
phrase("for _ in $(seq 1 60); do"),
|
|
505
|
+
"step 1's bounded poll was rewritten — it is a command substitution, it splits correctly (60 iterations, measured), and #854's filer retracted the claim that it was broken",
|
|
506
|
+
);
|
|
507
|
+
});
|