crysk 0.7.0 → 0.8.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/README.md +27 -23
- package/dist/SKILL-1q3658n0.md +74 -0
- package/dist/SKILL-25j4q9b8.md +143 -0
- package/dist/SKILL-4747bhne.md +143 -0
- package/dist/SKILL-4jc3sv23.md +74 -0
- package/dist/SKILL-c0492rch.md +540 -0
- package/dist/SKILL-d1nzkhhr.md +74 -0
- package/dist/SKILL-f8p7kvx0.md +143 -0
- package/dist/SKILL-gxd45g38.md +553 -0
- package/dist/SKILL-rec41991.md +66 -0
- package/dist/SKILL-zze8zj5g.md +536 -0
- package/dist/cli.js +24658 -24654
- package/dist/index.js +492 -463
- package/dist/opencode-ci-qrcv7a99.md +106 -0
- package/dist/opencode-ci-rdpcc7xc.md +106 -0
- package/dist/opencode-ci-yt0k74t0.md +106 -0
- package/dist/workflow-andv2dvm.yml +158 -0
- package/package.json +1 -1
- package/prompts/default/PROVENANCE.md +1 -0
- package/skills/crysk/SKILL.md +6 -6
- package/skills/crysk-ci-setup/SKILL.md +32 -33
- package/skills/crysk-ci-setup/assets/workflow.yml +5 -10
- package/skills/crysk-ci-setup/references/ci-admission.md +5 -5
- package/skills/crysk-ci-setup/references/opencode-ci.md +6 -6
- package/skills/crysk-loop/SKILL.md +37 -54
- package/skills/crysk-pr/SKILL.md +1 -1
- package/src/asset-manifest.ts +0 -6
- package/src/assets.ts +1 -4
- package/src/brand.ts +20 -30
- package/src/ci/gates.ts +155 -201
- package/src/ci/outcome.ts +4 -31
- package/src/ci/platform-limits.ts +135 -0
- package/src/ci/platform-report.ts +212 -126
- package/src/ci/platform.ts +28 -26
- package/src/ci/reporter.ts +25 -26
- package/src/ci/review-admission.ts +1 -2
- package/src/ci/review-levels.ts +12 -53
- package/src/ci/setup.ts +96 -66
- package/src/ci/trace-bundle.ts +11 -27
- package/src/ci/trace-transcripts.ts +4 -6
- package/src/ci/trigger.ts +3 -5
- package/src/cli.ts +6 -5
- package/src/commands/ci-setup-questions.ts +2 -55
- package/src/commands/ci-setup.ts +2 -26
- package/src/commands/triage.ts +131 -38
- package/src/commands/usage.ts +0 -1
- package/src/compare/compare.ts +3 -3
- package/src/compare/floor-test.ts +30 -201
- package/src/config/config.ts +6 -30
- package/src/diversity/accounting.ts +0 -26
- package/src/diversity/benchmark.ts +1 -17
- package/src/diversity/identity.ts +0 -14
- package/src/diversity/pipeline-integration.ts +0 -29
- package/src/doctor.ts +3 -6
- package/src/execution/claude-session-trace.ts +7 -2
- package/src/execution/contracts.ts +15 -9
- package/src/execution/harness.ts +165 -187
- package/src/execution/spend-limiter.ts +39 -131
- package/src/execution/usage-facts.ts +397 -0
- package/src/execution/usage-normalized.ts +33 -86
- package/src/harness/materiality-judge.ts +0 -5
- package/src/harness/pipeline-plan.ts +0 -3
- package/src/harness/replay-rows.ts +0 -5
- package/src/harness/route-runner.ts +2 -2
- package/src/harness/single-step.ts +3 -9
- package/src/index.ts +1 -1
- package/src/mcp/preflight.ts +2 -2
- package/src/model/catalog.ts +1 -3
- package/src/model/free-discovery.ts +11 -78
- package/src/model/model-name.ts +14 -4
- package/src/model/profiles/claude.ts +1 -2
- package/src/model/profiles/openai.ts +1 -2
- package/src/model/profiles.ts +1 -2
- package/src/model/provider-capabilities.ts +16 -55
- package/src/model/routing.ts +39 -36
- package/src/pr/admission.ts +6 -6
- package/src/pr/answered-findings.ts +8 -4
- package/src/pr/ci-publish.ts +0 -2
- package/src/pr/discovery.ts +4 -25
- package/src/pr/plan.ts +40 -121
- package/src/pr/pr-status.ts +14 -2
- package/src/pr/preflight.ts +15 -12
- package/src/pr/publish-outcome.ts +1 -19
- package/src/pr/review-pr.ts +10 -47
- package/src/pr/target.ts +76 -82
- package/src/production-runtime.ts +52 -114
- package/src/progress.ts +0 -54
- package/src/rereview/prepare.ts +4 -1
- package/src/rereview/state.ts +1 -1
- package/src/review/boundary.ts +4 -8
- package/src/review/drafts.ts +3 -3
- package/src/review/findings-conformance.ts +1 -1
- package/src/review/findings.ts +0 -4
- package/src/review/pipeline.ts +57 -395
- package/src/review/preflight.ts +162 -201
- package/src/review/prompt-set.ts +0 -2
- package/src/review/report.ts +2 -162
- package/src/review/review.ts +16 -65
- package/src/review/route-preflight.ts +3 -35
- package/src/review/run.ts +37 -73
- package/src/review/size-gate.ts +3 -3
- package/src/review/spec.ts +6 -11
- package/src/review/step-runner.ts +4 -4
- package/src/runner-authority.ts +10 -9
- package/src/security/credential-broker.ts +5 -6
- package/src/server/preflight.ts +0 -1
- package/src/server/server.ts +17 -6
- package/src/store/activity.ts +1 -2
- package/src/store/backfill-preflight.ts +0 -3
- package/src/store/backfill.ts +0 -1
- package/src/store/metrics-preflight.ts +4 -14
- package/src/store/metrics.ts +5 -5
- package/src/store/preflight.ts +0 -13
- package/src/store/store.ts +11 -12
- package/src/transport-registry.ts +6 -30
- package/src/transports/claude-code-cli.ts +149 -215
- package/src/transports/opencode-client.ts +4 -24
- package/src/transports/opencode-sdk.ts +17 -112
- package/src/triage/plain-reply.ts +37 -0
- package/src/ui/activity.ts +1 -6
- package/src/ui/config-edit.ts +14 -67
- package/src/ui/config.ts +3 -8
- package/src/ui/plan.ts +11 -198
- package/src/ui/progress.ts +3 -49
- package/src/ui/result.ts +18 -77
- package/src/ui/review-menu.ts +3 -12
- package/src/ui/select.ts +9 -79
- package/src/updater.ts +1 -1
- package/src/usage.ts +1 -7
- package/prompts/default/deep-review-parity.md +0 -152
- package/prompts/scout.md +0 -140
- package/src/ci/platform-estimate.ts +0 -111
- package/src/review/scout.ts +0 -323
|
@@ -10,33 +10,23 @@ import type { SessionUsage } from "../usage";
|
|
|
10
10
|
|
|
11
11
|
export type UsageCompleteness = "complete" | "partial" | "unavailable";
|
|
12
12
|
// #182 follow-up: "free" is a USAGE-layer precision, not a capability mode.
|
|
13
|
-
// A free-declared route bills nothing
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
// `BillingMode` ("subscription"|"metered") stays binary on purpose: the exact
|
|
20
|
-
// binding still reports a free route as subscription/not_applicable, and the
|
|
21
|
-
// spend ledger is composed for it by credential kind (production-runtime.ts).
|
|
13
|
+
// A free-declared route bills nothing and its credential kind travels in the
|
|
14
|
+
// platform report as `free`, apart from `subscription` and `metered`.
|
|
15
|
+
// Capability `BillingMode` ("subscription"|"metered") stays binary on purpose:
|
|
16
|
+
// the exact binding still reports a free route as subscription,
|
|
17
|
+
// and the spend ledger is composed for it by credential kind
|
|
18
|
+
// (production-runtime.ts).
|
|
22
19
|
export type UsageBillingMode = "subscription" | "metered" | "free" | "unknown";
|
|
23
|
-
export type UsageCostSource =
|
|
24
|
-
| "provider"
|
|
25
|
-
| "versioned_rate_table"
|
|
26
|
-
| "subscription"
|
|
27
|
-
| "unknown";
|
|
28
20
|
|
|
29
21
|
// 2026-09-02, #177. THE one place that says "this environment carries a
|
|
30
22
|
// per-token credential". Two callers need it and they must not each carry
|
|
31
|
-
// their own copy:
|
|
32
|
-
//
|
|
33
|
-
//
|
|
23
|
+
// their own copy: the CI route classifier (ci/gates.ts) and the Claude CLI
|
|
24
|
+
// transport, which turns it into the `billingMode` STAMPED ON EVERY USAGE
|
|
25
|
+
// RECORD it emits. This is the same anti-drift shape
|
|
34
26
|
// `credentialKindBillsMetered` (runner-authority.ts) already applies to the
|
|
35
27
|
// credential KIND, and for the same measured reason: #177 IS the drift. The CI
|
|
36
28
|
// gate already called an API-key route metered while the transport filed that
|
|
37
|
-
// user's
|
|
38
|
-
// charged" — and since budget enforcement is cash-only (§8), that user's spend
|
|
39
|
-
// ceiling read $0 and stopped existing.
|
|
29
|
+
// user's usage under another mode.
|
|
40
30
|
//
|
|
41
31
|
// A boolean, not a mode, matching its sibling: the two callers narrow it into
|
|
42
32
|
// two DIFFERENT enums (`CiBillingMode`, `UsageBillingMode`), and returning a
|
|
@@ -56,8 +46,8 @@ export type UsageCostSource =
|
|
|
56
46
|
// (security/claude-credential.ts) holds only the Claude credential chosen from
|
|
57
47
|
// `credentials.claude`, so this predicate answers metered exactly when the run
|
|
58
48
|
// chose the API key. A caller with its own env that holds both still gets
|
|
59
|
-
// metered, because guessing subscription wrongly
|
|
60
|
-
//
|
|
49
|
+
// metered, because guessing subscription wrongly files a per-token credential
|
|
50
|
+
// as a quota.
|
|
61
51
|
//
|
|
62
52
|
// Trimming is load-bearing, and it is worth being exact about WHAT it buys,
|
|
63
53
|
// because the sentence it replaces overstated it and #177 is a finding about
|
|
@@ -68,8 +58,8 @@ export type UsageCostSource =
|
|
|
68
58
|
// with or without the trim. What the trim actually catches is a
|
|
69
59
|
// WHITESPACE-ONLY value (a secret whose content is a space, a YAML block
|
|
70
60
|
// scalar that kept its newline), which is truthy and would otherwise read as
|
|
71
|
-
// a live key and
|
|
72
|
-
//
|
|
61
|
+
// a live key and file a subscription run's quota usage as metered.
|
|
62
|
+
// Mutation-checked: dropping the trim flips exactly the
|
|
73
63
|
// whitespace arms, never the empty-string ones.
|
|
74
64
|
//
|
|
75
65
|
// ---------------------------------------------------------------------------
|
|
@@ -82,27 +72,25 @@ export type UsageCostSource =
|
|
|
82
72
|
// for the question in general.
|
|
83
73
|
//
|
|
84
74
|
// Until #197 the reason was safety: deriving either side from env turned a
|
|
85
|
-
// metered claude-code route into
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
// `true`, so that refusal can no longer happen and the fail-closed argument
|
|
90
|
-
// is spent.
|
|
75
|
+
// metered claude-code route into a route that needed pricing the engine could
|
|
76
|
+
// not supply, so it was refused admission outright and API-key users stopped
|
|
77
|
+
// being able to run at all. The engine no longer prices anything, so that
|
|
78
|
+
// refusal cannot happen and the fail-closed argument is spent.
|
|
91
79
|
//
|
|
92
80
|
// What remained was ownership, and #161 settles it by NAMING the owner
|
|
93
81
|
// instead of banning the wiring outright: `credentialKindForRoute` is the
|
|
94
82
|
// one admission-side reader of this predicate, and `envBillsMetered` is the
|
|
95
83
|
// one shared implementation both it and the Claude CLI transport's
|
|
96
|
-
// `
|
|
84
|
+
// `claudeCliBillingMode` call — never two copies of the same trim rule
|
|
97
85
|
// answering "does this environment carry a per-token credential?"
|
|
98
86
|
// differently for the same attempt.
|
|
99
87
|
//
|
|
100
88
|
// The two calls read DIFFERENT env values on purpose, and on a SUCCESSFUL
|
|
101
|
-
// projection that is not a fork: `
|
|
89
|
+
// projection that is not a fork: `claudeCliBillingMode` reads the child's
|
|
102
90
|
// ACTUAL, POST-projection-strip env (`request.isolation.env`) — a successful
|
|
103
91
|
// projection strips the key-bearing vars (`PROJECTION_OWNED_KEYS`,
|
|
104
|
-
// harness.ts), so this is a truthful read of what the process
|
|
105
|
-
//
|
|
92
|
+
// harness.ts), so this is a truthful read of what the process whose usage
|
|
93
|
+
// is filed actually saw. `credentialKindForRoute` runs BEFORE any child
|
|
106
94
|
// exists, so it cannot read that env — it reads the raw, pre-strip one plus
|
|
107
95
|
// whether a broker WILL ATTEMPT to strip it (`hasBroker`), and
|
|
108
96
|
// `!hasBroker && envBillsMetered(rawEnv)` equals `envBillsMetered(postStripEnv)`
|
|
@@ -117,9 +105,9 @@ export type UsageCostSource =
|
|
|
117
105
|
// UNSTRIPPED, so `hasBroker: true` no longer implies "the child's env has no
|
|
118
106
|
// key" — admission still says subscription (this function's answer is
|
|
119
107
|
// deliberately left unchanged; it cannot see a runtime degrade), and
|
|
120
|
-
// `
|
|
108
|
+
// `claudeCliBillingMode` (reading the real, unstripped child env) correctly
|
|
121
109
|
// files it metered. That disagreement between admission and filing is
|
|
122
|
-
// permanent by design — but the
|
|
110
|
+
// permanent by design — but the usage it describes is no longer
|
|
123
111
|
// unaccounted for: `StepExecutionHarness.run` (harness.ts) recognizes its
|
|
124
112
|
// own degraded projection and applies THIS SAME `envBillsMetered` predicate
|
|
125
113
|
// to the SAME child env to open a spend-ledger reservation for that one
|
|
@@ -179,17 +167,11 @@ export interface NormalizedUsage {
|
|
|
179
167
|
readonly tokens: NormalizedTokens;
|
|
180
168
|
readonly completeness: UsageCompleteness;
|
|
181
169
|
readonly billingMode: UsageBillingMode;
|
|
182
|
-
readonly cashCostUsd?: number;
|
|
183
|
-
readonly notionalCostUsd?: number;
|
|
184
|
-
readonly costSource: UsageCostSource;
|
|
185
170
|
readonly redactedRaw?: unknown;
|
|
186
171
|
}
|
|
187
172
|
|
|
188
|
-
interface
|
|
173
|
+
interface UsageModeInput {
|
|
189
174
|
readonly billingMode: UsageBillingMode;
|
|
190
|
-
readonly costSource: UsageCostSource;
|
|
191
|
-
readonly cashCostUsd?: number;
|
|
192
|
-
readonly notionalCostUsd?: number;
|
|
193
175
|
}
|
|
194
176
|
|
|
195
177
|
function sumOrZero(...values: ReadonlyArray<number | undefined>): number {
|
|
@@ -208,34 +190,12 @@ function attemptTotalKnown(tokens: NormalizedTokens): number | undefined {
|
|
|
208
190
|
return tokens.totalKnown ?? tokens.providerReportedTotal;
|
|
209
191
|
}
|
|
210
192
|
|
|
211
|
-
// 2026-09-02: "did this attempt produce output tokens?", answered from the
|
|
212
|
-
// LEAVES and not from `outputKnown` alone. `outputKnown` is a rollup some
|
|
213
|
-
// builders populate (`normalizeInclusiveUsage`, the OpenCode transport) and
|
|
214
|
-
// others do not, so a reader that consulted it alone would let a transport
|
|
215
|
-
// filling only `outputVisible` slip past — deciding an accounting question by
|
|
216
|
-
// which fields a transport happens to set rather than by whether tokens were
|
|
217
|
-
// produced. The §8 output leaves are disjoint by contract, so summing them is
|
|
218
|
-
// not double counting. One consumer today: `settlementFromUsage`'s
|
|
219
|
-
// metered-zero rule (spend-limiter.ts).
|
|
220
|
-
export function outputTokensKnown(
|
|
221
|
-
tokens: NormalizedTokens,
|
|
222
|
-
): number | undefined {
|
|
223
|
-
return (
|
|
224
|
-
tokens.outputKnown ??
|
|
225
|
-
sumIfAnyDefined(
|
|
226
|
-
tokens.outputVisible,
|
|
227
|
-
tokens.outputReasoning,
|
|
228
|
-
tokens.outputOther,
|
|
229
|
-
)
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
193
|
// §8 line 455: "If a provider total includes detailed cache/reasoning
|
|
234
194
|
// values, split the total into leaves and store only the non-negative
|
|
235
195
|
// residual in inputOther/outputOther; never add the detail to the inclusive
|
|
236
196
|
// total." OpenAI's `prompt_tokens`/`completion_tokens` are this shape — the
|
|
237
197
|
// detail fields are a SUBSET of the total, never additional to it.
|
|
238
|
-
export interface InclusiveUsageInput extends
|
|
198
|
+
export interface InclusiveUsageInput extends UsageModeInput {
|
|
239
199
|
readonly wallMs: number;
|
|
240
200
|
readonly inputTotal: number;
|
|
241
201
|
readonly inputCacheRead?: number;
|
|
@@ -270,18 +230,15 @@ export function normalizeInclusiveUsage(
|
|
|
270
230
|
},
|
|
271
231
|
completeness: "complete",
|
|
272
232
|
billingMode: input.billingMode,
|
|
273
|
-
costSource: input.costSource,
|
|
274
|
-
cashCostUsd: input.cashCostUsd,
|
|
275
|
-
notionalCostUsd: input.notionalCostUsd,
|
|
276
233
|
};
|
|
277
234
|
}
|
|
278
235
|
|
|
279
236
|
// §8 line 457: "If inclusion cannot be proven, keep providerReportedTotal,
|
|
280
237
|
// mark partial, and do not invent a split." No leaf field is populated here
|
|
281
|
-
// — inventing one would resurrect the exact "
|
|
238
|
+
// — inventing one would resurrect the exact "zero on parse failure" collapse
|
|
282
239
|
// this slice exists to kill, just with a fabricated split instead of a
|
|
283
240
|
// fabricated zero.
|
|
284
|
-
export interface PartialUsageInput extends
|
|
241
|
+
export interface PartialUsageInput extends UsageModeInput {
|
|
285
242
|
readonly wallMs: number;
|
|
286
243
|
readonly providerReportedTotal: number;
|
|
287
244
|
}
|
|
@@ -294,17 +251,14 @@ export function normalizePartialUsage(
|
|
|
294
251
|
tokens: { providerReportedTotal: input.providerReportedTotal },
|
|
295
252
|
completeness: "partial",
|
|
296
253
|
billingMode: input.billingMode,
|
|
297
|
-
costSource: input.costSource,
|
|
298
|
-
cashCostUsd: input.cashCostUsd,
|
|
299
|
-
notionalCostUsd: input.notionalCostUsd,
|
|
300
254
|
};
|
|
301
255
|
}
|
|
302
256
|
|
|
303
|
-
// spec: "Parse Failure Yields Unavailable Completeness, Never Zero
|
|
257
|
+
// spec: "Parse Failure Yields Unavailable Completeness, Never Zero Usage" —
|
|
304
258
|
// used when nothing about an attempt's usage can be trusted (corrupted
|
|
305
259
|
// stdout, a dropped final usage chunk, a safety-blocked response with no
|
|
306
|
-
// usage block at all). No leaf
|
|
307
|
-
// fabricated zero; billingMode
|
|
260
|
+
// usage block at all). No leaf or total field is ever populated as a
|
|
261
|
+
// fabricated zero; billingMode falls back to "unknown" rather
|
|
308
262
|
// than guessing which one applied.
|
|
309
263
|
export interface UnavailableUsageInput {
|
|
310
264
|
readonly wallMs: number;
|
|
@@ -319,7 +273,6 @@ export function normalizeUnavailableUsage(
|
|
|
319
273
|
tokens: {},
|
|
320
274
|
completeness: "unavailable",
|
|
321
275
|
billingMode: input.billingMode ?? "unknown",
|
|
322
|
-
costSource: "unknown",
|
|
323
276
|
};
|
|
324
277
|
}
|
|
325
278
|
|
|
@@ -337,10 +290,8 @@ function worseCompleteness(
|
|
|
337
290
|
}
|
|
338
291
|
|
|
339
292
|
// Accumulates two attempts' usage within one step. A failed attempt's tokens
|
|
340
|
-
// still
|
|
341
|
-
// this sums, never replaces.
|
|
342
|
-
// (spec: "Cash And Notional Cost Stay Separate") — neither is ever read to
|
|
343
|
-
// derive the other. billingMode/costSource fall back to "unknown" on
|
|
293
|
+
// still count (ported rationale from `sumUsage` in `src/usage.ts`), so
|
|
294
|
+
// this sums, never replaces. billingMode falls back to "unknown" on
|
|
344
295
|
// disagreement between attempts rather than guessing which one is right.
|
|
345
296
|
export function sumNormalizedUsage(
|
|
346
297
|
a: NormalizedUsage,
|
|
@@ -384,9 +335,6 @@ export function sumNormalizedUsage(
|
|
|
384
335
|
},
|
|
385
336
|
completeness: worseCompleteness(a.completeness, b.completeness),
|
|
386
337
|
billingMode: a.billingMode === b.billingMode ? a.billingMode : "unknown",
|
|
387
|
-
costSource: a.costSource === b.costSource ? a.costSource : "unknown",
|
|
388
|
-
cashCostUsd: sumIfAnyDefined(a.cashCostUsd, b.cashCostUsd),
|
|
389
|
-
notionalCostUsd: sumIfAnyDefined(a.notionalCostUsd, b.notionalCostUsd),
|
|
390
338
|
};
|
|
391
339
|
}
|
|
392
340
|
|
|
@@ -466,6 +414,5 @@ export function projectLegacyUsage(usage: NormalizedUsage): SessionUsage {
|
|
|
466
414
|
tokens_in,
|
|
467
415
|
tokens_out,
|
|
468
416
|
tokens_total,
|
|
469
|
-
cost_usd_est: usage.cashCostUsd ?? 0,
|
|
470
417
|
};
|
|
471
418
|
}
|
|
@@ -54,7 +54,6 @@ export interface JudgeOutcome {
|
|
|
54
54
|
label: MaterialityLabel | null;
|
|
55
55
|
reason?: string;
|
|
56
56
|
error?: string;
|
|
57
|
-
cost: number;
|
|
58
57
|
// The route the judge was planned on, absent only when no plan was built.
|
|
59
58
|
route?: ResolvedModelRoute;
|
|
60
59
|
routeFingerprint?: string;
|
|
@@ -117,12 +116,10 @@ export async function runMaterialityJudge(
|
|
|
117
116
|
parse: parseJudgeVerdict,
|
|
118
117
|
}),
|
|
119
118
|
);
|
|
120
|
-
const cost = result.usage.cost_usd_est;
|
|
121
119
|
if (result.status !== "ok" || result.output === undefined) {
|
|
122
120
|
return {
|
|
123
121
|
label: null,
|
|
124
122
|
error: result.stderrTail.slice(-300),
|
|
125
|
-
cost,
|
|
126
123
|
...recorded,
|
|
127
124
|
};
|
|
128
125
|
}
|
|
@@ -130,14 +127,12 @@ export async function runMaterialityJudge(
|
|
|
130
127
|
return {
|
|
131
128
|
label: verdict.label,
|
|
132
129
|
...(verdict.reason === undefined ? {} : { reason: verdict.reason }),
|
|
133
|
-
cost,
|
|
134
130
|
...recorded,
|
|
135
131
|
};
|
|
136
132
|
} catch (error) {
|
|
137
133
|
return {
|
|
138
134
|
label: null,
|
|
139
135
|
error: error instanceof Error ? error.message : String(error),
|
|
140
|
-
cost: 0,
|
|
141
136
|
...(identity === undefined
|
|
142
137
|
? {}
|
|
143
138
|
: {
|
|
@@ -32,7 +32,6 @@ export type PipelinePlanInput = Pick<
|
|
|
32
32
|
| "models"
|
|
33
33
|
| "config"
|
|
34
34
|
| "summarizer"
|
|
35
|
-
| "scout"
|
|
36
35
|
| "consolidate"
|
|
37
36
|
| "materiality"
|
|
38
37
|
>;
|
|
@@ -76,7 +75,6 @@ export async function buildPipelineHarnessPlan(
|
|
|
76
75
|
bundled: value.bundled === true,
|
|
77
76
|
};
|
|
78
77
|
const summarizer = await stage(input.summarizer);
|
|
79
|
-
const scout = await stage(input.scout);
|
|
80
78
|
const consolidate = await stage(input.consolidate);
|
|
81
79
|
return buildResolvedRoutePlan({
|
|
82
80
|
agents: spec.agents,
|
|
@@ -88,7 +86,6 @@ export async function buildPipelineHarnessPlan(
|
|
|
88
86
|
...(input.bundledAgents === true ? { bundledAgents: true } : {}),
|
|
89
87
|
frontmatterModel: (agentKey) => frontmatter.get(agentKey),
|
|
90
88
|
...(summarizer === undefined ? {} : { summarizer }),
|
|
91
|
-
...(scout === undefined ? {} : { scout }),
|
|
92
89
|
...(consolidate === undefined ? {} : { consolidate }),
|
|
93
90
|
...(input.materiality === undefined ? {} : { materiality: true as const }),
|
|
94
91
|
});
|
|
@@ -94,7 +94,6 @@ export function refuterReplayRow(input: {
|
|
|
94
94
|
expect: c.expect,
|
|
95
95
|
label: c.label,
|
|
96
96
|
prompt_check: input.promptCheck,
|
|
97
|
-
notional_usd: result.usageV2?.notionalCostUsd ?? null,
|
|
98
97
|
wall_ms: result.usageV2?.wallMs ?? null,
|
|
99
98
|
};
|
|
100
99
|
}
|
|
@@ -130,7 +129,6 @@ export type ConsolidateStepRow = {
|
|
|
130
129
|
readonly plan?: PlanEntry[];
|
|
131
130
|
readonly in: number;
|
|
132
131
|
readonly out: number;
|
|
133
|
-
readonly notional_usd: number | null;
|
|
134
132
|
readonly model: string;
|
|
135
133
|
} & RouteIdentityFields;
|
|
136
134
|
|
|
@@ -147,7 +145,6 @@ export function consolidateStepRow(input: {
|
|
|
147
145
|
model: route.model,
|
|
148
146
|
...routeIdentityFields(route.identity),
|
|
149
147
|
};
|
|
150
|
-
const notional_usd = result.usageV2?.notionalCostUsd ?? null;
|
|
151
148
|
if (result.status !== "ok") {
|
|
152
149
|
return {
|
|
153
150
|
label,
|
|
@@ -155,7 +152,6 @@ export function consolidateStepRow(input: {
|
|
|
155
152
|
reason: (result.stderrTail ?? "").slice(-300),
|
|
156
153
|
in: ids.length,
|
|
157
154
|
out: ids.length,
|
|
158
|
-
notional_usd,
|
|
159
155
|
...ran,
|
|
160
156
|
};
|
|
161
157
|
}
|
|
@@ -166,7 +162,6 @@ export function consolidateStepRow(input: {
|
|
|
166
162
|
plan,
|
|
167
163
|
in: ids.length,
|
|
168
164
|
out: plan.length,
|
|
169
|
-
notional_usd,
|
|
170
165
|
...ran,
|
|
171
166
|
};
|
|
172
167
|
}
|
|
@@ -42,8 +42,8 @@ export class HarnessRouteError extends Error {
|
|
|
42
42
|
|
|
43
43
|
// buildResolvedRoutePlan's input with every step optional and the profile
|
|
44
44
|
// defaulting to `claude`, as a review's does. A single-step harness names its
|
|
45
|
-
// one step: `agents: [{ key: "refuter", role: "refuter" }]`,
|
|
46
|
-
// `materiality: true`. `bundledAgents` (and `bundled` on a root prompt) gives
|
|
45
|
+
// one step: `agents: [{ key: "refuter", role: "refuter" }]`,
|
|
46
|
+
// `consolidate: {...}`, `materiality: true`. `bundledAgents` (and `bundled` on a root prompt) gives
|
|
47
47
|
// the step the profile seat; a lab prompt set passes `frontmatterModel`
|
|
48
48
|
// instead, and its frontmatter wins as in production.
|
|
49
49
|
export type HarnessRoutePlanInput = Partial<BuildRoutePlanInput>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Single-step harnesses on the route seam (odd/tasks/route-plan-harness.md S3,
|
|
2
|
-
// S6): refuter-replay,
|
|
2
|
+
// S6): refuter-replay, consolidate-replay, live-micro-eval and
|
|
3
3
|
// martian-judge each run one step. Each builds a one-step plan from the model
|
|
4
4
|
// it measures, prepares the runner through route-runner.ts, routes its spec,
|
|
5
5
|
// and records the route identity in its rows.
|
|
@@ -26,11 +26,7 @@ import {
|
|
|
26
26
|
// production role (the Martian judge, the trivial micro-eval) under its own
|
|
27
27
|
// key. A harness-only step has no profile seat or `models` role: only the
|
|
28
28
|
// harness's model routes it.
|
|
29
|
-
export type SingleStep =
|
|
30
|
-
| "refuter"
|
|
31
|
-
| "scout"
|
|
32
|
-
| "consolidate"
|
|
33
|
-
| { readonly key: string };
|
|
29
|
+
export type SingleStep = "refuter" | "consolidate" | { readonly key: string };
|
|
34
30
|
|
|
35
31
|
export function singleStepPlanInput(
|
|
36
32
|
step: SingleStep,
|
|
@@ -43,10 +39,8 @@ export function singleStepPlanInput(
|
|
|
43
39
|
bundledAgents: true,
|
|
44
40
|
cliModel: model,
|
|
45
41
|
};
|
|
46
|
-
//
|
|
42
|
+
// This takes the model as the stage's own, not cliModel, so the bare
|
|
47
43
|
// pinned id is spelled out here as buildHarnessRoutePlan does for cliModel.
|
|
48
|
-
case "scout":
|
|
49
|
-
return { scout: { model: harnessModelChoice(model) ?? model } };
|
|
50
44
|
case "consolidate":
|
|
51
45
|
return { consolidate: { model: harnessModelChoice(model) ?? model } };
|
|
52
46
|
default:
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Public API surface; the deep-review lab consumes exactly these exports.
|
|
3
3
|
|
|
4
4
|
export const ENGINE_NAME = "pr-hero";
|
|
5
|
-
export const ENGINE_VERSION = "0.
|
|
5
|
+
export const ENGINE_VERSION = "0.8.0";
|
|
6
6
|
|
|
7
7
|
// errors and git/refs used to reach this surface only through re-exports in
|
|
8
8
|
// review/preflight.ts; they are exported directly now that those re-exports
|
package/src/mcp/preflight.ts
CHANGED
|
@@ -57,7 +57,7 @@ const MCP_TOOLS: McpToolDefinition[] = [
|
|
|
57
57
|
{
|
|
58
58
|
name: "crysk_get_run",
|
|
59
59
|
description:
|
|
60
|
-
"Retrieve full telemetry, timing, summary score, and
|
|
60
|
+
"Retrieve full telemetry, timing, summary score, and token usage of a single review run.",
|
|
61
61
|
inputSchema: {
|
|
62
62
|
type: "object",
|
|
63
63
|
properties: {
|
|
@@ -118,7 +118,7 @@ const MCP_TOOLS: McpToolDefinition[] = [
|
|
|
118
118
|
{
|
|
119
119
|
name: "crysk_get_usage",
|
|
120
120
|
description:
|
|
121
|
-
"Retrieve aggregated token usage
|
|
121
|
+
"Retrieve aggregated token usage and run counts (global or scoped to a repository).",
|
|
122
122
|
inputSchema: {
|
|
123
123
|
type: "object",
|
|
124
124
|
properties: {
|
package/src/model/catalog.ts
CHANGED
|
@@ -172,14 +172,13 @@ export function isEffort(value: string): value is Effort {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
// Which kind of step is being built. Wider than `AgentSpec.role` on purpose:
|
|
175
|
-
// the summarizer
|
|
175
|
+
// the summarizer and rereview verifier are steps too, and each needs a
|
|
176
176
|
// resolved level, not an implicit one. `other` is for ad hoc steps (judges,
|
|
177
177
|
// probes) built outside the pipeline.
|
|
178
178
|
export type StepRole =
|
|
179
179
|
| "hunter"
|
|
180
180
|
| "refuter"
|
|
181
181
|
| "summarizer"
|
|
182
|
-
| "scout"
|
|
183
182
|
| "verifier"
|
|
184
183
|
| "other";
|
|
185
184
|
|
|
@@ -214,7 +213,6 @@ const ROLE_EFFORT: Readonly<Record<StepRole, Effort>> = Object.freeze({
|
|
|
214
213
|
hunter: profileRoleEffort(FALLBACK_PROFILE, "hunter"),
|
|
215
214
|
refuter: profileRoleEffort(FALLBACK_PROFILE, "refuter"),
|
|
216
215
|
summarizer: profileRoleEffort(FALLBACK_PROFILE, "summary"),
|
|
217
|
-
scout: profileRoleEffort(FALLBACK_PROFILE, "scout"),
|
|
218
216
|
verifier: "high",
|
|
219
217
|
other: "high",
|
|
220
218
|
});
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { credentialKindForRoute } from "../runner-authority";
|
|
2
|
-
|
|
3
1
|
// #182: live free-model discovery. OpenCode free models (backend `opencode`,
|
|
4
2
|
// provider `opencode`, e.g. `muse-spark-1.3-contributor-free`) authenticate
|
|
5
3
|
// with NOTHING, but without a liveness check they are refused at credential
|
|
@@ -11,34 +9,21 @@ import { credentialKindForRoute } from "../runner-authority";
|
|
|
11
9
|
// provider itself declares: exact model id present AND status active AND
|
|
12
10
|
// input===0 AND output===0 AND cache.read===0 AND cache.write===0.
|
|
13
11
|
//
|
|
14
|
-
// WHY `--refresh`: a stale price is a CONFIDENT WRONG
|
|
15
|
-
// than no
|
|
16
|
-
// stale quote defeats it by making the unknown look known. That doctrine used
|
|
17
|
-
// to live in src/pricing-catalog.ts, whose bundled rate tables #197 deleted
|
|
18
|
-
// for failing it (they aged on our release cadence and then refused the very
|
|
19
|
-
// routes they existed to price); it is restated here rather than pointed at,
|
|
20
|
-
// because it is this function's reason and now has no other home. A cached
|
|
12
|
+
// WHY `--refresh`: a stale price is a CONFIDENT WRONG ANSWER, which is worse
|
|
13
|
+
// than no answer — a stale quote makes an unknown look known. A cached
|
|
21
14
|
// all-zero cost that has since become metered would admit a paid run as free;
|
|
22
15
|
// offline failure must refuse loudly downstream (fail closed →
|
|
23
16
|
// provider_api_token), not silently pass.
|
|
24
17
|
//
|
|
25
|
-
// SCOPE NOTE (residual
|
|
26
|
-
// the
|
|
27
|
-
//
|
|
28
|
-
// the
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
// (
|
|
33
|
-
//
|
|
34
|
-
// stated figure), the spend ledger fences the bucket, and the harness fails
|
|
35
|
-
// the attempt closed with no retry (re-probe is the remedy). Measured first:
|
|
36
|
-
// a legitimate free attempt reports cash 0 (Step-0 probe, "Say OK" on
|
|
37
|
-
// muse-spark-1.3-contributor-free), so the rule cannot misfire on list-price
|
|
38
|
-
// reporting. Free usage with NO cash figure releases WITHOUT fencing
|
|
39
|
-
// (harness.ts free-route fence scope) — no cash figure means no evidence of
|
|
40
|
-
// billing. Cancelled/undefined-usage and non-free incomplete usage still
|
|
41
|
-
// fence: no usage mode to exonerate them, so fail closed.
|
|
18
|
+
// SCOPE NOTE (residual, #182 follow-up): between the probe and the attempt
|
|
19
|
+
// the provider could flip a model from free to metered (stale-cache window).
|
|
20
|
+
// The attempt then runs under an empty projection. The engine no longer reads
|
|
21
|
+
// a price off the attempt: it reports the tokens, the models and the route's
|
|
22
|
+
// credential class ("free"), and the platform prices them. What the engine
|
|
23
|
+
// keeps is the credential fence: a free route is reserved in the spend ledger
|
|
24
|
+
// like a metered one (production-runtime.ts), so usage it could not confirm
|
|
25
|
+
// (partial, unavailable, cancelled) fences the bucket and no further attempt
|
|
26
|
+
// runs on it; the remedy is a re-probe.
|
|
42
27
|
|
|
43
28
|
export type FreeModelProbe = (
|
|
44
29
|
provider: string,
|
|
@@ -264,58 +249,6 @@ export function createFreeModelProbe(options: {
|
|
|
264
249
|
};
|
|
265
250
|
}
|
|
266
251
|
|
|
267
|
-
// The plan line's billing half: how many steps of an ADMITTED route plan the
|
|
268
|
-
// free verdict covers. Reads only the verdicts admission already decided, so
|
|
269
|
-
// it never spawns — `probe` is the memoised instance admission returned, and a
|
|
270
|
-
// pair admission never probed would spawn here, which is why the gate below
|
|
271
|
-
// is the same one admission applies (openCodeFreeVerdicts in
|
|
272
|
-
// production-runtime.ts): credentialKindForRoute over the run's CRYSK_OPENCODE_*
|
|
273
|
-
// names (U3), so only a route whose kind is an API token can be free. An OAuth
|
|
274
|
-
// route (`openai` on its `_OAUTH` record, or on no names at all) never probes,
|
|
275
|
-
// and a claude-code step has no free kind at all. A missing probe, or a
|
|
276
|
-
// throwing one, counts as not free: an unknown price is never presented as free.
|
|
277
|
-
export interface FreeRouteBilling {
|
|
278
|
-
readonly free: number;
|
|
279
|
-
readonly total: number;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export async function countFreeRouteSteps(input: {
|
|
283
|
-
readonly steps: readonly {
|
|
284
|
-
readonly route: {
|
|
285
|
-
readonly backend: string;
|
|
286
|
-
readonly provider: string;
|
|
287
|
-
readonly modelSnapshot: string;
|
|
288
|
-
};
|
|
289
|
-
}[];
|
|
290
|
-
readonly probe: FreeModelProbe | undefined;
|
|
291
|
-
// The names admission read from the setup step's manifest
|
|
292
|
-
// (productionAdmission.authorityOptions.openCodeSecretNames); absent outside CI.
|
|
293
|
-
readonly openCodeSecretNames?: readonly string[];
|
|
294
|
-
}): Promise<FreeRouteBilling> {
|
|
295
|
-
const total = input.steps.length;
|
|
296
|
-
if (input.probe === undefined) return { free: 0, total };
|
|
297
|
-
const probe = input.probe;
|
|
298
|
-
const verdicts = await Promise.all(
|
|
299
|
-
input.steps.map(async ({ route }) => {
|
|
300
|
-
if (route.backend !== "opencode") return false;
|
|
301
|
-
const kind = credentialKindForRoute(
|
|
302
|
-
"opencode",
|
|
303
|
-
route.provider,
|
|
304
|
-
{},
|
|
305
|
-
false,
|
|
306
|
-
input.openCodeSecretNames,
|
|
307
|
-
);
|
|
308
|
-
if (kind !== "provider_api_token") return false;
|
|
309
|
-
try {
|
|
310
|
-
return await probe(route.provider, route.modelSnapshot);
|
|
311
|
-
} catch {
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
}),
|
|
315
|
-
);
|
|
316
|
-
return { free: verdicts.filter((free) => free).length, total };
|
|
317
|
-
}
|
|
318
|
-
|
|
319
252
|
// S7 (E-g, E2; odd/tasks/role-model-routing.md L34): the variants OpenCode
|
|
320
253
|
// lists for a model, read from the SAME `models <provider> --verbose
|
|
321
254
|
// --refresh` listing the free check reads. OpenCode prints each model's whole
|
package/src/model/model-name.ts
CHANGED
|
@@ -194,7 +194,6 @@ export function modelNameFromAlias(value: string): ModelName {
|
|
|
194
194
|
export const FIXED_MODEL_ROLES = [
|
|
195
195
|
"default",
|
|
196
196
|
"consolidate",
|
|
197
|
-
"scout",
|
|
198
197
|
"judge",
|
|
199
198
|
"refuter",
|
|
200
199
|
"summary",
|
|
@@ -369,10 +368,17 @@ export type ModelsConfig = Readonly<Record<string, readonly ModelListEntry[]>>;
|
|
|
369
368
|
const JUDGE_NO_EFFORT =
|
|
370
369
|
"the materiality judge runs at the effort it was measured at, so models.judge takes model names only";
|
|
371
370
|
|
|
372
|
-
const ROLE_LIST =
|
|
373
|
-
"default, hunter.<key>, consolidate, scout, judge, refuter, summary";
|
|
371
|
+
const ROLE_LIST = "default, hunter.<key>, consolidate, judge, refuter, summary";
|
|
374
372
|
|
|
375
|
-
|
|
373
|
+
// Roles that used to exist and are still accepted in `models`, never read: a
|
|
374
|
+
// stored profile naming one must keep loading. `onRemoved` hears each one so
|
|
375
|
+
// the caller can say it was ignored; without it the entry is skipped silently.
|
|
376
|
+
const REMOVED_MODEL_ROLES: readonly string[] = ["scout"];
|
|
377
|
+
|
|
378
|
+
export function parseModelsConfig(
|
|
379
|
+
value: unknown,
|
|
380
|
+
onRemoved?: (role: string) => void,
|
|
381
|
+
): ModelsConfig {
|
|
376
382
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
377
383
|
throw new ModelNameError(
|
|
378
384
|
"models must be an object from role to a list of models",
|
|
@@ -380,6 +386,10 @@ export function parseModelsConfig(value: unknown): ModelsConfig {
|
|
|
380
386
|
}
|
|
381
387
|
const result: Record<string, ModelListEntry[]> = {};
|
|
382
388
|
for (const [role, list] of Object.entries(value)) {
|
|
389
|
+
if (REMOVED_MODEL_ROLES.includes(role)) {
|
|
390
|
+
onRemoved?.(role);
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
383
393
|
if (!isModelRole(role)) {
|
|
384
394
|
throw new ModelNameError(
|
|
385
395
|
`models has an unknown role ${quoted(role)}: roles are ${ROLE_LIST}`,
|
|
@@ -6,7 +6,7 @@ import type { ModelProfile } from "../profiles";
|
|
|
6
6
|
//
|
|
7
7
|
// Exactly what 4898e1b4 runs with no configuration, read off the bundled
|
|
8
8
|
// prompts' frontmatter (prompts/default/*.md, consolidate.md, summarizer.md),
|
|
9
|
-
// the old
|
|
9
|
+
// the old DEFAULT_CONSOLIDATE_MODEL /
|
|
10
10
|
// DEFAULT_CONSOLIDATE_EFFORT / DEFAULT_SUMMARY_MODEL / MATERIALITY_JUDGE_MODEL
|
|
11
11
|
// constants and ROLE_EFFORT (catalog.ts, where the #299 evidence for the
|
|
12
12
|
// hunter and refuter levels lives). Pinned by
|
|
@@ -20,7 +20,6 @@ export const CLAUDE_PROFILE: ModelProfile = Object.freeze({
|
|
|
20
20
|
model: "claude:sonnet-latest",
|
|
21
21
|
effort: "high",
|
|
22
22
|
}),
|
|
23
|
-
scout: Object.freeze({ model: "claude:sonnet-latest", effort: "high" }),
|
|
24
23
|
summary: Object.freeze({ model: "claude:haiku-latest", effort: "high" }),
|
|
25
24
|
judge: Object.freeze({ model: "claude:sonnet-latest", effort: "high" }),
|
|
26
25
|
}),
|
|
@@ -3,7 +3,7 @@ import type { ModelProfile } from "../profiles";
|
|
|
3
3
|
// The `openai` profile: every step on OpenAI models through OpenCode, the same
|
|
4
4
|
// parallel hunters `claude` runs. Juanma's approved table (odd/tasks/
|
|
5
5
|
// openai-profile.md S2, "Asi si"): Sol for the refuter, Terra for the hunters,
|
|
6
|
-
// consolidate
|
|
6
|
+
// consolidate and judge, Luna for the summary.
|
|
7
7
|
//
|
|
8
8
|
// An effort becomes the OpenCode variant (OpenAI's Responses variants are
|
|
9
9
|
// none..xhigh). A role with no effort sends no variant, so it runs at the
|
|
@@ -29,7 +29,6 @@ export const OPENAI_PROFILE: ModelProfile = Object.freeze({
|
|
|
29
29
|
model: "opencode:openai/gpt-6.1-terra",
|
|
30
30
|
effort: "high",
|
|
31
31
|
}),
|
|
32
|
-
scout: Object.freeze({ model: "opencode:openai/gpt-6.1-terra" }),
|
|
33
32
|
summary: Object.freeze({ model: "opencode:openai/gpt-6-luna" }),
|
|
34
33
|
judge: Object.freeze({ model: "opencode:openai/gpt-6.1-terra" }),
|
|
35
34
|
}),
|
package/src/model/profiles.ts
CHANGED
|
@@ -26,7 +26,6 @@ export const PROFILE_ROLES = [
|
|
|
26
26
|
"hunter",
|
|
27
27
|
"refuter",
|
|
28
28
|
"consolidate",
|
|
29
|
-
"scout",
|
|
30
29
|
"summary",
|
|
31
30
|
"judge",
|
|
32
31
|
] as const;
|
|
@@ -45,7 +44,7 @@ export interface ModelProfile {
|
|
|
45
44
|
readonly id: string;
|
|
46
45
|
// A role the profile leaves out falls back to the fallback profile's.
|
|
47
46
|
readonly roles: Readonly<Partial<Record<ProfileRole, ProfileRoute>>>;
|
|
48
|
-
// Per-hunter overrides, keyed by specialty (`logic`, `
|
|
47
|
+
// Per-hunter overrides, keyed by specialty (`logic`, `security`, ...).
|
|
49
48
|
readonly hunters?: Readonly<Record<string, ProfileRoute>>;
|
|
50
49
|
// The profile's prompt set (S4): the name of a set under
|
|
51
50
|
// `prompts/profiles/<name>/` that holds only the files that differ from the
|