@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,55 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
// Review finding on #1349's PR (#1361): `fleet-run scriptPathFor` joins
|
|
7
|
+
// `path.join(installPath, "scripts", script)` — the Resolver ALREADY places
|
|
8
|
+
// the caller under `scripts/`, and does no existence check on the result
|
|
9
|
+
// (`--path` "print the resolved path; do not exec"). Every prose site that
|
|
10
|
+
// told a caller to run `fleet-run --path scripts/review-eval.mjs` therefore
|
|
11
|
+
// resolved to `<installPath>/scripts/scripts/review-eval.mjs` — a path one
|
|
12
|
+
// level too deep that would only fail LOUDLY once something tried to
|
|
13
|
+
// `import()` it, never at the Resolver call itself. The correct invocation
|
|
14
|
+
// is `--path review-eval.mjs`, bare — `scripts/` is implicit.
|
|
15
|
+
//
|
|
16
|
+
// This is the existence check the Resolver itself does not perform: pin it
|
|
17
|
+
// here, against this repo's own `plugin/` tree standing in for an install
|
|
18
|
+
// root (`scriptPathFor`'s own join, replicated rather than imported — the
|
|
19
|
+
// Resolver is a standalone file placed outside the plugin by hand, per its
|
|
20
|
+
// own header, and importing it would need it to travel with a module it
|
|
21
|
+
// does not carry).
|
|
22
|
+
const REPO = join(import.meta.dirname, "..");
|
|
23
|
+
|
|
24
|
+
function scriptPathFor(installPath, script) {
|
|
25
|
+
return join(installPath, "scripts", script);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
test("the correct --path form resolves to a file that actually exists", () => {
|
|
29
|
+
const correct = scriptPathFor(REPO, "review-eval.mjs");
|
|
30
|
+
assert.ok(existsSync(correct), `${correct} does not exist — review-eval.mjs moved or was renamed`);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("the double-scripts/ form (the mistake this pins against) does not exist", () => {
|
|
34
|
+
const wrong = scriptPathFor(REPO, "scripts/review-eval.mjs");
|
|
35
|
+
assert.ok(
|
|
36
|
+
!existsSync(wrong),
|
|
37
|
+
`${wrong} exists — either a stray directory was created, or scriptPathFor's join changed and the prose sites need re-checking`,
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// The prose sites: review-eval.mjs's own usage comment, plus every doc site
|
|
42
|
+
// that tells a caller how to load it. All three must spell the bare form.
|
|
43
|
+
const SITES = [
|
|
44
|
+
{ path: ["scripts", "review-eval.mjs"], what: "review-eval.mjs's own usage comment" },
|
|
45
|
+
{ path: ["commands", "review-and-fix.md"], what: "review-and-fix.md's OMP invocation line" },
|
|
46
|
+
{ path: ["skills", "run-team", "SKILL.md"], what: "SKILL.md's OMP invocation line" },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
for (const { path, what } of SITES) {
|
|
50
|
+
test(`${what} spells the bare --path form, never the doubled scripts/ one`, () => {
|
|
51
|
+
const text = readFileSync(join(REPO, ...path), "utf8");
|
|
52
|
+
assert.match(text, /--path review-eval\.mjs\b/, `${what} no longer names the correct --path invocation`);
|
|
53
|
+
assert.doesNotMatch(text, /--path scripts\/review-eval\.mjs/, `${what} regressed to the doubled scripts/ form`);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// review-eval.mjs — the shim for the PR review port (#1349, per #1303's
|
|
2
|
+
// ruling on #1296). It is loaded (never review-core.mjs directly) through
|
|
3
|
+
// the Resolver, from an `eval` cell:
|
|
4
|
+
//
|
|
5
|
+
// const path = (await Bun.$`~/.fleet/bin/fleet-run --path review-eval.mjs`.text()).trim();
|
|
6
|
+
// const { runReviewOnOmp } = await import(path);
|
|
7
|
+
// const result = await runReviewOnOmp({ pr, branch, worktree, testCmd, scratch });
|
|
8
|
+
//
|
|
9
|
+
// Since #1802 the cell that does this is the `review-pr-<pr#>` member's own —
|
|
10
|
+
// agents/fleet-review-runner.agent.md, off the controller's turn — and it calls
|
|
11
|
+
// `runReviewToFile` (bottom of this file), which wraps `runReviewOnOmp` with the
|
|
12
|
+
// one retry and writes the result file. A controller holding its own turn can
|
|
13
|
+
// still call `runReviewOnOmp` exactly as above.
|
|
14
|
+
//
|
|
15
|
+
// This file `import`s review-core.mjs (a same-directory sibling, both ship
|
|
16
|
+
// together under the same Install root) with a RELATIVE specifier, so the
|
|
17
|
+
// Resolver is only needed ONCE, to find this file itself — the relationship
|
|
18
|
+
// between the two is an ordinary same-install sibling import, which eval's
|
|
19
|
+
// Bun VM permits without restriction (#1296 Q6). Never resolve
|
|
20
|
+
// review-core.mjs's own path through the Resolver a second time — that would
|
|
21
|
+
// be two doors where CONTEXT.md's Resolver entry says there is exactly one.
|
|
22
|
+
//
|
|
23
|
+
// No `model`/`effort` appears anywhere below (#1349 gap 3; audited by
|
|
24
|
+
// review-tier-audit.test.mjs). Every dispatch names a bare fleet-owned
|
|
25
|
+
// `agentType` from review-core.mjs's DEFAULT_DIMENSIONS or from
|
|
26
|
+
// runReview's own snapshot/verifier dispatch, unmodified — omp's `agent()`
|
|
27
|
+
// resolves a bare frontmatter `name:` exactly, which is already what those
|
|
28
|
+
// strings are.
|
|
29
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
30
|
+
import { isAbsolute, join } from "node:path";
|
|
31
|
+
import { digestOf, runReview, runnerPrRefusal } from "./review-core.mjs";
|
|
32
|
+
|
|
33
|
+
// eval's `agent()` returns a HANDLE, not data (#1296 Q2): `agent(prompt,
|
|
34
|
+
// opts)` resolves near-instantly to an `AgentHandle` with `.wait()`, and only
|
|
35
|
+
// `.wait()` unwraps the schema-validated `structuredOutput.data`. This
|
|
36
|
+
// wrapper is what makes review-core.mjs's `await host.agent(...)` read like
|
|
37
|
+
// a synchronous, data-returning call — the ONE piece of host-specific glue
|
|
38
|
+
// `runReview` needs and cannot see.
|
|
39
|
+
//
|
|
40
|
+
// A crashed/rejected dispatch resolves to `null`, the contract every guard
|
|
41
|
+
// in review-core.mjs (`if (snap) {...}`, `unrunCrashed`, `verdictFor`) is
|
|
42
|
+
// written against. eval's DEFAULT `schemaMode` is "permissive": an exhausted
|
|
43
|
+
// structured-output retry is ACCEPTED anyway, carrying `schemaOverridden:
|
|
44
|
+
// true` on invalid data (#1296 Q2) rather than nulling out. `schemaMode:
|
|
45
|
+
// "strict"` turns that same exhaustion into a thrown/rejected result
|
|
46
|
+
// instead — still not a null — so this wrapper treats a REJECTED `.wait()`
|
|
47
|
+
// as the crash signal (`agent()`'s only way to fail loudly under omp) and
|
|
48
|
+
// maps it to `null` itself; it does not attempt to distinguish an
|
|
49
|
+
// accepted-but-schema-overridden permissive result from a clean one,
|
|
50
|
+
// because review-core.mjs never reads a distinguishing field for that case
|
|
51
|
+
// either — a schema violation the host already retried three times and
|
|
52
|
+
// gave up correcting is not this shim's contract to relitigate.
|
|
53
|
+
//
|
|
54
|
+
// NO PER-CALL WORKING DIRECTORY HERE, AND WHY THE ISOLATION RULE LIVES IN THE
|
|
55
|
+
// PROMPTS INSTEAD (#1433). Three PRs reviewed back-to-back from one eval cell
|
|
56
|
+
// left FOUR files modified in the checkout that cell was standing in — a
|
|
57
|
+
// specialist's mutation-test experiment reached through a RELATIVE path, in the
|
|
58
|
+
// tree the controller reads instruments.sh, ci-state.mjs and every gate
|
|
59
|
+
// decision out of. Review specialists have no assigned worktree to fall back
|
|
60
|
+
// to, so the preferred fix was a scratch cwd per dispatch, passed through this
|
|
61
|
+
// wrapper. The harness has no such option — measured against its own contract,
|
|
62
|
+
// not assumed:
|
|
63
|
+
//
|
|
64
|
+
// - eval's `agent()` takes `{ agent, label, schema, schemaMode, isolated,
|
|
65
|
+
// apply, merge, tools }` and nothing else (`omp://tools/eval.md`
|
|
66
|
+
// § `agent()`), and `task`'s item shape — `{ name, agent, task, effort,
|
|
67
|
+
// outputSchema, schemaMode, isolated }` — carries no cwd either
|
|
68
|
+
// (`omp://tools/task.md`). A non-isolated spawn "call[s] `runSubprocess(…)`
|
|
69
|
+
// directly with parent cwd", so the child's directory is decided one level
|
|
70
|
+
// above this file and is the controller's own.
|
|
71
|
+
// - `isolated: true` is not that option under another name. It names no
|
|
72
|
+
// directory, so it cannot BE the `<scratch>/pr<N>/<finding>/` the two-level
|
|
73
|
+
// scratch convention asks for; it exists only where
|
|
74
|
+
// `task.isolation.enabled` is on, and requesting it while isolation is
|
|
75
|
+
// `none` fails PREFLIGHT — synchronously, out of the `await agent(...)`
|
|
76
|
+
// below, which the `try` further down does not cover — so on any install
|
|
77
|
+
// with isolation off every dimension would come back null and the review
|
|
78
|
+
// would report itself wholly crashed. And it MERGES what the child changed
|
|
79
|
+
// back into the parent (patch apply, or a branch cherry-pick that stashes
|
|
80
|
+
// the parent repo first): a mutation-testing specialist's deliberately
|
|
81
|
+
// broken tree, applied to the checkout. That is the reported defect with a
|
|
82
|
+
// commit attached.
|
|
83
|
+
//
|
|
84
|
+
// So the rule lives where it can be stated at all: review-core.mjs's snapshot,
|
|
85
|
+
// specialist and refuter prompts name the inherited cwd as a no-run zone, order
|
|
86
|
+
// a `cd` into the run-root scratch path before any mutation, and require a
|
|
87
|
+
// `CWD-AUDIT:` line back. This wrapper stays a pure handle adapter. Should
|
|
88
|
+
// eval's `agent()` ever gain a cwd option, THIS is the one place that changes —
|
|
89
|
+
// thread it through `opts` here, and the prompt rules become the second belt
|
|
90
|
+
// rather than the only one.
|
|
91
|
+
async function ompAgent(prompt, opts) {
|
|
92
|
+
const handle = await agent(prompt, { agent: opts.agentType, schema: opts.schema, label: opts.label });
|
|
93
|
+
try {
|
|
94
|
+
return await handle.wait();
|
|
95
|
+
} catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// `pipeline()`/`parallel()` have no omp counterpart (#1296 Q3) — this is the
|
|
101
|
+
// same hand-rolled pair review-core.mjs exports as its own default (see
|
|
102
|
+
// `defaultPipeline`/`defaultParallel` there), passed through explicitly here
|
|
103
|
+
// rather than left to the default so a reader of THIS file, the one the
|
|
104
|
+
// controller actually loads, can see the omp orchestration shape without
|
|
105
|
+
// following an import.
|
|
106
|
+
function pipeline(items, stage1, stage2) {
|
|
107
|
+
return Promise.all(
|
|
108
|
+
items.map(async (item) => {
|
|
109
|
+
let r1;
|
|
110
|
+
try {
|
|
111
|
+
r1 = await stage1(item);
|
|
112
|
+
} catch {
|
|
113
|
+
r1 = null;
|
|
114
|
+
}
|
|
115
|
+
if (!r1) return null;
|
|
116
|
+
try {
|
|
117
|
+
return await stage2(r1, item);
|
|
118
|
+
} catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function parallel(fns) {
|
|
125
|
+
return Promise.all(fns.map((fn) => fn()));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// The controller's `eval` cell entry point. `phase`/`log` are eval's own
|
|
129
|
+
// prelude globals (`omp://tools/eval.md`) — real free variables in the
|
|
130
|
+
// cell's scope, exactly like `agent` above; naming them as parameters here
|
|
131
|
+
// would ask the controller's cell to thread through globals it already has.
|
|
132
|
+
export async function runReviewOnOmp(args) {
|
|
133
|
+
return runReview({ agent: ompAgent, phase, log, pipeline, parallel }, args);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// #1802 (spec 2026-09-24-slot-based-fleet-loop-design.md § 3 §1, §2, §5, §7).
|
|
137
|
+
// The whole of the omp review runner's job, so the agent's own cell is three
|
|
138
|
+
// lines and this contract can be run (review-runner.test.mjs): the full result
|
|
139
|
+
// object goes to `<scratch>/review-<pr>.json` — the one artefact handed to
|
|
140
|
+
// the fix-applier — and only the digest comes back, because the digest is
|
|
141
|
+
// all the controller reads and a 26–61 KB result is what the file exists to
|
|
142
|
+
// keep out of its context.
|
|
143
|
+
//
|
|
144
|
+
// Failure is a throw or an empty return. The holder of the review call retries
|
|
145
|
+
// once; a second failure returns `failed` with both errors and the fallback
|
|
146
|
+
// reviewer's name (`review-pr-<pr>-b`), and writes no file, so nothing reads a
|
|
147
|
+
// half-review as a review. A dispatch mistake — a pr that is not a PR number, a
|
|
148
|
+
// scratch that is not absolute (eval's cwd is the MAIN CHECKOUT, so a relative
|
|
149
|
+
// one would put the file there) — throws before any run: it is not a review
|
|
150
|
+
// failure, and retrying or falling back would only repeat it. `run` is the seam
|
|
151
|
+
// the test injects; nothing else passes it.
|
|
152
|
+
export async function runReviewToFile(args, run = runReviewOnOmp) {
|
|
153
|
+
const pr = args?.pr;
|
|
154
|
+
const scratch = args?.scratch;
|
|
155
|
+
const prRefusal = runnerPrRefusal(pr);
|
|
156
|
+
if (prRefusal) throw new Error(`review-runner: ${prRefusal}`);
|
|
157
|
+
if (typeof scratch !== "string" || !isAbsolute(scratch)) {
|
|
158
|
+
throw new Error(`review-runner: args.scratch must be an absolute path, got ${JSON.stringify(scratch)}`);
|
|
159
|
+
}
|
|
160
|
+
const errors = [];
|
|
161
|
+
for (let attempt = 1; attempt <= 2; attempt++) {
|
|
162
|
+
let result;
|
|
163
|
+
try {
|
|
164
|
+
result = await run(args);
|
|
165
|
+
} catch (e) {
|
|
166
|
+
errors.push(`attempt ${attempt}: ${e?.message ?? String(e)}`);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
// #1813: `result.counts` is read below to build the digest and the ledger
|
|
170
|
+
// token, but that read happens AFTER `mkdir`/`writeFile` have already put
|
|
171
|
+
// the file on disk — so a `run` that resolves to a truthy, object-shaped
|
|
172
|
+
// result missing `.counts` would otherwise throw on the destructure below
|
|
173
|
+
// OUTSIDE this function's own retry try/catch (which wraps only the
|
|
174
|
+
// `run(args)` call), leaving a half-written `review-<pr>.json` on disk
|
|
175
|
+
// that a fix-applier reading it would mistake for a completed review that
|
|
176
|
+
// never actually finished. Treated the same as an empty return: retried,
|
|
177
|
+
// then reported `failed`, and no file is written for it.
|
|
178
|
+
if (!result || typeof result !== "object" || !result.counts || typeof result.counts !== "object") {
|
|
179
|
+
errors.push(`attempt ${attempt}: empty return (${String(result)})`);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const path = join(scratch, `review-${pr}.json`);
|
|
183
|
+
await mkdir(scratch, { recursive: true });
|
|
184
|
+
await writeFile(path, `${JSON.stringify(result, null, 2)}\n`);
|
|
185
|
+
const { survived, refuted, unverified } = result.counts;
|
|
186
|
+
return {
|
|
187
|
+
status: "completed",
|
|
188
|
+
path,
|
|
189
|
+
// Spec § 3 §7's result token, ready for `ledger.mjs row`.
|
|
190
|
+
ledger: `reviewed=${result.head}:${survived}/${refuted}/${unverified}`,
|
|
191
|
+
attempts: attempt,
|
|
192
|
+
errors,
|
|
193
|
+
digest: digestOf(result),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
return { status: "failed", errors, fallback: `review-pr-${pr}-b` };
|
|
197
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Shared `runReview(host, args)` test double, extracted from
|
|
2
|
+
// review-in-run-retry.test.mjs so review-path-default.test.mjs's own return-
|
|
3
|
+
// shape pin can drive a REAL `runReview` call instead of re-parsing
|
|
4
|
+
// review-core.mjs's source text for its `return {` — the retired script's
|
|
5
|
+
// own return literal was the ONLY thing that pin ever read;
|
|
6
|
+
// ADR 0014 (omp-only) leaves review-core.mjs as the one body to run.
|
|
7
|
+
//
|
|
8
|
+
// review-core.mjs's own pipeline contract, mirrored here: a null stage-1
|
|
9
|
+
// result never reaches stage 2, with a throw landing in the same null slot —
|
|
10
|
+
// the shape `defaultPipeline` (review-core.mjs) already has, restated as a
|
|
11
|
+
// scripted double so a caller needs no host beyond what it drives itself.
|
|
12
|
+
export async function pipeline(items, stage1, stage2) {
|
|
13
|
+
return Promise.all(
|
|
14
|
+
items.map(async (item) => {
|
|
15
|
+
let r1;
|
|
16
|
+
try {
|
|
17
|
+
r1 = await stage1(item);
|
|
18
|
+
} catch {
|
|
19
|
+
r1 = null;
|
|
20
|
+
}
|
|
21
|
+
if (!r1) return null;
|
|
22
|
+
try {
|
|
23
|
+
return await stage2(r1, item);
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
export const parallel = (fns) => Promise.all(fns.map((fn) => fn()));
|
|
31
|
+
|
|
32
|
+
export const ARGS = { pr: 7, branch: "feature/x", worktree: "/repo/.worktrees/7-x", scratch: "/scr", testCmd: "node --test", dimensions: ["correctness"] };
|
|
33
|
+
export const SNAP = {
|
|
34
|
+
runRoot: "/scr/pr7/run-ab12",
|
|
35
|
+
path: "/scr/pr7/run-ab12/snapshot-abc123",
|
|
36
|
+
head: "abc123",
|
|
37
|
+
pathVerified: true,
|
|
38
|
+
repoVerified: true,
|
|
39
|
+
testCmd: "node --test",
|
|
40
|
+
};
|
|
41
|
+
export const RAN = { command: "node --test", tests: 5, pass: 5, fail: 0 };
|
|
42
|
+
export const review = (findings, testRun = RAN) => ({
|
|
43
|
+
dimension: "correctness",
|
|
44
|
+
scope_searched: "CWD-AUDIT: clean /repo",
|
|
45
|
+
findings,
|
|
46
|
+
test_run: testRun,
|
|
47
|
+
});
|
|
48
|
+
export const finding = (severity) => ({ severity, claim: `a ${severity} claim`, file: "a.js", line: 3, evidence: "line 3 has no else" });
|
|
49
|
+
export const vote = (refuted) => ({ refuted, reason: "measured. CWD-AUDIT: clean /repo" });
|
|
50
|
+
|
|
51
|
+
// A host whose `agent()` answers each dispatch label from a script, one entry
|
|
52
|
+
// per call in dispatch order (the last entry repeats), and counts the calls.
|
|
53
|
+
// An `Error` entry is thrown rather than returned. Counting happens
|
|
54
|
+
// synchronously on the call, so the two refuters of one pair are calls 1 and
|
|
55
|
+
// 2 of their label, and a re-dispatched pair is calls 3 and 4.
|
|
56
|
+
export function scriptedHost(script) {
|
|
57
|
+
const calls = {};
|
|
58
|
+
return {
|
|
59
|
+
calls,
|
|
60
|
+
host: {
|
|
61
|
+
agent: async (_prompt, opts) => {
|
|
62
|
+
const n = (calls[opts.label] = (calls[opts.label] ?? 0) + 1);
|
|
63
|
+
const seq = script[opts.label];
|
|
64
|
+
if (!seq) throw new Error(`scriptedHost: unexpected dispatch ${opts.label}`);
|
|
65
|
+
const answer = seq[Math.min(n, seq.length) - 1];
|
|
66
|
+
if (answer instanceof Error) throw answer;
|
|
67
|
+
return answer === null ? null : structuredClone(answer);
|
|
68
|
+
},
|
|
69
|
+
phase: () => {},
|
|
70
|
+
log: () => {},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// #1802 (spec docs/specs/2026-09-24-slot-based-fleet-loop-design.md § 3 §2, §6).
|
|
2
|
+
// Two changes to the review's own result, in review-core.mjs's own body:
|
|
3
|
+
//
|
|
4
|
+
// 1. Crash repair inside the run. Each crashed specialist is re-dispatched
|
|
5
|
+
// once, and each refuter pair whose every vote died is re-dispatched once
|
|
6
|
+
// as a pair, before the result is assembled. What still fails lands in
|
|
7
|
+
// `dimensionsUnrun` / `unverified` as before, and `resume` now means
|
|
8
|
+
// "crashed again after the in-run retry".
|
|
9
|
+
// 2. Digest first. The small fields a controller acts on lead the returned
|
|
10
|
+
// object and the bulky finding arrays trail it, so a large review's
|
|
11
|
+
// digest is available without depending on (or risking truncation from)
|
|
12
|
+
// the finding arrays that follow it (before this, `resume` was LAST).
|
|
13
|
+
//
|
|
14
|
+
// Driven through a SCRIPTED HOST rather than a mocked runReview: `agent`,
|
|
15
|
+
// `pipeline`, `parallel`, `phase`, `log` are exactly the parameters
|
|
16
|
+
// runReview takes off `host`, so the retry and the digest ordering are
|
|
17
|
+
// exercised as review-core.mjs's own wiring runs them, never a re-derived
|
|
18
|
+
// copy of what that wiring is supposed to do. The fixtures below are shared
|
|
19
|
+
// with review-path-default.test.mjs's own return-shape pin, via
|
|
20
|
+
// review-host-fixture.mjs.
|
|
21
|
+
import { test } from "node:test";
|
|
22
|
+
import assert from "node:assert/strict";
|
|
23
|
+
import { runReview, DIGEST_KEYS, digestOf } from "./review-core.mjs";
|
|
24
|
+
import { pipeline, parallel, ARGS, SNAP, review, finding, vote, scriptedHost } from "./review-host-fixture.mjs";
|
|
25
|
+
|
|
26
|
+
const COPIES = [["review-core.mjs", (host, args) => runReview({ ...host, pipeline, parallel }, args)]];
|
|
27
|
+
|
|
28
|
+
for (const [name, run] of COPIES) {
|
|
29
|
+
test(`${name}: a specialist that crashes once is re-dispatched, and its review lands`, async () => {
|
|
30
|
+
const { host, calls } = scriptedHost({ snapshot: [SNAP], "review:correctness": [null, review([])] });
|
|
31
|
+
const result = await run(host, ARGS);
|
|
32
|
+
assert.equal(calls["review:correctness"], 2, "a crashed specialist was not re-dispatched in-run");
|
|
33
|
+
assert.deepEqual(result.dimensionsUnrun, [], "the re-dispatched specialist's review was not used");
|
|
34
|
+
assert.equal(result.cwdAudit.length, 1);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test(`${name}: a thrown specialist dispatch is a crash too, and is re-dispatched`, async () => {
|
|
38
|
+
const { host, calls } = scriptedHost({ snapshot: [SNAP], "review:correctness": [new Error("spend limit"), review([])] });
|
|
39
|
+
const result = await run(host, ARGS);
|
|
40
|
+
assert.equal(calls["review:correctness"], 2);
|
|
41
|
+
assert.deepEqual(result.dimensionsUnrun, []);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test(`${name}: a specialist that crashes twice is dispatched exactly twice, then named unrun`, async () => {
|
|
45
|
+
const { host, calls } = scriptedHost({ snapshot: [SNAP], "review:correctness": [null] });
|
|
46
|
+
const result = await run(host, ARGS);
|
|
47
|
+
assert.equal(calls["review:correctness"], 2, "the retry is ONE re-dispatch, not a loop");
|
|
48
|
+
assert.equal(result.dimensionsUnrun.length, 1);
|
|
49
|
+
assert.equal(result.dimensionsUnrun[0].dimension, "correctness");
|
|
50
|
+
assert.match(result.dimensionsUnrun[0].reason, /returned nothing/);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test(`${name}: a specialist that RETURNED but ran no suite is not a crash — never re-dispatched`, async () => {
|
|
54
|
+
const { host, calls } = scriptedHost({
|
|
55
|
+
snapshot: [SNAP],
|
|
56
|
+
"review:correctness": [review([], { command: "node --test", tests: 0, pass: 0, fail: 0 })],
|
|
57
|
+
});
|
|
58
|
+
const result = await run(host, ARGS);
|
|
59
|
+
assert.equal(calls["review:correctness"], 1, "a returned-but-unrun review was re-dispatched as if it had crashed");
|
|
60
|
+
assert.equal(result.dimensionsUnrun.length, 1);
|
|
61
|
+
assert.match(result.dimensionsUnrun[0].reason, /0 tests/);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test(`${name}: a refuter pair whose every vote died is re-dispatched once, as a pair`, async () => {
|
|
65
|
+
const { host, calls } = scriptedHost({
|
|
66
|
+
snapshot: [SNAP],
|
|
67
|
+
"review:correctness": [review([finding("critical")])],
|
|
68
|
+
"verify:correctness": [null, null, vote(false), vote(false)],
|
|
69
|
+
});
|
|
70
|
+
const result = await run(host, ARGS);
|
|
71
|
+
assert.equal(calls["verify:correctness"], 4, "a wholly crashed refuter pair was not re-dispatched as a pair");
|
|
72
|
+
assert.equal(result.survived.length, 1);
|
|
73
|
+
assert.equal(result.survived[0].refutersDispatched, 2);
|
|
74
|
+
assert.deepEqual(result.counts, { survived: 1, refuted: 0, unverified: 0, crashed: 0 });
|
|
75
|
+
assert.equal(result.resume, null, "a pair the retry recovered still reads as crashed");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test(`${name}: a pair that crashes again after the retry is unverified, counted crashed, and resume says so`, async () => {
|
|
79
|
+
const { host, calls } = scriptedHost({
|
|
80
|
+
snapshot: [SNAP],
|
|
81
|
+
"review:correctness": [review([finding("critical")])],
|
|
82
|
+
"verify:correctness": [null],
|
|
83
|
+
});
|
|
84
|
+
const result = await run(host, ARGS);
|
|
85
|
+
assert.equal(calls["verify:correctness"], 4, "the pair retry is ONE re-dispatch, not a loop");
|
|
86
|
+
assert.equal(result.unverified.length, 1);
|
|
87
|
+
assert.equal(result.unverified[0].refutersDispatched, 2);
|
|
88
|
+
assert.deepEqual(result.counts, { survived: 0, refuted: 0, unverified: 1, crashed: 1 });
|
|
89
|
+
assert.match(result.resume, /in-run retry/, "resume no longer says the crash survived the in-run retry");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// #1813: a REJECTED dispatch (not a resolved `null`) is the shape every
|
|
93
|
+
// real `parallel()`/`agent()` failure actually takes on omp — see
|
|
94
|
+
// `retryCrashed`'s own doc comment: "that second answer is final, THROWN or
|
|
95
|
+
// not". Before this fix, a finding whose refuter pair rejected on both
|
|
96
|
+
// `retryCrashed` attempts propagated that rejection into the shared,
|
|
97
|
+
// findings-level `parallel()` (a bare `Promise.all`), which discarded every
|
|
98
|
+
// OTHER finding under the same dimension — including ones whose refuters
|
|
99
|
+
// fully succeeded — and reported the whole dimension `dimensionsUnrun`
|
|
100
|
+
// with the misleading "the reviewer returned nothing" reason, even though
|
|
101
|
+
// the specialist's review DID come back with real findings.
|
|
102
|
+
test(`${name}: a finding whose refuter pair rejects on both retry attempts does not erase its dimension-mates' verdicts`, async () => {
|
|
103
|
+
const crashing = finding("critical");
|
|
104
|
+
const surviving = finding("important");
|
|
105
|
+
const calls = { crashing: 0, surviving: 0 };
|
|
106
|
+
const host = {
|
|
107
|
+
agent: async (prompt, opts) => {
|
|
108
|
+
if (opts.label === "snapshot") return structuredClone(SNAP);
|
|
109
|
+
if (opts.label === "review:correctness") return structuredClone(review([crashing, surviving]));
|
|
110
|
+
if (opts.label === "verify:correctness") {
|
|
111
|
+
if (prompt.includes(crashing.claim)) {
|
|
112
|
+
calls.crashing++;
|
|
113
|
+
throw new Error(`refuter crash ${calls.crashing}`);
|
|
114
|
+
}
|
|
115
|
+
if (prompt.includes(surviving.claim)) {
|
|
116
|
+
calls.surviving++;
|
|
117
|
+
return structuredClone(vote(false));
|
|
118
|
+
}
|
|
119
|
+
throw new Error("scriptedHost: unexpected verify prompt");
|
|
120
|
+
}
|
|
121
|
+
throw new Error(`scriptedHost: unexpected dispatch ${opts.label}`);
|
|
122
|
+
},
|
|
123
|
+
phase: () => {},
|
|
124
|
+
log: () => {},
|
|
125
|
+
};
|
|
126
|
+
const result = await run(host, ARGS);
|
|
127
|
+
assert.equal(calls.crashing, 4, "the crashing pair is dispatched twice per attempt, across both retryCrashed attempts");
|
|
128
|
+
assert.equal(calls.surviving, 2, "the surviving pair's own refuters are undisturbed by the other finding's crash");
|
|
129
|
+
assert.equal(result.survived.length, 1, "a fully-verified sibling finding must not be erased by another finding's crash");
|
|
130
|
+
assert.equal(result.survived[0].claim, surviving.claim);
|
|
131
|
+
assert.equal(result.unverified.length, 1, "the crashed finding is reported unverified, not silently dropped");
|
|
132
|
+
assert.equal(result.unverified[0].claim, crashing.claim);
|
|
133
|
+
assert.equal(result.unverified[0].refutersDispatched, 2);
|
|
134
|
+
assert.deepEqual(result.dimensionsUnrun, [], "the dimension itself ran and returned real findings — it must not read as unrun");
|
|
135
|
+
assert.deepEqual(result.counts, { survived: 1, refuted: 0, unverified: 1, crashed: 1 });
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test(`${name}: a pair with one live vote did not crash — it is ruled on that vote, not re-dispatched`, async () => {
|
|
139
|
+
const { host, calls } = scriptedHost({
|
|
140
|
+
snapshot: [SNAP],
|
|
141
|
+
"review:correctness": [review([finding("important")])],
|
|
142
|
+
"verify:correctness": [null, vote(true)],
|
|
143
|
+
});
|
|
144
|
+
const result = await run(host, ARGS);
|
|
145
|
+
assert.equal(calls["verify:correctness"], 2, "a pair with a surviving vote was re-dispatched as if every refuter had died");
|
|
146
|
+
assert.equal(result.refuted.length, 1);
|
|
147
|
+
assert.deepEqual(result.counts, { survived: 0, refuted: 1, unverified: 0, crashed: 0 });
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test(`${name}: a suggestion's 0-refuter budget is policy, not a crash — nothing is dispatched for it`, async () => {
|
|
151
|
+
const { host, calls } = scriptedHost({ snapshot: [SNAP], "review:correctness": [review([finding("suggestion")])] });
|
|
152
|
+
const result = await run(host, ARGS);
|
|
153
|
+
assert.equal(calls["verify:correctness"], undefined, "a 0-refuter suggestion bought a refuter dispatch");
|
|
154
|
+
assert.equal(result.unverified.length, 1);
|
|
155
|
+
assert.equal(result.unverified[0].refutersDispatched, 0);
|
|
156
|
+
assert.deepEqual(result.counts, { survived: 0, refuted: 0, unverified: 1, crashed: 0 });
|
|
157
|
+
assert.equal(result.resume, null);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test(`${name}: the digest leads the returned object, so it is a prefix of the serialized result`, async () => {
|
|
161
|
+
const { host } = scriptedHost({
|
|
162
|
+
snapshot: [SNAP],
|
|
163
|
+
"review:correctness": [review([finding("critical"), finding("suggestion")])],
|
|
164
|
+
"verify:correctness": [vote(false)],
|
|
165
|
+
});
|
|
166
|
+
const result = await run(host, ARGS);
|
|
167
|
+
assert.deepEqual(Object.keys(result), [...DIGEST_KEYS, "snapshot", "survived", "refuted", "unverified"]);
|
|
168
|
+
// The consumer-visible property, not the key list: the pre-cutover
|
|
169
|
+
// harness hands the controller the FIRST ~8 KB of the serialized result,
|
|
170
|
+
// so every digest field has to be serialized before the first byte of a
|
|
171
|
+
// finding array.
|
|
172
|
+
const whole = JSON.stringify(result);
|
|
173
|
+
const digest = JSON.stringify(digestOf(result));
|
|
174
|
+
assert.ok(whole.startsWith(digest.slice(0, -1) + ","), "a bulk field is serialized ahead of the digest — a large review truncates it away");
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// The accept half of the digest helper: every digest key, nothing else, and in
|
|
179
|
+
// the result's own order — a digest that dropped `resume` is the defect this
|
|
180
|
+
// reorder exists to fix, one layer up.
|
|
181
|
+
test("digestOf keeps exactly the digest keys, in order, and leaves the finding arrays behind", async () => {
|
|
182
|
+
const { host } = scriptedHost({ snapshot: [SNAP], "review:correctness": [review([finding("suggestion")])] });
|
|
183
|
+
const result = await runReview({ ...host, pipeline, parallel }, ARGS);
|
|
184
|
+
const digest = digestOf(result);
|
|
185
|
+
assert.deepEqual(Object.keys(digest), DIGEST_KEYS);
|
|
186
|
+
for (const bulk of ["snapshot", "survived", "refuted", "unverified"]) assert.equal(bulk in digest, false, bulk);
|
|
187
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
// #1349's own acceptance text: `grep -n 'pr-review-toolkit' skills/
|
|
7
|
+
// commands/` returns nothing — the six vendored names are never DISPATCHED.
|
|
8
|
+
// Scoped to those two directories deliberately, not the whole `plugin/`
|
|
9
|
+
// tree: `agents/fleet-review-*.agent.md`'s credit comments plainly name the
|
|
10
|
+
// vendored source they adapted a prompt from (review finding on #1361 — an
|
|
11
|
+
// earlier revision obfuscated the slug there to satisfy an over-widened
|
|
12
|
+
// reading of this same criterion, which helped nobody and made the credit
|
|
13
|
+
// harder to verify). Attribution prose and dispatch names are different
|
|
14
|
+
// claims; this pins the one #1349 actually makes.
|
|
15
|
+
const REPO = join(import.meta.dirname, "..");
|
|
16
|
+
|
|
17
|
+
function allFiles(dir) {
|
|
18
|
+
const out = [];
|
|
19
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
20
|
+
const full = join(dir, entry.name);
|
|
21
|
+
if (entry.isDirectory()) out.push(...allFiles(full));
|
|
22
|
+
else out.push(full);
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
test("no file under skills/ or commands/ mentions the retired vendor plugin", () => {
|
|
28
|
+
for (const dir of ["skills", "commands"]) {
|
|
29
|
+
for (const file of allFiles(join(REPO, dir))) {
|
|
30
|
+
const text = readFileSync(file, "utf8");
|
|
31
|
+
assert.doesNotMatch(text, /pr-review-toolkit/, `${file} still mentions pr-review-toolkit`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// The counterpart: agents/ deliberately DOES name it, in plain text, as
|
|
37
|
+
// attribution — this is not covered by the criterion above and must not be
|
|
38
|
+
// "fixed" into the same obfuscated shape a prior revision tried.
|
|
39
|
+
test("agents/fleet-review-*.agent.md credit the vendored source plainly, not obfuscated", () => {
|
|
40
|
+
const dims = ["correctness", "silent-failure", "tests", "comments", "types", "simplify"];
|
|
41
|
+
for (const key of dims) {
|
|
42
|
+
const text = readFileSync(join(REPO, "agents", `fleet-review-${key}.agent.md`), "utf8");
|
|
43
|
+
assert.match(text, /pr-review-toolkit/, `fleet-review-${key}.agent.md no longer plainly credits the vendored plugin`);
|
|
44
|
+
}
|
|
45
|
+
});
|