@feigi/fleet-ctl 3.23.36 → 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,175 +0,0 @@
|
|
|
1
|
-
// #814. Phase 0 step 4's staleness recipe named the commit that removed a
|
|
2
|
-
// string with `git log -S '<old string>' --oneline origin/main -- <file>` and
|
|
3
|
-
// then prescribed `git merge-base --is-ancestor <sha> origin/main` to "prove it
|
|
4
|
-
// is not a pre-rebase orphan". `git log <ref>` enumerates only commits
|
|
5
|
-
// reachable from `<ref>`, so that sha is an ancestor of `origin/main` BY
|
|
6
|
-
// CONSTRUCTION, and `--is-ancestor` is true again when the two are equal: the
|
|
7
|
-
// step could not answer no in the position it was written into, and a step that
|
|
8
|
-
// always passes reads as a check that was performed.
|
|
9
|
-
//
|
|
10
|
-
// Measured in this repository while the defect was live: the walk for the
|
|
11
|
-
// defect's own wording, `git log -S 'proves it is not a pre-rebase orphan'
|
|
12
|
-
// --format=%H -n1 origin/main -- plugin/skills/run-team/SKILL.md`, names
|
|
13
|
-
// `9c930a7`, and `git merge-base --is-ancestor 9c930a7 origin/main` exits 0;
|
|
14
|
-
// `git merge-base --is-ancestor origin/main origin/main` exits 0 as well. The
|
|
15
|
-
// check is not inert — on a commit that did NOT come from that walk it exits 1
|
|
16
|
-
// (measured on this branch's own tip, unreachable from `origin/main`) — so the
|
|
17
|
-
// defect is the position, never the check.
|
|
18
|
-
//
|
|
19
|
-
// WHY A PIN AT ALL, given the check's own redundancy is the finding: the
|
|
20
|
-
// vacuous wording shipped and survived the entire suite for the whole of its
|
|
21
|
-
// life, because nothing in `*.test.mjs` read this paragraph. The probe that
|
|
22
|
-
// carries the same reasoning in code (`staleness.mjs`'s call-site comment) is
|
|
23
|
-
// itself backed by a test that the citation walk is scoped to `origin/main`
|
|
24
|
-
// (`staleness.test.mjs`, #813) — the prose half had no equivalent. A revert of
|
|
25
|
-
// the fix is one sentence, and `git revert` reproduces the old wording
|
|
26
|
-
// byte-for-byte.
|
|
27
|
-
//
|
|
28
|
-
// THE SLICE IS WHAT ANCHORS. Matched over the whole document these phrases are
|
|
29
|
-
// satisfiable from outside the rule: this file discusses `origin/main`
|
|
30
|
-
// scoping, `--is-ancestor`, orphans and pre-rebase shas across several
|
|
31
|
-
// neighbouring paragraphs, and `plugin/commands/run-merge-bot.md` prescribes
|
|
32
|
-
// the same command for its own (non-vacuous) input. `paragraph()` cuts the
|
|
33
|
-
// recipe to the one block carrying the rule and throws rather than widening if
|
|
34
|
-
// the anchor moves.
|
|
35
|
-
//
|
|
36
|
-
// MUTATION-VERIFIED BOTH WAYS, on a copy of this worktree's file kept outside
|
|
37
|
-
// it (`<scratch>/impl-814/SKILL.md.orig`, restored and sha-256-compared after
|
|
38
|
-
// every run). Five tests here; three of the 35 pre-existing prose pins over
|
|
39
|
-
// this same document — liveness-rationale, staleness-verdict,
|
|
40
|
-
// staleness-qualifier, 12 tests together — stayed green on every mutation,
|
|
41
|
-
// which is the discrimination:
|
|
42
|
-
// - the old wording restored whole (`git show origin/main:` before this fix):
|
|
43
|
-
// 5 of 5 red. That wording is green on origin/main's own CI, which is the
|
|
44
|
-
// measurement that this paragraph was unpinned.
|
|
45
|
-
// - the reachability reason cut out ("so every commit it can print is
|
|
46
|
-
// reachable from `origin/main` by construction" → "so the commit it names
|
|
47
|
-
// is the one to cite"): 3 red — the no-check-here pin plus the two
|
|
48
|
-
// accept-side tests, which derive their fixtures FROM the live paragraph
|
|
49
|
-
// and so red whenever a pinned span leaves it. The relocation pin and the
|
|
50
|
-
// negative both stay green: the mutation removed the reason, not the
|
|
51
|
-
// position.
|
|
52
|
-
// - the relocated input unnamed ("a sha the TICKET quotes" → "a sha from
|
|
53
|
-
// some other source"): 3 red — the relocation pin and the same two
|
|
54
|
-
// accept-side tests; the no-check-here pin stays green.
|
|
55
|
-
// - THE ACCEPT SIDE, measured on the file rather than a fixture: the whole
|
|
56
|
-
// paragraph re-wrapped at a width nothing here assumes — 5 of 5 GREEN.
|
|
57
|
-
// These pins refuse drift, not reflow.
|
|
58
|
-
// - the decoy, which is what the slice bound is for: both pinned spans
|
|
59
|
-
// deleted from the recipe and appended verbatim as a stray paragraph at
|
|
60
|
-
// the end of the file — 4 red, not bought off by the copy. The negative
|
|
61
|
-
// pin stays green there, correctly: nothing re-attached the proof claim.
|
|
62
|
-
//
|
|
63
|
-
// THE CEILING: two positive spans and one negative. The negative pins the
|
|
64
|
-
// LITERAL reverted clause — the walk's output bound to the proof claim — and a
|
|
65
|
-
// reworded re-attachment evades it; the positive spans are what carry the
|
|
66
|
-
// meaning. Neither half pins the exit-1/exit-128 reading note that follows
|
|
67
|
-
// them, which is a reading aid, not the rule. `git show` resolving an orphan is
|
|
68
|
-
// stated in the prose and not asserted here: it is a property of git, not of
|
|
69
|
-
// this document.
|
|
70
|
-
import { test } from "node:test";
|
|
71
|
-
import assert from "node:assert/strict";
|
|
72
|
-
import { readFileSync } from "node:fs";
|
|
73
|
-
import { join } from "node:path";
|
|
74
|
-
import { paragraph, phrase } from "./prose-pin.mjs";
|
|
75
|
-
|
|
76
|
-
const SKILL = "skills/run-team/SKILL.md";
|
|
77
|
-
const ANCHOR = "**Grep for the ticket's ASKED-FOR CHANGE, not only its subject construct**";
|
|
78
|
-
const text = () => readFileSync(join(import.meta.dirname, "..", ...SKILL.split("/")), "utf8");
|
|
79
|
-
|
|
80
|
-
// `**` stripped, nothing else: every pinned span below opens on a bolded lead
|
|
81
|
-
// clause, and where the emphasis sits is not what this file is about — dropping
|
|
82
|
-
// or moving the asterisks must not red a pin that holds the words. Whitespace
|
|
83
|
-
// is left to `phrase()`, which joins on `\s+` and so already absorbs the
|
|
84
|
-
// hard-wrap.
|
|
85
|
-
const recipe = () => paragraph(text(), ANCHOR, SKILL).replace(/\*\*/g, "");
|
|
86
|
-
|
|
87
|
-
// ONE contiguous span, never three presence checks: the rule is the JOIN of the
|
|
88
|
-
// instruction (no ancestry check here), its reason (reachable by construction,
|
|
89
|
-
// because that is where the walk starts) and the tautology's second case (true
|
|
90
|
-
// again when the sha IS the ref). Independent matches on those three would each
|
|
91
|
-
// stay green with the reason attached to the wrong clause, which is the shape
|
|
92
|
-
// the defect had.
|
|
93
|
-
const NO_CHECK_HERE =
|
|
94
|
-
"No ancestry check on what that walk printed. `origin/main` is where the walk starts, so every commit it can print is reachable from `origin/main` by construction, and `git merge-base --is-ancestor <sha> origin/main` is true for all of them — true again when the sha *is* `origin/main`.";
|
|
95
|
-
|
|
96
|
-
// The relocation, as one span for the same reason: the check, the input it
|
|
97
|
-
// belongs to (a sha the TICKET quotes) and the mechanism that lets that input
|
|
98
|
-
// answer no. "It can fail somewhere" with no named input is what the recipe
|
|
99
|
-
// already read like.
|
|
100
|
-
const BELONGS_TO_TICKET_SHA =
|
|
101
|
-
"That check belongs one input over — a sha the TICKET quotes, where it can answer no: a rebase leaves the commit it orphaned a whole object, so `git show` resolves it happily while nothing in `origin/main`'s history reaches it";
|
|
102
|
-
|
|
103
|
-
// The reverted clause, verbatim from `origin/main` before this fix: the walk's
|
|
104
|
-
// output bound to the proof claim. Narrow on purpose — the phrase "pre-rebase
|
|
105
|
-
// orphan" is LEGITIMATE in this paragraph when it describes the ticket-quoted
|
|
106
|
-
// sha, which is the whole point of the relocation, so a bare search for it
|
|
107
|
-
// would red correct prose. The accept-side test below feeds exactly that
|
|
108
|
-
// wording in and requires this pin to stay green on it.
|
|
109
|
-
const REVERTED =
|
|
110
|
-
"the commit that removed it, `git merge-base --is-ancestor <sha> origin/main` proves it is not a pre-rebase orphan";
|
|
111
|
-
|
|
112
|
-
test("the phase-0 recipe states the walk's own output needs no ancestry check, and why", () => {
|
|
113
|
-
assert.match(
|
|
114
|
-
recipe(),
|
|
115
|
-
phrase(NO_CHECK_HERE),
|
|
116
|
-
`${SKILL}'s "${ANCHOR}" paragraph no longer says "${NO_CHECK_HERE}". Without the reason bound to the instruction, the next reader restores the check — it looks like evidence, and nothing on the page says the walk already answers it. #814.`,
|
|
117
|
-
);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
test("the phase-0 recipe keeps the ancestry check on the input where it can answer no", () => {
|
|
121
|
-
assert.match(
|
|
122
|
-
recipe(),
|
|
123
|
-
phrase(BELONGS_TO_TICKET_SHA),
|
|
124
|
-
`${SKILL}'s "${ANCHOR}" paragraph no longer says "${BELONGS_TO_TICKET_SHA}". The check is not wrong, it was in the wrong position — dropping the ticket-quoted-sha case loses the one input it is evidence for, and a sha a ticket quotes is where a stale premise hides. #814.`,
|
|
125
|
-
);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test("the phase-0 recipe does not re-attach the proof claim to the sha the walk printed", () => {
|
|
129
|
-
assert.doesNotMatch(
|
|
130
|
-
recipe(),
|
|
131
|
-
phrase(REVERTED),
|
|
132
|
-
`${SKILL}'s "${ANCHOR}" paragraph says "${REVERTED}" again — that is the #814 defect verbatim: the sha came from a walk starting at \`origin/main\`, so the check cannot answer no about it and proves nothing. Run it on a sha the ticket quotes instead.`,
|
|
133
|
-
);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
// ACCEPT SIDE 1 — the guard's own false-positive class. "Pre-rebase orphan" is
|
|
137
|
-
// correct English about the ticket-quoted sha; the relocation is the reason
|
|
138
|
-
// that wording still belongs in this paragraph, so a future author spelling
|
|
139
|
-
// the relocated check that way must not red anything here. The fixture is the
|
|
140
|
-
// live paragraph plus exactly that sentence, about the ticket's sha: the
|
|
141
|
-
// negative pin stays green because what it refuses is the ADJACENCY to the
|
|
142
|
-
// walk's output, not the words.
|
|
143
|
-
test("naming the relocated check a pre-rebase-orphan test is ACCEPTED, not refused", () => {
|
|
144
|
-
const live = recipe();
|
|
145
|
-
const reworded = `${live} Run \`git merge-base --is-ancestor <sha> origin/main\` on the sha the ticket quotes: exit 0 proves it is not a pre-rebase orphan, exit 1 says it is one and the premise is stale.`;
|
|
146
|
-
assert.doesNotMatch(
|
|
147
|
-
reworded,
|
|
148
|
-
phrase(REVERTED),
|
|
149
|
-
"the negative pin fires on a LEGITIMATE use of the orphan wording on the ticket-quoted sha — narrow it to the walk-output adjacency",
|
|
150
|
-
);
|
|
151
|
-
assert.match(reworded, phrase(NO_CHECK_HERE));
|
|
152
|
-
assert.match(reworded, phrase(BELONGS_TO_TICKET_SHA));
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// ACCEPT SIDE 2 — reflow. Derived from the live paragraph, never a quoted copy
|
|
156
|
-
// of today's lines, so a reword of the surrounding prose is not what this
|
|
157
|
-
// measures: re-wrapped at a width nothing here assumes, every pin above still
|
|
158
|
-
// holds. These pins refuse drift, not line breaks.
|
|
159
|
-
test("a rewrapped recipe paragraph still matches every pin above", () => {
|
|
160
|
-
const live = recipe();
|
|
161
|
-
const narrow = live
|
|
162
|
-
.split(/\s+/)
|
|
163
|
-
.filter(Boolean)
|
|
164
|
-
.reduce((acc, w) => {
|
|
165
|
-
const last = acc[acc.length - 1];
|
|
166
|
-
if (last && `${last} ${w}`.length <= 45) acc[acc.length - 1] = `${last} ${w}`;
|
|
167
|
-
else acc.push(w);
|
|
168
|
-
return acc;
|
|
169
|
-
}, [])
|
|
170
|
-
.join("\n ");
|
|
171
|
-
assert.notEqual(narrow, live, "the rewrap fixture no longer changes the paragraph's wrapping — update it");
|
|
172
|
-
assert.match(narrow, phrase(NO_CHECK_HERE));
|
|
173
|
-
assert.match(narrow, phrase(BELONGS_TO_TICKET_SHA));
|
|
174
|
-
assert.doesNotMatch(narrow, phrase(REVERTED));
|
|
175
|
-
});
|
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
// #164 / ADR 0007. Gate for `.github/scripts/apply-ruleset.sh`, the only
|
|
2
|
-
// sanctioned path for changing this repo's merge gate.
|
|
3
|
-
//
|
|
4
|
-
// The script's own header calls the post-write readback "the whole point of the
|
|
5
|
-
// script", and every branch it has is an error branch: the happy path is one
|
|
6
|
-
// line. Nothing executed it before this file — it was reachable only through
|
|
7
|
-
// prose. So what is pinned here is the behaviour an operator reads off it:
|
|
8
|
-
// the exit status, the message, and whether a PUT was issued at all.
|
|
9
|
-
//
|
|
10
|
-
// Three defects this file was written against, all reproduced before the fix:
|
|
11
|
-
// - the name lookup did not filter `source_type == "Repository"`, so an
|
|
12
|
-
// inherited org ruleset sharing the name either blocked the applier or sent
|
|
13
|
-
// the PUT to the parent's id (which the repo token cannot write);
|
|
14
|
-
// - the post-PUT readback was an unguarded command substitution, so the one
|
|
15
|
-
// state that matters — write landed, cannot be proven — exited with `gh`'s
|
|
16
|
-
// raw status and no message naming the unverified write;
|
|
17
|
-
// - `norm` compared `rules` positionally, so a server-side reorder turned a
|
|
18
|
-
// correct gate into a permanent refusal.
|
|
19
|
-
//
|
|
20
|
-
// Nothing here executes a workflow or reaches the network: `gh` is a stub on
|
|
21
|
-
// PATH and the script under test is the real file at the repo root, never a
|
|
22
|
-
// copy. `t_applies_a_genuine_difference` is the harness's positive control — if
|
|
23
|
-
// the stub or the PATH were wrong, every "exits 2" assertion below would pass
|
|
24
|
-
// for the wrong reason, and that one would fail.
|
|
25
|
-
|
|
26
|
-
import { test } from "node:test";
|
|
27
|
-
import assert from "node:assert/strict";
|
|
28
|
-
import { spawnSync } from "node:child_process";
|
|
29
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
30
|
-
import { tmpdir } from "node:os";
|
|
31
|
-
import { writeExecStub } from "./exec-stub.mjs";
|
|
32
|
-
import { join } from "node:path";
|
|
33
|
-
import { fileURLToPath } from "node:url";
|
|
34
|
-
|
|
35
|
-
const ROOT = fileURLToPath(new URL("../../", import.meta.url));
|
|
36
|
-
const SCRIPT = join(ROOT, ".github/scripts/apply-ruleset.sh");
|
|
37
|
-
const SHIPPED_SPEC = join(ROOT, ".github/rulesets/main.json");
|
|
38
|
-
// Resolved once from the ambient PATH: the missing-tool tests below hand the
|
|
39
|
-
// script a PATH with one entry, and a relative `bash` would then fail to spawn
|
|
40
|
-
// at all — an error indistinguishable from the refusal being asserted.
|
|
41
|
-
const BASH = which("bash");
|
|
42
|
-
|
|
43
|
-
function which(name) {
|
|
44
|
-
const found = spawnSync("sh", ["-c", `command -v ${name}`], { encoding: "utf8" });
|
|
45
|
-
assert.equal(found.status, 0, `${name} must be on PATH for this file to test anything`);
|
|
46
|
-
return found.stdout.trim();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
assert.ok(existsSync(SCRIPT), "apply-ruleset.sh is missing — this file tests nothing");
|
|
50
|
-
|
|
51
|
-
// Canned `gh`. Logs every invocation so a test can assert a PUT did or did not
|
|
52
|
-
// happen, which no exit status reports. Reads are numbered: the pre-PUT read
|
|
53
|
-
// and the post-PUT readback hit the same URL and have to be answerable apart.
|
|
54
|
-
// The listing is paged the way the real endpoint is — the second page exists
|
|
55
|
-
// only for a caller that asked for all of them.
|
|
56
|
-
const GH_STUB = [
|
|
57
|
-
"#!/bin/sh",
|
|
58
|
-
'printf "%s\\n" "$*" >> "$GH_LOG"',
|
|
59
|
-
'if [ "$1" = "repo" ]; then',
|
|
60
|
-
' if [ -f "$GH_FIX/repo.fail" ]; then echo "gh: HTTP 401: Bad credentials" >&2; exit 1; fi',
|
|
61
|
-
' printf "%s\\n" "acme/widget"; exit 0',
|
|
62
|
-
"fi",
|
|
63
|
-
'shift # drop the `api` verb',
|
|
64
|
-
"method=GET; path=; paginate=0",
|
|
65
|
-
"while [ $# -gt 0 ]; do",
|
|
66
|
-
" case $1 in",
|
|
67
|
-
" -X|--method) method=$2; shift 2 ;;",
|
|
68
|
-
" --input|--jq) shift 2 ;;",
|
|
69
|
-
" --paginate) paginate=1; shift ;;",
|
|
70
|
-
" -*) shift ;;",
|
|
71
|
-
" *) path=$1; shift ;;",
|
|
72
|
-
" esac",
|
|
73
|
-
"done",
|
|
74
|
-
'if [ "$method" = PUT ]; then',
|
|
75
|
-
' if [ -f "$GH_FIX/put.fail" ]; then echo "gh: HTTP 422: Validation Failed" >&2; exit 1; fi',
|
|
76
|
-
' echo "{}"; exit 0',
|
|
77
|
-
"fi",
|
|
78
|
-
'case "$path" in',
|
|
79
|
-
" */rulesets)",
|
|
80
|
-
' if [ -f "$GH_FIX/list.fail" ]; then echo "gh: HTTP 503: Service Unavailable" >&2; exit 1; fi',
|
|
81
|
-
' cat "$GH_FIX/list.json"',
|
|
82
|
-
' if [ "$paginate" = 1 ] && [ -f "$GH_FIX/list2.json" ]; then cat "$GH_FIX/list2.json"; fi ;;',
|
|
83
|
-
" */rulesets/*)",
|
|
84
|
-
' n=$(cat "$GH_FIX/reads" 2>/dev/null || echo 0); n=$((n + 1)); echo "$n" > "$GH_FIX/reads"',
|
|
85
|
-
' if [ -f "$GH_FIX/read$n.fail" ]; then echo "gh: HTTP 502 (post-PUT read)" >&2; exit 1; fi',
|
|
86
|
-
' if [ -f "$GH_FIX/read$n.json" ]; then cat "$GH_FIX/read$n.json"; else cat "$GH_FIX/read.json"; fi ;;',
|
|
87
|
-
" *)",
|
|
88
|
-
' echo "gh stub: unexpected path [$path]" >&2; exit 91 ;;',
|
|
89
|
-
"esac",
|
|
90
|
-
].join("\n");
|
|
91
|
-
|
|
92
|
-
/** A minimal but shaped-like-the-real-thing ruleset spec. */
|
|
93
|
-
const spec = (over = {}) => ({
|
|
94
|
-
name: "main",
|
|
95
|
-
target: "branch",
|
|
96
|
-
enforcement: "active",
|
|
97
|
-
bypass_actors: [],
|
|
98
|
-
conditions: { ref_name: { exclude: [], include: ["~DEFAULT_BRANCH"] } },
|
|
99
|
-
rules: [
|
|
100
|
-
{ type: "deletion" },
|
|
101
|
-
{ type: "pull_request", parameters: { allowed_merge_methods: ["merge"], required_approving_review_count: 0 } },
|
|
102
|
-
{ type: "required_status_checks", parameters: { strict_required_status_checks_policy: true, required_status_checks: [{ context: "check", integration_id: 15368 }] } },
|
|
103
|
-
],
|
|
104
|
-
...over,
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* The server's view of a ruleset: the spec's writable fields plus the
|
|
109
|
-
* server-only ones the projection has to ignore.
|
|
110
|
-
*/
|
|
111
|
-
const served = (obj, id = 42) => ({
|
|
112
|
-
id,
|
|
113
|
-
source_type: "Repository",
|
|
114
|
-
created_at: "2026-07-31T14:10:14Z",
|
|
115
|
-
updated_at: "2026-07-31T16:37:01Z",
|
|
116
|
-
_links: { self: { href: "https://api.github.com/..." } },
|
|
117
|
-
...obj,
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const listed = (...entries) => entries.map(([id, name, source_type]) => ({ id, name, source_type }));
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Run the shipped script against `fixtures`.
|
|
124
|
-
*
|
|
125
|
-
* `spec` is the spec file's content (an object, or a raw string for the
|
|
126
|
-
* malformed cases). `list` is the listing's first page and `list2` its second,
|
|
127
|
-
* which only a paginating caller ever sees. `reads` are the successive answers
|
|
128
|
-
* to the by-id GET; `readFails` names the 1-based read that should fail
|
|
129
|
-
* instead. `args` are options placed before the spec path. `path` overrides
|
|
130
|
-
* PATH for the missing-tool cases.
|
|
131
|
-
*/
|
|
132
|
-
function run(t, { spec: specObj, list = listed([42, "main", "Repository"]), list2, reads = [], readFails = [], repoFails = false, putFails = false, listFails = false, specPath, args = [], path } = {}) {
|
|
133
|
-
const dir = mkdtempSync(join(tmpdir(), "apply-ruleset-"));
|
|
134
|
-
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
135
|
-
const fix = join(dir, "fix");
|
|
136
|
-
const bin = join(dir, "bin");
|
|
137
|
-
mkdirSync(fix);
|
|
138
|
-
mkdirSync(bin);
|
|
139
|
-
writeExecStub(join(bin, "gh"), GH_STUB);
|
|
140
|
-
|
|
141
|
-
const specFile = join(dir, "spec.json");
|
|
142
|
-
if (specObj !== undefined) {
|
|
143
|
-
writeFileSync(specFile, typeof specObj === "string" ? specObj : JSON.stringify(specObj, null, 2));
|
|
144
|
-
}
|
|
145
|
-
writeFileSync(join(fix, "list.json"), JSON.stringify(list));
|
|
146
|
-
if (list2) writeFileSync(join(fix, "list2.json"), JSON.stringify(list2));
|
|
147
|
-
reads.forEach((r, i) => writeFileSync(join(fix, `read${i + 1}.json`), JSON.stringify(r)));
|
|
148
|
-
if (reads.length > 0) writeFileSync(join(fix, "read.json"), JSON.stringify(reads[reads.length - 1]));
|
|
149
|
-
for (const n of readFails) writeFileSync(join(fix, `read${n}.fail`), "");
|
|
150
|
-
if (repoFails) writeFileSync(join(fix, "repo.fail"), "");
|
|
151
|
-
if (putFails) writeFileSync(join(fix, "put.fail"), "");
|
|
152
|
-
if (listFails) writeFileSync(join(fix, "list.fail"), "");
|
|
153
|
-
|
|
154
|
-
const log = join(dir, "gh.log");
|
|
155
|
-
writeFileSync(log, "");
|
|
156
|
-
|
|
157
|
-
const r = spawnSync(BASH, [SCRIPT, ...args, specPath ?? specFile], {
|
|
158
|
-
cwd: dir,
|
|
159
|
-
encoding: "utf8",
|
|
160
|
-
env: { PATH: path ?? `${bin}:${process.env.PATH}`, HOME: dir, GH_FIX: fix, GH_LOG: log },
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
const calls = readFileSync(log, "utf8").split("\n").filter(Boolean);
|
|
164
|
-
return {
|
|
165
|
-
status: r.status,
|
|
166
|
-
out: `${r.stdout}${r.stderr}`,
|
|
167
|
-
calls,
|
|
168
|
-
puts: calls.filter((c) => c.includes("-X PUT")),
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** A PATH holding only the named real tools, for the "not on PATH" branches. */
|
|
173
|
-
function pathWith(t, names) {
|
|
174
|
-
const dir = mkdtempSync(join(tmpdir(), "apply-ruleset-path-"));
|
|
175
|
-
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
176
|
-
for (const n of names) {
|
|
177
|
-
// `gh` is the stub even here: this PATH exists to make one tool missing,
|
|
178
|
-
// never to let a real API call out.
|
|
179
|
-
if (n === "gh") writeExecStub(join(dir, n), GH_STUB);
|
|
180
|
-
else writeExecStub(join(dir, n), `#!/bin/sh\nexec ${which(n)} "$@"\n`);
|
|
181
|
-
}
|
|
182
|
-
return dir;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// ---- the positive control ------------------------------------------------
|
|
186
|
-
|
|
187
|
-
test("applies a genuine difference and re-reads it", (t) => {
|
|
188
|
-
const want = spec();
|
|
189
|
-
const r = run(t, { spec: want, reads: [served({ ...want, enforcement: "disabled" }), served(want)] });
|
|
190
|
-
assert.equal(r.status, 0, r.out);
|
|
191
|
-
assert.equal(r.puts.length, 1, r.out);
|
|
192
|
-
assert.match(r.out, /applied and verified/);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
test("a live object equal to the spec is left alone", (t) => {
|
|
196
|
-
const want = spec();
|
|
197
|
-
const r = run(t, { spec: want, reads: [served(want)] });
|
|
198
|
-
assert.equal(r.status, 0, r.out);
|
|
199
|
-
assert.deepEqual(r.puts, [], "nothing to apply must not write");
|
|
200
|
-
assert.match(r.out, /already matches/);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// ---- resolving the ruleset ----------------------------------------------
|
|
204
|
-
|
|
205
|
-
test("an inherited org ruleset sharing the name does not shadow the repo's own", (t) => {
|
|
206
|
-
const want = spec();
|
|
207
|
-
const r = run(t, {
|
|
208
|
-
spec: want,
|
|
209
|
-
list: listed([42, "main", "Repository"], [7777777, "main", "Organization"]),
|
|
210
|
-
reads: [served(want)],
|
|
211
|
-
});
|
|
212
|
-
assert.equal(r.status, 0, r.out);
|
|
213
|
-
assert.ok(
|
|
214
|
-
r.calls.some((c) => c.includes("rulesets/42")),
|
|
215
|
-
`must resolve the repository-level id, got: ${r.calls.join(" | ")}`,
|
|
216
|
-
);
|
|
217
|
-
assert.ok(!r.calls.some((c) => c.includes("7777777")), "must never address the parent's id");
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
test("an inherited org ruleset alone is not a repository ruleset", (t) => {
|
|
221
|
-
const r = run(t, { spec: spec(), list: listed([7777777, "main", "Organization"]) });
|
|
222
|
-
assert.equal(r.status, 2);
|
|
223
|
-
assert.match(r.out, /no repository-level ruleset named 'main'/);
|
|
224
|
-
assert.deepEqual(r.puts, [], "must not write to a ruleset it cannot own");
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
test("two repository rulesets sharing the name are refused, not guessed between", (t) => {
|
|
228
|
-
const r = run(t, { spec: spec(), list: listed([42, "main", "Repository"], [43, "main", "Repository"]) });
|
|
229
|
-
assert.equal(r.status, 2);
|
|
230
|
-
assert.match(r.out, /more than one ruleset named 'main'/);
|
|
231
|
-
assert.deepEqual(r.puts, []);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
test("a quote in the ruleset name resolves instead of breaking the lookup", (t) => {
|
|
235
|
-
const want = spec({ name: 'ma"in' });
|
|
236
|
-
const r = run(t, { spec: want, list: listed([42, 'ma"in', "Repository"]), reads: [served(want)] });
|
|
237
|
-
assert.equal(r.status, 0, r.out);
|
|
238
|
-
assert.match(r.out, /already matches/);
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
test("a ruleset past the listing's first page is still found", (t) => {
|
|
242
|
-
const want = spec();
|
|
243
|
-
const filler = Array.from({ length: 30 }, (_, i) => [100 + i, `other-${i}`, "Repository"]);
|
|
244
|
-
const r = run(t, {
|
|
245
|
-
spec: want,
|
|
246
|
-
list: listed(...filler),
|
|
247
|
-
list2: listed([42, "main", "Repository"]),
|
|
248
|
-
reads: [served(want)],
|
|
249
|
-
});
|
|
250
|
-
assert.equal(r.status, 0, r.out);
|
|
251
|
-
assert.match(r.out, /already matches/);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
// ---- the comparable projection ------------------------------------------
|
|
255
|
-
|
|
256
|
-
test("a server-side reorder of rules is not a difference", (t) => {
|
|
257
|
-
const want = spec();
|
|
258
|
-
const r = run(t, { spec: want, reads: [served({ ...want, rules: [...want.rules].reverse() })] });
|
|
259
|
-
assert.equal(r.status, 0, r.out);
|
|
260
|
-
assert.deepEqual(r.puts, [], "a pure reorder must not provoke a write");
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
test("a changed top-level field is a difference", (t) => {
|
|
264
|
-
const want = spec();
|
|
265
|
-
const live = served({ ...want, enforcement: "evaluate" });
|
|
266
|
-
const r = run(t, { spec: want, reads: [live, live] });
|
|
267
|
-
assert.equal(r.status, 2, r.out);
|
|
268
|
-
assert.match(r.out, /refusing to report success/);
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
test("a field changed deep inside a rule's parameters is a difference", (t) => {
|
|
272
|
-
const want = spec();
|
|
273
|
-
const drift = want.rules.map((x) => (x.type === "pull_request" ? { ...x, parameters: { ...x.parameters, allowed_merge_methods: ["squash"] } } : x));
|
|
274
|
-
const live = served({ ...want, rules: drift });
|
|
275
|
-
const r = run(t, { spec: want, reads: [live, live] });
|
|
276
|
-
assert.equal(r.status, 2, r.out);
|
|
277
|
-
assert.match(r.out, /still differs from/);
|
|
278
|
-
assert.match(r.out, /squash/, "the refusal must show what differs");
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
// ---- the failures an operator has to be able to read ---------------------
|
|
282
|
-
|
|
283
|
-
test("a write that cannot be proven says so, rather than exiting on gh's status", (t) => {
|
|
284
|
-
const want = spec();
|
|
285
|
-
const r = run(t, { spec: want, reads: [served({ ...want, enforcement: "disabled" })], readFails: [2] });
|
|
286
|
-
assert.equal(r.puts.length, 1, "the PUT must have been attempted for this to be the unprovable case");
|
|
287
|
-
assert.equal(r.status, 2, "a status the script itself never produces reads as a crash");
|
|
288
|
-
assert.match(r.out, /UNVERIFIED/);
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
test("a failing PUT is not diagnosed as a scope problem", (t) => {
|
|
292
|
-
const want = spec();
|
|
293
|
-
const r = run(t, { spec: want, reads: [served({ ...want, enforcement: "disabled" })], putFails: true });
|
|
294
|
-
assert.equal(r.status, 2);
|
|
295
|
-
assert.match(r.out, /PUT failed/);
|
|
296
|
-
assert.doesNotMatch(r.out, /repo-admin scope/, "422 is not a permissions failure");
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
test("a failing listing is not diagnosed as a scope problem", (t) => {
|
|
300
|
-
const r = run(t, { spec: spec(), listFails: true });
|
|
301
|
-
assert.equal(r.status, 2);
|
|
302
|
-
assert.match(r.out, /cannot list rulesets/);
|
|
303
|
-
assert.doesNotMatch(r.out, /repo-admin scope/, "503 is not a permissions failure");
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
test("a failing repo lookup is not diagnosed as being outside a checkout", (t) => {
|
|
307
|
-
const r = run(t, { spec: spec(), repoFails: true });
|
|
308
|
-
assert.equal(r.status, 2);
|
|
309
|
-
assert.doesNotMatch(r.out, /run this inside the checkout/, "401 has nothing to do with cwd");
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
// ---- refusing before it touches anything ---------------------------------
|
|
313
|
-
|
|
314
|
-
test("a missing spec file is refused before any API call", (t) => {
|
|
315
|
-
const r = run(t, { specPath: "/nonexistent/ruleset.json" });
|
|
316
|
-
assert.equal(r.status, 2);
|
|
317
|
-
assert.match(r.out, /no ruleset spec at/);
|
|
318
|
-
assert.deepEqual(r.calls, [], "must not reach for gh before it has a spec");
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
test("a malformed spec is named by the script, not left to jq's exit code", (t) => {
|
|
322
|
-
const r = run(t, { spec: '{ "name": "main",' });
|
|
323
|
-
assert.equal(r.status, 2, "jq's own exit status escaping would be 5");
|
|
324
|
-
assert.match(r.out, /apply-ruleset: .*is not valid JSON/);
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
test("a spec without a name cannot resolve a target", (t) => {
|
|
328
|
-
const r = run(t, { spec: { target: "branch" } });
|
|
329
|
-
assert.equal(r.status, 2);
|
|
330
|
-
assert.match(r.out, /has no \.name/);
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
test("a missing gh is refused by name", (t) => {
|
|
334
|
-
const r = run(t, { spec: spec(), path: pathWith(t, ["jq"]) });
|
|
335
|
-
assert.equal(r.status, 2);
|
|
336
|
-
assert.match(r.out, /gh is not on PATH/);
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
test("a missing jq is refused by name", (t) => {
|
|
340
|
-
const r = run(t, { spec: spec(), path: pathWith(t, ["gh"]) });
|
|
341
|
-
assert.equal(r.status, 2);
|
|
342
|
-
assert.match(r.out, /jq is not on PATH/);
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
// ---- --check: the same comparison, asked by something that cannot write ----
|
|
346
|
-
//
|
|
347
|
-
// #1710. The four contexts ADR 0007 added sat in the spec and not in the
|
|
348
|
-
// live gate for the 4d22h between ratification and reconcile, because
|
|
349
|
-
// nothing reads the gate unless a person decides to. What makes the flag
|
|
350
|
-
// worth its branch is the third status: an unattended caller holds no
|
|
351
|
-
// admin, and a read it was never allowed to make must not reach it as "the
|
|
352
|
-
// gate has drifted".
|
|
353
|
-
|
|
354
|
-
test("--check reports a difference and writes nothing", (t) => {
|
|
355
|
-
const want = spec();
|
|
356
|
-
const r = run(t, { args: ["--check"], spec: want, reads: [served({ ...want, enforcement: "disabled" })] });
|
|
357
|
-
assert.equal(r.status, 3, r.out);
|
|
358
|
-
assert.deepEqual(r.puts, [], "--check must never write");
|
|
359
|
-
assert.match(r.out, /does NOT match/);
|
|
360
|
-
assert.match(r.out, /disabled/, "the diff itself has to reach the caller, not just the verdict");
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
test("--check on a gate that matches its spec is an ordinary success", (t) => {
|
|
364
|
-
const want = spec();
|
|
365
|
-
const r = run(t, { args: ["--check"], spec: want, reads: [served(want)] });
|
|
366
|
-
assert.equal(r.status, 0, r.out);
|
|
367
|
-
assert.deepEqual(r.puts, [], "--check must never write");
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
test("--check on a listing with no matching repository-level ruleset is drift, not unanswerable", (t) => {
|
|
371
|
-
// The worst drift there is — the gate itself is gone — must not collapse
|
|
372
|
-
// into the same status a caller without a credential gets: 3, not 2.
|
|
373
|
-
const want = spec();
|
|
374
|
-
const r = run(t, { args: ["--check"], spec: want, list: listed([7777777, "main", "Organization"]) });
|
|
375
|
-
assert.equal(r.status, 3, "a deleted or renamed gate is drift, not merely unanswerable");
|
|
376
|
-
assert.match(r.out, /has no repository-level ruleset named/);
|
|
377
|
-
assert.deepEqual(r.puts, [], "--check must never write");
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
test("--check cannot read the gate at all is not reported as drift", (t) => {
|
|
381
|
-
const want = spec();
|
|
382
|
-
const r = run(t, { args: ["--check"], spec: want, readFails: [1] });
|
|
383
|
-
assert.equal(r.status, 2, "a read that fails outright must not be reported as though a diff was seen");
|
|
384
|
-
assert.match(r.out, /cannot read/);
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
test("--check without admin visibility into bypass_actors is not reported as drift", (t) => {
|
|
388
|
-
// GitHub answers a non-admin's GET with 200 and the `bypass_actors` key
|
|
389
|
-
// simply absent, never with a failed read. norm() would otherwise turn
|
|
390
|
-
// that absence into JSON `null` and compare it against the spec's `[]` as
|
|
391
|
-
// though it were a real difference (#1710's actual failure mode).
|
|
392
|
-
const want = spec();
|
|
393
|
-
const { bypass_actors, ...withheld } = served(want);
|
|
394
|
-
const r = run(t, { args: ["--check"], spec: want, reads: [withheld] });
|
|
395
|
-
assert.equal(r.status, 2, "a 200 that withholds bypass_actors is a missing credential, not a null-vs-[] diff");
|
|
396
|
-
assert.match(r.out, /bypass_actors/);
|
|
397
|
-
assert.doesNotMatch(r.out, /does NOT match/, "must never be compared as drift");
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
test("an unknown option is refused rather than read as a spec path", (t) => {
|
|
401
|
-
const r = run(t, { args: ["--dry-run"], spec: spec(), reads: [served(spec())] });
|
|
402
|
-
assert.equal(r.status, 2, r.out);
|
|
403
|
-
assert.match(r.out, /unknown option --dry-run/);
|
|
404
|
-
assert.deepEqual(r.calls, [], "refused before it reaches the API");
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
test("-- ends option parsing rather than being read as an unknown option", (t) => {
|
|
408
|
-
const want = spec();
|
|
409
|
-
const r = run(t, { args: ["--"], spec: want, reads: [served(want)] });
|
|
410
|
-
assert.equal(r.status, 0, r.out);
|
|
411
|
-
assert.match(r.out, /already matches/);
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
// ---- the shipped spec ----------------------------------------------------
|
|
415
|
-
|
|
416
|
-
test("the shipped ruleset spec is one this script can compare", (t) => {
|
|
417
|
-
const shipped = JSON.parse(readFileSync(SHIPPED_SPEC, "utf8"));
|
|
418
|
-
const r = run(t, { spec: shipped, list: listed([20119969, shipped.name, "Repository"]), reads: [served(shipped, 20119969)] });
|
|
419
|
-
assert.equal(r.status, 0, r.out);
|
|
420
|
-
assert.match(r.out, /already matches/);
|
|
421
|
-
});
|