crysk 0.6.1 → 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.
Files changed (179) hide show
  1. package/README.md +28 -22
  2. package/dist/SKILL-1q3658n0.md +74 -0
  3. package/dist/SKILL-25j4q9b8.md +143 -0
  4. package/dist/SKILL-32cmme3j.md +143 -0
  5. package/dist/SKILL-4747bhne.md +143 -0
  6. package/dist/SKILL-4jc3sv23.md +74 -0
  7. package/dist/SKILL-c0492rch.md +540 -0
  8. package/dist/SKILL-d1nzkhhr.md +74 -0
  9. package/dist/SKILL-f8p7kvx0.md +143 -0
  10. package/dist/SKILL-gxd45g38.md +553 -0
  11. package/dist/SKILL-rec41991.md +66 -0
  12. package/dist/SKILL-zze8zj5g.md +536 -0
  13. package/dist/adjudicator-eckqh14e.md +78 -0
  14. package/dist/ci-admission-qn797a6c.md +128 -0
  15. package/dist/cli.js +18608 -18523
  16. package/dist/consolidate-4xw1pkg7.md +24 -0
  17. package/dist/deep-review-logic-dgr112y1.md +196 -0
  18. package/dist/deep-review-logic-fck5z4xe.md +197 -0
  19. package/dist/deep-review-logic-h1fpamfh.md +192 -0
  20. package/dist/deep-review-logic-m4vk5683.md +196 -0
  21. package/dist/deep-review-logic-z63kmgmc.md +157 -0
  22. package/dist/deep-review-parity-7x7s5d81.md +148 -0
  23. package/dist/deep-review-parity-9wxmynsc.md +115 -0
  24. package/dist/deep-review-parity-bwwe7cx6.md +152 -0
  25. package/dist/deep-review-parity-e50pw3pk.md +117 -0
  26. package/dist/deep-review-parity-ennmm9m1.md +151 -0
  27. package/{prompts/default/deep-review-parity.md → dist/deep-review-parity-h7y6y2he.md} +14 -16
  28. package/dist/deep-review-parity-xg6wy69c.md +151 -0
  29. package/dist/deep-review-reliability-6h3c4gmw.md +125 -0
  30. package/dist/deep-review-reliability-dcjab69x.md +122 -0
  31. package/dist/deep-review-reliability-ec7b5pbk.md +159 -0
  32. package/dist/deep-review-reliability-hvasvmt9.md +153 -0
  33. package/dist/deep-review-reliability-mjnayxmt.md +158 -0
  34. package/dist/deep-review-reliability-mm7fnayf.md +124 -0
  35. package/dist/deep-review-reliability-xk4xvc2w.md +158 -0
  36. package/dist/deep-review-resilience-0esd5qeh.md +148 -0
  37. package/dist/deep-review-resilience-envgcmpy.md +115 -0
  38. package/dist/deep-review-resilience-fgx8ythf.md +151 -0
  39. package/dist/deep-review-resilience-mq5qa6ad.md +152 -0
  40. package/dist/deep-review-resilience-pwh1gawp.md +151 -0
  41. package/dist/deep-review-resilience-s9n21dkx.md +117 -0
  42. package/dist/deep-review-resilience-vz4qskea.md +119 -0
  43. package/dist/deep-review-security-1vwjdc9q.md +205 -0
  44. package/dist/deep-review-security-x1cc1z00.md +205 -0
  45. package/dist/index.js +590 -485
  46. package/dist/opencode-ci-jc8mf4wn.md +106 -0
  47. package/dist/opencode-ci-qrcv7a99.md +106 -0
  48. package/dist/opencode-ci-rdpcc7xc.md +106 -0
  49. package/dist/opencode-ci-yt0k74t0.md +106 -0
  50. package/dist/review-refuter-7qffwtzz.md +77 -0
  51. package/dist/verifier-tyh8r45v.md +40 -0
  52. package/dist/verifier-xf4xj701.md +40 -0
  53. package/dist/workflow-andv2dvm.yml +158 -0
  54. package/package.json +1 -1
  55. package/prompts/consolidate.md +1 -1
  56. package/prompts/default/PROVENANCE.md +6 -0
  57. package/prompts/default/deep-review-logic.md +56 -15
  58. package/prompts/default/deep-review-reliability.md +64 -30
  59. package/prompts/default/deep-review-resilience.md +71 -37
  60. package/prompts/default/deep-review-security.md +205 -0
  61. package/prompts/default/review-refuter.md +1 -1
  62. package/prompts/verifier.md +40 -0
  63. package/skills/crysk/SKILL.md +6 -6
  64. package/skills/crysk-ci-setup/SKILL.md +32 -33
  65. package/skills/crysk-ci-setup/assets/workflow.yml +5 -10
  66. package/skills/crysk-ci-setup/references/ci-admission.md +5 -5
  67. package/skills/crysk-ci-setup/references/opencode-ci.md +6 -6
  68. package/skills/crysk-loop/SKILL.md +37 -54
  69. package/skills/crysk-loop/adjudicator.md +10 -18
  70. package/skills/crysk-pr/SKILL.md +1 -1
  71. package/src/asset-manifest.ts +6 -6
  72. package/src/assets.ts +4 -4
  73. package/src/brand.ts +20 -30
  74. package/src/ci/gates.ts +155 -192
  75. package/src/ci/outcome.ts +4 -31
  76. package/src/ci/platform-limits.ts +135 -0
  77. package/src/ci/platform-report.ts +212 -126
  78. package/src/ci/platform.ts +28 -26
  79. package/src/ci/reporter.ts +25 -26
  80. package/src/ci/review-admission.ts +1 -2
  81. package/src/ci/review-levels.ts +12 -53
  82. package/src/ci/setup.ts +96 -66
  83. package/src/ci/trace-bundle.ts +11 -27
  84. package/src/ci/trace-transcripts.ts +4 -6
  85. package/src/ci/trigger.ts +3 -5
  86. package/src/cli.ts +6 -5
  87. package/src/commands/ci-setup-questions.ts +2 -55
  88. package/src/commands/ci-setup.ts +2 -26
  89. package/src/commands/triage.ts +131 -38
  90. package/src/commands/usage.ts +0 -1
  91. package/src/compare/compare.ts +3 -3
  92. package/src/compare/floor-test.ts +30 -201
  93. package/src/compare/hunter-exam.ts +631 -0
  94. package/src/config/config.ts +6 -30
  95. package/src/diversity/accounting.ts +0 -26
  96. package/src/diversity/benchmark.ts +1 -17
  97. package/src/diversity/identity.ts +0 -14
  98. package/src/diversity/pipeline-integration.ts +0 -29
  99. package/src/doctor.ts +3 -6
  100. package/src/execution/claude-session-trace.ts +7 -2
  101. package/src/execution/contracts.ts +15 -9
  102. package/src/execution/harness.ts +165 -187
  103. package/src/execution/spend-limiter.ts +39 -131
  104. package/src/execution/usage-facts.ts +397 -0
  105. package/src/execution/usage-normalized.ts +33 -86
  106. package/src/harness/materiality-judge.ts +0 -5
  107. package/src/harness/pipeline-plan.ts +0 -3
  108. package/src/harness/replay-rows.ts +0 -5
  109. package/src/harness/route-runner.ts +2 -2
  110. package/src/harness/single-step.ts +3 -9
  111. package/src/index.ts +1 -1
  112. package/src/mcp/preflight.ts +2 -2
  113. package/src/model/catalog.ts +1 -3
  114. package/src/model/free-discovery.ts +11 -78
  115. package/src/model/model-name.ts +16 -5
  116. package/src/model/profiles/claude.ts +1 -2
  117. package/src/model/profiles/openai.ts +1 -2
  118. package/src/model/profiles.ts +2 -3
  119. package/src/model/provider-capabilities.ts +16 -55
  120. package/src/model/routing.ts +39 -36
  121. package/src/pr/admission.ts +6 -6
  122. package/src/pr/answered-findings.ts +8 -4
  123. package/src/pr/ci-publish.ts +0 -2
  124. package/src/pr/discovery.ts +4 -25
  125. package/src/pr/plan.ts +40 -121
  126. package/src/pr/pr-status.ts +14 -2
  127. package/src/pr/pr.ts +1 -1
  128. package/src/pr/preflight.ts +44 -15
  129. package/src/pr/publish-outcome.ts +1 -19
  130. package/src/pr/review-pr.ts +15 -47
  131. package/src/pr/target.ts +76 -82
  132. package/src/production-runtime.ts +52 -114
  133. package/src/progress.ts +0 -54
  134. package/src/rereview/prepare.ts +4 -1
  135. package/src/rereview/state.ts +1 -1
  136. package/src/rereview/verify.ts +15 -9
  137. package/src/review/boundary.ts +5 -8
  138. package/src/review/drafts.ts +3 -3
  139. package/src/review/findings-conformance.ts +1 -1
  140. package/src/review/findings.ts +0 -4
  141. package/src/review/pipeline.ts +194 -407
  142. package/src/review/preflight.ts +175 -201
  143. package/src/review/prompt-set.ts +1 -2
  144. package/src/review/report.ts +2 -162
  145. package/src/review/review.ts +25 -74
  146. package/src/review/route-preflight.ts +19 -35
  147. package/src/review/run.ts +37 -73
  148. package/src/review/size-gate.ts +3 -3
  149. package/src/review/spec.ts +6 -11
  150. package/src/review/step-runner.ts +4 -4
  151. package/src/runner-authority.ts +10 -9
  152. package/src/security/credential-broker.ts +5 -6
  153. package/src/server/preflight.ts +0 -1
  154. package/src/server/server.ts +17 -6
  155. package/src/store/activity.ts +1 -2
  156. package/src/store/backfill-preflight.ts +0 -3
  157. package/src/store/backfill.ts +0 -1
  158. package/src/store/metrics-preflight.ts +4 -14
  159. package/src/store/metrics.ts +5 -5
  160. package/src/store/preflight.ts +0 -13
  161. package/src/store/store.ts +11 -12
  162. package/src/transport-registry.ts +6 -30
  163. package/src/transports/claude-code-cli.ts +149 -215
  164. package/src/transports/opencode-client.ts +4 -24
  165. package/src/transports/opencode-sdk.ts +17 -112
  166. package/src/triage/plain-reply.ts +37 -0
  167. package/src/ui/activity.ts +1 -6
  168. package/src/ui/config-edit.ts +14 -67
  169. package/src/ui/config.ts +3 -8
  170. package/src/ui/plan.ts +11 -198
  171. package/src/ui/progress.ts +3 -49
  172. package/src/ui/result.ts +18 -77
  173. package/src/ui/review-menu.ts +3 -12
  174. package/src/ui/select.ts +9 -79
  175. package/src/updater.ts +1 -1
  176. package/src/usage.ts +1 -7
  177. package/prompts/scout.md +0 -140
  178. package/src/ci/platform-estimate.ts +0 -111
  179. 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, but a model free at probe time can flip
