@feigi/fleet-ctl 3.23.35 → 3.23.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/main-checkout.mjs +1 -1
- package/scripts/member-write-guard.mjs +1 -1
- package/scripts/repo-root.mjs +1 -1
- package/skills/run-team/references/reaping.md +1 -1
- package/scripts/agent-test-dir-prose.test.mjs +0 -59
- package/scripts/agent-test.test.mjs +0 -1640
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
- package/scripts/ambient-git-vars-prose.test.mjs +0 -192
- package/scripts/ancestry-check-position-prose.test.mjs +0 -175
- package/scripts/apply-ruleset.test.mjs +0 -421
- package/scripts/arg-header-probes-prose.test.mjs +0 -394
- package/scripts/arg.test.mjs +0 -1354
- package/scripts/board-cli.test.mjs +0 -710
- package/scripts/board-identity.test.mjs +0 -429
- package/scripts/board-liveness-banner.test.mjs +0 -119
- package/scripts/board-prev-shape.test.mjs +0 -228
- package/scripts/board-tryparse-null.test.mjs +0 -119
- package/scripts/board.test.mjs +0 -3121
- package/scripts/brief-after-cut-prose.test.mjs +0 -53
- package/scripts/candidates-exit3-prose.test.mjs +0 -302
- package/scripts/candidates.test.mjs +0 -2312
- package/scripts/caveat-unification-prose.test.mjs +0 -98
- package/scripts/cell-readout.test.mjs +0 -615
- package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
- package/scripts/ci-completes-premise-prose.test.mjs +0 -257
- package/scripts/ci-state-prose.test.mjs +0 -113
- package/scripts/ci-state.test.mjs +0 -1933
- package/scripts/ci-vacuous-green.test.mjs +0 -368
- package/scripts/citation-sweep-prose.test.mjs +0 -1712
- package/scripts/claim-lifecycle.test.mjs +0 -187
- package/scripts/claim-ticket.test.mjs +0 -1122
- package/scripts/closing-keyword-prose.test.mjs +0 -193
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
- package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
- package/scripts/compute-board.test.mjs +0 -1214
- package/scripts/compute-spend.test.mjs +0 -517
- package/scripts/consumer-technology-prose.test.mjs +0 -126
- package/scripts/cross-repo-citation-prose.test.mjs +0 -155
- package/scripts/cwd-isolation-pins.mjs +0 -83
- package/scripts/dedupe-guard-prose.test.mjs +0 -243
- package/scripts/delete-merged-branch.test.mjs +0 -576
- package/scripts/derive-testcmd.test.mjs +0 -595
- package/scripts/diff-stats.test.mjs +0 -404
- package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
- package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
- package/scripts/dispositions-check.test.mjs +0 -936
- package/scripts/dispositions-gate-prose.test.mjs +0 -129
- package/scripts/drop-merged-label.test.mjs +0 -479
- package/scripts/exec-stub.mjs +0 -93
- package/scripts/exec-stub.test.mjs +0 -69
- package/scripts/expected-jobs-prose.test.mjs +0 -80
- package/scripts/fan-out-authorization-prose.test.mjs +0 -80
- package/scripts/filing-bar-seat-prose.test.mjs +0 -242
- package/scripts/filing-claim-bar-prose.test.mjs +0 -166
- package/scripts/finisher-died-prose.test.mjs +0 -31
- package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
- package/scripts/finisher-halt-prose.test.mjs +0 -106
- package/scripts/finisher-name-prose.test.mjs +0 -134
- package/scripts/finisher-own-tree-prose.test.mjs +0 -299
- package/scripts/finisher-pin-race-prose.test.mjs +0 -339
- package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
- package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
- package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
- package/scripts/fleet-bootstrap.test.mjs +0 -75
- package/scripts/fleet-heartbeat.test.mjs +0 -450
- package/scripts/fleet-provenance.test.mjs +0 -138
- package/scripts/fleet-run.test.mjs +0 -90
- package/scripts/fleet-state.test.mjs +0 -460
- package/scripts/fleet-tick-prose.test.mjs +0 -300
- package/scripts/fleet-tick.test.mjs +0 -2444
- package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
- package/scripts/frontmatter-check.test.mjs +0 -436
- package/scripts/git-env.test.mjs +0 -149
- package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
- package/scripts/gone-walk.test.mjs +0 -213
- package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
- package/scripts/head-moved-after-label-prose.test.mjs +0 -233
- package/scripts/immutable-body-claim-prose.test.mjs +0 -204
- package/scripts/implementer-model-tier.test.mjs +0 -235
- package/scripts/inflight-citation-prose.test.mjs +0 -144
- package/scripts/inflight-exit2-prose.test.mjs +0 -81
- package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
- package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
- package/scripts/inflight.test.mjs +0 -2882
- package/scripts/injection-control-prose.test.mjs +0 -404
- package/scripts/install-root-audit.test.mjs +0 -464
- package/scripts/instrument-check-prose.test.mjs +0 -235
- package/scripts/instruments.test.mjs +0 -787
- package/scripts/is-cli.test.mjs +0 -99
- package/scripts/issue-tracker-prose.test.mjs +0 -71
- package/scripts/json.test.mjs +0 -364
- package/scripts/ledger-dispatch.test.mjs +0 -927
- package/scripts/ledger-grammar.test.mjs +0 -227
- package/scripts/ledger-read-require-file.test.mjs +0 -197
- package/scripts/ledger-rotate.test.mjs +0 -142
- package/scripts/ledger.test.mjs +0 -3436
- package/scripts/line-distance-prose.test.mjs +0 -245
- package/scripts/liveness-rationale-prose.test.mjs +0 -83
- package/scripts/locale-pin-prose.test.mjs +0 -189
- package/scripts/main-checkout.test.mjs +0 -332
- package/scripts/member-outcome-prose.test.mjs +0 -167
- package/scripts/member-outcomes-header.test.mjs +0 -129
- package/scripts/member-outcomes-prose.test.mjs +0 -63
- package/scripts/member-outcomes.test.mjs +0 -638
- package/scripts/member-prompt-prose.test.mjs +0 -165
- package/scripts/member-record.test.mjs +0 -541
- package/scripts/member-write-guard.test.mjs +0 -214
- package/scripts/merge-commit-probe-prose.test.mjs +0 -122
- package/scripts/merge-gate.test.mjs +0 -613
- package/scripts/muted-git-guard-sweep.test.mjs +0 -493
- package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
- package/scripts/net-watchdog-prose.test.mjs +0 -79
- package/scripts/net.test.mjs +0 -211
- package/scripts/no-ci-gate-prose.test.mjs +0 -108
- package/scripts/no-undo-audit.test.mjs +0 -3961
- package/scripts/no-wave.test.mjs +0 -138
- package/scripts/node-floor-sweep.test.mjs +0 -611
- package/scripts/pointer-target-prose.test.mjs +0 -186
- package/scripts/pr-cost.test.mjs +0 -521
- package/scripts/pr-overlap.test.mjs +0 -692
- package/scripts/printf-die-sweep.test.mjs +0 -384
- package/scripts/prompt-renderer.mjs +0 -40
- package/scripts/prompt-renderer.test.mjs +0 -68
- package/scripts/prose-pin.mjs +0 -807
- package/scripts/prose-pin.test.mjs +0 -1034
- package/scripts/prove-merge.test.mjs +0 -995
- package/scripts/pull-table-relabel-prose.test.mjs +0 -60
- package/scripts/quiet-payload-prose.test.mjs +0 -222
- package/scripts/reap-cherry-check-prose.test.mjs +0 -80
- package/scripts/reap.test.mjs +0 -4432
- package/scripts/reaping-prose.test.mjs +0 -239
- package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
- package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
- package/scripts/recipe-derivation-prose.test.mjs +0 -112
- package/scripts/recipe-prove.test.mjs +0 -1042
- package/scripts/refuter-scratch-prose.test.mjs +0 -135
- package/scripts/release-label-required-prose.test.mjs +0 -71
- package/scripts/release-label-split-prose.test.mjs +0 -184
- package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
- package/scripts/release-ticket.test.mjs +0 -5099
- package/scripts/renovate-release-contract.test.mjs +0 -379
- package/scripts/repo-root.test.mjs +0 -873
- package/scripts/reporter-output-rule-prose.test.mjs +0 -208
- package/scripts/review-agent-report-only.test.mjs +0 -49
- package/scripts/review-core-booking.test.mjs +0 -35
- package/scripts/review-core-cwd-isolation.test.mjs +0 -374
- package/scripts/review-core-reads.test.mjs +0 -478
- package/scripts/review-core-refuter-scratch.test.mjs +0 -148
- package/scripts/review-core-scratch-refusal.test.mjs +0 -64
- package/scripts/review-core-shared-test-run.test.mjs +0 -275
- package/scripts/review-core-snapshot-path.test.mjs +0 -830
- package/scripts/review-core-specialist-scratch.test.mjs +0 -191
- package/scripts/review-core-testcmd.test.mjs +0 -335
- package/scripts/review-core-unrun.test.mjs +0 -566
- package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
- package/scripts/review-eval-resolver-path.test.mjs +0 -55
- package/scripts/review-host-fixture.mjs +0 -89
- package/scripts/review-in-run-retry.test.mjs +0 -211
- package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
- package/scripts/review-path-default.test.mjs +0 -796
- package/scripts/review-runner-spawns.test.mjs +0 -95
- package/scripts/review-runner.test.mjs +0 -166
- package/scripts/review-tier-audit.test.mjs +0 -140
- package/scripts/run-artifact-pr-prose.test.mjs +0 -341
- package/scripts/run-merge-bot-prose.test.mjs +0 -1413
- package/scripts/run-team-local-hook.test.mjs +0 -442
- package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
- package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
- package/scripts/section-between-guard-prose.test.mjs +0 -379
- package/scripts/select-dimensions.test.mjs +0 -674
- package/scripts/shared-refusal.test.mjs +0 -388
- package/scripts/shell-traps-prose.test.mjs +0 -504
- package/scripts/shortlist.test.mjs +0 -380
- package/scripts/slow-transport.mjs +0 -72
- package/scripts/snapshot-repo.test.mjs +0 -1006
- package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
- package/scripts/spend-view.test.mjs +0 -312
- package/scripts/staleness-qualifier-prose.test.mjs +0 -251
- package/scripts/staleness-verdict-prose.test.mjs +0 -142
- package/scripts/staleness.test.mjs +0 -893
- package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
- package/scripts/stash-prohibition-prose.test.mjs +0 -313
- package/scripts/strip-comments.mjs +0 -44
- package/scripts/temp-dir.mjs +0 -47
- package/scripts/ticket-router.test.mjs +0 -981
- package/scripts/tier-check.test.mjs +0 -828
- package/scripts/tier-outcomes-header.test.mjs +0 -518
- package/scripts/tier-outcomes.test.mjs +0 -572
- package/scripts/tier-roles.test.mjs +0 -535
- package/scripts/tracker-block-copy-prose.test.mjs +0 -288
- package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
- package/scripts/unattended-git-sweep.test.mjs +0 -142
- package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
- package/scripts/verify-sha.test.mjs +0 -692
- package/scripts/watcher-degraded-block.test.mjs +0 -369
- package/scripts/watcher-key-prose.test.mjs +0 -106
- package/scripts/within-run-pair-prose.test.mjs +0 -212
- package/scripts/worktree-audit.test.mjs +0 -1408
- package/scripts/worktree-head-prose.test.mjs +0 -276
- package/scripts/worktree-listing-sweep.test.mjs +0 -217
- package/scripts/worktree-model-prose.test.mjs +0 -216
- package/scripts/worktree-porcelain.mjs +0 -35
- package/scripts/worktree-porcelain.test.mjs +0 -102
|
@@ -1,692 +0,0 @@
|
|
|
1
|
-
// Regression gate for #169: a flag given with no value must die, by name,
|
|
2
|
-
// rather than being read as absent or silently consumed as the following
|
|
3
|
-
// flag's own value.
|
|
4
|
-
//
|
|
5
|
-
// `--a`/`--b` given trailing were already caught by pr-overlap.mjs's own
|
|
6
|
-
// `if (!a || !b) die(...)` guard — `undefined` is falsy — so it was never a
|
|
7
|
-
// silent-widening site the way ci-state.mjs's `--base`/`--workflow` were (see
|
|
8
|
-
// feigi's PR #167 review comment). What was NOT caught: `--a` given `--b` as
|
|
9
|
-
// its "value" (`pr-overlap.mjs --a --b 5`) — `a` becomes the string "--b",
|
|
10
|
-
// passes the falsy check, and only failed later as a confusing `gh pr diff
|
|
11
|
-
// --b` error instead of a clear refusal naming the flag.
|
|
12
|
-
import { test } from "node:test";
|
|
13
|
-
import assert from "node:assert/strict";
|
|
14
|
-
import { spawnSync, execFileSync } from "node:child_process";
|
|
15
|
-
import { mkdtempSync, mkdirSync, readFileSync, writeFileSync, rmSync } from "node:fs";
|
|
16
|
-
import { tmpdir } from "node:os";
|
|
17
|
-
import { join, dirname } from "node:path";
|
|
18
|
-
import { fileURLToPath } from "node:url";
|
|
19
|
-
import { writeExecStub } from "./exec-stub.mjs";
|
|
20
|
-
|
|
21
|
-
const SCRIPT = fileURLToPath(new URL("./pr-overlap.mjs", import.meta.url));
|
|
22
|
-
|
|
23
|
-
test("CLI: trailing --a (no value) dies (exit 2) naming the flag", () => {
|
|
24
|
-
const r = spawnSync(process.execPath, [SCRIPT, "--a"], { encoding: "utf8" });
|
|
25
|
-
assert.equal(r.status, 2);
|
|
26
|
-
assert.match(r.stderr, /--a needs a value/);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test("CLI: --a followed by --b is rejected by name, not run through gh as a PR ref", () => {
|
|
30
|
-
const r = spawnSync(process.execPath, [SCRIPT, "--a", "--b", "5"], { encoding: "utf8" });
|
|
31
|
-
assert.equal(r.status, 2);
|
|
32
|
-
assert.match(r.stderr, /--a needs a value/);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("CLI: --a=5 form dies by name, not silently read as absent", () => {
|
|
36
|
-
const r = spawnSync(process.execPath, [SCRIPT, "--a=5", "--b", "6"], { encoding: "utf8" });
|
|
37
|
-
assert.equal(r.status, 2);
|
|
38
|
-
assert.match(r.stderr, /--a needs a space-separated value/);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// `value.trim() === ""` was the one clause of the guard no test reached in any
|
|
42
|
-
// of the five scripts that then carried their own copy of it — board,
|
|
43
|
-
// candidates, ci-state, diff-stats, pr-overlap — so it could be deleted from
|
|
44
|
-
// all five at once, green. #367 has since folded those copies into arg.mjs's
|
|
45
|
-
// single one, which every one of the five still routes through.
|
|
46
|
-
test("CLI: --a given a whitespace-only value dies naming the flag", () => {
|
|
47
|
-
const r = spawnSync(process.execPath, [SCRIPT, "--a", " ", "--b", "6"], { encoding: "utf8" });
|
|
48
|
-
assert.equal(r.status, 2);
|
|
49
|
-
assert.match(r.stderr, /--a needs a value/);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// The other half of arg()'s guard: every case above is a value it must
|
|
53
|
-
// REFUSE. Nothing above ever hands the script a well-formed pair, so #367's
|
|
54
|
-
// shared arg() could return `undefined` for every accepted input and this
|
|
55
|
-
// file would stay green. `--a 1 --b 2` must reach gh and report a verdict.
|
|
56
|
-
test("CLI: well-formed --a/--b values are accepted and the CLI reports a verdict", () => {
|
|
57
|
-
const bin = mkdtempSync(join(tmpdir(), "pr-overlap-bin-"));
|
|
58
|
-
const gh = join(bin, "gh");
|
|
59
|
-
const log = join(bin, "calls");
|
|
60
|
-
// `$3` is the PR number pr-overlap.mjs passes as `gh pr diff <pr> --name-only`.
|
|
61
|
-
writeExecStub(
|
|
62
|
-
gh,
|
|
63
|
-
`#!/bin/sh\nprintf '%s\\n' "$*" >> ${log}\ncase "$3" in\n 1) echo src/shared.ts ;;\n 2) echo src/shared.ts ;;\nesac\n`,
|
|
64
|
-
);
|
|
65
|
-
const r = spawnSync(process.execPath, [SCRIPT, "--a", "1", "--b", "2"], {
|
|
66
|
-
encoding: "utf8",
|
|
67
|
-
env: { ...process.env, PATH: `${bin}:${process.env.PATH}` },
|
|
68
|
-
});
|
|
69
|
-
const calls = readFileSync(log, "utf8").trim().split("\n");
|
|
70
|
-
rmSync(bin, { recursive: true, force: true });
|
|
71
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
72
|
-
const payload = JSON.parse(r.stdout);
|
|
73
|
-
assert.deepEqual(payload, {
|
|
74
|
-
a: 1,
|
|
75
|
-
b: 2,
|
|
76
|
-
files: ["src/shared.ts"],
|
|
77
|
-
modules: ["shared"],
|
|
78
|
-
dirs: ["src"],
|
|
79
|
-
prose: [],
|
|
80
|
-
proseUnrun: null,
|
|
81
|
-
signal: "files",
|
|
82
|
-
});
|
|
83
|
-
// #705's signal costs nothing on a pair with no data file on either side,
|
|
84
|
-
// which is nearly every pair. An unconditional full-diff read would double
|
|
85
|
-
// this tool's `gh` traffic and hand its ENOBUFS cliff to every caller, so
|
|
86
|
-
// the two `--name-only` calls are the whole bill here.
|
|
87
|
-
assert.deepEqual(calls, ["pr diff 1 --name-only", "pr diff 2 --name-only"]);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
// ---------------------------------------------------------------------------
|
|
91
|
-
// #705: the prose-citation signal.
|
|
92
|
-
//
|
|
93
|
-
// A fixture is one throwaway directory holding a fake `gh` on PATH, a
|
|
94
|
-
// `<pr>.names` and `<pr>.diff` per PR, and a real git repo the script runs
|
|
95
|
-
// inside — the last one because the basename-ambiguity guard counts with
|
|
96
|
-
// `git ls-files`, so a test that cannot control the tree cannot reach the
|
|
97
|
-
// branch where a basename is dropped. An ABSENT `<pr>.diff` makes the fake
|
|
98
|
-
// `gh` exit non-zero, which is how the degradation case below is driven.
|
|
99
|
-
function fixture({ prs, tracked = [] }) {
|
|
100
|
-
const root = mkdtempSync(join(tmpdir(), "pr-overlap-prose-"));
|
|
101
|
-
const bin = join(root, "bin");
|
|
102
|
-
const data = join(root, "data");
|
|
103
|
-
const repo = join(root, "repo");
|
|
104
|
-
for (const d of [bin, data, repo]) mkdirSync(d);
|
|
105
|
-
for (const [pr, { names, diff }] of Object.entries(prs)) {
|
|
106
|
-
writeFileSync(join(data, `${pr}.names`), `${names.join("\n")}\n`);
|
|
107
|
-
if (diff !== undefined) writeFileSync(join(data, `${pr}.diff`), diff);
|
|
108
|
-
}
|
|
109
|
-
const gh = join(bin, "gh");
|
|
110
|
-
writeExecStub(
|
|
111
|
-
gh,
|
|
112
|
-
"#!/bin/sh\n" +
|
|
113
|
-
`case "$4" in\n` +
|
|
114
|
-
` --name-only) cat ${data}/"$3".names ;;\n` +
|
|
115
|
-
` *) cat ${data}/"$3".diff ;;\n` +
|
|
116
|
-
"esac\n",
|
|
117
|
-
);
|
|
118
|
-
execFileSync("git", ["init", "-q"], { cwd: repo });
|
|
119
|
-
for (const f of tracked) {
|
|
120
|
-
mkdirSync(join(repo, dirname(f)), { recursive: true });
|
|
121
|
-
writeFileSync(join(repo, f), "x\n");
|
|
122
|
-
}
|
|
123
|
-
if (tracked.length) execFileSync("git", ["add", "--", ...tracked], { cwd: repo });
|
|
124
|
-
return { root, bin, repo };
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function run({ prs, tracked }, a, b) {
|
|
128
|
-
const fx = fixture({ prs, tracked });
|
|
129
|
-
const r = spawnSync(process.execPath, [SCRIPT, "--a", String(a), "--b", String(b)], {
|
|
130
|
-
encoding: "utf8",
|
|
131
|
-
cwd: fx.repo,
|
|
132
|
-
env: { ...process.env, PATH: `${fx.bin}:${process.env.PATH}` },
|
|
133
|
-
});
|
|
134
|
-
rmSync(fx.root, { recursive: true, force: true });
|
|
135
|
-
return r;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// A unified diff body for one file. Only hunk lines matter to the scan; the
|
|
139
|
-
// `+++`/`---` headers are present because they are what the parser has to
|
|
140
|
-
// skip — they carry the path itself, so a parser that reads them finds every
|
|
141
|
-
// data file "cited" by the PR that changed it.
|
|
142
|
-
const hunk = (file, lines) =>
|
|
143
|
-
`diff --git a/${file} b/${file}\nindex 1111111..2222222 100644\n--- a/${file}\n+++ b/${file}\n@@ -1,3 +1,3 @@\n${lines.map((l) => l + "\n").join("")}`;
|
|
144
|
-
|
|
145
|
-
const TSV = "docs/metrics/tier-outcomes.tsv";
|
|
146
|
-
|
|
147
|
-
// The defect itself. #704 appended rows to the TSV, #703 held the prose that
|
|
148
|
-
// reads it, and the two share no path, no module and no directory — so the
|
|
149
|
-
// three original signals answered `none`, which is the strongest clear this
|
|
150
|
-
// tool has and the one that licenses a merge.
|
|
151
|
-
test("prose: a data file named in the other PR's diff fires signal=prose", () => {
|
|
152
|
-
const r = run(
|
|
153
|
-
{
|
|
154
|
-
prs: {
|
|
155
|
-
1: { names: [TSV], diff: hunk(TSV, ["+1490\timpl-1490\tclass=routine"]) },
|
|
156
|
-
2: {
|
|
157
|
-
names: ["plugin/skills/run-team/SKILL.md"],
|
|
158
|
-
diff: hunk("plugin/skills/run-team/SKILL.md", [
|
|
159
|
-
" **Recount before citing any of this.**",
|
|
160
|
-
`+grep -vc '^#' ${TSV}`,
|
|
161
|
-
]),
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
1,
|
|
166
|
-
2,
|
|
167
|
-
);
|
|
168
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
169
|
-
const payload = JSON.parse(r.stdout);
|
|
170
|
-
assert.equal(payload.signal, "prose");
|
|
171
|
-
assert.deepEqual(payload.files, []);
|
|
172
|
-
assert.deepEqual(payload.dirs, []);
|
|
173
|
-
assert.equal(payload.proseUnrun, null);
|
|
174
|
-
assert.deepEqual(payload.prose, [
|
|
175
|
-
{ data: TSV, citedBy: "plugin/skills/run-team/SKILL.md", token: TSV, line: `+grep -vc '^#' ${TSV}` },
|
|
176
|
-
]);
|
|
177
|
-
// The witness is the whole value of a weak signal: one read disproves it.
|
|
178
|
-
assert.match(r.stderr, /cited by plugin\/skills\/run-team\/SKILL\.md/);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
// Every citing file gets its own witness, and each one gets its OWN most
|
|
182
|
-
// specific token. A loop that stopped at the first token matching ANYWHERE
|
|
183
|
-
// reports one file and drops the rest — and the set of citing files is
|
|
184
|
-
// exactly what the caller has to go read to disprove the hold.
|
|
185
|
-
test("prose: each citing file reports its own witness, path token preferred", () => {
|
|
186
|
-
const r = run(
|
|
187
|
-
{
|
|
188
|
-
prs: {
|
|
189
|
-
1: { names: [TSV], diff: hunk(TSV, ["+1490\timpl-1490"]) },
|
|
190
|
-
2: {
|
|
191
|
-
names: ["plugin/skills/run-team/SKILL.md", "plugin/commands/run-merge-bot.md"],
|
|
192
|
-
diff:
|
|
193
|
-
hunk("plugin/skills/run-team/SKILL.md", [`+recount off ${TSV} and also tier-outcomes.tsv`]) +
|
|
194
|
-
hunk("plugin/commands/run-merge-bot.md", ["+the append lands in tier-outcomes.tsv"]),
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
1,
|
|
199
|
-
2,
|
|
200
|
-
);
|
|
201
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
202
|
-
const payload = JSON.parse(r.stdout);
|
|
203
|
-
assert.deepEqual(
|
|
204
|
-
payload.prose.map((h) => [h.citedBy, h.token]),
|
|
205
|
-
[
|
|
206
|
-
// Names it both ways -> reported once, by path.
|
|
207
|
-
["plugin/commands/run-merge-bot.md", "tier-outcomes.tsv"],
|
|
208
|
-
["plugin/skills/run-team/SKILL.md", TSV],
|
|
209
|
-
],
|
|
210
|
-
);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
// The citer side is an explicit extension list, and the stderr note prints it
|
|
214
|
-
// as the scan's scope — so it is an advertised bound and has to hold. Here a
|
|
215
|
-
// DATA file's own hunks name another data file: `member-outcomes.tsv`'s header
|
|
216
|
-
// really does cite `tier-outcomes.tsv` in this repo, and a run-artifact PR
|
|
217
|
-
// really does edit both. Widen the citer side to every changed file and this
|
|
218
|
-
// fires on every such pair.
|
|
219
|
-
//
|
|
220
|
-
// Nothing is lost by refusing it, which is what makes the bound defensible
|
|
221
|
-
// rather than merely narrow: both files live under `docs/metrics/`, so `dirs`
|
|
222
|
-
// already reports that pair — at exactly the weak strength it deserves. The
|
|
223
|
-
// assertion below is that the case is covered THERE, not that it is ignored.
|
|
224
|
-
test("prose: a data file's own hunks are not a citation site, and dirs still covers the pair", () => {
|
|
225
|
-
const OTHER = "docs/metrics/member-outcomes.tsv";
|
|
226
|
-
const cite = `+# verdicts live in ${TSV}, joined on pr`;
|
|
227
|
-
const r = run(
|
|
228
|
-
{
|
|
229
|
-
prs: {
|
|
230
|
-
1: { names: [TSV], diff: hunk(TSV, ["+1490\timpl-1490"]) },
|
|
231
|
-
2: { names: [OTHER], diff: hunk(OTHER, [cite]) },
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
1,
|
|
235
|
-
2,
|
|
236
|
-
);
|
|
237
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
238
|
-
const payload = JSON.parse(r.stdout);
|
|
239
|
-
assert.deepEqual(payload.prose, []);
|
|
240
|
-
assert.deepEqual(payload.dirs, ["docs/metrics"]);
|
|
241
|
-
assert.equal(payload.signal, "dirs");
|
|
242
|
-
|
|
243
|
-
// Positive control on the identical citation: move it into a `.md` and the
|
|
244
|
-
// signal fires. Without this, a partition that dropped the data file from
|
|
245
|
-
// the TARGET side too would pass above for the wrong reason.
|
|
246
|
-
const inProse = {
|
|
247
|
-
prs: {
|
|
248
|
-
1: { names: [TSV], diff: hunk(TSV, ["+1490\timpl-1490"]) },
|
|
249
|
-
2: { names: ["docs/metrics/README.md"], diff: hunk("docs/metrics/README.md", [cite]) },
|
|
250
|
-
},
|
|
251
|
-
};
|
|
252
|
-
const second = JSON.parse(run(inProse, 1, 2).stdout);
|
|
253
|
-
assert.deepEqual(second.prose.map((h) => h.citedBy), ["docs/metrics/README.md"]);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
// Which PR holds the rows and which holds the prose is not knowable from the
|
|
257
|
-
// flags, so both directions are scanned. A one-directional wiring passes the
|
|
258
|
-
// test above and misses half the pairs.
|
|
259
|
-
test("prose: fires when the data file is on --b and the prose on --a", () => {
|
|
260
|
-
const r = run(
|
|
261
|
-
{
|
|
262
|
-
prs: {
|
|
263
|
-
1: {
|
|
264
|
-
names: ["plugin/commands/run-merge-bot.md"],
|
|
265
|
-
diff: hunk("plugin/commands/run-merge-bot.md", [`+read ${TSV} before ruling`]),
|
|
266
|
-
},
|
|
267
|
-
2: { names: [TSV], diff: hunk(TSV, ["+1490\timpl-1490"]) },
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
1,
|
|
271
|
-
2,
|
|
272
|
-
);
|
|
273
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
274
|
-
const payload = JSON.parse(r.stdout);
|
|
275
|
-
assert.equal(payload.signal, "prose");
|
|
276
|
-
assert.deepEqual(payload.prose.map((h) => h.citedBy), ["plugin/commands/run-merge-bot.md"]);
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
// A diff's `+++`/`--- ` lines carry the path and begin with the same
|
|
280
|
-
// characters a hunk line does, so a scan that reads them attributes a
|
|
281
|
-
// citation to the patch's own plumbing. Reachable whenever a text file's path
|
|
282
|
-
// CONTAINS a data file's — `docs/x.json.md` documenting `a/x.json` is the
|
|
283
|
-
// ordinary spelling of that — and the witness it produces is a diff header,
|
|
284
|
-
// which is the confident nonsense `moduleOf` above refuses to emit.
|
|
285
|
-
test("prose: a diff's own file headers are not read as citations", () => {
|
|
286
|
-
const r = run(
|
|
287
|
-
{
|
|
288
|
-
prs: {
|
|
289
|
-
1: { names: ["a/x.json"], diff: hunk("a/x.json", ['+{"x":1}']) },
|
|
290
|
-
2: {
|
|
291
|
-
names: ["docs/x.json.md"],
|
|
292
|
-
diff: hunk("docs/x.json.md", ["+unrelated prose that names no file"]),
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
tracked: ["a/x.json", "docs/x.json.md"],
|
|
296
|
-
},
|
|
297
|
-
1,
|
|
298
|
-
2,
|
|
299
|
-
);
|
|
300
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
301
|
-
const payload = JSON.parse(r.stdout);
|
|
302
|
-
assert.deepEqual(payload.prose, []);
|
|
303
|
-
assert.equal(payload.signal, "none");
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
// The other half, and the one that decides whether this signal is usable:
|
|
307
|
-
// #703 DID touch `run-team/SKILL.md`, the very file whose tier-guard
|
|
308
|
-
// paragraph reads the TSV, and was still correctly unrelated — its hunks
|
|
309
|
-
// never reach that paragraph. A whole-FILE read fires here, permanently,
|
|
310
|
-
// because SKILL.md names the TSV in nine places; reading the DIFF is what
|
|
311
|
-
// reproduces merge-bot-9's hand-run clearing grep. Re-measured live on
|
|
312
|
-
// #703 vs #704: `signal=none prose=0`, `proseUnrun: null`.
|
|
313
|
-
test("prose: a citing file edited AWAY from its citation does not fire", () => {
|
|
314
|
-
const r = run(
|
|
315
|
-
{
|
|
316
|
-
prs: {
|
|
317
|
-
1: { names: [TSV], diff: hunk(TSV, ["+1490\timpl-1490"]) },
|
|
318
|
-
2: {
|
|
319
|
-
names: ["plugin/skills/run-team/SKILL.md"],
|
|
320
|
-
diff: hunk("plugin/skills/run-team/SKILL.md", [
|
|
321
|
-
" Its four duties are a checklist — audit the worktree,",
|
|
322
|
-
"+report, and the merge gate downstream still catches it.",
|
|
323
|
-
]),
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
1,
|
|
328
|
-
2,
|
|
329
|
-
);
|
|
330
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
331
|
-
const payload = JSON.parse(r.stdout);
|
|
332
|
-
assert.equal(payload.signal, "none");
|
|
333
|
-
assert.deepEqual(payload.prose, []);
|
|
334
|
-
// An empty result is only a clear when the scan actually covered the diff.
|
|
335
|
-
assert.equal(payload.proseUnrun, null);
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
// A bare stem with no extension is a word, not a reference. Every one of
|
|
339
|
-
// run-team/SKILL.md's nine references to this file is written with the
|
|
340
|
-
// extension — `docs/metrics/tier-outcomes.tsv` ×7, `tier-outcomes.tsv` ×2
|
|
341
|
-
// (measured) — so matching the stem buys no coverage and is where the false
|
|
342
|
-
// positives the ticket warned about would come from.
|
|
343
|
-
test("prose: a bare stem with no extension is never matched", () => {
|
|
344
|
-
const r = run(
|
|
345
|
-
{
|
|
346
|
-
prs: {
|
|
347
|
-
1: { names: [TSV], diff: hunk(TSV, ["+1490\timpl-1490"]) },
|
|
348
|
-
2: {
|
|
349
|
-
names: ["docs/notes.md"],
|
|
350
|
-
diff: hunk("docs/notes.md", ["+the tier-outcomes corpus is confounded with calendar date"]),
|
|
351
|
-
},
|
|
352
|
-
},
|
|
353
|
-
},
|
|
354
|
-
1,
|
|
355
|
-
2,
|
|
356
|
-
);
|
|
357
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
358
|
-
assert.deepEqual(JSON.parse(r.stdout).prose, []);
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
// `moduleOf`'s measurement, one file type over: a shared basename is not a
|
|
362
|
-
// shared file. Two `config.json` in unrelated subtrees, and the citing PR
|
|
363
|
-
// names the OTHER one — the full paths differ, so the only thing that could
|
|
364
|
-
// fire is the basename, and the tree says that basename is ambiguous.
|
|
365
|
-
// Derived from `git ls-files` rather than a deny-list, so it needs no
|
|
366
|
-
// upkeep; delete the count and this reds.
|
|
367
|
-
test("prose: an ambiguous basename is dropped, and the full path still decides", () => {
|
|
368
|
-
const tracked = ["a/config.json", "b/config.json"];
|
|
369
|
-
const base = {
|
|
370
|
-
prs: {
|
|
371
|
-
1: { names: ["a/config.json"], diff: hunk("a/config.json", ['+{"x":1}']) },
|
|
372
|
-
2: { names: ["docs/notes.md"], diff: hunk("docs/notes.md", ["+see b/config.json for the other one"]) },
|
|
373
|
-
},
|
|
374
|
-
tracked,
|
|
375
|
-
};
|
|
376
|
-
assert.deepEqual(JSON.parse(run(base, 1, 2).stdout).prose, []);
|
|
377
|
-
|
|
378
|
-
// Positive control for the same tree: the ambiguity guard drops basenames,
|
|
379
|
-
// never paths, so naming the changed file BY PATH still fires. Without
|
|
380
|
-
// this, a guard that dropped the data file entirely would pass above.
|
|
381
|
-
const byPath = {
|
|
382
|
-
...base,
|
|
383
|
-
prs: {
|
|
384
|
-
...base.prs,
|
|
385
|
-
2: { names: ["docs/notes.md"], diff: hunk("docs/notes.md", ["+see a/config.json for the one that moved"]) },
|
|
386
|
-
},
|
|
387
|
-
};
|
|
388
|
-
const payload = JSON.parse(run(byPath, 1, 2).stdout);
|
|
389
|
-
assert.equal(payload.signal, "prose");
|
|
390
|
-
assert.deepEqual(payload.prose.map((h) => h.token), ["a/config.json"]);
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
// Ranked below `dirs` so it can only ever turn a `none` into something. A
|
|
394
|
-
// ladder that put it first would relabel every existing verdict, and the
|
|
395
|
-
// count on the summary line is what keeps the evidence visible underneath a
|
|
396
|
-
// stronger one.
|
|
397
|
-
test("prose: a prose hit never masks a stronger signal, and is still reported", () => {
|
|
398
|
-
const r = run(
|
|
399
|
-
{
|
|
400
|
-
prs: {
|
|
401
|
-
1: { names: [TSV, "docs/notes.md"], diff: hunk(TSV, ["+1490\timpl-1490"]) },
|
|
402
|
-
2: { names: ["docs/notes.md"], diff: hunk("docs/notes.md", [`+cites ${TSV} here`]) },
|
|
403
|
-
},
|
|
404
|
-
},
|
|
405
|
-
1,
|
|
406
|
-
2,
|
|
407
|
-
);
|
|
408
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
409
|
-
const payload = JSON.parse(r.stdout);
|
|
410
|
-
assert.equal(payload.signal, "files");
|
|
411
|
-
assert.deepEqual(payload.files, ["docs/notes.md"]);
|
|
412
|
-
assert.equal(payload.prose.length, 1);
|
|
413
|
-
assert.match(r.stderr, /prose=1/);
|
|
414
|
-
// The caveat block is keyed on the COUNT, not on `signal`: under a `files`
|
|
415
|
-
// verdict the ladder hides the stronger evidence, and the witness is what
|
|
416
|
-
// the caller disproves the pair with. Key it on `signal` and this reds.
|
|
417
|
-
assert.match(r.stderr, /prose citation/);
|
|
418
|
-
assert.match(r.stderr, new RegExp(`${TSV} cited by docs/notes\\.md`));
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
// Context lines are searched along with added and removed ones, deliberately:
|
|
422
|
-
// the hazard is prose being rewritten NEXT TO a citation, not only a citation
|
|
423
|
-
// being typed, and merge-bot-9's own clearing grep on #703 counted context
|
|
424
|
-
// too. A scan narrowed to `+`/`-` lines misses the whole rewrite-in-place
|
|
425
|
-
// case, which is the shape #705 describes — a paragraph edited underneath
|
|
426
|
-
// rows landing beneath it.
|
|
427
|
-
test("prose: a citation on a context line counts", () => {
|
|
428
|
-
const r = run(
|
|
429
|
-
{
|
|
430
|
-
prs: {
|
|
431
|
-
1: { names: [TSV], diff: hunk(TSV, ["+1490\timpl-1490"]) },
|
|
432
|
-
2: {
|
|
433
|
-
names: ["plugin/skills/run-team/SKILL.md"],
|
|
434
|
-
diff: hunk("plugin/skills/run-team/SKILL.md", [
|
|
435
|
-
` grep -vc '^#' ${TSV}`,
|
|
436
|
-
"+recount before citing any of this",
|
|
437
|
-
]),
|
|
438
|
-
},
|
|
439
|
-
},
|
|
440
|
-
},
|
|
441
|
-
1,
|
|
442
|
-
2,
|
|
443
|
-
);
|
|
444
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
445
|
-
const payload = JSON.parse(r.stdout);
|
|
446
|
-
assert.equal(payload.signal, "prose");
|
|
447
|
-
assert.deepEqual(payload.prose.map((h) => h.token), [TSV]);
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
// The degradation, and the reason it is a field rather than a `die()`. A
|
|
451
|
-
// run-artifact PR appends thousands of rows, so the full-patch read is the
|
|
452
|
-
// one call here with a real ENOBUFS cliff — and this signal is ranked last,
|
|
453
|
-
// so it must never be the reason the three above become unavailable. An
|
|
454
|
-
// empty `prose[]` with no reason beside it would be byte-identical to a
|
|
455
|
-
// clean scan, which is #705's own failure mode one level in.
|
|
456
|
-
test("prose: a full-diff read that fails names itself and leaves the other three answerable", () => {
|
|
457
|
-
const r = run(
|
|
458
|
-
{
|
|
459
|
-
prs: {
|
|
460
|
-
1: { names: [TSV], diff: hunk(TSV, ["+1490\timpl-1490"]) },
|
|
461
|
-
2: { names: ["plugin/skills/run-team/SKILL.md"] }, // no .diff: the fake gh exits non-zero
|
|
462
|
-
},
|
|
463
|
-
},
|
|
464
|
-
1,
|
|
465
|
-
2,
|
|
466
|
-
);
|
|
467
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
468
|
-
const payload = JSON.parse(r.stdout);
|
|
469
|
-
assert.deepEqual(payload.prose, []);
|
|
470
|
-
assert.match(payload.proseUnrun, /gh pr diff 2 failed/);
|
|
471
|
-
assert.equal(payload.signal, "none");
|
|
472
|
-
assert.match(r.stderr, /prose scan INCOMPLETE/);
|
|
473
|
-
assert.match(r.stderr, /does not clear the same-section case/);
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
// #878: `--a 0`/`--b 0` is the row the `=== null` absence check exists for,
|
|
477
|
-
// and the one a later "simplification" back to `!a || !b` silently breaks:
|
|
478
|
-
// numArg() returns a NUMBER, so `!a` is true for a zero the caller plainly
|
|
479
|
-
// GAVE, and the usage die above would then answer it as though `--a` were
|
|
480
|
-
// never given at all. Companion to arg.test.mjs's identical row for
|
|
481
|
-
// diff-stats.mjs and ci-state.test.mjs's own for `--pr` — #878's own comment
|
|
482
|
-
// names all three callers as sharing this contract, and only diff-stats.mjs
|
|
483
|
-
// had this row before.
|
|
484
|
-
//
|
|
485
|
-
// `strictEqual` on both fields, same reason as the well-formed test above: a
|
|
486
|
-
// payload reading `a`/`b` back as the string "0" would satisfy a loose check
|
|
487
|
-
// while breaking every consumer that keys on a number.
|
|
488
|
-
test("#878: --a 0/--b 0 reach gh rather than drawing the usage line for an absent flag", () => {
|
|
489
|
-
const bin = mkdtempSync(join(tmpdir(), "pr-overlap-bin-"));
|
|
490
|
-
const gh = join(bin, "gh");
|
|
491
|
-
writeExecStub(gh, '#!/bin/sh\ncase "$3" in\n 0) echo src/shared.ts ;;\nesac\n');
|
|
492
|
-
const r = spawnSync(process.execPath, [SCRIPT, "--a", "0", "--b", "0"], {
|
|
493
|
-
encoding: "utf8",
|
|
494
|
-
env: { ...process.env, PATH: `${bin}:${process.env.PATH}` },
|
|
495
|
-
});
|
|
496
|
-
rmSync(bin, { recursive: true, force: true });
|
|
497
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
498
|
-
assert.doesNotMatch(r.stderr, /usage:/, `--a 0/--b 0 was answered as an absent flag: ${r.stderr}`);
|
|
499
|
-
const payload = JSON.parse(r.stdout);
|
|
500
|
-
assert.strictEqual(payload.a, 0, `a zero --a must survive to the payload as 0: ${r.stdout}`);
|
|
501
|
-
assert.strictEqual(payload.b, 0, `a zero --b must survive to the payload as 0: ${r.stdout}`);
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
// A `-`/`+` diff marker followed by CONTENT that itself starts with a dash
|
|
505
|
-
// or plus (a removed `--pin ...` line, an added `++retry ...` line) composes
|
|
506
|
-
// to `---`/`+++` — the same three characters a real file-header line begins
|
|
507
|
-
// with. Gating capture on the `@@` hunk boundary rather than on those three
|
|
508
|
-
// characters is what tells the two apart; testing the header text alone
|
|
509
|
-
// mistakes the hunk-body line for its own file header and drops it.
|
|
510
|
-
test("prose: a hunk-body line beginning with -- or ++ is still read as a citation, not mistaken for a diff header", () => {
|
|
511
|
-
const REMOVED_CITER = "docs/removed-hazard.md";
|
|
512
|
-
const ADDED_CITER = "docs/added-hazard.md";
|
|
513
|
-
const r = run(
|
|
514
|
-
{
|
|
515
|
-
prs: {
|
|
516
|
-
1: { names: [TSV], diff: hunk(TSV, ["+1490\timpl-1490"]) },
|
|
517
|
-
2: {
|
|
518
|
-
names: [REMOVED_CITER, ADDED_CITER],
|
|
519
|
-
diff:
|
|
520
|
-
hunk(REMOVED_CITER, [`---pin ${TSV} (stale, drop it)`]) +
|
|
521
|
-
hunk(ADDED_CITER, [`+++retry ${TSV} (kept)`]),
|
|
522
|
-
},
|
|
523
|
-
},
|
|
524
|
-
},
|
|
525
|
-
1,
|
|
526
|
-
2,
|
|
527
|
-
);
|
|
528
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
529
|
-
const payload = JSON.parse(r.stdout);
|
|
530
|
-
assert.equal(payload.signal, "prose");
|
|
531
|
-
assert.deepEqual(
|
|
532
|
-
payload.prose.map((h) => h.citedBy).sort(),
|
|
533
|
-
[ADDED_CITER, REMOVED_CITER],
|
|
534
|
-
);
|
|
535
|
-
});
|
|
536
|
-
|
|
537
|
-
// `trackedBasenameCounts()`'s own `git ls-files` failure must name its cause
|
|
538
|
-
// the same way `changedFiles()` and `diffOf()` do — a bare `null` collapsing
|
|
539
|
-
// into a fixed string is indistinguishable from every OTHER git failure, and
|
|
540
|
-
// disables the ambiguity guard (full paths only) with no diagnostic to act
|
|
541
|
-
// on. Shadows `git` on PATH so `git ls-files -z` fails; the full-path
|
|
542
|
-
// citation below still fires because the guard narrowing to full-paths-only
|
|
543
|
-
// is exactly what a failed count means, not a disabled scan.
|
|
544
|
-
test("prose: a git ls-files failure names its cause instead of vanishing into a fixed string", () => {
|
|
545
|
-
const fx = fixture({
|
|
546
|
-
prs: {
|
|
547
|
-
1: { names: [TSV], diff: hunk(TSV, ["+1490\timpl-1490"]) },
|
|
548
|
-
2: { names: ["docs/notes.md"], diff: hunk("docs/notes.md", [`+cites ${TSV} here`]) },
|
|
549
|
-
},
|
|
550
|
-
});
|
|
551
|
-
const git = join(fx.bin, "git");
|
|
552
|
-
writeExecStub(git, "#!/bin/sh\nexit 1\n");
|
|
553
|
-
const r = spawnSync(process.execPath, [SCRIPT, "--a", "1", "--b", "2"], {
|
|
554
|
-
encoding: "utf8",
|
|
555
|
-
cwd: fx.repo,
|
|
556
|
-
env: { ...process.env, PATH: `${fx.bin}:${process.env.PATH}` },
|
|
557
|
-
});
|
|
558
|
-
rmSync(fx.root, { recursive: true, force: true });
|
|
559
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
560
|
-
const payload = JSON.parse(r.stdout);
|
|
561
|
-
assert.equal(payload.signal, "prose");
|
|
562
|
-
assert.match(payload.proseUnrun, /git ls-files failed: exit 1/);
|
|
563
|
-
assert.match(r.stderr, /git ls-files failed: exit 1/);
|
|
564
|
-
});
|
|
565
|
-
|
|
566
|
-
// The guard counted only the PRE-PR index: a data file the PR itself ADDS is
|
|
567
|
-
// untracked at this checkout, so subtracting nothing from an existing
|
|
568
|
-
// OTHER tracked file's count left the added file wrongly "unique" — the two
|
|
569
|
-
// files share a basename post-PR and neither should be citable by it alone.
|
|
570
|
-
test("prose: a data file the PR itself adds is still checked against existing tracked basenames", () => {
|
|
571
|
-
const EXISTING = "other/dir/config.json";
|
|
572
|
-
const ADDED = "new/config.json";
|
|
573
|
-
const CITER = "docs/notes.md";
|
|
574
|
-
const r = run(
|
|
575
|
-
{
|
|
576
|
-
prs: {
|
|
577
|
-
1: { names: [ADDED], diff: hunk(ADDED, ['+{"x":1}']) },
|
|
578
|
-
2: { names: [CITER], diff: hunk(CITER, ["+see config.json for the format"]) },
|
|
579
|
-
},
|
|
580
|
-
tracked: [EXISTING],
|
|
581
|
-
},
|
|
582
|
-
1,
|
|
583
|
-
2,
|
|
584
|
-
);
|
|
585
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
586
|
-
const payload = JSON.parse(r.stdout);
|
|
587
|
-
assert.equal(payload.signal, "none");
|
|
588
|
-
assert.deepEqual(payload.prose, []);
|
|
589
|
-
});
|
|
590
|
-
|
|
591
|
-
// The guard's other branch: a data file the PR only MODIFIES (already
|
|
592
|
-
// tracked, exactly once) must still be matched by its bare basename. Only
|
|
593
|
-
// the ambiguous case (count 2+) and the freshly-added case (count 0) were
|
|
594
|
-
// covered before this — a mutation that narrows the "unique" boundary
|
|
595
|
-
// silently drops this branch, and no test caught it.
|
|
596
|
-
test("prose: a uniquely-tracked data file is still matched by its bare basename", () => {
|
|
597
|
-
const UNIQUE = "data/only-owner.json";
|
|
598
|
-
const CITER = "docs/notes.md";
|
|
599
|
-
const r = run(
|
|
600
|
-
{
|
|
601
|
-
prs: {
|
|
602
|
-
1: { names: [UNIQUE], diff: hunk(UNIQUE, ['+{"x":1}']) },
|
|
603
|
-
2: { names: [CITER], diff: hunk(CITER, ["+see only-owner.json for the schema"]) },
|
|
604
|
-
},
|
|
605
|
-
tracked: [UNIQUE],
|
|
606
|
-
},
|
|
607
|
-
1,
|
|
608
|
-
2,
|
|
609
|
-
);
|
|
610
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
611
|
-
const payload = JSON.parse(r.stdout);
|
|
612
|
-
assert.equal(payload.signal, "prose");
|
|
613
|
-
assert.deepEqual(payload.prose.map((h) => h.token), ["only-owner.json"]);
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
// #1599: trackedBasenameCounts() passed no env at all before this fix, and
|
|
617
|
-
// #1020's own census could not see it — its scan is `.sh`-only. Measured
|
|
618
|
-
// directly: an ambient GIT_DIR (a git hook, `rebase --exec`, `bisect run`)
|
|
619
|
-
// makes `git ls-files -z` answer for a DIFFERENT repository regardless of
|
|
620
|
-
// `cwd`, silently, at exit 0 — so the count this guard bases its verdict on
|
|
621
|
-
// comes from whichever repository the ambient variable names, not the one
|
|
622
|
-
// the caller is actually running the tool against.
|
|
623
|
-
//
|
|
624
|
-
// The fixture pairs a real repository where the data file's basename is
|
|
625
|
-
// UNIQUE (`only-owner.json`, tracked once — the exact positive shape the
|
|
626
|
-
// test above pins) with an ambient GIT_DIR naming an unrelated repository
|
|
627
|
-
// where that basename is tracked TWICE. Unscrubbed, the guard reads the
|
|
628
|
-
// ambient repository's count (2) instead of the real one (1), the bare
|
|
629
|
-
// basename is wrongly judged ambiguous and dropped, and the citation below
|
|
630
|
-
// goes unreported — `signal` stays "none" instead of "prose".
|
|
631
|
-
test("prose: an inherited GIT_DIR must not substitute another repository's basename count for this repository's own", () => {
|
|
632
|
-
const UNIQUE = "data/only-owner.json";
|
|
633
|
-
const CITER = "docs/notes.md";
|
|
634
|
-
|
|
635
|
-
const otherRepo = mkdtempSync(join(tmpdir(), "pr-overlap-other-"));
|
|
636
|
-
execFileSync("git", ["init", "-q"], { cwd: otherRepo });
|
|
637
|
-
mkdirSync(join(otherRepo, "a"), { recursive: true });
|
|
638
|
-
mkdirSync(join(otherRepo, "b"), { recursive: true });
|
|
639
|
-
writeFileSync(join(otherRepo, "a", "only-owner.json"), "x\n");
|
|
640
|
-
writeFileSync(join(otherRepo, "b", "only-owner.json"), "x\n");
|
|
641
|
-
execFileSync("git", ["add", "-A"], { cwd: otherRepo });
|
|
642
|
-
|
|
643
|
-
const fx = fixture({
|
|
644
|
-
prs: {
|
|
645
|
-
1: { names: [UNIQUE], diff: hunk(UNIQUE, ['+{"x":1}']) },
|
|
646
|
-
2: { names: [CITER], diff: hunk(CITER, ["+see only-owner.json for the schema"]) },
|
|
647
|
-
},
|
|
648
|
-
tracked: [UNIQUE],
|
|
649
|
-
});
|
|
650
|
-
let r;
|
|
651
|
-
try {
|
|
652
|
-
r = spawnSync(process.execPath, [SCRIPT, "--a", "1", "--b", "2"], {
|
|
653
|
-
encoding: "utf8",
|
|
654
|
-
cwd: fx.repo,
|
|
655
|
-
env: { ...process.env, PATH: `${fx.bin}:${process.env.PATH}`, GIT_DIR: join(otherRepo, ".git") },
|
|
656
|
-
});
|
|
657
|
-
} finally {
|
|
658
|
-
rmSync(fx.root, { recursive: true, force: true });
|
|
659
|
-
rmSync(otherRepo, { recursive: true, force: true });
|
|
660
|
-
}
|
|
661
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
662
|
-
const payload = JSON.parse(r.stdout);
|
|
663
|
-
assert.equal(payload.signal, "prose",
|
|
664
|
-
"an ambient GIT_DIR must not substitute the OTHER repository's (ambiguous) basename count for this repository's own (unique) one");
|
|
665
|
-
assert.deepEqual(payload.prose.map((h) => h.token), ["only-owner.json"]);
|
|
666
|
-
});
|
|
667
|
-
|
|
668
|
-
// The other ranking pair: `dirs` sits ABOVE `prose` in the ladder, and no
|
|
669
|
-
// test drove a PR pair where both fire simultaneously. A swap of that
|
|
670
|
-
// ordering (`prose` checked before `dirs`) would pass the whole suite
|
|
671
|
-
// untouched without this.
|
|
672
|
-
test("prose: dirs outranks prose when both fire, and the prose hit is still reported", () => {
|
|
673
|
-
const r = run(
|
|
674
|
-
{
|
|
675
|
-
prs: {
|
|
676
|
-
1: { names: [TSV, "docs/metrics/other.md"], diff: hunk(TSV, ["+1490\timpl-1490"]) },
|
|
677
|
-
2: {
|
|
678
|
-
names: ["docs/metrics/notes.md"],
|
|
679
|
-
diff: hunk("docs/metrics/notes.md", [`+cites ${TSV} here`]),
|
|
680
|
-
},
|
|
681
|
-
},
|
|
682
|
-
},
|
|
683
|
-
1,
|
|
684
|
-
2,
|
|
685
|
-
);
|
|
686
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
687
|
-
const payload = JSON.parse(r.stdout);
|
|
688
|
-
assert.equal(payload.signal, "dirs");
|
|
689
|
-
assert.deepEqual(payload.dirs, ["docs/metrics"]);
|
|
690
|
-
assert.equal(payload.prose.length, 1);
|
|
691
|
-
assert.match(r.stderr, /prose citation/);
|
|
692
|
-
});
|