@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,507 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, utimesSync, existsSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join, dirname } from "node:path";
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { normalizeModel, parseMemberName, rowsForSession, COLUMNS, mergeRows, formatTsv, parseTsv } from "./member-outcomes.mjs";
|
|
8
|
+
|
|
9
|
+
test("a versioned model id is kept verbatim", () => {
|
|
10
|
+
assert.equal(normalizeModel("claude-opus-5"), "claude-opus-5");
|
|
11
|
+
assert.equal(normalizeModel("claude-haiku-4-5-20251001"), "claude-haiku-4-5-20251001");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("the [1m] context variant is stripped — it is the same model", () => {
|
|
15
|
+
// A member's `model` can read "claude-opus-5[1m]" on one turn while another
|
|
16
|
+
// turn of the same member says "claude-opus-5". Two spellings of one model
|
|
17
|
+
// would split every count.
|
|
18
|
+
assert.equal(normalizeModel("claude-opus-5[1m]"), "claude-opus-5");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("a bare alias stays bare — it cannot be resolved to a version", () => {
|
|
22
|
+
// Guessing a version here would invent data. `opus` is honestly less precise
|
|
23
|
+
// than `claude-opus-5`, and a read-out can group on the family prefix.
|
|
24
|
+
assert.equal(normalizeModel("opus"), "opus");
|
|
25
|
+
assert.equal(normalizeModel("sonnet"), "sonnet");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("<synthetic> is dropped, not mapped — it is not a model", () => {
|
|
29
|
+
assert.equal(normalizeModel("<synthetic>"), null);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("empty and absent are dropped", () => {
|
|
33
|
+
assert.equal(normalizeModel(""), null);
|
|
34
|
+
assert.equal(normalizeModel(undefined), null);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("impl-<n> names a TICKET, not a PR", () => {
|
|
38
|
+
assert.deepEqual(parseMemberName("impl-580"), { ticket: "580", pr: "" });
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("every pr-shaped member name yields a PR and no ticket", () => {
|
|
42
|
+
assert.deepEqual(parseMemberName("fix-pr-662"), { ticket: "", pr: "662" });
|
|
43
|
+
assert.deepEqual(parseMemberName("review-pr-555"), { ticket: "", pr: "555" });
|
|
44
|
+
assert.deepEqual(parseMemberName("finisher-pr-904"), { ticket: "", pr: "904" });
|
|
45
|
+
assert.deepEqual(parseMemberName("finish-pr-601"), { ticket: "", pr: "601" });
|
|
46
|
+
assert.deepEqual(parseMemberName("finisher-532"), { ticket: "", pr: "532" });
|
|
47
|
+
assert.deepEqual(parseMemberName("finish-567"), { ticket: "", pr: "567" });
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("resolve-pr-<n> names a PR and no ticket (#1250)", () => {
|
|
51
|
+
// `resolve-pr-<n>` is the controller's conflict/rebase-resolver dispatch
|
|
52
|
+
// against an already-open PR, real recorded names, the unrecognised before
|
|
53
|
+
// this fix: `resolve-pr-1232`. Unmatched, it fell through to `{ticket:"",
|
|
54
|
+
// pr:""}`, losing the join key into tier-outcomes.tsv.
|
|
55
|
+
assert.deepEqual(parseMemberName("resolve-pr-1232"), { ticket: "", pr: "1232" });
|
|
56
|
+
// The re-dispatch suffixes (#1482) apply to this family too, every other
|
|
57
|
+
// PR-shaped name, the same as `resolve-pr-1440-2`, { ticket: "", pr: "1440" }.
|
|
58
|
+
assert.deepEqual(parseMemberName("resolve-pr-1440-2"), { ticket: "", pr: "1440" });
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("merge-bot's number is a per-run dispatch counter, never a PR, so it is neither ticket nor PR", () => {
|
|
62
|
+
// merge-bot-12 is the twelfth merge bot this run dispatched, not PR 12.
|
|
63
|
+
// Booking it as a pr would join this row to an unrelated PR's verdict row.
|
|
64
|
+
assert.deepEqual(parseMemberName("merge-bot-12"), { ticket: "", pr: "" });
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("a retry suffix does not change what the name identifies", () => {
|
|
68
|
+
// run-team spawns `impl-<N>-b` when a member is re-dispatched.
|
|
69
|
+
assert.deepEqual(parseMemberName("impl-580-b"), { ticket: "580", pr: "" });
|
|
70
|
+
assert.deepEqual(parseMemberName("finisher-903-c"), { ticket: "", pr: "903" });
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("a -v<n> re-dispatch suffix is stripped the same way as a retry letter", () => {
|
|
74
|
+
// #1482: a controller re-dispatches a finisher/reviewer against a PR whose
|
|
75
|
+
// head moved after label — `<name>-v2`, `<name>-v10`, etc. Left unstripped,
|
|
76
|
+
// this fell through to a blank pr column, orphaning the token row from the
|
|
77
|
+
// PR's outcome.
|
|
78
|
+
assert.deepEqual(parseMemberName("finisher-pr-1475-v2"), { ticket: "", pr: "1475" });
|
|
79
|
+
// Two-digit suffixes are the same spelling, not a special case: -v10 is the
|
|
80
|
+
// tenth re-dispatch, not a different pattern than -v2.
|
|
81
|
+
assert.deepEqual(parseMemberName("finisher-pr-1475-v10"), { ticket: "", pr: "1475" });
|
|
82
|
+
// The existing single-letter retry suffix keeps working unchanged.
|
|
83
|
+
assert.deepEqual(parseMemberName("finisher-pr-1475-b"), { ticket: "", pr: "1475" });
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("a bare numeric re-dispatch suffix is stripped for PR-shaped names only (#1482)", () => {
|
|
87
|
+
// The numeric-only suffix (a genuine second-ticket batch, not a retry) is
|
|
88
|
+
// still deliberately NOT stripped for a TICKET-shaped name.
|
|
89
|
+
assert.deepEqual(parseMemberName("impl-137-2"), { ticket: "", pr: "" });
|
|
90
|
+
// The commoner numeric re-dispatch spelling (no `-v`, no letter) also falls
|
|
91
|
+
// through the old regex: `finisher-pr-1440-2`, `fix-pr-1281-2`. A trailing
|
|
92
|
+
// `-\d+` cannot be a second ticket the way `impl-<ticket>-<n>`'s can —
|
|
93
|
+
// measured across docs/metrics/member-outcomes.tsv: 476,202 cache-create
|
|
94
|
+
// tokens across 7 real rows fell through to a blank pr column this way,
|
|
95
|
+
// more than the 37,580 the -v<n> fix above addressed.
|
|
96
|
+
assert.deepEqual(parseMemberName("finisher-pr-1440-2"), { ticket: "", pr: "1440" });
|
|
97
|
+
assert.deepEqual(parseMemberName("fix-pr-1281-2"), { ticket: "", pr: "1281" });
|
|
98
|
+
// The ticket-shaped impl-<ticket>-<n> family is untouched: its second-ticket
|
|
99
|
+
// ambiguity is real, and a PR-shaped name's is not.
|
|
100
|
+
assert.deepEqual(parseMemberName("impl-753-2"), { ticket: "", pr: "" });
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("an unrecognised name yields blanks, never a guess", () => {
|
|
104
|
+
assert.deepEqual(parseMemberName("size candidate 7"), { ticket: "", pr: "" });
|
|
105
|
+
assert.deepEqual(parseMemberName(""), { ticket: "", pr: "" });
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
// omp fixtures — shaped like real ~/.omp/agent/sessions/**/*.jsonl lines
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
111
|
+
|
|
112
|
+
const evt = (o) => JSON.stringify(o);
|
|
113
|
+
const sessionEvt = (cwd) => evt({ type: "session", version: 3, id: "s1", timestamp: "2026-09-08T15:11:49.444Z", cwd });
|
|
114
|
+
const thinkingEvt = (level) => evt({ type: "thinking_level_change", id: "t1", parentId: null, timestamp: "2026-09-08T15:11:49.494Z", thinkingLevel: level, configured: null });
|
|
115
|
+
const sessionInitEvt = (task, agent) => evt({ type: "session_init", id: "i1", parentId: "t1", timestamp: "2026-09-08T15:11:49.495Z", task, agent });
|
|
116
|
+
const assistantEvt = (model, usage = {}, ts = "2026-08-25T09:00:00.000Z") => evt({
|
|
117
|
+
type: "message", id: "m1", parentId: "i1", timestamp: ts,
|
|
118
|
+
message: { role: "assistant", content: [{ type: "text", text: "ok" }], model, usage: { input: 1, output: 1, cacheRead: 0, cacheWrite: 0, totalTokens: 2, cost: { total: 0.001 }, ...usage } },
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// A real `<ISO>_<uuid>` name: most of this file's fixtures reach the CLI via
|
|
122
|
+
// spawnSync, and the CLI now refuses (#1302-style) a directory whose own
|
|
123
|
+
// name is not an omp session dir — see "a directory that is not an omp
|
|
124
|
+
// session dir is a refusal" below. rowsForSession() itself still reads
|
|
125
|
+
// whatever directory it is handed and applies no name gate of its own; only
|
|
126
|
+
// the CLI (member-outcomes.mjs's main()) and readMembers()'s tree walk
|
|
127
|
+
// (member-record.test.mjs) do.
|
|
128
|
+
function fixture(members) {
|
|
129
|
+
const root = mkdtempSync(join(tmpdir(), "mo-"));
|
|
130
|
+
const sessionDir = join(root, "2026-08-25T09-00-00-000Z_abcdef12-3456-7890-abcd-ef1234567890");
|
|
131
|
+
for (const [name, lines] of members) {
|
|
132
|
+
const file = join(sessionDir, `${name}.jsonl`);
|
|
133
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
134
|
+
writeFileSync(file, lines.join("\n") + "\n");
|
|
135
|
+
utimesSync(file, new Date("2026-08-25T09:00:00Z"), new Date("2026-08-25T09:00:00Z"));
|
|
136
|
+
}
|
|
137
|
+
return sessionDir;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
test("one row per member, stamped with the session and its run date", () => {
|
|
141
|
+
const dir = fixture([
|
|
142
|
+
["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]],
|
|
143
|
+
["merge-bot-12", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("merge bot pass 12", "fleet-merge-bot"), assistantEvt("claude-opus-5")]],
|
|
144
|
+
]);
|
|
145
|
+
const rows = rowsForSession(dir);
|
|
146
|
+
assert.equal(rows.length, 2);
|
|
147
|
+
assert.equal(rows[0].session, "2026-08-25T09-00-00-000Z_abcdef12-3456-7890-abcd-ef1234567890");
|
|
148
|
+
assert.equal(rows[0].run_date, "2026-08-25");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("a member whose file readFileSync cannot read is skipped without losing its siblings", () => {
|
|
152
|
+
// Not a permissions test (unreliable across CI users/root) — a directory
|
|
153
|
+
// named `<x>.jsonl` matches the recursive `.jsonl` filter exactly the same
|
|
154
|
+
// way a regular file does, and readFileSync on a directory throws EISDIR,
|
|
155
|
+
// the same class of per-file fault the try/catch below exists to survive.
|
|
156
|
+
const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
|
|
157
|
+
mkdirSync(join(dir, "bad.jsonl"));
|
|
158
|
+
assert.equal(rowsForSession(dir).length, 1);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("a session directory that does not exist yields no rows and does not throw", () => {
|
|
162
|
+
const root = mkdtempSync(join(tmpdir(), "mo-"));
|
|
163
|
+
assert.deepEqual(rowsForSession(join(root, "never-created")), []);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test("a member that yields no row still dates the session, and its siblings survive", () => {
|
|
167
|
+
// A member dispatched but not yet answered (session_init, no assistant turn
|
|
168
|
+
// yet) is dropped, but it DID write a transcript: its mtime is part of when
|
|
169
|
+
// this session ran. Sampling mtime only for surviving members would date
|
|
170
|
+
// the session from the older sibling.
|
|
171
|
+
const dir = fixture([
|
|
172
|
+
["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]],
|
|
173
|
+
["impl-581", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("Implement ticket 581", "fleet-implementer")]],
|
|
174
|
+
]);
|
|
175
|
+
const newer = join(dir, "impl-581.jsonl");
|
|
176
|
+
utimesSync(newer, new Date("2026-08-26T09:00:00Z"), new Date("2026-08-26T09:00:00Z"));
|
|
177
|
+
|
|
178
|
+
const rows = rowsForSession(dir);
|
|
179
|
+
assert.equal(rows.length, 1);
|
|
180
|
+
assert.equal(rows[0].member, "impl-580");
|
|
181
|
+
assert.equal(rows[0].run_date, "2026-08-26");
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("a nested member's fan-out is scraped too, keyed on its path-relative stem", () => {
|
|
185
|
+
// Transcripts live at TWO depths: the flat top-level ones a directly-
|
|
186
|
+
// dispatched member writes, and one level deeper for the fan-out a member
|
|
187
|
+
// itself dispatches (a nested reviewer, say). A one-level readdir would
|
|
188
|
+
// miss the whole nested half.
|
|
189
|
+
//
|
|
190
|
+
// Mutation this must survive: dropping `{ recursive: true }`.
|
|
191
|
+
const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
|
|
192
|
+
mkdirSync(join(dir, "Nested"), { recursive: true });
|
|
193
|
+
writeFileSync(join(dir, "Nested", "Reviewer.jsonl"), [
|
|
194
|
+
sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("Review PR 943"), assistantEvt("claude-sonnet-5"),
|
|
195
|
+
].join("\n") + "\n");
|
|
196
|
+
|
|
197
|
+
const rows = rowsForSession(dir);
|
|
198
|
+
assert.equal(rows.length, 2);
|
|
199
|
+
const nested = rows.find((r) => r.model === "claude-sonnet-5");
|
|
200
|
+
assert.ok(nested, "the nested transcript produced a row");
|
|
201
|
+
// The stem carries the path, which is what keeps `agent` unique across the
|
|
202
|
+
// two depths — and what lets this widening REPLACE existing rows rather
|
|
203
|
+
// than duplicate them, since a flat stem is unchanged by recursing.
|
|
204
|
+
assert.equal(nested.agent, "Nested/Reviewer");
|
|
205
|
+
assert.equal(rows.find((r) => r.model === "claude-opus-5").agent, "impl-580");
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
test("role comes from classifyRole and is not invented here", () => {
|
|
209
|
+
// `role` had no assertion anywhere: it is the GROUPING column of the header's
|
|
210
|
+
// pair query, so a classifyRole regression moved every bucket in the read-out
|
|
211
|
+
// while the suite stayed green.
|
|
212
|
+
const dir = fixture([
|
|
213
|
+
["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]],
|
|
214
|
+
["merge-bot-3", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("merge pass 3", "fleet-merge-bot"), assistantEvt("claude-opus-5")]],
|
|
215
|
+
["general-purpose", [sessionEvt("/x"), sessionInitEvt("Review PR 943 correctness"), assistantEvt("claude-opus-5")]],
|
|
216
|
+
]);
|
|
217
|
+
const byMember = Object.fromEntries(rowsForSession(dir).map((r) => [r.member, r.role]));
|
|
218
|
+
assert.equal(byMember["impl-580"], "implementer");
|
|
219
|
+
assert.equal(byMember["merge-bot-3"], "merge-bot");
|
|
220
|
+
// A non-canonical AgentId with no spawnDepth and no `agent` field, only
|
|
221
|
+
// task prose — classifies off the task text alone.
|
|
222
|
+
assert.equal(byMember["general-purpose"], "reviewer");
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("`subagent_type` is what the DISPATCH named, and blank when it named nothing", () => {
|
|
226
|
+
// The whole of #1066: a deliberate alternate-tier pair is identifiable only
|
|
227
|
+
// from the dispatch record, and `session_init.agent` is written at dispatch
|
|
228
|
+
// time — so the column is derived, survives a regeneration, and mislabels
|
|
229
|
+
// no historical row.
|
|
230
|
+
const dir = fixture([
|
|
231
|
+
["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("Implement ticket 580", "fleet-implementer"), assistantEvt("claude-opus-5")]],
|
|
232
|
+
["impl-581", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("Implement ticket 581", "fleet-implementer-alt"), assistantEvt("claude-sonnet-5")]],
|
|
233
|
+
["impl-582", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]],
|
|
234
|
+
]);
|
|
235
|
+
assert.deepEqual(
|
|
236
|
+
Object.fromEntries(rowsForSession(dir).map((r) => [r.member, r.subagentType])),
|
|
237
|
+
{ "impl-580": "fleet-implementer", "impl-581": "fleet-implementer-alt", "impl-582": "" },
|
|
238
|
+
);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test("a row whose cell count is wrong is REFUSED, never padded", () => {
|
|
242
|
+
// Padding put "" in the LAST column — `agent` when this was written,
|
|
243
|
+
// `subagent_type` now — a key rowsForSession can never produce, so mergeRows
|
|
244
|
+
// could never replace it. Three measured routes there, all exit 0: a torn
|
|
245
|
+
// last line became a permanent phantom that re-scraping could not heal, git
|
|
246
|
+
// conflict markers became three data rows, and adding one column ahead of
|
|
247
|
+
// `agent` collapsed 2,702 rows to 156.
|
|
248
|
+
//
|
|
249
|
+
// The 14-field spelling is the PREVIOUS schema, still on every branch cut
|
|
250
|
+
// before #1066: it must be refused rather than padded with a blank
|
|
251
|
+
// `subagent_type`, which would read as "this member was dispatched untyped"
|
|
252
|
+
// for rows that were nothing of the kind. Regenerating is the migration.
|
|
253
|
+
//
|
|
254
|
+
// Mutation this must survive: restoring `cells[i] ?? ""`.
|
|
255
|
+
const short = ["s1", "2026-08-25", "memory"].join("\t");
|
|
256
|
+
assert.throws(() => parseTsv(short), /malformed row: 3 fields, expected 15/);
|
|
257
|
+
assert.throws(() => parseTsv("<<<<<<< HEAD"), /malformed row/);
|
|
258
|
+
assert.throws(() => parseTsv(formatTsv([row()]).trim().split("\t").slice(0, 14).join("\t")), /14 fields, expected 15/);
|
|
259
|
+
// A long row is refused too — that is the schema-drift direction.
|
|
260
|
+
assert.throws(() => parseTsv(formatTsv([row()]).trim() + "\textra"), /16 fields/);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const row = (o = {}) => ({
|
|
264
|
+
session: "s1", run_date: "2026-08-25", role: "implementer", member: "impl-580",
|
|
265
|
+
model: "claude-opus-5", effort: "xhigh", ticket: "580", pr: "",
|
|
266
|
+
tokensCacheCreate: 0, tokensOut: 0, wallS: 0, turns: 1,
|
|
267
|
+
// Default agent tracks the default/overridden member, so fixtures that vary
|
|
268
|
+
// only `member` still get distinct transcript ids, and fixtures that share
|
|
269
|
+
// the default member (untouched) still key as the SAME agent.
|
|
270
|
+
agent: o.member ?? "impl-580", harness: "omp",
|
|
271
|
+
subagentType: "fleet-implementer", ...o,
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
test("re-scraping a session REPLACES its rows rather than appending duplicates", () => {
|
|
275
|
+
const merged = mergeRows([row({ model: "opus" })], [row({ model: "claude-opus-5" })]);
|
|
276
|
+
assert.equal(merged.length, 1);
|
|
277
|
+
assert.equal(merged[0].model, "claude-opus-5");
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test("re-scraping one session leaves every other session untouched", () => {
|
|
281
|
+
// The failure this guards: a backfill loop that rewrites the file per session
|
|
282
|
+
// and drops the previous session each time.
|
|
283
|
+
const merged = mergeRows(
|
|
284
|
+
[row({ session: "s0", member: "impl-1" }), row({ session: "s1", member: "impl-580" })],
|
|
285
|
+
[row({ session: "s1", member: "impl-580", turns: 9 })],
|
|
286
|
+
);
|
|
287
|
+
assert.equal(merged.length, 2);
|
|
288
|
+
assert.equal(merged.find((r) => r.session === "s0").member, "impl-1");
|
|
289
|
+
assert.equal(merged.find((r) => r.session === "s1").turns, 9);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test("output order is stable, so a regeneration produces no spurious diff", () => {
|
|
293
|
+
const a = formatTsv(mergeRows([], [row({ member: "impl-9" }), row({ member: "impl-1" })]));
|
|
294
|
+
const b = formatTsv(mergeRows([], [row({ member: "impl-1" }), row({ member: "impl-9" })]));
|
|
295
|
+
assert.equal(a, b);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
test("a tsv round-trips", () => {
|
|
299
|
+
// formatTsv does not sort (only mergeRows does), so the round-trip preserves
|
|
300
|
+
// input order. Ordering itself is pinned by the "output order is stable" test.
|
|
301
|
+
const rows = [row(), row({ session: "s2", member: "fix-pr-662", role: "reviewer", ticket: "", pr: "662" })];
|
|
302
|
+
assert.deepEqual(parseTsv(formatTsv(rows)).map((r) => r.member), ["impl-580", "fix-pr-662"]);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
test("a blank field round-trips as blank, never as zero", () => {
|
|
306
|
+
// Blank means UNKNOWN. Reading it back as 0 would make an unmeasured member
|
|
307
|
+
// look like a free one.
|
|
308
|
+
const parsed = parseTsv(formatTsv([row({ effort: "" })]));
|
|
309
|
+
assert.equal(parsed[0].effort, "");
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
test("two UNNAMED members of one session are two rows, not one", () => {
|
|
313
|
+
// `member` falls back to the agent stem for an unnamed dispatch, and every
|
|
314
|
+
// unnamed agent in a session shares the same fallback. Keying on the member
|
|
315
|
+
// name collapsed 1,202 of 2,694 real members into their siblings.
|
|
316
|
+
const a = row({ agent: "aaaa", member: "general-purpose" });
|
|
317
|
+
const b = row({ agent: "bbbb", member: "general-purpose" });
|
|
318
|
+
const merged = mergeRows([], [a, b]);
|
|
319
|
+
assert.equal(merged.length, 2);
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
const CLI = new URL("./member-outcomes.mjs", import.meta.url).pathname;
|
|
323
|
+
|
|
324
|
+
test("no session dir is a refusal, not a silent no-op", () => {
|
|
325
|
+
const r = spawnSync(process.execPath, [CLI], { encoding: "utf8" });
|
|
326
|
+
assert.equal(r.status, 2);
|
|
327
|
+
assert.match(r.stderr, /member-outcomes/);
|
|
328
|
+
assert.equal(r.stdout, "");
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
test("a nonexistent session directory is a refusal, not a silent no-op", () => {
|
|
332
|
+
// A wrong guess used to exit 0 having written nothing, because
|
|
333
|
+
// rowsForSession() catches the readdir failure and returns []. A dir that
|
|
334
|
+
// EXISTS but holds no transcripts yet is a real, legitimate state (a
|
|
335
|
+
// session between launch and its first member's spawn) and must not
|
|
336
|
+
// refuse; only a path that genuinely does not resolve should.
|
|
337
|
+
const missing = join(mkdtempSync(join(tmpdir(), "mo-empty-")), "never-created");
|
|
338
|
+
const out = join(mkdtempSync(join(tmpdir(), "mo-out-")), "member-outcomes.tsv");
|
|
339
|
+
const r = spawnSync(process.execPath, [CLI, missing, "--file", out], { encoding: "utf8" });
|
|
340
|
+
assert.equal(r.status, 2);
|
|
341
|
+
assert.match(r.stderr, /cannot read/);
|
|
342
|
+
assert.equal(existsSync(out), false);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
test("a session-dir argument that is actually a FILE is a refusal, not a silent no-op", () => {
|
|
346
|
+
const root = mkdtempSync(join(tmpdir(), "mo-notdir-"));
|
|
347
|
+
const notADir = join(root, "impl-580.jsonl");
|
|
348
|
+
writeFileSync(notADir, "");
|
|
349
|
+
const out = join(mkdtempSync(join(tmpdir(), "mo-out-")), "member-outcomes.tsv");
|
|
350
|
+
const r = spawnSync(process.execPath, [CLI, notADir, "--file", out], { encoding: "utf8" });
|
|
351
|
+
assert.equal(r.status, 2);
|
|
352
|
+
assert.match(r.stderr, /ENOTDIR/);
|
|
353
|
+
assert.equal(existsSync(out), false);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
test("a directory that is not an omp <ISO>_<uuid> session dir is a refusal, not silently scraped whole", () => {
|
|
357
|
+
// #1302-shaped regression: this CLI hands rowsForSession one EXPLICIT
|
|
358
|
+
// directory, which readdirSync's `{recursive:true}` then walks in full —
|
|
359
|
+
// so an encoded-cwd PROJECT directory (holding a real nested session dir
|
|
360
|
+
// plus a stray top-level main-session transcript, the real tree's own
|
|
361
|
+
// shape) used to be silently accepted whole: every session under it
|
|
362
|
+
// stamped with the project dir's own name, and the controller's own
|
|
363
|
+
// main-session transcript booked as a member.
|
|
364
|
+
const root = mkdtempSync(join(tmpdir(), "mo-proj-"));
|
|
365
|
+
const projectDir = join(root, "-dev-fleet-plugin");
|
|
366
|
+
const sessionName = "2026-09-08T14-14-34-049Z_01a0815e-e141-716c-b2d8-2adf310fbe55";
|
|
367
|
+
mkdirSync(join(projectDir, sessionName), { recursive: true });
|
|
368
|
+
writeFileSync(join(projectDir, sessionName, "impl-5.jsonl"),
|
|
369
|
+
[sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")].join("\n") + "\n");
|
|
370
|
+
writeFileSync(join(projectDir, `${sessionName}.jsonl`),
|
|
371
|
+
[sessionEvt("/x"), assistantEvt("claude-sonnet-5")].join("\n") + "\n");
|
|
372
|
+
const out = join(mkdtempSync(join(tmpdir(), "mo-out-")), "member-outcomes.tsv");
|
|
373
|
+
const r = spawnSync(process.execPath, [CLI, projectDir, "--file", out], { encoding: "utf8" });
|
|
374
|
+
assert.equal(r.status, 2);
|
|
375
|
+
assert.match(r.stderr, /is not an omp .* session directory/);
|
|
376
|
+
assert.equal(existsSync(out), false);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
test("--file=<path> is refused, not silently ignored", () => {
|
|
380
|
+
// --file wants a SPACE-separated value, not `=`. Without a check, this never
|
|
381
|
+
// sets fileIdx, so it silently writes the PRODUCTION metrics file instead of
|
|
382
|
+
// the path the operator asked for.
|
|
383
|
+
const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
|
|
384
|
+
const r = spawnSync(process.execPath, [CLI, dir, "--file=/tmp/x.tsv"], { encoding: "utf8" });
|
|
385
|
+
assert.equal(r.status, 2);
|
|
386
|
+
assert.match(r.stderr, /--file/);
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
test("an unrecognised flag is refused, not silently dropped", () => {
|
|
390
|
+
const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
|
|
391
|
+
const r = spawnSync(process.execPath, [CLI, dir, "--wat"], { encoding: "utf8" });
|
|
392
|
+
assert.equal(r.status, 2);
|
|
393
|
+
assert.match(r.stderr, /--wat/);
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
test("two separate sessions scraped in two runs merge into one TSV", () => {
|
|
397
|
+
const dirA = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("Implement ticket 580", "fleet-implementer"), assistantEvt("claude-opus-5")]]]);
|
|
398
|
+
const dirB = fixture([["Solo", [sessionEvt("/x"), thinkingEvt("high"), sessionInitEvt("Implement ticket 581", "fleet-implementer-alt"), assistantEvt("claude-sonnet-5")]]]);
|
|
399
|
+
|
|
400
|
+
const out = join(mkdtempSync(join(tmpdir(), "mo-out-")), "member-outcomes.tsv");
|
|
401
|
+
const runA = spawnSync(process.execPath, [CLI, dirA, "--file", out], { encoding: "utf8" });
|
|
402
|
+
assert.equal(runA.status, 0, runA.stderr);
|
|
403
|
+
const runB = spawnSync(process.execPath, [CLI, dirB, "--file", out], { encoding: "utf8" });
|
|
404
|
+
assert.equal(runB.status, 0, runB.stderr);
|
|
405
|
+
|
|
406
|
+
const rows = parseTsv(readFileSync(out, "utf8"));
|
|
407
|
+
assert.equal(rows.length, 2);
|
|
408
|
+
assert.deepEqual(new Set(rows.map((r) => r.member)), new Set(["impl-580", "Solo"]));
|
|
409
|
+
// #1066: the deliberate-pair column reaches the FILE, not just the record.
|
|
410
|
+
assert.equal(rows.find((r) => r.member === "Solo").subagentType, "fleet-implementer-alt");
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
test("a run writes rows, and a second run over the same session changes nothing", () => {
|
|
414
|
+
const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
|
|
415
|
+
const out = join(mkdtempSync(join(tmpdir(), "mo-out-")), "member-outcomes.tsv");
|
|
416
|
+
const run = () => spawnSync(process.execPath, [CLI, dir, "--file", out], { encoding: "utf8" });
|
|
417
|
+
assert.equal(run().status, 0);
|
|
418
|
+
const first = readFileSync(out, "utf8");
|
|
419
|
+
assert.equal(run().status, 0);
|
|
420
|
+
assert.equal(readFileSync(out, "utf8"), first);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
test("the header survives a rewrite", () => {
|
|
424
|
+
// The header carries the read-out commands and the blank-means-unknown rule.
|
|
425
|
+
// A rewrite that drops it strands every reader.
|
|
426
|
+
const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
|
|
427
|
+
const out = join(mkdtempSync(join(tmpdir(), "mo-out-")), "member-outcomes.tsv");
|
|
428
|
+
writeFileSync(out, "# keep me\n");
|
|
429
|
+
spawnSync(process.execPath, [CLI, dir, "--file", out], { encoding: "utf8" });
|
|
430
|
+
assert.match(readFileSync(out, "utf8"), /^# keep me$/m);
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
test("importing the module never runs the CLI, even from a file whose name ends with its own", () => {
|
|
434
|
+
// The guard used to be a suffix match, so a wrapper called
|
|
435
|
+
// run-member-outcomes.mjs tripped the CLI block on import: it wrote a file
|
|
436
|
+
// and exited 2 in a process that only wanted the helpers.
|
|
437
|
+
const dir = mkdtempSync(join(tmpdir(), "mo-wrap-"));
|
|
438
|
+
const wrapper = join(dir, "run-member-outcomes.mjs");
|
|
439
|
+
writeFileSync(wrapper, `import { normalizeModel } from ${JSON.stringify(CLI)};\n`
|
|
440
|
+
+ `console.log(normalizeModel("claude-opus-5"));\n`);
|
|
441
|
+
const r = spawnSync(process.execPath, [wrapper], { encoding: "utf8" });
|
|
442
|
+
assert.equal(r.status, 0);
|
|
443
|
+
assert.equal(r.stdout.trim(), "claude-opus-5");
|
|
444
|
+
assert.equal(r.stderr, "");
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
test("the documented bare form works — no --file needed", () => {
|
|
448
|
+
// `member-outcomes.mjs <session-dir>` is the form the spec, the backfill loop
|
|
449
|
+
// and run-team's phase-3 instruction all use. It exited 2 for every input
|
|
450
|
+
// until the filter stopped treating `fileIdx + 1` as a real index when
|
|
451
|
+
// --file is absent.
|
|
452
|
+
const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
|
|
453
|
+
const cwd = mkdtempSync(join(tmpdir(), "mo-cwd-"));
|
|
454
|
+
mkdirSync(join(cwd, "docs", "metrics"), { recursive: true });
|
|
455
|
+
const r = spawnSync(process.execPath, [CLI, dir], { encoding: "utf8", cwd });
|
|
456
|
+
assert.equal(r.status, 0);
|
|
457
|
+
assert.match(r.stderr, /scraped 1 of 1 members \(0 dropped\)/);
|
|
458
|
+
const written = readFileSync(join(cwd, "docs", "metrics", "member-outcomes.tsv"), "utf8");
|
|
459
|
+
assert.match(written, /impl-580/);
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
test("the run reports its own YIELD, not just the file's size", () => {
|
|
463
|
+
// `wrote N rows` printed merged.length — the whole corpus — so a session where
|
|
464
|
+
// every member dropped printed the same reassuring line as a healthy one.
|
|
465
|
+
//
|
|
466
|
+
// Mutation this must survive: printing merged.length alone.
|
|
467
|
+
const dir = fixture([
|
|
468
|
+
["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]],
|
|
469
|
+
// A sibling dispatched but never answered — the real drop shape: a
|
|
470
|
+
// transcript that exists, carries no assistant turn, and so yields no row.
|
|
471
|
+
["impl-581", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("Implement ticket 581", "fleet-implementer")]],
|
|
472
|
+
]);
|
|
473
|
+
const out = join(mkdtempSync(join(tmpdir(), "mo-out-")), "member-outcomes.tsv");
|
|
474
|
+
writeFileSync(out, formatTsv([row({ session: "other", member: "impl-1" })]));
|
|
475
|
+
|
|
476
|
+
const r = spawnSync(process.execPath, [CLI, dir, "--file", out], { encoding: "utf8" });
|
|
477
|
+
assert.equal(r.status, 0);
|
|
478
|
+
assert.match(r.stderr, /scraped 1 of 2 members \(1 dropped\)/);
|
|
479
|
+
// The file total is still reported, and is deliberately a DIFFERENT number
|
|
480
|
+
// from the yield — that difference is the whole point.
|
|
481
|
+
assert.match(r.stderr, /holds 2 rows/);
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
test("a corpus this schema cannot read is refused before anything is rewritten", () => {
|
|
485
|
+
// Reading an out-of-schema file used to pad it and rewrite it, converting a
|
|
486
|
+
// human's unresolved merge conflict into confident-looking data.
|
|
487
|
+
const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
|
|
488
|
+
const out = join(mkdtempSync(join(tmpdir(), "mo-out-")), "member-outcomes.tsv");
|
|
489
|
+
const conflicted = "# hdr\n<<<<<<< HEAD\n" + formatTsv([row()]) + "=======\n>>>>>>> theirs\n";
|
|
490
|
+
writeFileSync(out, conflicted);
|
|
491
|
+
const r = spawnSync(process.execPath, [CLI, dir, "--file", out], { encoding: "utf8" });
|
|
492
|
+
assert.equal(r.status, 2);
|
|
493
|
+
assert.match(r.stderr, /malformed row/);
|
|
494
|
+
assert.equal(readFileSync(out, "utf8"), conflicted, "the file is left exactly as found");
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
test("the header's blank lines and paragraph order survive a rewrite", () => {
|
|
498
|
+
// Collecting every `#` line from anywhere hoisted a below-data note to the
|
|
499
|
+
// top and dropped the blank separators, silently, while the comment promised
|
|
500
|
+
// "preserved verbatim".
|
|
501
|
+
const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
|
|
502
|
+
const out = join(mkdtempSync(join(tmpdir(), "mo-out-")), "member-outcomes.tsv");
|
|
503
|
+
const header = "# first paragraph\n\n# second paragraph\n";
|
|
504
|
+
writeFileSync(out, header);
|
|
505
|
+
spawnSync(process.execPath, [CLI, dir, "--file", out], { encoding: "utf8" });
|
|
506
|
+
assert.equal(readFileSync(out, "utf8").startsWith(header), true);
|
|
507
|
+
});
|