@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,468 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The dispatch-time tier check (#1345, ruled on #1298; ADR 0014). Layer 2 of
|
|
3
|
+
// two: layer 1 (#1314) is a static audit of the agent files' SHAPE, before
|
|
4
|
+
// any run exists; this layer compares what a run actually DISPATCHED against
|
|
5
|
+
// what omp's own record says it RESOLVED, for every member dispatched by
|
|
6
|
+
// named definition. Not a lint — a refusal, run after every Pull's dispatch,
|
|
7
|
+
// whose verdict on an implementer lands on the ledger, where fleet-tick.mjs
|
|
8
|
+
// holds the next Pull until there is one (run-team/SKILL.md's phase 2).
|
|
9
|
+
//
|
|
10
|
+
// Declared is the definition's own frontmatter — `model: "@<role>:<level>"`,
|
|
11
|
+
// a fleet tier route (ADR 0014), never a vendor id. Resolved is read back
|
|
12
|
+
// from omp's own record, three ways, in preference order:
|
|
13
|
+
// 1. the job record's OWN `resolvedModel`/`resolvedThinkingLevel` (#1302)
|
|
14
|
+
// — a controller that already holds BOTH never opens the child's file
|
|
15
|
+
// at all (this ticket's 4th fixture). Holding only one is the ordinary
|
|
16
|
+
// case, not a corner (the two live on different omp records), so the
|
|
17
|
+
// missing half is read off the transcript instead of reported as a lie.
|
|
18
|
+
// 2. `--session <dir>` — the controller's own session root, when it has no
|
|
19
|
+
// job record (or only half of one) but knows where its dispatched
|
|
20
|
+
// member's own transcript lives: the flat `<session>/<member>.jsonl`
|
|
21
|
+
// file, read directly (#1345's extension to member-record.mjs's
|
|
22
|
+
// readers — a member with no assistant turn yet still resolves off its
|
|
23
|
+
// dispatch-time `session_init` record, never treated as absent).
|
|
24
|
+
// 3. `--transcript <file>` — the member's own transcript, when the caller
|
|
25
|
+
// already holds the exact path (tests, or a caller with no session
|
|
26
|
+
// root handy).
|
|
27
|
+
//
|
|
28
|
+
// Compare is EXACT on the level (`thinking-level` verbatim) and by ROLE
|
|
29
|
+
// TARGET on the model: the declared alias's role (`@slow`/`@task`/`@smol`)
|
|
30
|
+
// resolves through the operator's `modelRoles.<role>`, and the resolved
|
|
31
|
+
// identity is compared against THAT target (`expectedOmpModel`) — never
|
|
32
|
+
// against the alias's own spelling, which would let an unrelated role
|
|
33
|
+
// resolving to a same-family model pass by accident. Real spellings carry
|
|
34
|
+
// more than the bare family name — `resolvedModel`/`resolvedModelIdentity`
|
|
35
|
+
// are ALWAYS provider-prefixed (`anthropic/claude-opus-5`,
|
|
36
|
+
// `anthropic/claude-opus-5:high` — 906/906 measured, zero bare) — so
|
|
37
|
+
// `modelsEqual` (tier-roles.mjs) strips the provider prefix and any
|
|
38
|
+
// `:suffix` tail before matching.
|
|
39
|
+
//
|
|
40
|
+
// A batch file, not one member: `--batch` takes a JSON array, and the
|
|
41
|
+
// failure line — `member: declared <m>/<l> resolved <m>/<l>` — is printed
|
|
42
|
+
// once per member that mismatched, not once per invocation. Under Pull,
|
|
43
|
+
// run-team's phase 2 calls this after every Pull's dispatch with a batch of
|
|
44
|
+
// one, the member just dispatched. See run-team/SKILL.md's phase-2 dispatch
|
|
45
|
+
// paragraph for the batch file's exact entry shape and how the controller
|
|
46
|
+
// obtains each field.
|
|
47
|
+
//
|
|
48
|
+
// An implementer (`impl-<N>`, ledger-grammar.mjs's name) is judged on the
|
|
49
|
+
// ledger's terms, not the caller's (#1398): the definition it should have
|
|
50
|
+
// run under is derived from its ticket row's `tier=` token
|
|
51
|
+
// (`expectedDefinition`), the agent type it was actually dispatched as is
|
|
52
|
+
// read off its own transcript and must BE that definition — a generic `task`
|
|
53
|
+
// dispatch fails even when its model happens to match — and the verdict
|
|
54
|
+
// lands on the ledger either way: `tier-ok=impl-<N>:<definition>` on the
|
|
55
|
+
// row on a pass, `ledger.mjs settle impl-<N> tier-mismatch` on a failure.
|
|
56
|
+
// fleet-tick.mjs holds the next Pull on the newest implementer of a ticket
|
|
57
|
+
// carrying neither.
|
|
58
|
+
|
|
59
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
60
|
+
import { execFileSync } from "node:child_process";
|
|
61
|
+
import { join, dirname, isAbsolute } from "node:path";
|
|
62
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
63
|
+
import { makeDie, defineFlags } from "./arg.mjs";
|
|
64
|
+
import { foldOmpTranscript, parseMemberName } from "./member-record.mjs";
|
|
65
|
+
import { parseFrontmatter, expectedOmpModel, modelsEqual, readOmpConfigValue } from "./tier-roles.mjs";
|
|
66
|
+
import { parseMember, parseToken, memberTokens } from "./ledger-grammar.mjs";
|
|
67
|
+
|
|
68
|
+
const NAME = "tier-check";
|
|
69
|
+
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
70
|
+
const LEDGER_SCRIPT = join(SCRIPT_DIR, "ledger.mjs");
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// pure core — unit-tested directly (tier-check.test.mjs), no filesystem or
|
|
74
|
+
// process access below this line until main()
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
// The declared pair a dispatch is judged against — straight off the
|
|
78
|
+
// definition's own frontmatter (`tier-roles.mjs`'s `parseFrontmatter`
|
|
79
|
+
// already carries `model`/`level`, never a second reader here).
|
|
80
|
+
export function declaredPairFor(frontmatter) {
|
|
81
|
+
return { model: frontmatter.model, level: frontmatter.level };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// The resolved pair off a transcript (or the omp job record). The
|
|
85
|
+
// short-circuit requires BOTH `resolvedModel` AND `resolvedThinkingLevel` —
|
|
86
|
+
// they live on different omp records (`session_init` carries
|
|
87
|
+
// `resolvedModel`/`resolvedModelIdentity`, `thinking_level_change` carries
|
|
88
|
+
// `thinkingLevel`; no single line carries both, measured 906 of the former
|
|
89
|
+
// against 232 of the latter), so holding only one is the ORDINARY case, not
|
|
90
|
+
// a corner, and the missing half is read off the transcript rather than
|
|
91
|
+
// reported as `null` (a `null` reaching `formatMismatch` would print
|
|
92
|
+
// `resolved .../null`, a lie about a field nobody asked was absent).
|
|
93
|
+
//
|
|
94
|
+
// The transcript-derived model prefers `resolvedModelIdentity`
|
|
95
|
+
// (`session_init`, written at DISPATCH) over the assistant turn's own
|
|
96
|
+
// `model`: the identity exists before the member's first turn, where the
|
|
97
|
+
// per-turn model does not, so preferring it is what makes this check usable
|
|
98
|
+
// immediately after a background dispatch rather than only once a member has
|
|
99
|
+
// already produced output.
|
|
100
|
+
export function resolveActual({ transcriptText, resolvedModel, resolvedThinkingLevel }) {
|
|
101
|
+
if (resolvedModel && resolvedThinkingLevel) {
|
|
102
|
+
return { model: resolvedModel, level: resolvedThinkingLevel, viaJobRecord: true };
|
|
103
|
+
}
|
|
104
|
+
const folded = foldOmpTranscript(transcriptText);
|
|
105
|
+
return {
|
|
106
|
+
model: resolvedModel ?? folded.resolvedModelIdentity ?? folded.model,
|
|
107
|
+
level: resolvedThinkingLevel ?? folded.thinking ?? "-",
|
|
108
|
+
viaJobRecord: false,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// The comparison itself, called only from evaluateMember below. The declared
|
|
113
|
+
// alias is a fleet tier name (ADR 0011/0014): `ok` requires the role it
|
|
114
|
+
// names to resolve to a model (`expected.model !== null`), that resolved
|
|
115
|
+
// model to match what the dispatched member actually ran under, and an
|
|
116
|
+
// exact level match — an unrecognised or unrouted declared model
|
|
117
|
+
// (`expected.model === null`) can never read `ok`, because `null === null`
|
|
118
|
+
// would let two different unrouted declarations pass as though they agreed
|
|
119
|
+
// on something.
|
|
120
|
+
function compare(member, declared, resolved, modelRoles) {
|
|
121
|
+
const expected = expectedOmpModel(declared.model, modelRoles);
|
|
122
|
+
const ok = expected.model !== null && modelsEqual(expected.model, resolved.model) && declared.level === resolved.level;
|
|
123
|
+
return { member, ok, declared, resolved, expected };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// One member, declared vs a transcript/job-record resolution. `modelRoles`
|
|
127
|
+
// is required — the role target every declared alias is judged against.
|
|
128
|
+
export function evaluateMember(entry) {
|
|
129
|
+
const declared = declaredPairFor(entry.frontmatter);
|
|
130
|
+
const resolved = resolveActual(entry);
|
|
131
|
+
return { ...compare(entry.member, declared, resolved, entry.modelRoles), viaJobRecord: resolved.viaJobRecord };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// The one-line failure shape the ticket's contract spells verbatim.
|
|
135
|
+
export function formatMismatch({ member, declared, resolved }) {
|
|
136
|
+
return `${member}: declared ${declared.model}/${declared.level} resolved ${resolved.model}/${resolved.level}`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Follow-up line: which role the declared alias routed through and what
|
|
140
|
+
// that role currently targets — the context `formatMismatch`'s pair alone
|
|
141
|
+
// cannot carry, since a mismatch there could be a stale `modelRoles.<role>`
|
|
142
|
+
// just as easily as a wrong dispatch. stderr only, never appended to the
|
|
143
|
+
// ledger row (`appendedLedgerText`'s idempotency keys on `formatMismatch`'s
|
|
144
|
+
// exact line).
|
|
145
|
+
export function formatOmpExpectation(r) {
|
|
146
|
+
const target = r.expected.role
|
|
147
|
+
? `@${r.expected.role} = ${r.expected.model ?? `(modelRoles.${r.expected.role} unset)`}`
|
|
148
|
+
: "no role — model: is not a route (@slow|@task|@smol:<level>)";
|
|
149
|
+
return ` ${r.member}: omp routes ${r.declared.model} through ${target}`;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ledger.mjs has no per-member field — member-record.mjs's own header says so
|
|
153
|
+
// ("the ledger has no member concept and gains none here") — so the mismatch
|
|
154
|
+
// pair rides in the row's free text, APPENDED to whatever the row already
|
|
155
|
+
// held rather than replacing it, since `row` rewrites the whole line
|
|
156
|
+
// (ledger.mjs's `data.rows[i] = line`) and a bare mismatch note would drop
|
|
157
|
+
// `class=`, `KILLED` or `→ PR#` tokens a prior `row` call wrote for the same
|
|
158
|
+
// ticket. Idempotent on the identical note: the documented loop is check,
|
|
159
|
+
// fix, re-check (SKILL.md's "fix the definition or the dispatch and re-run
|
|
160
|
+
// the check before continuing"), and a member that still mismatches for the
|
|
161
|
+
// SAME reason on a later run must not grow the row a second time — a
|
|
162
|
+
// DIFFERENT note (a changed pair) still appends, since that is new
|
|
163
|
+
// information the row does not carry yet.
|
|
164
|
+
export function appendedLedgerText(existingText, mismatchNote) {
|
|
165
|
+
const trimmed = String(existingText ?? "").trim();
|
|
166
|
+
if (!trimmed) return mismatchNote;
|
|
167
|
+
if (trimmed === mismatchNote || trimmed.endsWith(` · ${mismatchNote}`)) return trimmed;
|
|
168
|
+
return `${trimmed} · ${mismatchNote}`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// #1398: the definition an implementer should have run under, off its
|
|
172
|
+
// ticket row's `tier=` token — none means `fleet-implementer`, `tier=<x>`
|
|
173
|
+
// means `fleet-implementer-<x>`: `alt` (phase 2's every-5th-Pull alternate)
|
|
174
|
+
// and every #2030 per-cell name (`slow-high`) alike. The value becomes a
|
|
175
|
+
// file name under `agents/`, so it is held to `[a-z0-9]` words joined by
|
|
176
|
+
// `-` rather than joined into a path as written, and two different `tier=`
|
|
177
|
+
// values on one row name no single definition — refused, never resolved by
|
|
178
|
+
// position.
|
|
179
|
+
const TIER_SUFFIX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
180
|
+
export function expectedDefinition(rowText) {
|
|
181
|
+
const values = [...new Set(String(rowText ?? "").split(/\s+/)
|
|
182
|
+
.filter((t) => t.startsWith("tier=")).map((t) => t.slice("tier=".length)))];
|
|
183
|
+
if (values.length === 0) return "fleet-implementer";
|
|
184
|
+
if (values.length > 1) throw new Error(`row carries conflicting tier= tokens (${values.map((v) => `tier=${v}`).join(", ")})`);
|
|
185
|
+
if (!TIER_SUFFIX.test(values[0])) throw new Error(`tier=${values[0]} is not a definition suffix — expected [a-z0-9] words joined by '-'`);
|
|
186
|
+
return `fleet-implementer-${values[0]}`;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// The agent-type half of an implementer's verdict: the definition the
|
|
190
|
+
// transcript's `session_init` says the member was DISPATCHED AS
|
|
191
|
+
// (`folded.agent` — the value member-record.mjs records as `subagent_type`)
|
|
192
|
+
// against the derived one. Judged apart from the model because a generic
|
|
193
|
+
// `task` dispatch can resolve to the role's target by coincidence and still
|
|
194
|
+
// not be the definition the run means to measure.
|
|
195
|
+
export function formatAgentMismatch({ member, agent, definition }) {
|
|
196
|
+
return `${member}: dispatched ${agent ?? "(no agent on record)"}, expected ${definition}`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// One implementer, both halves. `frontmatter` is null when `agents/` holds
|
|
200
|
+
// no file for the derived definition: nothing declares a tier to compare
|
|
201
|
+
// against, which can never read ok.
|
|
202
|
+
export function evaluateImplementer({ member, definition, frontmatter, transcriptText, resolvedModel, resolvedThinkingLevel, modelRoles }) {
|
|
203
|
+
const agent = foldOmpTranscript(transcriptText).agent;
|
|
204
|
+
const tier = frontmatter
|
|
205
|
+
? evaluateMember({ member, frontmatter, transcriptText, resolvedModel, resolvedThinkingLevel, modelRoles })
|
|
206
|
+
: null;
|
|
207
|
+
return { member, definition, agent, tier, ok: agent === definition && tier?.ok === true };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Every reason an implementer failed, one line each, in the order printed.
|
|
211
|
+
export function implementerFailures(r) {
|
|
212
|
+
const lines = [];
|
|
213
|
+
if (r.agent !== r.definition) lines.push(formatAgentMismatch(r));
|
|
214
|
+
if (r.tier === null) lines.push(`${r.member}: expected ${r.definition} has no agents/${r.definition}.agent.md to declare its tier`);
|
|
215
|
+
else if (!r.tier.ok) lines.push(formatMismatch(r.tier));
|
|
216
|
+
return lines;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// The two verdict tokens fleet-tick.mjs reads. Neither parses as a member
|
|
220
|
+
// token (ledger-grammar.mjs's parseMember refuses a `tier-ok`/`tier-mismatch`
|
|
221
|
+
// name), so `ledger.mjs row` passes them as free text. `tier-mismatch=` is
|
|
222
|
+
// written only for a member already settled some other way — `settle`
|
|
223
|
+
// refuses to re-settle it, and the mismatch must still hold the next Pull.
|
|
224
|
+
export const tierOkToken = (member, definition) => `tier-ok=${member}:${definition}`;
|
|
225
|
+
export const tierMismatchToken = (member, definition) => `tier-mismatch=${member}:${definition}`;
|
|
226
|
+
|
|
227
|
+
// A single-token append, idempotent on the token's PRESENCE anywhere in the
|
|
228
|
+
// row — unlike appendedLedgerText's trailing-segment rule, which is for
|
|
229
|
+
// multi-word notes: a token is exact, and a later `row` or `settle` that
|
|
230
|
+
// wrote past it must not let a re-run add it a second time.
|
|
231
|
+
export function withToken(existingText, token) {
|
|
232
|
+
const trimmed = String(existingText ?? "").trim();
|
|
233
|
+
if (trimmed.split(/\s+/).includes(token)) return trimmed;
|
|
234
|
+
return trimmed ? `${trimmed} · ${token}` : token;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Where a member stands on the ledger, read the way `ledger.mjs settle`
|
|
238
|
+
// reads it — `## Dispatched` and every row, settled anywhere is settled:
|
|
239
|
+
// undefined when it is on the ledger nowhere, null while live, else its
|
|
240
|
+
// outcome.
|
|
241
|
+
export function memberOutcome(data, name) {
|
|
242
|
+
const found = [...(data.dispatched ?? []).map(parseToken), ...(data.rows ?? []).flatMap(memberTokens)]
|
|
243
|
+
.filter((t) => t?.name === name);
|
|
244
|
+
if (found.length === 0) return undefined;
|
|
245
|
+
return found.find((t) => t.outcome !== null)?.outcome ?? null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// A ticket row's text past its `#<N>` key, "" when the ledger has no row.
|
|
249
|
+
export function rowText(data, ticket) {
|
|
250
|
+
const key = `#${ticket}`;
|
|
251
|
+
const row = (data.rows ?? []).find((r) => r.split(/\s/)[0] === key);
|
|
252
|
+
return row ? row.slice(key.length).trim() : "";
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ---------------------------------------------------------------------------
|
|
256
|
+
// CLI — batch I/O, ledger append, exit code
|
|
257
|
+
// ---------------------------------------------------------------------------
|
|
258
|
+
|
|
259
|
+
const die = makeDie(NAME);
|
|
260
|
+
const { arg, sweep, stray } = defineFlags(die, {
|
|
261
|
+
flags: { batch: "value", ledger: "value", repo: "value", "model-roles": "value" },
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
function resolvePath(repoRoot, p) {
|
|
265
|
+
return isAbsolute(p) ? p : join(repoRoot, p);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// The `--session` lookup: a directly-dispatched member's transcript is a FLAT
|
|
269
|
+
// file named by its own AgentId (member-record.mjs's own `readOmpSession`
|
|
270
|
+
// comment), and the member's `name` in a batch entry IS that AgentId — so
|
|
271
|
+
// the path is exact, not searched. A member's own nested fan-out
|
|
272
|
+
// (`<parent-AgentId>/<stem>.jsonl`, one directory level down) is out of
|
|
273
|
+
// reach of this flat lookup — pass `--transcript` for a transcript this
|
|
274
|
+
// cannot find directly.
|
|
275
|
+
function resolveViaSession(repoRoot, sessionPath, member) {
|
|
276
|
+
const root = resolvePath(repoRoot, sessionPath);
|
|
277
|
+
const flat = join(root, `${member}.jsonl`);
|
|
278
|
+
if (!existsSync(flat)) throw new Error(`no ${member}.jsonl found under --session ${sessionPath}`);
|
|
279
|
+
return readFileSync(flat, "utf8");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function runLedger(ledgerFile, args, what) {
|
|
283
|
+
try {
|
|
284
|
+
return execFileSync(process.execPath, [LEDGER_SCRIPT, ...(ledgerFile ? ["--file", ledgerFile] : []), ...args], { encoding: "utf8" });
|
|
285
|
+
} catch (e) {
|
|
286
|
+
die(`could not ${what}: ${e.stderr?.trim() || e.message}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function readLedger(ledgerFile) {
|
|
291
|
+
const raw = runLedger(ledgerFile, ["read"], "read the ledger");
|
|
292
|
+
try {
|
|
293
|
+
return JSON.parse(raw);
|
|
294
|
+
} catch (e) {
|
|
295
|
+
die(`could not read the ledger: ${e.message}`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function writeLedgerRow(ledgerFile, ticket, text) {
|
|
300
|
+
runLedger(ledgerFile, ["row", String(ticket), text], `write ledger row #${ticket}`);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// An implementer's verdict, onto the ledger either way. Read fresh, not
|
|
304
|
+
// from the evaluation's copy: an earlier entry in this same batch may have
|
|
305
|
+
// written the row since. On a failure the reasons ride in the row's free
|
|
306
|
+
// text as ONE ` · `-joined note, so appendedLedgerText's trailing-segment
|
|
307
|
+
// idempotency covers a re-run of the whole verdict, and the member is
|
|
308
|
+
// settled `tier-mismatch` here rather than left to the controller — the
|
|
309
|
+
// hand step #1398 measured never taken.
|
|
310
|
+
function recordImplementer(ledgerFile, r) {
|
|
311
|
+
const data = readLedger(ledgerFile);
|
|
312
|
+
const existing = rowText(data, r.ticket);
|
|
313
|
+
if (r.ok) {
|
|
314
|
+
const token = tierOkToken(r.member, r.definition);
|
|
315
|
+
const updated = withToken(existing, token);
|
|
316
|
+
if (updated === existing) console.error(` ${r.member}: row #${r.ticket} already carries ${token} — not written again`);
|
|
317
|
+
else writeLedgerRow(ledgerFile, r.ticket, updated);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
const lines = implementerFailures(r);
|
|
321
|
+
for (const line of lines) console.error(line);
|
|
322
|
+
if (r.tier && !r.tier.ok) console.error(formatOmpExpectation(r.tier));
|
|
323
|
+
const outcome = memberOutcome(data, r.member);
|
|
324
|
+
if (outcome === undefined) {
|
|
325
|
+
die(`${r.member}: not on the ledger — \`ledger.mjs dispatch\` records a member before its tier can be settled`);
|
|
326
|
+
}
|
|
327
|
+
// A member already settled some other way (`bailed`, `killed`,
|
|
328
|
+
// `released`, `PR#M`) cannot be re-settled — `settle` refuses — so the
|
|
329
|
+
// mismatch rides as a row token instead, ahead of the note so the note
|
|
330
|
+
// stays the row's trailing segment.
|
|
331
|
+
let updated = outcome === null || outcome === "tier-mismatch"
|
|
332
|
+
? existing
|
|
333
|
+
: withToken(existing, tierMismatchToken(r.member, r.definition));
|
|
334
|
+
updated = appendedLedgerText(updated, lines.join(" · "));
|
|
335
|
+
if (updated === existing) console.error(` ${r.member}: row #${r.ticket} already carries this exact verdict — not appended again`);
|
|
336
|
+
else writeLedgerRow(ledgerFile, r.ticket, updated);
|
|
337
|
+
if (outcome === null) runLedger(ledgerFile, ["settle", r.member, "tier-mismatch"], `settle ${r.member} tier-mismatch`);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function main() {
|
|
341
|
+
const batchPath = arg("batch");
|
|
342
|
+
if (!batchPath) die("usage: tier-check.mjs --batch <path-to-json> [--ledger <path>] [--repo <path>] [--model-roles <path>]");
|
|
343
|
+
const ledgerFile = arg("ledger");
|
|
344
|
+
const repoRoot = arg("repo") ?? join(SCRIPT_DIR, "..");
|
|
345
|
+
|
|
346
|
+
// #1669: this file bound only makeDie/makeArg, so a stray or misspelled
|
|
347
|
+
// flag (`--ledgerr`) was silently ignored and the run computed a real
|
|
348
|
+
// verdict against the DEFAULT ledger — the fail-open harm arg.mjs exists
|
|
349
|
+
// to prevent. Below the arg() reads and the --batch usage guard above,
|
|
350
|
+
// per arg.mjs's sweep() ordering contract, so a roster flag given with
|
|
351
|
+
// no value (or --batch omitted entirely) still answers its own
|
|
352
|
+
// needs-a-value/usage message rather than a generic stray complaint.
|
|
353
|
+
// Above the batch file's own JSON/array checks below, so a stray riding
|
|
354
|
+
// along with a well-formed --batch is refused by name instead of being
|
|
355
|
+
// silently absorbed into a batch-content error.
|
|
356
|
+
sweep();
|
|
357
|
+
// #463: sweep() only refuses a `--`-prefixed token; a bare or single-dash
|
|
358
|
+
// one (`-ledger`, the single-dash cousin of the ticket's own `--ledgerr`)
|
|
359
|
+
// rode along in silence the same way. This file takes no positional, so
|
|
360
|
+
// any leftover token is a stray.
|
|
361
|
+
stray();
|
|
362
|
+
|
|
363
|
+
let entries;
|
|
364
|
+
try {
|
|
365
|
+
entries = JSON.parse(readFileSync(batchPath, "utf8"));
|
|
366
|
+
} catch (e) {
|
|
367
|
+
die(`could not read --batch ${batchPath}: ${e.message}`);
|
|
368
|
+
}
|
|
369
|
+
if (!Array.isArray(entries) || entries.length === 0) {
|
|
370
|
+
die(`--batch ${batchPath} must be a JSON array of at least one member entry`);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// Read once per invocation, before the map: every entry in the batch is
|
|
374
|
+
// judged against the SAME operator config, never a per-entry re-read.
|
|
375
|
+
const modelRolesPath = arg("model-roles");
|
|
376
|
+
let modelRoles;
|
|
377
|
+
try {
|
|
378
|
+
modelRoles = modelRolesPath ? JSON.parse(readFileSync(modelRolesPath, "utf8")) : readOmpConfigValue("modelRoles");
|
|
379
|
+
} catch (e) {
|
|
380
|
+
die(e.message);
|
|
381
|
+
}
|
|
382
|
+
if (typeof modelRoles !== "object" || modelRoles === null || Array.isArray(modelRoles)) {
|
|
383
|
+
die(`${modelRolesPath ? `--model-roles ${modelRolesPath}` : "omp config get modelRoles --json"} must be a JSON object`);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// The ledger is read at most once for evaluation: every implementer's
|
|
387
|
+
// expected definition comes off its row, and nothing this loop does
|
|
388
|
+
// writes a `tier=` token.
|
|
389
|
+
let ledgerData = null;
|
|
390
|
+
const results = entries.map((raw) => {
|
|
391
|
+
const parsed = parseMember(String(raw.member ?? ""));
|
|
392
|
+
const impl = parsed?.family === "impl";
|
|
393
|
+
if (!raw.member || (!impl && !raw.agentFile)) {
|
|
394
|
+
die(`batch entry missing member/agentFile: ${JSON.stringify(raw)}`);
|
|
395
|
+
}
|
|
396
|
+
if (impl && raw.agentFile) {
|
|
397
|
+
die(`${raw.member}: an impl- entry carries no agentFile — its definition is derived from the ledger row's tier= token`);
|
|
398
|
+
}
|
|
399
|
+
const hasJobRecord = raw.resolvedModel && raw.resolvedThinkingLevel;
|
|
400
|
+
let frontmatter = null, transcriptText = null, ticket = null, definition = null;
|
|
401
|
+
try {
|
|
402
|
+
if (impl) {
|
|
403
|
+
ticket = parsed.number;
|
|
404
|
+
ledgerData ??= readLedger(ledgerFile);
|
|
405
|
+
definition = expectedDefinition(rowText(ledgerData, ticket));
|
|
406
|
+
const definitionFile = join(repoRoot, "agents", `${definition}.agent.md`);
|
|
407
|
+
if (existsSync(definitionFile)) frontmatter = parseFrontmatter(readFileSync(definitionFile, "utf8"));
|
|
408
|
+
} else {
|
|
409
|
+
frontmatter = parseFrontmatter(readFileSync(resolvePath(repoRoot, raw.agentFile), "utf8"));
|
|
410
|
+
}
|
|
411
|
+
// An implementer's transcript is read even beside a full job record:
|
|
412
|
+
// the agent type it was dispatched as lives only there.
|
|
413
|
+
if (impl || !hasJobRecord) {
|
|
414
|
+
if (raw.session) {
|
|
415
|
+
transcriptText = resolveViaSession(repoRoot, raw.session, raw.member);
|
|
416
|
+
} else if (raw.transcript) {
|
|
417
|
+
transcriptText = readFileSync(resolvePath(repoRoot, raw.transcript), "utf8");
|
|
418
|
+
} else if (impl) {
|
|
419
|
+
throw new Error("an impl- entry needs session or transcript — the agent type it was dispatched as is read off its own transcript, which no job record carries");
|
|
420
|
+
} else {
|
|
421
|
+
// Reached by BOTH a fully absent job record and a PARTIAL one
|
|
422
|
+
// (only `resolvedModel` or only `resolvedThinkingLevel`) — a
|
|
423
|
+
// partial record still needs a transcript for its missing half,
|
|
424
|
+
// never a silent "-" default (finding #2).
|
|
425
|
+
throw new Error("no --transcript or --session given, and no full omp job record (both resolvedModel and resolvedThinkingLevel) supplied");
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
} catch (e) {
|
|
429
|
+
die(`${raw.member}: ${e.message}`);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const entry = {
|
|
433
|
+
member: raw.member, frontmatter, transcriptText,
|
|
434
|
+
resolvedModel: raw.resolvedModel, resolvedThinkingLevel: raw.resolvedThinkingLevel,
|
|
435
|
+
modelRoles,
|
|
436
|
+
};
|
|
437
|
+
return impl
|
|
438
|
+
? { impl: true, ticket, ...evaluateImplementer({ ...entry, definition }) }
|
|
439
|
+
: { impl: false, ...evaluateMember(entry) };
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
for (const r of results) {
|
|
443
|
+
if (r.impl) {
|
|
444
|
+
recordImplementer(ledgerFile, r);
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
if (r.ok) continue;
|
|
448
|
+
const line = formatMismatch(r);
|
|
449
|
+
console.error(line);
|
|
450
|
+
if (r.expected) console.error(formatOmpExpectation(r));
|
|
451
|
+
const { ticket } = parseMemberName(r.member);
|
|
452
|
+
if (!ticket) {
|
|
453
|
+
console.error(` ${r.member}: no ticket derivable from the member name — tier-mismatch pair not written to the ledger`);
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
const existing = rowText(readLedger(ledgerFile), ticket);
|
|
457
|
+
const updated = appendedLedgerText(existing, line);
|
|
458
|
+
if (updated === existing) {
|
|
459
|
+
console.error(` ${r.member}: ledger row for #${ticket} already carries this exact pair — not appended again`);
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
writeLedgerRow(ledgerFile, ticket, updated);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
process.exit(results.some((r) => !r.ok) ? 1 : 0);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
if (import.meta.url === pathToFileURL(process.argv[1] || "").href) main();
|