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.
Files changed (133) hide show
  1. package/README.md +27 -23
  2. package/dist/SKILL-1q3658n0.md +74 -0
  3. package/dist/SKILL-25j4q9b8.md +143 -0
  4. package/dist/SKILL-4747bhne.md +143 -0
  5. package/dist/SKILL-4jc3sv23.md +74 -0
  6. package/dist/SKILL-c0492rch.md +540 -0
  7. package/dist/SKILL-d1nzkhhr.md +74 -0
  8. package/dist/SKILL-f8p7kvx0.md +143 -0
  9. package/dist/SKILL-gxd45g38.md +553 -0
  10. package/dist/SKILL-rec41991.md +66 -0
  11. package/dist/SKILL-zze8zj5g.md +536 -0
  12. package/dist/cli.js +24658 -24654
  13. package/dist/index.js +492 -463
  14. package/dist/opencode-ci-qrcv7a99.md +106 -0
  15. package/dist/opencode-ci-rdpcc7xc.md +106 -0
  16. package/dist/opencode-ci-yt0k74t0.md +106 -0
  17. package/dist/workflow-andv2dvm.yml +158 -0
  18. package/package.json +1 -1
  19. package/prompts/default/PROVENANCE.md +1 -0
  20. package/skills/crysk/SKILL.md +6 -6
  21. package/skills/crysk-ci-setup/SKILL.md +32 -33
  22. package/skills/crysk-ci-setup/assets/workflow.yml +5 -10
  23. package/skills/crysk-ci-setup/references/ci-admission.md +5 -5
  24. package/skills/crysk-ci-setup/references/opencode-ci.md +6 -6
  25. package/skills/crysk-loop/SKILL.md +37 -54
  26. package/skills/crysk-pr/SKILL.md +1 -1
  27. package/src/asset-manifest.ts +0 -6
  28. package/src/assets.ts +1 -4
  29. package/src/brand.ts +20 -30
  30. package/src/ci/gates.ts +155 -201
  31. package/src/ci/outcome.ts +4 -31
  32. package/src/ci/platform-limits.ts +135 -0
  33. package/src/ci/platform-report.ts +212 -126
  34. package/src/ci/platform.ts +28 -26
  35. package/src/ci/reporter.ts +25 -26
  36. package/src/ci/review-admission.ts +1 -2
  37. package/src/ci/review-levels.ts +12 -53
  38. package/src/ci/setup.ts +96 -66
  39. package/src/ci/trace-bundle.ts +11 -27
  40. package/src/ci/trace-transcripts.ts +4 -6
  41. package/src/ci/trigger.ts +3 -5
  42. package/src/cli.ts +6 -5
  43. package/src/commands/ci-setup-questions.ts +2 -55
  44. package/src/commands/ci-setup.ts +2 -26
  45. package/src/commands/triage.ts +131 -38
  46. package/src/commands/usage.ts +0 -1
  47. package/src/compare/compare.ts +3 -3
  48. package/src/compare/floor-test.ts +30 -201
  49. package/src/config/config.ts +6 -30
  50. package/src/diversity/accounting.ts +0 -26
  51. package/src/diversity/benchmark.ts +1 -17
  52. package/src/diversity/identity.ts +0 -14
  53. package/src/diversity/pipeline-integration.ts +0 -29
  54. package/src/doctor.ts +3 -6
  55. package/src/execution/claude-session-trace.ts +7 -2
  56. package/src/execution/contracts.ts +15 -9
  57. package/src/execution/harness.ts +165 -187
  58. package/src/execution/spend-limiter.ts +39 -131
  59. package/src/execution/usage-facts.ts +397 -0
  60. package/src/execution/usage-normalized.ts +33 -86
  61. package/src/harness/materiality-judge.ts +0 -5
  62. package/src/harness/pipeline-plan.ts +0 -3
  63. package/src/harness/replay-rows.ts +0 -5
  64. package/src/harness/route-runner.ts +2 -2
  65. package/src/harness/single-step.ts +3 -9
  66. package/src/index.ts +1 -1
  67. package/src/mcp/preflight.ts +2 -2
  68. package/src/model/catalog.ts +1 -3
  69. package/src/model/free-discovery.ts +11 -78
  70. package/src/model/model-name.ts +14 -4
  71. package/src/model/profiles/claude.ts +1 -2
  72. package/src/model/profiles/openai.ts +1 -2
  73. package/src/model/profiles.ts +1 -2
  74. package/src/model/provider-capabilities.ts +16 -55
  75. package/src/model/routing.ts +39 -36
  76. package/src/pr/admission.ts +6 -6
  77. package/src/pr/answered-findings.ts +8 -4
  78. package/src/pr/ci-publish.ts +0 -2
  79. package/src/pr/discovery.ts +4 -25
  80. package/src/pr/plan.ts +40 -121
  81. package/src/pr/pr-status.ts +14 -2
  82. package/src/pr/preflight.ts +15 -12
  83. package/src/pr/publish-outcome.ts +1 -19
  84. package/src/pr/review-pr.ts +10 -47
  85. package/src/pr/target.ts +76 -82
  86. package/src/production-runtime.ts +52 -114
  87. package/src/progress.ts +0 -54
  88. package/src/rereview/prepare.ts +4 -1
  89. package/src/rereview/state.ts +1 -1
  90. package/src/review/boundary.ts +4 -8
  91. package/src/review/drafts.ts +3 -3
  92. package/src/review/findings-conformance.ts +1 -1
  93. package/src/review/findings.ts +0 -4
  94. package/src/review/pipeline.ts +57 -395
  95. package/src/review/preflight.ts +162 -201
  96. package/src/review/prompt-set.ts +0 -2
  97. package/src/review/report.ts +2 -162
  98. package/src/review/review.ts +16 -65
  99. package/src/review/route-preflight.ts +3 -35
  100. package/src/review/run.ts +37 -73
  101. package/src/review/size-gate.ts +3 -3
  102. package/src/review/spec.ts +6 -11
  103. package/src/review/step-runner.ts +4 -4
  104. package/src/runner-authority.ts +10 -9
  105. package/src/security/credential-broker.ts +5 -6
  106. package/src/server/preflight.ts +0 -1
  107. package/src/server/server.ts +17 -6
  108. package/src/store/activity.ts +1 -2
  109. package/src/store/backfill-preflight.ts +0 -3
  110. package/src/store/backfill.ts +0 -1
  111. package/src/store/metrics-preflight.ts +4 -14
  112. package/src/store/metrics.ts +5 -5
  113. package/src/store/preflight.ts +0 -13
  114. package/src/store/store.ts +11 -12
  115. package/src/transport-registry.ts +6 -30
  116. package/src/transports/claude-code-cli.ts +149 -215
  117. package/src/transports/opencode-client.ts +4 -24
  118. package/src/transports/opencode-sdk.ts +17 -112
  119. package/src/triage/plain-reply.ts +37 -0
  120. package/src/ui/activity.ts +1 -6
  121. package/src/ui/config-edit.ts +14 -67
  122. package/src/ui/config.ts +3 -8
  123. package/src/ui/plan.ts +11 -198
  124. package/src/ui/progress.ts +3 -49
  125. package/src/ui/result.ts +18 -77
  126. package/src/ui/review-menu.ts +3 -12
  127. package/src/ui/select.ts +9 -79
  128. package/src/updater.ts +1 -1
  129. package/src/usage.ts +1 -7
  130. package/prompts/default/deep-review-parity.md +0 -152
  131. package/prompts/scout.md +0 -140
  132. package/src/ci/platform-estimate.ts +0 -111
  133. package/src/review/scout.ts +0 -323
