@feigi/fleet-ctl 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +9 -0
- package/LICENSE +202 -0
- package/NOTICE +18 -0
- package/agents/fleet-finisher.agent.md +7 -0
- package/agents/fleet-implementer-alt.agent.md +210 -0
- package/agents/fleet-implementer.agent.md +210 -0
- package/agents/fleet-merge-bot.agent.md +7 -0
- package/agents/fleet-review-comments.agent.md +40 -0
- package/agents/fleet-review-correctness.agent.md +43 -0
- package/agents/fleet-review-runner.agent.md +73 -0
- package/agents/fleet-review-silent-failure.agent.md +49 -0
- package/agents/fleet-review-simplify.agent.md +46 -0
- package/agents/fleet-review-snapshot.agent.md +24 -0
- package/agents/fleet-review-tests.agent.md +46 -0
- package/agents/fleet-review-types.agent.md +41 -0
- package/agents/fleet-review-verifier.agent.md +29 -0
- package/commands/review-and-fix.md +98 -0
- package/commands/run-merge-bot.md +357 -0
- package/commands/run-team-help.md +17 -0
- package/package.json +23 -0
- package/scripts/agent-test-dir-prose.test.mjs +59 -0
- package/scripts/agent-test.test.mjs +1636 -0
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +354 -0
- package/scripts/ambient-git-vars-prose.test.mjs +192 -0
- package/scripts/ancestry-check-position-prose.test.mjs +175 -0
- package/scripts/apply-ruleset.test.mjs +420 -0
- package/scripts/arg-header-probes-prose.test.mjs +393 -0
- package/scripts/arg.mjs +600 -0
- package/scripts/arg.test.mjs +1354 -0
- package/scripts/board-cli.test.mjs +694 -0
- package/scripts/board-identity.test.mjs +429 -0
- package/scripts/board-liveness-banner.test.mjs +119 -0
- package/scripts/board-prev-shape.test.mjs +229 -0
- package/scripts/board-tryparse-null.test.mjs +119 -0
- package/scripts/board.html +471 -0
- package/scripts/board.mjs +2037 -0
- package/scripts/board.test.mjs +3086 -0
- package/scripts/brief-after-cut-prose.test.mjs +53 -0
- package/scripts/candidates-exit3-prose.test.mjs +302 -0
- package/scripts/candidates.mjs +674 -0
- package/scripts/candidates.test.mjs +2101 -0
- package/scripts/caveat-unification-prose.test.mjs +98 -0
- package/scripts/ci-comment-rot-prose.test.mjs +2025 -0
- package/scripts/ci-completes-premise-prose.test.mjs +257 -0
- package/scripts/ci-state-prose.test.mjs +113 -0
- package/scripts/ci-state.mjs +761 -0
- package/scripts/ci-state.test.mjs +1640 -0
- package/scripts/ci-vacuous-green.test.mjs +368 -0
- package/scripts/citation-sweep-prose.test.mjs +1572 -0
- package/scripts/claim-lifecycle.test.mjs +185 -0
- package/scripts/claim-ticket.sh +417 -0
- package/scripts/claim-ticket.test.mjs +1121 -0
- package/scripts/closing-keyword-prose.test.mjs +193 -0
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +165 -0
- package/scripts/cockpit-tick-nonblocking.test.mjs +210 -0
- package/scripts/compute-board.mjs +579 -0
- package/scripts/compute-board.test.mjs +1060 -0
- package/scripts/compute-spend.mjs +329 -0
- package/scripts/compute-spend.test.mjs +451 -0
- package/scripts/cross-repo-citation-prose.test.mjs +156 -0
- package/scripts/cwd-isolation-pins.mjs +83 -0
- package/scripts/dedupe-guard-prose.test.mjs +243 -0
- package/scripts/derive-testcmd.sh +239 -0
- package/scripts/derive-testcmd.test.mjs +380 -0
- package/scripts/diff-stats.mjs +231 -0
- package/scripts/diff-stats.test.mjs +408 -0
- package/scripts/dispatch-block-golden-prose.test.mjs +1024 -0
- package/scripts/dispatch-block-pins-prose.test.mjs +615 -0
- package/scripts/drop-merged-label.sh +173 -0
- package/scripts/drop-merged-label.test.mjs +480 -0
- package/scripts/expected-jobs-prose.test.mjs +80 -0
- package/scripts/filing-bar-seat-prose.test.mjs +242 -0
- package/scripts/filing-claim-bar-prose.test.mjs +166 -0
- package/scripts/finisher-dispatch-premise-prose.test.mjs +312 -0
- package/scripts/finisher-halt-prose.test.mjs +106 -0
- package/scripts/finisher-name-prose.test.mjs +134 -0
- package/scripts/finisher-own-tree-prose.test.mjs +285 -0
- package/scripts/finisher-pin-race-prose.test.mjs +339 -0
- package/scripts/fix-applier-correction-rules-prose.test.mjs +201 -0
- package/scripts/fix-applier-result-file-prose.test.mjs +100 -0
- package/scripts/fleet-bootstrap +155 -0
- package/scripts/fleet-heartbeat.mjs +272 -0
- package/scripts/fleet-heartbeat.test.mjs +450 -0
- package/scripts/fleet-provenance +207 -0
- package/scripts/fleet-provenance.test.mjs +64 -0
- package/scripts/fleet-run +148 -0
- package/scripts/fleet-run.test.mjs +90 -0
- package/scripts/fleet-state.mjs +400 -0
- package/scripts/fleet-state.test.mjs +373 -0
- package/scripts/fleet-tick-prose.test.mjs +299 -0
- package/scripts/fleet-tick.mjs +832 -0
- package/scripts/fleet-tick.test.mjs +1332 -0
- package/scripts/force-with-lease-reason-prose.test.mjs +184 -0
- package/scripts/frontmatter-allowlist.json +64 -0
- package/scripts/frontmatter-check.mjs +256 -0
- package/scripts/frontmatter-check.test.mjs +436 -0
- package/scripts/git-env.mjs +124 -0
- package/scripts/git-env.test.mjs +149 -0
- package/scripts/git-status-untracked-mode-sweep.test.mjs +216 -0
- package/scripts/gone-walk.test.mjs +213 -0
- package/scripts/gp-sep-invariant-prose.test.mjs +188 -0
- package/scripts/head-moved-after-label-prose.test.mjs +233 -0
- package/scripts/immutable-body-claim-prose.test.mjs +413 -0
- package/scripts/implementer-model-tier.test.mjs +643 -0
- package/scripts/inflight-citation-prose.test.mjs +144 -0
- package/scripts/inflight-exit2-prose.test.mjs +81 -0
- package/scripts/inflight-probe-guard-prose.test.mjs +109 -0
- package/scripts/inflight-scan-scope-prose.test.mjs +57 -0
- package/scripts/inflight.sh +1106 -0
- package/scripts/inflight.test.mjs +2984 -0
- package/scripts/injection-control-prose.test.mjs +404 -0
- package/scripts/install-root-audit.test.mjs +464 -0
- package/scripts/instrument-check-prose.test.mjs +235 -0
- package/scripts/instruments.sh +394 -0
- package/scripts/instruments.test.mjs +787 -0
- package/scripts/issue-tracker-prose.test.mjs +71 -0
- package/scripts/json.sh +248 -0
- package/scripts/json.test.mjs +364 -0
- package/scripts/ledger-dispatch.test.mjs +516 -0
- package/scripts/ledger-grammar.mjs +85 -0
- package/scripts/ledger-grammar.test.mjs +142 -0
- package/scripts/ledger-read-require-file.test.mjs +197 -0
- package/scripts/ledger.mjs +1753 -0
- package/scripts/ledger.test.mjs +3554 -0
- package/scripts/line-distance-prose.test.mjs +245 -0
- package/scripts/liveness-rationale-prose.test.mjs +83 -0
- package/scripts/locale-pin-prose.test.mjs +189 -0
- package/scripts/member-outcome-prose.test.mjs +167 -0
- package/scripts/member-outcomes-header.test.mjs +148 -0
- package/scripts/member-outcomes-prose.test.mjs +63 -0
- package/scripts/member-outcomes.mjs +231 -0
- package/scripts/member-outcomes.test.mjs +507 -0
- package/scripts/member-prompt-prose.test.mjs +161 -0
- package/scripts/member-record.mjs +605 -0
- package/scripts/member-record.test.mjs +516 -0
- package/scripts/member-write-guard.mjs +279 -0
- package/scripts/member-write-guard.test.mjs +211 -0
- package/scripts/merge-commit-probe-prose.test.mjs +122 -0
- package/scripts/merge-gate.mjs +262 -0
- package/scripts/merge-gate.test.mjs +613 -0
- package/scripts/muted-git-guard-sweep.test.mjs +493 -0
- package/scripts/net-ssh-precedence-prose.test.mjs +91 -0
- package/scripts/net-watchdog-prose.test.mjs +79 -0
- package/scripts/net.sh +409 -0
- package/scripts/net.test.mjs +211 -0
- package/scripts/no-ci-gate-prose.test.mjs +108 -0
- package/scripts/no-undo-audit.sh +1134 -0
- package/scripts/no-undo-audit.test.mjs +3965 -0
- package/scripts/no-wave.test.mjs +138 -0
- package/scripts/node-floor-sweep.test.mjs +611 -0
- package/scripts/pointer-target-prose.test.mjs +186 -0
- package/scripts/pr-overlap.mjs +417 -0
- package/scripts/pr-overlap.test.mjs +695 -0
- package/scripts/printf-die-sweep.test.mjs +384 -0
- package/scripts/prompt-renderer.mjs +39 -0
- package/scripts/prompt-renderer.test.mjs +68 -0
- package/scripts/prose-pin.mjs +808 -0
- package/scripts/prose-pin.test.mjs +1034 -0
- package/scripts/prove-merge.sh +228 -0
- package/scripts/prove-merge.test.mjs +995 -0
- package/scripts/pull-table-relabel-prose.test.mjs +60 -0
- package/scripts/quiet-payload-prose.test.mjs +222 -0
- package/scripts/reap.sh +1768 -0
- package/scripts/reap.test.mjs +4395 -0
- package/scripts/reaping-prose.test.mjs +159 -0
- package/scripts/refuter-scratch-prose.test.mjs +135 -0
- package/scripts/release-label-required-prose.test.mjs +71 -0
- package/scripts/release-label-split-prose.test.mjs +169 -0
- package/scripts/release-ticket.sh +1716 -0
- package/scripts/release-ticket.test.mjs +5106 -0
- package/scripts/renovate-release-contract.test.mjs +379 -0
- package/scripts/repo-root.mjs +544 -0
- package/scripts/repo-root.test.mjs +873 -0
- package/scripts/reporter-output-rule-prose.test.mjs +208 -0
- package/scripts/review-agent-report-only.test.mjs +49 -0
- package/scripts/review-core-cwd-isolation.test.mjs +374 -0
- package/scripts/review-core-reads.test.mjs +478 -0
- package/scripts/review-core-refuter-scratch.test.mjs +148 -0
- package/scripts/review-core-snapshot-path.test.mjs +777 -0
- package/scripts/review-core-specialist-scratch.test.mjs +189 -0
- package/scripts/review-core-testcmd.test.mjs +288 -0
- package/scripts/review-core-unrun.test.mjs +530 -0
- package/scripts/review-core-unverified-discriminant.test.mjs +208 -0
- package/scripts/review-core.mjs +1028 -0
- package/scripts/review-eval-resolver-path.test.mjs +55 -0
- package/scripts/review-eval.mjs +197 -0
- package/scripts/review-host-fixture.mjs +73 -0
- package/scripts/review-in-run-retry.test.mjs +187 -0
- package/scripts/review-no-vendor-dispatch.test.mjs +45 -0
- package/scripts/review-path-default.test.mjs +796 -0
- package/scripts/review-runner-spawns.test.mjs +93 -0
- package/scripts/review-runner.test.mjs +155 -0
- package/scripts/review-tier-audit.test.mjs +140 -0
- package/scripts/run-artifact-pr-prose.test.mjs +341 -0
- package/scripts/run-merge-bot-prose.test.mjs +1391 -0
- package/scripts/scratch-partition-invariant-prose.test.mjs +74 -0
- package/scripts/scripts-path-citation-sweep.test.mjs +73 -0
- package/scripts/section-between-guard-prose.test.mjs +378 -0
- package/scripts/select-dimensions.test.mjs +674 -0
- package/scripts/shared-refusal.test.mjs +388 -0
- package/scripts/shell-traps-prose.test.mjs +507 -0
- package/scripts/shortlist.mjs +355 -0
- package/scripts/shortlist.test.mjs +366 -0
- package/scripts/slow-transport.mjs +72 -0
- package/scripts/snapshot-repo.test.mjs +772 -0
- package/scripts/snapshot-runner-audience-prose.test.mjs +129 -0
- package/scripts/spend-view.test.mjs +312 -0
- package/scripts/staleness-qualifier-prose.test.mjs +251 -0
- package/scripts/staleness-verdict-prose.test.mjs +142 -0
- package/scripts/staleness.mjs +414 -0
- package/scripts/staleness.test.mjs +893 -0
- package/scripts/stalled-member-liveness-prose.test.mjs +219 -0
- package/scripts/stash-prohibition-prose.test.mjs +313 -0
- package/scripts/strip-comments.mjs +44 -0
- package/scripts/tier-check.mjs +468 -0
- package/scripts/tier-check.test.mjs +726 -0
- package/scripts/tier-guard-gate-prose.test.mjs +216 -0
- package/scripts/tier-outcomes-header.test.mjs +586 -0
- package/scripts/tier-outcomes.mjs +441 -0
- package/scripts/tier-outcomes.test.mjs +342 -0
- package/scripts/tier-roles.mjs +250 -0
- package/scripts/tier-roles.test.mjs +316 -0
- package/scripts/tracker-block-copy-prose.test.mjs +288 -0
- package/scripts/triage-labels-gloss-prose.test.mjs +97 -0
- package/scripts/unattended-git-sweep.test.mjs +142 -0
- package/scripts/verify-sha-exit2-prose.test.mjs +269 -0
- package/scripts/verify-sha.sh +117 -0
- package/scripts/verify-sha.test.mjs +693 -0
- package/scripts/watcher-degraded-block.test.mjs +372 -0
- package/scripts/watcher-key-prose.test.mjs +106 -0
- package/scripts/within-run-pair-prose.test.mjs +208 -0
- package/scripts/worktree-audit.sh +482 -0
- package/scripts/worktree-audit.test.mjs +1407 -0
- package/scripts/worktree-head-prose.test.mjs +276 -0
- package/scripts/worktree-listing-sweep.test.mjs +217 -0
- package/scripts/worktree-model-prose.test.mjs +216 -0
- package/scripts/worktree.sh +470 -0
- package/skills/next-ticket/SKILL.md +138 -0
- package/skills/run-team/SKILL.md +3603 -0
- package/skills/run-team/references/ci-and-staleness.md +75 -0
- package/skills/run-team/references/correction-tickets.md +37 -0
- package/skills/run-team/references/isolation.md +23 -0
- package/skills/run-team/references/member-lifecycle.md +73 -0
- package/skills/run-team/references/reaping.md +73 -0
- package/skills/sizing-a-ticket/SKILL.md +39 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// #503. The refuter prompt orders a verification RUN and never said how to
|
|
2
|
+
// observe it. Measured: refuters independently reach for
|
|
3
|
+
// `until grep -q "<marker>" <log>; do sleep N`, and one waited on the tap `#`
|
|
4
|
+
// prefix while node wrote the spec one, so the marker could never appear and
|
|
5
|
+
// the loop was infinite — the transcript froze and the finding went unchecked.
|
|
6
|
+
//
|
|
7
|
+
// Accepting both prefixes is necessary but NOT sufficient, which is why the
|
|
8
|
+
// prefix pin and the SGR pin below are ONE span and not two. Measured on
|
|
9
|
+
// node v26.7.0, `node --test` against a three-test file, piped through `cat -v`:
|
|
10
|
+
//
|
|
11
|
+
// env -u FORCE_COLOR -> "ℹ pass 3"
|
|
12
|
+
// FORCE_COLOR=1 -> "\x1b[34mℹ pass 3\x1b[39m"
|
|
13
|
+
// env FORCE_COLOR= -> "\x1b[34mℹ pass 3\x1b[39m" <- NOT a control
|
|
14
|
+
// script -q /dev/null -> "\x1b[34mℹ pass 3\x1b[39m" <- a TTY colors too
|
|
15
|
+
//
|
|
16
|
+
// The colored line begins with ESC, so an anchor on either prefix matches
|
|
17
|
+
// nothing and returns empty at exit 0 — the same shape as a hung run and as a
|
|
18
|
+
// zero-test run. That is why `env -u FORCE_COLOR` is pinned as the control:
|
|
19
|
+
// `FORCE_COLOR=` empty colors identically to `FORCE_COLOR=1`, so a baseline
|
|
20
|
+
// taken with it silently is not a baseline.
|
|
21
|
+
//
|
|
22
|
+
// THE TAP PREFIX WAS NOT REPRODUCED AS A DEFAULT. Only node v26.7.0 is
|
|
23
|
+
// installed here and it emits the spec prefix even when piped, so the `#`
|
|
24
|
+
// form was only observed under an explicit `--test-reporter=tap`. The rule is
|
|
25
|
+
// therefore written to be SAFE under a prefix this machine cannot produce
|
|
26
|
+
// rather than asserting what was not measured — which is also why it demands
|
|
27
|
+
// SGR stripping instead of a wider prefix alternation.
|
|
28
|
+
//
|
|
29
|
+
// All THREE live dispatch sites are pinned, not the two the ticket counted:
|
|
30
|
+
// `grep -rn 'Try to REFUTE this finding'` finds the instruction quoted
|
|
31
|
+
// verbatim in run-team/SKILL.md's fix-applier block, in review-and-fix.md
|
|
32
|
+
// step 2, and in review-core.mjs's own prompt.
|
|
33
|
+
// refuter-scratch-prose.test.mjs already ruled the reason — "a fix added to
|
|
34
|
+
// only one is the one that does not reach whichever path a given caller
|
|
35
|
+
// takes".
|
|
36
|
+
//
|
|
37
|
+
// THE CEILING, same as refuter-scratch-prose.test.mjs: these are PRESENCE pins
|
|
38
|
+
// over a bounded slice, each a single regex. Every join is `\s+` and no pin
|
|
39
|
+
// carries a `.{0,N}` gap, because a bounded gap is not a join — it is slack,
|
|
40
|
+
// and slack holds a sentence. Measured: the earlier `.{0,200}` gap between the
|
|
41
|
+
// poll ban and its carve-out bridged 107 characters of real prose, so
|
|
42
|
+
// substituting a sentence that reinstates polling for that prose kept all
|
|
43
|
+
// three sites green. A splice inside a `\s+`-joined span cannot: it has
|
|
44
|
+
// nowhere to land. What a presence pin still cannot catch is a whole new
|
|
45
|
+
// sentence appended AFTER the span carving out an exception — that is what the
|
|
46
|
+
// negative pin at the bottom of this file is for, and why it bans the wait
|
|
47
|
+
// vocabulary rather than three literal idioms. A reflow stays green by design:
|
|
48
|
+
// the words are pinned, not their layout.
|
|
49
|
+
import { test } from "node:test";
|
|
50
|
+
import assert from "node:assert/strict";
|
|
51
|
+
import { readFileSync } from "node:fs";
|
|
52
|
+
import { join } from "node:path";
|
|
53
|
+
import { between } from "./prose-pin.mjs";
|
|
54
|
+
|
|
55
|
+
const REPO = join(import.meta.dirname, "..");
|
|
56
|
+
const read = (...p) => readFileSync(join(REPO, ...p), "utf8");
|
|
57
|
+
|
|
58
|
+
// Two source shapes reach these regexes. run-team/SKILL.md's copy sits in a
|
|
59
|
+
// nested `> > ` blockquote, so a hard wrap lands with the quote gutter — not
|
|
60
|
+
// whitespace — at the break, and `\s+` does not span `>`. review-core.mjs's copy
|
|
61
|
+
// is inside a template literal, so every backtick in it is BACKSLASH-ESCAPED
|
|
62
|
+
// in the source text; unescape them or every pin naming a code span fails on
|
|
63
|
+
// that file alone. Both normalizations are harmless on review-and-fix.md.
|
|
64
|
+
const norm = (text) =>
|
|
65
|
+
text
|
|
66
|
+
.split("\n")
|
|
67
|
+
.map((l) => l.replace(/^(>\s?)+/, ""))
|
|
68
|
+
.join(" ")
|
|
69
|
+
.replace(/\\`/g, "`");
|
|
70
|
+
|
|
71
|
+
const SITES = [
|
|
72
|
+
[
|
|
73
|
+
"run-team/SKILL.md",
|
|
74
|
+
() =>
|
|
75
|
+
norm(
|
|
76
|
+
between(
|
|
77
|
+
read("skills", "run-team", "SKILL.md"),
|
|
78
|
+
"Try to REFUTE this finding",
|
|
79
|
+
"Survives → apply it, with one hold",
|
|
80
|
+
"run-team/SKILL.md",
|
|
81
|
+
),
|
|
82
|
+
),
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
"review-and-fix.md",
|
|
86
|
+
() =>
|
|
87
|
+
norm(
|
|
88
|
+
between(
|
|
89
|
+
read("commands", "review-and-fix.md"),
|
|
90
|
+
"Try to REFUTE this finding",
|
|
91
|
+
"That last clause is the whole mechanism",
|
|
92
|
+
"review-and-fix.md",
|
|
93
|
+
),
|
|
94
|
+
),
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
"review-core.mjs",
|
|
98
|
+
() =>
|
|
99
|
+
norm(
|
|
100
|
+
between(
|
|
101
|
+
read("scripts", "review-core.mjs"),
|
|
102
|
+
"Try to REFUTE this finding",
|
|
103
|
+
"Scratch: ",
|
|
104
|
+
"review-core.mjs",
|
|
105
|
+
),
|
|
106
|
+
),
|
|
107
|
+
],
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
for (const [name, getPrompt] of SITES) {
|
|
111
|
+
// ONE span from the exit-code rule through the poll ban to the carve-out,
|
|
112
|
+
// joined by `\s+` and nothing wider. Split into separate assertions — or
|
|
113
|
+
// joined by a `.{0,N}` gap, which is the same thing with extra steps — these
|
|
114
|
+
// would let a sentence reinstating a wait loop sit between them and stay
|
|
115
|
+
// green; that is the splice defect refuter-scratch-prose.test.mjs pins
|
|
116
|
+
// against, and it was measured live on all three sites here before this span
|
|
117
|
+
// was closed. The middle clause is therefore pinned, not skipped over. The
|
|
118
|
+
// carve-out rides in the same span deliberately: a poll ban with no statement
|
|
119
|
+
// of what a refuter MAY still do reads as a ban on reading logs at all, and a
|
|
120
|
+
// refuter that cannot read a finished log cannot verify anything.
|
|
121
|
+
test(`${name}: refuter observes a run synchronously by exit code, never by polling a log`, () => {
|
|
122
|
+
assert.match(
|
|
123
|
+
getPrompt(),
|
|
124
|
+
/run\s+the\s+command,\s+wait\s+for\s+it,\s+read\s+its\s+exit\s+code\.\s+Never\s+poll\s+a\s+log\s+file\s+for\s+a\s+completion\s+marker:\s+prefer\s+ONE\s+blocking\s+run\s+to\s+a\s+poll\s+loop,\s+and\s+treat\s+its\s+return\s+as\s+permission\s+to\s+look,\s+never\s+as\s+the\s+answer\.\s+Reading\s+a\s+log\s+the\s+run\s+has\s+already\s+finished\s+writing\s+is\s+fine/,
|
|
125
|
+
"the synchronous-observation rule is broken — either the exit-code rule is gone, or the poll ban is gone (a refuter reaches for `until grep <marker>` and wedges forever on a marker that can never appear), or the clause preferring one blocking run is gone, or the carve-out permitting a finished log is gone, or a sentence was spliced between them reinstating a wait",
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Both halves in ONE span, because either alone is the measured defect: the
|
|
130
|
+
// dual-prefix matcher `grep -E "^(ℹ|#) fail"` is exactly what a colored run
|
|
131
|
+
// defeats, and SGR stripping without both prefixes false-refuses on a node
|
|
132
|
+
// whose default reporter differs.
|
|
133
|
+
test(`${name}: a reporter-output matcher needs both prefixes AND SGR stripping, neither alone`, () => {
|
|
134
|
+
assert.match(
|
|
135
|
+
getPrompt(),
|
|
136
|
+
/accepting\s+both\s+`ℹ`\s+and\s+`#`\s+is\s+necessary\s+but\s+NOT\s+sufficient\s+—\s+strip\s+SGR\s+escapes\s+first/,
|
|
137
|
+
"the reporter-matching rule lost a half — dual prefixes alone is the matcher a colored run was MEASURED to defeat (the line begins with ESC, so no prefix anchor matches and the result is empty at exit 0, indistinguishable from a hung run), and SGR stripping alone false-refuses across node versions",
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// The control, and why it is one. Pinned as a span with the refutation
|
|
142
|
+
// attached: `env -u FORCE_COLOR` on its own invites the `FORCE_COLOR=`
|
|
143
|
+
// spelling back, which colors identically and silently is not a baseline.
|
|
144
|
+
test(`${name}: the uncolored baseline is env -u FORCE_COLOR, and says why the empty spelling is not`, () => {
|
|
145
|
+
assert.match(
|
|
146
|
+
getPrompt(),
|
|
147
|
+
/`env\s+-u\s+FORCE_COLOR`;\s+`FORCE_COLOR=`\s+empty\s+still\s+enables\s+color,\s+so\s+it\s+is\s+not\s+a\s+control/,
|
|
148
|
+
"the baseline control is broken — an `env FORCE_COLOR= ...` baseline is colored, so every comparison run against it is invalid, and dropping the reason is what lets the wrong spelling come back",
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// Both clauses in one span, `\s+`-joined: a scope-only rule was measured to
|
|
153
|
+
// catch one of the two refuted negative claims and NOT the other, whose scope
|
|
154
|
+
// was stated accurately and was still the wrong scope for the claim. The two
|
|
155
|
+
// `.{0,160}` gaps this span used to carry bridged 3 and 27 characters of real
|
|
156
|
+
// text, so each held room for a sentence retracting the rule between its own
|
|
157
|
+
// halves.
|
|
158
|
+
test(`${name}: a negative claim states its search scope AND what the pattern would have missed`, () => {
|
|
159
|
+
assert.match(
|
|
160
|
+
getPrompt(),
|
|
161
|
+
/State\s+your\s+search\s+scope\s+AND\s+what\s+your\s+pattern\s+would\s+have\s+missed\.\s+A\s+grep\s+over\s+one\s+ref\s+does\s+not\s+support\s+a\s+claim\s+about\s+history;\s+a\s+pattern\s+built\s+from\s+the\s+token\s+a\s+diff\s+removed\s+does\s+not\s+support\s+a\s+claim\s+that\s+the\s+category\s+is\s+empty/,
|
|
162
|
+
"the negative-claim rule lost a half — stating scope alone does not catch a pattern built from the token a diff removed, which was the measured second refutation",
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// The acceptance criterion is that a wait appears nowhere as endorsement. A
|
|
167
|
+
// presence pin cannot express that; this is the negative half, and it must
|
|
168
|
+
// fire regardless of SPELLING — the sentence measured to defeat the old pins
|
|
169
|
+
// ("poll the log until the marker appears") contains none of the three shell
|
|
170
|
+
// idioms the ban used to enumerate. So ban the vocabulary instead, after
|
|
171
|
+
// removing the rule's own two sanctioned mentions of polling. Removing them
|
|
172
|
+
// hides nothing: both are inside the `\s+`-joined span the first test pins
|
|
173
|
+
// verbatim, so deleting or rewording either reddens there first. `replace` is
|
|
174
|
+
// deliberately non-global — a SECOND "poll" is exactly what this catches.
|
|
175
|
+
test(`${name}: the refuter prompt never spells a wait on a log as something to do`, () => {
|
|
176
|
+
const rest = getPrompt()
|
|
177
|
+
.replace(/Never\s+poll\s+a\s+log\s+file\s+for\s+a\s+completion\s+marker/, "")
|
|
178
|
+
.replace(/prefer\s+ONE\s+blocking\s+run\s+to\s+a\s+poll\s+loop/, "");
|
|
179
|
+
assert.doesNotMatch(
|
|
180
|
+
rest,
|
|
181
|
+
/poll|sleep|tail\s+-f|while\s+!|watch(?:ing)?\s+the\s+log|until\s+\S+\s+(?:appears|shows|exists|is\s+written)/i,
|
|
182
|
+
"the refuter prompt now spells a wait on a log — the idiom this brief exists to ban reads as endorsement wherever it appears in an instruction handed to an agent verbatim, and a reinstatement does not have to reuse the brief's own words to be one",
|
|
183
|
+
);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Every slice above starts at the same anchor, and `between()` takes the FIRST
|
|
188
|
+
// match — by contract, pinned in prose-pin.test.mjs, so the guard cannot go
|
|
189
|
+
// there. Measured on a copy: a partial quote planted earlier is harmless (it
|
|
190
|
+
// either reds on the `to` anchor or widens the slice into a superset that still
|
|
191
|
+
// catches drift), but a VERBATIM copy of the whole pinned span planted earlier
|
|
192
|
+
// silently retargets every pin at the copy, and real drift in the live prompt
|
|
193
|
+
// goes green on all three sites. The anchor is shared with
|
|
194
|
+
// refuter-scratch-prose.test.mjs and review-core-reads.test.mjs, so this one
|
|
195
|
+
// guard covers their slices too.
|
|
196
|
+
for (const [name, ...p] of [
|
|
197
|
+
["run-team/SKILL.md", "skills", "run-team", "SKILL.md"],
|
|
198
|
+
["review-and-fix.md", "commands", "review-and-fix.md"],
|
|
199
|
+
["review-core.mjs", "scripts", "review-core.mjs"],
|
|
200
|
+
]) {
|
|
201
|
+
test(`${name}: the refuter-prompt slice anchor occurs exactly once`, () => {
|
|
202
|
+
assert.equal(
|
|
203
|
+
read(...p).split("Try to REFUTE this finding").length - 1,
|
|
204
|
+
1,
|
|
205
|
+
`${name} contains "Try to REFUTE this finding" more than once — every pin over this file slices from the FIRST occurrence, so a second copy silently moves what they check away from the live prompt`,
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
|
|
6
|
+
// Review finding on #1349's PR (#1361): "Say read-only" in
|
|
7
|
+
// commands/review-and-fix.md was scoped to a false premise — NONE of the
|
|
8
|
+
// six `fleet-review-*` specialist definitions restricts tool access in its
|
|
9
|
+
// frontmatter (a `.agent.md` prompt saying "report only" is instruction, not
|
|
10
|
+
// enforcement), so a hand-dispatched agent, named or general-purpose, always
|
|
11
|
+
// carries write tools it must not use. Fixed there (the rule is
|
|
12
|
+
// unconditional again); this pins the OTHER half — every one of the six
|
|
13
|
+
// review-dimension prompts states the constraint explicitly, so a reader of
|
|
14
|
+
// the prompt alone (not just the command doc) sees it too.
|
|
15
|
+
const REPO = join(import.meta.dirname, "..");
|
|
16
|
+
const SPECIALISTS = ["correctness", "silent-failure", "tests", "comments", "types", "simplify"];
|
|
17
|
+
|
|
18
|
+
for (const key of SPECIALISTS) {
|
|
19
|
+
test(`fleet-review-${key}.agent.md states report-only, never edit/commit/push`, () => {
|
|
20
|
+
const text = readFileSync(join(REPO, "agents", `fleet-review-${key}.agent.md`), "utf8");
|
|
21
|
+
assert.match(text, /Report only; never edit, commit or push\./);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// The snapshot and verifier dispatches are NOT specialists in this sense —
|
|
26
|
+
// snapshot's whole job is a fixed shell script the caller already bounds
|
|
27
|
+
// (`Do not modify ${worktree}` is in review-core.mjs's own prompt, not the
|
|
28
|
+
// agent's), and verifier is a refuter whose job is verification commands in
|
|
29
|
+
// its own scratch directory, never the checkout. Neither belongs in the six
|
|
30
|
+
// above; this documents the exclusion is deliberate rather than an oversight
|
|
31
|
+
// a future reader "fixes" by adding a ninth/tenth match here.
|
|
32
|
+
test("the exclusion is exactly the six review-dimension specialists, not all eight definitions", () => {
|
|
33
|
+
assert.equal(SPECIALISTS.length, 6);
|
|
34
|
+
assert.ok(!SPECIALISTS.includes("snapshot") && !SPECIALISTS.includes("verifier"));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// commands/review-and-fix.md's own rule must be unconditional again — no
|
|
38
|
+
// carve-out for a "by design" fleet-review-* exemption that isn't true.
|
|
39
|
+
test("review-and-fix.md's read-only rule is unconditional, not scoped to general-purpose hand-dispatch only", () => {
|
|
40
|
+
const text = readFileSync(join(REPO, "commands", "review-and-fix.md"), "utf8");
|
|
41
|
+
const bullet = text.split("\n").find((l) => l.includes("**Say read-only.**"));
|
|
42
|
+
assert.ok(bullet, "the Say read-only bullet is gone");
|
|
43
|
+
assert.match(bullet, /No `fleet-review-\*` definition's frontmatter restricts tool access/);
|
|
44
|
+
assert.doesNotMatch(
|
|
45
|
+
bullet,
|
|
46
|
+
/is a report-only specialist by design/,
|
|
47
|
+
"the bullet still claims fleet-review-* dispatches are enforced report-only, which no frontmatter actually does",
|
|
48
|
+
);
|
|
49
|
+
});
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
// #1433. Three PRs reviewed back-to-back from one omp `eval` cell left FOUR
|
|
2
|
+
// files modified in the checkout that cell was standing in — one specialist's
|
|
3
|
+
// mutation-test experiment per review reaching the repository through a
|
|
4
|
+
// RELATIVE path. Review specialists have no assigned worktree to fall back to
|
|
5
|
+
// (unlike implementers, whose own relative-path defect is #1411), and the
|
|
6
|
+
// controller reads every gate decision — instruments.sh, ci-state.mjs, any
|
|
7
|
+
// local `node --test` — out of that same tree, so a modified instrument
|
|
8
|
+
// silently changes what a later gate check reads.
|
|
9
|
+
//
|
|
10
|
+
// WHY THE FIX IS PROMPT PROSE AND NOT A `cwd` ARGUMENT. The preferred remedy
|
|
11
|
+
// was an explicit scratch cwd per specialist dispatch, passed through
|
|
12
|
+
// review-eval.mjs's `ompAgent()`. Neither dispatch primitive has one:
|
|
13
|
+
// eval's `agent()` takes `{ agent, label, schema, schemaMode, isolated, apply,
|
|
14
|
+
// merge, tools }` and `task`'s item shape carries no cwd either, and a
|
|
15
|
+
// non-isolated spawn runs with the PARENT's cwd. `isolated: true` is not that
|
|
16
|
+
// option renamed — it names no directory, it fails preflight wherever
|
|
17
|
+
// `task.isolation.enabled` is off, and it MERGES the child's changes back into
|
|
18
|
+
// the parent, which for a mutation-testing specialist means applying a
|
|
19
|
+
// deliberately broken tree to the checkout. review-eval.mjs's own header holds
|
|
20
|
+
// that determination with its sources; this file pins what the prompts say
|
|
21
|
+
// because of it.
|
|
22
|
+
//
|
|
23
|
+
// THREE PARTS, PINNED SEPARATELY, because the later two are inert without the
|
|
24
|
+
// first and each fails differently: the inherited cwd is NAMED as a tree the
|
|
25
|
+
// agent must not write to, `pwd` fixes which directory that is, and the
|
|
26
|
+
// `CWD-AUDIT:` line is what makes a CLEAN run say so. An audit reported only
|
|
27
|
+
// when it finds something is indistinguishable from one never run — the same
|
|
28
|
+
// reading `unrunReason` already applies to a `test_run` reporting nothing, and
|
|
29
|
+
// the reason "four files dirty" was found by chance rather than by a report.
|
|
30
|
+
//
|
|
31
|
+
// WHY THESE PINS RENDER RATHER THAN GREP, and why the slice is the pin: same
|
|
32
|
+
// two reasons review-core-specialist-scratch.test.mjs states. The rules live
|
|
33
|
+
// inside template literals whose backticks are written escaped (`` \` ``), so
|
|
34
|
+
// a source-text pin passes just as happily on a prompt showing the agent a
|
|
35
|
+
// literal `\`; and all three prompts here carry the SAME wording, so a pin
|
|
36
|
+
// matched against the whole file would be satisfied by any one of them —
|
|
37
|
+
// which is the defect shape this ticket reports one dispatch at a time.
|
|
38
|
+
// Each prompt is extracted by its own `agent()` call's anchors through
|
|
39
|
+
// prompt-renderer.mjs and rendered, so the other two are outside it by
|
|
40
|
+
// construction. Measured, per prompt: reverting the block out of the
|
|
41
|
+
// specialist prompt alone reds that prompt's four tests and the shared marker
|
|
42
|
+
// pin below, leaving every refuter and snapshot test green; the mirror revert
|
|
43
|
+
// does the same the other way, and reverting the snapshot sentence reds its
|
|
44
|
+
// prose pin alone. Block-commenting a dispatch reds the whole file at
|
|
45
|
+
// extraction — it does not render as live text (strip-comments.mjs).
|
|
46
|
+
//
|
|
47
|
+
// THE CEILING, same as the sibling scratch pins': nothing here reaches the
|
|
48
|
+
// agent's own obedience. These pins settle what a dispatch is TOLD and what
|
|
49
|
+
// the schema can carry back — never where a specialist actually writes.
|
|
50
|
+
import { test } from "node:test";
|
|
51
|
+
import assert from "node:assert/strict";
|
|
52
|
+
import { phrase } from "./prose-pin.mjs";
|
|
53
|
+
import { promptRenderer } from "./prompt-renderer.mjs";
|
|
54
|
+
import { AUDIT_COMMAND, AUDIT_STATES, CWD_AUDIT_MARKER, EVERY_RUN, PWD_FIRST, REFUTER_CWD, REPORT_FIELD, SCRATCH_NAMED_REFUTER, SCRATCH_NAMED_SPECIALIST, SPECIALIST_CWD, auditLine } from "./cwd-isolation-pins.mjs";
|
|
55
|
+
import { FINDINGS_SCHEMA, VERDICT_SCHEMA, cwdAuditFrom, runReview } from "./review-core.mjs";
|
|
56
|
+
|
|
57
|
+
const FILE = "scripts/review-core.mjs";
|
|
58
|
+
const SNAP = { path: "/scr/run-1/snapshot-abc1234", head: "abc1234", runRoot: "/scr/run-1" };
|
|
59
|
+
|
|
60
|
+
// One specialist's, one refuter's and the snapshot agent's prompt. Every
|
|
61
|
+
// argument is fixed: these pins are about what the prompts SAY, not about how
|
|
62
|
+
// they vary, so nothing here needs to. `readRules`/`usableDiff`/
|
|
63
|
+
// `environmentNote` are stubs for the sibling pins' reason — binding them
|
|
64
|
+
// keeps a render that stops passing one throwing a ReferenceError instead of
|
|
65
|
+
// dropping a paragraph silently.
|
|
66
|
+
const specialist = promptRenderer({
|
|
67
|
+
file: FILE,
|
|
68
|
+
start: "`Review PR #${pr} (branch ${branch}) for: ",
|
|
69
|
+
end: "label: `review:",
|
|
70
|
+
scope: ["pr", "branch", "d", "snap", "worktree", "stats", "testCmd", "readRules", "usableDiff", "environmentNote"],
|
|
71
|
+
what: "review-core.mjs's specialist prompt (opening `Review PR #${pr} (branch ${branch}) for: `, labelled `review:`)",
|
|
72
|
+
})(7, "feature/x", { key: "correctness", prompt: "does it do what it says" }, SNAP, "/repo/.worktrees/7-x", null, "node --test", () => "READ RULES", () => null, () => "TEST ENVIRONMENT");
|
|
73
|
+
|
|
74
|
+
const refuter = promptRenderer({
|
|
75
|
+
file: FILE,
|
|
76
|
+
start: "`Try to REFUTE this finding from PR #",
|
|
77
|
+
end: "{ label: `verify:",
|
|
78
|
+
scope: ["pr", "f", "snap", "stats", "d", "i", "fi", "readRules", "usableDiff", "environmentNote"],
|
|
79
|
+
what: "review-core.mjs's refuter prompt (opening `Try to REFUTE this finding from PR #`, labelled `verify:`)",
|
|
80
|
+
})(7, { claim: "the guard fails open", file: "a.js", line: 12, evidence: "line 12 has no else" }, SNAP, null, { key: "correctness" }, 0, 0, () => "READ RULES", () => null, () => "TEST ENVIRONMENT");
|
|
81
|
+
|
|
82
|
+
const snapshot = promptRenderer({
|
|
83
|
+
file: FILE,
|
|
84
|
+
start: "`In ${worktree}, cut an immutable review snapshot",
|
|
85
|
+
end: '{ label: "snapshot"',
|
|
86
|
+
scope: ["worktree", "scratch", "runRootParent", "runRootPrefix", "pr", "harness"],
|
|
87
|
+
what: 'review-core.mjs\'s snapshot prompt (opening `In ${worktree}, cut an immutable review snapshot`, labelled "snapshot")',
|
|
88
|
+
})("/repo/.worktrees/7-x", "/scr", "/scr/pr7", "/scr/pr7/run-", 7, "omp");
|
|
89
|
+
|
|
90
|
+
// --- Part 1: the inherited cwd is named, as a tree not to write to ---------
|
|
91
|
+
// ONE contiguous span per prompt, never two assertions and never a `.{0,N}`
|
|
92
|
+
// gap — cwd-isolation-pins.mjs holds both spans and why their three clauses
|
|
93
|
+
// have to arrive together. Mutation-tested on each prompt: deleting any one of
|
|
94
|
+
// the three clauses, and splicing an exception between them ("…lands THERE,
|
|
95
|
+
// unless the command is read-only"), both red these.
|
|
96
|
+
test("the rendered specialist prompt names the cwd it inherits and says a relative path lands there", () => {
|
|
97
|
+
assert.match(
|
|
98
|
+
specialist,
|
|
99
|
+
phrase(SPECIALIST_CWD),
|
|
100
|
+
"review-core.mjs's specialist prompt no longer names the directory it is dispatched INTO — a specialist that does not know its cwd is the controller's checkout has no reason to leave it, " +
|
|
101
|
+
"which is how three reviews left four files modified there (#1433)",
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("the rendered refuter prompt names the cwd it inherits and says a relative path lands there", () => {
|
|
106
|
+
assert.match(
|
|
107
|
+
refuter,
|
|
108
|
+
phrase(`your shell does not start there: ${REFUTER_CWD}`),
|
|
109
|
+
"review-core.mjs's refuter prompt no longer names the directory it is dispatched INTO — a refuter applying a mutation is the likeliest writer of the four files #1433 measured",
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// --- Part 2: `pwd` first, and the inherited directory is a no-run zone -----
|
|
114
|
+
// Both halves in one span (PWD_FIRST, cwd-isolation-pins.mjs says why).
|
|
115
|
+
// Mutation-tested: demoting FIRST to "early" or dropping the no-run clause
|
|
116
|
+
// reds these.
|
|
117
|
+
for (const [name, prompt] of [
|
|
118
|
+
["specialist", specialist],
|
|
119
|
+
["refuter", refuter],
|
|
120
|
+
]) {
|
|
121
|
+
test(`the rendered ${name} prompt orders pwd as the first command and makes that directory a no-run zone`, () => {
|
|
122
|
+
assert.match(
|
|
123
|
+
prompt,
|
|
124
|
+
PWD_FIRST,
|
|
125
|
+
`review-core.mjs's ${name} prompt no longer fixes which directory it started in before running anything — the audit below then has no path to audit, and the cd rules guard a directory nothing identified (#1433)`,
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// --- Part 2.5 (#1721): where the snapshot/scratch dir are named, per prompt
|
|
131
|
+
// Each prompt's own claim (SCRATCH_NAMED_SPECIALIST / SCRATCH_NAMED_REFUTER,
|
|
132
|
+
// cwd-isolation-pins.mjs says why the two differ). Regression pin: reverting
|
|
133
|
+
// review-core.mjs's specialist prompt back to "above" while leaving this file on
|
|
134
|
+
// "in this prompt" passed the entire suite otherwise (measured at PR #1825's
|
|
135
|
+
// review) — nothing previously pinned past PWD_FIRST's "no-run zone from then
|
|
136
|
+
// on" on either prompt.
|
|
137
|
+
for (const [name, prompt, span] of [
|
|
138
|
+
["specialist", specialist, SCRATCH_NAMED_SPECIALIST],
|
|
139
|
+
["refuter", refuter, SCRATCH_NAMED_REFUTER],
|
|
140
|
+
]) {
|
|
141
|
+
test(`the rendered ${name} prompt states where the snapshot and scratch dir are named as absolute paths`, () => {
|
|
142
|
+
assert.match(
|
|
143
|
+
prompt,
|
|
144
|
+
span,
|
|
145
|
+
`review-core.mjs's ${name} prompt no longer makes this claim, or worded it to match "above" when its scratch dir is actually named later (#1721)`,
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// --- Part 3: the positive self-check, into a field the schema carries ------
|
|
151
|
+
// The audit command and the report contract are separate spans, each
|
|
152
|
+
// contiguous, for the reasons cwd-isolation-pins.mjs gives. Mutation-tested:
|
|
153
|
+
// dropping `-uall`, dropping the `showUntrackedFiles=no` reason, and replacing
|
|
154
|
+
// "every run, clean or not" with "when it printed anything" each red one of
|
|
155
|
+
// these.
|
|
156
|
+
test("the rendered specialist prompt audits the directory it started in, with the explicit untracked mode", () => {
|
|
157
|
+
assert.match(
|
|
158
|
+
specialist,
|
|
159
|
+
phrase(AUDIT_COMMAND),
|
|
160
|
+
"review-core.mjs's specialist prompt dropped the stray-write audit, or asks for bare `--porcelain` — which a `status.showUntrackedFiles=no` config silences into a false clean, the same false-clean class worktree-audit.sh's own `-uall` exists to deny (#1433)",
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test("the rendered refuter prompt audits the directory it started in, with the explicit untracked mode", () => {
|
|
165
|
+
assert.match(
|
|
166
|
+
refuter,
|
|
167
|
+
phrase(AUDIT_COMMAND),
|
|
168
|
+
"review-core.mjs's refuter prompt dropped the stray-write audit, or asks for bare `--porcelain` (#1433)",
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// The report contract, and the half a prose pin usually cannot reach: the
|
|
173
|
+
// field each prompt names has to be one its SCHEMA declares. Both schemas are
|
|
174
|
+
// `additionalProperties: false`, so a rule pointing at any other name is inert
|
|
175
|
+
// — the agent's audit is dropped in validation and the prompt still reads
|
|
176
|
+
// correct. The field name is EXTRACTED from the rendered prompt by
|
|
177
|
+
// REPORT_FIELD's capture group rather than transcribed here, so the pin fails
|
|
178
|
+
// in either direction: the prompt renaming the field, or the schema losing it.
|
|
179
|
+
for (const [name, prompt, schema, schemaName] of [
|
|
180
|
+
["specialist", specialist, FINDINGS_SCHEMA, "FINDINGS_SCHEMA"],
|
|
181
|
+
["refuter", refuter, VERDICT_SCHEMA, "VERDICT_SCHEMA"],
|
|
182
|
+
]) {
|
|
183
|
+
test(`the rendered ${name} prompt reports its audit into a field ${schemaName} actually carries, every run`, () => {
|
|
184
|
+
const named = prompt.match(REPORT_FIELD);
|
|
185
|
+
assert.ok(
|
|
186
|
+
named,
|
|
187
|
+
`review-core.mjs's ${name} prompt no longer names a report field for the CWD-AUDIT line — an audit the agent has nowhere to put is an audit the caller never sees (#1433)`,
|
|
188
|
+
);
|
|
189
|
+
assert.equal(schema.additionalProperties, false, `${schemaName} no longer refuses undeclared fields — this pin's premise (a wrongly-named field is DROPPED, not passed through) no longer holds; re-derive it`);
|
|
190
|
+
assert.ok(
|
|
191
|
+
Object.hasOwn(schema.properties, named[1]),
|
|
192
|
+
`review-core.mjs's ${name} prompt reports the audit in \`${named[1]}\`, which ${schemaName} does not declare — \`additionalProperties: false\` drops it, so the audit dies in validation with the prompt still reading correct`,
|
|
193
|
+
);
|
|
194
|
+
assert.ok(
|
|
195
|
+
schema.required.includes(named[1]),
|
|
196
|
+
`${schemaName} no longer REQUIRES \`${named[1]}\`, so an agent that omits the audit omits the whole field and validates anyway — the report has to ride a field the schema already insists on`,
|
|
197
|
+
);
|
|
198
|
+
// All three states, and the always clause. Two of the states are what keep
|
|
199
|
+
// the check POSITIVE: a prompt that spells out only `dirty` leaves a clean
|
|
200
|
+
// run and a never-run check reporting the same nothing, and `unrepo` is
|
|
201
|
+
// what stops a `fatal: not a git repository` — the honest answer whenever
|
|
202
|
+
// the inherited cwd is not a checkout — being read as a reason to report
|
|
203
|
+
// nothing at all.
|
|
204
|
+
for (const state of AUDIT_STATES) {
|
|
205
|
+
assert.match(
|
|
206
|
+
prompt,
|
|
207
|
+
auditLine(state),
|
|
208
|
+
`review-core.mjs's ${name} prompt no longer spells the \`${state}\` form of the audit line — the state it cannot spell is the state it will not report (#1433)`,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
assert.match(
|
|
212
|
+
prompt,
|
|
213
|
+
EVERY_RUN,
|
|
214
|
+
`review-core.mjs's ${name} prompt no longer demands the audit line on a CLEAN run — an audit reported only when it finds something is indistinguishable from one never run, which is exactly how #1433's four files went unrecorded`,
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Checked against each prompt individually (CWD_AUDIT_MARKER,
|
|
220
|
+
// cwd-isolation-pins.mjs) — a capture group around a fixed literal with no
|
|
221
|
+
// alternation inside it can only ever capture that same literal, so comparing
|
|
222
|
+
// `inSpecialist[1]` against `inRefuter[1]` (the prior shape of this test)
|
|
223
|
+
// could never fail as long as both prompts matched at all; the `assert.ok`
|
|
224
|
+
// above already covers that.
|
|
225
|
+
for (const [name, prompt] of [
|
|
226
|
+
["specialist", specialist],
|
|
227
|
+
["refuter", refuter],
|
|
228
|
+
]) {
|
|
229
|
+
test(`the rendered ${name} prompt names the CWD-AUDIT marker as a code span`, () => {
|
|
230
|
+
assert.match(
|
|
231
|
+
prompt,
|
|
232
|
+
CWD_AUDIT_MARKER,
|
|
233
|
+
`review-core.mjs's ${name} prompt no longer names the CWD-AUDIT marker as a code span — a reader cannot tell the literal from the prose around it`,
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// --- The snapshot dispatch, whose rule is different ------------------------
|
|
239
|
+
// It is dispatched with the same inherited cwd, but it CREATES the scratch
|
|
240
|
+
// tree, so it has no scratch directory to `cd` into as a first command and
|
|
241
|
+
// gets the other half of the rule instead: every path it uses is absolute or
|
|
242
|
+
// `-C`-anchored, so nothing relative may be added to the block.
|
|
243
|
+
test("the rendered snapshot prompt says its own block is absolute by construction and forbids adding a relative path", () => {
|
|
244
|
+
assert.match(
|
|
245
|
+
snapshot,
|
|
246
|
+
phrase(
|
|
247
|
+
"Every path in the block above is absolute or `-C`-anchored on purpose: this dispatch carries no working directory of its own either, so you start in the controller's own checkout, and a relative path — a `tar -x` with no `-C`, a bare `git` — reads or writes THERE",
|
|
248
|
+
),
|
|
249
|
+
"review-core.mjs's snapshot prompt no longer says why its paths are absolute — the agent that mints the scratch tree is the one dispatch with no scratch dir to cd into, so the rule it gets is the only one it can follow (#1433)",
|
|
250
|
+
);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// The other direction, and the one that keeps the sentence above from being
|
|
254
|
+
// aspirational: the block really is anchored. Every command line in the prompt
|
|
255
|
+
// is checked, so a bare `git status` or a `tar -x` with no `-C` added later
|
|
256
|
+
// reds HERE — where the prose claiming otherwise lives — rather than in a
|
|
257
|
+
// review that quietly measured the controller's checkout. Command lines are
|
|
258
|
+
// the 4-space-indented ones, which is how both blocks in this prompt are
|
|
259
|
+
// written; the prose that NAMES `tar -x` and `git` sits at column 0 and is not
|
|
260
|
+
// scanned, so this pin cannot be satisfied or broken by its own rule's wording.
|
|
261
|
+
test("every command line in the snapshot prompt is -C-anchored, cd-chained, or path-free", () => {
|
|
262
|
+
const lines = snapshot.split("\n").filter((l) => /^ {4}\S/.test(l));
|
|
263
|
+
assert.ok(lines.length >= 15, `only ${lines.length} indented command lines found in the snapshot prompt — the block was reshaped past what this pin scans; update it or restore the block`);
|
|
264
|
+
for (const line of lines) {
|
|
265
|
+
const cdChained = /cd\s+"\$\w+"\s+&&/.test(line);
|
|
266
|
+
for (const m of line.matchAll(/(?<![-\w])git\s+(?!-C\b)(\S+)/g)) {
|
|
267
|
+
assert.ok(
|
|
268
|
+
cdChained,
|
|
269
|
+
`the snapshot block runs \`git ${m[1]}\` with neither \`-C\` nor a chained \`cd\` on the same line — it answers about the directory the dispatch inherited, the controller's own checkout: ${line.trim()}`,
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
for (const m of line.matchAll(/(?<![-\w])tar\s+(\S+)/g)) {
|
|
273
|
+
assert.match(
|
|
274
|
+
line,
|
|
275
|
+
/tar\s[^|]*-C\s/,
|
|
276
|
+
`the snapshot block runs \`tar ${m[1]}\` with no \`-C\` — an extraction with no destination unpacks into the inherited cwd: ${line.trim()}`,
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// --- The specialist's audit reaching the payload (PR #1671 review, gap 1) --
|
|
283
|
+
// Part 3 above pins that the audit is NAMED and has somewhere valid to land;
|
|
284
|
+
// it does not pin that `runReview` ever reads it back out once it lands
|
|
285
|
+
// there. Measured against the PR #1671 review's own reproduction: a
|
|
286
|
+
// specialist that dutifully reported `CWD-AUDIT: dirty <checkout>` into
|
|
287
|
+
// `scope_searched` had that fact dropped before `runReview`'s return —
|
|
288
|
+
// `scope_searched` fed only `unrunReason`'s test-run check, which never reads
|
|
289
|
+
// it, so the audit dead-ended inside a field nothing else looked at.
|
|
290
|
+
// `cwdAuditFrom` extracts the line; the tests below pin that `runReview`
|
|
291
|
+
// folds its result into the payload under `cwdAudit`, and that a missing or
|
|
292
|
+
// misspelled line is flagged there rather than silently read as clean.
|
|
293
|
+
test("cwdAuditFrom reads each of the audit line's states, and flags its own absence", () => {
|
|
294
|
+
assert.deepEqual(cwdAuditFrom("grepped src/**/*.js for auth checks. CWD-AUDIT: clean /repo/.worktrees/7-x"), {
|
|
295
|
+
state: "clean",
|
|
296
|
+
line: "CWD-AUDIT: clean /repo/.worktrees/7-x",
|
|
297
|
+
});
|
|
298
|
+
assert.deepEqual(cwdAuditFrom("CWD-AUDIT: dirty /repo/.worktrees/7-x — M src/foo.js"), {
|
|
299
|
+
state: "dirty",
|
|
300
|
+
line: "CWD-AUDIT: dirty /repo/.worktrees/7-x — M src/foo.js",
|
|
301
|
+
});
|
|
302
|
+
assert.deepEqual(cwdAuditFrom("CWD-AUDIT: unrepo /repo/.worktrees/7-x"), {
|
|
303
|
+
state: "unrepo",
|
|
304
|
+
line: "CWD-AUDIT: unrepo /repo/.worktrees/7-x",
|
|
305
|
+
});
|
|
306
|
+
// No line at all.
|
|
307
|
+
assert.deepEqual(cwdAuditFrom("grepped src/**/*.js for auth checks"), { state: "missing", line: null });
|
|
308
|
+
// Misspelled — the ticket's own failure mode: a schema-valid string that
|
|
309
|
+
// never actually reports, because FINDINGS_SCHEMA has no pattern over it.
|
|
310
|
+
assert.deepEqual(cwdAuditFrom("CWD AUDIT: clean /repo/.worktrees/7-x"), { state: "missing", line: null });
|
|
311
|
+
assert.deepEqual(cwdAuditFrom(undefined), { state: "missing", line: null });
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// A minimal fake host: every fact `runReview` otherwise gets from `gh`/`git`
|
|
315
|
+
// arrives inside the snapshot agent's own structured response — review-
|
|
316
|
+
// core.js never shells out itself, every command lives in a dispatched
|
|
317
|
+
// prompt (grep finds no `child_process` import in this file) — so a scripted
|
|
318
|
+
// `agent()` stub returning one canned object per dispatch label is a
|
|
319
|
+
// complete double for the whole pipeline, no real repository needed.
|
|
320
|
+
function fakeReviewHost(scopeSearched) {
|
|
321
|
+
return {
|
|
322
|
+
agent: async (_prompt, opts) => {
|
|
323
|
+
if (opts.label === "snapshot")
|
|
324
|
+
return {
|
|
325
|
+
runRoot: "/scr/pr7/run-ab12",
|
|
326
|
+
path: "/scr/pr7/run-ab12/snapshot-abc123",
|
|
327
|
+
head: "abc123",
|
|
328
|
+
pathVerified: true,
|
|
329
|
+
repoVerified: true,
|
|
330
|
+
testCmd: "node --test",
|
|
331
|
+
};
|
|
332
|
+
if (opts.label === "review:correctness")
|
|
333
|
+
return {
|
|
334
|
+
dimension: "correctness",
|
|
335
|
+
scope_searched: scopeSearched,
|
|
336
|
+
findings: [],
|
|
337
|
+
test_run: { command: "node --test", tests: 5, pass: 5, fail: 0 },
|
|
338
|
+
};
|
|
339
|
+
throw new Error(`fakeReviewHost: unexpected dispatch ${opts.label}`);
|
|
340
|
+
},
|
|
341
|
+
phase: () => {},
|
|
342
|
+
log: () => {},
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
test("runReview carries a specialist's dirty CWD-AUDIT into the payload's cwdAudit field", async () => {
|
|
347
|
+
const host = fakeReviewHost("CWD-AUDIT: dirty /repo/.worktrees/7-x — M src/foo.js");
|
|
348
|
+
const result = await runReview(host, {
|
|
349
|
+
pr: 7,
|
|
350
|
+
worktree: "/repo/.worktrees/7-x",
|
|
351
|
+
scratch: "/scr",
|
|
352
|
+
dimensions: ["correctness"],
|
|
353
|
+
});
|
|
354
|
+
assert.deepEqual(
|
|
355
|
+
result.cwdAudit,
|
|
356
|
+
[{ dimension: "correctness", state: "dirty", line: "CWD-AUDIT: dirty /repo/.worktrees/7-x — M src/foo.js" }],
|
|
357
|
+
"a specialist that reported a dirty checkout must have that fact reach the payload — silently dropping it is the exact defect PR #1671's review found (#1433)",
|
|
358
|
+
);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
test("runReview flags a specialist's missing CWD-AUDIT line rather than reading it as clean", async () => {
|
|
362
|
+
const host = fakeReviewHost("grepped the diff for auth checks — nothing else searched");
|
|
363
|
+
const result = await runReview(host, {
|
|
364
|
+
pr: 7,
|
|
365
|
+
worktree: "/repo/.worktrees/7-x",
|
|
366
|
+
scratch: "/scr",
|
|
367
|
+
dimensions: ["correctness"],
|
|
368
|
+
});
|
|
369
|
+
assert.deepEqual(
|
|
370
|
+
result.cwdAudit,
|
|
371
|
+
[{ dimension: "correctness", state: "missing", line: null }],
|
|
372
|
+
"a specialist that satisfied FINDINGS_SCHEMA without ever emitting a CWD-AUDIT line must be flagged, not read as an unreported-but-clean run",
|
|
373
|
+
);
|
|
374
|
+
});
|