@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,2312 +0,0 @@
|
|
|
1
|
-
// Regression gate for the candidate query's two filters — to-spec specs never
|
|
2
|
-
// reach the queue, and the list comes back oldest-first — and for its exit
|
|
3
|
-
// codes, which are the whole interface for a caller that reads no stderr: 2 is
|
|
4
|
-
// "the query broke", 1 is "the queue is empty", and the two must never swap.
|
|
5
|
-
//
|
|
6
|
-
// candidates.mjs applies its reduction through gh's `--jq`, so the stub below
|
|
7
|
-
// runs the same expression gh would have received — under the system jq it
|
|
8
|
-
// execs by default, not the gojq gh embeds and applies in its own process.
|
|
9
|
-
// Both predicates are under test that way; the ENGINE itself is under test
|
|
10
|
-
// only where a real gojq binary is reachable (`findGojq()` below) — the
|
|
11
|
-
// dependency scan since #331, the spec predicate since #204. `\s`, `\d` and
|
|
12
|
-
// `\b` are Unicode-aware in jq's Oniguruma and ASCII-only in Go's RE2, so the
|
|
13
|
-
// same body used to reduce differently depending on which engine ran it, and
|
|
14
|
-
// gojq's answer is the one that reaches production: gh applies gojq, not jq,
|
|
15
|
-
// so dropSpecs is the only line of defence against what gojq actually
|
|
16
|
-
// decides. #383 closed that divergence by spelling an explicit class at every
|
|
17
|
-
// position, each chosen from what GFM renders — so the class after a
|
|
18
|
-
// heading's `#` marker is deliberately NARROWER than the class at the end of
|
|
19
|
-
// that same heading's line. The expression now contains no `\s`, `\d` or
|
|
20
|
-
// `\b`, and all 24 measured fixtures agree on both engines.
|
|
21
|
-
//
|
|
22
|
-
// That agreement is also what removed the old proof of which engine ran.
|
|
23
|
-
// Until #383 the gated tests identified their engine by one fixture the two
|
|
24
|
-
// answered differently — a trailing U+00A0 that made a heading a spec under
|
|
25
|
-
// jq and not under gojq. Those rows are ruled now and agree, so the proof is
|
|
26
|
-
// direct instead: the STUB records the `--version` of the binary it executed
|
|
27
|
-
// and every gated test asserts that recording is gojq (`assertRanGojq`).
|
|
28
|
-
// A pattern gojq rejects outright at least exits non-zero; a class that
|
|
29
|
-
// merely matches differently would leave this suite green on jq alone, which
|
|
30
|
-
// is what the gated gojq tests below exist to catch. Stubbing gh to return
|
|
31
|
-
// already-reduced JSON would leave the jq expression — which is where both
|
|
32
|
-
// predicates actually live — completely untested.
|
|
33
|
-
|
|
34
|
-
import { test } from "node:test";
|
|
35
|
-
import assert from "node:assert/strict";
|
|
36
|
-
import { spawnSync } from "node:child_process";
|
|
37
|
-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
38
|
-
import { tmpdir } from "node:os";
|
|
39
|
-
import { join } from "node:path";
|
|
40
|
-
import { fileURLToPath } from "node:url";
|
|
41
|
-
import { stripComments } from "./strip-comments.mjs";
|
|
42
|
-
import { between, phrase } from "./prose-pin.mjs";
|
|
43
|
-
import { writeExecStub } from "./exec-stub.mjs";
|
|
44
|
-
|
|
45
|
-
const SCRIPT = fileURLToPath(new URL("./candidates.mjs", import.meta.url));
|
|
46
|
-
const ARG_MODULE = fileURLToPath(new URL("./arg.mjs", import.meta.url));
|
|
47
|
-
|
|
48
|
-
const STUB = `#!/bin/sh
|
|
49
|
-
# Stand-in for \`gh issue list … --jq <expr>\`. Applies the expression gh was
|
|
50
|
-
# given to the fixture, so the expression is under test rather than assumed.
|
|
51
|
-
#
|
|
52
|
-
# ONE plumb point for which binary applies it, and it records itself. The
|
|
53
|
-
# gated gojq tests below can no longer tell the engines apart by their
|
|
54
|
-
# ANSWERS: #383 ruled every divergent position and all 24 fixtures now agree
|
|
55
|
-
# on both engines, which is the point of the ticket and also what blinded the
|
|
56
|
-
# old proof. So the engine names itself here, by the same --version test
|
|
57
|
-
# isGojq applies, and those tests assert the recording. Resolved ONCE and
|
|
58
|
-
# reused for the version line and both apply paths below, so the recording
|
|
59
|
-
# can never describe a different binary from the one that reduced the
|
|
60
|
-
# fixture. Delete this plumb and every gated test reds, because the recording
|
|
61
|
-
# then reads jq- and not gojq.
|
|
62
|
-
JQ_RAN="\${JQ_BIN:-jq}"
|
|
63
|
-
[ -n "$ENGINE_LOG" ] && "$JQ_RAN" --version > "$ENGINE_LOG" 2>&1
|
|
64
|
-
expr=""
|
|
65
|
-
search=""
|
|
66
|
-
fields=""
|
|
67
|
-
while [ $# -gt 0 ]; do
|
|
68
|
-
case "$1" in
|
|
69
|
-
--jq) shift; expr="$1" ;;
|
|
70
|
-
--search) shift; search="$1" ;;
|
|
71
|
-
--json) shift; fields="$1" ;;
|
|
72
|
-
esac
|
|
73
|
-
shift
|
|
74
|
-
done
|
|
75
|
-
# The fallback is the query with no POSITIVE label: term. The leading space is
|
|
76
|
-
# the whole test and cannot be dropped: every exclusion is spelled \`-label:\`,
|
|
77
|
-
# so a bare \`*label:*\` matches the unfiltered query too and silently serves it
|
|
78
|
-
# the labeled fixture — the fallback then looks untaken however well it works.
|
|
79
|
-
# \$search is padded so the term still matches when it leads: gh ignores
|
|
80
|
-
# qualifier order, so reordering query()'s template must not invert this.
|
|
81
|
-
# No second fixture supplied — both queries see the same rows, as before.
|
|
82
|
-
# The two fixtures are deliberately DISJOINT, which real gh could never be
|
|
83
|
-
# (unfiltered is a superset). A faithful superset makes the stub's ignored
|
|
84
|
-
# --limit stop the cap tests firing. So never assert a labeled row is ABSENT
|
|
85
|
-
# from the fallback payload — it was never in that fixture, and it passes
|
|
86
|
-
# whatever the code does.
|
|
87
|
-
# gh applies \`--jq\` itself, inside its own process, so a reduction that did not
|
|
88
|
-
# take is a real failure mode — an old gh, an expression it rejects, a proxy
|
|
89
|
-
# answering with an error object. Overriding the expression is the only way a
|
|
90
|
-
# test reaches the empty and non-array refusals: the real one always emits an
|
|
91
|
-
# array. It is NOT the only way to reach the row-shape refusal, which a fixture
|
|
92
|
-
# alone trips whenever a field's type is wrong upstream (\`"number":"11"\` reduces
|
|
93
|
-
# to \`{"n":"11"}\`) — the expression fixes the key set, never the value types.
|
|
94
|
-
[ -n "$JQ_OVERRIDE" ] && expr="$JQ_OVERRIDE"
|
|
95
|
-
fixture="$FIXTURE"
|
|
96
|
-
case " $search " in
|
|
97
|
-
*\\ label:*)
|
|
98
|
-
# GitHub ends an UNQUOTED qualifier value at the first space; every word
|
|
99
|
-
# after the first becomes a free-text term instead. Measured against the
|
|
100
|
-
# live repo 2026-08-17: \`label:ready-for-agent candidates\` returns
|
|
101
|
-
# strictly fewer issues than \`label:ready-for-agent\`, while
|
|
102
|
-
# \`label:"ready-for-agent"\` returns exactly as many — the relationship and
|
|
103
|
-
# not the counts, which drift with the queue from hour to hour.
|
|
104
|
-
# Reproduce that split or no test can tell the two forms apart — both
|
|
105
|
-
# contain \` label:\`, so the dispatch above serves the labeled fixture
|
|
106
|
-
# either way and #175 stays green while broken.
|
|
107
|
-
#
|
|
108
|
-
# Opt-in through \$LABEL_EXPECT: unset, the term is parsed and ignored, so
|
|
109
|
-
# every test written before #175 keeps exactly its old dispatch.
|
|
110
|
-
padded=" $search "
|
|
111
|
-
term=\${padded#* label:}
|
|
112
|
-
case "$term" in
|
|
113
|
-
\\"*) label=\${term#\\"}; label=\${label%%\\"*} ;;
|
|
114
|
-
*) label=\${term%% *} ;;
|
|
115
|
-
esac
|
|
116
|
-
;;
|
|
117
|
-
# No positive \`label:\` term at all, so nothing was parsed out. An empty
|
|
118
|
-
# \$label matches no \$LABEL_EXPECT, which is what refuses the OTHER
|
|
119
|
-
# direction of #175 — a query that dropped the qualifier outright rather
|
|
120
|
-
# than misparsing it. Only a check BELOW the case can see that: such a
|
|
121
|
-
# search never enters the arm above.
|
|
122
|
-
*) label=""; [ -n "$FIXTURE_UNFILTERED" ] && fixture="$FIXTURE_UNFILTERED" ;;
|
|
123
|
-
esac
|
|
124
|
-
if [ -n "$LABEL_EXPECT" ] && [ "$label" != "$LABEL_EXPECT" ]; then
|
|
125
|
-
# An empty array, not a missing one: the real query would have SUCCEEDED
|
|
126
|
-
# and matched nothing, which is the whole confusion #175 is about.
|
|
127
|
-
echo '[]' | "$JQ_RAN" -c "$expr"
|
|
128
|
-
exit
|
|
129
|
-
fi
|
|
130
|
-
# gh answers \`--json\` with EXACTLY the fields it names, never the whole issue,
|
|
131
|
-
# so the fixture is cut down to them before the expression sees it. Uncut, the
|
|
132
|
-
# stub would serve fields the query never asked for: drop \`blockedBy\` from
|
|
133
|
-
# candidates.mjs's \`--json\` and real gh sends no edge at all, while every
|
|
134
|
-
# native-edge fixture below would still reduce to its blockers (#1741). Cut by
|
|
135
|
-
# the same binary that applies the expression, so a gated test stays gojq end
|
|
136
|
-
# to end.
|
|
137
|
-
if [ -n "$fields" ]; then
|
|
138
|
-
"$JQ_RAN" -c --arg fields "$fields" '($fields | split(",") | map({(.): true}) | add) as $keep | map(with_entries(select($keep[.key])))' "$fixture" > "$fixture.fields" || exit
|
|
139
|
-
fixture="$fixture.fields"
|
|
140
|
-
fi
|
|
141
|
-
exec "$JQ_RAN" -c "$expr" "$fixture"
|
|
142
|
-
`;
|
|
143
|
-
|
|
144
|
-
function run(issues, args = ["--require-label", "ready-for-agent"], unfiltered = null, extraEnv = {}) {
|
|
145
|
-
const dir = mkdtempSync(join(tmpdir(), "candidates-"));
|
|
146
|
-
const fixture = join(dir, "issues.json");
|
|
147
|
-
writeFileSync(fixture, JSON.stringify(issues));
|
|
148
|
-
const gh = join(dir, "gh");
|
|
149
|
-
writeExecStub(gh, STUB);
|
|
150
|
-
const engineLog = join(dir, "engine-version");
|
|
151
|
-
const env = { ...process.env, PATH: `${dir}:${process.env.PATH}`, FIXTURE: fixture, ENGINE_LOG: engineLog, ...extraEnv };
|
|
152
|
-
if (unfiltered) {
|
|
153
|
-
const second = join(dir, "unfiltered.json");
|
|
154
|
-
writeFileSync(second, JSON.stringify(unfiltered));
|
|
155
|
-
env.FIXTURE_UNFILTERED = second;
|
|
156
|
-
}
|
|
157
|
-
const r = spawnSync(process.execPath, [SCRIPT, ...args], { encoding: "utf8", env });
|
|
158
|
-
// Read the engine recording BEFORE the temp dir goes. This is the only
|
|
159
|
-
// evidence of which binary actually applied the expression (#383); it
|
|
160
|
-
// stays "" when the STUB never ran (ENOENT), which is itself a failure the
|
|
161
|
-
// gated tests report rather than skipping past. Only ENOENT is expected
|
|
162
|
-
// here — any OTHER fs error (EACCES, EMFILE/ENFILE, ENOTDIR, EISDIR…)
|
|
163
|
-
// means the STUB (and the engine it invoked) may well have run fine and
|
|
164
|
-
// the log path itself is what's broken; swallowing it too would have
|
|
165
|
-
// `assertRanGojq` misreport a real I/O failure as "never reached gojq".
|
|
166
|
-
let engine = "";
|
|
167
|
-
try {
|
|
168
|
-
engine = readFileSync(engineLog, "utf8").trim();
|
|
169
|
-
} catch (e) {
|
|
170
|
-
if (e.code !== "ENOENT") throw e;
|
|
171
|
-
}
|
|
172
|
-
rmSync(dir, { recursive: true, force: true });
|
|
173
|
-
return { ...r, rows: r.stdout.trim() ? JSON.parse(r.stdout) : [], engine };
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// For the failure shapes the fixture stub cannot reach — it always `exec`s jq,
|
|
177
|
-
// so it can only ever fail by exit status. A gh that kills itself, or one that
|
|
178
|
-
// is absent, is a different `execFileSync` error object entirely.
|
|
179
|
-
function runWithGh(script) {
|
|
180
|
-
const dir = mkdtempSync(join(tmpdir(), "candidates-gh-"));
|
|
181
|
-
const gh = join(dir, "gh");
|
|
182
|
-
writeExecStub(gh, script);
|
|
183
|
-
const env = { ...process.env, PATH: `${dir}:${process.env.PATH}` };
|
|
184
|
-
const r = spawnSync(process.execPath, [SCRIPT, "--require-label", "ready-for-agent"], {
|
|
185
|
-
encoding: "utf8",
|
|
186
|
-
env,
|
|
187
|
-
});
|
|
188
|
-
rmSync(dir, { recursive: true, force: true });
|
|
189
|
-
return r;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Labels are settled by the fixture, not by the query: the stub ignores
|
|
193
|
-
// `--search`'s label term beyond picking a fixture. A row in the unfiltered
|
|
194
|
-
// fixture therefore has to carry a label that would NOT have matched the
|
|
195
|
-
// labeled query, or the two fixtures contradict each other.
|
|
196
|
-
const ticket = (n, body, labels = ["ready-for-agent"]) => ({
|
|
197
|
-
number: n,
|
|
198
|
-
title: `ticket ${n}`,
|
|
199
|
-
labels: labels.map((name) => ({ name })),
|
|
200
|
-
body,
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// #1306: EXCLUDE is a single string literal, pinned whole rather than by N
|
|
204
|
-
// independent `assert.match` calls for individual terms — a dropped or
|
|
205
|
-
// reordered term sits in the gap BETWEEN two such matches and neither would
|
|
206
|
-
// see it. One `assert.equal` over the exact captured span covers every term
|
|
207
|
-
// and their order together.
|
|
208
|
-
//
|
|
209
|
-
// Read through stripComments(), not raw source — the same escape :1039's
|
|
210
|
-
// `die()` pin already closes. An unanchored match against raw text is
|
|
211
|
-
// satisfied by a declaration parked in a `/* */` block above a reverted one:
|
|
212
|
-
// measured, with the correct five-term EXCLUDE moved into a block comment
|
|
213
|
-
// and the live declaration reverted to the pre-#1306 five terms, a raw-source
|
|
214
|
-
// version of this assertion still passed while the unfiltered scan leaked
|
|
215
|
-
// all eight wayfinder tickets back in. stripComments() blanks whole-line and
|
|
216
|
-
// block comments (its own documented ceiling), so the mutant reds under it
|
|
217
|
-
// and the real declaration's capture is unaffected either way.
|
|
218
|
-
test("EXCLUDE carries every canonical exclusion term, in order, as one pinned string (#1306)", () => {
|
|
219
|
-
const src = stripComments(readFileSync(SCRIPT, "utf8"));
|
|
220
|
-
const m = src.match(/const EXCLUDE =\n\s*"([^"]+)";/);
|
|
221
|
-
assert.notEqual(m, null, "candidates.mjs's EXCLUDE declaration no longer matches this pin's shape — update this test");
|
|
222
|
-
assert.equal(
|
|
223
|
-
m[1],
|
|
224
|
-
"-label:in-progress -label:onhold -label:wontfix -label:needs-triage -label:needs-info -label:wayfinder:map -label:wayfinder:research -label:wayfinder:prototype -label:wayfinder:grilling -label:wayfinder:task",
|
|
225
|
-
);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
test("a to-spec spec is dropped — it is to-tickets' input, not a claimable ticket", () => {
|
|
229
|
-
const { rows } = run([
|
|
230
|
-
ticket(10, "## Problem Statement\n\nx\n\n## User Stories\n\n1. As a user, I want…\n"),
|
|
231
|
-
ticket(11, "## What to build\n\nAdd a --json flag.\n"),
|
|
232
|
-
]);
|
|
233
|
-
assert.deepEqual(rows.map((r) => r.n), [11]);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
test("every spec is dropped and named — a filter that stops at the first leaks the rest", () => {
|
|
237
|
-
const { rows, stderr } = run([
|
|
238
|
-
ticket(10, "## User Stories\n\n1. As a user, I want…\n"),
|
|
239
|
-
ticket(11, "## Problem Statement\n\ny\n\n## User Stories\n\n2. As a user…\n"),
|
|
240
|
-
ticket(12, "## What to build\n\nx\n"),
|
|
241
|
-
]);
|
|
242
|
-
assert.deepEqual(rows.map((r) => r.n), [12]);
|
|
243
|
-
// deepEqual on the parsed lines, not a substring match: `/dropped #10/` is
|
|
244
|
-
// satisfied by a hardcoded number and by logging kept rows too. This pins
|
|
245
|
-
// both that 10 and 11 are named and that 12 is not.
|
|
246
|
-
assert.deepEqual(stderr.match(/dropped #\d+/g), ["dropped #10", "dropped #11"]);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
test("a drop from the no-label run is tagged [unfiltered] — the one pass tag no other test reaches", () => {
|
|
250
|
-
// Every other run() in this file passes --require-label, so the pass-1
|
|
251
|
-
// ternary always takes its `label:` arm and the `unfiltered` arm is
|
|
252
|
-
// unpinned: rename it to anything and the whole suite stays green. Both
|
|
253
|
-
// documented callers do pass the flag (next-ticket/SKILL.md's `## 1. Candidates`
|
|
254
|
-
// step, and shortlist.mjs, which run-team/SKILL.md's **Build the Shortlist** step runs), so this arm is reachable only by a hand-run — but
|
|
255
|
-
// it is a supported invocation, and its tag is what tells a reader which
|
|
256
|
-
// query dropped what. Two rows, not one: the spec supplies the drop line,
|
|
257
|
-
// the ticket keeps the queue non-empty so this exits 0, not the empty-queue 1.
|
|
258
|
-
const { status, stderr, rows } = run(
|
|
259
|
-
[
|
|
260
|
-
ticket(10, "## User Stories\n\n1. As a user…\n", ["ready-for-human"]),
|
|
261
|
-
ticket(11, "## What to build\n\nx\n", ["ready-for-human"]),
|
|
262
|
-
],
|
|
263
|
-
[],
|
|
264
|
-
);
|
|
265
|
-
assert.equal(status, 0);
|
|
266
|
-
assert.deepEqual(rows.map((r) => r.n), [11]);
|
|
267
|
-
// The closing `\]` is load-bearing: without it this is also satisfied by the
|
|
268
|
-
// fallback pass's `[unfiltered (fallback)]`, the one tag already pinned above.
|
|
269
|
-
assert.match(stderr, /dropped #10 — to-spec spec, not a ticket \(User Stories heading\) \[unfiltered\]/);
|
|
270
|
-
});
|
|
271
|
-
test("near misses are kept — the predicate's shape is specified, not accidental", () => {
|
|
272
|
-
// One fixture per dimension the regex commits to. Without these, every
|
|
273
|
-
// loosening of the heading match still passes: the dropped fixture differs
|
|
274
|
-
// from a ticket in all of them at once, so it discriminates none.
|
|
275
|
-
//
|
|
276
|
-
// #65: nesting depth (`### User Stories`) moved OUT of this list — it is no
|
|
277
|
-
// longer a near miss, see the depth test below — and the split-heading
|
|
278
|
-
// fixture moved IN, replacing it as the dimension this list now pins.
|
|
279
|
-
const { rows } = run([
|
|
280
|
-
ticket(2, "## user stories\n\nlowercase\n"),
|
|
281
|
-
ticket(3, "##User Stories\n\nno separating space\n"),
|
|
282
|
-
ticket(4, "## User Stories (draft)\n\ntrailing text\n"),
|
|
283
|
-
ticket(5, "Mentions ## User Stories mid-line, not a heading.\n"),
|
|
284
|
-
// #65: the marker alone on its line, heading text starting the next —
|
|
285
|
-
// `\s` spans the newline so this used to read as the same heading. Kept
|
|
286
|
-
// is the fixed behaviour; `dropped #6` in a future run is the regression.
|
|
287
|
-
ticket(6, "##\nUser Stories\n\nmarker and text on separate lines\n"),
|
|
288
|
-
// #65: both ends of the depth range. `#` is an ordinary ticket's h1 and the
|
|
289
|
-
// floor the regex's own name commits to — loosen `#{2,6}` to `#+` and this
|
|
290
|
-
// is what goes red. `#######` is past CommonMark's six-`#` cap, so it is not
|
|
291
|
-
// a heading at all and must not read as the signature; it pins the ceiling
|
|
292
|
-
// the way #7 below pins that the range does not stop at three.
|
|
293
|
-
ticket(10, "# User Stories\n\nan h1, not the signature depth\n"),
|
|
294
|
-
ticket(11, "####### User Stories\n\nseven hashes, past CommonMark's cap\n"),
|
|
295
|
-
]);
|
|
296
|
-
assert.deepEqual(rows.map((r) => r.n), [2, 3, 4, 5, 6, 10, 11]);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
test("a spec heading is dropped at depth two through six, however separated and ended — #65", () => {
|
|
300
|
-
// Why the predicate widened at all — see candidates.mjs's spec-predicate
|
|
301
|
-
// comment. What this test adds is the shape of the range and its edges:
|
|
302
|
-
// `####` pins that it does not stop at three (the near-miss list above pins
|
|
303
|
-
// both ends), and #12/#9/#13 ride the same run to pin what may separate the
|
|
304
|
-
// marker from the text and what may end the line.
|
|
305
|
-
const { rows } = run([
|
|
306
|
-
ticket(1, "### User Stories\n\nnested one level deeper\n"),
|
|
307
|
-
ticket(7, "#### User Stories\n\nnested deeper still\n"),
|
|
308
|
-
// #65: CRLF. `$` under `(?m)` matches BEFORE the `\n`, so the line still
|
|
309
|
-
// ends in `\r` and a trailing class of `[ \t]*` cannot reach the anchor —
|
|
310
|
-
// this body stops matching and the spec leaks, silently, with nothing on
|
|
311
|
-
// stderr. GitHub's web textarea submits CRLF, so it is a real body shape,
|
|
312
|
-
// and this is the only line of defence. Narrow the trailing `\s*` and
|
|
313
|
-
// `dropped #12` is what goes missing.
|
|
314
|
-
ticket(12, "## User Stories\r\n\r\n1. As a user…\r\n"),
|
|
315
|
-
ticket(9, "## User Stories \n\n1. As a user…\n"),
|
|
316
|
-
// #65: a TAB between marker and text. The class is `[ \t]`, but every other
|
|
317
|
-
// fixture here uses a space, so narrowing it to `[ ]` passed the whole repo
|
|
318
|
-
// suite green — the documented half was asserted in prose and pinned
|
|
319
|
-
// nowhere.
|
|
320
|
-
ticket(13, "##\tUser Stories\n\na tab between marker and text\n"),
|
|
321
|
-
ticket(8, "## What to build\n\nx\n"),
|
|
322
|
-
]);
|
|
323
|
-
// #8 is a real kept ticket, so this is a POSITIVE assertion: a query that
|
|
324
|
-
// dies outright fails it too, which `deepEqual(…, [])` over a spec-only
|
|
325
|
-
// fixture could not. Every other row above must be absent, and the failure
|
|
326
|
-
// names whichever one leaked.
|
|
327
|
-
assert.deepEqual(rows.map((r) => r.n), [8]);
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
// Dependency-scan tests (#58). The forms below are the ones to-tickets
|
|
331
|
-
// actually publishes — see candidates.mjs's `depnums` comment — not the bare
|
|
332
|
-
// inline phrasings the OLD regex covered alone.
|
|
333
|
-
|
|
334
|
-
test("a Blocked-by heading with bulleted refs yields every number, not just the first", () => {
|
|
335
|
-
const { rows } = run([ticket(9, "## Blocked by\n\n- #12\n- #13\n")]);
|
|
336
|
-
assert.deepEqual(rows[0].d, [12, 13]);
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
test("None — can start immediately under a heading yields no dependencies", () => {
|
|
340
|
-
const { rows } = run([ticket(9, "## Blocked by\n\n- None — can start immediately\n")]);
|
|
341
|
-
assert.deepEqual(rows[0].d, []);
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
test("a reference in unrelated prose, not under a blocking declaration, is not a dependency", () => {
|
|
345
|
-
const { rows } = run([ticket(9, "- A reference to #77 blocking ticket\n")]);
|
|
346
|
-
assert.deepEqual(rows[0].d, []);
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
test("the bold-label form yields its number — to-tickets' local-file template writes this, not the issue template", () => {
|
|
350
|
-
const { rows } = run([ticket(9, "**Blocked by:** #12\n")]);
|
|
351
|
-
assert.deepEqual(rows[0].d, [12]);
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
test("the original bare inline phrasings still work, now reduced to numbers rather than matched phrase text", () => {
|
|
355
|
-
const { rows } = run([
|
|
356
|
-
ticket(1, "depends on #5\n"),
|
|
357
|
-
ticket(2, "blocked by #99 inline form\n"),
|
|
358
|
-
ticket(3, "requires #3\n"),
|
|
359
|
-
ticket(4, "after #4\n"),
|
|
360
|
-
]);
|
|
361
|
-
assert.deepEqual(rows.map((r) => r.d), [[5], [99], [3], [4]]);
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
test("several references on one inline label line are all found, not just the first", () => {
|
|
365
|
-
const { rows } = run([ticket(9, "Blocked by: #12, #13\n")]);
|
|
366
|
-
assert.deepEqual(rows[0].d, [12, 13]);
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
test("a chained ref separated by FORM FEED or a bare CR is still collected, not silently dropped (#383)", () => {
|
|
370
|
-
// The inline label/ref separator class must match candidates.mjs's
|
|
371
|
-
// end-of-heading-line class ([\t\f\r \p{Zs}]) for the same reasons: \f is
|
|
372
|
-
// stripped by GFM and \r keeps CRLF bodies working. A narrower class here
|
|
373
|
-
// than there SILENTLY DROPS the ref after the odd separator — the worse
|
|
374
|
-
// direction, since a reader still sees `Blocked by #12,\f#13` as two
|
|
375
|
-
// dependencies and GitHub still autolinks both.
|
|
376
|
-
const { rows } = run([
|
|
377
|
-
ticket(1, "Blocked by #12,\f#13\n"),
|
|
378
|
-
ticket(2, "Blocked by #12,\r#13\n"),
|
|
379
|
-
]);
|
|
380
|
-
assert.deepEqual(rows.map((r) => r.d), [[12, 13], [12, 13]]);
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
test("a heading section ends at the NEXT heading, blocking or not — a ref past it is not swept in", () => {
|
|
384
|
-
const { rows } = run([ticket(9, "## Blocked by\n\n- #12\n\n## Notes\n\nsee #999 for context\n")]);
|
|
385
|
-
assert.deepEqual(rows[0].d, [12]);
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
test("a bare marker-only heading (no title text) still closes a blocking section, on both LF and CRLF bodies (#383)", () => {
|
|
389
|
-
// GFM still renders a bare `##` as a real (empty) `<h2>` — the toggle that
|
|
390
|
-
// decides whether a line starts a NEW heading must see it too, or the
|
|
391
|
-
// still-open `## Blocked by` section wrongly keeps collecting refs past
|
|
392
|
-
// it. Over-collection, the direction #383's own gate ruling did not cover:
|
|
393
|
-
// a bare `[ \t]` marker class matches only a TITLED heading, so this one
|
|
394
|
-
// was invisible to the toggle and the section never closed.
|
|
395
|
-
const { rows } = run([
|
|
396
|
-
ticket(1, "## Blocked by\n\n- #12\n\n##\n\n- #13\n"),
|
|
397
|
-
ticket(2, "## Blocked by\r\n\r\n- #12\r\n\r\n##\r\n\r\n- #13\r\n"),
|
|
398
|
-
]);
|
|
399
|
-
assert.deepEqual(rows.map((r) => r.d), [[12], [12]]);
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
test("d holds plain issue numbers, not matched phrase strings", () => {
|
|
403
|
-
const { rows } = run([ticket(9, "depends on #5\n")]);
|
|
404
|
-
assert.deepEqual(rows[0].d, [5]);
|
|
405
|
-
assert.equal(typeof rows[0].d[0], "number");
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
test("an open blocking section reads its list items only — a later prose ref is not a phantom blocker", () => {
|
|
409
|
-
// The section flag closes on the NEXT heading, so a `## Blocked by` that is
|
|
410
|
-
// the last heading in the body stays armed to EOF. Collecting every line
|
|
411
|
-
// there turns "None — can start immediately" plus ordinary notes into a
|
|
412
|
-
// blocker the body never declared, and the consumer (next-ticket step 2)
|
|
413
|
-
// drops the ticket without re-reading the body.
|
|
414
|
-
const { rows } = run([
|
|
415
|
-
ticket(9, "## Blocked by\n\n- None — can start immediately\n\nImplementation notes: mirror what #300 did.\n"),
|
|
416
|
-
]);
|
|
417
|
-
assert.deepEqual(rows[0].d, []);
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
test("a fenced code sample inside an open blocking section is not swept in", () => {
|
|
421
|
-
const { rows } = run([ticket(9, "## Blocked by\n\n- #12\n\n```\ngit log #999\n```\n")]);
|
|
422
|
-
assert.deepEqual(rows[0].d, [12]);
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
test("both passes are line-local — a phrase whose ref opens the next line is not collected", () => {
|
|
426
|
-
// The removed regex's `\s+` crossed newlines and did collect these. The
|
|
427
|
-
// narrowing is deliberate (see candidates.mjs's `depnums` comment); this
|
|
428
|
-
// pins it so it stays a decision rather than drifting back by accident.
|
|
429
|
-
const { rows } = run([
|
|
430
|
-
ticket(1, "Blocked by:\n#12\n"),
|
|
431
|
-
ticket(2, "This depends on\n#5 landing first\n"),
|
|
432
|
-
ticket(3, "requires\n#7\n"),
|
|
433
|
-
]);
|
|
434
|
-
assert.deepEqual(rows.map((r) => r.d), [[], [], []]);
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
test("'and' joins refs on an inline label line, the same as a comma", () => {
|
|
438
|
-
const { rows } = run([ticket(9, "Blocked by: #12 and #13\n")]);
|
|
439
|
-
assert.deepEqual(rows[0].d, [12, 13]);
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
test("every declarative phrase arms a heading section, not just 'Blocked by'", () => {
|
|
443
|
-
// Dropping `requires` or `depends on` from the heading alternation left the
|
|
444
|
-
// whole suite green: only `## Blocked by` was ever pinned.
|
|
445
|
-
const { rows } = run([
|
|
446
|
-
ticket(1, "## Requires\n\n- #8\n"),
|
|
447
|
-
ticket(2, "## Depends on\n\n- #9\n"),
|
|
448
|
-
]);
|
|
449
|
-
assert.deepEqual(rows.map((r) => r.d), [[8], [9]]);
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
test("an `after` HEADING arms nothing — it is narrative, not a declaration", () => {
|
|
453
|
-
// `## After the migration` / `## Before` + `## After` are ordinary ticket
|
|
454
|
-
// prose, unlike the three declarative phrases, which head a section only to
|
|
455
|
-
// declare one. A heading that really does name a blocker still resolves,
|
|
456
|
-
// through the inline pass — `after` stays in that alternation.
|
|
457
|
-
const { rows } = run([
|
|
458
|
-
ticket(1, "## After the migration\n\n- see #77 for background\n"),
|
|
459
|
-
ticket(2, "## Before\n\n- old path\n\n## After\n\n- new path short-circuits, see #12\n"),
|
|
460
|
-
ticket(3, "## After #4 lands\n\n- do the thing\n"),
|
|
461
|
-
]);
|
|
462
|
-
assert.deepEqual(rows.map((r) => r.d), [[], [], [4]]);
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
test("the label's asterisks may close BEFORE the colon as well as after it", () => {
|
|
466
|
-
// `**Blocked by:** #12` and `**Blocked by**: #12` are both bold labels a
|
|
467
|
-
// human writes; only the first was covered, and the regex group carrying
|
|
468
|
-
// the second could be deleted with the whole suite still green.
|
|
469
|
-
const { rows } = run([ticket(9, "**Blocked by**: #12\n")]);
|
|
470
|
-
assert.deepEqual(rows[0].d, [12]);
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
test("a bolded REF yields its number — whitespace and asterisks interleave freely between label and ref", () => {
|
|
474
|
-
// #439: the asterisk groups used to sit ahead of the separating whitespace,
|
|
475
|
-
// so only asterisks flush against the label matched. Markdown puts them on
|
|
476
|
-
// the other side of the space, on the ref — which is what #208's brief
|
|
477
|
-
// wrote, and the scan then read that whole section as no dependency at all.
|
|
478
|
-
const { rows } = run([
|
|
479
|
-
ticket(1, "Blocked by **#179** (decides gone shape)\n"),
|
|
480
|
-
ticket(2, "blocked by **#178**\n"),
|
|
481
|
-
ticket(3, "Depends on **#5**\n"),
|
|
482
|
-
ticket(4, "Blocked by: **#12**\n"),
|
|
483
|
-
ticket(5, "**Blocked by:** **#12**\n"),
|
|
484
|
-
ticket(6, "Blocked by *#12*\n"),
|
|
485
|
-
ticket(7, "**Blocked by** : #12\n"),
|
|
486
|
-
]);
|
|
487
|
-
assert.deepEqual(rows.map((r) => r.d), [[179], [178], [5], [12], [12], [12], [12]]);
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
test("a bolded ref AFTER the first one still joins the run — asterisks interleave between refs too", () => {
|
|
491
|
-
// #439's residual, found reviewing the fix: the separator between the label
|
|
492
|
-
// and the first ref was widened, the continuation between refs was not, so
|
|
493
|
-
// the second ref's leading `**` ended the run and the number was dropped —
|
|
494
|
-
// no error, no warning, the same wrong admission #439 was filed for, one ref
|
|
495
|
-
// to the right. Revert the continuation and every row here reds.
|
|
496
|
-
const { rows } = run([
|
|
497
|
-
ticket(1, "Blocked by **#12** and **#13**\n"),
|
|
498
|
-
ticket(2, "Blocked by: **#12**, **#13**\n"),
|
|
499
|
-
ticket(3, "Blocked by #12 and **#13**\n"),
|
|
500
|
-
ticket(4, "Depends on **#5**, #6\n"),
|
|
501
|
-
]);
|
|
502
|
-
assert.deepEqual(rows.map((r) => r.d), [[12, 13], [12, 13], [12, 13], [5, 6]]);
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
test("a bold split landing MID-PHRASE misses the label — ACCEPTED LIMITATION, pinned, not desired behavior", () => {
|
|
506
|
-
// #1033. READ ROWS 1-4 AS A BOUNDARY, NOT AS A SPECIFICATION of what the
|
|
507
|
-
// scan should do. They are shapes an author could plausibly write and the
|
|
508
|
-
// scan does NOT read: the separator AROUND the label tolerates asterisks
|
|
509
|
-
// freely (`**Blocked by:** #12`, `Blocked by **#12**` — the two tests
|
|
510
|
-
// above), but the label PHRASE itself must still appear as one unbroken
|
|
511
|
-
// literal, so emphasis closing BETWEEN its two words drops the ref silently
|
|
512
|
-
// — exit 0, nothing on stderr, the ticket reading as claimable while its
|
|
513
|
-
// blocker is open. Row 3 shows a colon does not rescue it and row 4 that the
|
|
514
|
-
// run length does not matter: it is where the seam falls, not the emphasis,
|
|
515
|
-
// that decides. Measured at 662004f on both engines, agreeing — `/usr/bin/jq`
|
|
516
|
-
// 1.7.1-apple and `gojq` 0.12.19 both return [] for rows 1-4.
|
|
517
|
-
//
|
|
518
|
-
// Widening the alternation to tolerate emphasis INSIDE the phrase was
|
|
519
|
-
// considered at triage and refused, for two reasons worth keeping here:
|
|
520
|
-
// - Nothing produces this shape. to-tickets' templates bold the whole
|
|
521
|
-
// label (`**Blocked by:**`) or the whole ref (`Blocked by **#12**`),
|
|
522
|
-
// never split the two words — the form is derived from the regex, never
|
|
523
|
-
// observed in a real body.
|
|
524
|
-
// - A label alternation loosened for bold is the exact class of change
|
|
525
|
-
// that reopened the phantom-blocker sweep before; "the phantom-blocker
|
|
526
|
-
// sweep stays closed against the widened label and heading gates" below
|
|
527
|
-
// is what catches that. Widening spends the expensive half of the trade
|
|
528
|
-
// on a shape nobody writes.
|
|
529
|
-
//
|
|
530
|
-
// So, to a future widener: this fixture going red is the PROMPT, not a
|
|
531
|
-
// regression. Before flipping rows 1-4 to expect numbers, re-measure the
|
|
532
|
-
// phantom-blocker sweep on BOTH engines — system jq (Oniguruma) and gojq
|
|
533
|
-
// (RE2, the one gh actually applies) — because a loosened label gate is
|
|
534
|
-
// what reopens that sweep, and the two engines need not agree about it.
|
|
535
|
-
//
|
|
536
|
-
// Rows 5-7 are the controls, and are what keeps this from being a vacuous
|
|
537
|
-
// pin: the seam forms — emphasis closing at the phrase boundary, or absent
|
|
538
|
-
// altogether — still resolve. Break the scan outright and rows 1-4 stay
|
|
539
|
-
// green while 5-7 red.
|
|
540
|
-
const { rows } = run([
|
|
541
|
-
ticket(1, "**Blocked** by #12\n"),
|
|
542
|
-
ticket(2, "**Depends** on #5\n"),
|
|
543
|
-
ticket(3, "**Blocked** by: #12\n"),
|
|
544
|
-
ticket(4, "*Blocked* by #12\n"),
|
|
545
|
-
ticket(5, "**Blocked by** #12\n"),
|
|
546
|
-
ticket(6, "**Depends on** #5\n"),
|
|
547
|
-
ticket(7, "Blocked by #12\n"),
|
|
548
|
-
]);
|
|
549
|
-
assert.deepEqual(rows.map((r) => r.d), [[], [], [], [], [12], [5], [12]]);
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
test("a noun-form Dependencies heading arms a section, at any heading depth and with a trailing colon", () => {
|
|
553
|
-
// #439's second, independent miss: the gate named the verb forms only, so
|
|
554
|
-
// the heading #208's brief actually used opened nothing, and the list-item
|
|
555
|
-
// branch never engaged either. Both routes into that section failed.
|
|
556
|
-
const { rows } = run([
|
|
557
|
-
ticket(1, "## Dependencies\n\n- #12\n- #13\n"),
|
|
558
|
-
ticket(2, "## Dependency\n\n- #12\n"),
|
|
559
|
-
ticket(3, "### Dependencies:\n\n- #12\n"),
|
|
560
|
-
ticket(4, "###### Dependencies\n\n- #12\n"),
|
|
561
|
-
]);
|
|
562
|
-
assert.deepEqual(rows.map((r) => r.d), [[12, 13], [12], [12], [12]]);
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
test("a bolded dependency heading arms its section — emphasis is not a different heading", () => {
|
|
566
|
-
// #1031: the gate admitted no emphasis at all, so `## **Dependencies**` armed
|
|
567
|
-
// NO section and every ref its bullets declared was dropped — exit 0, nothing
|
|
568
|
-
// on stderr, the same silent wrong admission #439 was filed for — reached
|
|
569
|
-
// through the heading gate rather than through the inline label separator
|
|
570
|
-
// #439 widened. Both emphasis runs are load-bearing: markdown
|
|
571
|
-
// closes the bold either before the colon (`**Dependencies**:`) or after it
|
|
572
|
-
// (`**Dependencies:**`), and the run is `*`, `**` or `***` depending on
|
|
573
|
-
// whether the author wanted italic, bold or both. Substitute the
|
|
574
|
-
// `\*{0,2}` pair the ticket hypothesised — one leading run, one ahead of the
|
|
575
|
-
// colon and none after it — and rows 5 and 8 red, on both engines.
|
|
576
|
-
const { rows } = run([
|
|
577
|
-
ticket(1, "## **Dependencies**\n\n- #12\n- #13\n"),
|
|
578
|
-
ticket(2, "## **Blocked by**\n\n- #12\n"),
|
|
579
|
-
ticket(3, "## **Depends on**\n\n- #9\n"),
|
|
580
|
-
ticket(4, "## **Requires**\n\n- #8\n"),
|
|
581
|
-
ticket(5, "## **Dependencies:**\n\n- #12\n"),
|
|
582
|
-
ticket(6, "## **Dependencies**:\n\n- #12\n"),
|
|
583
|
-
ticket(7, "## *Dependencies*\n\n- #12\n"),
|
|
584
|
-
ticket(8, "## ***Dependencies***\n\n- #12\n"),
|
|
585
|
-
ticket(9, "###### **Dependency**\n\n- #12\n"),
|
|
586
|
-
]);
|
|
587
|
-
assert.deepEqual(
|
|
588
|
-
rows.map((r) => r.d),
|
|
589
|
-
[[12, 13], [12], [9], [8], [12], [12], [12], [12], [12]],
|
|
590
|
-
);
|
|
591
|
-
});
|
|
592
|
-
|
|
593
|
-
test("the noun form arms only when it is the WHOLE heading — bolded or not, a Dependency-injection section is prose", () => {
|
|
594
|
-
// The verb forms end at `\b` and tolerate trailing text, because a heading
|
|
595
|
-
// opening with `Blocked by` declares one whatever follows it. The noun form
|
|
596
|
-
// cannot afford that: `## Dependency injection` is an ordinary section title
|
|
597
|
-
// in a code repo, and arming on it turns every `#N` in its bullets into a
|
|
598
|
-
// blocker the body never declared, starving the ticket out of the queue —
|
|
599
|
-
// the same over-fire the list-item restriction exists to prevent. Anchoring
|
|
600
|
-
// the noun alternative to end-of-line is what keeps these three closed;
|
|
601
|
-
// widen it to `\b` like its neighbours and this test is what reds.
|
|
602
|
-
//
|
|
603
|
-
// The bolded halves are #1031's other side: emphasis tolerance is added
|
|
604
|
-
// AROUND that anchor, never by relaxing it, so the run of asterisks must not
|
|
605
|
-
// smuggle in the prefix match the anchor exists to refuse. The runs match
|
|
606
|
-
// ASTERISKS only, which is what keeps ` injection` outside them — spell
|
|
607
|
-
// either one as a general wildcard (`.*`) and all six rows arm, silently
|
|
608
|
-
// inventing #300 as a blocker on every DI section in the queue.
|
|
609
|
-
const { rows } = run([
|
|
610
|
-
ticket(1, "## Dependency injection\n\n- rework the container, see #300\n"),
|
|
611
|
-
ticket(2, "## Dependencies (blocking)\n\n- #300\n"),
|
|
612
|
-
ticket(3, "## Dependency injection:\n\n- see #300\n"),
|
|
613
|
-
ticket(4, "## **Dependency injection**\n\n- rework the container, see #300\n"),
|
|
614
|
-
ticket(5, "## **Dependencies (blocking)**\n\n- #300\n"),
|
|
615
|
-
ticket(6, "## **Dependency injection:**\n\n- see #300\n"),
|
|
616
|
-
]);
|
|
617
|
-
assert.deepEqual(rows.map((r) => r.d), [[], [], [], [], [], []]);
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
test("#208's own brief text yields both of the open blockers it declared in prose", () => {
|
|
621
|
-
// The live wrong admission #439 was filed from: this section reduced to no
|
|
622
|
-
// dependency at all, so a ticket with two open blockers reached the survivor
|
|
623
|
-
// read as claimable. What this fixture pins is the noun-form heading half:
|
|
624
|
-
// its bolded refs sit on list-item lines inside the armed section, so the
|
|
625
|
-
// list-item branch reads them whatever the label separator does — revert
|
|
626
|
-
// that separator to its pre-#439 form and this row stays green, while
|
|
627
|
-
// reverting the heading gate to the verb forms is what reds it. The
|
|
628
|
-
// separator half is pinned by the two bolded-ref tests above instead.
|
|
629
|
-
// The `PR #390` bullet is collected too: in-section collection reads every
|
|
630
|
-
// `#N` on a list-item line by construction, and a merged ref is inert at the
|
|
631
|
-
// consumer, which drops a ticket only for a blocker that is still open.
|
|
632
|
-
const { rows } = run([
|
|
633
|
-
ticket(208, [
|
|
634
|
-
"## Dependencies",
|
|
635
|
-
"",
|
|
636
|
-
"- Blocked by **#179** (decides `gone()`'s shape, which `Indeterminate` needs), which is itself blocked by **#178**.",
|
|
637
|
-
"- Vocabulary from **PR #390**.",
|
|
638
|
-
"",
|
|
639
|
-
"Recording those as native dependency edges so the fleet does not claim this early.",
|
|
640
|
-
"",
|
|
641
|
-
].join("\n")),
|
|
642
|
-
]);
|
|
643
|
-
assert.deepEqual(rows[0].d, [178, 179, 390]);
|
|
644
|
-
});
|
|
645
|
-
|
|
646
|
-
test("the phantom-blocker sweep stays closed against the widened label and heading gates", () => {
|
|
647
|
-
// PR #331 closed these by restricting in-section collection to list-item
|
|
648
|
-
// lines. #439 loosens the label separator and widens the heading gate,
|
|
649
|
-
// neither of which touches that restriction — this pins that they did not,
|
|
650
|
-
// because a regex widened for bold is exactly the change that reopens them.
|
|
651
|
-
// The noun-form rows carry the same shapes through the newly-armed heading,
|
|
652
|
-
// and #1031's bolded rows carry them once more through the emphasis the gate
|
|
653
|
-
// tolerates next: a section armed by `## **Dependencies**` reads its LIST ITEMS
|
|
654
|
-
// only, exactly as the unbolded one does, so the prose ref in row 8 and the
|
|
655
|
-
// fenced one in row 9 stay out of `d`. Widening the gate does not widen what
|
|
656
|
-
// an armed section then sweeps, and that is the half this re-run pins.
|
|
657
|
-
const { rows } = run([
|
|
658
|
-
ticket(1, "## Blocked by\n\nSee #99 for context\n"),
|
|
659
|
-
ticket(2, "## Blocked by\n\n- #1\n\nSome later text mentioning #42\n"),
|
|
660
|
-
// Row 3 is kept to pin an ACCEPTANCE CRITERION, not to discriminate a
|
|
661
|
-
// mutant — #439's own criteria name this shape verbatim among the four the
|
|
662
|
-
// phantom-blocker sweep must keep closed: "a fenced code block containing
|
|
663
|
-
// `fixes #77` → `[]`". It is the executable record that that criterion
|
|
664
|
-
// holds, and that is the whole job it is here for. Under the mutant this
|
|
665
|
-
// test's NAME invokes — `$nextsec and $item` → `$nextsec`, dropping #331's
|
|
666
|
-
// list-item restriction — every other row in this table moves and row 3
|
|
667
|
-
// does not: no heading arms a section here, so that restriction is never
|
|
668
|
-
// reached. Both facts measured. Do not delete it on the second one; it has
|
|
669
|
-
// already been re-filed on exactly that reading once (#1034).
|
|
670
|
-
// Row 6 is the SIBLING that covers the fenced case with real discriminating
|
|
671
|
-
// power — a fence inside an armed `## Dependencies` section, which answers
|
|
672
|
-
// `[12, 999]` under that same mutant (row 9 is its bolded twin). The two
|
|
673
|
-
// are not duplicates and neither subsumes the other: row 6 discriminates
|
|
674
|
-
// the mutant, row 3 records the criterion — and row 3 is in fact the only
|
|
675
|
-
// row here that moves when the inline verb alternation is widened to admit
|
|
676
|
-
// `fixes`, where it answers `[77]` and every other row holds still.
|
|
677
|
-
ticket(3, "```\nfixes #77\n```\n"),
|
|
678
|
-
ticket(4, "## Dependencies\n\n- #12 and then\n more about #999\n"),
|
|
679
|
-
ticket(5, "## Dependencies\n\nSee #99 for context\n"),
|
|
680
|
-
ticket(6, "## Dependencies\n\n- #12\n\n```\ngit log #999\n```\n"),
|
|
681
|
-
ticket(7, "## **Dependencies**\n\n- #12 and then\n more about #999\n"),
|
|
682
|
-
ticket(8, "## **Blocked by**\n\nSee #99 for context\n"),
|
|
683
|
-
ticket(9, "## **Dependencies**\n\n- #12\n\n```\ngit log #999\n```\n"),
|
|
684
|
-
ticket(10, "## **Dependencies**\n\n- None — can start immediately\n\nMirror what #300 did.\n"),
|
|
685
|
-
]);
|
|
686
|
-
assert.deepEqual(
|
|
687
|
-
rows.map((r) => r.d),
|
|
688
|
-
[[], [1], [], [12], [], [12], [12], [], [12], []],
|
|
689
|
-
);
|
|
690
|
-
});
|
|
691
|
-
|
|
692
|
-
// #1032. The per-candidate row prints `deps:` only when `d` is non-empty, so a
|
|
693
|
-
// heading that named a dependency the gate refused printed EXACTLY the row of a
|
|
694
|
-
// ticket that declared none — and the refusal is by design (`## Dependencies
|
|
695
|
-
// (blocking)`, two tests above), so that shape declared blockers into a void
|
|
696
|
-
// with nothing said. The new line is the signal, and matching on its wording is
|
|
697
|
-
// the point rather than an accident: #1032's central constraint is that it reads
|
|
698
|
-
// as "declared, not parsed" and never as a fault, because the near-miss is
|
|
699
|
-
// legitimate usage and a fault-worded diagnostic false-alarms on every ticket
|
|
700
|
-
// using it.
|
|
701
|
-
const MISS = /not parsed as a dependency section/;
|
|
702
|
-
const missLines = (stderr) => stderr.split("\n").filter((l) => MISS.test(l));
|
|
703
|
-
|
|
704
|
-
test("a dependency heading that armed no section is named on stderr, and an armed one is not (#1032)", () => {
|
|
705
|
-
const { status, stdout, stderr, rows } = run([
|
|
706
|
-
// The near-miss the gate refuses on purpose: fires.
|
|
707
|
-
ticket(1, "## Dependencies (blocking)\n\n- #300\n"),
|
|
708
|
-
// No dependency heading at all — a `#N` in ordinary prose is not one: silent.
|
|
709
|
-
ticket(2, "## Notes\n\n- see #300 for context\n"),
|
|
710
|
-
// Armed correctly, refs collected: silent. The signal is about the
|
|
711
|
-
// near-miss, not about every heading that mentions the concept.
|
|
712
|
-
ticket(3, "## Dependencies\n\n- #12\n"),
|
|
713
|
-
// The deliberate over-fire. Detection is LOOSER than the gate because the
|
|
714
|
-
// headings worth naming are the ones the gate rejected — tighten it to the
|
|
715
|
-
// gate and nothing is ever reported, which is what the neutral wording
|
|
716
|
-
// below pays for.
|
|
717
|
-
ticket(4, "## Dependency injection\n\n- rework the container, see #300\n"),
|
|
718
|
-
// One line per CANDIDATE, not per heading.
|
|
719
|
-
ticket(5, "## Dependencies (blocking)\n\n- #300\n\n## Dependency injection\n\n- see #42\n"),
|
|
720
|
-
]);
|
|
721
|
-
const lines = missLines(stderr);
|
|
722
|
-
assert.deepEqual(lines.map((l) => l.match(/#(\d+)/)[1]), ["1", "4", "5"], stderr);
|
|
723
|
-
assert.ok(lines[0].includes("'## Dependencies (blocking)'"), lines[0]);
|
|
724
|
-
assert.ok(lines[1].includes("'## Dependency injection'"), lines[1]);
|
|
725
|
-
assert.ok(
|
|
726
|
-
lines[2].includes("'## Dependencies (blocking)'") && lines[2].includes("'## Dependency injection'"),
|
|
727
|
-
lines[2],
|
|
728
|
-
);
|
|
729
|
-
// Points at the heading, and reads as a fact about the scan rather than a
|
|
730
|
-
// fault in the ticket. Both halves of that are load-bearing: a line worded
|
|
731
|
-
// as an error is the false alarm #1032 refuses, and a line that names no
|
|
732
|
-
// heading leaves the reader to guess which one the scan skipped.
|
|
733
|
-
assert.ok(lines[0].includes("check the heading"), lines[0]);
|
|
734
|
-
assert.doesNotMatch(lines[0], /error|fail|invalid|malformed|broken|warning|must /i);
|
|
735
|
-
// The row format is untouched: #1 still prints no `deps:` — the empty list is
|
|
736
|
-
// still an empty list — and #3 still prints its refs the same way.
|
|
737
|
-
assert.match(stderr, /^ {4}#1 \[ready-for-agent\] ticket 1$/m);
|
|
738
|
-
assert.match(stderr, /^ {4}#3 \[ready-for-agent\] ticket 3 {2}deps:12$/m);
|
|
739
|
-
// Exit status and payload unchanged. The heading text reaches this process as
|
|
740
|
-
// a jq field (the body never does), so the assertion that matters is that the
|
|
741
|
-
// field is stripped before stdout: phase 0 and fleet-tick's readSupply() read the
|
|
742
|
-
// same four keys they read before — `spec` is the reduction's other
|
|
743
|
-
// stderr-only field, and `dropSpecs` has already destructured that one out.
|
|
744
|
-
assert.equal(status, 0);
|
|
745
|
-
assert.deepEqual(rows.map((r) => r.d), [[], [], [12], [], []]);
|
|
746
|
-
for (const r of rows) assert.deepEqual(Object.keys(r).sort(), ["d", "l", "n", "t"]);
|
|
747
|
-
assert.doesNotMatch(stdout, /dh/);
|
|
748
|
-
});
|
|
749
|
-
|
|
750
|
-
// #1741. `d` is the union of the body scan and the issue's native "blocked by"
|
|
751
|
-
// edges. Fixtures carry `blockedBy` in the shape gh 2.100.0 emits —
|
|
752
|
-
// `{nodes:[{number,state,…}], totalCount}` — and the STUB cuts every fixture
|
|
753
|
-
// down to candidates.mjs's own `--json` list the way real gh does, so these
|
|
754
|
-
// rows also pin that the query ASKS for the field: take `blockedBy` out of it
|
|
755
|
-
// and no edge ever arrives. Every fixture before this block carries no
|
|
756
|
-
// `blockedBy` at all, so each earlier `d` pin, unmodified, is also the pin
|
|
757
|
-
// that an issue without edges still reduces to the body scan alone.
|
|
758
|
-
const edges = (...nodes) => ({
|
|
759
|
-
nodes: nodes.map(([number, state]) => ({ number, state })),
|
|
760
|
-
totalCount: nodes.length,
|
|
761
|
-
});
|
|
762
|
-
const withEdges = (t, blockedBy) => ({ ...t, blockedBy });
|
|
763
|
-
// #593's blocker line, verbatim from the live issue. Its first parenthetical
|
|
764
|
-
// breaks the scan's ref chain, so the body alone yields [239] and never #531 —
|
|
765
|
-
// the admission gap #1741 was filed on, left in place (the grammar is out of
|
|
766
|
-
// scope), so the native edge is the only thing carrying #531.
|
|
767
|
-
const BODY_593 =
|
|
768
|
-
"**Blocked by #239** (the new bar must exist before anything is re-labelled against it) and **#531** (the dedupe guard's ledger arm is empty, so an unknown share of the pile is duplicates — promoting duplicates is worse than filing them).\n";
|
|
769
|
-
// A blocker list longer than the one page gh fetches (`blockedBy(first:50)`).
|
|
770
|
-
const SHORT_50_OF_51 = {
|
|
771
|
-
nodes: Array.from({ length: 50 }, (_, i) => ({ number: 100 + i, state: "OPEN" })),
|
|
772
|
-
totalCount: 51,
|
|
773
|
-
};
|
|
774
|
-
|
|
775
|
-
test("#593's shape: the blocker the body scan misses reaches `d` through its native edge, and the shared one lands once (#1741)", () => {
|
|
776
|
-
// #592 is the same body with no edge: the scan's own answer, which is the
|
|
777
|
-
// gap. #593's edges arrive 531-first; `d` comes out sorted and deduplicated,
|
|
778
|
-
// so #239 — named by both the body and an edge — appears exactly once.
|
|
779
|
-
const { status, rows, stderr } = run([
|
|
780
|
-
ticket(592, BODY_593),
|
|
781
|
-
withEdges(ticket(593, BODY_593), edges([531, "OPEN"], [239, "CLOSED"])),
|
|
782
|
-
]);
|
|
783
|
-
assert.equal(status, 0, stderr);
|
|
784
|
-
assert.deepEqual(rows.map((r) => r.d), [[239], [239, 531]]);
|
|
785
|
-
});
|
|
786
|
-
|
|
787
|
-
test("edges alone make `d` when the body names no blocker — a closed one kept, as the scan keeps one (#1741)", () => {
|
|
788
|
-
// `d` stays RAW: openness is the consumer's call (run-team / next-ticket
|
|
789
|
-
// step 2), so an edge's CLOSED state does not filter its number out here.
|
|
790
|
-
const { rows } = run([withEdges(ticket(9, "## What to build\n\nx\n"), edges([12, "OPEN"], [7, "CLOSED"]))]);
|
|
791
|
-
assert.deepEqual(rows[0].d, [7, 12]);
|
|
792
|
-
});
|
|
793
|
-
|
|
794
|
-
test("a blocker list gh cut short refuses at exit 2 — `d` never ships with blockers missing (#1741)", () => {
|
|
795
|
-
// Unreachable today (GitHub caps an issue at 50 edges per relationship, and
|
|
796
|
-
// gh fetches 50), which is exactly why it must be loud if either moves: a
|
|
797
|
-
// truncated list reads as a smaller one, and #12's 51st blocker would drop
|
|
798
|
-
// out of `d` with nothing said. The whole query refuses, like a capped
|
|
799
|
-
// list does, and the message names the issue and the shortfall.
|
|
800
|
-
const { status, stderr } = run([
|
|
801
|
-
ticket(11, "## What to build\n\nx\n"),
|
|
802
|
-
withEdges(ticket(12, "## What to build\n\nx\n"), SHORT_50_OF_51),
|
|
803
|
-
]);
|
|
804
|
-
assert.equal(status, 2, stderr);
|
|
805
|
-
assert.match(stderr, /#12: blockedBy lists 50 of 51 blockers, so d would miss the rest/);
|
|
806
|
-
assert.match(stderr, /^candidates: gh issue list failed/m);
|
|
807
|
-
});
|
|
808
|
-
|
|
809
|
-
// The gap #63 named: the STUB above execs system jq (Oniguruma), but gh
|
|
810
|
-
// applies `--jq` with its embedded gojq (RE2) — a different engine, and every
|
|
811
|
-
// other test in this file accepts that gap rather than closing it. This one
|
|
812
|
-
// closes it for the dependency scan specifically, since #58 asks for it by
|
|
813
|
-
// name: when a real `gojq` binary is reachable (`go install
|
|
814
|
-
// github.com/itchyny/gojq/cmd/gojq@v0.12.19`), the STUB runs the fixtures
|
|
815
|
-
// through it instead of system jq, so the regex is checked against the exact
|
|
816
|
-
// engine gh uses — not merely a same-family stand-in. No `gojq` on this
|
|
817
|
-
// machine → skip, loudly, rather than silently passing on the weaker engine.
|
|
818
|
-
// Answering `--version` is not the same as BEING gojq: system jq answers it
|
|
819
|
-
// too, and resolving to it would run the fixtures on Oniguruma under a name
|
|
820
|
-
// claiming RE2 — the silent degrade this whole check exists to refuse. gojq
|
|
821
|
-
// prints `gojq 0.12.19 (rev: …)`, jq prints `jq-1.7.1-apple`.
|
|
822
|
-
// Single source of truth for "is this gojq" — isGojq (which engine ran the
|
|
823
|
-
// --version probe) and assertRanGojq (which engine the STUB recorded) each
|
|
824
|
-
// own their own site under #383, and only sharing this pattern by
|
|
825
|
-
// construction keeps them from silently desyncing if gojq's version-string
|
|
826
|
-
// format ever changes: a future edit to one site would otherwise quietly
|
|
827
|
-
// reopen the exact "gated test proved nothing" failure mode #383 is fixing.
|
|
828
|
-
const GOJQ_VERSION_RE = /^gojq /;
|
|
829
|
-
const isGojq = (bin) =>
|
|
830
|
-
GOJQ_VERSION_RE.test(spawnSync(bin, ["--version"], { encoding: "utf8" }).stdout ?? "");
|
|
831
|
-
|
|
832
|
-
function findGojq() {
|
|
833
|
-
const named = process.env.GOJQ_BIN;
|
|
834
|
-
// A caller who names the binary asked for that engine. Falling back past it
|
|
835
|
-
// would run the check on something else and still report the gojq test green.
|
|
836
|
-
if (named && !isGojq(named)) throw new Error(`GOJQ_BIN=${named} is not gojq`);
|
|
837
|
-
if (named) return named;
|
|
838
|
-
if (isGojq("gojq")) return "gojq";
|
|
839
|
-
// No `go` on PATH → spawnSync fails ENOENT and `stdout` is undefined, not "".
|
|
840
|
-
// Without `?.` this throws at import, taking every test in the file with it —
|
|
841
|
-
// the opposite of the loud skip the comment above promises.
|
|
842
|
-
const gopath = spawnSync("go", ["env", "GOPATH"], { encoding: "utf8" }).stdout?.trim();
|
|
843
|
-
if (!gopath) return null;
|
|
844
|
-
const candidate = join(gopath, "bin", "gojq");
|
|
845
|
-
return isGojq(candidate) ? candidate : null;
|
|
846
|
-
}
|
|
847
|
-
const GOJQ = findGojq();
|
|
848
|
-
const SKIP_WITHOUT_GOJQ = { skip: GOJQ ? false : "no gojq on PATH — go install github.com/itchyny/gojq/cmd/gojq@v0.12.19 to run this check" };
|
|
849
|
-
|
|
850
|
-
// What proves a gated test REACHED gojq (#383). Until these rulings the proof
|
|
851
|
-
// was indirect: one fixture per test that the two engines ANSWERED
|
|
852
|
-
// differently — a U+00A0 that reduced to [12] under Oniguruma and [] under
|
|
853
|
-
// RE2. The rulings removed every such row on purpose, so all 24 fixtures now
|
|
854
|
-
// agree on both engines, and no assertion about OUTPUT can say which engine
|
|
855
|
-
// produced it any more. The STUB therefore records the --version of the
|
|
856
|
-
// binary it executed and this reads that recording, applying the very test
|
|
857
|
-
// isGojq does. A strengthening of the harness, not a thinning of it
|
|
858
|
-
// (.out-of-scope/gojq-parity-harness.md): the old discriminator proved the
|
|
859
|
-
// engine only as a side effect of one disagreeing row, so it went blind the
|
|
860
|
-
// moment that row was ruled, and it proved nothing about the OTHER assertions
|
|
861
|
-
// in its own test — this proves it directly, for every gated assertion, and
|
|
862
|
-
// keeps proving it however the fixtures are ruled later. Mutation-checked:
|
|
863
|
-
// delete the STUB's JQ_RAN plumb and every gated test reds here.
|
|
864
|
-
const assertRanGojq = (r) =>
|
|
865
|
-
assert.match(
|
|
866
|
-
r.engine,
|
|
867
|
-
GOJQ_VERSION_RE,
|
|
868
|
-
`the STUB recorded ${JSON.stringify(r.engine)} — this gated test never reached gojq`,
|
|
869
|
-
);
|
|
870
|
-
|
|
871
|
-
// The pre-#383 program, verbatim (from the commit #383's own diff replaced),
|
|
872
|
-
// kept here ONLY so the discriminating test below can run it through
|
|
873
|
-
// JQ_OVERRIDE and prove what it actually did on system jq — the engine the
|
|
874
|
-
// three gojq-only fixtures below #908 cannot reach, because RE2 was already
|
|
875
|
-
// ASCII-only at every one of these positions before #383 too, so gojq never
|
|
876
|
-
// had the bug being fixed. Never used to run the real query; the current JQ
|
|
877
|
-
// constant in candidates.mjs is the only one this script ever ships with.
|
|
878
|
-
const OLD_JQ =
|
|
879
|
-
'def armed: test("(?i)^#{1,6}\\\\s+\\\\**((?:depends on|blocked by|requires)\\\\b|dependenc(?:y|ies)\\\\**:?\\\\**\\\\s*$)");\n' +
|
|
880
|
-
'\n' +
|
|
881
|
-
'def depmiss:\n' +
|
|
882
|
-
' [ split("\\n")[]\n' +
|
|
883
|
-
' | select(test("(?i)^#{1,6}\\\\s.*(dependenc|blocked by|depends on|requires)") and (armed | not))\n' +
|
|
884
|
-
' | rtrimstr("\\r")\n' +
|
|
885
|
-
' ];\n' +
|
|
886
|
-
'\n' +
|
|
887
|
-
'def depnums:\n' +
|
|
888
|
-
' (reduce (split("\\n"))[] as $line (\n' +
|
|
889
|
-
' {insec: false, nums: []};\n' +
|
|
890
|
-
' ($line | armed) as $bh\n' +
|
|
891
|
-
' | ($line | test("^#{1,6}\\\\s")) as $any\n' +
|
|
892
|
-
' | (if $any then $bh else .insec end) as $nextsec\n' +
|
|
893
|
-
' | ($line | test("^\\\\s*([-*+]|[0-9]+[.)])\\\\s")) as $item\n' +
|
|
894
|
-
' | {\n' +
|
|
895
|
-
' insec: $nextsec,\n' +
|
|
896
|
-
' nums: (\n' +
|
|
897
|
-
' .nums\n' +
|
|
898
|
-
' + (if $nextsec and $item then [$line | scan("#\\\\d+")] else [] end)\n' +
|
|
899
|
-
' + [ $line\n' +
|
|
900
|
-
' | scan("(?i)(?:depends on|blocked by|requires|after)[\\\\s*]*:?[\\\\s*]*(#\\\\d+(?:[\\\\s*]*(?:,|and)?[\\\\s*]*#\\\\d+)*)")\n' +
|
|
901
|
-
' | .[0]\n' +
|
|
902
|
-
' | scan("#\\\\d+")\n' +
|
|
903
|
-
' ]\n' +
|
|
904
|
-
' )\n' +
|
|
905
|
-
' }\n' +
|
|
906
|
-
' )).nums\n' +
|
|
907
|
-
' | map(ltrimstr("#") | tonumber)\n' +
|
|
908
|
-
' | unique;\n' +
|
|
909
|
-
'\n' +
|
|
910
|
-
'[.[] | {n:.number,t:.title,l:[.labels[].name],\n' +
|
|
911
|
-
' spec:((.body//"")|test("(?m)^#{2,6}[ \\\\t]+User Stories\\\\s*$")),\n' +
|
|
912
|
-
' d:((.body//"")|depnums),\n' +
|
|
913
|
-
' dh:((.body//"")|depmiss)}]\n';
|
|
914
|
-
|
|
915
|
-
test(
|
|
916
|
-
"dependency forms hold under gojq, the engine gh actually applies — not only system jq",
|
|
917
|
-
SKIP_WITHOUT_GOJQ,
|
|
918
|
-
() => {
|
|
919
|
-
const extraEnv = { JQ_BIN: GOJQ };
|
|
920
|
-
// gojq REJECTING the program is the failure this test exists to catch. Read
|
|
921
|
-
// the exit status first: `rows[0]` is undefined the moment the child exits
|
|
922
|
-
// non-zero, so without this the report is `Cannot read properties of
|
|
923
|
-
// undefined (reading 'd')`, naming neither gojq nor the refusal it printed.
|
|
924
|
-
const deps = (body) => {
|
|
925
|
-
const r = run([ticket(9, body)], undefined, null, extraEnv);
|
|
926
|
-
assert.equal(r.status, 0, r.stderr);
|
|
927
|
-
// Every form, not just one row: the proof is per-application, so no
|
|
928
|
-
// assertion below can pass having silently run on system jq.
|
|
929
|
-
assertRanGojq(r);
|
|
930
|
-
return r.rows[0].d;
|
|
931
|
-
};
|
|
932
|
-
assert.deepEqual(deps("## Blocked by\n\n- #12\n- #13\n"), [12, 13]);
|
|
933
|
-
assert.deepEqual(deps("## Blocked by\n\n- None — can start immediately\n"), []);
|
|
934
|
-
assert.deepEqual(deps("- A reference to #77 blocking ticket\n"), []);
|
|
935
|
-
assert.deepEqual(deps("**Blocked by:** #12\n"), [12]);
|
|
936
|
-
assert.deepEqual(deps("depends on #5\n"), [5]);
|
|
937
|
-
assert.deepEqual(deps("Blocked by: #12, #13\n"), [12, 13]);
|
|
938
|
-
assert.deepEqual(deps("## Blocked by\n\n- #12\n\n## Notes\n\nsee #999 for context\n"), [12]);
|
|
939
|
-
// #439's two forms, on the engine that produced the live wrong admission.
|
|
940
|
-
assert.deepEqual(deps("Blocked by **#179**\n"), [179]);
|
|
941
|
-
assert.deepEqual(deps("Blocked by: **#12**\n"), [12]);
|
|
942
|
-
assert.deepEqual(deps("Blocked by **#12** and **#13**\n"), [12, 13]);
|
|
943
|
-
assert.deepEqual(deps("Blocked by: **#12**, **#13**\n"), [12, 13]);
|
|
944
|
-
assert.deepEqual(deps("**Blocked by** : #12\n"), [12]);
|
|
945
|
-
assert.deepEqual(deps("## Dependencies\n\n- #12\n- #13\n"), [12, 13]);
|
|
946
|
-
assert.deepEqual(deps("## Dependency injection\n\n- see #300\n"), []);
|
|
947
|
-
assert.deepEqual(deps("## Blocked by\n\nSee #99 for context\n"), []);
|
|
948
|
-
// #1031's widened heading gate, on the engine gh actually applies. The
|
|
949
|
-
// emphasis runs are plain `\*`, which Oniguruma and RE2 spell alike — so
|
|
950
|
-
// these rows are expected to AGREE with the system-jq fixtures above, and
|
|
951
|
-
// exist to confirm that rather than because a divergence was found. The
|
|
952
|
-
// negative rows matter most here: RE2 has no backtracking, so a `$` anchor
|
|
953
|
-
// reached through a widened alternation is exactly where the two engines
|
|
954
|
-
// could have parted, and `## **Dependency injection**` arming under gojq
|
|
955
|
-
// alone would be invisible to every other test in this file.
|
|
956
|
-
assert.deepEqual(deps("## **Dependencies**\n\n- #12\n- #13\n"), [12, 13]);
|
|
957
|
-
assert.deepEqual(deps("## **Blocked by**\n\n- #12\n"), [12]);
|
|
958
|
-
assert.deepEqual(deps("## **Dependencies:**\n\n- #12\n"), [12]);
|
|
959
|
-
assert.deepEqual(deps("## ***Dependencies***\n\n- #12\n"), [12]);
|
|
960
|
-
assert.deepEqual(deps("## **Dependency injection**\n\n- see #300\n"), []);
|
|
961
|
-
assert.deepEqual(deps("## **Dependency injection:**\n\n- see #300\n"), []);
|
|
962
|
-
assert.deepEqual(deps("## **Dependencies (blocking)**\n\n- #300\n"), []);
|
|
963
|
-
assert.deepEqual(deps("## **Dependencies**\n\nSee #99 for context\n"), []);
|
|
964
|
-
// #1033's ACCEPTED LIMITATION, carried onto the engine gh applies — see
|
|
965
|
-
// "a bold split landing MID-PHRASE misses the label" above for the ruling
|
|
966
|
-
// and for what a widener owes. The [] rows are NOT a spec: they record
|
|
967
|
-
// that a seam landing mid-phrase is missed, and being here says the gap
|
|
968
|
-
// is a property of the alternation and not an engine artifact — measured,
|
|
969
|
-
// both engines agree. The paired seam row is the control, so a scan broken
|
|
970
|
-
// outright reds this block rather than confirming the limitation.
|
|
971
|
-
assert.deepEqual(deps("**Blocked** by #12\n"), []);
|
|
972
|
-
assert.deepEqual(deps("**Depends** on #5\n"), []);
|
|
973
|
-
assert.deepEqual(deps("**Blocked by** #12\n"), [12]);
|
|
974
|
-
// #383's inline-separator ruling: `[\t \p{Zs}*]*`, so a U+00A0 between
|
|
975
|
-
// label and ref IS a separator and the ref IS a blocker. GFM renders
|
|
976
|
-
// `Blocked by:<NBSP>#12` as `Blocked by: #12` and autolinks the ref, so a
|
|
977
|
-
// reader sees a dependency — and an admission gate must not be the one
|
|
978
|
-
// thing that misses it. This row asserted [] until the ruling: gojq's
|
|
979
|
-
// answer, adopted because it was production's and never because anyone
|
|
980
|
-
// ruled it correct. Both engines now say [12]. Keep the `\u00a0` escape:
|
|
981
|
-
// a literal NBSP does not survive being copied.
|
|
982
|
-
assert.deepEqual(deps("Blocked by:\u00a0#12\n"), [12]);
|
|
983
|
-
// The same ruling through #439's widened separator, which now spells the
|
|
984
|
-
// class instead of inheriting `\s`, so the bolded form agrees with the
|
|
985
|
-
// bare one rather than inheriting a split.
|
|
986
|
-
assert.deepEqual(deps("Blocked by:\u00a0**#12**\n"), [12]);
|
|
987
|
-
// The separator BETWEEN refs takes that class too, so a chain does not
|
|
988
|
-
// stop at the first ref when a NBSP follows the comma — gojq collected
|
|
989
|
-
// [12] alone here.
|
|
990
|
-
assert.deepEqual(deps("Blocked by #12,\u00a0#13\n"), [12, 13]);
|
|
991
|
-
// `\d` → `[0-9]` (#383). Arabic-Indic digits are not refs anyone is trying
|
|
992
|
-
// to support, and this is the one position where the divergence could take
|
|
993
|
-
// the whole RUN down rather than change a row: under Oniguruma `\d` matched
|
|
994
|
-
// these, the scan collected the ref, and `tonumber` then made the program
|
|
995
|
-
// exit 5 — one ticket body took down the entire candidate listing. Exit 0
|
|
996
|
-
// is half of what this pins, and `deps` asserts that before it returns.
|
|
997
|
-
assert.deepEqual(deps("Blocked by: #\u0661\u0662\n"), []);
|
|
998
|
-
// The after-marker ruling is the NARROWER `[ \t]`, not the separator class
|
|
999
|
-
// above: GFM opens a heading on a space or a tab only, so this line is a
|
|
1000
|
-
// PARAGRAPH, arms no section, and its bullet declares nothing. Two
|
|
1001
|
-
// positions on one construct taking two different classes is exactly what
|
|
1002
|
-
// ruling them per position buys.
|
|
1003
|
-
assert.deepEqual(deps("##\u00a0Blocked by\n\n- #12\n"), []);
|
|
1004
|
-
// The same class one level down, on the list item's own marker gap.
|
|
1005
|
-
assert.deepEqual(deps("## Blocked by\n\n-\u00a0#12\n"), []);
|
|
1006
|
-
// An ASCII NARROWING, and deliberate: `\f` was whitespace to `\s` on BOTH
|
|
1007
|
-
// engines, so both used to collect [12] here. GFM renders `-<FF>#12` as a
|
|
1008
|
-
// paragraph, so it is not a bullet and declares nothing.
|
|
1009
|
-
assert.deepEqual(deps("## Blocked by\n\n-\f#12\n"), []);
|
|
1010
|
-
// The same narrowing after the heading marker: `##<FF>Blocked by` is a
|
|
1011
|
-
// paragraph, so it arms nothing and the bullet below is never read.
|
|
1012
|
-
assert.deepEqual(deps("##\fBlocked by\n\n- #12\n"), []);
|
|
1013
|
-
// `\b` → `(?:[^\p{L}\p{M}\p{N}_]|$)`, Unicode-aware where RE2's `\b` is
|
|
1014
|
-
// ASCII. A letter continuing the word means a DIFFERENT word, so this
|
|
1015
|
-
// heading does not arm — gojq armed it and collected [12].
|
|
1016
|
-
assert.deepEqual(deps("## Blocked by\u00e9\n\n- #12\n"), []);
|
|
1017
|
-
// End-of-heading-line ruling `[\t\f\r \p{Zs}]*`: the noun form must be the
|
|
1018
|
-
// WHOLE heading, and U+00A0 padding does not stop it being that heading —
|
|
1019
|
-
// GFM still renders an `<h2>`. gojq refused this and reported it as a near
|
|
1020
|
-
// miss instead of collecting the blocker.
|
|
1021
|
-
assert.deepEqual(deps("## Dependencies\u00a0\n\n1. #12\n"), [12]);
|
|
1022
|
-
},
|
|
1023
|
-
);
|
|
1024
|
-
|
|
1025
|
-
// Findings 5-7 (review of #1746): the U+00A0/Arabic-Indic-digit/VERTICAL-TAB
|
|
1026
|
-
// fixtures inside the three gojq-gated tests above and below are ALL
|
|
1027
|
-
// gojq-only assertions, but RE2 was already ASCII-only at every one of these
|
|
1028
|
-
// three positions before #383 too — so pre- and post-#383 agree under gojq
|
|
1029
|
-
// on every one of them, and none of those gated assertions actually exercise
|
|
1030
|
-
// the jq-vs-gojq divergence its own comment describes. That divergence is
|
|
1031
|
-
// real, but only reachable on system jq (Oniguruma), which the gojq-gated
|
|
1032
|
-
// tests structurally cannot run. This test reaches it directly, under plain
|
|
1033
|
-
// system jq — no `JQ_BIN` override, no `SKIP_WITHOUT_GOJQ` guard — running
|
|
1034
|
-
// OLD_JQ (pre-#383) through the STUB's `JQ_OVERRIDE` escape hatch to prove
|
|
1035
|
-
// each old class actually MISBEHAVED here, paired with the current script
|
|
1036
|
-
// (unmodified, no override) proving #383's narrower classes actually fixed
|
|
1037
|
-
// it — on the one engine where the fix was ever needed.
|
|
1038
|
-
test("system jq: the three class-position fixes actually changed behaviour on the engine that has the bug (#383)", () => {
|
|
1039
|
-
// #1's after-marker toggle position, on the heading and on the list item's
|
|
1040
|
-
// own marker gap: Oniguruma's old `\s` matched U+00A0, so `##<NBSP>Blocked
|
|
1041
|
-
// by` and a bulleted `-<NBSP>#12` both wrongly armed/collected under jq.
|
|
1042
|
-
const oldHeadingGap = run([ticket(1, "##\u00a0Blocked by\n\n- #12\n")], undefined, null, { JQ_OVERRIDE: OLD_JQ });
|
|
1043
|
-
assert.deepEqual(oldHeadingGap.rows[0].d, [12], oldHeadingGap.stderr);
|
|
1044
|
-
const oldListGap = run([ticket(2, "## Blocked by\n\n-\u00a0#12\n")], undefined, null, { JQ_OVERRIDE: OLD_JQ });
|
|
1045
|
-
assert.deepEqual(oldListGap.rows[0].d, [12], oldListGap.stderr);
|
|
1046
|
-
// #383's narrower `[ \t]` fixes both, on the same engine.
|
|
1047
|
-
const newHeadingGap = run([ticket(1, "##\u00a0Blocked by\n\n- #12\n")]);
|
|
1048
|
-
assert.deepEqual(newHeadingGap.rows[0].d, []);
|
|
1049
|
-
const newListGap = run([ticket(2, "## Blocked by\n\n-\u00a0#12\n")]);
|
|
1050
|
-
assert.deepEqual(newListGap.rows[0].d, []);
|
|
1051
|
-
|
|
1052
|
-
// #2: Oniguruma's old `\d` matched Arabic-Indic digits, so `tonumber`
|
|
1053
|
-
// crashed jq itself (exit 5), which candidates.mjs's own gh-call guard
|
|
1054
|
-
// turns into a hard refusal rather than a silent per-ticket miss.
|
|
1055
|
-
const oldDigits = run([ticket(3, "Blocked by: #\u0661\u0662\n")], undefined, null, { JQ_OVERRIDE: OLD_JQ });
|
|
1056
|
-
assert.equal(oldDigits.status, 2, oldDigits.stderr);
|
|
1057
|
-
assert.match(oldDigits.stderr, /gh issue list failed/);
|
|
1058
|
-
// #383's `[0-9]` no longer matches them, so the same fixture no longer
|
|
1059
|
-
// crashes the real CLI invocation — the actual bug #6 describes.
|
|
1060
|
-
const newDigits = run([ticket(3, "Blocked by: #\u0661\u0662\n")]);
|
|
1061
|
-
assert.equal(newDigits.status, 0, newDigits.stderr);
|
|
1062
|
-
assert.deepEqual(newDigits.rows[0].d, []);
|
|
1063
|
-
|
|
1064
|
-
// #3: Oniguruma's old `\s*$` trailing class matched VERTICAL TAB, so a
|
|
1065
|
-
// `## User Stories<VT>` heading was wrongly to-spec and dropSpecs silently
|
|
1066
|
-
// discarded the ticket. #999 keeps the queue non-empty either way, so #1's
|
|
1067
|
-
// presence in rows is the verdict.
|
|
1068
|
-
const oldVt = run(
|
|
1069
|
-
[ticket(4, "## User Stories\u000b\n\nx\n"), ticket(999, "## What to build\n\nx\n")],
|
|
1070
|
-
undefined,
|
|
1071
|
-
null,
|
|
1072
|
-
{ JQ_OVERRIDE: OLD_JQ },
|
|
1073
|
-
);
|
|
1074
|
-
assert.equal(oldVt.status, 0, oldVt.stderr);
|
|
1075
|
-
assert.ok(!oldVt.rows.some((r) => r.n === 4), "old class must have dropped #4 as a false spec");
|
|
1076
|
-
// #383's class excludes VT on purpose (GFM renders it as U+FFFD, not
|
|
1077
|
-
// blank), so the same heading is no longer to-spec and #4 survives.
|
|
1078
|
-
const newVt = run([ticket(4, "## User Stories\u000b\n\nx\n"), ticket(999, "## What to build\n\nx\n")]);
|
|
1079
|
-
assert.equal(newVt.status, 0, newVt.stderr);
|
|
1080
|
-
assert.ok(newVt.rows.some((r) => r.n === 4), "the fixed class must not drop #4");
|
|
1081
|
-
});
|
|
1082
|
-
|
|
1083
|
-
// #1032's diagnostic, on the engine that actually runs it. The test above
|
|
1084
|
-
// exercises `depmiss` under system jq only, and a `def` gojq parses differently
|
|
1085
|
-
// would red the dependency-forms test next door (it asserts exit 0) — but a
|
|
1086
|
-
// `test` RE2 merely reads differently would not: the diagnostic would go dead
|
|
1087
|
-
// in production, green here, which is exactly the silent degrade the two
|
|
1088
|
-
// gated tests either side of this one exist to refuse. The near-miss row and
|
|
1089
|
-
// the armed row together, so a `depmiss` that answered [] and one that
|
|
1090
|
-
// answered every heading are both caught.
|
|
1091
|
-
test(
|
|
1092
|
-
"the near-miss diagnostic fires under gojq too — the engine gh actually applies (#1032)",
|
|
1093
|
-
SKIP_WITHOUT_GOJQ,
|
|
1094
|
-
() => {
|
|
1095
|
-
const r = run(
|
|
1096
|
-
[
|
|
1097
|
-
ticket(1, "## Dependencies (blocking)\n\n- #300\n"),
|
|
1098
|
-
ticket(2, "## Dependencies\n\n- #12\n"),
|
|
1099
|
-
],
|
|
1100
|
-
undefined,
|
|
1101
|
-
null,
|
|
1102
|
-
{ JQ_BIN: GOJQ },
|
|
1103
|
-
);
|
|
1104
|
-
const { status, stderr } = r;
|
|
1105
|
-
assert.equal(status, 0, stderr);
|
|
1106
|
-
assertRanGojq(r);
|
|
1107
|
-
const lines = missLines(stderr);
|
|
1108
|
-
assert.deepEqual(lines.map((l) => l.match(/#(\d+)/)[1]), ["1"], stderr);
|
|
1109
|
-
assert.ok(lines[0].includes("'## Dependencies (blocking)'"), lines[0]);
|
|
1110
|
-
},
|
|
1111
|
-
);
|
|
1112
|
-
|
|
1113
|
-
// #65: the spec predicate's decisions, checked against gojq specifically —
|
|
1114
|
-
// gojq is what gh applies, so gojq is where a leak would actually happen.
|
|
1115
|
-
// The first three fixtures are plain ASCII (`#`, `[ \t]`, `\r`), so none of
|
|
1116
|
-
// them is expected to diverge between engines; they exist to confirm that,
|
|
1117
|
-
// not because a divergence was found. The predicate's trailing class still
|
|
1118
|
-
// contains `\r` for #65's reason: b4739c8 widened it back from `[ \t]*` so a
|
|
1119
|
-
// CRLF line's `\r` still reaches the anchor, which is the only reason the
|
|
1120
|
-
// third fixture matches at all — drop `\r` from that class and the CRLF
|
|
1121
|
-
// assertion is what reds. #383 then spelled the class out as
|
|
1122
|
-
// `[\t\f\r \p{Zs}]*` instead of leaving it `\s*`, because `\s` was the one
|
|
1123
|
-
// part of this predicate whose meaning changed with the engine (Oniguruma
|
|
1124
|
-
// Unicode-aware, RE2 `[\t\n\f\r ]` — not even every ASCII whitespace, since
|
|
1125
|
-
// a vertical tab diverged too). The rows at the end pin each edge of that
|
|
1126
|
-
// ruling: `\p{Zs}` padding is still a spec, a VERTICAL TAB is not, and a
|
|
1127
|
-
// U+00A0 after the `#` marker is not a heading at all. Which engine actually
|
|
1128
|
-
// ran is no longer inferred from a disagreement — `assertRanGojq` reads the
|
|
1129
|
-
// STUB's recording; see this file's header.
|
|
1130
|
-
test(
|
|
1131
|
-
"the spec predicate holds under gojq — depth widened, split heading not spanned, CRLF caught",
|
|
1132
|
-
SKIP_WITHOUT_GOJQ,
|
|
1133
|
-
() => {
|
|
1134
|
-
const extraEnv = { JQ_BIN: GOJQ };
|
|
1135
|
-
// #9 is the body under test; #999 keeps the queue non-empty either way, so
|
|
1136
|
-
// a passing run always exits 0 and #9's presence/absence in rows is what
|
|
1137
|
-
// reads the verdict — dropSpecs strips the `spec` field from surviving rows.
|
|
1138
|
-
const isDroppedAsSpec = (body) => {
|
|
1139
|
-
const r = run(
|
|
1140
|
-
[ticket(9, body), ticket(999, "## What to build\n\nx\n")],
|
|
1141
|
-
undefined,
|
|
1142
|
-
null,
|
|
1143
|
-
extraEnv,
|
|
1144
|
-
);
|
|
1145
|
-
assert.equal(r.status, 0, r.stderr);
|
|
1146
|
-
assertRanGojq(r);
|
|
1147
|
-
return !r.rows.some((row) => row.n === 9);
|
|
1148
|
-
};
|
|
1149
|
-
assert.equal(isDroppedAsSpec("### User Stories\n\nnested one level deeper\n"), true);
|
|
1150
|
-
assert.equal(isDroppedAsSpec("##\nUser Stories\n\nsplit across lines\n"), false);
|
|
1151
|
-
assert.equal(isDroppedAsSpec("## User Stories\r\n\r\n1. As a user…\r\n"), true);
|
|
1152
|
-
// #383's end-of-heading-line ruling: `[\t\f\r \p{Zs}]*` before the anchor.
|
|
1153
|
-
// `## User Stories` padded with U+00A0 still renders a real `<h2>` on
|
|
1154
|
-
// GitHub, so it is still a to-spec spec and is still dropped. This row
|
|
1155
|
-
// asserted `false` until the ruling — gojq's answer, i.e. production's,
|
|
1156
|
-
// adopted because it was production's and never because anyone ruled it
|
|
1157
|
-
// correct; under it the spec shipped as a claimable ticket, the under-fire
|
|
1158
|
-
// direction an admission gate must never take. Both engines now say true.
|
|
1159
|
-
// Keep the `\u00a0` escape: a literal NBSP does not survive being copied,
|
|
1160
|
-
// and has already produced a false refutation of a correct finding in this
|
|
1161
|
-
// repo (#200).
|
|
1162
|
-
assert.equal(isDroppedAsSpec("## User Stories\u00a0\n\nx\n"), true);
|
|
1163
|
-
// Any `\p{Zs}`, not NBSP alone: every Unicode space separator renders as a
|
|
1164
|
-
// blank, so the rule is "looks like a space" rather than a list of code
|
|
1165
|
-
// points anyone has met so far.
|
|
1166
|
-
assert.equal(isDroppedAsSpec("## User Stories\u2003\n\nx\n"), true);
|
|
1167
|
-
// VERTICAL TAB is excluded ON PURPOSE, and it is why the class is not
|
|
1168
|
-
// simply "whitespace": GFM renders U+000B as U+FFFD, so a reader sees a
|
|
1169
|
-
// replacement character sitting in the heading, not padding. Not a spec.
|
|
1170
|
-
assert.equal(isDroppedAsSpec("## User Stories\u000b\n\nx\n"), false);
|
|
1171
|
-
// The after-marker position takes the narrower `[ \t]`: GFM opens a
|
|
1172
|
-
// heading on a space or a tab only, so this is a paragraph and not a
|
|
1173
|
-
// heading at all. Same line, two positions, two classes.
|
|
1174
|
-
assert.equal(isDroppedAsSpec("##\u00a0User Stories\n\nx\n"), false);
|
|
1175
|
-
},
|
|
1176
|
-
);
|
|
1177
|
-
|
|
1178
|
-
// #1741's half of the program under the engine gh applies. `blockers` holds no
|
|
1179
|
-
// regex, so no class ruling is at stake — what gojq could still refuse or
|
|
1180
|
-
// read differently is the rest: `//` over a missing field, `error()` with an
|
|
1181
|
-
// interpolated message, and `unique` over the union. The STUB cuts each
|
|
1182
|
-
// fixture to the `--json` list with gojq too, so this runs gojq end to end.
|
|
1183
|
-
test("native edges reduce the same under gojq — union, dedupe, closed kept, and the short-list refusal (#1741)", SKIP_WITHOUT_GOJQ, () => {
|
|
1184
|
-
const extraEnv = { JQ_BIN: GOJQ };
|
|
1185
|
-
const r = run(
|
|
1186
|
-
[
|
|
1187
|
-
ticket(592, BODY_593),
|
|
1188
|
-
withEdges(ticket(593, BODY_593), edges([531, "OPEN"], [239, "CLOSED"])),
|
|
1189
|
-
withEdges(ticket(9, "## What to build\n\nx\n"), edges([12, "OPEN"], [7, "CLOSED"])),
|
|
1190
|
-
],
|
|
1191
|
-
undefined,
|
|
1192
|
-
null,
|
|
1193
|
-
extraEnv,
|
|
1194
|
-
);
|
|
1195
|
-
assert.equal(r.status, 0, r.stderr);
|
|
1196
|
-
assertRanGojq(r);
|
|
1197
|
-
assert.deepEqual(r.rows.map((row) => row.d), [[7, 12], [239], [239, 531]]);
|
|
1198
|
-
const short = run([withEdges(ticket(12, "## What to build\n\nx\n"), SHORT_50_OF_51)], undefined, null, extraEnv);
|
|
1199
|
-
assert.equal(short.status, 2, short.stderr);
|
|
1200
|
-
assertRanGojq(short);
|
|
1201
|
-
assert.match(short.stderr, /#12: blockedBy lists 50 of 51 blockers, so d would miss the rest/);
|
|
1202
|
-
});
|
|
1203
|
-
|
|
1204
|
-
test("the cap is checked before specs are dropped — filtering first hides truncation", () => {
|
|
1205
|
-
// The ordering candidates.mjs calls load-bearing. Swap the two and this is
|
|
1206
|
-
// the only thing that fails: dropSpecs shrinks the array below --limit, the
|
|
1207
|
-
// cap check stops seeing a capped list, and the silent-truncation bug the
|
|
1208
|
-
// "no silent caps" rule exists to close comes back with every test green.
|
|
1209
|
-
const { status, stderr } = run(
|
|
1210
|
-
[
|
|
1211
|
-
ticket(10, "## User Stories\n\n1. As a user…\n"),
|
|
1212
|
-
ticket(11, "## What to build\n\nx\n"),
|
|
1213
|
-
],
|
|
1214
|
-
["--require-label", "ready-for-agent", "--limit", "2"],
|
|
1215
|
-
);
|
|
1216
|
-
assert.equal(status, 2);
|
|
1217
|
-
assert.match(stderr, /capped/);
|
|
1218
|
-
});
|
|
1219
|
-
|
|
1220
|
-
test("a labeled queue of only specs falls back to unfiltered — all filtered out is an empty queue", () => {
|
|
1221
|
-
// The emptiness test gating --allow-fallback has to read the length AFTER
|
|
1222
|
-
// the specs are dropped. Reading the raw one leaves a ready-for-agent queue
|
|
1223
|
-
// holding nothing but to-spec specs reporting "no work" with the fallback
|
|
1224
|
-
// untried, while #12 sits there claimable.
|
|
1225
|
-
const { rows, status, stderr } = run(
|
|
1226
|
-
[
|
|
1227
|
-
ticket(10, "## Problem Statement\n\nx\n\n## User Stories\n\n1. As a user…\n"),
|
|
1228
|
-
ticket(11, "## User Stories\n\n2. As a user…\n"),
|
|
1229
|
-
],
|
|
1230
|
-
["--require-label", "ready-for-agent", "--allow-fallback"],
|
|
1231
|
-
[
|
|
1232
|
-
ticket(12, "## What to build\n\nreal work\n", ["ready-for-human"]),
|
|
1233
|
-
// A spec HERE is what makes the assertion below discriminate: delete the
|
|
1234
|
-
// strip inside the fallback and #13 ships as a claimable ticket. A leaked
|
|
1235
|
-
// spec passes phase 2's bail tests, so a member implements a whole spec.
|
|
1236
|
-
ticket(13, "## User Stories\n\n4. As a user…\n", ["ready-for-human"]),
|
|
1237
|
-
],
|
|
1238
|
-
);
|
|
1239
|
-
assert.deepEqual(rows.map((r) => r.n), [12]);
|
|
1240
|
-
// The BRANCH ran, not merely that the unfiltered fixture reached some query.
|
|
1241
|
-
// Move the positive term to the front of `search` and the stub serves the
|
|
1242
|
-
// LABELED query the unfiltered fixture: same payload, same status, fallback
|
|
1243
|
-
// never entered. The payload alone pins the fixture, never the branch.
|
|
1244
|
-
assert.match(stderr, /retrying unfiltered/);
|
|
1245
|
-
// Each pass's drop line is attributable to the query it came from. Swap the
|
|
1246
|
-
// two dropSpecs call-site labels and both lines still print, both still name
|
|
1247
|
-
// a real spec, and nothing else in this file notices — these two asserts are
|
|
1248
|
-
// what tell pass 1's drop from pass 2's. Deliberately not a count: drops are
|
|
1249
|
-
// not deduplicated across passes (candidates.mjs's dropSpecs, #133), so a raw
|
|
1250
|
-
// `grep -c 'dropped #'` reads 4 here whether or not the tags are present.
|
|
1251
|
-
assert.match(stderr, /dropped #10 — to-spec spec, not a ticket \(User Stories heading\) \[label:ready-for-agent\]/);
|
|
1252
|
-
assert.match(stderr, /dropped #13 — to-spec spec, not a ticket \(User Stories heading\) \[unfiltered \(fallback\)\]/);
|
|
1253
|
-
// Two queries actually RAN. The announcement above prints before the query,
|
|
1254
|
-
// so it pins the branch being entered, never that its answer shipped.
|
|
1255
|
-
assert.equal(stderr.match(/^\$ gh /gm).length, 2);
|
|
1256
|
-
// The strip inside the block ran. Delete that line and every assertion above
|
|
1257
|
-
// still passes while `spec` — and any spec row — reaches the payload.
|
|
1258
|
-
assert.deepEqual(Object.keys(rows[0]).sort(), ["d", "l", "n", "t"]);
|
|
1259
|
-
// Exit 0, not 1: the payload and the "is there work" answer are one fact,
|
|
1260
|
-
// and a caller that reads only the status must not still hear "empty".
|
|
1261
|
-
assert.equal(status, 0);
|
|
1262
|
-
});
|
|
1263
|
-
|
|
1264
|
-
test("the cap is checked before specs are dropped in the fallback too, not only in the labeled query", () => {
|
|
1265
|
-
// The cap-before-drop ordering of "the cap is checked before specs are
|
|
1266
|
-
// dropped", one branch deeper — NOT the drop-before-emptiness test directly
|
|
1267
|
-
// above, which pins the other half of the same wedge. The labeled query is
|
|
1268
|
-
// under its cap on 1 row, empties out, and hands over to the fallback —
|
|
1269
|
-
// whose 2 rows hit --limit 2 exactly. Drop first and one spec leaves, the
|
|
1270
|
-
// cap check sees 1, and the truncated list ships as an answer.
|
|
1271
|
-
const { status, stderr } = run(
|
|
1272
|
-
[ticket(10, "## User Stories\n\n1. As a user…\n")],
|
|
1273
|
-
["--require-label", "ready-for-agent", "--allow-fallback", "--limit", "2"],
|
|
1274
|
-
[
|
|
1275
|
-
ticket(12, "## User Stories\n\n3. As a user…\n", ["ready-for-human"]),
|
|
1276
|
-
ticket(13, "## What to build\n\nx\n", ["ready-for-human"]),
|
|
1277
|
-
],
|
|
1278
|
-
);
|
|
1279
|
-
assert.equal(status, 2);
|
|
1280
|
-
// Pin which query refused. `/capped/` alone is satisfied by the labeled
|
|
1281
|
-
// query dying, which is a different bug with the same exit code.
|
|
1282
|
-
assert.match(stderr, /unfiltered \(fallback\)/);
|
|
1283
|
-
});
|
|
1284
|
-
|
|
1285
|
-
test("the spec predicate never reaches the payload — it is pure token cost downstream", () => {
|
|
1286
|
-
const { rows } = run([ticket(12, "## What to build\n\nplain ticket\n")]);
|
|
1287
|
-
assert.equal(rows.length, 1);
|
|
1288
|
-
assert.deepEqual(Object.keys(rows[0]).sort(), ["d", "l", "n", "t"]);
|
|
1289
|
-
});
|
|
1290
|
-
|
|
1291
|
-
// `$ gh …` is echoed by query() before every invocation, so its absence is how
|
|
1292
|
-
// these pin that the refusal came BEFORE any query ran. Status 2 alone does not:
|
|
1293
|
-
// a query that ran and then died still exits 2, and for --require-label the
|
|
1294
|
-
// query that runs is the widening one the whole file exists to prevent.
|
|
1295
|
-
const queriesRun = (stderr) => (stderr.match(/^\$ gh /gm) ?? []).length;
|
|
1296
|
-
|
|
1297
|
-
test("a trailing --limit refuses — an absent value is not a licence to use the default", () => {
|
|
1298
|
-
const { status, stderr } = run(
|
|
1299
|
-
[ticket(11, "## What to build\n\nx\n")],
|
|
1300
|
-
["--require-label", "ready-for-agent", "--limit"],
|
|
1301
|
-
);
|
|
1302
|
-
assert.equal(status, 2);
|
|
1303
|
-
// Not 0-with-500-rows. `arg()` handed back `undefined`, `?? 500` read that as
|
|
1304
|
-
// "flag absent", and the positive-integer guard never saw the malformed input
|
|
1305
|
-
// it exists to catch.
|
|
1306
|
-
assert.equal(queriesRun(stderr), 0);
|
|
1307
|
-
});
|
|
1308
|
-
|
|
1309
|
-
test("a trailing --require-label refuses — a falsy label runs the query --allow-fallback exists to gate", () => {
|
|
1310
|
-
const { status, stderr } = run([ticket(11, "## What to build\n\nx\n")], ["--require-label"]);
|
|
1311
|
-
// The worst of the three: query() reads a falsy label as "no label", so the
|
|
1312
|
-
// UNFILTERED query shipped at exit 0 — the exact widening onto ready-for-human
|
|
1313
|
-
// that run-team/SKILL.md's "do NOT pass `--allow-fallback`" prevents, reached
|
|
1314
|
-
// without the flag. Asserting the status alone would pass on a run that
|
|
1315
|
-
// widened and then happened to die.
|
|
1316
|
-
assert.equal(queriesRun(stderr), 0);
|
|
1317
|
-
assert.equal(status, 2);
|
|
1318
|
-
});
|
|
1319
|
-
|
|
1320
|
-
test("a --require-label whose value is the next flag refuses — it reaches the same widening", () => {
|
|
1321
|
-
// Same harm as the trailing case, one keystroke away: `--allow-fallback` is
|
|
1322
|
-
// consumed as the label, `label:--allow-fallback` matches nothing, and the
|
|
1323
|
-
// empty result hands straight over to the unfiltered fallback at exit 0.
|
|
1324
|
-
const { status, stderr } = run([ticket(11, "## What to build\n\nx\n")], ["--require-label", "--allow-fallback"]);
|
|
1325
|
-
assert.equal(queriesRun(stderr), 0);
|
|
1326
|
-
assert.equal(status, 2);
|
|
1327
|
-
});
|
|
1328
|
-
|
|
1329
|
-
test("a --require-label whose value is empty refuses — an unset shell variable is not 'no label'", () => {
|
|
1330
|
-
// The likeliest spelling of all of them, and the only one the caller cannot
|
|
1331
|
-
// see: `--require-label "$LABEL"` with the variable unset leaves an empty
|
|
1332
|
-
// argv slot, not a missing one. `""` is falsy, so query() dropped the label
|
|
1333
|
-
// term and ran the UNFILTERED search at exit 0 — and stderr said
|
|
1334
|
-
// `N candidate(s)` with no label suffix, indistinguishable from a clean run.
|
|
1335
|
-
const { status, stderr } = run([ticket(11, "## What to build\n\nx\n")], ["--require-label", ""]);
|
|
1336
|
-
assert.equal(queriesRun(stderr), 0);
|
|
1337
|
-
assert.equal(status, 2);
|
|
1338
|
-
});
|
|
1339
|
-
|
|
1340
|
-
test("a --require-label=value refuses — indexOf cannot see the = form, so the flag reads as absent", () => {
|
|
1341
|
-
// Not the same route as the three above: `indexOf("--require-label")` misses
|
|
1342
|
-
// `--require-label=x` entirely, so arg() returned null — "flag absent" — and
|
|
1343
|
-
// the unfiltered query ran at exit 0 with the label the caller did pass.
|
|
1344
|
-
const { status, stderr } = run(
|
|
1345
|
-
[ticket(11, "## What to build\n\nx\n")],
|
|
1346
|
-
["--require-label=ready-for-agent"],
|
|
1347
|
-
);
|
|
1348
|
-
assert.equal(queriesRun(stderr), 0);
|
|
1349
|
-
assert.equal(status, 2);
|
|
1350
|
-
});
|
|
1351
|
-
|
|
1352
|
-
test("an unknown flag refuses and names it — a flag that is merely ignored runs unfiltered", () => {
|
|
1353
|
-
// `--label ready-for-agent` is not an invented typo: it is what run-team's
|
|
1354
|
-
// phase 0 rule said, one line under a command spelling it `--require-label`.
|
|
1355
|
-
// Ignored, the label term never reaches gh, so the ready-for-human queue
|
|
1356
|
-
// ships at exit 0 — the widening `--require-label` exists to prevent, reached
|
|
1357
|
-
// by following this repo's own instruction.
|
|
1358
|
-
const { status, stderr } = run(
|
|
1359
|
-
[ticket(11, "## What to build\n\nx\n")],
|
|
1360
|
-
["--label", "ready-for-agent"],
|
|
1361
|
-
);
|
|
1362
|
-
assert.equal(queriesRun(stderr), 0);
|
|
1363
|
-
assert.equal(status, 2);
|
|
1364
|
-
// The flag has to be NAMED. A bare "bad arguments" leaves the caller — markdown
|
|
1365
|
-
// read by a model, with no way to see the script — re-guessing its own spelling.
|
|
1366
|
-
// Line-anchored, per die()'s leading newline.
|
|
1367
|
-
assert.match(stderr, /^candidates: Unknown option '--label'/m);
|
|
1368
|
-
});
|
|
1369
|
-
|
|
1370
|
-
// The test above is satisfied by a guard that only works when the bad flag is
|
|
1371
|
-
// FIRST, which is what shipped: the catch tested
|
|
1372
|
-
// `e.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION"` and dropped every other
|
|
1373
|
-
// parseArgs error. That is not a narrower guard but a disabled one. parseArgs
|
|
1374
|
-
// stops at the FIRST offending argument, so an argument raising any other code
|
|
1375
|
-
// was swallowed and the unknown flag behind it was never reached — the query
|
|
1376
|
-
// then ran UNFILTERED at exit 0, which is the whole harm #173 exists to stop.
|
|
1377
|
-
//
|
|
1378
|
-
// Rows 1-2 are the two masking arguments on their own; rows 3-4 put a real
|
|
1379
|
-
// `--label` BEHIND each of them, which is the shape the code test let through
|
|
1380
|
-
// and the one no other test in this file covers. All four must refuse before
|
|
1381
|
-
// any query — `status` alone is not enough, since exit 2 is also what a broken
|
|
1382
|
-
// query produces after gh has already run.
|
|
1383
|
-
//
|
|
1384
|
-
// Rows 2 and 4 no longer reach parseArgs at all: #364 gave has() its own `=`
|
|
1385
|
-
// guard, evaluated when `allowFallback` is assigned — above and long before
|
|
1386
|
-
// the parseArgs call below — so the boolean case now dies with has()'s own
|
|
1387
|
-
// boolean-specific wording (distinct from arg()'s "needs a space-separated
|
|
1388
|
-
// value", since a boolean has no value to take), never Node's "does not take
|
|
1389
|
-
// an argument". That does NOT make `ERR_PARSE_ARGS_INVALID_OPTION_VALUE` dead
|
|
1390
|
-
// here, and an earlier draft of this comment claimed it did: arg()'s own `=`
|
|
1391
|
-
// guard is indexOf-gated, firing only when the bare spelling is absent, so a
|
|
1392
|
-
// REPEATED string flag whose later occurrence carries no value sails past both
|
|
1393
|
-
// guards into parseArgs — measured, `--limit 5 --limit` raises exactly that
|
|
1394
|
-
// code, with Node's wording (#462 review). The catch stays unconditional for
|
|
1395
|
-
// that reason among others. The loop still refuses before any query and still
|
|
1396
|
-
// names the offending flag, which is the property that matters; only the
|
|
1397
|
-
// source moved.
|
|
1398
|
-
for (const [what, args, refusal] of [
|
|
1399
|
-
[
|
|
1400
|
-
"a bare positional",
|
|
1401
|
-
["ready-for-agent"],
|
|
1402
|
-
/^candidates: Unexpected argument 'ready-for-agent'\./m,
|
|
1403
|
-
],
|
|
1404
|
-
[
|
|
1405
|
-
"a boolean flag handed a =value",
|
|
1406
|
-
["--allow-fallback=true"],
|
|
1407
|
-
/^candidates: --allow-fallback is a boolean flag, not --allow-fallback=/m,
|
|
1408
|
-
],
|
|
1409
|
-
[
|
|
1410
|
-
"an unknown flag behind a positional",
|
|
1411
|
-
["junk", "--label", "ready-for-agent"],
|
|
1412
|
-
/^candidates: Unexpected argument 'junk'\./m,
|
|
1413
|
-
],
|
|
1414
|
-
[
|
|
1415
|
-
"an unknown flag behind a =value boolean",
|
|
1416
|
-
["--allow-fallback=true", "--label", "ready-for-agent"],
|
|
1417
|
-
/^candidates: --allow-fallback is a boolean flag, not --allow-fallback=/m,
|
|
1418
|
-
],
|
|
1419
|
-
]) {
|
|
1420
|
-
test(`${what} refuses before any query — every parseArgs error is a refusal, not just the unknown-name one`, () => {
|
|
1421
|
-
const { status, stderr } = run([ticket(11, "## What to build\n\nx\n")], args);
|
|
1422
|
-
assert.equal(queriesRun(stderr), 0);
|
|
1423
|
-
assert.equal(status, 2);
|
|
1424
|
-
// The refusal has to name the OFFENDING argument, not merely the accepted
|
|
1425
|
-
// set: parseArgs reports the first offender, and a caller told only "bad
|
|
1426
|
-
// arguments" cannot tell which of its four tokens was wrong.
|
|
1427
|
-
assert.match(stderr, refusal);
|
|
1428
|
-
});
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
// Pre-#364, `--allow-fallback=<value>` was silently IGNORED rather than merely
|
|
1432
|
-
// unchecked: `has()` compared exactly, so no `=` form ever matched and the
|
|
1433
|
-
// fallback was disabled without a word. The fixtures below are the arrangement
|
|
1434
|
-
// that showed it — the labeled query comes back empty and the unfiltered one
|
|
1435
|
-
// has a row — so the flag was the only thing standing between exit 1 and exit
|
|
1436
|
-
// 0. Measured on the pre-fix version, all three spellings here exited 1
|
|
1437
|
-
// ("queue empty, query fine") for a run that never applied the flag it was
|
|
1438
|
-
// handed, while the space-separated spelling exited 0 off the fallback.
|
|
1439
|
-
// `notEqual(1)` is the load-bearing assertion, not decoration: it pins the
|
|
1440
|
-
// exact wrong code the ignored form used to produce, now unreachable — has()
|
|
1441
|
-
// refuses this argv outright, before `allowFallback` is even assigned. All
|
|
1442
|
-
// three spellings are the ones the ticket's acceptance criteria name.
|
|
1443
|
-
for (const v of ["=true", "=false", "="]) {
|
|
1444
|
-
test(`--allow-fallback${v} refuses outright, rather than being silently dropped and falling through`, () => {
|
|
1445
|
-
const { status, stderr } = run(
|
|
1446
|
-
[],
|
|
1447
|
-
["--require-label", "nonexistent", `--allow-fallback${v}`],
|
|
1448
|
-
[ticket(12, "## What to build\n\ny\n", ["ready-for-human"])],
|
|
1449
|
-
);
|
|
1450
|
-
assert.equal(queriesRun(stderr), 0);
|
|
1451
|
-
assert.notEqual(status, 1);
|
|
1452
|
-
assert.equal(status, 2);
|
|
1453
|
-
assert.match(stderr, /^candidates: --allow-fallback is a boolean flag, not --allow-fallback=/m);
|
|
1454
|
-
});
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
// The control for the test above. Without it, "refuses the = form" is equally
|
|
1458
|
-
// satisfied by a guard that refuses `--allow-fallback` in every spelling, which
|
|
1459
|
-
// would break the one caller that legitimately passes it
|
|
1460
|
-
// (next-ticket/SKILL.md's `## 1. Candidates` step). Same fixtures,
|
|
1461
|
-
// space-separated: the fallback has
|
|
1462
|
-
// to run and ship the unfiltered row at exit 0.
|
|
1463
|
-
test("--allow-fallback still falls back in its space-separated spelling — the = refusal is not a blanket one", () => {
|
|
1464
|
-
const { status, stderr, rows } = run(
|
|
1465
|
-
[],
|
|
1466
|
-
["--require-label", "nonexistent", "--allow-fallback"],
|
|
1467
|
-
[ticket(12, "## What to build\n\ny\n", ["ready-for-human"])],
|
|
1468
|
-
);
|
|
1469
|
-
assert.equal(queriesRun(stderr), 2);
|
|
1470
|
-
assert.equal(status, 0);
|
|
1471
|
-
assert.deepEqual(rows.map((r) => r.n), [12]);
|
|
1472
|
-
});
|
|
1473
|
-
|
|
1474
|
-
// The parseArgs call sits BELOW the value guards so their wording wins wherever
|
|
1475
|
-
// both would refuse, and ORDER is the only thing that decides that. Node's
|
|
1476
|
-
// message for this same argv is "Option '--require-label <value>' argument
|
|
1477
|
-
// missing", which names the syntax; #169's names the flag the way every other
|
|
1478
|
-
// refusal in this file does. Anchored at both ends so the suffix parseArgs'
|
|
1479
|
-
// branch appends cannot satisfy it.
|
|
1480
|
-
test("--require-label with no value keeps #169's wording — the name check runs after the value guards", () => {
|
|
1481
|
-
const { status, stderr } = run([ticket(11, "## What to build\n\nx\n")], ["--require-label"]);
|
|
1482
|
-
assert.equal(queriesRun(stderr), 0);
|
|
1483
|
-
assert.equal(status, 2);
|
|
1484
|
-
assert.match(stderr, /^candidates: --require-label needs a value$/m);
|
|
1485
|
-
});
|
|
1486
|
-
|
|
1487
|
-
test("gh output that is not an array refuses — a reduction that did not apply is not an empty queue", () => {
|
|
1488
|
-
const { status, stderr } = run(
|
|
1489
|
-
[ticket(11, "## What to build\n\nx\n")],
|
|
1490
|
-
["--require-label", "ready-for-agent"],
|
|
1491
|
-
null,
|
|
1492
|
-
{ JQ_OVERRIDE: '{message:"Not Found"}' },
|
|
1493
|
-
);
|
|
1494
|
-
// 2, not 1. Unchecked, the object flows on and the first use of it throws —
|
|
1495
|
-
// and an uncaught throw exits 1, the code reserved for "successful query, no
|
|
1496
|
-
// survivors". A caller reading only the status hears "there is no work".
|
|
1497
|
-
assert.equal(status, 2);
|
|
1498
|
-
// Anchored on the die() prefix: `--jq` also appears in the echoed `$ gh` line,
|
|
1499
|
-
// so an unanchored /--jq/ passes on a run that never refused at all.
|
|
1500
|
-
assert.match(stderr, /^candidates: .*--jq/m);
|
|
1501
|
-
});
|
|
1502
|
-
|
|
1503
|
-
test("gh output that is empty refuses — the reduction emits an array for every input, including none", () => {
|
|
1504
|
-
// The one shape the checks below cannot see, because it never reaches the
|
|
1505
|
-
// parse. `[…]`-wrapped, the expression emits `[]` for an empty list, so no
|
|
1506
|
-
// output at all means it did not run — the same fact as a wrong shape, and
|
|
1507
|
-
// NOT an empty queue. Returning `[]` here spent that on exit 1, "no work".
|
|
1508
|
-
const { status, stderr } = run(
|
|
1509
|
-
[ticket(11, "## What to build\n\nx\n")],
|
|
1510
|
-
["--require-label", "ready-for-agent"],
|
|
1511
|
-
null,
|
|
1512
|
-
{ JQ_OVERRIDE: "empty" },
|
|
1513
|
-
);
|
|
1514
|
-
assert.equal(status, 2);
|
|
1515
|
-
assert.match(stderr, /^candidates: .*--jq/m);
|
|
1516
|
-
});
|
|
1517
|
-
|
|
1518
|
-
test("gh rows that were never reduced refuse — raw issues are not {n,t,l,d,dh,spec}", () => {
|
|
1519
|
-
// What a gh that ignored `--jq` actually returns: the unreduced `--json`
|
|
1520
|
-
// payload. An array, so an array check alone passes it through.
|
|
1521
|
-
const { status, stderr } = run(
|
|
1522
|
-
[ticket(11, "## What to build\n\nx\n")],
|
|
1523
|
-
["--require-label", "ready-for-agent"],
|
|
1524
|
-
null,
|
|
1525
|
-
{ JQ_OVERRIDE: "." },
|
|
1526
|
-
);
|
|
1527
|
-
assert.equal(status, 2);
|
|
1528
|
-
assert.match(stderr, /^candidates: .*--jq/m);
|
|
1529
|
-
// The refusal names the row by index and never prints it. This is the one
|
|
1530
|
-
// payload-shaped stderr path in the file, and an unreduced row carries the
|
|
1531
|
-
// full issue body — the ~97% this script exists to not fetch. Without this,
|
|
1532
|
-
// a die() that interpolated the row instead of its index kept the whole
|
|
1533
|
-
// suite green while emitting every body it refused to pull.
|
|
1534
|
-
assert.doesNotMatch(stderr, /What to build/);
|
|
1535
|
-
});
|
|
1536
|
-
|
|
1537
|
-
test("a failed gh query refuses without re-emitting gh's own stderr", () => {
|
|
1538
|
-
// A program jq cannot compile: it exits non-zero, so execFileSync throws and
|
|
1539
|
-
// the fail-closed die() runs. jq echoes the offending program in its own
|
|
1540
|
-
// error, which is the marker below.
|
|
1541
|
-
const { status, stderr } = run(
|
|
1542
|
-
[ticket(11, "## What to build\n\nx\n")],
|
|
1543
|
-
["--require-label", "ready-for-agent"],
|
|
1544
|
-
null,
|
|
1545
|
-
{ JQ_OVERRIDE: "MARKER_ZZZ(((" },
|
|
1546
|
-
);
|
|
1547
|
-
// 2, not 1: a broken query is not an empty queue — the archetypal fail-closed
|
|
1548
|
-
// path, and the one die() in query() that had no test at all.
|
|
1549
|
-
assert.equal(status, 2);
|
|
1550
|
-
// Both halves of the contract, and neither is a count over the whole stream.
|
|
1551
|
-
// Counting occurrences looks like the tighter pin but is coupled to jq's
|
|
1552
|
-
// choice of error path: `(((` is unbalanced, so jq takes the SYNTAX-error
|
|
1553
|
-
// branch, which echoes the program once. Balanced `MARKER_ZZZ` takes the
|
|
1554
|
-
// undefined-function branch, which names the symbol AND echoes the program —
|
|
1555
|
-
// two occurrences from the child alone, failing an exactly-1 assertion
|
|
1556
|
-
// against correct code.
|
|
1557
|
-
//
|
|
1558
|
-
// So: the child's copy must arrive (execFileSync forwards it), and the
|
|
1559
|
-
// refusal line must not carry it a second time (#176 — measured 7,700 B of
|
|
1560
|
-
// gh stderr becoming 15,454 B, into a caller that is markdown read by a
|
|
1561
|
-
// model). The same duplication this file's row-shape refusal already avoids.
|
|
1562
|
-
assert.match(stderr, /MARKER_ZZZ/);
|
|
1563
|
-
const refusal = stderr.match(/^candidates: .*$/m)[0];
|
|
1564
|
-
assert.match(refusal, /^candidates: gh issue list failed/);
|
|
1565
|
-
assert.doesNotMatch(refusal, /MARKER_ZZZ/);
|
|
1566
|
-
});
|
|
1567
|
-
|
|
1568
|
-
test("the exit code survives a gh stderr larger than the pipe buffer — the case that motivated it", () => {
|
|
1569
|
-
// The failure mode the fix targets, at the size it actually happens. Once
|
|
1570
|
-
// ~64 KiB of gh's forwarded stderr is already queued on a pipe, this fd is
|
|
1571
|
-
// non-blocking and die()'s own writeSync can throw EAGAIN. Unfixed, that
|
|
1572
|
-
// throw is uncaught: process.exit(2) never runs and the process falls
|
|
1573
|
-
// through to exit 1 — "query fine, queue empty", the wrong fact (#299).
|
|
1574
|
-
// Under the buffer every variant passes, so the program must stay large.
|
|
1575
|
-
//
|
|
1576
|
-
// Flaky by nature — it races the pipe reader — so it's pinned by repeated
|
|
1577
|
-
// runs under Linux (this repo's CI target), not by a single local pass:
|
|
1578
|
-
// unfixed, 7/15 runs inverted to exit 1; fixed, 0/20 did, 1000+ msgs run.
|
|
1579
|
-
// On darwin EAGAIN never fires at all — unfixed, the status assertion below
|
|
1580
|
-
// caught the revert 0/15 — so a local green confirms nothing and the source
|
|
1581
|
-
// pin at the end is the only gate on this platform.
|
|
1582
|
-
//
|
|
1583
|
-
// Text, not just status: this only asserts the EXIT CODE, not the refusal
|
|
1584
|
-
// wording. #889 gave die() a bounded EAGAIN retry loop (MAX_EAGAIN_RETRIES
|
|
1585
|
-
// in arg.mjs) that resumes a short write and retries the exact EAGAIN this
|
|
1586
|
-
// test forces, so the message is no longer lost on the first EAGAIN the way
|
|
1587
|
-
// it was before #889 — only a reader that never drains past the retry cap
|
|
1588
|
-
// can still lose it, and #299 is what keeps the exit code honest either way.
|
|
1589
|
-
const { status, stderr } = run(
|
|
1590
|
-
[ticket(11, "## What to build\n\nx\n")],
|
|
1591
|
-
["--require-label", "ready-for-agent"],
|
|
1592
|
-
null,
|
|
1593
|
-
{ JQ_OVERRIDE: `${"z".repeat(100_000)}(((` },
|
|
1594
|
-
);
|
|
1595
|
-
assert.ok(stderr.length > 60_000, `gh stderr must exceed the buffer, got ${stderr.length}`);
|
|
1596
|
-
assert.equal(status, 2);
|
|
1597
|
-
// The guard's SHAPE, deterministically — the assertion above is the race.
|
|
1598
|
-
// Stripped first, and this is not optional: against raw source a `die()`
|
|
1599
|
-
// genuinely reverted to console.error with the good shape parked in a block
|
|
1600
|
-
// comment passes 375/375 (measured), because a `^…/m` anchor matches inside
|
|
1601
|
-
// the comment. Dropping this pin also drops the only pin on #176, which is
|
|
1602
|
-
// what the refusal-text assertion this test used to carry was doing.
|
|
1603
|
-
//
|
|
1604
|
-
// #367 moved die() into arg.mjs's makeDie() — candidates.mjs's own source no
|
|
1605
|
-
// longer contains the try/catch shape, so a lift pin against SCRIPT alone
|
|
1606
|
-
// would now test a module nothing here calls (a source text-lift pin tests
|
|
1607
|
-
// a COPY). The SHAPE is pinned here; the CALL SITE that wires it in is
|
|
1608
|
-
// pinned for all seven consumers in arg.test.mjs, not here — pinning it here
|
|
1609
|
-
// was vacuous: candidates.mjs can define a local console.error makeDie(),
|
|
1610
|
-
// keep `const die = makeDie(NAME);` verbatim, and the suite stays green at
|
|
1611
|
-
// 640/640 (measured). That line pins a NAME, not the module it resolves to.
|
|
1612
|
-
//
|
|
1613
|
-
// Each fragment anchored at a line start under /m — the old regex joined
|
|
1614
|
-
// them with a bare `\s*` and no anchor at all. stripComments() blanks
|
|
1615
|
-
// whole-line comments only (its own documented ceiling), so a trailing
|
|
1616
|
-
// `code; // function die(msg) { try { writeSync(2,` survives stripping and
|
|
1617
|
-
// satisfied the old regex with die() genuinely reverted (measured).
|
|
1618
|
-
// Requiring each fragment at a line START refuses that — the decoy sits
|
|
1619
|
-
// mid-line, and a whole-line decoy is blanked to "". `\s*^\s*` between the
|
|
1620
|
-
// fragments rather than a literal `\n` on purpose: a future editor adding a
|
|
1621
|
-
// comment line inside makeDie must not turn this pin red (measured — the
|
|
1622
|
-
// adjacency form over-fired on exactly that). Do not terminate the lines
|
|
1623
|
-
// with `$` either; that over-fires on a trailing comment (measured).
|
|
1624
|
-
//
|
|
1625
|
-
// #889/#1549: the loop that consumes writeSync's return value no longer
|
|
1626
|
-
// lives in die() at all — it is arg.mjs's writeAll(), pinned ONCE at its
|
|
1627
|
-
// own definition in arg.test.mjs. Three test files used to carry
|
|
1628
|
-
// near-copies of that same loop regex, differing only in head line and fd,
|
|
1629
|
-
// and keeping three hand-mirrored loops in step was what #1549 removed.
|
|
1630
|
-
//
|
|
1631
|
-
// What stays die()'s OWN, and is all this pins, is the wiring: the refusal
|
|
1632
|
-
// goes through writeAll on fd 2, the template sits INSIDE the try, and
|
|
1633
|
-
// process.exit(2) follows it unconditionally, outside the catch. That
|
|
1634
|
-
// middle clause is load-bearing rather than decorative — hoisting the
|
|
1635
|
-
// template out to writeAll's argument list puts msg's own string coercion
|
|
1636
|
-
// back where a throwing msg escapes and skips the exit call, which is the
|
|
1637
|
-
// #299/#328 inversion this file's die() promises never to repeat.
|
|
1638
|
-
// Measured against that exact mutant: this pin reds, and the writeAll loop
|
|
1639
|
-
// pin in arg.test.mjs stays green — the two discriminate different defects
|
|
1640
|
-
// and neither substitutes for the other.
|
|
1641
|
-
assert.match(
|
|
1642
|
-
stripComments(readFileSync(ARG_MODULE, "utf8")),
|
|
1643
|
-
/^\s*(?:return )?function die\(msg\) \{\s*^\s*try \{\s*^\s*writeAll\(2, `[^`]*`\);\s*^\s*\} catch \{\s*^\s*\}\s*^\s*process\.exit\(2\);/m,
|
|
1644
|
-
);
|
|
1645
|
-
});
|
|
1646
|
-
|
|
1647
|
-
test("gh missing entirely is named as ENOENT — the shape that prints nothing at all", () => {
|
|
1648
|
-
// The other side of `e.code ?? …`. Deleting the whole `e.code` half leaves
|
|
1649
|
-
// the suite green without this: the jq test above only ever reaches the
|
|
1650
|
-
// exit-status branch. ENOENT is the shape where die() is the SOLE diagnostic
|
|
1651
|
-
// — nothing spawned, so no child stderr was forwarded to fall back on.
|
|
1652
|
-
const { status, stderr } = run(
|
|
1653
|
-
[ticket(11, "## What to build\n\nx\n")],
|
|
1654
|
-
["--require-label", "ready-for-agent"],
|
|
1655
|
-
null,
|
|
1656
|
-
{ PATH: "/nonexistent" },
|
|
1657
|
-
);
|
|
1658
|
-
assert.equal(status, 2);
|
|
1659
|
-
assert.match(stderr, /^candidates: gh issue list failed: ENOENT$/m);
|
|
1660
|
-
});
|
|
1661
|
-
|
|
1662
|
-
test("a signal-killed gh is named by its signal, not reported as `exit null`", () => {
|
|
1663
|
-
// Third disjoint shape: `e.code` undefined AND `e.status` null, so a
|
|
1664
|
-
// two-branch expression prints `exit null` and names nothing. Live for gh —
|
|
1665
|
-
// the OOM killer on a large query, a SIGPIPE, a propagated Ctrl-C — and the
|
|
1666
|
-
// child prints nothing on its way out, so this line is all the caller gets.
|
|
1667
|
-
const { status, stderr } = runWithGh(`#!/bin/sh\nkill -TERM $$\n`);
|
|
1668
|
-
assert.equal(status, 2);
|
|
1669
|
-
assert.match(stderr, /^candidates: gh issue list failed: killed by SIGTERM$/m);
|
|
1670
|
-
assert.doesNotMatch(stderr, /exit null/);
|
|
1671
|
-
});
|
|
1672
|
-
|
|
1673
|
-
test("a payload past the pipe buffer arrives whole — truncated JSON must never read as exit 0", () => {
|
|
1674
|
-
// process.exit() discards queued writes, and stdout on a pipe (which is what
|
|
1675
|
-
// spawnSync gives us, and what every real caller gives it) is async. 499 rows
|
|
1676
|
-
// — one UNDER the default --limit, so refuseIfCapped never fires — measured
|
|
1677
|
-
// 65,536 B and mid-JSON at exit 0: a corrupt payload typed as success, the
|
|
1678
|
-
// one outcome this file's exit codes exist to make impossible.
|
|
1679
|
-
//
|
|
1680
|
-
// The pin is `rows`, which run() JSON.parses: truncation throws there. The
|
|
1681
|
-
// byte assertion is what makes it meaningful — under the buffer this test
|
|
1682
|
-
// passes against process.exit() too, so it must stay comfortably over.
|
|
1683
|
-
const issues = Array.from({ length: 499 }, (_, i) => ({
|
|
1684
|
-
number: i + 1,
|
|
1685
|
-
title: "t".repeat(120),
|
|
1686
|
-
labels: [{ name: "ready-for-agent" }, { name: "size:m" }],
|
|
1687
|
-
body: "## What to build\n\ndepends on #7\n",
|
|
1688
|
-
}));
|
|
1689
|
-
const { status, stdout, rows } = run(issues);
|
|
1690
|
-
assert.ok(stdout.length > 70_000, `payload must exceed the 64 KiB buffer, got ${stdout.length}`);
|
|
1691
|
-
assert.equal(rows.length, 499);
|
|
1692
|
-
assert.equal(status, 0);
|
|
1693
|
-
});
|
|
1694
|
-
|
|
1695
|
-
test("an empty queue is exit 1, not 2 — the query worked and there is no work", () => {
|
|
1696
|
-
// The other half of the contract in this file's header. Every refusal above
|
|
1697
|
-
// pins 2; nothing pinned 1, so a change spending 2 on an empty queue — the
|
|
1698
|
-
// swap the header forbids — shipped green. Verified by mutation: flipping the
|
|
1699
|
-
// `: 1` arm of `rows.length === 0 ? (allFilteredOut ? 3 : 1) : 0` to `: 2`
|
|
1700
|
-
// fails this test, the #64 fallback-genuinely-empty test below, AND
|
|
1701
|
-
// fleet-tick's "supply comes from candidates.mjs" — every reader of that arm,
|
|
1702
|
-
// across both files. Before #64 the line read `rows.length === 0 ? 1 : 0`
|
|
1703
|
-
// and this was indeed the only test that saw it; the exit-3 branch and its
|
|
1704
|
-
// fallback test are what made that count stale.
|
|
1705
|
-
const { status, stdout } = run([], ["--require-label", "ready-for-agent"]);
|
|
1706
|
-
assert.equal(status, 1);
|
|
1707
|
-
assert.equal(stdout.trim(), "[]");
|
|
1708
|
-
});
|
|
1709
|
-
|
|
1710
|
-
test("an all-filtered labeled queue with no fallback is exit 3, not 1 — the caller can tell filtered-empty from genuinely-empty (#64)", () => {
|
|
1711
|
-
// No --allow-fallback, so this is a single pass: the labeled query returns
|
|
1712
|
-
// rows and dropSpecs removes every one. Byte-identical to a genuinely empty
|
|
1713
|
-
// queue on stdout; the exit code is the only place the two facts differ.
|
|
1714
|
-
const { status, stdout } = run([
|
|
1715
|
-
ticket(10, "## User Stories\n\n1. As a user…\n"),
|
|
1716
|
-
ticket(11, "## Problem Statement\n\ny\n\n## User Stories\n\n2. As a user…\n"),
|
|
1717
|
-
]);
|
|
1718
|
-
assert.equal(stdout.trim(), "[]");
|
|
1719
|
-
assert.equal(status, 3);
|
|
1720
|
-
});
|
|
1721
|
-
|
|
1722
|
-
test("an all-filtered fallback pass is exit 3 even though the labeled pass was genuinely empty — the verdict is the fallback's own, not pass 1's (#64)", () => {
|
|
1723
|
-
// Pass 1 (labeled) comes back with zero rows — genuinely empty, nothing to
|
|
1724
|
-
// filter, so pass 1's own flag would be false. Pass 2 (fallback) comes back
|
|
1725
|
-
// with rows and drops every one. If the two passes' flags were AND'd together
|
|
1726
|
-
// instead of the fallback's replacing pass 1's outright, this would wrongly
|
|
1727
|
-
// read pass 1's "false" through and report exit 1 — verified by mutation, and
|
|
1728
|
-
// this is the only test in the suite that the AND breaks. OR is the
|
|
1729
|
-
// complementary bug, which this test cannot see (false OR true is true
|
|
1730
|
-
// either way); the test below is what pins that direction.
|
|
1731
|
-
const { status, stdout, stderr } = run(
|
|
1732
|
-
[],
|
|
1733
|
-
["--require-label", "ready-for-agent", "--allow-fallback"],
|
|
1734
|
-
[
|
|
1735
|
-
ticket(12, "## User Stories\n\n1. As a user…\n", ["ready-for-human"]),
|
|
1736
|
-
ticket(13, "## Problem Statement\n\nz\n\n## User Stories\n\n2. As a user…\n", ["ready-for-human"]),
|
|
1737
|
-
],
|
|
1738
|
-
);
|
|
1739
|
-
assert.match(stderr, /retrying unfiltered/);
|
|
1740
|
-
assert.equal(stdout.trim(), "[]");
|
|
1741
|
-
assert.equal(status, 3);
|
|
1742
|
-
});
|
|
1743
|
-
|
|
1744
|
-
test("a labeled all-specs query that falls back to a genuinely empty unfiltered query is exit 1, not 3 — pass 1's drop must not leak into pass 2's verdict (#64)", () => {
|
|
1745
|
-
// The edge case the ticket names explicitly. Pass 1 (labeled) has rows and
|
|
1746
|
-
// drops every one as a spec — pass 1's own flag is true. Pass 2 (fallback)
|
|
1747
|
-
// comes back with no rows at all — genuinely empty, nothing to filter. If
|
|
1748
|
-
// pass 1's "true" carried forward (an OR instead of a plain reassignment),
|
|
1749
|
-
// this would wrongly report exit 3 for a fallback that filtered nothing.
|
|
1750
|
-
const { status, stdout, stderr } = run(
|
|
1751
|
-
[ticket(10, "## User Stories\n\n1. As a user…\n")],
|
|
1752
|
-
["--require-label", "ready-for-agent", "--allow-fallback"],
|
|
1753
|
-
[],
|
|
1754
|
-
);
|
|
1755
|
-
assert.match(stderr, /retrying unfiltered/);
|
|
1756
|
-
assert.equal(stdout.trim(), "[]");
|
|
1757
|
-
assert.equal(status, 1);
|
|
1758
|
-
});
|
|
1759
|
-
|
|
1760
|
-
test("candidates come back oldest first, whatever order gh returned them in", () => {
|
|
1761
|
-
// gh defaults to created-desc, so newest-first is the realistic input.
|
|
1762
|
-
const { rows } = run([
|
|
1763
|
-
ticket(42, "## What to build\n\nc\n"),
|
|
1764
|
-
ticket(19, "## What to build\n\nb\n"),
|
|
1765
|
-
ticket(7, "## What to build\n\na\n"),
|
|
1766
|
-
]);
|
|
1767
|
-
assert.deepEqual(rows.map((r) => r.n), [7, 19, 42]);
|
|
1768
|
-
});
|
|
1769
|
-
|
|
1770
|
-
// #175. The search term is built by interpolation, so the label's own
|
|
1771
|
-
// characters are read by GitHub's query parser, not carried past it. The stub
|
|
1772
|
-
// above models the one split that matters — an unquoted value ends at the
|
|
1773
|
-
// first space. Neither test below is green on both trees, but they go red for
|
|
1774
|
-
// different reasons. On the raw interpolation the first fails outright: the
|
|
1775
|
-
// term resolves to `good`, the query matches nothing, and the empty answer
|
|
1776
|
-
// surfaces as exit 1. The second's QUERY OUTCOME — status and rows — is
|
|
1777
|
-
// identical either way, which is the whole point of it: quoting the label
|
|
1778
|
-
// every current caller actually passes is a no-op for what comes back. Its
|
|
1779
|
-
// wire-form assertion is the fix-dependent half, and reds on the raw
|
|
1780
|
-
// interpolation exactly like the first.
|
|
1781
|
-
|
|
1782
|
-
test("a multi-word label is quoted into the search term — unquoted, every word after the first is free text (#175)", () => {
|
|
1783
|
-
// The ticket's headline symptom, and the one the exit-code contract makes
|
|
1784
|
-
// expensive: the query silently did not mean what was asked, matched
|
|
1785
|
-
// nothing, and its empty result read as exit 1 — "the query worked and
|
|
1786
|
-
// there is no work" — against a queue that was not empty. Reachable in a
|
|
1787
|
-
// repo that remapped its triage labels (docs/agents/triage-labels.md invites
|
|
1788
|
-
// exactly that), where the AFK-ready role can be spelled `good first issue`.
|
|
1789
|
-
const { status, rows } = run(
|
|
1790
|
-
[ticket(11, "## What to build\n\nx\n", ["good first issue"])],
|
|
1791
|
-
["--require-label", "good first issue"],
|
|
1792
|
-
null,
|
|
1793
|
-
{ LABEL_EXPECT: "good first issue" },
|
|
1794
|
-
);
|
|
1795
|
-
assert.equal(status, 0);
|
|
1796
|
-
assert.deepEqual(rows.map((r) => r.n), [11]);
|
|
1797
|
-
});
|
|
1798
|
-
|
|
1799
|
-
test("a single-word label still resolves to itself — quoting must not disturb the only label every caller passes", () => {
|
|
1800
|
-
// AC-3's other half, and the half a quoting fix can newly break: this term
|
|
1801
|
-
// is what next-ticket/SKILL.md's `## 1. Candidates` step, shortlist.mjs (run-team/SKILL.md's
|
|
1802
|
-
// **Build the Shortlist** step) and fleet-tick.mjs's `supply` all send, so a change that widened or narrowed it would
|
|
1803
|
-
// empty the fleet's queue at exit 1 — #175's own defect, relocated. Measured
|
|
1804
|
-
// against the live repo 2026-08-17: `label:ready-for-agent` and
|
|
1805
|
-
// `label:"ready-for-agent"` return the same count, so the quoting is a no-op
|
|
1806
|
-
// HERE, which is a fact about GitHub's parser and not one this stub can
|
|
1807
|
-
// prove. What the stub can prove is the half that would break: the term
|
|
1808
|
-
// still resolves to `ready-for-agent` and nothing else.
|
|
1809
|
-
const { status, rows, stderr } = run(
|
|
1810
|
-
[ticket(11, "## What to build\n\nx\n")],
|
|
1811
|
-
["--require-label", "ready-for-agent"],
|
|
1812
|
-
null,
|
|
1813
|
-
{ LABEL_EXPECT: "ready-for-agent" },
|
|
1814
|
-
);
|
|
1815
|
-
assert.equal(status, 0);
|
|
1816
|
-
assert.deepEqual(rows.map((r) => r.n), [11]);
|
|
1817
|
-
// Anchored on the `--json` that follows, so this cannot be satisfied by a
|
|
1818
|
-
// term with the label plus trailing free text — the exact shape #175 is.
|
|
1819
|
-
assert.match(stderr, /--search -label:in-progress[^\n]* label:"ready-for-agent" --json/);
|
|
1820
|
-
});
|
|
1821
|
-
|
|
1822
|
-
test("a label with no space is quoted too — the wire form carries every label, not only the ones a space would break", () => {
|
|
1823
|
-
// What this pins is the UNIFORMITY, not a second dangerous character. Space
|
|
1824
|
-
// is how the ticket found the bug and — measured 2026-08-17 — it is the only
|
|
1825
|
-
// character GitHub splits an unquoted value on: `label:auto:logs` and
|
|
1826
|
-
// `label:"auto:logs"` agree on renovatebot/renovate, so `status:ready` would
|
|
1827
|
-
// in fact survive unquoted. The fix quotes it anyway because quoting a value
|
|
1828
|
-
// that needs none is a measured no-op, and one unconditional form beats a
|
|
1829
|
-
// `/\s/` predicate that has to stay in step with GitHub's parser; quoting
|
|
1830
|
-
// only when /\s/ matched would pass every other test in this suite unnoticed.
|
|
1831
|
-
// Behaviour cannot pin this one — the stub's parser resolves the label under
|
|
1832
|
-
// either form — so the wire form is the assertion.
|
|
1833
|
-
const { stderr } = run(
|
|
1834
|
-
[ticket(11, "## What to build\n\nx\n", ["status:ready"])],
|
|
1835
|
-
["--require-label", "status:ready"],
|
|
1836
|
-
);
|
|
1837
|
-
assert.match(stderr, /--search -label:in-progress[^\n]* label:"status:ready" --json/);
|
|
1838
|
-
});
|
|
1839
|
-
|
|
1840
|
-
test("a label containing a double quote refuses — an unrepresentable query must not run as an empty one", () => {
|
|
1841
|
-
// What the fix itself newly makes possible: the term is `label:"<value>"`,
|
|
1842
|
-
// so a `"` inside the value closes it early and the remainder becomes free
|
|
1843
|
-
// text — #175's defect with the quoting applied. Refuse at exit 2 ("the
|
|
1844
|
-
// query broke") rather than send it, because the alternative is the fail-open
|
|
1845
|
-
// this file exists to prevent: a misparsed query whose empty result is
|
|
1846
|
-
// indistinguishable from an empty queue. Escaping instead was not shipped
|
|
1847
|
-
// because there is nothing to escape TO: GitHub does honour `\"` inside a
|
|
1848
|
-
// qualifier, so a backslash cannot rescue a quote — it only moves the same
|
|
1849
|
-
// misparse one character left, which is what the next test pins.
|
|
1850
|
-
const { status, stderr } = run(
|
|
1851
|
-
[ticket(11, "## What to build\n\nx\n")],
|
|
1852
|
-
["--require-label", 'say "hi"'],
|
|
1853
|
-
);
|
|
1854
|
-
assert.equal(status, 2);
|
|
1855
|
-
assert.match(stderr, /^candidates: --require-label cannot contain a double quote/m);
|
|
1856
|
-
// Refuses BEFORE gh, like every other value guard: a query that cannot be
|
|
1857
|
-
// built correctly must not be sent at all.
|
|
1858
|
-
assert.equal(queriesRun(stderr), 0);
|
|
1859
|
-
});
|
|
1860
|
-
|
|
1861
|
-
test("a label ending in a backslash refuses too — it eats the closing quote the fix adds", () => {
|
|
1862
|
-
// The same term broken from the other side, and the side that leaves no
|
|
1863
|
-
// trace. Measured against feigi/claude-config 2026-08-17: negating a label
|
|
1864
|
-
// no issue carries is a no-op, so `-label:"zzz" label:"ready-for-agent"`
|
|
1865
|
-
// returns the same count as `label:"ready-for-agent"` alone — but
|
|
1866
|
-
// `-label:"zzz\" label:"ready-for-agent"` returns the count for
|
|
1867
|
-
// `ready-for-agent` as FREE TEXT, the backslash having eaten the closing
|
|
1868
|
-
// quote and swallowed the whole following qualifier. Doubling does not
|
|
1869
|
-
// escape it. In the shape query() actually builds the label term comes
|
|
1870
|
-
// LAST, so a trailing backslash leaves its value unterminated and the query
|
|
1871
|
-
// answers zero rows at HTTP 200, no error — #175's silent empty, reached
|
|
1872
|
-
// through the fix rather than around it. Without this case the widened
|
|
1873
|
-
// guard is unpinned: narrowing it back to `"` alone leaves every other test
|
|
1874
|
-
// in this file green.
|
|
1875
|
-
const { status, stderr } = run(
|
|
1876
|
-
[ticket(11, "## What to build\n\nx\n")],
|
|
1877
|
-
["--require-label", "trailing\\"],
|
|
1878
|
-
);
|
|
1879
|
-
assert.equal(status, 2);
|
|
1880
|
-
assert.match(stderr, /^candidates: --require-label cannot contain a double quote or a backslash/m);
|
|
1881
|
-
assert.equal(queriesRun(stderr), 0);
|
|
1882
|
-
});
|
|
1883
|
-
|
|
1884
|
-
// The other half of #173, and the half that produced the refused invocation
|
|
1885
|
-
// above: the rule a controller reads lives in another file and was pinned by
|
|
1886
|
-
// nothing, so it named a flag the script has never accepted.
|
|
1887
|
-
const RUN_TEAM = readFileSync(join(import.meta.dirname, "..", "skills", "run-team", "SKILL.md"), "utf8");
|
|
1888
|
-
|
|
1889
|
-
test("run-team's phase 0 rule names the flag candidates.mjs accepts", () => {
|
|
1890
|
-
// The step-1 bullet alone. A slice any wider is vacuous for this claim: the
|
|
1891
|
-
// `candidates.mjs` invocation in the same bullet already spells
|
|
1892
|
-
// `--require-label` correctly, so a positive match anywhere in phase 0 stays
|
|
1893
|
-
// green with the rule naming anything at all.
|
|
1894
|
-
const step1 = between(RUN_TEAM, "1. **Build the Shortlist**", "\n2. ", "run-team/SKILL.md");
|
|
1895
|
-
// Leading backtick, so this can only be satisfied by the RULE: in the command
|
|
1896
|
-
// above it, `--require-label` is preceded by a line break, not a backtick.
|
|
1897
|
-
// The gap is loose enough that rewording around `mandatory` stays green and
|
|
1898
|
-
// tight enough that a different flag in the rule does not.
|
|
1899
|
-
assert.match(
|
|
1900
|
-
step1,
|
|
1901
|
-
/`--require-label ready-for-agent`[\s\S]{0,20}mandatory/,
|
|
1902
|
-
"run-team's mandatory-label rule no longer names --require-label",
|
|
1903
|
-
);
|
|
1904
|
-
// The positive pin cannot see a SECOND sentence naming the wrong flag, which
|
|
1905
|
-
// is exactly what shipped. `--require-label` does not contain `--label`, so
|
|
1906
|
-
// this needs no quoting to tell them apart.
|
|
1907
|
-
assert.doesNotMatch(
|
|
1908
|
-
step1,
|
|
1909
|
-
/--label\b/,
|
|
1910
|
-
"run-team's phase 0 step 1 names `--label`, which candidates.mjs refuses",
|
|
1911
|
-
);
|
|
1912
|
-
});
|
|
1913
|
-
|
|
1914
|
-
// --- #240: the third carrier, and the one the pin above cannot see. The rule
|
|
1915
|
-
// in run-team/SKILL.md is pinned; the design spec that rule descends from was
|
|
1916
|
-
// not, and it still spelled the flag `--label`.
|
|
1917
|
-
//
|
|
1918
|
-
// The spelling was CORRECT the day that spec was written: at `02bfd59`, the
|
|
1919
|
-
// commit that added it, `next-ticket` step 1 — the step the spec cites rather
|
|
1920
|
-
// than restates — was a raw `gh issue list` reading "Add `--label
|
|
1921
|
-
// ready-for-agent` first". `c3310fe` moved that query into this script the next
|
|
1922
|
-
// day, and this script has read `arg("require-label")` in every commit of its
|
|
1923
|
-
// life. That is why the spec carries a supersession note rather than a silent
|
|
1924
|
-
// swap: these documents are dated records, and only a behavioural claim the
|
|
1925
|
-
// code contradicts gets corrected in them.
|
|
1926
|
-
const SPEC_RUN_TEAM_DESIGN = fileURLToPath(
|
|
1927
|
-
new URL("../../docs/specs/2026-07-22-run-team-agent-fleet-design.md", import.meta.url),
|
|
1928
|
-
);
|
|
1929
|
-
const SPEC_COCKPIT_DESIGN = fileURLToPath(
|
|
1930
|
-
new URL("../../docs/specs/2026-07-24-fleet-cockpit-design.md", import.meta.url),
|
|
1931
|
-
);
|
|
1932
|
-
|
|
1933
|
-
// Derived from the declaration, not restated from it: a rename of the accepted
|
|
1934
|
-
// flag reddens here, which is the whole failure this ticket is an instance of —
|
|
1935
|
-
// a hand-copied spelling that nothing made move with the script.
|
|
1936
|
-
//
|
|
1937
|
-
// Guarded at every step, and called from a test body rather than run at module
|
|
1938
|
-
// scope, because an unguarded index here fails at IMPORT, and an import-time
|
|
1939
|
-
// failure takes down every test in this file — the ones deriving the flag and
|
|
1940
|
-
// the ones that have nothing to do with it alike — leaving one node-authored
|
|
1941
|
-
// `TypeError` that names a file and a line but never names `OPTIONS` as the
|
|
1942
|
-
// thing to look at. Measured on this tree by appending an unguarded
|
|
1943
|
-
// module-scope `.match(...)[0]` to this file and one-lining `OPTIONS`:
|
|
1944
|
-
// `node --test plugin/scripts/candidates.test.mjs` then reports one
|
|
1945
|
-
// synthetic test, zero passes, and that TypeError.
|
|
1946
|
-
//
|
|
1947
|
-
// Reformatting `OPTIONS` — one-lining it, wrapping it in `Object.freeze`,
|
|
1948
|
-
// anything that drops the literal `\n};` this regex needs — has zero
|
|
1949
|
-
// behavioural effect, so what the guard buys is that such a reformat costs
|
|
1950
|
-
// only the tests that derive the flag: measured by one-lining `OPTIONS` on
|
|
1951
|
-
// this tree, those tests red with this guard's own `OPTIONS block no longer
|
|
1952
|
-
// matches — update this test` message and every other test in this file still
|
|
1953
|
-
// runs and passes.
|
|
1954
|
-
//
|
|
1955
|
-
// The `*label` match is global and required to be UNIQUE rather than indexed
|
|
1956
|
-
// at the first hit, because indexing fails SILENTLY: an `"exclude-label"`
|
|
1957
|
-
// declared above `"require-label"` would pin the specs below to a flag they do
|
|
1958
|
-
// not mean, and a test passing for the wrong reason is this ticket's own defect
|
|
1959
|
-
// class. Anchoring to the literal `require-label` would settle the ordering by
|
|
1960
|
-
// restating the string this test exists to stop restating.
|
|
1961
|
-
function declaredLabelFlag() {
|
|
1962
|
-
const block = readFileSync(SCRIPT, "utf8").match(/const OPTIONS = \{[\s\S]*?\n\};/);
|
|
1963
|
-
assert.ok(block, "candidates.mjs' OPTIONS block no longer matches — update this test");
|
|
1964
|
-
const flags = [...block[0].matchAll(/"([a-z-]*label)":/g)];
|
|
1965
|
-
assert.equal(
|
|
1966
|
-
flags.length,
|
|
1967
|
-
1,
|
|
1968
|
-
`candidates.mjs' OPTIONS declares ${flags.length} \`*label\` flags, not the 1 this test derives — update this test`,
|
|
1969
|
-
);
|
|
1970
|
-
return flags[0][1];
|
|
1971
|
-
}
|
|
1972
|
-
|
|
1973
|
-
// Which carriers of this flag's spelling carry a pin through this function,
|
|
1974
|
-
// and what a rename owes the ones that deliberately do not (#1196).
|
|
1975
|
-
//
|
|
1976
|
-
// The line is LIVE versus FROZEN, never value-bearing versus bare. Every live
|
|
1977
|
-
// carrier is pinned — a shipped skill or command, a live doc, and a contract
|
|
1978
|
-
// table edited in place, which is live whatever date its file is named for —
|
|
1979
|
-
// and a bare `candidates.mjs --<flag>` counts as much as one carrying a value:
|
|
1980
|
-
// left behind by a rename, it still names a flag that no longer exists, in a
|
|
1981
|
-
// file that is read as current. A rename edits each live carrier in place,
|
|
1982
|
-
// with no note, and its pin reds until it does.
|
|
1983
|
-
//
|
|
1984
|
-
// Frozen records — an accepted ADR's body, a dated spec's narrative, a
|
|
1985
|
-
// supersession note — stay unpinned, because a rename's correct handling of
|
|
1986
|
-
// them never touches the line a pin would read, so a pin there could only red
|
|
1987
|
-
// on a rename it cannot see handled. What a rename owes each kind:
|
|
1988
|
-
// - a dated spec: a supersession note, never a silent swap. The old spelling
|
|
1989
|
-
// now names an invocation this script refuses at exit 2, which is the
|
|
1990
|
-
// behavioural contradiction #257 lets a dated record be corrected for —
|
|
1991
|
-
// the note at the head of the run-team design spec (#240) is the shape.
|
|
1992
|
-
// - an accepted ADR: an `Amended by #N: …` on its `**Status:**` line, its
|
|
1993
|
-
// body left as ruled (AGENTS.md, *ADR amendments*).
|
|
1994
|
-
// The one pin on a dated spec below stays: it protects a correction #240
|
|
1995
|
-
// already made in place, rather than freezing a record.
|
|
1996
|
-
|
|
1997
|
-
test("the run-team design spec's candidate-scan step names the flag this script declares", () => {
|
|
1998
|
-
const DECLARED_LABEL_FLAG = declaredLabelFlag();
|
|
1999
|
-
// The step alone, for the reason the run-team pin above gives: a match
|
|
2000
|
-
// anywhere in the document is vacuous, and here it is worse than vacuous —
|
|
2001
|
-
// the supersession note at the head cites `--label` deliberately, as the
|
|
2002
|
-
// spelling this script refuses, so a file-wide negative would fail on the
|
|
2003
|
-
// correction's own prose.
|
|
2004
|
-
const step = between(
|
|
2005
|
-
readFileSync(SPEC_RUN_TEAM_DESIGN, "utf8"),
|
|
2006
|
-
"1. Candidate scan",
|
|
2007
|
-
"\n2. ",
|
|
2008
|
-
"the run-team design spec",
|
|
2009
|
-
);
|
|
2010
|
-
|
|
2011
|
-
assert.ok(
|
|
2012
|
-
step.includes(`\`--${DECLARED_LABEL_FLAG} ready-for-agent\``),
|
|
2013
|
-
`the spec's candidate-scan step no longer names --${DECLARED_LABEL_FLAG}, the label flag this script's OPTIONS declares`,
|
|
2014
|
-
);
|
|
2015
|
-
// `--require-label` does not contain `--label`, so this tells them apart with
|
|
2016
|
-
// no quoting — same reasoning as the run-team pin above.
|
|
2017
|
-
assert.doesNotMatch(
|
|
2018
|
-
step,
|
|
2019
|
-
/--label\b/,
|
|
2020
|
-
"the spec's candidate-scan step names `--label`, which this script refuses at exit 2",
|
|
2021
|
-
);
|
|
2022
|
-
});
|
|
2023
|
-
|
|
2024
|
-
// --- #851: the next-ticket carrier. `git grep -n -- --require-label docs
|
|
2025
|
-
// plugin` lists every carrier of this flag's spelling, pinned and unpinned
|
|
2026
|
-
// alike; which ones carry a pin, and why the rest deliberately do not, is the
|
|
2027
|
-
// rule above `declaredLabelFlag()`. `next-ticket/SKILL.md` earns a pin here
|
|
2028
|
-
// because it is what a solo caller reads to run the scan, and `--label` is
|
|
2029
|
-
// what `gh issue list` accepts, so it is the plausible thing to write and the
|
|
2030
|
-
// thing this script refuses at exit 2. Derived from `OPTIONS`, through the
|
|
2031
|
-
// same guarded `declaredLabelFlag()` the run-team design-spec pin uses, so a
|
|
2032
|
-
// rename of the flag reddens here instead of minting the next hand-copied
|
|
2033
|
-
// spelling.
|
|
2034
|
-
//
|
|
2035
|
-
// What gets pinned is the TOKEN inside the candidate step, not the invocation
|
|
2036
|
-
// that carries it. Measured, both legs: deleting that step's only fenced block
|
|
2037
|
-
// and naming the flag in prose instead leaves the whole suite green, while
|
|
2038
|
-
// deleting the same fence with NO mention of the flag reds with this pin's own
|
|
2039
|
-
// message. So this holds "the flag named here is the one `OPTIONS` declares",
|
|
2040
|
-
// never "there is a runnable command here" — a separate invariant #851 does
|
|
2041
|
-
// not ask for and nothing else in this suite claims.
|
|
2042
|
-
const NEXT_TICKET = readFileSync(join(import.meta.dirname, "..", "skills", "next-ticket", "SKILL.md"), "utf8");
|
|
2043
|
-
|
|
2044
|
-
// Takes the text rather than reading the file, so the discrimination test below
|
|
2045
|
-
// can put the same pin in front of the input it must red on AND the input it
|
|
2046
|
-
// must not. A pin only shown to red is not shown to discriminate.
|
|
2047
|
-
function assertScanRunsDeclaredFlag(text, where) {
|
|
2048
|
-
const flag = declaredLabelFlag();
|
|
2049
|
-
// The candidate step alone, for the reason both pins above give, and here
|
|
2050
|
-
// with a live second reason: step 7 of this same skill says "Never fold
|
|
2051
|
-
// `--label` into the create", where `--label` is `gh pr edit`'s own flag and
|
|
2052
|
-
// correct (#375). A file-wide negative would fail on that sentence.
|
|
2053
|
-
const step = between(text, "## 1. Candidates", "## 2. Dependencies", where);
|
|
2054
|
-
assert.ok(
|
|
2055
|
-
step.includes(`--${flag} ready-for-agent`),
|
|
2056
|
-
`${where}'s candidate scan no longer runs the label flag candidates.mjs' OPTIONS declares`,
|
|
2057
|
-
);
|
|
2058
|
-
// `--require-label` does not contain `--label`, so this tells them apart with
|
|
2059
|
-
// no quoting — same reasoning as the two pins above.
|
|
2060
|
-
assert.doesNotMatch(
|
|
2061
|
-
step,
|
|
2062
|
-
/--label\b/,
|
|
2063
|
-
`${where}'s candidate scan names \`--label\`, which candidates.mjs refuses at exit 2`,
|
|
2064
|
-
);
|
|
2065
|
-
}
|
|
2066
|
-
|
|
2067
|
-
test("next-ticket's candidate scan runs the flag this script declares", () => {
|
|
2068
|
-
assertScanRunsDeclaredFlag(NEXT_TICKET, "next-ticket/SKILL.md");
|
|
2069
|
-
});
|
|
2070
|
-
|
|
2071
|
-
test("the next-ticket pin reds on the refused spelling and stays green on text it must accept", () => {
|
|
2072
|
-
// REDS on the swap it exists to catch — written through the declared flag
|
|
2073
|
-
// rather than the literal, so a rename of the flag moves the mutant with it
|
|
2074
|
-
// instead of leaving a mutant that tests nothing.
|
|
2075
|
-
assert.throws(
|
|
2076
|
-
() => assertScanRunsDeclaredFlag(NEXT_TICKET.replaceAll(`--${declaredLabelFlag()}`, "--label"), "the mutant"),
|
|
2077
|
-
/the mutant's candidate scan/,
|
|
2078
|
-
"the pin does not red when the candidate scan is given the spelling this script refuses",
|
|
2079
|
-
);
|
|
2080
|
-
|
|
2081
|
-
// GREEN, control 1: the live file, which carries a legitimate `--label`
|
|
2082
|
-
// outside this slice. This is what separates a bounded pin from a whole-file
|
|
2083
|
-
// one — the latter clears "it and only it reds" and still reds on prose it
|
|
2084
|
-
// has no business reading.
|
|
2085
|
-
assert.match(
|
|
2086
|
-
NEXT_TICKET,
|
|
2087
|
-
/Never fold `--label` into the create/,
|
|
2088
|
-
"next-ticket/SKILL.md no longer carries a legitimate `--label` outside its candidate step — this control now proves nothing",
|
|
2089
|
-
);
|
|
2090
|
-
|
|
2091
|
-
// GREEN, control 2: a reflow. Rewrapping prose outside fenced blocks has zero
|
|
2092
|
-
// behavioural effect on a skill, and a prose pin that reds on one costs its
|
|
2093
|
-
// readers more than it holds.
|
|
2094
|
-
//
|
|
2095
|
-
// TWO reflows, in opposite directions, because one is not enough to stay
|
|
2096
|
-
// honest: an unwrap applied to an already-unwrapped file changes nothing, and
|
|
2097
|
-
// a control that asserts its own input changed would then red on the very
|
|
2098
|
-
// maintainer edit it exists to bless — measured, by running this against an
|
|
2099
|
-
// unwrapped copy of the skill. Requiring only that ONE of the two differs
|
|
2100
|
-
// keeps the control non-vacuous whatever the file's current wrapping.
|
|
2101
|
-
const outsideFences = (md, f) =>
|
|
2102
|
-
md.split(/(```[\s\S]*?```)/).map((part, i) => (i % 2 ? part : f(part))).join("");
|
|
2103
|
-
const unwrapped = outsideFences(NEXT_TICKET, (p) => p.replace(/(\S)\n(?=\S)/g, "$1 "));
|
|
2104
|
-
const rewrapped = outsideFences(unwrapped, (p) => p.replace(/, (?=\S)/g, ",\n"));
|
|
2105
|
-
assert.ok(
|
|
2106
|
-
unwrapped !== NEXT_TICKET || rewrapped !== NEXT_TICKET,
|
|
2107
|
-
"neither reflow changed next-ticket/SKILL.md — this control now proves nothing",
|
|
2108
|
-
);
|
|
2109
|
-
assertScanRunsDeclaredFlag(unwrapped, "an unwrapped next-ticket/SKILL.md");
|
|
2110
|
-
assertScanRunsDeclaredFlag(rewrapped, "a rewrapped next-ticket/SKILL.md");
|
|
2111
|
-
});
|
|
2112
|
-
|
|
2113
|
-
// --- #1196: the remaining live carriers, one pin each, by the rule above
|
|
2114
|
-
// `declaredLabelFlag()`. Each pin takes the text rather than reading the file,
|
|
2115
|
-
// for the reason `assertScanRunsDeclaredFlag` gives, and each has a
|
|
2116
|
-
// discrimination test that reds it on the refused spelling and keeps it green
|
|
2117
|
-
// on the real text.
|
|
2118
|
-
//
|
|
2119
|
-
// The fleet-plugin design spec's script-surface table is a live contract,
|
|
2120
|
-
// edited in place row by row, not a dated record — so its `candidates.mjs` row
|
|
2121
|
-
// is pinned like any shipped file, and a rename edits it with no note.
|
|
2122
|
-
const SPEC_PLUGIN_DESIGN = readFileSync(
|
|
2123
|
-
fileURLToPath(new URL("../../docs/specs/2026-07-23-fleet-plugin-design.md", import.meta.url)),
|
|
2124
|
-
"utf8",
|
|
2125
|
-
);
|
|
2126
|
-
|
|
2127
|
-
// The lookup candidates-exit3-prose.test.mjs's `candidatesRow()` makes, over
|
|
2128
|
-
// a text passed in. A local copy rather than an import: importing a test
|
|
2129
|
-
// module registers every test in it a second time in this process.
|
|
2130
|
-
function candidatesRow(text, where) {
|
|
2131
|
-
const line = text.split("\n").find((l) => l.startsWith("| `candidates.mjs` |"));
|
|
2132
|
-
assert.ok(line, `${where}'s script-surface table no longer has a \`candidates.mjs\` row — update this test`);
|
|
2133
|
-
return line;
|
|
2134
|
-
}
|
|
2135
|
-
|
|
2136
|
-
// The declared flag as a whole token: `--<flag>` with nothing word-like after
|
|
2137
|
-
// it, so `--<flag>s` or `--<flag>-x` is not it.
|
|
2138
|
-
const labelFlagToken = () => new RegExp(`--${declaredLabelFlag()}(?![\\w-])`);
|
|
2139
|
-
|
|
2140
|
-
// Two tokens, both pinned: the In cell's synopsis and the Non-zero cell's
|
|
2141
|
-
// exit-2 cause. Either one alone renamed is a refused spelling in the row a
|
|
2142
|
-
// reader copies, and a positive on one cannot see the other. Each positive
|
|
2143
|
-
// reads the TOKEN inside its own cell, never the cell's wording around it
|
|
2144
|
-
// (#1196: "pin the token, not … the synopsis row's shape"), so a new
|
|
2145
|
-
// placeholder or a reworded exit-2 cause stays green.
|
|
2146
|
-
function assertRowNamesDeclaredFlag(text, where) {
|
|
2147
|
-
const flag = declaredLabelFlag();
|
|
2148
|
-
const token = labelFlagToken();
|
|
2149
|
-
const row = candidatesRow(text, where);
|
|
2150
|
-
const [, , inCell, , nonZeroCell] = row.split("|");
|
|
2151
|
-
assert.match(
|
|
2152
|
-
inCell,
|
|
2153
|
-
token,
|
|
2154
|
-
`${where}'s candidates row no longer names --${flag} in its In cell, the label flag candidates.mjs' OPTIONS declares`,
|
|
2155
|
-
);
|
|
2156
|
-
assert.match(
|
|
2157
|
-
nonZeroCell ?? "",
|
|
2158
|
-
token,
|
|
2159
|
-
`${where}'s candidates row no longer names --${flag} in its Non-zero cell, where \`--allow-fallback\` needs it`,
|
|
2160
|
-
);
|
|
2161
|
-
// The row carries no `gh` invocation, so nothing in it spells `--label`
|
|
2162
|
-
// correctly and a row-wide negative is safe.
|
|
2163
|
-
assert.doesNotMatch(row, /--label\b/, `${where}'s candidates row names \`--label\`, which candidates.mjs refuses at exit 2`);
|
|
2164
|
-
}
|
|
2165
|
-
|
|
2166
|
-
test("the fleet-plugin design spec's candidates row names the flag this script declares", () => {
|
|
2167
|
-
assertRowNamesDeclaredFlag(SPEC_PLUGIN_DESIGN, "the fleet-plugin design spec");
|
|
2168
|
-
});
|
|
2169
|
-
|
|
2170
|
-
// The spec's text with its `candidates.mjs` row's cells rewritten by `edit`.
|
|
2171
|
-
// Mutants and controls are built from the cells rather than from quoted row
|
|
2172
|
-
// wording, so a row edit that keeps the token cannot strand them.
|
|
2173
|
-
function withRowCells(text, edit) {
|
|
2174
|
-
const row = candidatesRow(text, "the fleet-plugin design spec");
|
|
2175
|
-
const cells = row.split("|");
|
|
2176
|
-
edit(cells);
|
|
2177
|
-
return text.replace(row, cells.join("|"));
|
|
2178
|
-
}
|
|
2179
|
-
|
|
2180
|
-
test("the candidates-row pin reds on either token renamed alone and stays green on the real row", () => {
|
|
2181
|
-
const flag = declaredLabelFlag();
|
|
2182
|
-
for (const [cell, which] of [
|
|
2183
|
-
[2, "the In cell"],
|
|
2184
|
-
[4, "the Non-zero cell"],
|
|
2185
|
-
]) {
|
|
2186
|
-
const mutant = withRowCells(SPEC_PLUGIN_DESIGN, (cells) => {
|
|
2187
|
-
cells[cell] = cells[cell].replace(labelFlagToken(), "--label");
|
|
2188
|
-
});
|
|
2189
|
-
assert.notEqual(mutant, SPEC_PLUGIN_DESIGN, `${which} no longer carries --${flag} — this mutant now tests nothing`);
|
|
2190
|
-
assert.throws(
|
|
2191
|
-
() => assertRowNamesDeclaredFlag(mutant, "the mutant"),
|
|
2192
|
-
/the mutant's candidates row/,
|
|
2193
|
-
`the pin does not red when only ${which} is given the spelling this script refuses`,
|
|
2194
|
-
);
|
|
2195
|
-
}
|
|
2196
|
-
// GREEN on a row that keeps the flag's spelling but not its wording — a new
|
|
2197
|
-
// placeholder, a reworded exit-2 cause — the inputs a shape pin wrongly
|
|
2198
|
-
// refuses.
|
|
2199
|
-
for (const [cell, text, which] of [
|
|
2200
|
-
[2, ` \`[--${flag} LABEL] [--limit N]\` `, "the In cell's placeholder"],
|
|
2201
|
-
[4, ` exit 2 when \`--allow-fallback\` is given unless \`--${flag}\` is `, "the Non-zero cell's wording"],
|
|
2202
|
-
]) {
|
|
2203
|
-
assertRowNamesDeclaredFlag(
|
|
2204
|
-
withRowCells(SPEC_PLUGIN_DESIGN, (cells) => {
|
|
2205
|
-
cells[cell] = text;
|
|
2206
|
-
}),
|
|
2207
|
-
`the spec with ${which} reworded`,
|
|
2208
|
-
);
|
|
2209
|
-
}
|
|
2210
|
-
assertRowNamesDeclaredFlag(SPEC_PLUGIN_DESIGN, "the real spec");
|
|
2211
|
-
});
|
|
2212
|
-
|
|
2213
|
-
// The two component docs, each sliced to its candidate-scan list item. Matched
|
|
2214
|
-
// through `phrase()` so a rewrap of the item stays green; the negative names
|
|
2215
|
-
// `candidates.mjs` so it reads the invocation, not any `--label` near it.
|
|
2216
|
-
const COMPONENT_SCANS = [
|
|
2217
|
-
["next-ticket.md", "1. **List candidates**", "\n2. **Filter.**"],
|
|
2218
|
-
["supply-and-shortlist.md", "1. **Scan.**", "\n2. **Filter**"],
|
|
2219
|
-
].map(([file, from, to]) => ({
|
|
2220
|
-
where: `docs/components/${file}`,
|
|
2221
|
-
text: readFileSync(fileURLToPath(new URL(`../../docs/components/${file}`, import.meta.url)), "utf8"),
|
|
2222
|
-
from,
|
|
2223
|
-
to,
|
|
2224
|
-
}));
|
|
2225
|
-
|
|
2226
|
-
function assertComponentScanNamesDeclaredFlag({ text, from, to }, where) {
|
|
2227
|
-
const flag = declaredLabelFlag();
|
|
2228
|
-
const item = between(text, from, to, where);
|
|
2229
|
-
assert.match(
|
|
2230
|
-
item,
|
|
2231
|
-
phrase(`candidates.mjs --${flag} ready-for-agent`),
|
|
2232
|
-
`${where}'s candidate-scan item no longer runs the label flag candidates.mjs' OPTIONS declares`,
|
|
2233
|
-
);
|
|
2234
|
-
assert.doesNotMatch(
|
|
2235
|
-
item,
|
|
2236
|
-
/candidates\.mjs\s+--label\b/,
|
|
2237
|
-
`${where}'s candidate-scan item names \`candidates.mjs --label\`, which candidates.mjs refuses at exit 2`,
|
|
2238
|
-
);
|
|
2239
|
-
}
|
|
2240
|
-
|
|
2241
|
-
for (const doc of COMPONENT_SCANS) {
|
|
2242
|
-
test(`${doc.where}'s candidate scan names the flag this script declares`, () => {
|
|
2243
|
-
assertComponentScanNamesDeclaredFlag(doc, doc.where);
|
|
2244
|
-
});
|
|
2245
|
-
|
|
2246
|
-
test(`the ${doc.where} pin reds on the refused spelling and stays green on the real text`, () => {
|
|
2247
|
-
assert.throws(
|
|
2248
|
-
() =>
|
|
2249
|
-
assertComponentScanNamesDeclaredFlag(
|
|
2250
|
-
{ ...doc, text: doc.text.replaceAll(`--${declaredLabelFlag()}`, "--label") },
|
|
2251
|
-
"the mutant",
|
|
2252
|
-
),
|
|
2253
|
-
/the mutant's candidate-scan item/,
|
|
2254
|
-
"the pin does not red when the candidate-scan item is given the spelling this script refuses",
|
|
2255
|
-
);
|
|
2256
|
-
assertComponentScanNamesDeclaredFlag(doc, doc.where);
|
|
2257
|
-
});
|
|
2258
|
-
}
|
|
2259
|
-
|
|
2260
|
-
// review-and-fix step 5 names the flag BARE — `candidates.mjs --<flag>`, no
|
|
2261
|
-
// value — and is pinned all the same: live, shipped, read as current. The
|
|
2262
|
-
// negative names `candidates.mjs` rather than `/--label\b/`, because this same
|
|
2263
|
-
// step correctly runs `gh issue create --label`, `gh`'s own flag.
|
|
2264
|
-
const REVIEW_AND_FIX = readFileSync(join(import.meta.dirname, "..", "commands", "review-and-fix.md"), "utf8");
|
|
2265
|
-
|
|
2266
|
-
function assertDeferralStepNamesDeclaredFlag(text, where) {
|
|
2267
|
-
const flag = declaredLabelFlag();
|
|
2268
|
-
const step5 = between(text, "5. File each deferred finding", "\n6. Diff-check green", `${where} step 5`);
|
|
2269
|
-
assert.match(
|
|
2270
|
-
step5,
|
|
2271
|
-
new RegExp(`${phrase(`candidates.mjs --${flag}`).source}(?![\\w-])`),
|
|
2272
|
-
`${where}'s step 5 no longer names the label flag candidates.mjs' OPTIONS declares`,
|
|
2273
|
-
);
|
|
2274
|
-
assert.doesNotMatch(
|
|
2275
|
-
step5,
|
|
2276
|
-
/candidates\.mjs\s+--label\b/,
|
|
2277
|
-
`${where}'s step 5 names \`candidates.mjs --label\`, which candidates.mjs refuses at exit 2`,
|
|
2278
|
-
);
|
|
2279
|
-
}
|
|
2280
|
-
|
|
2281
|
-
test("review-and-fix's deferral step names the flag this script declares", () => {
|
|
2282
|
-
assertDeferralStepNamesDeclaredFlag(REVIEW_AND_FIX, "review-and-fix.md");
|
|
2283
|
-
});
|
|
2284
|
-
|
|
2285
|
-
test("the review-and-fix pin reds on the refused spelling and stays green beside gh's own --label", () => {
|
|
2286
|
-
assert.throws(
|
|
2287
|
-
() =>
|
|
2288
|
-
assertDeferralStepNamesDeclaredFlag(REVIEW_AND_FIX.replaceAll(`--${declaredLabelFlag()}`, "--label"), "the mutant"),
|
|
2289
|
-
/the mutant's step 5/,
|
|
2290
|
-
"the pin does not red when step 5 is given the spelling this script refuses",
|
|
2291
|
-
);
|
|
2292
|
-
// GREEN on the real step, which carries a legitimate `--label` — the input
|
|
2293
|
-
// a looser negative would wrongly refuse.
|
|
2294
|
-
assert.match(
|
|
2295
|
-
between(REVIEW_AND_FIX, "5. File each deferred finding", "\n6. Diff-check green", "review-and-fix.md step 5"),
|
|
2296
|
-
/gh issue create --label/,
|
|
2297
|
-
"review-and-fix step 5 no longer carries gh's own `--label` — this control now proves nothing",
|
|
2298
|
-
);
|
|
2299
|
-
assertDeferralStepNamesDeclaredFlag(REVIEW_AND_FIX, "review-and-fix.md");
|
|
2300
|
-
});
|
|
2301
|
-
|
|
2302
|
-
test("the cockpit spec's gh invocation keeps the flag gh accepts", () => {
|
|
2303
|
-
// The other half of the same class, and the one a fix for it can break:
|
|
2304
|
-
// `--label` is correct for `gh issue list`, so a sweep for the wrong spelling
|
|
2305
|
-
// that did not distinguish the caller would rewrite a working invocation into
|
|
2306
|
-
// a broken one. This is the input the check must ACCEPT.
|
|
2307
|
-
assert.match(
|
|
2308
|
-
readFileSync(SPEC_COCKPIT_DESIGN, "utf8"),
|
|
2309
|
-
/`gh issue list --label ready-for-agent`/,
|
|
2310
|
-
"the cockpit spec's `gh issue list --label ready-for-agent` changed — `--label` is gh's own flag and is correct there, so a sweep for this script's wrong spelling must leave it alone",
|
|
2311
|
-
);
|
|
2312
|
-
});
|