14
- // to metered before/during the attempt — and the transport observes
15
- // provider-reported cost per message (opencode-sdk.ts cashCostUsd,
16
- // costSource "provider"). Stamping "subscription" would let
17
- // `settlementFromUsage`'s free-nonzero rule (spend-limiter.ts) never fire and
18
- // settle a flipped attempt's priced cost as a truthful zero. Capability
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: `deriveCiBillingMode` (ci/gates.ts) turns it into a CI spend
32
- // ceiling, and the Claude CLI transport turns it into the `billingMode`
33
- // STAMPED ON EVERY USAGE RECORD it emits. This is the same anti-drift shape
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 real spend as `notionalCostUsd`, which renders as "at list price, not
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 reports real money as not
60
- // charged.
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 impose a ceiling — or, here, book a subscription run's quota
72
- // spend as cash. Mutation-checked: dropping the trim flips exactly the
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 `pricingApplicability: "required"` with no
86
- // pricing source to answer, so the route was refused admission outright
87
- // (`pricing_table_missing`, blocking) and API-key users stopped being able to
88
- // run at all. #197 flipped the claude-code transport's `pricingReady` to
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
- // `claudeCliCostBasis` call — never two copies of the same trim rule
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: `claudeCliCostBasis` reads the child's
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 the money was
105
- // spent by actually saw. `credentialKindForRoute` runs BEFORE any child
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
- // `claudeCliCostBasis` (reading the real, unstripped child env) correctly
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 spend it describes is no longer
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 UsageCostInput {
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 UsageCostInput {
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 "$0 on parse failure" collapse
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 UsageCostInput {
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 Cost" —
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, cost, or total field is ever populated as a
307
- // fabricated zero; billingMode/costSource fall back to "unknown" rather
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 cost money (ported rationale from `sumUsage` in `src/usage.ts`), so
341
- // this sums, never replaces. Cash and notional accumulate independently
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" }]`, `scout: {...}`,
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, scout-probe, consolidate-replay, live-micro-eval and
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
- // These take the model as the stage's own, not cliModel, so the bare
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.6.1";
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
@@ -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 cost breakdown of a single review run.",
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, cost breakdown, and run counts (global or scoped to a repository).",
121
+ "Retrieve aggregated token usage and run counts (global or scoped to a repository).",
122
122
  inputSchema: {
123
123
  type: "object",
124
124
  properties: {
@@ -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, scout and rereview verifier are steps too, and each needs a
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 NUMBER, which is worse
15
- // than no price — the gate exists to refuse billing an unknown amount, and a
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 now guarded, #182 follow-up): between the probe and
26
- // the attempt the provider could flip a model from free to metered
27
- // (stale-cache window). The attempt then runs under an empty projection, and
28
- // the flip is observable at settlement — the transport accumulates
29
- // provider-reported cost per message (`cashCostUsd`, `costSource: "provider"`,
30
- // opencode-sdk.ts), stamped with the route's billing mode ("free",
31
- // transport-registry.ts). `settlementFromUsage`'s free-nonzero rule
32
- // (spend-limiter.ts) routes complete usage with cash > 0 on a free-declared
33
- // route to unresolved WITH reason `free_nonzero_cost` (carrying the provider's
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
@@ -187,13 +187,13 @@ export function modelNameFromAlias(value: string): ModelName {
187
187
 
188
188
  // The roles a model can be assigned to (S1). `refuter` covers the verifier and
189
189
  // the adjudicator too: the three judge one finding against the code, and the
190
- // verifier and adjudicator run the refuter's prompt family. `judge` is the
190
+ // verifier and adjudicator run as the refuter's agent (the verifier under its
191
+ // own engine-owned instructions, prompts/verifier.md). `judge` is the
191
192
  // materiality judge. Hunters are open: `hunter.<key>` for any hunter key the
192
193
  // review spec declares, checked against the spec when the plan is built.
193
194
  export const FIXED_MODEL_ROLES = [
194
195
  "default",
195
196
  "consolidate",
196
- "scout",
197
197
  "judge",
198
198
  "refuter",
199
199
  "summary",
@@ -368,10 +368,17 @@ export type ModelsConfig = Readonly<Record<string, readonly ModelListEntry[]>>;
368
368
  const JUDGE_NO_EFFORT =
369
369
  "the materiality judge runs at the effort it was measured at, so models.judge takes model names only";
370
370
 
371
- const ROLE_LIST =
372
- "default, hunter.<key>, consolidate, scout, judge, refuter, summary";
371
+ const ROLE_LIST = "default, hunter.<key>, consolidate, judge, refuter, summary";
373
372
 
374
- export function parseModelsConfig(value: unknown): ModelsConfig {
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 {
375
382
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
376
383
  throw new ModelNameError(
377
384
  "models must be an object from role to a list of models",
@@ -379,6 +386,10 @@ export function parseModelsConfig(value: unknown): ModelsConfig {
379
386
  }
380
387
  const result: Record<string, ModelListEntry[]> = {};
381
388
  for (const [role, list] of Object.entries(value)) {
389
+ if (REMOVED_MODEL_ROLES.includes(role)) {
390
+ onRemoved?.(role);
391
+ continue;
392
+ }
382
393
  if (!isModelRole(role)) {
383
394
  throw new ModelNameError(
384
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 DEFAULT_SCOUT_MODEL / DEFAULT_CONSOLIDATE_MODEL /
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, scout and judge, Luna for the summary.
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
  }),