package/src/pr/target.ts CHANGED
@@ -19,17 +19,17 @@
19
19
  import { existsSync } from "node:fs";
20
20
  import os from "node:os";
21
21
  import {
22
- budgetDisabledWarningMessage,
23
- budgetUnlimitedNoticeMessage,
22
+ type CiBillingMode,
24
23
  type CiSizeLimits,
25
24
  deriveCiBillingMode,
26
- resolveCiBudgetCeiling,
25
+ type ModelRoleBilling,
27
26
  resolveCiSizeLimits,
28
27
  sizeGateUnlimitedNoticeMessage,
29
28
  } from "#ci/gates";
30
29
  import { formatWorkflowCommand } from "#ci/reporter";
31
- import { openCodeRoutesBillMetered } from "#ci/setup";
30
+ import { modelRoleBilling, openCodeRoutesBillMetered } from "#ci/setup";
32
31
  import { resolveRepoRoot } from "#git/git";
32
+ import { planRoutes, type ResolvedRoutePlan } from "#model/routing";
33
33
  import { ghCurrentBranchPr, ghPrView } from "#pr/pr";
34
34
  import {
35
35
  type PrTarget,
@@ -44,9 +44,9 @@ import {
44
44
  type CliOptions,
45
45
  isCiEnvironment,
46
46
  type NumstatFile,
47
+ resolveMaterialityGate,
47
48
  } from "#review/preflight";
48
49
  import type { ParsedAgent, PromptSetIdentity } from "#review/prompt-set";
49
- import type { estimateCost } from "#review/report";
50
50
  import { buildCliRoutePlan, isBundledAgentsDir } from "#review/route-preflight";
51
51
  import {
52
52
  type LoadedRunConfig,
@@ -113,16 +113,14 @@ export async function resolvePrRunOptions(
113
113
  // yet at this point, and a `.crysk/config.json` committed by the PR author
114
114
  // must stay unread (O-8). Same loader as local mode, so the two modes
115
115
  // cannot drift on precedence.
116
- const { loaded, config, summary, scout, post, profile } = await loadRunConfig(
117
- {
118
- root: operatorRoot,
119
- home,
120
- configFlag: options.config,
121
- options,
122
- },
123
- );
116
+ const { loaded, config, summary, post, profile } = await loadRunConfig({
117
+ root: operatorRoot,
118
+ home,
119
+ configFlag: options.config,
120
+ options,
121
+ });
124
122
  // ROADMAP Pillar 3 (GitHub Actions CI). isCi folds in HERE, alongside
125
- // scout/post, so `options.yes` carries the headless bypass (spec 2.1:
123
+ // post, so `options.yes` carries the headless bypass (spec 2.1:
126
124
  // "MUST run headlessly ... equivalent to --yes") through every downstream
127
125
  // read of `options.yes` in one move — the confirm gate, the in-flight
128
126
  // TOCTOU check (`if (options.yes) return 0` is the correct CI answer to a
@@ -137,7 +135,7 @@ export async function resolvePrRunOptions(
137
135
  prNumber,
138
136
  home,
139
137
  isCi,
140
- options: { ...options, scout, post, yes: options.yes || isCi },
138
+ options: { ...options, post, yes: options.yes || isCi },
141
139
  loaded,
142
140
  config,
143
141
  summary,
@@ -146,7 +144,13 @@ export async function resolvePrRunOptions(
146
144
  }
147
145
 
148
146
  export interface ResolvedPrPromptSet {
149
- ciBudgetCeiling: ReturnType<typeof resolveCiBudgetCeiling>;
147
+ // How the run bills (the engine's own answer: the platform cannot see it).
148
+ // The CI limits gate reads it (src/pr/plan.ts); the size limits resolve from it.
149
+ ciBillingMode: CiBillingMode;
150
+ // Which of the run's model roles bill an API key, for the limits gate's
151
+ // comparison of a mixed setup (S17). Undefined when the routes could not be
152
+ // resolved here: the gate then compares the whole estimate.
153
+ ciRoleBilling: ModelRoleBilling | undefined;
150
154
  ciSizeLimits: CiSizeLimits | undefined;
151
155
  agents: AgentsDirResolution;
152
156
  spec: ReviewSpec;
@@ -156,30 +160,33 @@ export interface ResolvedPrPromptSet {
156
160
  gotchasPath: string | undefined;
157
161
  }
158
162
 
159
- // The OpenCode providers of every route the run resolves, fallbacks included,
160
- // from the same plan builder the run confirms with (buildCliRoutePlan), so each
161
- // source routing reads counts the way routing reads it. Undefined when the plan
162
- // cannot be built here; the run itself surfaces that error at confirm.
163
- async function openCodeRouteProviders(
163
+ // The run's route plan, fallbacks included, from the same plan builder the run
164
+ // confirms with (buildCliRoutePlan), so each source routing reads counts the way
165
+ // routing reads it. Undefined when the plan cannot be built here; the run itself
166
+ // surfaces that error at confirm.
167
+ async function resolveRoutePlanForBilling(
164
168
  input: Parameters<typeof buildCliRoutePlan>[0],
165
- ): Promise<string[] | undefined> {
166
- let plan: Awaited<ReturnType<typeof buildCliRoutePlan>>;
169
+ ): Promise<ResolvedRoutePlan | undefined> {
167
170
  try {
168
- plan = await buildCliRoutePlan(input);
171
+ return await buildCliRoutePlan(input);
169
172
  } catch {
170
173
  return undefined;
171
174
  }
175
+ }
176
+
177
+ // The OpenCode providers of every route of the plan, fallbacks included.
178
+ function openCodeRouteProviders(
179
+ plan: ResolvedRoutePlan | undefined,
180
+ ): string[] | undefined {
181
+ if (plan === undefined) return undefined;
172
182
  const providers = new Set<string>();
173
- for (const step of plan.steps) {
174
- for (const route of [step, ...(step.fallbacks ?? [])]) {
175
- if (route.route.backend === "opencode")
176
- providers.add(route.route.provider);
177
- }
183
+ for (const route of planRoutes(plan)) {
184
+ if (route.route.backend === "opencode") providers.add(route.route.provider);
178
185
  }
179
186
  return [...providers].sort();
180
187
  }
181
188
 
182
- // Step 1's second half: the CI budget ceiling (+ its notices), then the
189
+ // Step 1's second half: how the run bills, then the
183
190
  // prompt set resolution and the gotchas PATH (never the validation itself —
184
191
  // see this module's header). Runs after the caller's own
185
192
  // `readLocalIgnoreRules(operatorRoot)` read, before its own
@@ -215,35 +222,41 @@ export async function resolvePrPromptSetAndBudget(params: {
215
222
  // invoices nothing for a run whose models do not bill per token. Not
216
223
  // envBillsMetered either: that predicate stamps Claude usage and must stay
217
224
  // Anthropic-env-only.
218
- const billingMode = deriveCiBillingMode(
219
- params.claudeRun?.env ?? process.env,
220
- {
221
- openCodeBillsMetered: openCodeRoutesBillMetered({
222
- providers: await openCodeRouteProviders({
223
- spec,
224
- options: params.options,
225
- agentFiles,
226
- bundledAgents: isBundledAgentsDir(agents),
227
- models: params.config.models,
228
- summary: params.summary,
229
- profile: params.profile,
230
- }),
231
- authFilePresent: existsSync(resolveOpenCodeAuthPath()),
232
- openCodeSecretNames: readOpenCodeSecretNames(),
233
- }),
234
- },
235
- );
236
- // Issue #156: resolve the ceiling ONCE, here, and use this same value at
237
- // the budget gate far below (src/pr/review-pr.ts's plan/confirm stage).
238
- // Resolving twice invites the announcement and the gate drifting apart.
239
- // Deliberately NOT folded back into `options.budgetUsd` — the metered
240
- // default is a CI-gate policy, and leaking a 10 that the operator never
241
- // typed into every other read of `options.budgetUsd` would make it look
242
- // configured.
243
- const ciBudgetCeiling = resolveCiBudgetCeiling({
244
- configured: params.options.budgetUsd,
245
- billingMode,
225
+ const routePlan = await resolveRoutePlanForBilling({
226
+ spec,
227
+ options: params.options,
228
+ agentFiles,
229
+ bundledAgents: isBundledAgentsDir(agents),
230
+ models: params.config.models,
231
+ summary: params.summary,
232
+ profile: params.profile,
233
+ // The judge step joins the run when the gate is on (plan.ts), so the plan
234
+ // that decides how the run bills must have it too (#551 R002). On, whatever
235
+ // a re-review later skips: counting a judge that may not run is the
236
+ // conservative side.
237
+ materialityEnabled: resolveMaterialityGate(params.config),
238
+ });
239
+ const claudeEnv = params.claudeRun?.env ?? process.env;
240
+ const authFilePresent = existsSync(resolveOpenCodeAuthPath());
241
+ const openCodeSecretNames = readOpenCodeSecretNames();
242
+ const billingMode = deriveCiBillingMode(claudeEnv, {
243
+ openCodeBillsMetered: openCodeRoutesBillMetered({
244
+ providers: openCodeRouteProviders(routePlan),
245
+ authFilePresent,
246
+ openCodeSecretNames,
247
+ }),
246
248
  });
249
+ // The same routes, per model role: the platform prices each role and the
250
+ // limits gate compares the ones billed on an API key (S17).
251
+ const ciRoleBilling = modelRoleBilling({
252
+ plan: routePlan,
253
+ agents: spec.agents,
254
+ claudeEnv,
255
+ authFilePresent,
256
+ openCodeSecretNames,
257
+ });
258
+ // Resolved ONCE, here: the size limits below and the platform limits gate
259
+ // far below (src/pr/plan.ts's plan/confirm stage) read this same value.
247
260
  // The size gate's half of the same route policy (ci/gates.ts,
248
261
  // resolveCiSizeLimits). CI only: a local or watcher run keeps reading the
249
262
  // flags and the repo config exactly as before.
@@ -254,25 +267,9 @@ export async function resolvePrPromptSetAndBudget(params: {
254
267
  billingMode,
255
268
  })
256
269
  : undefined;
257
- // Spec 3.1: a silent disable is indistinguishable from a passing gate, so
258
- // an EXPLICIT `--budget-usd <= 0` warns even though it never skips a run.
259
- // Emitted here (once, as soon as isCi/budgetUsd are both known) rather
260
- // than beside the budget-gate check far below, which only runs at all when
261
- // there IS an estimate to compare against. The subscription notice rides
262
- // the same reasoning and the same placement, one register quieter: a
263
- // resolved no-ceiling is not an operator mistake, but it is still a gate
264
- // that did not run, and this repo does not ship those silently.
270
+ // A gate that did not run is still announced: the size gate's notice for a
271
+ // route where its limits resolved to off.
265
272
  if (params.isCi) {
266
- const disabledWarning = budgetDisabledWarningMessage(
267
- ciBudgetCeiling.budgetUsd,
268
- );
269
- if (disabledWarning !== null) {
270
- log(formatWorkflowCommand("warning", disabledWarning));
271
- }
272
- const unlimitedNotice = budgetUnlimitedNoticeMessage(ciBudgetCeiling);
273
- if (unlimitedNotice !== null) {
274
- log(formatWorkflowCommand("notice", unlimitedNotice));
275
- }
276
273
  if (ciSizeLimits !== undefined) {
277
274
  const sizeNotice = sizeGateUnlimitedNoticeMessage(ciSizeLimits);
278
275
  if (sizeNotice !== null) {
@@ -295,7 +292,8 @@ export async function resolvePrPromptSetAndBudget(params: {
295
292
  }
296
293
  const gotchasPath = instructions.path;
297
294
  return {
298
- ciBudgetCeiling,
295
+ ciBillingMode: billingMode,
296
+ ciRoleBilling,
299
297
  ciSizeLimits,
300
298
  agents,
301
299
  spec,
@@ -381,7 +379,7 @@ export async function resolvePrTargetRecord(params: {
381
379
 
382
380
  // Step 3's second half: the free dry-run exit's size-gate verdict, plan
383
381
  // card, and closing lines. Relocated out of reviewPr()'s `if (options.dryRun)`
384
- // block; the FIRST half of that block (hunterCount/estimate/dryRunGateConfig,
382
+ // block; the FIRST half of that block (dryRunGateConfig,
385
383
  // then the `resolvePrDryRunNumstat` call just above) stays inline in
386
384
  // reviewPr(), unchanged. This half picks up right after `perFile` is known
387
385
  // and returns the dry run's exit code (always 0).
@@ -400,8 +398,6 @@ export function renderPrDryRunPlan(params: {
400
398
  summary: LoadedRunConfig["summary"];
401
399
  loaded: LoadedRunConfig["loaded"];
402
400
  isCi: boolean;
403
- hunterCount: number;
404
- estimate: ReturnType<typeof estimateCost>;
405
401
  dryRunGateConfig: SizeGateConfig;
406
402
  perFile: NumstatFile[] | null;
407
403
  }): number {
@@ -441,8 +437,6 @@ export function renderPrDryRunPlan(params: {
441
437
  spec: params.spec,
442
438
  config: params.config,
443
439
  summary: params.summary,
444
- estimate: params.estimate,
445
- hunterCount: params.hunterCount,
446
440
  sizeGate: estimated,
447
441
  sizeGateNote,
448
442
  droppedPaths: [],
@@ -382,16 +382,12 @@ class FrozenRuntimeBinding implements RuntimeBinding {
382
382
  !report.issues.some(
383
383
  (issue) => issue.code === "real_sdk_adapter_deferred_to_d1_11",
384
384
  );
385
- // #133. ONE effective billing mode, computed once and fed to all THREE
386
- // readers below (`pricingApplicable`, `billingMode`,
387
- // `cashCostAccountingValid`). They used to read `report.billing.mode`
388
- // independently, and that is precisely the trap: upgrading only
389
- // `billingMode` would leave `pricingApplicability` at "not_applicable",
390
- // the pricing gate would never fire, and a metered route would be
391
- // admitted as priced-not-required — executing on real spend while
392
- // reporting `cashCostUsd: 0`. Under-reporting is the failure this whole
393
- // issue exists to prevent, so the correction has to be applied ONCE,
394
- // upstream of every consumer, not per-expression.
385
+ // #133. ONE effective billing mode, computed once and fed to BOTH readers
386
+ // below (`billingMode`, `modeKnown`). They used to read
387
+ // `report.billing.mode` independently, and that is precisely the trap:
388
+ // upgrading only one would leave the other reporting a metered route as
389
+ // something it is not. The correction has to be applied ONCE, upstream of
390
+ // every consumer, not per-expression.
395
391
  //
396
392
  // The legacy backend-wide report cannot know this: it is produced before
397
393
  // any route resolves, so it cannot see the provider. The credential KIND
@@ -412,63 +408,23 @@ class FrozenRuntimeBinding implements RuntimeBinding {
412
408
  credentialKindBillsMetered(this.credential.kind)
413
409
  ? "metered"
414
410
  : report.billing.mode;
415
- const pricingApplicable =
416
- effectiveBillingMode === "metered" ? "required" : "not_applicable";
417
411
  // The legacy report carries THREE billing modes (subscription | metered |
418
412
  // unknown) and the exact contract carries two, so `unknown` narrows into
419
413
  // "subscription" here. WHY that narrowing is not a lie: it is sound ONLY
420
- // because `cashCostAccountingValid` below reads the three-state
421
- // `effectiveBillingMode` and independently blocks `unknown` — the design
422
- // doc makes `billingMode: "unknown"` a blocking preflight result
423
- // (docs/multi-runtime-model-diversity-design.md:461), and the pricing
424
- // gate cannot enforce it because `unknown` is not `metered`, leaving
425
- // pricingApplicability at "not_applicable". Delete or weaken the
426
- // cash-cost derivation and this narrowing silently starts claiming that
427
- // an unknown-billing route bills like a subscription.
414
+ // because `modeKnown` below reads the three-state `effectiveBillingMode`
415
+ // and independently blocks `unknown` — the design doc makes
416
+ // `billingMode: "unknown"` a blocking preflight result
417
+ // (docs/multi-runtime-model-diversity-design.md:461): the platform prices
418
+ // a run by the credential class the engine reports, and an unknown class
419
+ // cannot be reported. Delete or weaken that derivation and this narrowing
420
+ // silently starts claiming that an unknown-billing route bills like a
421
+ // subscription.
428
422
  //
429
423
  // #133 keeps that intact: the effective mode only ever REPLACES `unknown`
430
- // with `metered`, and a metered route is caught by the pricing gate
431
- // instead. Nothing reaches "subscription" that did not already.
424
+ // with `metered`. Nothing reaches "subscription" that did not already.
432
425
  const billingMode: ExactBindingCapabilityReport["billing"]["mode"] =
433
426
  effectiveBillingMode === "metered" ? "metered" : "subscription";
434
- // #197. ONE source, and it is the transport's own claim. This used to be
435
- // a disjunction — the transport's `pricingReady` OR a bundled per-model
436
- // rate table selected by `this.route.provider` — and the table half is
437
- // deleted, along with the loader, the 90-day freshness window and the
438
- // `config/models/*-pricing.json` files behind it.
439
- //
440
- // WHY the table lost, given the design line (§8 line 461) names "provider
441
- // cost or a versioned rate table": our table was a hand-transcribed
442
- // snapshot of the same published LIST prices the transports report, and
443
- // it aged on our release cadence rather than the tool's. It expired after
444
- // 90 days and REFUSED the route it was meant to enable, it covered only
445
- // what someone remembered to transcribe (the zai table priced 11 of the
446
- // 16 models `opencode models` reports, five days after it landed), and a
447
- // new model was absent until noticed. The transports report a live figure
448
- // for whatever they actually ran.
449
- //
450
- // Both backends now answer for themselves: OpenCode reads a non-optional
451
- // `cost` off every assistant message, and the Claude CLI reports
452
- // `total_cost_usd` (#197 flipped that flag). A transport that reports NO
453
- // cost is refused — which is the gate's whole purpose, unchanged: refuse
454
- // to bill an unknown amount. What moved is where the unknown is answered.
455
- // A missing figure is now caught at SETTLEMENT, where the answer is
456
- // actually known (`settlementFromUsage`, spend-limiter.ts: complete usage
457
- // with no cash cost settles `unresolved`, never 0), instead of being
458
- // guessed at admission from a table that might be stale.
459
- const tokenPricingAvailable = report.billing.pricingReady;
460
- // Spec (same design line): subscription OAuth may truthfully report
461
- // `cashCostUsd: 0`; metered routes require a cost source; unknown is
462
- // blocking. Read off `tokenPricingAvailable` rather than the raw flag so
463
- // the two cannot drift — a metered report claiming
464
- // priced-but-not-accountable is self-contradictory and would strand the
465
- // route in a gate that no longer has a reason to refuse it.
466
- const cashCostAccountingValid =
467
- effectiveBillingMode === "subscription"
468
- ? true
469
- : effectiveBillingMode === "metered"
470
- ? tokenPricingAvailable
471
- : false;
427
+ const modeKnown = effectiveBillingMode !== "unknown";
472
428
  return {
473
429
  routeKey: this.key,
474
430
  backend: this.route.backend,
@@ -513,9 +469,7 @@ class FrozenRuntimeBinding implements RuntimeBinding {
513
469
  usage: { normalized: true },
514
470
  billing: {
515
471
  mode: billingMode,
516
- pricingApplicability: pricingApplicable,
517
- tokenPricingAvailable,
518
- cashCostAccountingValid,
472
+ modeKnown,
519
473
  },
520
474
  };
521
475
  }
@@ -548,9 +502,8 @@ class FrozenRuntimeBinding implements RuntimeBinding {
548
502
  // that supplies no registry — so the public `createProductionRuntime`,
549
503
  // which accepts an arbitrary `options.registry`, bypassed it entirely
550
504
  // and the factory silently fell back to "subscription" on a metered
551
- // route. That stamp is what `settlementFromUsage`'s metered-zero rule
552
- // keys on, so the fallback made the rule DEAD: an unaccountable
553
- // provider $0 settled as a truthful cost instead of fencing the bucket.
505
+ // route. That stamp is the credential class the platform prices the run
506
+ // by, so the fallback filed a metered route's usage as subscription.
554
507
  // (`collectDoctorExactBindingReports` supplies its own kind-less
555
508
  // registry too, but it only ever calls `capabilities()` — no attempt,
556
509
  // so no usage record, so nothing there could observe the divergence.
@@ -647,7 +600,7 @@ function bindingBucketId(
647
600
  // this binding otherwise authenticates with — those are two different
648
601
  // credentials that happen to share one route. Fencing the subscription
649
602
  // bucket here would block the next NON-degraded subscription attempt on
650
- // this same route over dollars the OAuth credential never spent (and would
603
+ // this same route over usage the OAuth credential never made (and would
651
604
  // widen the harness's own reservesSpend=false invariant: "a subscription
652
605
  // binding reserves nothing" — production-runtime.test.ts). Fencing this
653
606
  // mirrored bucket instead lands on the SAME identity a real metered
@@ -1038,9 +991,6 @@ export function d1_11EvidenceFromExactBinding(
1038
991
  credentialAuthority:
1039
992
  report.auth.projectionReady || report.auth.probe === "passed",
1040
993
  workspaceBroker: report.isolation.workspaceReadBroker,
1041
- pricingReady:
1042
- report.billing.pricingApplicability !== "required" ||
1043
- report.billing.tokenPricingAvailable,
1044
994
  };
1045
995
  }
1046
996
 
@@ -1185,7 +1135,7 @@ async function openCodeFreeVerdicts(
1185
1135
  // send, fallbacks included, is checked against the variants OpenCode lists for
1186
1136
  // that model before the run starts, and refused by name: an unknown variant,
1187
1137
  // a model with no variants, and a listing that could not be read all stop the
1188
- // review here, before the cost confirmation. A plan sending no variant (no
1138
+ // review here, before the plan confirmation. A plan sending no variant (no
1189
1139
  // OpenCode entry sets an effort, D1) checks nothing and spawns nothing.
1190
1140
  //
1191
1141
  // The listing is `opencode models <provider> --verbose --refresh`, the same
@@ -1561,7 +1511,7 @@ export async function prepareProductionAdmissionContext(input: {
1561
1511
  return { error: credentialRefusal.message, credentialRefusal };
1562
1512
  }
1563
1513
  }
1564
- // S7: after the credential check, before the bindings and the cost
1514
+ // S7: after the credential check, before the bindings and the plan
1565
1515
  // confirmation. The probe is built only when a route sends a variant, so a plan
1566
1516
  // without one spawns nothing new.
1567
1517
  const sendsVariant = planRoutes(input.plan).some(
@@ -1686,7 +1636,6 @@ export async function prepareProductionAdmissionContext(input: {
1686
1636
  credentialAuthority:
1687
1637
  combined.credentialAuthority && next.credentialAuthority,
1688
1638
  workspaceBroker: combined.workspaceBroker && next.workspaceBroker,
1689
- pricingReady: combined.pricingReady && next.pricingReady,
1690
1639
  };
1691
1640
  }
1692
1641
  if (combined !== undefined) evidence.set("opencode", combined);
@@ -1962,49 +1911,47 @@ export class MultiProviderRunner implements StepRunner {
1962
1911
  // 2026-09-02. WHICH steps reserve into the run's ledger: metered ones
1963
1912
  // only, read off the report the gate above just admitted rather than
1964
1913
  // re-derived from `binding.credential.kind`. One derivation of one fact —
1965
- // the same `effectiveBillingMode` #133 computes once and feeds to all
1966
- // three billing readers — so the fact that decided admission is the fact
1967
- // that decides reservation.
1914
+ // the same `effectiveBillingMode` #133 computes once and feeds to both
1915
+ // billing readers — so the fact that decided admission is the fact that
1916
+ // decides reservation.
1968
1917
  //
1969
1918
  // WHY not every step. The ledger's guarantee is "an unresolved bucket
1970
1919
  // blocks the next paid attempt", and `finalizeReservation` reaches it on
1971
- // more than the metered-zero rule: partial usage, unavailable usage (an
1920
+ // usage the engine could not confirm: partial usage, unavailable usage (an
1972
1921
  // OpenCode attempt where no usage event ever arrived, and ANY backend's
1973
1922
  // harness watchdog timeout, which normalizes to unavailable), and an
1974
1923
  // attempt that comes back `cancelled`. Any one of those fences the bucket
1975
1924
  // for the rest of the ledger's life.
1976
1925
  //
1977
- // On a metered bucket that is exactly right and fail-closed: we do not
1978
- // know what we spent, so we stop spending. On a SUBSCRIPTION bucket it
1979
- // would refuse later steps over dollars that cannot be spent — and it
1980
- // would do so against a pipeline built to survive exactly this. Hunters
1981
- // run under `Promise.allSettled` and `runPipeline` tolerates a lost
1982
- // hunter (`hunterFailures`, failing the run only when ALL of them fail),
1983
- // so one hunter whose stdout would not parse would fence the credential
1984
- // and take the refuter down with it. That trades a degraded run for a
1985
- // dead one, buying nothing, on the one backend that demonstrably works
1986
- // today.
1926
+ // On a metered bucket that is exactly right and fail-closed: the engine
1927
+ // cannot report what the attempt used, so it stops using that credential.
1928
+ // On a SUBSCRIPTION bucket it would refuse later steps over usage that
1929
+ // cannot be charged — and it would do so against a pipeline built to
1930
+ // survive exactly this. Hunters run under `Promise.allSettled` and
1931
+ // `runPipeline` tolerates a lost hunter (`hunterFailures`, failing the run
1932
+ // only when ALL of them fail), so one hunter whose stdout would not parse
1933
+ // would fence the credential and take the refuter down with it. That
1934
+ // trades a degraded run for a dead one, buying nothing, on the one backend
1935
+ // that demonstrably works today.
1987
1936
  //
1988
1937
  // Same reasoning keeps `ClaudeCodeRunner` (step-runner.ts) ledger-free:
1989
1938
  // claude-code resolves to `claude_subscription_oauth` for every provider
1990
- // (`credentialKindForRoute`), so the metered-zero rule structurally cannot
1991
- // fire there. A ledger on that path is a state machine with no guarantee
1992
- // to enforce. The known limitation, deliberately not addressed here: a
1993
- // claude-code run under a real `ANTHROPIC_API_KEY` does spend money, but
1994
- // the engine models that backend as subscription on purpose — ci/gates.ts
1995
- // documents why deriving it instead is an ADMISSION hazard, and
1996
- // `resolveCiBudgetCeiling` is where that case is handled.
1939
+ // (`credentialKindForRoute`). A ledger on that path is a state machine
1940
+ // with no guarantee to enforce. The known limitation, deliberately not
1941
+ // addressed here: a claude-code run under a real `ANTHROPIC_API_KEY` is
1942
+ // billed per token, but the engine models that backend as subscription on
1943
+ // purpose — ci/gates.ts documents why deriving it instead is an ADMISSION
1944
+ // hazard.
1997
1945
  //
1998
1946
  // 2026-09-02, #177: one clause of that paragraph is no longer true and the
1999
1947
  // correction matters. Its usage RECORDS are no longer "truthfully
2000
1948
  // subscription" on every route — the Claude CLI transport now stamps
2001
1949
  // `metered` when the projected child env carries ANTHROPIC_API_KEY or
2002
- // ANTHROPIC_AUTH_TOKEN, so the run's real spend reaches `cashCostUsd`
2003
- // instead of being filed as an uncharged list price. This line is
2004
- // deliberately unchanged: it reads the CAPABILITY REPORT, not the usage
2005
- // record, so no reservation is opened, nothing is fenced, and no API-key
2006
- // route loses admission. The record is honest; the gate stays where #161
2007
- // must move it.
1950
+ // ANTHROPIC_AUTH_TOKEN, so the platform sees that run as a per-token
1951
+ // credential. This line is deliberately unchanged: it reads the CAPABILITY
1952
+ // REPORT, not the usage record, so no reservation is opened, nothing is
1953
+ // fenced, and no API-key route loses admission. The record is honest; the
1954
+ // gate stays where #161 must move it.
2008
1955
  //
2009
1956
  // A claude-only run therefore records no reservations at all, and the
2010
1957
  // absent `reservations` key on those steps is the truthful signal — not a
@@ -2012,14 +1959,11 @@ export class MultiProviderRunner implements StepRunner {
2012
1959
  //
2013
1960
  // #182 follow-up: free OpenCode bindings reserve too — read off the
2014
1961
  // credential KIND, not the report (which still says subscription for free
2015
- // routes: capability `BillingMode` stays binary on purpose). Without a
2016
- // reservation `finalizeReservation` never runs, the free-nonzero rule
2017
- // (spend-limiter.ts) would be dead in production, and a flipped model
2018
- // would keep spending attempts instead of fencing the bucket and failing
2019
- // closed. A free step that stays free settles 0 and never fences, so the
2020
- // subscription reasoning above ("refusing later steps over dollars that
2021
- // cannot be spent") does not apply: only a priced flip, partial usage, or
2022
- // unavailable usage fences a free bucket.
1962
+ // routes: capability `BillingMode` stays binary on purpose). A free route
1963
+ // whose usage the engine could not confirm is not provably still free, so
1964
+ // it fences the bucket like a metered one instead of spending further
1965
+ // attempts on it. A free step whose usage is complete settles and never
1966
+ // fences.
2023
1967
  const reservesSpend =
2024
1968
  capabilityReport.billing.mode === "metered" ||
2025
1969
  binding.credential.kind === "provider_free";
@@ -2061,12 +2005,6 @@ export class MultiProviderRunner implements StepRunner {
2061
2005
  // fence lands on the credential that could not account for its spend
2062
2006
  // and leaves every other route admissible.
2063
2007
  //
2064
- // `reservedUsdPerAttempt` is deliberately left at the harness default
2065
- // of 0 rather than given an invented number: `reservedUsd` is
2066
- // RECORDED on the reservation and read by no gate anywhere — the
2067
- // fence keys on `fencedBuckets`, never on an amount — so a figure
2068
- // here would be a budget nobody has decided, dressed as one that was.
2069
- //
2070
2008
  // #279: `spendLedger` is now handed to EVERY binding — see the WHY
2071
2009
  // just above `isolation` — with `reservesSpend` carrying the
2072
2010
  // per-binding decision the conditional spread used to encode. A
package/src/progress.ts CHANGED
@@ -53,18 +53,6 @@ interface PanelHunter {
53
53
  failureReason?: string;
54
54
  }
55
55
 
56
- // The scout is the one stage with a real STARTED event, because it is the one
57
- // that runs alone: it is awaited before the hunters spawn, and M4 measured it
58
- // at 86-600s. Without a row of its own the panel shows four hunters "waiting"
59
- // for up to ten minutes and explains nothing — the silence that once cost a
60
- // paid run to a reasonable Ctrl-C.
61
- interface PanelScout {
62
- status: "running" | "done" | "failed";
63
- durationMs?: number;
64
- model?: string;
65
- leads?: number;
66
- }
67
-
68
56
  interface PanelSummarizer {
69
57
  // The summarizer starts with the pipeline, but it has no separate started
70
58
  // event. Seeding it as running keeps the first frame truthful.
@@ -94,10 +82,6 @@ export interface PanelState {
94
82
  // own elapsed, not the panel's.
95
83
  huntersStartedAtMs?: number;
96
84
  hunters: PanelHunter[];
97
- // Absent until the scout-started event arrives — unlike the summarizer,
98
- // which is seeded, because a run with no scout must show no scout row and
99
- // the caller's flag is not the panel's business.
100
- scout?: PanelScout;
101
85
  // Cosmetic only: the pipeline owns summary semantics and run status.
102
86
  // Absent means the summary step was disabled for this run.
103
87
  summarizer?: PanelSummarizer;
@@ -207,20 +191,6 @@ export function applyProgressEvent(
207
191
  case "verify-started":
208
192
  case "verify-step-finished":
209
193
  return;
210
- case "scout-started": {
211
- state.scout = { status: "running", model: event.model };
212
- return;
213
- }
214
- case "scout-finished": {
215
- // Tolerant of a finish with no start: the construction-failure path
216
- // emits only the finish, and a panel that threw there would take the
217
- // run down with it.
218
- state.scout ??= { status: "running" };
219
- state.scout.status = event.ok ? "done" : "failed";
220
- state.scout.durationMs = event.durationMs;
221
- if (event.leads !== undefined) state.scout.leads = event.leads;
222
- return;
223
- }
224
194
  case "summarizer-finished": {
225
195
  if (!state.summarizer) return;
226
196
  state.summarizer.status = event.ok ? "done" : "failed";
@@ -374,26 +344,6 @@ function refuterNode(
374
344
  };
375
345
  }
376
346
 
377
- function scoutNode(
378
- scout: PanelScout,
379
- state: PanelState,
380
- nowMs: number,
381
- labelWidth: number,
382
- ): TreeNode {
383
- const detail =
384
- scout.status === "running"
385
- ? `reading the diff — ${formatElapsed(nowMs - state.startedAtMs)}`
386
- : scout.status === "done"
387
- ? `${scout.leads ?? 0} lead${scout.leads === 1 ? "" : "s"} — ` +
388
- formatElapsed(scout.durationMs ?? 0)
389
- : "failed — the hunters run unled";
390
- return {
391
- label: pad("scout", labelWidth),
392
- status: scout.status,
393
- detail,
394
- };
395
- }
396
-
397
347
  function summarizerNode(
398
348
  summarizer: PanelSummarizer,
399
349
  state: PanelState,
@@ -447,16 +397,12 @@ export function renderPanelLines(
447
397
  "dedupe".length,
448
398
  "refuter".length,
449
399
  state.summarizer === undefined ? 0 : "summarizer".length,
450
- state.scout === undefined ? 0 : "scout".length,
451
400
  );
452
401
  const modelWidth = Math.max(
453
402
  0,
454
403
  ...state.hunters.map((h) => h.model?.length ?? 0),
455
404
  );
456
- // FIRST, above the hunters: it ran before them, and a row below rows that
457
- // are waiting on it reads as the wrong order.
458
405
  const nodes: TreeNode[] = [];
459
- if (state.scout) nodes.push(scoutNode(state.scout, state, nowMs, labelWidth));
460
406
  nodes.push(
461
407
  ...state.hunters.map((hunter) =>
462
408
  hunterNode(hunter, state, nowMs, labelWidth, modelWidth),