@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,478 +0,0 @@
|
|
|
1
|
-
import { test } from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { readFileSync } from "node:fs";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { stripComments } from "./strip-comments.mjs";
|
|
6
|
-
import { between } from "./prose-pin.mjs";
|
|
7
|
-
import { usableDiff, readRules, SNAPSHOT_SCHEMA } from "./review-core.mjs";
|
|
8
|
-
|
|
9
|
-
const REPO = join(import.meta.dirname, "..");
|
|
10
|
-
const SOURCE = readFileSync(join(REPO, "scripts", "review-core.mjs"), "utf8");
|
|
11
|
-
|
|
12
|
-
// Every pin below runs against CODE, not SOURCE: a declaration or a paragraph a
|
|
13
|
-
// reader's eye skips must not satisfy an assertion. Stripping once closes the
|
|
14
|
-
// class for every assertion in this file, including ones added later — see
|
|
15
|
-
// strip-comments.mjs for the two escapes measured green without it, and for why
|
|
16
|
-
// the stripper is shared rather than copied into each test file.
|
|
17
|
-
const CODE = stripComments(SOURCE);
|
|
18
|
-
|
|
19
|
-
// #1129: `usableDiff` no longer returns the reported `diffPath`, it REBUILDS
|
|
20
|
-
// the path from the run root the caller already checked — the redirect that
|
|
21
|
-
// wrote the file is `> "$RUN"/pr.diff` inside the snapshot block, so the path is
|
|
22
|
-
// the caller's to derive. What the reported field still decides is whether the
|
|
23
|
-
// capture happened at all, which is why every fixture below varies `diffPath`
|
|
24
|
-
// while the accepted RESULT is always derived from `runRoot`.
|
|
25
|
-
const ROOT = "/s/pr7/run-ab12cd34";
|
|
26
|
-
|
|
27
|
-
// A diff that is empty, or whose line count was never measured, is worse than
|
|
28
|
-
// no diff: the specialist reads it as authoritative.
|
|
29
|
-
test("usableDiff rejects a diff that would lie about the snapshot", () => {
|
|
30
|
-
assert.equal(usableDiff({}), null, "no diffPath");
|
|
31
|
-
assert.equal(
|
|
32
|
-
usableDiff({ diffLines: 40 }),
|
|
33
|
-
null,
|
|
34
|
-
"diffPath absent but diffLines truthy — isolates the diffPath guard from the diffLines guard",
|
|
35
|
-
);
|
|
36
|
-
assert.equal(
|
|
37
|
-
usableDiff({ diffPath: "/s/pr.diff", diffLines: 0 }),
|
|
38
|
-
null,
|
|
39
|
-
"0-byte diff — `gh pr diff` exits 1 and still leaves the file",
|
|
40
|
-
);
|
|
41
|
-
// The one guard where ABSENT and 0 mean the same thing. Deliberate: the count
|
|
42
|
-
// is not a cross-check, it is the only thing that rules out that 0-byte file,
|
|
43
|
-
// so an unreported count leaves "usable" a guess. Pinned because it reads like
|
|
44
|
-
// the inversion bug.
|
|
45
|
-
assert.equal(
|
|
46
|
-
usableDiff({ diffPath: "/s/pr.diff" }),
|
|
47
|
-
null,
|
|
48
|
-
"diffLines absent — no count means the 0-byte case cannot be ruled out",
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// The accept half. Heads are `snapshotMissing`'s to judge, before this runs, so
|
|
53
|
-
// a present `refHead` — matching or not — must not cost a counted diff here.
|
|
54
|
-
test("usableDiff accepts a counted diff and derives its path from runRoot", () => {
|
|
55
|
-
assert.equal(usableDiff({ runRoot: ROOT, head: "aaa", diffPath: "/s/pr.diff", diffLines: 40 }), `${ROOT}/pr.diff`);
|
|
56
|
-
assert.equal(
|
|
57
|
-
usableDiff({ runRoot: ROOT, head: "aaa", diffPath: "/s/pr.diff", diffLines: 40, refHead: "bbb" }),
|
|
58
|
-
`${ROOT}/pr.diff`,
|
|
59
|
-
"usableDiff judged the heads again — the compare belongs to snapshotMissing alone",
|
|
60
|
-
);
|
|
61
|
-
assert.equal(
|
|
62
|
-
usableDiff({ runRoot: ROOT, head: "a".repeat(40), diffPath: "/s/pr.diff", diffLines: 40, refHead: "z".repeat(7) }),
|
|
63
|
-
`${ROOT}/pr.diff`,
|
|
64
|
-
"unconditionally blind to refHead, not merely permissive of one mismatch shape — an abbreviated mismatch must not cost the diff either",
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const PATHS = {
|
|
69
|
-
paths: [
|
|
70
|
-
{ path: "scripts/review-core.mjs", kind: "src", loc: 115 },
|
|
71
|
-
{ path: "docs/specs/a.md", kind: "docs", loc: 393 },
|
|
72
|
-
],
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// Emitting both the diff pointer and the file list doubles the block on exactly
|
|
76
|
-
// the PRs where prompt size matters most. The branches are exclusive.
|
|
77
|
-
test("readRules names the diff and does not also list files", () => {
|
|
78
|
-
const out = readRules("/s/pr.diff", PATHS);
|
|
79
|
-
assert.match(out, /\/s\/pr\.diff/);
|
|
80
|
-
assert.doesNotMatch(out, /touched exactly these files/);
|
|
81
|
-
// The IMPERATIVE, not just the path. Reducing this branch to `The PR's whole
|
|
82
|
-
// diff is at ${diffPath}.` left the suite green — and a path with no order to
|
|
83
|
-
// read it first is pre-fix behaviour plus tokens, which is the entire defect
|
|
84
|
-
// this branch exists to fix. `\s+` per the file's reflow convention.
|
|
85
|
-
assert.match(
|
|
86
|
-
out,
|
|
87
|
-
/Read\s+it\s+FIRST,\s+bounded/,
|
|
88
|
-
"the diff is named but not ordered read first — a specialist keeps reading whole files",
|
|
89
|
-
);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// The unit is stated INLINE, per file. A bare `(115)` under a header is read as
|
|
93
|
-
// the file's length — "small, take it whole" on a 900-line file — which is the
|
|
94
|
-
// unbounded read the block exists to stop.
|
|
95
|
-
test("readRules falls back to the changed-file list with each file's loc", () => {
|
|
96
|
-
const out = readRules(null, PATHS);
|
|
97
|
-
assert.match(out, /No diff file was captured/);
|
|
98
|
-
assert.match(out, /scripts\/review-core\.mjs \(115 changed\)/);
|
|
99
|
-
assert.match(out, /docs\/specs\/a\.md \(393 changed\)/);
|
|
100
|
-
// The POSITIVE companion the four `doesNotMatch(/touched exactly these files/)`
|
|
101
|
-
// assertions in this file need. Without it, renaming the phrase makes all four
|
|
102
|
-
// pass forever against a branch 2 that no longer says anything of the kind —
|
|
103
|
-
// a `doesNotMatch` over an unverified baseline passes trivially.
|
|
104
|
-
assert.match(
|
|
105
|
-
out,
|
|
106
|
-
/touched exactly these files and no others/,
|
|
107
|
-
"branch 2 no longer emits the closure phrase the negative assertions are written against",
|
|
108
|
-
);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// `stats` is null whenever diff-stats.mjs errored or its blob was unparseable
|
|
112
|
-
// (where the caller parses `snap.diffStats`). Saying so beats emitting an empty
|
|
113
|
-
// list, which reads as "the PR touched no files".
|
|
114
|
-
test("readRules says so when it has neither a diff nor a file list", () => {
|
|
115
|
-
const out = readRules(null, null);
|
|
116
|
-
assert.match(out, /No diff file and no file list were captured/);
|
|
117
|
-
assert.doesNotMatch(out, /touched exactly these files/);
|
|
118
|
-
// This branch is ONE failure away, not two: diff-stats.mjs shells out to
|
|
119
|
-
// `gh pr view <pr> --json files`, so a single broken `gh` takes the diff and
|
|
120
|
-
// the file list together. It is also the branch a specialist cannot fall back
|
|
121
|
-
// on anything else from — its "review request" is a dimension prompt naming no
|
|
122
|
-
// file. So it has to name a discovery move. The wording it replaces
|
|
123
|
-
// ("do not survey the snapshot") forbade the only one left.
|
|
124
|
-
// `\s+` spans every word gap, not just the one where the source happens to
|
|
125
|
-
// wrap today — the same reflow-tolerance convention the FIX-3 pins below
|
|
126
|
-
// use. An anchor tied to one wrap point reds on a routine rewrap with a
|
|
127
|
-
// message claiming the discovery move is missing, which it is not.
|
|
128
|
-
assert.match(out, /Locate\s+the\s+files\s+your\s+dimension\s+covers/);
|
|
129
|
-
assert.doesNotMatch(out, /do not survey/i);
|
|
130
|
-
// The blacklist above plus the sentence pin are both evadable together:
|
|
131
|
-
// rewriting this branch to "ONLY from the names your review request already
|
|
132
|
-
// gives you. Never explore the snapshot" passes both — and that is verbatim
|
|
133
|
-
// the regression 830bddb exists to prevent, since this branch's review request
|
|
134
|
-
// names no file. Pin the AFFIRMATIVE moves instead: a synonym walks around a
|
|
135
|
-
// blacklist, but it cannot supply a command that does the discovery.
|
|
136
|
-
assert.match(out, /'grep -rn'/, "the discovery move is not given as a runnable command");
|
|
137
|
-
assert.match(out, /'ls -R'/, "the discovery move is not given as a runnable command");
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// A `stats` object whose `paths` is empty must NOT fall into branch 2 — that
|
|
141
|
-
// would print the header with nothing under it. `.length` is the guard.
|
|
142
|
-
test("readRules treats an empty paths array as no file list", () => {
|
|
143
|
-
const out = readRules(null, { paths: [] });
|
|
144
|
-
assert.match(out, /No diff file and no file list were captured/);
|
|
145
|
-
assert.doesNotMatch(out, /touched exactly these files/);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
// A `stats` object that is truthy but carries no `paths` key at all (distinct
|
|
149
|
-
// from an empty array) must hit the same fallback. `stats.paths` is its own
|
|
150
|
-
// conjunct in the guard, separate from `.length`, and nothing above isolates
|
|
151
|
-
// it: every other test's `stats` either has a real `paths` array or is `null`
|
|
152
|
-
// outright, so a middle-conjunct deletion (`stats && stats.paths.length`,
|
|
153
|
-
// dropping `stats.paths &&`) reads `undefined.length` — a real production
|
|
154
|
-
// crash if diff-stats.mjs ever returns a blob without `paths` — and every
|
|
155
|
-
// existing test still passes around it.
|
|
156
|
-
test("readRules treats a stats object with no paths key as no file list", () => {
|
|
157
|
-
const out = readRules(null, {});
|
|
158
|
-
assert.match(out, /No diff file and no file list were captured/);
|
|
159
|
-
assert.doesNotMatch(out, /touched exactly these files/);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
// `gh pr view --json files` pages at 100 and exits 0 — measured 100 listed
|
|
163
|
-
// against `changedFiles` 124. Branch 2 is the first consumer to put that list in
|
|
164
|
-
// front of an agent, and it did so under a closure clause. The files that fell
|
|
165
|
-
// off the end vanish undetectably: `stats.files` is short too, so nothing in the
|
|
166
|
-
// blob contradicts the sentence.
|
|
167
|
-
test("readRules does not claim closure over a list gh truncated", () => {
|
|
168
|
-
const out = readRules(null, { ...PATHS, truncated: 124 });
|
|
169
|
-
assert.doesNotMatch(
|
|
170
|
-
out,
|
|
171
|
-
/touched exactly these files and no others/,
|
|
172
|
-
"a capped file list is still presented as the complete set of changed files",
|
|
173
|
-
);
|
|
174
|
-
assert.match(out, /at\s+least\s+these\s+files/);
|
|
175
|
-
assert.match(out, /capped\s+the\s+list\s+at\s+2\s+of\s+124/, "the cap is not quantified, so it cannot be acted on");
|
|
176
|
-
// Still a usable list — the fix is to stop overclaiming, not to withhold.
|
|
177
|
-
assert.match(out, /scripts\/review-core\.mjs \(115 changed\)/);
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
// `gh pr diff > pr.diff` is a shell REDIRECT: the file exists in every run, in
|
|
181
|
-
// the same ${scratch} tree the specialist is pointed at for its own work. A
|
|
182
|
-
// rejected diff is still on disk — non-empty when only `wc -l` failed — and "No
|
|
183
|
-
// diff file was captured" is then false in the one way that matters: the
|
|
184
|
-
// specialist can find the file and has been given no reason not to trust it.
|
|
185
|
-
test("readRules names a rejected diff rather than denying a file that exists", () => {
|
|
186
|
-
const out = readRules(null, PATHS, { diffPath: "/s/pr.diff" });
|
|
187
|
-
assert.doesNotMatch(out, /No diff file was captured/, "the diff file exists — the redirect always creates it");
|
|
188
|
-
assert.match(out, /REJECTED/);
|
|
189
|
-
assert.match(out, /\/s\/pr\.diff/, "the rejected file is not named, so the specialist cannot know which one to skip");
|
|
190
|
-
assert.match(out, /Do not read it/);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
// #1132 review: readRules() lost its `skew` binding, but nothing above
|
|
194
|
-
// proves it BY BEHAVIOR — reinserting the deleted head-skew branch verbatim
|
|
195
|
-
// passes every test in this file unchanged, because none of them call
|
|
196
|
-
// readRules() with a rejected diff AND a present refHead together. Pin the
|
|
197
|
-
// combination directly, not just the absence of `refHead` from the source.
|
|
198
|
-
test("readRules ignores refHead even when a rejected diff and a head mismatch are both present", () => {
|
|
199
|
-
const out = readRules(null, PATHS, { diffPath: "/s/pr.diff", head: "aaa", diffLines: 40, refHead: "bbb" });
|
|
200
|
-
assert.match(out, /REJECTED — its\s+line\s+count\s+was\s+never\s+reported/);
|
|
201
|
-
assert.doesNotMatch(
|
|
202
|
-
out,
|
|
203
|
-
/describes\s+the\s+PR's\s+head/i,
|
|
204
|
-
"readRules must not attribute the rejection to a head mismatch — that compare belongs to snapshotMissing alone",
|
|
205
|
-
);
|
|
206
|
-
assert.doesNotMatch(out, /\bbbb\b/, "refHead never surfaces in the reason readRules hands to a specialist");
|
|
207
|
-
assert.match(
|
|
208
|
-
out,
|
|
209
|
-
/touched exactly these files and no others/,
|
|
210
|
-
"no skew wording survives — the header is unconditional now",
|
|
211
|
-
);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
// Two rejections with nothing in common but the verdict — and the snapshot
|
|
215
|
-
// schema makes a further shape routine: `diffLines` is declared in that schema's
|
|
216
|
-
// `properties` and absent from its `required` list, and the snapshot agent's
|
|
217
|
-
// own prompt instructs the omission ("do not withhold one field because
|
|
218
|
-
// another failed"), so a run where `gh pr diff` captured the PR's whole change
|
|
219
|
-
// and only `wc -l` failed arrives here with no count at all. `usableDiff`
|
|
220
|
-
// rejects that diff like the others — deliberately, since the count is the
|
|
221
|
-
// only thing that rules out the 0-byte file — but the REASON handed to every
|
|
222
|
-
// specialist is a separate question, and a count that measured 0 is the only
|
|
223
|
-
// rejection that licenses "it is empty".
|
|
224
|
-
//
|
|
225
|
-
// The fixture is what these pins turn on, so each spells its own out. The case
|
|
226
|
-
// named for the empty diff used to report no count at all — `git show
|
|
227
|
-
// f743264:plugin/scripts/review-pr-reads.test.mjs | grep -A2 'distinguishes an
|
|
228
|
-
// empty rejected'` — so the empty case went unexercised under its own name,
|
|
229
|
-
// and the label it pinned was the conflation (#1131).
|
|
230
|
-
test("readRules calls a rejected diff empty only when a count measured it", () => {
|
|
231
|
-
const out = readRules(null, PATHS, { diffPath: "/s/pr.diff", diffLines: 0 });
|
|
232
|
-
assert.match(out, /REJECTED — it is empty/);
|
|
233
|
-
// A complete list — closure is TRUE here and must still be claimed.
|
|
234
|
-
assert.match(out, /touched exactly these files and no others/);
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
// The case the label used to lie about, and the one the snapshot schema's own
|
|
238
|
-
// optional `diffLines` makes ordinary: `gh pr diff` can succeed while `wc -l`
|
|
239
|
-
// fails, so the file a
|
|
240
|
-
// specialist is told not to read may hold the PR's whole change, and "it is
|
|
241
|
-
// empty" is then the silent green of `tests 0` served as a review instruction.
|
|
242
|
-
// review-core.mjs's diff-decision log already obeys this rule — the pin named
|
|
243
|
-
// "the no-diff log reports the raw fields, not a guard it did not measure"
|
|
244
|
-
// holds it there — and this is the copy every specialist reads.
|
|
245
|
-
test("readRules does not call a rejected diff empty when no count was reported", () => {
|
|
246
|
-
const out = readRules(null, PATHS, { diffPath: "/s/pr.diff" });
|
|
247
|
-
assert.match(out, /REJECTED — its\s+line\s+count\s+was\s+never\s+reported/);
|
|
248
|
-
assert.doesNotMatch(
|
|
249
|
-
out,
|
|
250
|
-
/it is empty/,
|
|
251
|
-
"an unreported count is served as a measured emptiness — every specialist reads that the PR changed nothing",
|
|
252
|
-
);
|
|
253
|
-
// Still rejected: `usableDiff`'s guard is unchanged, and a diff no count
|
|
254
|
-
// measured is still the one file not to read.
|
|
255
|
-
assert.match(out, /Do not read it/);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
// A run with no diffPath at all is not a rejection: nothing was captured, and
|
|
259
|
-
// saying "a diff was captured and rejected" would be a fresh false claim.
|
|
260
|
-
test("readRules reports no capture when the snapshot agent reported no diffPath", () => {
|
|
261
|
-
const out = readRules(null, PATHS, {});
|
|
262
|
-
assert.match(out, /No diff file was captured/);
|
|
263
|
-
assert.doesNotMatch(out, /REJECTED/);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
// The rule is the whole point of the block; it must survive every branch, not
|
|
267
|
-
// just the happy one. Assert the imperative and the counting clause, not a word
|
|
268
|
-
// that also appears in the surrounding rationale.
|
|
269
|
-
test("every branch carries the bounding rule", () => {
|
|
270
|
-
for (const out of [readRules("/s/pr.diff", PATHS), readRules(null, PATHS), readRules(null, null)]) {
|
|
271
|
-
assert.match(out, /BOUND EVERY READ/);
|
|
272
|
-
assert.match(out, /'wc -l' says it is small/);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// Bounded at both ends in prose-pin.mjs's between() — an unbounded end runs to
|
|
277
|
-
// EOF where the specialist and refuter prompts satisfy it, the defect
|
|
278
|
-
// `review-core-testcmd.test.mjs`'s "the test-run prompt hands the command over
|
|
279
|
-
// verbatim and rules 'tests 0' a failure" records.
|
|
280
|
-
const slice = (from, to) => between(CODE, from, to, "review-core.mjs");
|
|
281
|
-
|
|
282
|
-
// The snapshot schema's `additionalProperties: false` REJECTS an undeclared
|
|
283
|
-
// field, so a prompt that asks for these four while the schema omits them
|
|
284
|
-
// silently yields nothing. Both halves have to be pinned or the feature
|
|
285
|
-
// disconnects in one token.
|
|
286
|
-
test("the snapshot agent asks for the diff facts AND declares them in its schema", () => {
|
|
287
|
-
const snapshot = slice("const snap = await agent(", "if (snap) {");
|
|
288
|
-
// Pinned on `"$RUN"` since #1129: the capture is a shell redirect into a
|
|
289
|
-
// directory the snapshot block's own `mkdir -p` created, and both artefacts
|
|
290
|
-
// hang off the same per-run root, which is what keeps `pr.diff` a SIBLING of
|
|
291
|
-
// the snapshot tree (the relationship the read-rules qualifier below depends
|
|
292
|
-
// on) while stopping two reviews in one session from overwriting each other's.
|
|
293
|
-
assert.match(snapshot, /gh pr diff \$\{pr\} > "?\$RUN"?\/pr\.diff/, "no diff capture");
|
|
294
|
-
// `/headRefOid/` alone also matches the prose ("Report `prHead` = the
|
|
295
|
-
// headRefOid") in the same prompt, so deleting this command left the suite
|
|
296
|
-
// green — pin the command line itself, not a word it shares with prose.
|
|
297
|
-
assert.match(
|
|
298
|
-
snapshot,
|
|
299
|
-
/gh pr view \$\{pr\} --json headRefOid -q \.headRefOid/,
|
|
300
|
-
"no PR head to cross-check against the snapshot's",
|
|
301
|
-
);
|
|
302
|
-
// #1513: the read the caller actually compares the snapshot against. It sits
|
|
303
|
-
// BESIDE the `headRefOid` read above — that field is still reported, and its
|
|
304
|
-
// disagreement with this one is the PR-object desync a controller adjudicates
|
|
305
|
-
// — so the two commands are pinned separately, and each on its own command
|
|
306
|
-
// line rather than on a word ("ls-remote", "headRefName") the surrounding
|
|
307
|
-
// prose also carries.
|
|
308
|
-
assert.match(
|
|
309
|
-
snapshot,
|
|
310
|
-
/branch=\$\(gh pr view \$\{pr\} --json headRefName -q \.headRefName\)/,
|
|
311
|
-
"no branch-name read — `refs/heads/$branch` then names no ref, and every PR falls through to the PR-ref read instead of reporting the branch ref #1513 chose",
|
|
312
|
-
);
|
|
313
|
-
// #1616 made this pair ORDERED rather than a single line, so all three facts
|
|
314
|
-
// are pinned: the branch read captures into `$ref` (uncaptured, the fallback
|
|
315
|
-
// below can never see that it succeeded), the fallback is GUARDED on that
|
|
316
|
-
// capture being empty, and the branch read comes FIRST. Order is not
|
|
317
|
-
// decoration — reversed, every same-repo PR pays a second network read and
|
|
318
|
-
// reports an operand read from a different ref than #1513 chose, which no
|
|
319
|
-
// "both lines present" pin would notice.
|
|
320
|
-
const branchRead = /ref=\$\(git -C \$\{worktree\} ls-remote origin "refs\/heads\/\$branch" \| cut -f1\)/;
|
|
321
|
-
const prRefRead = /\[ -n "\$ref" \] \|\| ref=\$\(git -C \$\{worktree\} ls-remote origin "refs\/pull\/\$\{pr\}\/head" \| cut -f1\)/;
|
|
322
|
-
assert.match(
|
|
323
|
-
snapshot,
|
|
324
|
-
branchRead,
|
|
325
|
-
"no captured branch-ref read — the head compare is back on the PR object's lagging headRefOid (#1513), or the fallback can no longer tell whether this read answered",
|
|
326
|
-
);
|
|
327
|
-
assert.match(
|
|
328
|
-
snapshot,
|
|
329
|
-
prRefRead,
|
|
330
|
-
"no guarded PR-ref fallback — a fork PR's branch resolves nowhere on `origin`, so refHead goes permanently absent and the wrong-commit backstop cannot fire for any fork (#1616)",
|
|
331
|
-
);
|
|
332
|
-
assert.ok(
|
|
333
|
-
snapshot.search(branchRead) < snapshot.search(prRefRead),
|
|
334
|
-
"the PR-ref read no longer comes SECOND — a same-repo PR must not pay a second network read, and must keep reporting the branch ref #1513 made the operand (#1616)",
|
|
335
|
-
);
|
|
336
|
-
assert.match(
|
|
337
|
-
snapshot,
|
|
338
|
-
/^\s*echo "\$ref"$/m,
|
|
339
|
-
"the resolved ref is never printed — both reads run and the agent has no line to report `refHead` from",
|
|
340
|
-
);
|
|
341
|
-
assert.match(snapshot, /wc -l < "?\$RUN"?\/pr\.diff/, "no line count — a 0-byte diff would pass as usable");
|
|
342
|
-
// Scoped to `SNAPSHOT_SCHEMA.properties` directly — a real import now,
|
|
343
|
-
// never a second copy of its JSON re-parsed from source text. Declaring a
|
|
344
|
-
// field ANYWHERE else — beside `required`, in the options bag — leaves it
|
|
345
|
-
// undeclared as far as `additionalProperties: false` is concerned.
|
|
346
|
-
for (const field of ["diffPath", "diffLines", "refHead", "prHead"]) {
|
|
347
|
-
assert.ok(
|
|
348
|
-
Object.prototype.hasOwnProperty.call(SNAPSHOT_SCHEMA.properties, field),
|
|
349
|
-
`${field} is not declared in SNAPSHOT_SCHEMA.properties — additionalProperties:false drops it`,
|
|
350
|
-
);
|
|
351
|
-
}
|
|
352
|
-
// Declared beside them, but not one of them: `pathVerified` and
|
|
353
|
-
// `repoVerified` belong to `required`, not to the gh-failure set, so they are
|
|
354
|
-
// pinned on their own rather than folded into the loop above — whose comment,
|
|
355
|
-
// and the one below, both read "these four". Only `required` membership was
|
|
356
|
-
// pinned when `pathVerified` was added (#140); `additionalProperties: false`
|
|
357
|
-
// is what makes the DECLARATION mandatory too, for every field this schema
|
|
358
|
-
// carries. `repoError` is optional by design — a verified snapshot has
|
|
359
|
-
// nothing to say there — but an undeclared field the agent reports anyway is
|
|
360
|
-
// dropped, so it needs the same declaration pin (#1056).
|
|
361
|
-
for (const field of ["pathVerified", "repoVerified", "repoError"]) {
|
|
362
|
-
assert.ok(
|
|
363
|
-
Object.prototype.hasOwnProperty.call(SNAPSHOT_SCHEMA.properties, field),
|
|
364
|
-
`${field} is not declared in SNAPSHOT_SCHEMA.properties — additionalProperties:false drops it`,
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
// The review must survive a gh failure. Those three stay out of `required`.
|
|
368
|
-
// `pathVerified` joins path+head instead (#140) — a caller check on whether
|
|
369
|
-
// the snapshot exists, not a `gh` fact that can legitimately be absent — and
|
|
370
|
-
// `repoVerified` joins them on the same rule (#1056): whether the snapshot is
|
|
371
|
-
// a git repository holding the reviewed tree is a check, not a network fact,
|
|
372
|
-
// and an omitted boolean must not read as a verified measurement environment.
|
|
373
|
-
assert.deepEqual(
|
|
374
|
-
SNAPSHOT_SCHEMA.required,
|
|
375
|
-
["runRoot", "path", "head", "pathVerified", "repoVerified"],
|
|
376
|
-
"required must stay path+head+pathVerified+repoVerified only",
|
|
377
|
-
);
|
|
378
|
-
// Commands pinned, schema pinned — and the INSTRUCTION between them was not.
|
|
379
|
-
// Measured: deleting this paragraph outright left this file at 12 pass, 0
|
|
380
|
-
// fail. The commands still run, the schema still accepts the fields, and
|
|
381
|
-
// nothing tells the agent to report any of them, so all four come back
|
|
382
|
-
// omitted, `usableDiff` returns null on every run forever, and the feature
|
|
383
|
-
// degrades to branch 2 under a green suite. `\s+` spans the line wraps so a
|
|
384
|
-
// reflow of the same sentences stays green; the words are what is pinned.
|
|
385
|
-
// These names live inside a template literal, so each backtick is a
|
|
386
|
-
// BACKSLASH-backtick in the source text — `\\?` matches it either way.
|
|
387
|
-
const B = "\\\\?`";
|
|
388
|
-
for (const [re, missing] of [
|
|
389
|
-
[
|
|
390
|
-
// The measured escape for this one was re-inserting the paragraph verbatim
|
|
391
|
-
// inside a `/* */` block — which starts its line with `/*`, not `//`, so a
|
|
392
|
-
// `//`-only anchor would have stayed green. Handled once by CODE now,
|
|
393
|
-
// rather than by an anchor each future assertion has to remember.
|
|
394
|
-
// The run root, not `scratch`: #1129 moved every artefact of a run onto a
|
|
395
|
-
// per-run root, and a pin left on the bare root would go green again on
|
|
396
|
-
// exactly the regression it exists to stop — the diff capture sliding
|
|
397
|
-
// back to a path two reviews in one session share.
|
|
398
|
-
`Report\\s+${B}diffPath${B}\\s+=\\s+the\\s+SNAPSHOT_RUN_ROOT\\s+value\\s+with\\s+'/pr\\.diff'\\s+appended,\\s+ONLY\\s+if\\s+'gh pr diff'\\s+exited\\s+0`,
|
|
399
|
-
"diffPath is not both bound to a value and gated on the exit code — the agent must infer the path from the redirect target",
|
|
400
|
-
],
|
|
401
|
-
[
|
|
402
|
-
`${B}refHead${B}\\s+=\\s+the\\s+sha\\s+the\\s+'echo\\s+"\\$ref"'\\s+line\\s+printed`,
|
|
403
|
-
"refHead's value is not bound to the ref read — the commands run and nothing tells the agent to report what they printed (#1513)",
|
|
404
|
-
],
|
|
405
|
-
[
|
|
406
|
-
// An empty string reported as `refHead` is FALSY, so the compare skips on
|
|
407
|
-
// it exactly as it does on an absent field — but the run log's `??` does
|
|
408
|
-
// not catch it, so the skip prints as a blank instead of naming itself.
|
|
409
|
-
// Since #1616 `refHead` can also be OMITTED because the branch-ref read
|
|
410
|
-
// never ran at all — a cross-repo PR skips it outright — so "every read
|
|
411
|
-
// this PR was entitled to" is what covers both a same-repo PR whose two
|
|
412
|
-
// reads both came back empty and a cross-repo PR whose one read did.
|
|
413
|
-
`Omit\\s+${B}refHead${B}\\s+when\\s+every\\s+read\\s+this\\s+PR\\s+was\\s+entitled\\s+to\\s+came\\s+back\\s+empty`,
|
|
414
|
-
"a PR is not told to omit refHead when every read it was entitled to came back empty — the head check then skips without saying so",
|
|
415
|
-
],
|
|
416
|
-
[`${B}prHead${B}\\s+=\\s+the\\s+headRefOid`, "prHead's value is not bound to the headRefOid"],
|
|
417
|
-
[`${B}diffLines${B}\\s+=\\s+the\\s+wc\\s+-l\\s+count`, "diffLines' value is not bound to the wc -l count"],
|
|
418
|
-
[
|
|
419
|
-
"do\\s+not\\s+withhold\\s+one\\s+field\\s+because\\s+another\\s+failed",
|
|
420
|
-
"one gh failure can suppress the fields that succeeded",
|
|
421
|
-
],
|
|
422
|
-
])
|
|
423
|
-
assert.match(snapshot, new RegExp(re, "m"), missing);
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
// The functions are worthless if nothing calls them, and a text-lift pin tests a
|
|
427
|
-
// COPY: it stays green while the feature disconnects. Pin the CALL SITES.
|
|
428
|
-
test("the specialist prompt interpolates the read rules", () => {
|
|
429
|
-
const prompt = slice("READ ONLY FROM THE SNAPSHOT", "Scratch files go in");
|
|
430
|
-
assert.match(prompt, /\$\{readRules\(usableDiff\(snap\), stats, snap\)\}/);
|
|
431
|
-
// `pr.diff` is a SIBLING of the snapshot tree, not a child of it — reading it
|
|
432
|
-
// under an unqualified "READ ONLY FROM THE SNAPSHOT" is the exact
|
|
433
|
-
// contradiction this branch's headline fix removes. Bound to the clause
|
|
434
|
-
// itself (the `)` closing the HEAD parenthetical, then the qualifier), not
|
|
435
|
-
// to "diff" appearing anywhere in the prompt: the `readRules` interpolation
|
|
436
|
-
// this same prompt carries contains "Diff" in its own text, so a
|
|
437
|
-
// presence-only check would stay green against a qualifier reading
|
|
438
|
-
// "— nothing else." — which restores the original contradiction outright.
|
|
439
|
-
// `\s+` between every word so a reflow of the same sentence stays green.
|
|
440
|
-
assert.match(
|
|
441
|
-
prompt,
|
|
442
|
-
/READ ONLY FROM THE SNAPSHOT:[\s\S]*?\)\s+—\s+plus\s+the\s+diff\s+file\s+named\s+below,\s+if\s+one\s+is\s+given\./,
|
|
443
|
-
"the SNAPSHOT permission is not qualified to admit the diff file named below — the sibling-file contradiction FIX-1 removed is back",
|
|
444
|
-
);
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
test("the refuter prompt interpolates the same read rules", () => {
|
|
448
|
-
const prompt = slice("Try to REFUTE this finding", "Scratch: ");
|
|
449
|
-
assert.match(prompt, /\$\{readRules\(usableDiff\(snap\), stats, snap\)\}/);
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
// Nothing pinned this line, and its own comment says the feature is unobservable
|
|
453
|
-
// without it: deleting the whole `log()` call left the repo-wide suite at
|
|
454
|
-
// 283/283. That is how it shipped stating a measurement never taken — the clause
|
|
455
|
-
// chain printed `diff is 0 lines` for an ABSENT `diffLines`, so a run where
|
|
456
|
-
// `gh pr diff` produced 500 real lines and only `wc -l` failed read as an empty
|
|
457
|
-
// PR and nobody looked at `wc`. Both deferred follow-ups in the spec read this
|
|
458
|
-
// line for their evidence. Shape from `select-dimensions.test.mjs`'s
|
|
459
|
-
// `reviewDispatchOptions`: match the call, then assert on what it prints.
|
|
460
|
-
test("the no-diff log reports the raw fields, not a guard it did not measure", () => {
|
|
461
|
-
const m = CODE.match(/^\s*log\(\n\s*usable[\s\S]*?^\s*\);$/m);
|
|
462
|
-
assert.ok(m, "the diff-decision log line is gone — `usableDiff` returning null forever is then invisible");
|
|
463
|
-
for (const field of ["diffPath", "diffLines", "refHead", "prHead"]) {
|
|
464
|
-
assert.match(
|
|
465
|
-
m[0],
|
|
466
|
-
new RegExp(`${field}=\\$\\{snap\\.${field}`),
|
|
467
|
-
`the no-diff log does not print raw ${field} — the reader cannot tell absent from zero`,
|
|
468
|
-
);
|
|
469
|
-
}
|
|
470
|
-
// The exact regression: a message asserting a count that was never reported.
|
|
471
|
-
assert.doesNotMatch(
|
|
472
|
-
m[0],
|
|
473
|
-
/diff is 0 lines/,
|
|
474
|
-
"an absent diffLines is reported as a measured 0 — a failed read and an empty read are indistinguishable again",
|
|
475
|
-
);
|
|
476
|
-
assert.match(m[0], /\(absent\)/, "an omitted field prints as empty rather than saying it was omitted");
|
|
477
|
-
});
|
|
478
|
-
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
// #1561. PR #1082 (#496) added two directory-safety rules to the
|
|
2
|
-
// (since-retired) `review-pr` WORKFLOW's refuter prompt — chain the
|
|
3
|
-
// directory change into the command, and bracket a fixture's own git with
|
|
4
|
-
// `git rev-parse --show-toplevel`. PR #1530 (#1084) separately added them to
|
|
5
|
-
// that same retired file's own SPECIALIST prompt, and PR #1559 (#1550)
|
|
6
|
-
// mirrored them into `review-core.mjs`'s own SPECIALIST prompt
|
|
7
|
-
// (review-core-specialist-scratch.test.mjs pins that copy). `review-core.mjs`
|
|
8
|
-
// carries a THIRD copy of the same rules' target risk in its own REFUTER
|
|
9
|
-
// prompt — "Verify against the snapshot ... by RUNNING
|
|
10
|
-
// something — compile it, run the test, apply the mutation" orders exactly
|
|
11
|
-
// the git-touching work the two rules exist to make safe — and carried
|
|
12
|
-
// neither rule, naming only a scratch path.
|
|
13
|
-
//
|
|
14
|
-
// Naming the scratch path is not the same rule and does not close either
|
|
15
|
-
// failure mode: a `cd` that silently fails leaves the following `;`-separated
|
|
16
|
-
// `git` running in whatever directory the agent was already in (the incident
|
|
17
|
-
// this file's own fixture records as commit 020d6ea, reached during
|
|
18
|
-
// the PR #488 fix-applier run), and an agent that BELIEVES it is already in
|
|
19
|
-
// its scratch copy and is wrong runs `git init` / `git commit` against the
|
|
20
|
-
// repository. Neither is caught by a sentence about where writes SHOULD go.
|
|
21
|
-
//
|
|
22
|
-
// INLINED, NOT SHARED, same as review-core-specialist-scratch.test.mjs's
|
|
23
|
-
// reasoning and for the same reason: #496's brief rules the shared-source
|
|
24
|
-
// route out, and this was a fourth distinct prompt block in this codebase
|
|
25
|
-
// (the retired review-workflow script's specialist, the retired
|
|
26
|
-
// review-workflow script's refuter, review-core.mjs's specialist, and this
|
|
27
|
-
// one — two of the four since retired along with that script itself), not
|
|
28
|
-
// an import target.
|
|
29
|
-
//
|
|
30
|
-
// WHY THIS PIN RENDERS RATHER THAN GREPS. The rules live inside a template
|
|
31
|
-
// literal with escaped backticks (`` \` ``); a source-text pin has to tolerate
|
|
32
|
-
// the backslash and then passes just as happily on a prompt that shows the
|
|
33
|
-
// refuter a literal `\` instead of a code span. Rendering settles what the
|
|
34
|
-
// agent actually reads.
|
|
35
|
-
//
|
|
36
|
-
// THE SLICE IS THE PIN. Both rules already exist in review-core.mjs's own
|
|
37
|
-
// SPECIALIST prompt, so a pin unbounded to the whole file would pass on that
|
|
38
|
-
// copy alone — exactly the defect this ticket reports, and exactly what
|
|
39
|
-
// "review-core.mjs's refuter prompt" must not be allowed to mean here. The
|
|
40
|
-
// extraction is bounded by the refuter `agent()` call's own template,
|
|
41
|
-
// opening at `Try to REFUTE this finding from PR #` and closing at its own
|
|
42
|
-
// `label: \`verify:`, so the specialist prompt sits entirely outside it by
|
|
43
|
-
// construction. Measured: reverting the two rules out of only the refuter
|
|
44
|
-
// prompt (leaving the specialist's copy untouched) reds both rule tests
|
|
45
|
-
// below.
|
|
46
|
-
//
|
|
47
|
-
// THE CEILING, same as review-core-specialist-scratch.test.mjs's: nothing
|
|
48
|
-
// here reaches the agent's own obedience. These pins settle what a refuter
|
|
49
|
-
// is TOLD, never where it actually writes.
|
|
50
|
-
import { test } from "node:test";
|
|
51
|
-
import assert from "node:assert/strict";
|
|
52
|
-
import { readFileSync } from "node:fs";
|
|
53
|
-
import { join } from "node:path";
|
|
54
|
-
import { stripComments } from "./strip-comments.mjs";
|
|
55
|
-
|
|
56
|
-
const REPO = join(import.meta.dirname, "..");
|
|
57
|
-
const SOURCE = readFileSync(join(REPO, "scripts", "review-core.mjs"), "utf8");
|
|
58
|
-
|
|
59
|
-
// Extraction runs against CODE, not SOURCE: a block-commented `agent(...)`
|
|
60
|
-
// call still contains the whole template, so extracting from raw source would
|
|
61
|
-
// render dead text and report every criterion satisfied — the vacuity class
|
|
62
|
-
// strip-comments.mjs exists for.
|
|
63
|
-
const CODE = stripComments(SOURCE);
|
|
64
|
-
|
|
65
|
-
const TEMPLATE_START = "`Try to REFUTE this finding from PR #";
|
|
66
|
-
const TEMPLATE_END = "{ label: `verify:";
|
|
67
|
-
|
|
68
|
-
// The template's free names, in the order `render` binds them. `readRules`
|
|
69
|
-
// and `usableDiff` are stubs: what they return is not under test here.
|
|
70
|
-
// `environmentNote` is bound for the same reason as the workflow's copy: a
|
|
71
|
-
// render that stops binding it throws a ReferenceError rather than dropping a
|
|
72
|
-
// paragraph silently.
|
|
73
|
-
const SCOPE = ["pr", "f", "snap", "stats", "d", "i", "fi", "readRules", "usableDiff", "environmentNote"];
|
|
74
|
-
|
|
75
|
-
function refuterTemplate() {
|
|
76
|
-
const start = CODE.indexOf(TEMPLATE_START);
|
|
77
|
-
assert.notEqual(
|
|
78
|
-
start,
|
|
79
|
-
-1,
|
|
80
|
-
"review-core.mjs no longer builds a refuter prompt opening `Try to REFUTE this finding from PR #` — " +
|
|
81
|
-
"either it was renamed, or the whole verify fan-out is commented out. Update this test, or restore the prompt.",
|
|
82
|
-
);
|
|
83
|
-
const end = CODE.indexOf(TEMPLATE_END, start);
|
|
84
|
-
assert.notEqual(end, -1, "the refuter agent() call no longer carries a `verify:` label after its prompt — update this test");
|
|
85
|
-
const slice = CODE.slice(start, end);
|
|
86
|
-
return slice.slice(1, slice.lastIndexOf("`"));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const RENDER = new Function(...SCOPE, "return `" + refuterTemplate() + "`");
|
|
90
|
-
|
|
91
|
-
// One refuter's prompt. Every argument is fixed: these pins are about what the
|
|
92
|
-
// prompt SAYS, not about how it varies, so nothing here needs to.
|
|
93
|
-
const render = () =>
|
|
94
|
-
RENDER(
|
|
95
|
-
7,
|
|
96
|
-
{ claim: "the guard fails open", file: "a.js", line: 12, evidence: "line 12 has no else" },
|
|
97
|
-
{ path: "/scr/run-1/snapshot-abc1234", head: "abc1234", runRoot: "/scr/run-1" },
|
|
98
|
-
null,
|
|
99
|
-
{ key: "correctness" },
|
|
100
|
-
0,
|
|
101
|
-
0,
|
|
102
|
-
() => "READ RULES",
|
|
103
|
-
() => null,
|
|
104
|
-
() => "TEST ENVIRONMENT",
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
// The first rule. ONE contiguous regex rather than two assertions. Both gaps
|
|
108
|
-
// are the literal punctuation the rendered prompt carries around "never"
|
|
109
|
-
// ("…`, " before it, a line break plus backtick after) rather than a
|
|
110
|
-
// free-text `.{0,N}` span — mutation-tested: splicing "never except in dry
|
|
111
|
-
// runs" into the first gap reds this assertion, where an earlier
|
|
112
|
-
// `.{0,60}`-gapped version of this same regex does not catch that splice.
|
|
113
|
-
test("the rendered refuter prompt chains cd into the git command, never semicolon", () => {
|
|
114
|
-
assert.match(
|
|
115
|
-
render(),
|
|
116
|
-
/cd\s+"\$D"\s+&&\s+git\s+…`,\s+never\s+`cd\s+"\$D";\s+git\s+…/s,
|
|
117
|
-
"review-core.mjs's refuter prompt carries no cd-chaining rule — a silently failed `cd` leaves the following `git` " +
|
|
118
|
-
"running in the checkout, which is what produced commit 020d6ea during the PR #488 fix-applier run (#1561)",
|
|
119
|
-
);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// The second rule. Both halves, because they have OPPOSITE expected outcomes:
|
|
123
|
-
// a lone "resolves to your scratch path" guard is unsatisfiable before `git
|
|
124
|
-
// init` — a fresh scratch dir has no toplevel and exits 128 — and a guard that
|
|
125
|
-
// cannot pass on the clean path gets ignored. Naming a path alone does not
|
|
126
|
-
// catch the observed failure either, which was an agent BELIEVING it was
|
|
127
|
-
// already in scratch and being wrong.
|
|
128
|
-
test("the rendered refuter prompt requires a toplevel assertion around git init/commit, including the realpath remedy for macOS's /private/tmp symlink", () => {
|
|
129
|
-
assert.match(
|
|
130
|
-
render(),
|
|
131
|
-
/`git\s+rev-parse\s+--show-toplevel`:\s+before\s+`git\s+init`\s+it\s+must\s+NOT\s+resolve\s+to\s+the\s+repository,\s+and\s+a\s+fresh\s+scratch\s+dir's\s+`fatal:\s+not\s+a\s+git\s+repository`\s+\(exit\s+128\)\s+is\s+the\s+pass,\s+not\s+a\s+failure;\s+before\s+any\s+`git\s+commit`\s+it\s+must\s+resolve\s+to\s+your\s+scratch\s+path\s+—\s+compare\s+resolved\s+forms\s+\(`realpath`\),\s+since\s+`--show-toplevel`\s+can\s+report\s+`\/private\/tmp\/…`\s+for\s+a\s+`\/tmp`\s+scratch\s+dir\s+on\s+macOS/s,
|
|
132
|
-
"review-core.mjs's refuter prompt carries no toplevel assertion around a fixture's own git init/commit, or dropped the " +
|
|
133
|
-
"realpath remedy for macOS's /private vs /tmp symlink (#1561)",
|
|
134
|
-
);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// The other direction: a prompt that GAINS rules can displace what orders the
|
|
138
|
-
// real run those rules exist to make safe. A refuter's whole job is to run
|
|
139
|
-
// something against the snapshot; the two added rules must not read as
|
|
140
|
-
// forbidding that entirely.
|
|
141
|
-
test("the rendered refuter prompt still orders a real run against the snapshot", () => {
|
|
142
|
-
assert.match(
|
|
143
|
-
render(),
|
|
144
|
-
/Verify against the snapshot .* by RUNNING something/s,
|
|
145
|
-
"review-core.mjs's refuter prompt no longer orders a real run against the snapshot — adding the two directory-safety " +
|
|
146
|
-
"rules must not displace the instruction they exist to make safe",
|
|
147
|
-
);
|
|
148
|
-
});
|