@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,451 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { classifyRole, computeSpend, attributeTools, mergeTools } from "./compute-spend.mjs";
|
|
4
|
+
import { foldOmpTranscript } from "./member-record.mjs";
|
|
5
|
+
|
|
6
|
+
const agent = (o) => ({ label: "x", role: "other", cacheWrite: 0, output: 0, cacheRead: 0, ...o });
|
|
7
|
+
|
|
8
|
+
const call = (id, name, cacheWrite = 0) => ({ kind: "assistant", cacheWrite, tools: [{ id, name }] });
|
|
9
|
+
const result = (...rs) => ({ kind: "result", results: rs.map(([id, chars]) => ({ id, chars })) });
|
|
10
|
+
|
|
11
|
+
test("a tool result's cost is the NEXT assistant turn's cache write, not its own turn's", () => {
|
|
12
|
+
// The turn that CALLS a tool has not seen the result yet, so charging it there
|
|
13
|
+
// would credit the cost to whatever the agent happened to do beforehand.
|
|
14
|
+
const tools = attributeTools([
|
|
15
|
+
call("t1", "Bash", 100),
|
|
16
|
+
result(["t1", 500]),
|
|
17
|
+
{ kind: "assistant", cacheWrite: 900, tools: [] },
|
|
18
|
+
]);
|
|
19
|
+
assert.equal(tools.length, 1);
|
|
20
|
+
assert.equal(tools[0].tool, "Bash");
|
|
21
|
+
assert.equal(tools[0].cacheWrite, 900);
|
|
22
|
+
assert.equal(tools[0].resultChars, 500);
|
|
23
|
+
assert.equal(tools[0].calls, 1);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("a multi-result turn splits proportionally by result size", () => {
|
|
27
|
+
const tools = attributeTools([
|
|
28
|
+
{ kind: "assistant", cacheWrite: 0, tools: [{ id: "a", name: "Read" }, { id: "b", name: "Grep" }] },
|
|
29
|
+
result(["a", 750], ["b", 250]),
|
|
30
|
+
{ kind: "assistant", cacheWrite: 1000, tools: [] },
|
|
31
|
+
]);
|
|
32
|
+
const by = Object.fromEntries(tools.map((t) => [t.tool, t.cacheWrite]));
|
|
33
|
+
assert.equal(by.Read, 750);
|
|
34
|
+
assert.equal(by.Grep, 250);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Shared with the omp tests below, which fold the same stream out of omp's
|
|
38
|
+
// own line shape and must attribute it identically.
|
|
39
|
+
const CONSECUTIVE = [
|
|
40
|
+
{ kind: "assistant", cacheWrite: 0, tools: [{ id: "a", name: "Read" }, { id: "b", name: "Grep" }] },
|
|
41
|
+
result(["a", 750]),
|
|
42
|
+
result(["b", 250]),
|
|
43
|
+
{ kind: "assistant", cacheWrite: 1000, tools: [] },
|
|
44
|
+
];
|
|
45
|
+
const ORPHAN = [result(["orphan", 100]), { kind: "assistant", cacheWrite: 50, tools: [] }];
|
|
46
|
+
|
|
47
|
+
test("CONSECUTIVE result turns accumulate — that, not the multi-block turn, is the real shape", () => {
|
|
48
|
+
// Regression. Parallel tool calls do NOT arrive as one user turn carrying two
|
|
49
|
+
// tool_result blocks: across 45,062 real result-bearing turns, none carried
|
|
50
|
+
// two. They arrive as N single-result turns in a row (4,087 occurrences).
|
|
51
|
+
// Replacing `pending` per result turn dropped every batch but the last —
|
|
52
|
+
// 9.1% of all attributions — and made the proportional split above dead code.
|
|
53
|
+
const tools = attributeTools(CONSECUTIVE);
|
|
54
|
+
const by = Object.fromEntries(tools.map((t) => [t.tool, t.cacheWrite]));
|
|
55
|
+
assert.equal(by.Read, 750);
|
|
56
|
+
assert.equal(by.Grep, 250);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("an all-empty result batch still splits evenly rather than vanishing", () => {
|
|
60
|
+
// A tool that returns nothing still costs a turn to process; dropping it would
|
|
61
|
+
// silently under-report the cheap-but-chatty tools.
|
|
62
|
+
const tools = attributeTools([
|
|
63
|
+
{ kind: "assistant", cacheWrite: 0, tools: [{ id: "a", name: "Read" }, { id: "b", name: "Grep" }] },
|
|
64
|
+
result(["a", 0], ["b", 0]),
|
|
65
|
+
{ kind: "assistant", cacheWrite: 400, tools: [] },
|
|
66
|
+
]);
|
|
67
|
+
const by = Object.fromEntries(tools.map((t) => [t.tool, t.cacheWrite]));
|
|
68
|
+
assert.equal(by.Read, 200);
|
|
69
|
+
assert.equal(by.Grep, 200);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("a result whose tool_use id was never seen is counted as unknown, not dropped", () => {
|
|
73
|
+
const tools = attributeTools(ORPHAN);
|
|
74
|
+
assert.equal(tools[0].tool, "unknown");
|
|
75
|
+
assert.equal(tools[0].cacheWrite, 50);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("a trailing result with no following assistant turn costs nothing but is still counted", () => {
|
|
79
|
+
// Truncated transcripts are normal — an agent killed mid-turn. The call and the
|
|
80
|
+
// bytes are real; the cache write never happened, so attributing one would invent spend.
|
|
81
|
+
const tools = attributeTools([call("t1", "Bash", 0), result(["t1", 900])]);
|
|
82
|
+
assert.equal(tools[0].calls, 1);
|
|
83
|
+
assert.equal(tools[0].resultChars, 900);
|
|
84
|
+
assert.equal(tools[0].cacheWrite, 0);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// #1717: omp's side of the two fixtures above, as lines in the shape measured
|
|
88
|
+
// against real ~/.omp/agent/sessions/** (member-record.mjs's foldOmpTranscript
|
|
89
|
+
// comment): the call is a `toolCall` block on the assistant message, and each
|
|
90
|
+
// result is a `toolResult` message line of its own naming the call's id.
|
|
91
|
+
const ompMsg = (message) =>
|
|
92
|
+
JSON.stringify({ type: "message", id: "e1", parentId: null, timestamp: "2026-09-26T10:00:00.000Z", message });
|
|
93
|
+
const ompTurn = (cacheWrite, ...calls) => ompMsg({
|
|
94
|
+
role: "assistant", model: "claude-opus-5", stopReason: calls.length ? "toolUse" : "stop",
|
|
95
|
+
content: calls.map(([id, name]) => ({ type: "toolCall", id, name, arguments: {}, intent: "x" })),
|
|
96
|
+
usage: { input: 1, output: 1, cacheRead: 0, cacheWrite, totalTokens: 2 + cacheWrite, cost: { total: 0.01 } },
|
|
97
|
+
});
|
|
98
|
+
const ompResult = (id, toolName, chars) => ompMsg({
|
|
99
|
+
role: "toolResult", toolCallId: id, toolName, isError: false, timestamp: 1790415990525, details: {},
|
|
100
|
+
content: [{ type: "text", text: "x".repeat(chars) }],
|
|
101
|
+
});
|
|
102
|
+
const ompTools = (...lines) => attributeTools(foldOmpTranscript(lines.join("\n"), "/fake/omp.jsonl").entries);
|
|
103
|
+
|
|
104
|
+
test("omp: parallel results split the next turn's cache write, same as the synthetic fixture above (#1717)", () => {
|
|
105
|
+
// Parallel calls land on omp as consecutive toolResult lines too — measured,
|
|
106
|
+
// the batch sizes match the calls-per-turn counts — so this is the real
|
|
107
|
+
// shape of the proportional split.
|
|
108
|
+
const tools = ompTools(ompTurn(0, ["a", "Read"], ["b", "Grep"]), ompResult("a", "Read", 750), ompResult("b", "Grep", 250), ompTurn(1000));
|
|
109
|
+
assert.deepEqual(tools, attributeTools(CONSECUTIVE));
|
|
110
|
+
const by = Object.fromEntries(tools.map((t) => [t.tool, [t.calls, t.resultChars, t.cacheWrite]]));
|
|
111
|
+
assert.deepEqual(by, { Read: [1, 750, 750], Grep: [1, 250, 250] });
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("omp: a result whose call never landed in an assistant message is unknown (#1717)", () => {
|
|
115
|
+
// The measured way this happens: a turn aborted mid-stream writes the tool's
|
|
116
|
+
// synthetic "not executed" result, then persists the assistant message with
|
|
117
|
+
// empty content, so no `toolCall` block ever carries the id. The result line
|
|
118
|
+
// names the tool itself, but the stream is id-only.
|
|
119
|
+
const tools = ompTools(ompResult("orphan", "bash", 100), ompTurn(50));
|
|
120
|
+
assert.deepEqual(tools, attributeTools(ORPHAN));
|
|
121
|
+
assert.deepEqual(tools.map((t) => [t.tool, t.calls, t.resultChars, t.cacheWrite]), [["unknown", 0, 100, 50]]);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("mergeTools sums across agents and recomputes shares over the merged total", () => {
|
|
125
|
+
const merged = mergeTools([
|
|
126
|
+
[{ tool: "Bash", calls: 2, resultChars: 100, cacheWrite: 300, pct: 100 }],
|
|
127
|
+
[{ tool: "Bash", calls: 1, resultChars: 50, cacheWrite: 100, pct: 50 },
|
|
128
|
+
{ tool: "Read", calls: 4, resultChars: 20, cacheWrite: 100, pct: 50 }],
|
|
129
|
+
]);
|
|
130
|
+
const by = Object.fromEntries(merged.map((t) => [t.tool, t]));
|
|
131
|
+
assert.equal(by.Bash.calls, 3);
|
|
132
|
+
assert.equal(by.Bash.cacheWrite, 400);
|
|
133
|
+
assert.equal(by.Bash.resultChars, 150);
|
|
134
|
+
assert.equal(by.Read.pct, 20);
|
|
135
|
+
assert.equal(merged[0].tool, "Bash"); // sorted by spend
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test("depth beats description for review-shaped names — fan-out is not reviewer spend", () => {
|
|
139
|
+
// The fan-out names grandchildren things like "Review PR 539 correctness".
|
|
140
|
+
// Matching description first would book half the specialist spend as reviewer
|
|
141
|
+
// spend and destroy the only number that matters.
|
|
142
|
+
assert.equal(classifyRole({ spawnDepth: 1, description: "Review PR 539 correctness" }), "specialist");
|
|
143
|
+
assert.equal(classifyRole({ spawnDepth: 2, description: "Implement ticket 540" }), "specialist");
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test("the controller's own UNNAMED dispatches are depth 1 too — sizing is not fan-out", () => {
|
|
147
|
+
// Regression: only NAMED members are depth 0. The phase-0 sizing agents are
|
|
148
|
+
// dispatched straight from the controller but unnamed, so they arrive at
|
|
149
|
+
// depth 1 looking exactly like a specialist. Classifying on depth alone put
|
|
150
|
+
// all five in "specialist" and moved the review headline from 83% to 87%.
|
|
151
|
+
assert.equal(classifyRole({ spawnDepth: 1, description: "Size candidate batch A" }), "sizing");
|
|
152
|
+
assert.equal(classifyRole({ spawnDepth: 1, description: "Size ticket 531" }), "sizing");
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("the sizing pattern is anchored, so a specialist that mentions sizing stays a specialist", () => {
|
|
156
|
+
assert.equal(classifyRole({ spawnDepth: 1, description: "Review PR 539 — check batch sizing logic" }), "specialist");
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test("the memory exclusion reads the recorded DEFINITION, so any member name books memory", () => {
|
|
160
|
+
// #1505. The exclusion used to test the one `agentType` parameter, which the
|
|
161
|
+
// pre-cutover reader filled with the member's NAME — so the same dispatch
|
|
162
|
+
// (`memory-housekeeper`) booked three different roles depending on what it
|
|
163
|
+
// was called: `memory-housekeeper` memory, `housekeeper` other,
|
|
164
|
+
// `brain-housekeeping` specialist. Measured on the corpus that last one alone
|
|
165
|
+
// moved its session's review-spend headline 40.70% -> 62.37%.
|
|
166
|
+
// "brain-housekeeping" is the historical incident (#1505) and the only name
|
|
167
|
+
// of the four originally listed here that a mutation pass found load-bearing:
|
|
168
|
+
// it is the one whose NAME does not itself contain "memory-housekeeper", so
|
|
169
|
+
// it is the one that would slip to "specialist" if the exclusion ever read
|
|
170
|
+
// the member's NAME instead of its recorded DEFINITION.
|
|
171
|
+
assert.equal(
|
|
172
|
+
classifyRole({ agentDefinition: "memory-housekeeper", memberName: "brain-housekeeping", spawnDepth: 1, description: "Housekeep the brain" }),
|
|
173
|
+
"memory",
|
|
174
|
+
);
|
|
175
|
+
// Depth 1 above is the load-bearing half: the specialist rule is what caught
|
|
176
|
+
// `brain-housekeeping`, so this stays red if the exclusion moves below it.
|
|
177
|
+
assert.equal(classifyRole({ agentDefinition: "memory-proxy", memberName: "review-eval", spawnDepth: 2 }), "memory");
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("an untyped dispatch that recorded no definition still classifies by its NAME", () => {
|
|
181
|
+
// #1505's other half. A dispatch before typed agents existed records no
|
|
182
|
+
// definition at all — a closed category, not a hole — so the name is the only
|
|
183
|
+
// memory signal those members have. Measured over the sidecars on disk: three
|
|
184
|
+
// live members rest on this, and dropping it would put `memory-housekeeper`
|
|
185
|
+
// (named for its own definition, at depth 1) in the SPECIALIST bucket, which
|
|
186
|
+
// is the very defect #1505 reports.
|
|
187
|
+
assert.equal(classifyRole({ agentDefinition: "", memberName: "memory-proxy-session-review-2-3" }), "memory");
|
|
188
|
+
assert.equal(classifyRole({ agentDefinition: "", memberName: "memory-housekeeper", spawnDepth: 1 }), "memory");
|
|
189
|
+
// ...and it is still not a guess: a name carrying no memory agent falls
|
|
190
|
+
// through to the ordinary signals rather than being read as memory-adjacent.
|
|
191
|
+
assert.equal(classifyRole({ agentDefinition: "", memberName: "impl-1505", description: "Implement ticket 1505" }), "implementer");
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test("a memory agent named only in the dispatch PROSE does not book memory", () => {
|
|
195
|
+
// The false-positive half, and the reason `desc` is excluded from the
|
|
196
|
+
// exclusion's input: every memory-adjacent fleet member's own prompt names
|
|
197
|
+
// the memory agents, so blending prose would book the lot of them memory and
|
|
198
|
+
// quietly drain the buckets anyone reads.
|
|
199
|
+
assert.equal(classifyRole({ description: "Relay the finding to memory-proxy, then finish PR 563" }), "finisher");
|
|
200
|
+
assert.equal(classifyRole({ memberName: "fix-pr-1505", description: "Fix PR 1505 — memory-housekeeper writes the wrong scope" }), "reviewer");
|
|
201
|
+
assert.equal(classifyRole({ description: "Ask memory-housekeeper about it", spawnDepth: 1 }), "specialist");
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test("depth-0 fleet roles come off the controller's naming convention", () => {
|
|
205
|
+
assert.equal(classifyRole({ spawnDepth: 0, description: "Implement ticket 556" }), "implementer");
|
|
206
|
+
assert.equal(classifyRole({ spawnDepth: 0, description: "Review PR 564" }), "reviewer");
|
|
207
|
+
assert.equal(classifyRole({ spawnDepth: 0, description: "Finish PR 563" }), "finisher");
|
|
208
|
+
|
|
209
|
+
assert.equal(classifyRole({ spawnDepth: 0, description: "something else entirely" }), "other");
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test("the NAME wins over an earlier-checked prose keyword — the fixed branch order must not let description hijack a name-resolved role (#1506)", () => {
|
|
213
|
+
// Blending `${memberName} ${description}` into one haystack before running
|
|
214
|
+
// classifyRole's fixed-order branches (implementer -> reviewer -> finisher
|
|
215
|
+
// -> merge-bot) let a member's own free-text description satisfy an
|
|
216
|
+
// EARLIER branch than the one its canonical NAME would hit, hijacking the
|
|
217
|
+
// classification. Measured live: `finisher-1380` described as "Fix PR 1380
|
|
218
|
+
// review findings." matched the reviewer branch on "review" in the prose
|
|
219
|
+
// before the finisher branch ever saw the name; `merge-bot-12` described
|
|
220
|
+
// with "...review findings" misread the same way as finisher. The name
|
|
221
|
+
// must be checked alone, ahead of the blend.
|
|
222
|
+
assert.equal(
|
|
223
|
+
classifyRole({ memberName: "finisher-1380", description: "Fix PR 1380 review findings." }),
|
|
224
|
+
"finisher",
|
|
225
|
+
);
|
|
226
|
+
assert.equal(
|
|
227
|
+
classifyRole({ memberName: "merge-bot-12", description: "Finish PR 1420, apply the review findings" }),
|
|
228
|
+
"merge-bot",
|
|
229
|
+
);
|
|
230
|
+
// Control: a member with NO canonical name still falls through to the
|
|
231
|
+
// prose blend exactly as before — this fix only reorders, it does not
|
|
232
|
+
// remove the description-only fallback.
|
|
233
|
+
assert.equal(classifyRole({ description: "Fix PR 1380 review findings." }), "reviewer");
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test("resolve-pr-<n> books review spend, off the real dispatched name (#1250)", () => {
|
|
237
|
+
// Real recorded rows, both previously "other" for want of a name match:
|
|
238
|
+
// `resolve-pr-1232` ("Resolve conflict on PR 1232", session caf66206) and
|
|
239
|
+
// `resolve-pr-1310` ("Rebase and resolve conflicts for PR #1310", session
|
|
240
|
+
// 28488458). Descriptions deliberately carry no other review word, so the
|
|
241
|
+
// NAME has to carry the match, the same discipline the finisher spellings
|
|
242
|
+
// above are held to.
|
|
243
|
+
assert.equal(classifyRole({ memberName: "resolve-pr-1232", description: "Resolve conflict on PR 1232" }), "reviewer");
|
|
244
|
+
assert.equal(classifyRole({ memberName: "resolve-pr-1310", description: "Rebase and resolve conflicts for PR #1310" }), "reviewer");
|
|
245
|
+
// The bare prose form ("resolve pr" with no name carrying the PR number)
|
|
246
|
+
// is deliberately NOT matched: neither real cited description above
|
|
247
|
+
// contains it adjacently ("resolve conflict on pr", "resolve conflicts
|
|
248
|
+
// for pr" — never "resolve pr" together), so it would be untested reach.
|
|
249
|
+
// Matching it ahead of the finisher check below would let an unrelated
|
|
250
|
+
// finisher's description that happens to mention "resolve" near "pr"
|
|
251
|
+
// hijack its classification away from its own name.
|
|
252
|
+
assert.equal(classifyRole({ memberName: "finisher-pr-436", description: "Resolve PR conflicts left by review findings" }), "finisher");
|
|
253
|
+
// It must not be swept into merge-bot: this member's number is a PR, never
|
|
254
|
+
// a per-run dispatch counter, and merge-bot drains a pass's PRs rather than
|
|
255
|
+
// resolving one.
|
|
256
|
+
assert.equal(classifyRole({ memberName: "merge-bot-8", description: "Merge pass 8" }), "merge-bot");
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
test("finish-<n> member names classify as finisher — a historical spelling that must stay classifiable", () => {
|
|
260
|
+
// `finisher-pr-<n>` is the canonical finisher name (#326); `finish-<n>` is a
|
|
261
|
+
// spelling earlier runs actually dispatched and recorded runs still have to
|
|
262
|
+
// classify. The match has to come off the member NAME, not the literal words
|
|
263
|
+
// "finish pr" or "finisher": the description deliberately does NOT start with
|
|
264
|
+
// `finish-`, so an implementation keying on `description` alone fails here.
|
|
265
|
+
assert.equal(classifyRole({ memberName: "finish-436", description: "Apply reviewer findings for PR 436" }), "finisher");
|
|
266
|
+
// ...and the `^` has to be a real anchor: `finish-` mid-string is not a
|
|
267
|
+
// finisher. Without this, dropping the anchor leaves the case above green.
|
|
268
|
+
assert.equal(classifyRole({ spawnDepth: 0, description: "Rework the finish-label docs" }), "other");
|
|
269
|
+
// A two-ticket finisher was dispatched as `finish-<n>-<m>`, so the pattern has
|
|
270
|
+
// to match on the prefix rather than on a `finish-<digits>` shape. Its
|
|
271
|
+
// description carries no finisher word either, for the same reason as above.
|
|
272
|
+
assert.equal(classifyRole({ spawnDepth: 0, memberName: "finish-424-425", description: "Apply reviewer findings for PR 424 and 425" }), "finisher");
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
test("missing meta never throws — a transcript with no sibling .meta.json still counts", () => {
|
|
276
|
+
assert.equal(classifyRole(undefined), "other");
|
|
277
|
+
assert.equal(classifyRole({}), "other");
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test("implementers classify off the member NAME, which is where `impl-` actually appears", () => {
|
|
281
|
+
// `^impl-` is anchored against `${memberName} ${description}`, so it only ever
|
|
282
|
+
// fires via the name. Pin that coupling — the description alone never matches.
|
|
283
|
+
// It is the NAME and not the definition on purpose: `impl-332` is what the
|
|
284
|
+
// controller called the member, never an agent definition that exists (#1505).
|
|
285
|
+
assert.equal(classifyRole({ spawnDepth: 0, memberName: "impl-332", description: "whatever" }), "implementer");
|
|
286
|
+
assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "impl-332", description: "whatever" }), "other");
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test("the omp review fan-out classifies off its agent DEFINITION — depth cannot reach it there", () => {
|
|
290
|
+
// The depth check above books a nested fan-out whose specialists are the
|
|
291
|
+
// reviewer's grandchildren under that shape. omp has no such nesting: its
|
|
292
|
+
// `review-eval.mjs` inside the CONTROLLER's own session, so every fan-out
|
|
293
|
+
// member arrives at depth 0 and falls through to the description patterns —
|
|
294
|
+
// which is the exact "Review PR 539 correctness" misread the depth check
|
|
295
|
+
// exists to prevent. Measured 2026-09-16 over the live corpus: 466 of 477
|
|
296
|
+
// `fleet-review-*` rows sit at depth 0, and one definition
|
|
297
|
+
// (`fleet-review-verifier`) split across four buckets — 211 other, 172
|
|
298
|
+
// reviewer, 20 finisher, 2 merge-bot — on nothing but prompt wording.
|
|
299
|
+
assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-review-verifier", description: "Refute finding unv1 on PR 1353" }), "specialist");
|
|
300
|
+
assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-review-correctness", description: "Review PR 1353 correctness" }), "specialist");
|
|
301
|
+
assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-review-snapshot", description: "Cut the snapshot for PR 1353" }), "specialist");
|
|
302
|
+
// And the definition is the ONLY thing these two branches read: a member
|
|
303
|
+
// merely NAMED after a review definition was not dispatched as one (#1505) —
|
|
304
|
+
// `def` empty and `name` carrying the review-shaped string falls through to
|
|
305
|
+
// the description-inclusive fallback below, which has no "fleet-review-"
|
|
306
|
+
// pattern of its own (only `review pr`/`review-pr-`/etc.), so it resolves
|
|
307
|
+
// "other" rather than "specialist".
|
|
308
|
+
assert.equal(classifyRole({ spawnDepth: 0, memberName: "fleet-review-verifier", description: "whatever" }), "other");
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
test("the omp review RUNNER is the reviewer member, not a fan-out specialist, though its definition shares the prefix", () => {
|
|
312
|
+
// #1802. `fleet-review-runner` is the definition the controller dispatches
|
|
313
|
+
// as `review-pr-<n>` — the member that HOLDS a review, at depth 0, whose
|
|
314
|
+
// own fan-out is the specialists. The `fleet-review-` prefix the branch
|
|
315
|
+
// above books as "specialist" would swallow it on the definition alone,
|
|
316
|
+
// before the `review-pr-` name ever got read.
|
|
317
|
+
assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-review-runner", memberName: "review-pr-1353", description: "whatever" }), "reviewer");
|
|
318
|
+
// Exact, not a second prefix: every dimension definition still books as the
|
|
319
|
+
// fan-out it is, including one whose key merely starts with `runner`.
|
|
320
|
+
assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-review-runner-probe", description: "whatever" }), "specialist");
|
|
321
|
+
assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-review-correctness", memberName: "review-pr-1353", description: "whatever" }), "specialist");
|
|
322
|
+
// Depth still wins: whatever runs UNDER a runner is its fan-out.
|
|
323
|
+
assert.equal(classifyRole({ spawnDepth: 1, agentDefinition: "fleet-review-runner", description: "whatever" }), "specialist");
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
test("a definition name in the dispatch PROSE is not a dispatch — the fleet branches read `def` alone", () => {
|
|
327
|
+
// The false-positive half. Every fleet member's own prompt says what it is, so
|
|
328
|
+
// these names appear in description text constantly; matching the
|
|
329
|
+
// `${memberName} ${description}` blend would book a finisher that merely
|
|
330
|
+
// mentions the review fan-out as one of its specialists.
|
|
331
|
+
assert.equal(classifyRole({ spawnDepth: 0, description: "Relay the report to fleet-review-verifier" }), "other");
|
|
332
|
+
assert.equal(classifyRole({ spawnDepth: 0, description: "Dispatch every implementer as fleet-implementer" }), "other");
|
|
333
|
+
// And the control that must stay GREEN: prose-only input still classifies by
|
|
334
|
+
// its prose, so this narrowing did not cost the description patterns anything.
|
|
335
|
+
assert.equal(classifyRole({ spawnDepth: 0, description: "Apply fleet-review-verifier findings, then finish PR 563" }), "finisher");
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
test("the fleet implementer definitions classify as implementer, independent of the `^impl-` name pattern", () => {
|
|
339
|
+
// `agentDefinition`-based classification (`fleet-implementer(-alt)`) is
|
|
340
|
+
// checked BEFORE the `^impl-` name/description pattern below it, so it must
|
|
341
|
+
// not depend on a canonically-shaped member name to fire — this pin
|
|
342
|
+
// exercises classifyRole directly, on `agentDefinition` alone, so it stays
|
|
343
|
+
// green whatever the reader hands `memberName`.
|
|
344
|
+
//
|
|
345
|
+
// Historically this was the ONLY implementer signal an omp member had:
|
|
346
|
+
// before #1486, `agentDefinition` did not reach classifyRole from omp at
|
|
347
|
+
// all, and before #1506, `memberName` did not either — readOmpMember left
|
|
348
|
+
// it unset on the theory that the AgentId is a generated CamelCase word
|
|
349
|
+
// pair naming nothing. #1506 closed that: a canonically-named omp member
|
|
350
|
+
// (`impl-<n>`) now reaches `^impl-` too, through `memberName`, exactly like
|
|
351
|
+
// this branch already reaches it through `agentDefinition`. Measured
|
|
352
|
+
// 2026-09-16 before #1486's branch: 90 omp fleet-implementer/-alt rows
|
|
353
|
+
// split 73 other, 7 merge-bot, 5 finisher, 5 reviewer, none of them
|
|
354
|
+
// implementer — the gap was in what omp handed classifyRole, not in the
|
|
355
|
+
// classifier's own patterns.
|
|
356
|
+
assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-implementer", description: "Ticket #1486. Worktree: .worktrees/1486-classify" }), "implementer");
|
|
357
|
+
assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-implementer-alt", description: "Ticket #1486. Worktree: .worktrees/1486-classify" }), "implementer");
|
|
358
|
+
// EXACT, unlike the review prefix above: the alternate-tier pairing is closed
|
|
359
|
+
// at these two names, so a third `fleet-implementer-`-prefixed definition is a
|
|
360
|
+
// deliberate addition and not something to classify in advance.
|
|
361
|
+
assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-implementer-probe", description: "whatever" }), "other");
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
test("depth still outranks the definition — a fleet member's own fan-out is not another implementer", () => {
|
|
365
|
+
// Ordering pin. Both new branches sit BEHIND the depth check, so a child an
|
|
366
|
+
// implementer dispatched is the specialist it structurally is rather than
|
|
367
|
+
// inheriting its parent's definition. Move either branch above the depth
|
|
368
|
+
// check and this goes red.
|
|
369
|
+
assert.equal(classifyRole({ spawnDepth: 1, agentDefinition: "fleet-implementer", description: "whatever" }), "specialist");
|
|
370
|
+
// And memory still outranks both, which is the rule that keeps memory-system
|
|
371
|
+
// work out of review spend.
|
|
372
|
+
assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "memory-proxy", description: "Review PR 1353 correctness" }), "memory");
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
test("a role outside ROLE_ORDER is still reported, so percentages sum to 100", () => {
|
|
376
|
+
// Regression: roles were built by mapping over ROLE_ORDER, so an unknown role
|
|
377
|
+
// vanished from the table while its tokens stayed in totals — the column
|
|
378
|
+
// silently stopped summing to 100 and the run read as cheaper than it was.
|
|
379
|
+
const { roles, totals } = computeSpend({
|
|
380
|
+
agents: [agent({ role: "weird", cacheWrite: 500 }), agent({ role: "reviewer", cacheWrite: 500 })],
|
|
381
|
+
});
|
|
382
|
+
assert.equal(totals.cacheWrite, 1000);
|
|
383
|
+
assert.deepEqual(roles.map((r) => r.role).sort(), ["reviewer", "weird"]);
|
|
384
|
+
assert.equal(roles.reduce((n, r) => n + r.pct, 0), 100);
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
test("percentages are of cache_creation, not of raw tokens", () => {
|
|
388
|
+
// cacheRead is deliberately lopsided here: if it leaked into the ranking or
|
|
389
|
+
// the percentage base, the implementer would outrank the reviewer.
|
|
390
|
+
const { roles, totals } = computeSpend({
|
|
391
|
+
agents: [
|
|
392
|
+
agent({ role: "reviewer", cacheWrite: 300, cacheRead: 10 }),
|
|
393
|
+
agent({ role: "implementer", cacheWrite: 100, cacheRead: 9_000_000 }),
|
|
394
|
+
],
|
|
395
|
+
});
|
|
396
|
+
assert.equal(roles[0].role, "reviewer");
|
|
397
|
+
assert.equal(roles[0].pct, 75);
|
|
398
|
+
assert.equal(roles[1].pct, 25);
|
|
399
|
+
assert.equal(totals.cacheRead, 9_000_010);
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
test("reviewPct sums specialists and reviewers", () => {
|
|
403
|
+
const { reviewPct } = computeSpend({
|
|
404
|
+
agents: [
|
|
405
|
+
agent({ role: "specialist", cacheWrite: 470 }),
|
|
406
|
+
agent({ role: "reviewer", cacheWrite: 360 }),
|
|
407
|
+
agent({ role: "implementer", cacheWrite: 170 }),
|
|
408
|
+
],
|
|
409
|
+
});
|
|
410
|
+
assert.equal(Math.round(reviewPct), 83);
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
test("an empty run produces zeroes, not NaN", () => {
|
|
414
|
+
const s = computeSpend({ agents: [] });
|
|
415
|
+
assert.equal(s.totals.cacheWrite, 0);
|
|
416
|
+
assert.deepEqual(s.roles, []);
|
|
417
|
+
assert.deepEqual(s.top, []);
|
|
418
|
+
assert.equal(s.reviewPct, 0);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
test("top is ranked by cache_creation and honours topN", () => {
|
|
422
|
+
const { top } = computeSpend({
|
|
423
|
+
agents: [
|
|
424
|
+
agent({ label: "a", cacheWrite: 10 }),
|
|
425
|
+
agent({ label: "b", cacheWrite: 30 }),
|
|
426
|
+
agent({ label: "c", cacheWrite: 20 }),
|
|
427
|
+
],
|
|
428
|
+
topN: 2,
|
|
429
|
+
});
|
|
430
|
+
assert.deepEqual(top.map((t) => t.label), ["b", "c"]);
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
// #1879: `model` rides along on a top row only where the caller's agent
|
|
434
|
+
// object supplied one. An agent with no `model` key must not gain one on its
|
|
435
|
+
// top row: neither `model: null`, a column the served payload would then
|
|
436
|
+
// carry, nor `model: undefined`, which JSON drops but an own-key check on
|
|
437
|
+
// the in-process object still sees.
|
|
438
|
+
test("a top row carries `model` only when its agent supplied one (#1879)", () => {
|
|
439
|
+
const { top } = computeSpend({
|
|
440
|
+
agents: [
|
|
441
|
+
agent({ label: "no-model", role: "implementer", cacheWrite: 30 }),
|
|
442
|
+
agent({ label: "with-model", role: "implementer", model: "claude-opus-5", cacheWrite: 20 }),
|
|
443
|
+
],
|
|
444
|
+
});
|
|
445
|
+
const [noModel, withModel] = top;
|
|
446
|
+
assert.equal(noModel.label, "no-model");
|
|
447
|
+
assert.equal(Object.hasOwn(noModel, "model"), false,
|
|
448
|
+
`a row with no supplied model must carry no \`model\` key at all, got ${JSON.stringify(Object.keys(noModel))}`);
|
|
449
|
+
assert.equal(withModel.label, "with-model");
|
|
450
|
+
assert.equal(withModel.model, "claude-opus-5");
|
|
451
|
+
});
|
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
// #35. A fleet reference doc cited its whole evidence base as "PR #574" while
|
|
7
|
+
// this repo's PRs stop in the thirties, so the number reads as local — to a
|
|
8
|
+
// human and to an agent. Not a broken link (a repo's own markdown files link
|
|
9
|
+
// nothing); a reader defect, which is why counts-not-numbers was the only
|
|
10
|
+
// workaround the file had. The convention that closes it is host-split, and
|
|
11
|
+
// both halves need pinning: the rule in the Reviewers section, which the
|
|
12
|
+
// controller relays to a hand-dispatched fallback reviewer, and the applied
|
|
13
|
+
// instance where the foreign evidence sits.
|
|
14
|
+
const REPO = join(import.meta.dirname, "..");
|
|
15
|
+
const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
|
|
16
|
+
const CORRECTIONS = readFileSync(
|
|
17
|
+
join(REPO, "skills", "run-team", "references", "correction-tickets.md"),
|
|
18
|
+
"utf8",
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// Slice-scoped, not whole-file: SKILL.md is 1200+ lines and a bare presence
|
|
22
|
+
// check anywhere in it stays green when the text lands somewhere its reader
|
|
23
|
+
// never reaches (measured before in this repo — member-prompt-prose.test.mjs
|
|
24
|
+
// #172). The correction-ticket rule block sits under `### Reviewers`, and its
|
|
25
|
+
// own closing clause names the reader the controller has to relay it to: a
|
|
26
|
+
// hand-dispatched fallback reviewer.
|
|
27
|
+
function slice(text, startAnchor, endAnchor, what, { endsFile = false } = {}) {
|
|
28
|
+
const at = text.indexOf(startAnchor);
|
|
29
|
+
assert.notEqual(at, -1, `${what} start anchor ('${startAnchor}') moved — update this test`);
|
|
30
|
+
const end = text.indexOf(endAnchor, at);
|
|
31
|
+
// `endsFile` sections run to EOF until someone appends a section after them,
|
|
32
|
+
// so a missing end anchor is the normal state there, not a moved anchor.
|
|
33
|
+
if (end === -1 && endsFile) return text.slice(at);
|
|
34
|
+
assert.notEqual(end, -1, `${what} end anchor ('${endAnchor}') moved — update this test`);
|
|
35
|
+
return text.slice(at, end);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Markdown hard-wraps at ~80 columns, so a phrase splits across lines. Phrase
|
|
39
|
+
// matches need the wrap invisible.
|
|
40
|
+
const flat = (s) => s.replace(/\s+/g, " ");
|
|
41
|
+
|
|
42
|
+
const correctionRuleBlock = () =>
|
|
43
|
+
flat(
|
|
44
|
+
slice(
|
|
45
|
+
RUN_TEAM,
|
|
46
|
+
"**Correction tickets ship new wrong claims",
|
|
47
|
+
"#### Fallback: hand-dispatched reviewer member",
|
|
48
|
+
"the correction-ticket rule block",
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const conventionSection = () =>
|
|
53
|
+
flat(
|
|
54
|
+
slice(CORRECTIONS, "## Citing evidence from another repo's run", "\n## ", "the citation convention", {
|
|
55
|
+
endsFile: true,
|
|
56
|
+
}),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const secondRunSection = () =>
|
|
60
|
+
flat(slice(CORRECTIONS, "## Second mechanism", "## The clause-by-clause duty", "the second-run evidence"));
|
|
61
|
+
|
|
62
|
+
test("the cross-repo citation rule reaches the reviewer, in the rule block the controller relays to a fallback reviewer", () => {
|
|
63
|
+
const block = correctionRuleBlock();
|
|
64
|
+
assert.match(
|
|
65
|
+
block,
|
|
66
|
+
/another repo/i,
|
|
67
|
+
"the correction-ticket rule block no longer says anything about evidence from another repo — a fallback reviewer relayed only this block stops catching a bare `#N` written for foreign evidence",
|
|
68
|
+
);
|
|
69
|
+
assert.match(
|
|
70
|
+
block,
|
|
71
|
+
/owner\/repo#N/,
|
|
72
|
+
"the github.com half of the citation rule is gone from the block the controller relays",
|
|
73
|
+
);
|
|
74
|
+
assert.match(
|
|
75
|
+
block,
|
|
76
|
+
/GHE/,
|
|
77
|
+
"the non-github.com half is gone — the rule now reads as if `owner/repo#N` fits every source, which is the form that resolves to nothing for a GHE-hosted one",
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test("the convention splits by host, and both branches name what to write", () => {
|
|
82
|
+
const section = conventionSection();
|
|
83
|
+
assert.match(
|
|
84
|
+
section,
|
|
85
|
+
/github\.com.*owner\/repo#N/,
|
|
86
|
+
"the github.com branch no longer prescribes the qualified `owner/repo#N` form",
|
|
87
|
+
);
|
|
88
|
+
assert.match(
|
|
89
|
+
section,
|
|
90
|
+
/(GHE|GitLab|internal).*naming (the )?host and repo/i,
|
|
91
|
+
"the non-github.com branch no longer prescribes prose naming the host and the repo",
|
|
92
|
+
);
|
|
93
|
+
assert.match(
|
|
94
|
+
section,
|
|
95
|
+
/cannot be settled from this repo/,
|
|
96
|
+
"the non-github.com branch no longer requires marking the evidence unsettleable from here — a reader is left believing a settling command exists for it",
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("the convention carves out this repo's own references instead of banning bare `#N`", () => {
|
|
101
|
+
// The REFUSE half. Stated as "never write a bare `#N`" the rule condemns
|
|
102
|
+
// every local reference in the repo, this file's own `PR #32` included.
|
|
103
|
+
assert.match(
|
|
104
|
+
conventionSection(),
|
|
105
|
+
/own issues and PRs stay bare `#N`/,
|
|
106
|
+
"the convention no longer says local references stay bare — read as a blanket ban it sends a reader qualifying hundreds of correct local `#N`s",
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("the second-run evidence names its source repo, its host, and that it cannot be settled here", () => {
|
|
111
|
+
const section = secondRunSection();
|
|
112
|
+
assert.match(
|
|
113
|
+
section,
|
|
114
|
+
/CoCo\/agent-brain/,
|
|
115
|
+
"the second-run evidence no longer identifies its source repo — 'a different repo' gives provenance without identity, so a reader cannot reach the evidence at all",
|
|
116
|
+
);
|
|
117
|
+
assert.match(
|
|
118
|
+
section,
|
|
119
|
+
/bmw\.ghe\.com/,
|
|
120
|
+
"the host is gone — without it a reader takes `CoCo/agent-brain` for a github.com repo and gets a 404",
|
|
121
|
+
);
|
|
122
|
+
assert.match(
|
|
123
|
+
section,
|
|
124
|
+
/none of it can be settled from this repo/,
|
|
125
|
+
"the unsettleable marker is gone, and the ordinals this section carries ('4th of 5', '3rd') read as claims someone could re-check against this tree",
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("the ordinal-verification mechanism is named as behavior, not in the source repo's test vocabulary", () => {
|
|
130
|
+
const section = secondRunSection();
|
|
131
|
+
assert.doesNotMatch(
|
|
132
|
+
section,
|
|
133
|
+
/\bexpects?\b/i,
|
|
134
|
+
"the mechanism is scoped as foreign vocabulary again (`git grep 'expect(' HEAD` → zero hits here; this repo is `node:test` + `assert.*`), which invites a reader to discard a lesson that applies here unchanged",
|
|
135
|
+
);
|
|
136
|
+
assert.match(
|
|
137
|
+
section,
|
|
138
|
+
/failing assertion aborts the rest of its test/,
|
|
139
|
+
"the aborting-assertion behavior is no longer named generically — with it gone the ordinal trap reads as a quirk of someone else's runner",
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("local references in the same file are still bare — the convention did not get applied to them", () => {
|
|
144
|
+
// ACCEPT side. `PR #32` is this repo's own, MERGED, and correct as written;
|
|
145
|
+
// an over-applied convention rewrites it to `feigi/claude-config#32`.
|
|
146
|
+
assert.match(
|
|
147
|
+
CORRECTIONS,
|
|
148
|
+
/PR #32 measured/,
|
|
149
|
+
"the local `PR #32` reference was rewritten — the convention covers foreign evidence only, and qualifying a local reference is the false positive it must not produce",
|
|
150
|
+
);
|
|
151
|
+
assert.doesNotMatch(
|
|
152
|
+
CORRECTIONS,
|
|
153
|
+
/feigi\/claude-config#/,
|
|
154
|
+
"a local reference got the cross-repo qualified form; bare `#N` is correct and required for this repo's own issues and PRs",
|
|
155
|
+
);
|
|
156
|
+
});
|