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.
- package/README.md +28 -22
- package/dist/SKILL-1q3658n0.md +74 -0
- package/dist/SKILL-25j4q9b8.md +143 -0
- package/dist/SKILL-32cmme3j.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/adjudicator-eckqh14e.md +78 -0
- package/dist/ci-admission-qn797a6c.md +128 -0
- package/dist/cli.js +18608 -18523
- package/dist/consolidate-4xw1pkg7.md +24 -0
- package/dist/deep-review-logic-dgr112y1.md +196 -0
- package/dist/deep-review-logic-fck5z4xe.md +197 -0
- package/dist/deep-review-logic-h1fpamfh.md +192 -0
- package/dist/deep-review-logic-m4vk5683.md +196 -0
- package/dist/deep-review-logic-z63kmgmc.md +157 -0
- package/dist/deep-review-parity-7x7s5d81.md +148 -0
- package/dist/deep-review-parity-9wxmynsc.md +115 -0
- package/dist/deep-review-parity-bwwe7cx6.md +152 -0
- package/dist/deep-review-parity-e50pw3pk.md +117 -0
- package/dist/deep-review-parity-ennmm9m1.md +151 -0
- package/{prompts/default/deep-review-parity.md → dist/deep-review-parity-h7y6y2he.md} +14 -16
- package/dist/deep-review-parity-xg6wy69c.md +151 -0
- package/dist/deep-review-reliability-6h3c4gmw.md +125 -0
- package/dist/deep-review-reliability-dcjab69x.md +122 -0
- package/dist/deep-review-reliability-ec7b5pbk.md +159 -0
- package/dist/deep-review-reliability-hvasvmt9.md +153 -0
- package/dist/deep-review-reliability-mjnayxmt.md +158 -0
- package/dist/deep-review-reliability-mm7fnayf.md +124 -0
- package/dist/deep-review-reliability-xk4xvc2w.md +158 -0
- package/dist/deep-review-resilience-0esd5qeh.md +148 -0
- package/dist/deep-review-resilience-envgcmpy.md +115 -0
- package/dist/deep-review-resilience-fgx8ythf.md +151 -0
- package/dist/deep-review-resilience-mq5qa6ad.md +152 -0
- package/dist/deep-review-resilience-pwh1gawp.md +151 -0
- package/dist/deep-review-resilience-s9n21dkx.md +117 -0
- package/dist/deep-review-resilience-vz4qskea.md +119 -0
- package/dist/deep-review-security-1vwjdc9q.md +205 -0
- package/dist/deep-review-security-x1cc1z00.md +205 -0
- package/dist/index.js +590 -485
- package/dist/opencode-ci-jc8mf4wn.md +106 -0
- 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/review-refuter-7qffwtzz.md +77 -0
- package/dist/verifier-tyh8r45v.md +40 -0
- package/dist/verifier-xf4xj701.md +40 -0
- package/dist/workflow-andv2dvm.yml +158 -0
- package/package.json +1 -1
- package/prompts/consolidate.md +1 -1
- package/prompts/default/PROVENANCE.md +6 -0
- package/prompts/default/deep-review-logic.md +56 -15
- package/prompts/default/deep-review-reliability.md +64 -30
- package/prompts/default/deep-review-resilience.md +71 -37
- package/prompts/default/deep-review-security.md +205 -0
- package/prompts/default/review-refuter.md +1 -1
- package/prompts/verifier.md +40 -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-loop/adjudicator.md +10 -18
- package/skills/crysk-pr/SKILL.md +1 -1
- package/src/asset-manifest.ts +6 -6
- package/src/assets.ts +4 -4
- package/src/brand.ts +20 -30
- package/src/ci/gates.ts +155 -192
- 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/compare/hunter-exam.ts +631 -0
- 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 +16 -5
- package/src/model/profiles/claude.ts +1 -2
- package/src/model/profiles/openai.ts +1 -2
- package/src/model/profiles.ts +2 -3
- 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/pr.ts +1 -1
- package/src/pr/preflight.ts +44 -15
- package/src/pr/publish-outcome.ts +1 -19
- package/src/pr/review-pr.ts +15 -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/rereview/verify.ts +15 -9
- package/src/review/boundary.ts +5 -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 +194 -407
- package/src/review/preflight.ts +175 -201
- package/src/review/prompt-set.ts +1 -2
- package/src/review/report.ts +2 -162
- package/src/review/review.ts +25 -74
- package/src/review/route-preflight.ts +19 -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/scout.md +0 -140
- package/src/ci/platform-estimate.ts +0 -111
- package/src/review/scout.ts +0 -323
package/src/review/run.ts
CHANGED
|
@@ -16,14 +16,10 @@
|
|
|
16
16
|
|
|
17
17
|
import { existsSync } from "node:fs";
|
|
18
18
|
import path from "node:path";
|
|
19
|
-
import {
|
|
20
|
-
type EffectiveConfig,
|
|
21
|
-
loadEffectiveConfig,
|
|
22
|
-
notionalCostInput,
|
|
23
|
-
} from "#config/config";
|
|
19
|
+
import { type EffectiveConfig, loadEffectiveConfig } from "#config/config";
|
|
24
20
|
import type { ModelsConfig } from "#model/model-name";
|
|
25
21
|
import { type ModelProfile, resolveProfile } from "#model/profiles";
|
|
26
|
-
import type
|
|
22
|
+
import { type ResolvedRoutePlan, removedHunterRoles } from "#model/routing";
|
|
27
23
|
import type { CiMode } from "#pr/preflight";
|
|
28
24
|
import {
|
|
29
25
|
type FindingsDocument,
|
|
@@ -31,12 +27,7 @@ import {
|
|
|
31
27
|
type Telemetry,
|
|
32
28
|
writeFindings,
|
|
33
29
|
} from "#review/findings";
|
|
34
|
-
import {
|
|
35
|
-
changedPathsFromDiff,
|
|
36
|
-
type PipelineDeps,
|
|
37
|
-
type PipelineResult,
|
|
38
|
-
parityTriggered,
|
|
39
|
-
} from "#review/pipeline";
|
|
30
|
+
import type { PipelineDeps, PipelineResult } from "#review/pipeline";
|
|
40
31
|
import {
|
|
41
32
|
type AgentsDirResolution,
|
|
42
33
|
agentFilePath,
|
|
@@ -46,11 +37,11 @@ import {
|
|
|
46
37
|
gotchasUnusableReason,
|
|
47
38
|
type LocalConfig,
|
|
48
39
|
localReviewSpec,
|
|
40
|
+
PARITY_REMOVED,
|
|
49
41
|
parseNumstatFiles,
|
|
50
42
|
preflightAgentsDir,
|
|
51
43
|
resolveAgentsDir,
|
|
52
44
|
resolvePost,
|
|
53
|
-
resolveScout,
|
|
54
45
|
resolveSummary,
|
|
55
46
|
type SummarySettings,
|
|
56
47
|
} from "#review/preflight";
|
|
@@ -112,11 +103,16 @@ export const CODEGRAPH_ONLY_MCP_CONFIG = {
|
|
|
112
103
|
|
|
113
104
|
export const EMPTY_MCP_CONFIG = { mcpServers: {} };
|
|
114
105
|
|
|
106
|
+
// Where a non-fatal notice goes by default, beside every other `warning:` line
|
|
107
|
+
// a run prints.
|
|
108
|
+
function warnOnStderr(line: string): void {
|
|
109
|
+
process.stderr.write(`warning: ${line}\n`);
|
|
110
|
+
}
|
|
111
|
+
|
|
115
112
|
export interface LoadedRunConfig {
|
|
116
113
|
loaded: EffectiveConfig;
|
|
117
114
|
config: LocalConfig;
|
|
118
115
|
summary: SummarySettings;
|
|
119
|
-
scout: boolean;
|
|
120
116
|
post: boolean;
|
|
121
117
|
// The run's model profile, resolved once here from `config.profile`
|
|
122
118
|
// (openai-profile S3). Every route, prompt and pipeline input of the run
|
|
@@ -124,10 +120,10 @@ export interface LoadedRunConfig {
|
|
|
124
120
|
profile: ModelProfile;
|
|
125
121
|
}
|
|
126
122
|
|
|
127
|
-
// Config load + the
|
|
123
|
+
// Config load + the per-run resolvers read right after it: identical
|
|
128
124
|
// in both orchestrators except the root/home they read from (repoRoot +
|
|
129
125
|
// os.homedir() in review(), operatorRoot + the hoisted `home` in reviewPr()).
|
|
130
|
-
// Callers still own their own `options = { ...options,
|
|
126
|
+
// Callers still own their own `options = { ...options, post, ... }`
|
|
131
127
|
// reassignment — reviewPr() folds an extra `yes` field into the same spread,
|
|
132
128
|
// and forcing that in here would make this a mode flag instead of an
|
|
133
129
|
// explicit parameter.
|
|
@@ -135,7 +131,7 @@ export async function loadRunConfig(params: {
|
|
|
135
131
|
root: string;
|
|
136
132
|
home: string;
|
|
137
133
|
configFlag: string | undefined;
|
|
138
|
-
options: Pick<CliOptions, "summary" | "model" | "
|
|
134
|
+
options: Pick<CliOptions, "summary" | "model" | "post">;
|
|
139
135
|
// Where config warnings go. Defaults to stderr, beside every other
|
|
140
136
|
// `warning:` line a run prints.
|
|
141
137
|
warn?: (line: string) => void;
|
|
@@ -145,16 +141,13 @@ export async function loadRunConfig(params: {
|
|
|
145
141
|
home: params.home,
|
|
146
142
|
configFlag: params.configFlag,
|
|
147
143
|
});
|
|
148
|
-
const warn =
|
|
149
|
-
params.warn ??
|
|
150
|
-
((line: string) => process.stderr.write(`warning: ${line}\n`));
|
|
144
|
+
const warn = params.warn ?? warnOnStderr;
|
|
151
145
|
for (const line of loaded.warnings) warn(line);
|
|
152
146
|
const config = loaded.effective;
|
|
153
147
|
const summary = resolveSummary(params.options, config);
|
|
154
|
-
const scout = resolveScout(params.options, config);
|
|
155
148
|
const post = resolvePost(params.options, config);
|
|
156
149
|
const profile = resolveProfile(config.profile);
|
|
157
|
-
return { loaded, config, summary,
|
|
150
|
+
return { loaded, config, summary, post, profile };
|
|
158
151
|
}
|
|
159
152
|
|
|
160
153
|
// Shared range guard. Both orchestrators check the same thing right after
|
|
@@ -237,45 +230,14 @@ export async function validateGotchas(
|
|
|
237
230
|
}
|
|
238
231
|
}
|
|
239
232
|
|
|
240
|
-
// Which hunters actually run: every unconditional hunter
|
|
241
|
-
//
|
|
242
|
-
// never included — they are a
|
|
243
|
-
//
|
|
244
|
-
//
|
|
245
|
-
// parameter here.
|
|
246
|
-
export function selectActiveHunters(
|
|
247
|
-
agents
|
|
248
|
-
parityFires: boolean,
|
|
249
|
-
): AgentSpec[] {
|
|
250
|
-
return agents.filter(
|
|
251
|
-
(a) => a.role === "hunter" && (a.trigger === undefined || parityFires),
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// Whether the parity hunter fires for this diff: identical in both
|
|
256
|
-
// orchestrators. `changedPathsFromDiff`'s own list is never read afterward
|
|
257
|
-
// by either caller, only this boolean.
|
|
258
|
-
export function resolveParityFires(
|
|
259
|
-
patch: string,
|
|
260
|
-
parityTriggerPaths: string[],
|
|
261
|
-
): boolean {
|
|
262
|
-
return parityTriggered(changedPathsFromDiff(patch), parityTriggerPaths);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// How many hunters a full review of the whole PR runs: the unconditional ones,
|
|
266
|
-
// plus the parity hunter when the full PR patch touches a trigger path. A
|
|
267
|
-
// narrowed run's own count (none on a verify-only pass, no parity hunter when
|
|
268
|
-
// only the delta was read) would understate a full review, which is what the
|
|
269
|
-
// platform estimate's share divides by (cryskai/platform#12).
|
|
270
|
-
export function fullReviewHunterCount(
|
|
271
|
-
agents: readonly AgentSpec[],
|
|
272
|
-
prPatch: string,
|
|
273
|
-
parityTriggerPaths: string[],
|
|
274
|
-
): number {
|
|
275
|
-
return selectActiveHunters(
|
|
276
|
-
agents,
|
|
277
|
-
resolveParityFires(prPatch, parityTriggerPaths),
|
|
278
|
-
).length;
|
|
233
|
+
// Which hunters actually run: every unconditional hunter. A conditional
|
|
234
|
+
// (triggered) hunter never does, because no product review supplies trigger
|
|
235
|
+
// paths (the pipeline gets `[]`). Refuters are never included — they are a
|
|
236
|
+
// different role. Identical in both orchestrators;
|
|
237
|
+
// `reviewPr()`'s own `skipDiscovery` short-circuit to `[]` stays a call-site
|
|
238
|
+
// concern (a re-review with no delta to discover), not a parameter here.
|
|
239
|
+
export function selectActiveHunters(agents: readonly AgentSpec[]): AgentSpec[] {
|
|
240
|
+
return agents.filter((a) => a.role === "hunter" && a.trigger === undefined);
|
|
279
241
|
}
|
|
280
242
|
|
|
281
243
|
// The diff stat, TWICE and on purpose (moved here from review()'s own WHY
|
|
@@ -286,10 +248,9 @@ export function fullReviewHunterCount(
|
|
|
286
248
|
// must not consume the budget, and a file whose every change is whitespace
|
|
287
249
|
// drops out of that numstat entirely (verified: git emits no row for it).
|
|
288
250
|
//
|
|
289
|
-
// The
|
|
290
|
-
// hunters are handed diff.patch verbatim, whitespace hunks included, so
|
|
291
|
-
//
|
|
292
|
-
// class of lie the exclusion bug was.
|
|
251
|
+
// The report's DIFF STAT counts from the plain numstat, exclusions applied.
|
|
252
|
+
// The hunters are handed diff.patch verbatim, whitespace hunks included, so
|
|
253
|
+
// the stat describes what they actually read.
|
|
293
254
|
//
|
|
294
255
|
// `runGit` arrives as a callback, not an import of `git()` from `#git/git`:
|
|
295
256
|
// this module's import surface is deliberately narrowed to review-domain
|
|
@@ -356,8 +317,6 @@ export function buildTelemetry(
|
|
|
356
317
|
tokens_in: result.usage.tokens_in,
|
|
357
318
|
tokens_out: result.usage.tokens_out,
|
|
358
319
|
tokens_total: result.usage.tokens_total,
|
|
359
|
-
cost_usd_est: result.usage.cost_usd_est,
|
|
360
|
-
...(result.unresolved.length > 0 ? { cost_usd_est_is_floor: true } : {}),
|
|
361
320
|
per_agent: result.perAgent,
|
|
362
321
|
};
|
|
363
322
|
}
|
|
@@ -433,8 +392,6 @@ export async function writeRunReport(params: {
|
|
|
433
392
|
head: params.head,
|
|
434
393
|
diffStat: params.diffStat,
|
|
435
394
|
excludedPaths: params.droppedPaths,
|
|
436
|
-
costUsd: params.result.usage.cost_usd_est,
|
|
437
|
-
...notionalCostInput(params.result),
|
|
438
395
|
wallMs: params.wallMs,
|
|
439
396
|
...(params.ciMode === undefined ? {} : { ciMode: params.ciMode }),
|
|
440
397
|
}),
|
|
@@ -462,16 +419,25 @@ export async function resolvePromptSet(
|
|
|
462
419
|
prompts: NonNullable<Parameters<typeof resolveAgentsDir>[3]> & {
|
|
463
420
|
profile: ModelProfile;
|
|
464
421
|
},
|
|
422
|
+
// Where the two notices that need the spec go. Each orchestrator resolves its
|
|
423
|
+
// prompt set once per run, so each notice prints once.
|
|
424
|
+
warn: (line: string) => void = warnOnStderr,
|
|
465
425
|
): Promise<ResolvedPromptSet> {
|
|
466
426
|
const agents = resolveAgentsDir(options, loaded, undefined, prompts);
|
|
467
427
|
const spec = validateReviewSpec(localReviewSpec());
|
|
468
428
|
spec.agents.forEach((agent, i) => {
|
|
469
429
|
assertBasenameOnly(agent.file, i);
|
|
470
430
|
});
|
|
471
|
-
|
|
431
|
+
// The removed hunter's leftovers: a file in a custom directory, and a
|
|
432
|
+
// `models.hunter.parity` role. Neither is an error, neither does anything.
|
|
433
|
+
const warnings = await preflightAgentsDir(
|
|
472
434
|
agents,
|
|
473
435
|
spec.agents.map((a) => a.file),
|
|
474
436
|
);
|
|
437
|
+
for (const role of removedHunterRoles(loaded.effective.models, spec.agents)) {
|
|
438
|
+
warnings.push(`models.${role} ${PARITY_REMOVED}`);
|
|
439
|
+
}
|
|
440
|
+
for (const line of warnings) warn(line);
|
|
475
441
|
const agentFiles = new Map<string, ParsedAgent>();
|
|
476
442
|
for (const agent of spec.agents) {
|
|
477
443
|
// Parsing every agent file now is a preflight too: a malformed
|
|
@@ -535,7 +501,7 @@ export function routingConfigured(
|
|
|
535
501
|
|
|
536
502
|
// Production route resolution: identical in both orchestrators except the
|
|
537
503
|
// workspace root and (reviewPr()'s skipped-discovery re-review only) the
|
|
538
|
-
// summarizer/
|
|
504
|
+
// summarizer/consolidate/materiality enable overrides. Named distinctly from
|
|
539
505
|
// resolveProductionRoutePlanAtConfirm (#review/route-preflight), which this
|
|
540
506
|
// wraps — `resolveProductionRoute` reads as a near-duplicate of that name at
|
|
541
507
|
// a glance, which is exactly the confusion a shared wrapper should not add.
|
|
@@ -552,7 +518,6 @@ export async function resolvePipelineRoute(params: {
|
|
|
552
518
|
profile: ModelProfile;
|
|
553
519
|
summary: SummarySettings;
|
|
554
520
|
summarizerEnabled?: boolean;
|
|
555
|
-
scoutEnabled?: boolean;
|
|
556
521
|
consolidateEnabled?: boolean;
|
|
557
522
|
materialityEnabled?: boolean;
|
|
558
523
|
// S5: the run's Claude credential, chosen once at run start. Required (undefined
|
|
@@ -578,7 +543,6 @@ export async function resolvePipelineRoute(params: {
|
|
|
578
543
|
profile: params.profile,
|
|
579
544
|
summary: params.summary,
|
|
580
545
|
summarizerEnabled: params.summarizerEnabled,
|
|
581
|
-
scoutEnabled: params.scoutEnabled,
|
|
582
546
|
consolidateEnabled: params.consolidateEnabled,
|
|
583
547
|
materialityEnabled: params.materialityEnabled,
|
|
584
548
|
}),
|
package/src/review/size-gate.ts
CHANGED
|
@@ -398,9 +398,9 @@ export function unquotePath(field: string): string {
|
|
|
398
398
|
return out;
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
-
// The
|
|
402
|
-
//
|
|
403
|
-
//
|
|
401
|
+
// The size basis: the same aggregate the plan reads, but summed over the
|
|
402
|
+
// files that SURVIVE the exclusions. Feeding the gate the raw stat would
|
|
403
|
+
// count a lockfile the hunters never see.
|
|
404
404
|
export function effectiveDiffStat(
|
|
405
405
|
files: NumstatFile[],
|
|
406
406
|
rules: readonly IgnoreRule[],
|
package/src/review/spec.ts
CHANGED
|
@@ -42,7 +42,6 @@ export interface MultiModelDiversityConfig {
|
|
|
42
42
|
readonly enabled: true;
|
|
43
43
|
readonly armId: string;
|
|
44
44
|
readonly maxLegs: number;
|
|
45
|
-
readonly cashCapUsd: number;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
export interface ReviewSpec {
|
|
@@ -93,12 +92,6 @@ export function validateReviewSpec(candidate: unknown): ReviewSpec {
|
|
|
93
92
|
(diversity.maxLegs as number) >= 1,
|
|
94
93
|
"multiModelDiversity.maxLegs must be a positive integer",
|
|
95
94
|
);
|
|
96
|
-
must(
|
|
97
|
-
typeof diversity.cashCapUsd === "number" &&
|
|
98
|
-
Number.isFinite(diversity.cashCapUsd) &&
|
|
99
|
-
(diversity.cashCapUsd as number) > 0,
|
|
100
|
-
"multiModelDiversity.cashCapUsd must be a positive number",
|
|
101
|
-
);
|
|
102
95
|
}
|
|
103
96
|
const agents = spec.agents as unknown[];
|
|
104
97
|
const keys = new Set<string>();
|
|
@@ -210,10 +203,12 @@ export function validateReviewSpec(candidate: unknown): ReviewSpec {
|
|
|
210
203
|
return spec as unknown as ReviewSpec;
|
|
211
204
|
}
|
|
212
205
|
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
//
|
|
216
|
-
//
|
|
206
|
+
// The lab's legacy wiring, NOT the product's (localReviewSpec in
|
|
207
|
+
// src/review/preflight.ts is, and it has no parity hunter since the hunter left
|
|
208
|
+
// the product): reliability + resilience unconditional, parity conditional on
|
|
209
|
+
// the lab's parityTriggerPaths (the "input" sentinel), one refuter.
|
|
210
|
+
// runPipeline without an explicit spec uses this, which is what keeps the lab's
|
|
211
|
+
// engine behavior byte-stable.
|
|
217
212
|
export function defaultReviewSpec(): ReviewSpec {
|
|
218
213
|
return {
|
|
219
214
|
agents: [
|
|
@@ -110,8 +110,8 @@ export interface StepResult {
|
|
|
110
110
|
usage: SessionUsage;
|
|
111
111
|
// D1-08 PR2: the normalized disjoint leaves this step's attempts actually
|
|
112
112
|
// reported, summed across attempts. Absent when no attempt ever spawned
|
|
113
|
-
// (a pre-spawn denial, a construction failure) — those cases
|
|
114
|
-
//
|
|
113
|
+
// (a pre-spawn denial, a construction failure) — those cases genuinely
|
|
114
|
+
// used nothing, are not "unavailable", and carry no v2 record at all.
|
|
115
115
|
usageV2?: NormalizedUsage;
|
|
116
116
|
// D1-08 PR5b (§9.1): one entry per attempt that reached `runAttempt`'s
|
|
117
117
|
// reserve step, each carrying its own `reservationId` and TERMINAL state
|
|
@@ -133,7 +133,7 @@ export interface StepResult {
|
|
|
133
133
|
// cause, so after one this is the cause of the attempt before it.
|
|
134
134
|
finalCause?: FailureCause;
|
|
135
135
|
// The final attempt was refused by a fenced spend bucket (an earlier
|
|
136
|
-
// attempt on it left
|
|
136
|
+
// attempt on it left usage nobody could confirm), before the transport was called.
|
|
137
137
|
// That attempt is counted in `attempts` but wrote no log or receipt. Read
|
|
138
138
|
// only by the fallback (model-fallback.ts); never recorded.
|
|
139
139
|
spendFenced?: true;
|
|
@@ -250,7 +250,7 @@ export interface ClaudeCodeRunnerOptions {
|
|
|
250
250
|
//
|
|
251
251
|
// It stopped being cosmetic when the Claude CLI transport began reading
|
|
252
252
|
// that projected env to decide whether an attempt bills metered: two tests
|
|
253
|
-
// here assert the subscription
|
|
253
|
+
// here assert the subscription billing mode, and without this they assert it
|
|
254
254
|
// against whatever credentials the developer's own shell carries. Verified,
|
|
255
255
|
// not assumed — `ANTHROPIC_API_KEY=sk-probe bun test` reddened exactly those
|
|
256
256
|
// two before this landed. That is #174's defect, and it cost this repo two
|
package/src/runner-authority.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { planRoutes, type ResolvedRoutePlan } from "#model/routing";
|
|
|
14
14
|
import type { ClaudeCredentialKind } from "#review/preflight";
|
|
15
15
|
import type { CredentialKind, RunnerBackend } from "./execution/contracts";
|
|
16
16
|
// #161: the SAME predicate the Claude CLI transport files usage on
|
|
17
|
-
// (`
|
|
17
|
+
// (`claudeCliBillingMode` -> `envBillsMetered`) is the one `credentialKindForRoute`
|
|
18
18
|
// reads below, so admission and usage filing cannot answer "does this
|
|
19
19
|
// environment carry a per-token credential?" differently for one attempt. See
|
|
20
20
|
// the ADMISSION WIRING block on `envBillsMetered` itself for the full history.
|
|
@@ -333,11 +333,11 @@ export async function withClaudeDiscoveryAllowlist(
|
|
|
333
333
|
// plan cannot record.
|
|
334
334
|
//
|
|
335
335
|
// WHY the default is `provider_api_token` rather than the subscription kind:
|
|
336
|
-
// metered is the FAIL-CLOSED direction. A
|
|
337
|
-
//
|
|
338
|
-
//
|
|
339
|
-
//
|
|
340
|
-
//
|
|
336
|
+
// metered is the FAIL-CLOSED direction. A route wrongly marked subscription
|
|
337
|
+
// EXECUTES and files per-token usage as an uncharged quota — the platform
|
|
338
|
+
// prices a run by the credential class the engine reports, so that bill is
|
|
339
|
+
// nobody's to see. Guessing metered instead costs, at worst, a fence on a
|
|
340
|
+
// credential whose usage the engine could not confirm.
|
|
341
341
|
//
|
|
342
342
|
// #161 (corrected 2026-09-24 by Juanma — the first cut of this inverted
|
|
343
343
|
// precedence and is wrong; read this in full before touching the
|
|
@@ -439,7 +439,7 @@ export function credentialKindForRoute(
|
|
|
439
439
|
// Exhaustive on purpose: a backend with no credential authority must not
|
|
440
440
|
// fall into the metered default by accident. It has no binding at all —
|
|
441
441
|
// resolveBindingAuthority refuses it a few lines below — and inventing a
|
|
442
|
-
// kind for it here would make that refusal look like a
|
|
442
|
+
// kind for it here would make that refusal look like a billing problem.
|
|
443
443
|
throw new Error(`No credential authority is bound for backend "${backend}"`);
|
|
444
444
|
}
|
|
445
445
|
|
|
@@ -450,8 +450,9 @@ export function credentialKindForRoute(
|
|
|
450
450
|
// derives the billing mode STAMPED ON EVERY USAGE RECORD from it
|
|
451
451
|
// (transport-registry.ts). Two copies would be two chances for the capability
|
|
452
452
|
// report and the usage records to disagree about how one attempt bills — and
|
|
453
|
-
// the
|
|
454
|
-
// the disagreement would
|
|
453
|
+
// the platform prices a run by the credential class on the usage record, so
|
|
454
|
+
// the disagreement would silently mis-file the run rather than merely look
|
|
455
|
+
// untidy.
|
|
455
456
|
//
|
|
456
457
|
// A boolean, not a mode: the binding's rule is UPGRADE-ONLY (an OAuth or
|
|
457
458
|
// subscription kind keeps whatever the transport reported, `unknown`
|
|
@@ -539,13 +539,12 @@ function buildOpenCodeProjection(
|
|
|
539
539
|
// `type === "oauth"` lock. This kind promises a metered API token;
|
|
540
540
|
// projecting an OAuth record under it would make the capability report's
|
|
541
541
|
// `billing.mode: "metered"` wrong in the other direction — a subscription
|
|
542
|
-
// route gated
|
|
542
|
+
// route gated as if it were a per-token credential.
|
|
543
543
|
//
|
|
544
544
|
// Projection shape proven live (2026-09-01, opencode 1.18.23): a synthetic
|
|
545
545
|
// HOME carrying only `{ <provider>: { type: "api", ... } }` is read as exactly
|
|
546
546
|
// that one credential, with the operator's sibling providers absent, on two
|
|
547
|
-
// different provider keys. Inference under that credential is NOT yet proven
|
|
548
|
-
// that smoke is blocked on #137's pricing table.
|
|
547
|
+
// different provider keys. Inference under that credential is NOT yet proven.
|
|
549
548
|
// ---------------------------------------------------------------------------
|
|
550
549
|
|
|
551
550
|
// The provider name is interpolated into a JSON object key and compared
|
|
@@ -700,9 +699,9 @@ export class OpenCodeApiTokenBroker implements CredentialBroker {
|
|
|
700
699
|
// throws — the record lookup above never gets the chance to.
|
|
701
700
|
//
|
|
702
701
|
// Accepted cost (owner decision, #280, 2026-09-24): a model that flips from
|
|
703
|
-
// free to paid mid-run can
|
|
704
|
-
//
|
|
705
|
-
// stays keyed on `provider_free`/"free" regardless of what this broker
|
|
702
|
+
// free to paid mid-run can run one attempt before a re-probe notices —
|
|
703
|
+
// unchanged from #182, since the platform prices the usage the engine reports
|
|
704
|
+
// and billing stays keyed on `provider_free`/"free" regardless of what this broker
|
|
706
705
|
// projects. And an OpenCode Zen user with a stored `opencode` api key now
|
|
707
706
|
// runs Zen's free models with that key rather than keyless — accepted
|
|
708
707
|
// because it is strictly an upgrade (a working credential where none
|
package/src/server/preflight.ts
CHANGED
package/src/server/server.ts
CHANGED
|
@@ -31,6 +31,16 @@ import {
|
|
|
31
31
|
type UsageResponse,
|
|
32
32
|
} from "./preflight";
|
|
33
33
|
|
|
34
|
+
// The store keeps `cost_usd_est` as a legacy column (0 on every run since the platform prices runs,
|
|
35
|
+
// odd/tasks/platform-owned-cost.md S3): no dollar leaves the engine through this API, where a 0
|
|
36
|
+
// would read as a free run.
|
|
37
|
+
function withoutLegacyCost(row: CanonicalRunRow): CanonicalRunRow {
|
|
38
|
+
const { cost_usd_est: _legacy, ...rest } = row as CanonicalRunRow & {
|
|
39
|
+
cost_usd_est?: unknown;
|
|
40
|
+
};
|
|
41
|
+
return rest;
|
|
42
|
+
}
|
|
43
|
+
|
|
34
44
|
export interface ServerOptions {
|
|
35
45
|
dbPath: string;
|
|
36
46
|
socketPath?: string;
|
|
@@ -121,7 +131,9 @@ export function startProductStoreServer(
|
|
|
121
131
|
params.push(query.limit);
|
|
122
132
|
}
|
|
123
133
|
|
|
124
|
-
const runs = db.query(sql).all(...params) as CanonicalRunRow[]
|
|
134
|
+
const runs = (db.query(sql).all(...params) as CanonicalRunRow[]).map(
|
|
135
|
+
withoutLegacyCost,
|
|
136
|
+
);
|
|
125
137
|
const response: ListRunsResponse = { runs };
|
|
126
138
|
return Response.json(response);
|
|
127
139
|
}
|
|
@@ -132,7 +144,7 @@ export function startProductStoreServer(
|
|
|
132
144
|
if (!run) {
|
|
133
145
|
return Response.json({ error: "Run not found" }, { status: 404 });
|
|
134
146
|
}
|
|
135
|
-
return Response.json({ run });
|
|
147
|
+
return Response.json({ run: withoutLegacyCost(run) });
|
|
136
148
|
}
|
|
137
149
|
|
|
138
150
|
case "get_run_findings_doc": {
|
|
@@ -186,19 +198,18 @@ export function startProductStoreServer(
|
|
|
186
198
|
}
|
|
187
199
|
sql += " ORDER BY generated_at DESC;";
|
|
188
200
|
|
|
189
|
-
const rows = db.query(sql).all(...params) as CanonicalRunRow[]
|
|
201
|
+
const rows = (db.query(sql).all(...params) as CanonicalRunRow[]).map(
|
|
202
|
+
withoutLegacyCost,
|
|
203
|
+
);
|
|
190
204
|
let total_tokens = 0;
|
|
191
|
-
let total_cost_usd = 0;
|
|
192
205
|
|
|
193
206
|
for (const r of rows) {
|
|
194
207
|
total_tokens += r.tokens_total;
|
|
195
|
-
total_cost_usd += r.cost_usd_est;
|
|
196
208
|
}
|
|
197
209
|
|
|
198
210
|
const response: UsageResponse = {
|
|
199
211
|
rows,
|
|
200
212
|
total_tokens,
|
|
201
|
-
total_cost_usd,
|
|
202
213
|
};
|
|
203
214
|
return Response.json(response);
|
|
204
215
|
}
|
package/src/store/activity.ts
CHANGED
|
@@ -347,7 +347,6 @@ export interface RunHistoryItem {
|
|
|
347
347
|
blocking: number;
|
|
348
348
|
advisory: number;
|
|
349
349
|
wall_ms: number;
|
|
350
|
-
cost_usd_est: number;
|
|
351
350
|
generated_at: string;
|
|
352
351
|
pr?: number;
|
|
353
352
|
repo_id?: string;
|
|
@@ -393,7 +392,7 @@ export async function queryRecentRuns(
|
|
|
393
392
|
|
|
394
393
|
const rows = db
|
|
395
394
|
.query(
|
|
396
|
-
`SELECT id, run_status, blocking, advisory, wall_ms,
|
|
395
|
+
`SELECT id, run_status, blocking, advisory, wall_ms, generated_at, pr, repo_id
|
|
397
396
|
FROM runs
|
|
398
397
|
ORDER BY generated_at DESC
|
|
399
398
|
LIMIT ?`,
|
|
@@ -9,7 +9,6 @@ export interface BackfillStats {
|
|
|
9
9
|
skipped: number;
|
|
10
10
|
errors: number;
|
|
11
11
|
total_tokens: number;
|
|
12
|
-
total_cost_usd: number;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
export function createEmptyBackfillStats(): BackfillStats {
|
|
@@ -19,7 +18,6 @@ export function createEmptyBackfillStats(): BackfillStats {
|
|
|
19
18
|
skipped: 0,
|
|
20
19
|
errors: 0,
|
|
21
20
|
total_tokens: 0,
|
|
22
|
-
total_cost_usd: 0,
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
23
|
|
|
@@ -43,7 +41,6 @@ export function renderBackfillReport(stats: BackfillStats): string {
|
|
|
43
41
|
`Skipped runs: ${stats.skipped}`,
|
|
44
42
|
`Errors: ${stats.errors}`,
|
|
45
43
|
`Total tokens: ${stats.total_tokens.toLocaleString()}`,
|
|
46
|
-
`Total cost USD: $${stats.total_cost_usd.toFixed(2)}`,
|
|
47
44
|
];
|
|
48
45
|
return lines.join("\n");
|
|
49
46
|
}
|
package/src/store/backfill.ts
CHANGED
|
@@ -103,7 +103,6 @@ export async function backfillHistoricalRuns(
|
|
|
103
103
|
saveRunTransaction(db, projected, { keepGeneratedAt: true });
|
|
104
104
|
stats.ingested++;
|
|
105
105
|
stats.total_tokens += doc.telemetry.tokens_total;
|
|
106
|
-
stats.total_cost_usd += doc.telemetry.cost_usd_est;
|
|
107
106
|
} catch (err) {
|
|
108
107
|
stats.errors++;
|
|
109
108
|
options.log?.(
|
|
@@ -103,7 +103,6 @@ export interface RunRow {
|
|
|
103
103
|
tokens_in: number;
|
|
104
104
|
tokens_out: number;
|
|
105
105
|
tokens_total: number;
|
|
106
|
-
cost_usd_est: number;
|
|
107
106
|
blocking: number;
|
|
108
107
|
advisory: number;
|
|
109
108
|
}
|
|
@@ -114,7 +113,6 @@ export interface RunAgentRow {
|
|
|
114
113
|
duration_ms: number;
|
|
115
114
|
tokens_in: number;
|
|
116
115
|
tokens_out: number;
|
|
117
|
-
cost_usd_est: number;
|
|
118
116
|
attempts: number;
|
|
119
117
|
status: string;
|
|
120
118
|
}
|
|
@@ -160,7 +158,6 @@ export function projectRunRow(input: {
|
|
|
160
158
|
tokens_in: input.doc.telemetry.tokens_in,
|
|
161
159
|
tokens_out: input.doc.telemetry.tokens_out,
|
|
162
160
|
tokens_total: input.doc.telemetry.tokens_total,
|
|
163
|
-
cost_usd_est: input.doc.telemetry.cost_usd_est,
|
|
164
161
|
blocking,
|
|
165
162
|
advisory,
|
|
166
163
|
};
|
|
@@ -171,7 +168,6 @@ export function projectRunRow(input: {
|
|
|
171
168
|
duration_ms: usage.duration_ms,
|
|
172
169
|
tokens_in: usage.tokens_in,
|
|
173
170
|
tokens_out: usage.tokens_out,
|
|
174
|
-
cost_usd_est: usage.cost_usd_est,
|
|
175
171
|
attempts: usage.attempts,
|
|
176
172
|
status: usage.status,
|
|
177
173
|
}),
|
|
@@ -201,29 +197,23 @@ export function renderUsage(
|
|
|
201
197
|
const out: string[] = [];
|
|
202
198
|
out.push(
|
|
203
199
|
"| generated_at | repo_id | pr | status | blocking | advisory | " +
|
|
204
|
-
"tokens |
|
|
200
|
+
"tokens | run_dir |",
|
|
205
201
|
);
|
|
206
|
-
out.push("| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
202
|
+
out.push("| --- | --- | --- | --- | --- | --- | --- | --- |");
|
|
207
203
|
for (const row of rows) {
|
|
208
204
|
const status =
|
|
209
205
|
row.run_status + (row.session_failed ? " (session failed)" : "");
|
|
210
206
|
out.push(
|
|
211
207
|
`| ${row.generated_at} | ${row.repo_id} | ${row.pr ?? "local"} | ` +
|
|
212
208
|
`${status} | ${row.blocking} | ${row.advisory} | ` +
|
|
213
|
-
`${row.tokens_total} |
|
|
214
|
-
`${row.run_dir} |`,
|
|
209
|
+
`${row.tokens_total} | ${row.run_dir} |`,
|
|
215
210
|
);
|
|
216
211
|
}
|
|
217
|
-
let totalCost = 0;
|
|
218
212
|
let totalTokens = 0;
|
|
219
213
|
for (const row of rows) {
|
|
220
|
-
totalCost += row.cost_usd_est;
|
|
221
214
|
totalTokens += row.tokens_total;
|
|
222
215
|
}
|
|
223
216
|
out.push("");
|
|
224
|
-
out.push(
|
|
225
|
-
`${rows.length} run(s) — $${totalCost.toFixed(2)} total, ` +
|
|
226
|
-
`${totalTokens} tokens.`,
|
|
227
|
-
);
|
|
217
|
+
out.push(`${rows.length} run(s) — ${totalTokens} tokens.`);
|
|
228
218
|
return out;
|
|
229
219
|
}
|
package/src/store/metrics.ts
CHANGED
|
@@ -60,12 +60,15 @@ export interface IngestRunInput {
|
|
|
60
60
|
generatedAt?: string;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
// `cost_usd_est` is a LEGACY column (see the note on store.ts's RUN_UPSERT_SQL):
|
|
64
|
+
// NOT NULL since schema v1, so new rows carry the constant 0, nothing reads it,
|
|
65
|
+
// and a re-ingest of an existing run keeps its stored figure.
|
|
63
66
|
const RUN_UPSERT_SQL = `
|
|
64
67
|
INSERT INTO runs (
|
|
65
68
|
repo_id, run_dir, pr, checkout_path, head_sha, base_sha, run_status,
|
|
66
69
|
session_failed, model, generated_at, wall_ms, index_ms, tokens_in,
|
|
67
70
|
tokens_out, tokens_total, cost_usd_est, blocking, advisory
|
|
68
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
|
71
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?)
|
|
69
72
|
ON CONFLICT(run_dir) DO UPDATE SET
|
|
70
73
|
repo_id = excluded.repo_id,
|
|
71
74
|
pr = excluded.pr,
|
|
@@ -81,7 +84,6 @@ const RUN_UPSERT_SQL = `
|
|
|
81
84
|
tokens_in = excluded.tokens_in,
|
|
82
85
|
tokens_out = excluded.tokens_out,
|
|
83
86
|
tokens_total = excluded.tokens_total,
|
|
84
|
-
cost_usd_est = excluded.cost_usd_est,
|
|
85
87
|
blocking = excluded.blocking,
|
|
86
88
|
advisory = excluded.advisory
|
|
87
89
|
`;
|
|
@@ -103,7 +105,6 @@ function runParams(row: RunRow): SQLQueryBindings[] {
|
|
|
103
105
|
row.tokens_in,
|
|
104
106
|
row.tokens_out,
|
|
105
107
|
row.tokens_total,
|
|
106
|
-
row.cost_usd_est,
|
|
107
108
|
row.blocking,
|
|
108
109
|
row.advisory,
|
|
109
110
|
];
|
|
@@ -150,7 +151,7 @@ function insertAgents(
|
|
|
150
151
|
INSERT INTO run_agents (
|
|
151
152
|
run_id, agent_key, tokens_total, duration_ms, tokens_in, tokens_out,
|
|
152
153
|
cost_usd_est, attempts, status
|
|
153
|
-
) VALUES (?, ?, ?, ?, ?, ?,
|
|
154
|
+
) VALUES (?, ?, ?, ?, ?, ?, 0, ?, ?)
|
|
154
155
|
`);
|
|
155
156
|
for (const agent of agents) {
|
|
156
157
|
insert.run(
|
|
@@ -160,7 +161,6 @@ function insertAgents(
|
|
|
160
161
|
agent.duration_ms,
|
|
161
162
|
agent.tokens_in,
|
|
162
163
|
agent.tokens_out,
|
|
163
|
-
agent.cost_usd_est,
|
|
164
164
|
agent.attempts,
|
|
165
165
|
agent.status,
|
|
166
166
|
);
|