@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,372 @@
|
|
|
1
|
+
// #784. The degraded-watcher snippet in `run-team/SKILL.md` is prescriptive
|
|
2
|
+
// shell a controller copies verbatim, and it has now shipped a defect that its
|
|
3
|
+
// OWN surrounding prose already ruled out — three times. So this pin RUNS the
|
|
4
|
+
// block rather than matching strings in it: it lifts the fenced snippet out of
|
|
5
|
+
// the document, stubs `gh`, `ci-state.mjs` and `sleep` on PATH, and drives it
|
|
6
|
+
// through the states the prose promises: every probe latched at the level its
|
|
7
|
+
// cause lives at, each latch one-shot in both directions, one sleep per tick
|
|
8
|
+
// whatever went wrong, an ordinary not-green left alone, and the per-PR loop
|
|
9
|
+
// splitting per PR under zsh as well as sh.
|
|
10
|
+
//
|
|
11
|
+
// THE CEILING: the stubs cover only the three probes the block makes, and
|
|
12
|
+
// `sleep` is counted rather than taken, so this measures the block's control
|
|
13
|
+
// flow and nothing about real GitHub, real timing, or the "your normal handling
|
|
14
|
+
// of $st" line the block leaves as a placeholder. It also assumes the block
|
|
15
|
+
// stays a `while :; do` tick loop — that string is how the harness caps the run,
|
|
16
|
+
// and a rewrite to another loop form must update this test rather than the
|
|
17
|
+
// document.
|
|
18
|
+
import { test } from "node:test";
|
|
19
|
+
import assert from "node:assert/strict";
|
|
20
|
+
import { execFileSync } from "node:child_process";
|
|
21
|
+
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, chmodSync } from "node:fs";
|
|
22
|
+
import { tmpdir } from "node:os";
|
|
23
|
+
import { join } from "node:path";
|
|
24
|
+
|
|
25
|
+
// The stubs shell out to jq, and so does the block under test. Without it every
|
|
26
|
+
// gate would fail identically and the suite would go green on a block that
|
|
27
|
+
// never ran — the vacuous pass this file exists to prevent.
|
|
28
|
+
try {
|
|
29
|
+
execFileSync("jq", ["--version"], { stdio: "ignore" });
|
|
30
|
+
} catch {
|
|
31
|
+
throw new Error("jq is required to exercise the watcher block; install it before running this suite");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const SKILL = readFileSync(join(import.meta.dirname, "..", "skills", "run-team", "SKILL.md"), "utf8");
|
|
35
|
+
|
|
36
|
+
// Anchored on what the block CONTAINS, never on its ordinal: a fence inserted
|
|
37
|
+
// ahead of it would re-rot an index. Exactly one block may say WATCHER DEGRADED.
|
|
38
|
+
const blocks = [...SKILL.matchAll(/```sh\n([\s\S]*?)```/g)]
|
|
39
|
+
.map((m) => m[1])
|
|
40
|
+
.filter((b) => b.includes("WATCHER DEGRADED"));
|
|
41
|
+
assert.equal(blocks.length, 1, `expected exactly one sh block emitting WATCHER DEGRADED, found ${blocks.length} — update this test`);
|
|
42
|
+
const BLOCK = blocks[0];
|
|
43
|
+
|
|
44
|
+
const DIR = mkdtempSync(join(tmpdir(), "watcher-block-"));
|
|
45
|
+
const BIN = join(DIR, "bin");
|
|
46
|
+
mkdirSync(BIN);
|
|
47
|
+
|
|
48
|
+
const stub = (name, body) => {
|
|
49
|
+
const p = join(BIN, name);
|
|
50
|
+
writeFileSync(p, body);
|
|
51
|
+
chmodSync(p, 0o755);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Every *SEQ variable names a file of one value per line, consumed one per
|
|
55
|
+
// invocation, so a scenario can change what a probe returns between ticks. The
|
|
56
|
+
// matching fixed variable is the alternative. `gh` needs this for RL too: a
|
|
57
|
+
// latch is one-shot only if it stays quiet across a SUSTAINED outage and speaks
|
|
58
|
+
// once on recovery, and neither is observable from a single static budget.
|
|
59
|
+
// PRSSEQ is the same for the open-PR list, one space-separated list per line.
|
|
60
|
+
//
|
|
61
|
+
// `pr list` stops at `--limit` — 30 when the flag is absent — the way gh does
|
|
62
|
+
// (#2108): exit 0, no warning, the rest simply not printed. A block that lost
|
|
63
|
+
// its --limit is therefore cut at 30 here exactly as it would be on GitHub.
|
|
64
|
+
stub("gh", `#!/bin/sh
|
|
65
|
+
next() {
|
|
66
|
+
if [ -n "$1" ]; then
|
|
67
|
+
n=$(cat "$1.n" 2>/dev/null || echo 0); n=$((n+1)); echo "$n" > "$1.n"
|
|
68
|
+
sed -n "\${n}p" "$1"
|
|
69
|
+
else
|
|
70
|
+
printf '%s\\n' "$2"
|
|
71
|
+
fi
|
|
72
|
+
}
|
|
73
|
+
case "$2" in
|
|
74
|
+
list)
|
|
75
|
+
if [ "$(next "$LISTSEQ" "\${LISTMODE-ok}")" = err ]; then exit 1; fi
|
|
76
|
+
limit=30
|
|
77
|
+
while [ $# -gt 0 ]; do [ "$1" = --limit ] && limit=$2; shift; done
|
|
78
|
+
i=0
|
|
79
|
+
for p in $(next "$PRSSEQ" "$PRS"); do
|
|
80
|
+
i=$((i+1)); [ "$i" -le "$limit" ] || break
|
|
81
|
+
echo "$p"
|
|
82
|
+
done ;;
|
|
83
|
+
*) next "$RLSEQ" "\${RL-5000}" ;;
|
|
84
|
+
esac
|
|
85
|
+
`);
|
|
86
|
+
|
|
87
|
+
// $SEQ names a global sequence file; $SEQ.<pr>, when it exists, overrides it for
|
|
88
|
+
// that PR with its own file and its own counter. Without that per-PR override no
|
|
89
|
+
// scenario can hold two PRs in DIFFERENT states across more than one tick, which
|
|
90
|
+
// is the shape every multi-PR latch mutation lives in.
|
|
91
|
+
stub("ci-state.mjs", `#!/bin/sh
|
|
92
|
+
pr=$2
|
|
93
|
+
seq=$SEQ
|
|
94
|
+
[ -n "$seq" ] && [ -f "$seq.$pr" ] && seq="$seq.$pr"
|
|
95
|
+
if [ -n "$seq" ]; then
|
|
96
|
+
n=$(cat "$seq.n" 2>/dev/null || echo 0); n=$((n+1)); echo "$n" > "$seq.n"
|
|
97
|
+
mode=$(sed -n "\${n}p" "$seq")
|
|
98
|
+
else
|
|
99
|
+
mode=$MODE
|
|
100
|
+
fi
|
|
101
|
+
case "$mode" in
|
|
102
|
+
empty) exit 1 ;;
|
|
103
|
+
garbage) echo '<html>429</html>'; exit 1 ;;
|
|
104
|
+
ratelimited) printf '{"pr":%s,"verdict":"rate-limited","reasons":["refused"]}\\n' "$pr"; exit 1 ;;
|
|
105
|
+
emptyobj) echo '{}'; exit 1 ;;
|
|
106
|
+
nulldoc) echo 'null'; exit 1 ;;
|
|
107
|
+
nullverdict) printf '{"pr":%s,"verdict":null}\\n' "$pr"; exit 1 ;;
|
|
108
|
+
blind42) [ "$pr" = 42 ] && exit 1; printf '{"pr":%s,"verdict":"not-green"}\\n' "$pr"; exit 1 ;;
|
|
109
|
+
*) printf '{"pr":%s,"verdict":"not-green"}\\n' "$pr"; exit 1 ;;
|
|
110
|
+
esac
|
|
111
|
+
`);
|
|
112
|
+
|
|
113
|
+
// Counted, never taken — the block's pacing is the thing under test and a real
|
|
114
|
+
// 120s sleep would make the suite unrunnable.
|
|
115
|
+
stub("sleep", `#!/bin/sh
|
|
116
|
+
echo "SLEEP $1"
|
|
117
|
+
`);
|
|
118
|
+
|
|
119
|
+
const TICK_LOOP = "while :; do";
|
|
120
|
+
assert.ok(BLOCK.includes(TICK_LOOP), `the block no longer opens with '${TICK_LOOP}'; the harness caps the run on that line — update this test`);
|
|
121
|
+
|
|
122
|
+
function run(env, ticks, shell = "sh", { strict = false } = {}) {
|
|
123
|
+
const harness = BLOCK
|
|
124
|
+
.replace("~/.fleet/bin/fleet-run ci-state.mjs", "ci-state.mjs")
|
|
125
|
+
.replace(TICK_LOOP, `tick=0\nwhile tick=$((tick+1)); [ "$tick" -le ${ticks} ]; do`);
|
|
126
|
+
const path = join(DIR, "harness.sh");
|
|
127
|
+
// #1334: `strict` prefixes `set -eu` onto the harness so a regression to an
|
|
128
|
+
// unseeded latch (unbound under -u) or an unguarded `st=$(...)` (killed
|
|
129
|
+
// under -e by ci-state.mjs's ordinary non-zero not-green exit) fails LOUD
|
|
130
|
+
// here instead of shipping silent again.
|
|
131
|
+
writeFileSync(path, strict ? `set -eu\n${harness}` : harness);
|
|
132
|
+
return execFileSync(shell, [path], {
|
|
133
|
+
encoding: "utf8",
|
|
134
|
+
env: { ...process.env, ...env, PATH: `${BIN}:${process.env.PATH}` },
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const hasShell = (s) => {
|
|
139
|
+
try {
|
|
140
|
+
execFileSync(s, ["-c", "exit 0"], { stdio: "ignore" });
|
|
141
|
+
return true;
|
|
142
|
+
} catch {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const count = (out, needle) => out.split("\n").filter((l) => l.includes(needle)).length;
|
|
148
|
+
|
|
149
|
+
// The WATCHER lines in order, as "D42"/"R42" — for the multi-PR cases, where
|
|
150
|
+
// which PR spoke and when both matter and a bare count hides a reordering.
|
|
151
|
+
const events = (out) =>
|
|
152
|
+
out
|
|
153
|
+
.split("\n")
|
|
154
|
+
.filter((l) => l.startsWith("WATCHER"))
|
|
155
|
+
.map((l) => `${l.includes("DEGRADED") ? "D" : "R"}${l.match(/#(\d+)/)?.[1] ?? "*"}`);
|
|
156
|
+
|
|
157
|
+
test("a self-named rate-limited payload is an outage, not a reading", () => {
|
|
158
|
+
// ci-state emits {"verdict":"rate-limited"} on stdout and exits non-zero. It
|
|
159
|
+
// is parseable JSON, so a gate testing parseability alone clears the latch,
|
|
160
|
+
// prints RECOVERED, and hands the outage payload downstream as CI state.
|
|
161
|
+
const seq = join(DIR, "seq-ratelimited");
|
|
162
|
+
writeFileSync(seq, "empty\nratelimited\n");
|
|
163
|
+
const out = run({ SEQ: seq, PRS: "7" }, 2);
|
|
164
|
+
assert.equal(count(out, "WATCHER DEGRADED"), 1, `expected one DEGRADED line, got:\n${out}`);
|
|
165
|
+
assert.equal(
|
|
166
|
+
count(out, "WATCHER RECOVERED"),
|
|
167
|
+
0,
|
|
168
|
+
`a rate-limited payload cleared the latch — the gate is testing parseability, not the verdict:\n${out}`,
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("unparseable and empty payloads are outages too", () => {
|
|
173
|
+
for (const MODE of ["empty", "garbage"]) {
|
|
174
|
+
const out = run({ MODE, PRS: "7" }, 1);
|
|
175
|
+
assert.equal(count(out, "WATCHER DEGRADED"), 1, `${MODE}: expected one DEGRADED line, got:\n${out}`);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test("the payload latch is keyed by PR, not shared across them", () => {
|
|
180
|
+
// One persistently blind PR beside one healthy PR. A shared scalar latch is
|
|
181
|
+
// re-cleared by the healthy PR every tick, so the pair repeats forever — the
|
|
182
|
+
// per-tick volume the latch exists to prevent, and every RECOVERED in it
|
|
183
|
+
// falsely asserts the watch is alive for a PR that is still blind.
|
|
184
|
+
const out = run({ MODE: "blind42", PRS: "42 43" }, 3);
|
|
185
|
+
assert.equal(count(out, "WATCHER DEGRADED"), 1, `expected one DEGRADED across three ticks, got:\n${out}`);
|
|
186
|
+
assert.equal(count(out, "WATCHER RECOVERED"), 0, `a healthy PR cleared another PR's latch:\n${out}`);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test("one PR recovers without disturbing a sibling that is still blind", () => {
|
|
190
|
+
// Two PRs, four ticks, blind at different times — the only shape in which the
|
|
191
|
+
// per-PR latch's bookkeeping is observable at all. #4 is healthy on tick 1 and
|
|
192
|
+
// blind thereafter; #42 is blind from tick 1 and readable from tick 3. Each
|
|
193
|
+
// must announce itself exactly once in each direction, and #4's numbering is
|
|
194
|
+
// deliberately a prefix of #42's so the `case " $blind " in *" $pr "*` space
|
|
195
|
+
// anchoring is under test too.
|
|
196
|
+
//
|
|
197
|
+
// Three latch mutations die here and survive every other case in this file:
|
|
198
|
+
// wiping `blind` wholesale on any recovery (#4 re-fires on tick 4 -> 3
|
|
199
|
+
// DEGRADED), overwriting `blind="$pr"` instead of appending (neither PR stays
|
|
200
|
+
// latched -> 5 DEGRADED, 0 RECOVERED), and dropping the spaces from the latch
|
|
201
|
+
// test (#4 matches inside "42" and its outage is swallowed -> 1 DEGRADED).
|
|
202
|
+
const seq = join(DIR, "seq-siblings");
|
|
203
|
+
writeFileSync(`${seq}.4`, "normal\nempty\nempty\nempty\n");
|
|
204
|
+
writeFileSync(`${seq}.42`, "empty\nempty\nnormal\nnormal\n");
|
|
205
|
+
const out = run({ SEQ: seq, PRS: "4 42" }, 4);
|
|
206
|
+
// The ordered sequence, not four counts: the anchoring mutant only DELAYS #4's
|
|
207
|
+
// line to the tick #42's latch clears, so it lands on the same two-DEGRADED,
|
|
208
|
+
// one-RECOVERED totals the real block does and is invisible to counting.
|
|
209
|
+
assert.deepEqual(events(out), ["D42", "D4", "R42"], `wrong events, or in the wrong order:\n${out}`);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test("pacing lives in one place — a budget outage does not multiply by open PRs", () => {
|
|
213
|
+
// A sleep inside the per-PR pass turns 8 open PRs into 8 pauses per tick,
|
|
214
|
+
// against this section's own measured 24s outage reset.
|
|
215
|
+
const budget = run({ RL: "5", PRS: "1 2 3 4 5 6 7 8" }, 1);
|
|
216
|
+
assert.equal(count(budget, "SLEEP"), 1, `budget outage: expected one sleep per tick regardless of PR count, got:\n${budget}`);
|
|
217
|
+
assert.equal(count(budget, "WATCHER DEGRADED"), 1, budget);
|
|
218
|
+
// Same property one level down: a sleep in the per-PR degraded branch
|
|
219
|
+
// multiplies the same way, and the budget case above cannot see it because
|
|
220
|
+
// the per-PR pass never runs under a budget outage.
|
|
221
|
+
const payload = run({ MODE: "empty", PRS: "1 2 3 4 5 6 7 8" }, 1);
|
|
222
|
+
assert.equal(count(payload, "SLEEP"), 1, `payload outage: expected one sleep per tick regardless of PR count, got:\n${payload}`);
|
|
223
|
+
// And once more on the healthy path, which neither case above reaches: both
|
|
224
|
+
// route around the block's normal-handling line — the budget outage never
|
|
225
|
+
// enters the per-PR pass, the payload outage `continue`s before it. A sleep
|
|
226
|
+
// planted on that line is invisible to every other test in this file.
|
|
227
|
+
const healthy = run({ MODE: "normal", PRS: "1 2 3 4 5 6 7 8" }, 1);
|
|
228
|
+
assert.equal(count(healthy, "SLEEP"), 1, `healthy path: expected one sleep per tick regardless of PR count, got:\n${healthy}`);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test("a degraded payload tick still reaches the loop's own pacing", () => {
|
|
232
|
+
// A degraded branch that continues the OUTER loop skips the tail sleep and
|
|
233
|
+
// busy-spins probe pairs during exactly the outage it is reporting.
|
|
234
|
+
const out = run({ MODE: "empty", PRS: "7" }, 3);
|
|
235
|
+
assert.equal(count(out, "SLEEP"), 3, `every tick must reach the tail sleep, got:\n${out}`);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
test("a non-numeric budget read is an outage, not a budget", () => {
|
|
239
|
+
// `.resources.core.remaining` missing from the response yields `null`, and
|
|
240
|
+
// `[ null -lt 200 ]` errors — silently, under the block's own 2>/dev/null.
|
|
241
|
+
for (const RL of ["null", ""]) {
|
|
242
|
+
const out = run({ RL, PRS: "7" }, 1);
|
|
243
|
+
assert.equal(count(out, "WATCHER DEGRADED"), 1, `RL=${RL || "(empty)"} fell through to polling with no degraded line:\n${out}`);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test("an ordinary not-green PR never trips the outage path", () => {
|
|
248
|
+
const out = run({ MODE: "normal", PRS: "7" }, 3);
|
|
249
|
+
assert.equal(count(out, "WATCHER"), 0, `not-green is a frequent, ordinary state that exits non-zero:\n${out}`);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
test("#1334: the block survives set -eu on tick 1, on every probe path", () => {
|
|
253
|
+
// budget_out/list_out/blind were read before ever being assigned — unbound
|
|
254
|
+
// under set -u — and `st=$(ci-state.mjs ...)` was an unguarded assignment
|
|
255
|
+
// from a command that exits non-zero on the ordinary not-green state,
|
|
256
|
+
// killing the shell under set -e before the block's own payload-gate logic
|
|
257
|
+
// ever ran. Both reintroduced the exact silence #784 exists to remove, and
|
|
258
|
+
// neither is visible to any test above since none of them run under -eu.
|
|
259
|
+
const healthy = run({ MODE: "normal", PRS: "7" }, 2, "sh", { strict: true });
|
|
260
|
+
assert.equal(count(healthy, "SLEEP"), 2, `set -eu: an ordinary not-green payload died before tick 2:\n${healthy}`);
|
|
261
|
+
const budget = run({ RL: "5", PRS: "7" }, 2, "sh", { strict: true });
|
|
262
|
+
assert.equal(count(budget, "SLEEP"), 2, `set -eu: a budget outage died before tick 2:\n${budget}`);
|
|
263
|
+
const list = run({ LISTMODE: "err", PRS: "7" }, 2, "sh", { strict: true });
|
|
264
|
+
assert.equal(count(list, "SLEEP"), 2, `set -eu: an open-PR list outage died before tick 2:\n${list}`);
|
|
265
|
+
const payload = run({ MODE: "empty", PRS: "7" }, 2, "sh", { strict: true });
|
|
266
|
+
assert.equal(count(payload, "SLEEP"), 2, `set -eu: an unparseable payload died before tick 2:\n${payload}`);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test("a payload with no verdict at all is an outage, not a reading", () => {
|
|
270
|
+
// `.verdict != "rate-limited"` never tests that a verdict EXISTS: {}, null and
|
|
271
|
+
// an explicit null field all evaluate `null != "rate-limited"` -> true and
|
|
272
|
+
// clear the gate, handing an empty or error object downstream as CI state.
|
|
273
|
+
for (const MODE of ["emptyobj", "nulldoc", "nullverdict"]) {
|
|
274
|
+
const out = run({ MODE, PRS: "7" }, 1);
|
|
275
|
+
assert.equal(count(out, "WATCHER DEGRADED"), 1, `${MODE} cleared the gate — it tests inequality, not presence:\n${out}`);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
test("a failing `gh pr list` is an outage, not zero open PRs", () => {
|
|
280
|
+
// The third probe, with the budget healthy: a non-quota failure (secondary
|
|
281
|
+
// limit, 5xx, token error) never lowers .resources.core.remaining, so the
|
|
282
|
+
// budget gate clears and an unguarded `for pr in $(gh pr list …)` iterates
|
|
283
|
+
// zero times over the empty substitution — no error, no latch, no line. Total
|
|
284
|
+
// silence per tick, which is the exact state this section exists to remove.
|
|
285
|
+
const out = run({ LISTMODE: "err", PRS: "7" }, 3);
|
|
286
|
+
assert.equal(count(out, "WATCHER DEGRADED"), 1, `expected one DEGRADED across three ticks, got:\n${out}`);
|
|
287
|
+
assert.equal(count(out, "SLEEP"), 3, `an unreadable PR list must still reach the tail sleep, got:\n${out}`);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
test("the open-PR list latch clears once on recovery, not once per tick", () => {
|
|
291
|
+
const seq = join(DIR, "seq-list");
|
|
292
|
+
writeFileSync(seq, "err\nok\nok\n");
|
|
293
|
+
const out = run({ LISTSEQ: seq, MODE: "normal", PRS: "7" }, 3);
|
|
294
|
+
assert.equal(count(out, "WATCHER DEGRADED"), 1, out);
|
|
295
|
+
assert.equal(count(out, "WATCHER RECOVERED"), 1, `expected exactly one RECOVERED, got:\n${out}`);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// #2108. `n` open PRs, numbered from 1, as the space-separated list $PRS takes.
|
|
299
|
+
const openPrs = (n) => Array.from({ length: n }, (_, i) => i + 1).join(" ");
|
|
300
|
+
const CAPPED = "hit its --limit";
|
|
301
|
+
|
|
302
|
+
test("#2108: an open-PR list that fills its --limit is a degraded cause, and the PRs it did return are still polled", () => {
|
|
303
|
+
// Every ci-state read is blind, so each PR the pass reached speaks once: the
|
|
304
|
+
// count of those lines is the count of PRs the block polled. 200 of 250 is
|
|
305
|
+
// the explicit limit at work; 30 would be gh's bare default.
|
|
306
|
+
const out = run({ MODE: "empty", PRS: openPrs(250) }, 1);
|
|
307
|
+
assert.equal(count(out, CAPPED), 1, `a full page of open PRs went unreported:\n${out}`);
|
|
308
|
+
assert.equal(count(out, "no usable ci-state reading"), 200, "the block no longer polls the 200 PRs its capped read returned");
|
|
309
|
+
assert.equal(count(out, "SLEEP"), 1);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
test("#2108: the cap latch is one-shot across ticks, and clears once when the list comes back under it", () => {
|
|
313
|
+
const seq = join(DIR, "seq-prs-cap");
|
|
314
|
+
writeFileSync(seq, `${openPrs(250)}\n${openPrs(250)}\n7\n7\n`);
|
|
315
|
+
const out = run({ PRSSEQ: seq, MODE: "normal" }, 4);
|
|
316
|
+
assert.equal(count(out, CAPPED), 1, `expected one capped DEGRADED across two capped ticks, got:\n${out}`);
|
|
317
|
+
assert.equal(count(out, "under its --limit"), 1, `expected exactly one RECOVERED for the cap, got:\n${out}`);
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
test("#2108: a list one short of the cap, and past gh's bare default of 30, is complete and says nothing", () => {
|
|
321
|
+
// The input the guard must ACCEPT: 199 is a whole answer, not a capped one,
|
|
322
|
+
// and every one of them is polled — not the 30 a missing --limit yields.
|
|
323
|
+
const out = run({ MODE: "empty", PRS: openPrs(199) }, 1);
|
|
324
|
+
assert.equal(count(out, CAPPED), 0, `a list under its limit was reported as capped:\n${out}`);
|
|
325
|
+
assert.equal(count(out, "no usable ci-state reading"), 199, "the block polled fewer PRs than the list returned");
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
test("the budget latch is one-shot across a sustained outage", () => {
|
|
329
|
+
// Its own semantics, not the payload latch's: a budget branch that lost its
|
|
330
|
+
// `[ -z "$budget_out" ]` guard spams a DEGRADED every tick during exactly the
|
|
331
|
+
// outage it is reporting, and no per-PR test can see it — the per-PR pass
|
|
332
|
+
// never runs while the budget is out.
|
|
333
|
+
const out = run({ RL: "5", PRS: "7" }, 3);
|
|
334
|
+
assert.equal(count(out, "WATCHER DEGRADED"), 1, `expected one DEGRADED across three ticks, got:\n${out}`);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
test("the budget latch clears once on recovery, not once per tick", () => {
|
|
338
|
+
// The mirror mutation: a RECOVERED branch that never resets budget_out re-fires
|
|
339
|
+
// on every later tick, so the recovery line stops meaning "the watch is alive
|
|
340
|
+
// again" and becomes the per-tick volume the latch exists to prevent.
|
|
341
|
+
const seq = join(DIR, "seq-rl");
|
|
342
|
+
writeFileSync(seq, "5\n5000\n5000\n");
|
|
343
|
+
const out = run({ RLSEQ: seq, MODE: "normal", PRS: "7" }, 3);
|
|
344
|
+
assert.equal(count(out, "WATCHER DEGRADED"), 1, out);
|
|
345
|
+
assert.equal(count(out, "WATCHER RECOVERED"), 1, `expected exactly one RECOVERED, got:\n${out}`);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
test("the per-PR loop splits per PR under zsh too, not once over the whole blob", () => {
|
|
349
|
+
// zsh word-splits a command substitution's RESULT but not a bare parameter
|
|
350
|
+
// expansion, so `for pr in $prs` runs ONE iteration there with every number
|
|
351
|
+
// glued into a single value (measured) while sh and bash split it correctly.
|
|
352
|
+
// A regression to the bare form is therefore invisible to every sh-only case
|
|
353
|
+
// above — and the same trap applies to the blind-latch removal loop, where it
|
|
354
|
+
// leaves a recovered PR latched forever.
|
|
355
|
+
for (const shell of ["sh", "bash", "zsh"]) {
|
|
356
|
+
if (!hasShell(shell)) continue;
|
|
357
|
+
const out = run({ MODE: "empty", PRS: "42 43" }, 1, shell);
|
|
358
|
+
assert.equal(count(out, "WATCHER DEGRADED"), 2, `${shell}: expected one DEGRADED per PR, got:\n${out}`);
|
|
359
|
+
assert.ok(out.includes("#42") && out.includes("#43"), `${shell}: PR numbers were not split individually:\n${out}`);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
test("a recovered PR leaves the blind latch under zsh too", () => {
|
|
364
|
+
for (const shell of ["sh", "bash", "zsh"]) {
|
|
365
|
+
if (!hasShell(shell)) continue;
|
|
366
|
+
const seq = join(DIR, `seq-blind-${shell}`);
|
|
367
|
+
// One PR, blind on tick 1, readable on ticks 2 and 3.
|
|
368
|
+
writeFileSync(seq, "empty\nnormal\nnormal\n");
|
|
369
|
+
const out = run({ SEQ: seq, PRS: "42" }, 3, shell);
|
|
370
|
+
assert.equal(count(out, "WATCHER RECOVERED"), 1, `${shell}: the PR never left the blind list, so RECOVERED repeats:\n${out}`);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// #183. The watcher key was stated in two documents and the copies disagreed.
|
|
2
|
+
// `run-team/SKILL.md` keys on `<run-id>:<attempt>:<conclusion>` and names the
|
|
3
|
+
// `attempt`-less form as the bug that looks like it works — a rerun landing on
|
|
4
|
+
// the same conclusion regenerates an already-seen key and fires nothing, so the
|
|
5
|
+
// second failure is silent and reads exactly like a run still in progress.
|
|
6
|
+
// `references/ci-and-staleness.md` — the file SKILL.md sends a controller to for
|
|
7
|
+
// the why, from its CI paragraphs — still carried the two-part form at both of
|
|
8
|
+
// its own sites. A controller that follows the pointer reads the refuted form
|
|
9
|
+
// last, and last read is what it arms the Monitor with.
|
|
10
|
+
//
|
|
11
|
+
// THE CEILING: the tree-wide pin is literal. It catches the two-part key written
|
|
12
|
+
// as the token, not a paraphrase ("key on run id and conclusion") that means the
|
|
13
|
+
// same thing, and it cannot tell a stale copy from a deliberate counter-example —
|
|
14
|
+
// a document that wants to show the broken form has to update this test. Neither
|
|
15
|
+
// pin runs anything: ci-state.test.mjs owns `ci-state.mjs`'s behavior, and the
|
|
16
|
+
// Monitor is armed by a controller reading this prose, not by code under test.
|
|
17
|
+
// Accepted alongside that: a line break placed INSIDE the key token reddens the
|
|
18
|
+
// positive pin with no content change, because flat() rejoins the halves with a
|
|
19
|
+
// space the token does not contain. Measured on ci-and-staleness.md — textwrap
|
|
20
|
+
// at widths 30/40/52/55 with break_on_hyphens=True splits `<run-id>` and reddens
|
|
21
|
+
// it, while the same widths with break_on_hyphens=False, which is how this repo
|
|
22
|
+
// actually wraps, never split it and stayed green. Left undefended on purpose:
|
|
23
|
+
// a hyphen-seam special case in flat() buys nothing a realistic edit can reach,
|
|
24
|
+
// and the split renders as `<run- id>:...`, a broken code span this pin arguably
|
|
25
|
+
// SHOULD redden on.
|
|
26
|
+
import { test } from "node:test";
|
|
27
|
+
import assert from "node:assert/strict";
|
|
28
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
29
|
+
import { join } from "node:path";
|
|
30
|
+
|
|
31
|
+
const REPO = join(import.meta.dirname, "..");
|
|
32
|
+
const FLEET = REPO;
|
|
33
|
+
// The plugin root sits one level under the repo root since #1336's re-nest
|
|
34
|
+
// under `plugin/`; FLEET above walks up from THIS file's own location
|
|
35
|
+
// (`plugin/scripts/`), so it lands on the plugin root correctly regardless.
|
|
36
|
+
// The WALK below is still not `readdirSync(REPO)`: it must stay the plugin's
|
|
37
|
+
// own component dirs, because the scope note further down is a measured
|
|
38
|
+
// claim about which paths this test does and does not police, and a bare
|
|
39
|
+
// `readdirSync` would silently annex `docs/`, `.github/` and the rest of the
|
|
40
|
+
// repo root as out of scope.
|
|
41
|
+
const WALK = ["commands", "scripts", "skills", "agents"];
|
|
42
|
+
const CI_AND_STALENESS = readFileSync(
|
|
43
|
+
join(FLEET, "skills", "run-team", "references", "ci-and-staleness.md"),
|
|
44
|
+
"utf8",
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const THREE_PART = "`<run-id>:<attempt>:<conclusion>`";
|
|
48
|
+
// Derived, never written out: spelling the broken key literally here would put
|
|
49
|
+
// it back in the tree, and the sweep this ticket closes (`grep -rn 'run-id>:'
|
|
50
|
+
// commands scripts skills`) is supposed to come back all-three-part. Deriving it also
|
|
51
|
+
// means this file has nothing to exclude itself from the walk below for.
|
|
52
|
+
const TWO_PART = THREE_PART.replace("<attempt>:", "");
|
|
53
|
+
|
|
54
|
+
// Reflow-safety: markdown here hard-wraps at ~80 columns, so the multi-word
|
|
55
|
+
// SITES anchors below can land across a line break, and a pin that only matches
|
|
56
|
+
// the unwrapped form reddens on a rewrap that changed nothing. That is what
|
|
57
|
+
// flat() buys. The key tokens hold no spaces, so no space-wrapping reflow can
|
|
58
|
+
// split them and flattening is a no-op for those — see THE CEILING above for
|
|
59
|
+
// the break that does split one. Paragraphs are split off FIRST — the bound
|
|
60
|
+
// that keeps a positive pin from being satisfied by a neighbouring paragraph —
|
|
61
|
+
// and only then is whitespace inside each one flattened.
|
|
62
|
+
const flat = (s) => s.replace(/\s+/g, " ").trim();
|
|
63
|
+
const paragraphs = (text) => text.split(/\n\s*\n/).map(flat);
|
|
64
|
+
|
|
65
|
+
// Anchored on what the sentence SAYS, never on where it sits: an ordinal re-rots
|
|
66
|
+
// the moment anyone inserts ahead of it.
|
|
67
|
+
function paragraphSaying(text, anchor, label) {
|
|
68
|
+
const hits = paragraphs(text).filter((p) => p.includes(anchor));
|
|
69
|
+
assert.equal(hits.length, 1, `${label}: '${anchor}' matched ${hits.length} paragraphs, expected 1 — update this test`);
|
|
70
|
+
return hits[0];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const SITES = [
|
|
74
|
+
["the Monitor the controller arms over open PRs' latest runs", "controller arms second persistent Monitor"],
|
|
75
|
+
["the never-cache-a-conclusion rule", "never cache conclusion"],
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
test("ci-and-staleness.md keys watchers on the three-part form at both of its sites", () => {
|
|
79
|
+
for (const [label, anchor] of SITES) {
|
|
80
|
+
assert.match(
|
|
81
|
+
paragraphSaying(CI_AND_STALENESS, anchor, label),
|
|
82
|
+
new RegExp(THREE_PART.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")),
|
|
83
|
+
`${label} no longer keys on ${THREE_PART}; without \`attempt\` a rerun onto the same conclusion fires nothing and a stalled PR is indistinguishable from a running one`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Tree-wide, because the defect was a copy drifting from its original — pinning
|
|
89
|
+
// only the file this ticket corrected leaves the next copy free to be made wrong.
|
|
90
|
+
// "Tree-wide" is WALK and nowhere else, deliberately: the same key restated at
|
|
91
|
+
// the repo root or under docs/ goes unflagged (measured — a copy at each of
|
|
92
|
+
// those two paths left this test green, while the identical string under the
|
|
93
|
+
// plugin's own dirs reddened it). Every copy #183 found lives here; widening the
|
|
94
|
+
// root is a different ticket.
|
|
95
|
+
test("no document under the plugin's own dirs states the two-part watcher key", () => {
|
|
96
|
+
const offenders = WALK.flatMap((d) =>
|
|
97
|
+
readdirSync(join(FLEET, d), { recursive: true, withFileTypes: true })
|
|
98
|
+
.filter((e) => e.isFile() && !e.parentPath.includes("node_modules"))
|
|
99
|
+
.map((e) => join(e.parentPath, e.name)),
|
|
100
|
+
).filter((f) => flat(readFileSync(f, "utf8")).includes(TWO_PART));
|
|
101
|
+
assert.deepEqual(
|
|
102
|
+
offenders,
|
|
103
|
+
[],
|
|
104
|
+
`these state the refuted two-part watcher key ${TWO_PART}; it must be ${THREE_PART}. If one of them means to show the broken form deliberately, update this test rather than the document`,
|
|
105
|
+
);
|
|
106
|
+
});
|