crysk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -23
- package/dist/SKILL-1q3658n0.md +74 -0
- package/dist/SKILL-25j4q9b8.md +143 -0
- package/dist/SKILL-4747bhne.md +143 -0
- package/dist/SKILL-4jc3sv23.md +74 -0
- package/dist/SKILL-c0492rch.md +540 -0
- package/dist/SKILL-d1nzkhhr.md +74 -0
- package/dist/SKILL-f8p7kvx0.md +143 -0
- package/dist/SKILL-gxd45g38.md +553 -0
- package/dist/SKILL-rec41991.md +66 -0
- package/dist/SKILL-zze8zj5g.md +536 -0
- package/dist/cli.js +24658 -24654
- package/dist/index.js +492 -463
- package/dist/opencode-ci-qrcv7a99.md +106 -0
- package/dist/opencode-ci-rdpcc7xc.md +106 -0
- package/dist/opencode-ci-yt0k74t0.md +106 -0
- package/dist/workflow-andv2dvm.yml +158 -0
- package/package.json +1 -1
- package/prompts/default/PROVENANCE.md +1 -0
- package/skills/crysk/SKILL.md +6 -6
- package/skills/crysk-ci-setup/SKILL.md +32 -33
- package/skills/crysk-ci-setup/assets/workflow.yml +5 -10
- package/skills/crysk-ci-setup/references/ci-admission.md +5 -5
- package/skills/crysk-ci-setup/references/opencode-ci.md +6 -6
- package/skills/crysk-loop/SKILL.md +37 -54
- package/skills/crysk-pr/SKILL.md +1 -1
- package/src/asset-manifest.ts +0 -6
- package/src/assets.ts +1 -4
- package/src/brand.ts +20 -30
- package/src/ci/gates.ts +155 -201
- package/src/ci/outcome.ts +4 -31
- package/src/ci/platform-limits.ts +135 -0
- package/src/ci/platform-report.ts +212 -126
- package/src/ci/platform.ts +28 -26
- package/src/ci/reporter.ts +25 -26
- package/src/ci/review-admission.ts +1 -2
- package/src/ci/review-levels.ts +12 -53
- package/src/ci/setup.ts +96 -66
- package/src/ci/trace-bundle.ts +11 -27
- package/src/ci/trace-transcripts.ts +4 -6
- package/src/ci/trigger.ts +3 -5
- package/src/cli.ts +6 -5
- package/src/commands/ci-setup-questions.ts +2 -55
- package/src/commands/ci-setup.ts +2 -26
- package/src/commands/triage.ts +131 -38
- package/src/commands/usage.ts +0 -1
- package/src/compare/compare.ts +3 -3
- package/src/compare/floor-test.ts +30 -201
- package/src/config/config.ts +6 -30
- package/src/diversity/accounting.ts +0 -26
- package/src/diversity/benchmark.ts +1 -17
- package/src/diversity/identity.ts +0 -14
- package/src/diversity/pipeline-integration.ts +0 -29
- package/src/doctor.ts +3 -6
- package/src/execution/claude-session-trace.ts +7 -2
- package/src/execution/contracts.ts +15 -9
- package/src/execution/harness.ts +165 -187
- package/src/execution/spend-limiter.ts +39 -131
- package/src/execution/usage-facts.ts +397 -0
- package/src/execution/usage-normalized.ts +33 -86
- package/src/harness/materiality-judge.ts +0 -5
- package/src/harness/pipeline-plan.ts +0 -3
- package/src/harness/replay-rows.ts +0 -5
- package/src/harness/route-runner.ts +2 -2
- package/src/harness/single-step.ts +3 -9
- package/src/index.ts +1 -1
- package/src/mcp/preflight.ts +2 -2
- package/src/model/catalog.ts +1 -3
- package/src/model/free-discovery.ts +11 -78
- package/src/model/model-name.ts +14 -4
- package/src/model/profiles/claude.ts +1 -2
- package/src/model/profiles/openai.ts +1 -2
- package/src/model/profiles.ts +1 -2
- package/src/model/provider-capabilities.ts +16 -55
- package/src/model/routing.ts +39 -36
- package/src/pr/admission.ts +6 -6
- package/src/pr/answered-findings.ts +8 -4
- package/src/pr/ci-publish.ts +0 -2
- package/src/pr/discovery.ts +4 -25
- package/src/pr/plan.ts +40 -121
- package/src/pr/pr-status.ts +14 -2
- package/src/pr/preflight.ts +15 -12
- package/src/pr/publish-outcome.ts +1 -19
- package/src/pr/review-pr.ts +10 -47
- package/src/pr/target.ts +76 -82
- package/src/production-runtime.ts +52 -114
- package/src/progress.ts +0 -54
- package/src/rereview/prepare.ts +4 -1
- package/src/rereview/state.ts +1 -1
- package/src/review/boundary.ts +4 -8
- package/src/review/drafts.ts +3 -3
- package/src/review/findings-conformance.ts +1 -1
- package/src/review/findings.ts +0 -4
- package/src/review/pipeline.ts +57 -395
- package/src/review/preflight.ts +162 -201
- package/src/review/prompt-set.ts +0 -2
- package/src/review/report.ts +2 -162
- package/src/review/review.ts +16 -65
- package/src/review/route-preflight.ts +3 -35
- package/src/review/run.ts +37 -73
- package/src/review/size-gate.ts +3 -3
- package/src/review/spec.ts +6 -11
- package/src/review/step-runner.ts +4 -4
- package/src/runner-authority.ts +10 -9
- package/src/security/credential-broker.ts +5 -6
- package/src/server/preflight.ts +0 -1
- package/src/server/server.ts +17 -6
- package/src/store/activity.ts +1 -2
- package/src/store/backfill-preflight.ts +0 -3
- package/src/store/backfill.ts +0 -1
- package/src/store/metrics-preflight.ts +4 -14
- package/src/store/metrics.ts +5 -5
- package/src/store/preflight.ts +0 -13
- package/src/store/store.ts +11 -12
- package/src/transport-registry.ts +6 -30
- package/src/transports/claude-code-cli.ts +149 -215
- package/src/transports/opencode-client.ts +4 -24
- package/src/transports/opencode-sdk.ts +17 -112
- package/src/triage/plain-reply.ts +37 -0
- package/src/ui/activity.ts +1 -6
- package/src/ui/config-edit.ts +14 -67
- package/src/ui/config.ts +3 -8
- package/src/ui/plan.ts +11 -198
- package/src/ui/progress.ts +3 -49
- package/src/ui/result.ts +18 -77
- package/src/ui/review-menu.ts +3 -12
- package/src/ui/select.ts +9 -79
- package/src/updater.ts +1 -1
- package/src/usage.ts +1 -7
- package/prompts/default/deep-review-parity.md +0 -152
- package/prompts/scout.md +0 -140
- package/src/ci/platform-estimate.ts +0 -111
- package/src/review/scout.ts +0 -323
package/src/ci/gates.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
// Bounded unattended spend (ROADMAP Pillar 3, GitHub Actions CI): the
|
|
2
|
-
//
|
|
1
|
+
// Bounded unattended spend (ROADMAP Pillar 3, GitHub Actions CI): the gates
|
|
2
|
+
// that must clear BEFORE a CI run spawns a single agent, and the pure
|
|
3
3
|
// CI-mode skip payloads those gates produce when they don't.
|
|
4
4
|
//
|
|
5
5
|
// Phase 3 additions (this module's scope now covers the whole CI-mode
|
|
6
|
-
// policy layer, not just the
|
|
7
|
-
// `
|
|
6
|
+
// policy layer, not just the spend gates): `planCiSizeSkip`/
|
|
7
|
+
// `planCiLimitsSkip` are the ONE call reviewPr's shell makes per gate —
|
|
8
8
|
// comment + marker + step-summary markdown + $GITHUB_OUTPUT, all from the
|
|
9
|
-
// same
|
|
10
|
-
// write it".
|
|
11
|
-
// ceiling `::warning::` requirement. The exit-code contract (spec 2.1) lives
|
|
9
|
+
// same inputs, so the shell has no decision left to make beyond "post it /
|
|
10
|
+
// write it". The exit-code contract (spec 2.1) lives
|
|
12
11
|
// in src/review/exit-code.ts, shared by every mode.
|
|
13
12
|
//
|
|
14
13
|
// This module does NOT reimplement the size gate — that gate (deterministic
|
|
@@ -20,8 +19,8 @@
|
|
|
20
19
|
// there is nobody to prompt AND the run must still exit 0 with a courteous
|
|
21
20
|
// PR notice (assistant posture — see proposal.md's Invariants). So this
|
|
22
21
|
// module adds exactly that CI-mode handling on top of an already-computed
|
|
23
|
-
// `SizeGateVerdict`, plus the
|
|
24
|
-
//
|
|
22
|
+
// `SizeGateVerdict`, plus the platform limits rule (the engine computes no
|
|
23
|
+
// dollar figure; see `evaluatePlatformLimits`).
|
|
25
24
|
//
|
|
26
25
|
// Purity (project rule 1): every function here is a total function of its
|
|
27
26
|
// arguments. No file I/O, no `process.env` sniffing, no `log()`, no network,
|
|
@@ -67,6 +66,7 @@ import { commandHint, MARKER_OPEN } from "../brand";
|
|
|
67
66
|
import { CliUsageError } from "../errors";
|
|
68
67
|
import { envBillsMetered } from "../execution/usage-normalized";
|
|
69
68
|
import { ciForceReviewHintLine } from "./force-comment";
|
|
69
|
+
import type { PlatformLimitHit, PlatformLimits } from "./platform-limits";
|
|
70
70
|
import {
|
|
71
71
|
type CiOutputs,
|
|
72
72
|
type CiSummaryData,
|
|
@@ -83,56 +83,104 @@ import type { CiReviewPolicyMode } from "./review-policy";
|
|
|
83
83
|
import type { DeltaRiskAssessment } from "./review-risk";
|
|
84
84
|
import { OVERRIDE_COMMAND } from "./trigger";
|
|
85
85
|
|
|
86
|
-
function usd(amount: number): string {
|
|
87
|
-
return `$${amount.toFixed(2)}`;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
86
|
// ---------------------------------------------------------------------------
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
//
|
|
87
|
+
// Platform limits — platform-owned-cost L55. The platform owns the dollar
|
|
88
|
+
// limits (settings, defaults, the month's spend) and sends them with its
|
|
89
|
+
// estimate at the token exchange, nothing when the review was forced. The
|
|
90
|
+
// engine keeps ONE comparison, because only it knows whether the run bills an
|
|
91
|
+
// API key: skip when the run does and either the month's limit is used up, or
|
|
92
|
+
// the platform's estimate is over the per-review limit or over what is left of
|
|
93
|
+
// the month.
|
|
94
94
|
// ---------------------------------------------------------------------------
|
|
95
95
|
|
|
96
|
-
export
|
|
97
|
-
allowed:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
export type PlatformLimitsVerdict =
|
|
97
|
+
| { allowed: true }
|
|
98
|
+
| {
|
|
99
|
+
allowed: false;
|
|
100
|
+
hit: PlatformLimitHit;
|
|
101
|
+
// Set when the comparison used the API share of the estimate (S17), not
|
|
102
|
+
// the whole of it; the skip notice says so.
|
|
103
|
+
apiShare?: true;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// Which model roles the run bills on an API key (true) and which it does not
|
|
107
|
+
// (false), resolved once from the run's routes (`modelRoleBilling`, ci/setup.ts).
|
|
108
|
+
export type ModelRoleBilling = ReadonlyMap<string, boolean>;
|
|
109
|
+
|
|
110
|
+
// The part of the estimate that runs on an API key (S17): the platform's split
|
|
111
|
+
// summed over the roles the run bills on one, plus every key the run cannot map
|
|
112
|
+
// to one of its roles (an unknown role may bill, so it counts). Undefined means
|
|
113
|
+
// there is no usable split, and the whole estimate is compared: no split sent
|
|
114
|
+
// or the run's routes unresolved (a run whose roles bill no API key never gets
|
|
115
|
+
// here: evaluatePlatformLimits lets it run).
|
|
116
|
+
// Rounded to the platform's 6 decimals so a sum of its parts sits on a limit
|
|
117
|
+
// instead of a hair over it.
|
|
118
|
+
function apiShareUsd(
|
|
119
|
+
limits: PlatformLimits,
|
|
120
|
+
roleBilling: ModelRoleBilling | undefined,
|
|
121
|
+
): number | undefined {
|
|
122
|
+
const split = limits.estimateByRoleUsd;
|
|
123
|
+
if (split === undefined || roleBilling === undefined) return undefined;
|
|
124
|
+
if (!hasApiBilledRole(roleBilling)) return undefined;
|
|
125
|
+
let share = 0;
|
|
126
|
+
for (const [role, usd] of Object.entries(split)) {
|
|
127
|
+
if (roleBilling.get(role) !== false) share += usd;
|
|
128
|
+
}
|
|
129
|
+
return Math.round(share * 1e6) / 1e6;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// True when at least one resolved role bills an API key.
|
|
133
|
+
function hasApiBilledRole(roleBilling: ModelRoleBilling): boolean {
|
|
134
|
+
return [...roleBilling.values()].some(Boolean);
|
|
103
135
|
}
|
|
104
136
|
|
|
105
|
-
// Inclusive boundary:
|
|
137
|
+
// Inclusive boundary: an estimate exactly AT a limit passes, matching
|
|
106
138
|
// size-gate.ts's own `>` (not `>=`) comparison against its limits.
|
|
107
139
|
//
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
// 0` has to mean what `max-changed-lines: 0` means. The external convention
|
|
113
|
-
// does cut the other way (a $0 spend cap elsewhere often means "spend
|
|
114
|
-
// nothing"), which is why it is written down here rather than assumed.
|
|
140
|
+
// No estimate and a month with money left: the review runs. That is a stated
|
|
141
|
+
// limit of the design (a model the platform cannot price is not capped per
|
|
142
|
+
// review), not an oversight; the platform's own month ledger still counts the
|
|
143
|
+
// run once it reports.
|
|
115
144
|
//
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
// A subscription or free route is never skipped: its runs draw on quota, and
|
|
146
|
+
// only API spend counts toward the limits (L54, "counts": "api_only"). In a run
|
|
147
|
+
// whose roles bill differently, the estimate compared is the API share when the
|
|
148
|
+
// platform split it per role (S17); without the split it is the whole estimate,
|
|
149
|
+
// the conservative side.
|
|
150
|
+
export function evaluatePlatformLimits(input: {
|
|
151
|
+
billingMode: CiBillingMode;
|
|
152
|
+
limits: PlatformLimits | undefined;
|
|
153
|
+
roleBilling?: ModelRoleBilling;
|
|
154
|
+
}): PlatformLimitsVerdict {
|
|
155
|
+
const { limits } = input;
|
|
156
|
+
if (input.billingMode !== "metered" || limits === undefined) {
|
|
157
|
+
return { allowed: true };
|
|
158
|
+
}
|
|
159
|
+
// Metered by the Claude env alone (an API key present) while no resolved role
|
|
160
|
+
// routes to it: the run bills no API spend, so it is never skipped (#551 R001).
|
|
161
|
+
// No role map (routes unresolved) keeps the conservative whole-estimate path.
|
|
162
|
+
if (
|
|
163
|
+
input.roleBilling !== undefined &&
|
|
164
|
+
input.roleBilling.size > 0 &&
|
|
165
|
+
!hasApiBilledRole(input.roleBilling)
|
|
166
|
+
) {
|
|
167
|
+
return { allowed: true };
|
|
168
|
+
}
|
|
169
|
+
const { reviewUsd, monthLeftUsd, estimateUsd } = limits;
|
|
170
|
+
if (monthLeftUsd !== undefined && monthLeftUsd <= 0) {
|
|
171
|
+
return { allowed: false, hit: "month-used-up" };
|
|
172
|
+
}
|
|
173
|
+
if (estimateUsd === undefined) return { allowed: true };
|
|
174
|
+
const share = apiShareUsd(limits, input.roleBilling);
|
|
175
|
+
const compared = share ?? estimateUsd;
|
|
176
|
+
const basis = share === undefined ? {} : { apiShare: true as const };
|
|
177
|
+
if (reviewUsd !== undefined && compared > reviewUsd) {
|
|
178
|
+
return { allowed: false, hit: "review-limit", ...basis };
|
|
179
|
+
}
|
|
180
|
+
if (monthLeftUsd !== undefined && compared > monthLeftUsd) {
|
|
181
|
+
return { allowed: false, hit: "month-left", ...basis };
|
|
182
|
+
}
|
|
183
|
+
return { allowed: true };
|
|
136
184
|
}
|
|
137
185
|
|
|
138
186
|
// ---------------------------------------------------------------------------
|
|
@@ -214,27 +262,35 @@ function buildSizeSkipComment(
|
|
|
214
262
|
return `${lines.join("\n")}\n`;
|
|
215
263
|
}
|
|
216
264
|
|
|
217
|
-
// What a platform repository can do about a
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
265
|
+
// What a platform repository can do about a limits skip: the limits are
|
|
266
|
+
// dashboard settings (Review > Limits), not workflow inputs.
|
|
267
|
+
const LIMIT_SKIP_REASON: Record<PlatformLimitHit, string> = {
|
|
268
|
+
"month-used-up":
|
|
269
|
+
"⚠️ This organization's monthly review limit is used up for this calendar month.",
|
|
270
|
+
"review-limit":
|
|
271
|
+
"⚠️ The estimated cost of this review is over the per-review limit.",
|
|
272
|
+
"month-left":
|
|
273
|
+
"⚠️ The estimated cost of this review is more than what is left of this organization's monthly limit.",
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// A mixed setup is compared on the part of the estimate that runs on an API
|
|
277
|
+
// key; the notice says so, because the estimate the reader may know is larger.
|
|
278
|
+
const API_SHARE_LINE =
|
|
279
|
+
"Only the part of the estimate that runs on an API key (its API share) " +
|
|
280
|
+
"was compared with the limit.";
|
|
222
281
|
|
|
223
282
|
function buildBudgetSkipComment(data: SkipBudgetSummary): string {
|
|
224
|
-
const platformConnected = data.platformConnected === true;
|
|
225
283
|
const lines = [
|
|
226
284
|
SKIP_BUDGET_COMMENT_MARKER,
|
|
227
285
|
"## Crysk review skipped",
|
|
228
286
|
"",
|
|
229
|
-
|
|
230
|
-
|
|
287
|
+
LIMIT_SKIP_REASON[data.limit],
|
|
288
|
+
...(data.apiShare === true ? ["", API_SHARE_LINE] : []),
|
|
231
289
|
"",
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
: "Crysk did not run to stay within the configured `--budget-usd` " +
|
|
235
|
-
"ceiling.",
|
|
290
|
+
"Crysk did not run to stay within the limits set in the Crysk dashboard " +
|
|
291
|
+
"(Review > Limits). Raise the limit there to review later pushes.",
|
|
236
292
|
"",
|
|
237
|
-
ciForceReviewHintLine(data.prNumber,
|
|
293
|
+
ciForceReviewHintLine(data.prNumber, true),
|
|
238
294
|
];
|
|
239
295
|
return `${lines.join("\n")}\n`;
|
|
240
296
|
}
|
|
@@ -280,62 +336,34 @@ export function ciSizeGateSkip(input: CiSizeGateSkipInput): CiGateSkip | null {
|
|
|
280
336
|
};
|
|
281
337
|
}
|
|
282
338
|
|
|
283
|
-
export interface
|
|
339
|
+
export interface CiLimitsGateSkipInput {
|
|
284
340
|
isCi: boolean;
|
|
285
|
-
|
|
286
|
-
|
|
341
|
+
billingMode: CiBillingMode;
|
|
342
|
+
limits: PlatformLimits | undefined;
|
|
343
|
+
// The run's roles that bill an API key, for the estimate split (S17).
|
|
344
|
+
roleBilling?: ModelRoleBilling;
|
|
287
345
|
prNumber: number;
|
|
288
|
-
// The run came through the Crysk platform (CRYSK_PLATFORM_CONNECTED): the
|
|
289
|
-
// skip names only what applies to a platform repository.
|
|
290
|
-
platformConnected?: boolean;
|
|
291
346
|
}
|
|
292
347
|
|
|
293
|
-
export function
|
|
294
|
-
input:
|
|
348
|
+
export function ciLimitsGateSkip(
|
|
349
|
+
input: CiLimitsGateSkipInput,
|
|
295
350
|
): CiGateSkip | null {
|
|
296
|
-
|
|
297
|
-
|
|
351
|
+
if (!input.isCi) return null;
|
|
352
|
+
const verdict = evaluatePlatformLimits(input);
|
|
353
|
+
if (verdict.allowed) return null;
|
|
298
354
|
const summary: SkipBudgetSummary = {
|
|
299
355
|
kind: "skipped-budget",
|
|
300
356
|
prNumber: input.prNumber,
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
...(input.platformConnected === true ? { platformConnected: true } : {}),
|
|
357
|
+
limit: verdict.hit,
|
|
358
|
+
...(verdict.apiShare === true ? { apiShare: true as const } : {}),
|
|
304
359
|
};
|
|
305
360
|
return { comment: buildBudgetSkipComment(summary), summary };
|
|
306
361
|
}
|
|
307
362
|
|
|
308
363
|
// ---------------------------------------------------------------------------
|
|
309
|
-
//
|
|
310
|
-
//
|
|
311
|
-
//
|
|
312
|
-
// disabled." Only for an EXPLICIT <= 0 — `undefined` (the flag was never
|
|
313
|
-
// given) means no ceiling was ever configured, so there is nothing to warn
|
|
314
|
-
// about disabling. The shell wraps this message with
|
|
315
|
-
// `formatWorkflowCommand("warning", ...)` (ci/reporter.ts); this module only
|
|
316
|
-
// decides whether to and builds the text, never the annotation syntax.
|
|
317
|
-
// ---------------------------------------------------------------------------
|
|
318
|
-
|
|
319
|
-
export function budgetDisabledWarningMessage(
|
|
320
|
-
budgetUsd: number | undefined,
|
|
321
|
-
): string | null {
|
|
322
|
-
if (budgetUsd === undefined || budgetUsd > 0) return null;
|
|
323
|
-
return (
|
|
324
|
-
"budget-usd ceiling is disabled (<= 0 was configured); estimated cost " +
|
|
325
|
-
"is unconstrained for this CI run. The size gate is resolved " +
|
|
326
|
-
"separately."
|
|
327
|
-
);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// ---------------------------------------------------------------------------
|
|
331
|
-
// Route-aware ceiling resolution (issue #156). The budget gate compares
|
|
332
|
-
// `estimate.high` — a TOKEN-derived figure — against a real-dollar ceiling.
|
|
333
|
-
// On a Claude subscription route the real cash cost of a run is $0.00, so the
|
|
334
|
-
// shipped $10 default refused to do work over an overrun that cannot happen,
|
|
335
|
-
// and a skipped review is indistinguishable from a clean one to anyone
|
|
336
|
-
// reading the checks (this module's own doctrine, ~110-115; ci/setup.ts:50-63).
|
|
337
|
-
// So: no ceiling by default on a subscription route, the default ceiling on a
|
|
338
|
-
// metered one, and an explicit operator value honoured verbatim on either.
|
|
364
|
+
// How the run bills (issue #156). The size gate's route-aware limits and the
|
|
365
|
+
// platform limits gate both read it: a subscription route has no per-token
|
|
366
|
+
// invoice, so the platform's dollar limits never skip it.
|
|
339
367
|
// ---------------------------------------------------------------------------
|
|
340
368
|
|
|
341
369
|
export type CiBillingMode = "subscription" | "metered";
|
|
@@ -425,73 +453,6 @@ export function deriveCiBillingMode(
|
|
|
425
453
|
: "subscription";
|
|
426
454
|
}
|
|
427
455
|
|
|
428
|
-
// 12, raised from 10 when the default set gained its fourth always-on hunter.
|
|
429
|
-
// The gate compares the estimate's UPPER bound with this ceiling, and the
|
|
430
|
-
// estimate (review/report.ts) prices one seat per hunter. With the summarizer
|
|
431
|
-
// on, that hunter lifted every upper bound by 20%: the smallest pull request
|
|
432
|
-
// went from $8.53 to $10.24, so a ceiling of 10 skipped all of them. 12 admits
|
|
433
|
-
// what 10 admitted before. With the summarizer off the rise is 25%, so a pull
|
|
434
|
-
// request whose old upper bound sat between $9.60 and $10 is skipped now.
|
|
435
|
-
// A workflow that WRITES `budget-usd: 10` carries an operator value and does
|
|
436
|
-
// not move with this constant.
|
|
437
|
-
export const CI_DEFAULT_METERED_BUDGET_USD = 12;
|
|
438
|
-
|
|
439
|
-
export interface CiBudgetCeiling {
|
|
440
|
-
// `undefined` means NO ceiling — the gate does not run at all. Distinct from
|
|
441
|
-
// a `0` ceiling, which reaches `evaluateBudgetGate` and is allowed there by
|
|
442
|
-
// the `<= 0` convention; the two arrive by different routes and the shell
|
|
443
|
-
// announces them with different messages.
|
|
444
|
-
budgetUsd: number | undefined;
|
|
445
|
-
source: "operator" | "default-metered" | "unlimited-subscription";
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
// Total over the four cases. `source` exists so the caller can tell the two
|
|
449
|
-
// no-ceiling outcomes apart without re-deriving why.
|
|
450
|
-
//
|
|
451
|
-
// An explicitly configured value is honoured verbatim on ANY route — that is
|
|
452
|
-
// how an operator imposes a ceiling on a subscription (`budget-usd: 5`) or
|
|
453
|
-
// removes one on a metered route (`budget-usd: 0`, which still reaches
|
|
454
|
-
// `budgetDisabledWarningMessage`). The `configured !== undefined` test is what
|
|
455
|
-
// keeps 0 and negatives on the operator branch: falling back to a truthiness
|
|
456
|
-
// check would swallow the explicit disable and silently reimpose the default the
|
|
457
|
-
// operator just removed.
|
|
458
|
-
export function resolveCiBudgetCeiling(input: {
|
|
459
|
-
configured: number | undefined;
|
|
460
|
-
billingMode: CiBillingMode;
|
|
461
|
-
}): CiBudgetCeiling {
|
|
462
|
-
if (input.configured !== undefined) {
|
|
463
|
-
return { budgetUsd: input.configured, source: "operator" };
|
|
464
|
-
}
|
|
465
|
-
if (input.billingMode === "metered") {
|
|
466
|
-
return {
|
|
467
|
-
budgetUsd: CI_DEFAULT_METERED_BUDGET_USD,
|
|
468
|
-
source: "default-metered",
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
return { budgetUsd: undefined, source: "unlimited-subscription" };
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
// The loudness half. `unlimited-subscription` produces no ceiling and would
|
|
475
|
-
// otherwise be silent, which is the exact shape this module already refuses
|
|
476
|
-
// for the `<= 0` case: a disable is only safe when it is loud.
|
|
477
|
-
//
|
|
478
|
-
// Kept SEPARATE from `budgetDisabledWarningMessage`, and separate in register
|
|
479
|
-
// too — a NOTE, not a warning. The operator chose nothing wrong here; they
|
|
480
|
-
// configured nothing and the policy resolved. Merging the two would tell
|
|
481
|
-
// someone who never set `budget-usd` that they disabled something.
|
|
482
|
-
export function budgetUnlimitedNoticeMessage(
|
|
483
|
-
ceiling: CiBudgetCeiling,
|
|
484
|
-
): string | null {
|
|
485
|
-
if (ceiling.source !== "unlimited-subscription") return null;
|
|
486
|
-
return (
|
|
487
|
-
"no budget-usd ceiling was applied: this route has no per-token invoice " +
|
|
488
|
-
"credential (a Claude subscription or a free route), so a run draws on " +
|
|
489
|
-
"quota rather than a per-token invoice and the estimated cost is not a " +
|
|
490
|
-
"dollar figure to gate on. The size gate resolves from the route separately. " +
|
|
491
|
-
"Set `budget-usd: <n>` to impose a ceiling anyway."
|
|
492
|
-
);
|
|
493
|
-
}
|
|
494
|
-
|
|
495
456
|
// ---------------------------------------------------------------------------
|
|
496
457
|
// Route-aware size limits — the size gate's half of the #156 policy above.
|
|
497
458
|
// The size gate is a COST and predictability gate (review/size-gate.ts's own
|
|
@@ -575,7 +536,7 @@ export function sizeGateUnlimitedNoticeMessage(
|
|
|
575
536
|
|
|
576
537
|
// ---------------------------------------------------------------------------
|
|
577
538
|
// CI skip plan — the ONE call reviewPr's shell makes per gate. Composes
|
|
578
|
-
// ciSizeGateSkip/
|
|
539
|
+
// ciSizeGateSkip/ciLimitsGateSkip's {comment, summary} with renderStepSummary
|
|
579
540
|
// (ci/reporter.ts) and the $GITHUB_OUTPUT contract into everything the shell
|
|
580
541
|
// needs to publish, so the shell's own job is pure mechanical glue: post
|
|
581
542
|
// `comment` under `markerPrefix` if `--post`, append `summaryMarkdown` if
|
|
@@ -596,11 +557,7 @@ export interface CiGateSkipPlan {
|
|
|
596
557
|
}
|
|
597
558
|
|
|
598
559
|
// Spec 1.1's $GITHUB_OUTPUT contract for a skip: no review ran, so every
|
|
599
|
-
// finding count is 0 and there is no run dir.
|
|
600
|
-
// size skip (the gate fires before any cost estimate exists) and the
|
|
601
|
-
// estimate that tripped the ceiling for a budget skip — the same number the
|
|
602
|
-
// comment and summary already show (this module's own "same numbers"
|
|
603
|
-
// doctrine, see the module header).
|
|
560
|
+
// finding count is 0 and there is no run dir.
|
|
604
561
|
export function ciGateSkipOutputs(
|
|
605
562
|
status:
|
|
606
563
|
| "skipped-size"
|
|
@@ -608,14 +565,12 @@ export function ciGateSkipOutputs(
|
|
|
608
565
|
| "skipped-coverage"
|
|
609
566
|
| "skipped-excluded"
|
|
610
567
|
| "manual-required",
|
|
611
|
-
estimatedCostUsd: number,
|
|
612
568
|
): CiOutputs {
|
|
613
569
|
return {
|
|
614
570
|
status,
|
|
615
571
|
findings_count: 0,
|
|
616
572
|
blocking_count: 0,
|
|
617
573
|
advisory_count: 0,
|
|
618
|
-
cost_usd_est: estimatedCostUsd,
|
|
619
574
|
run_dir: "",
|
|
620
575
|
};
|
|
621
576
|
}
|
|
@@ -629,7 +584,7 @@ export function planCiSizeSkip(
|
|
|
629
584
|
comment: skip.comment,
|
|
630
585
|
markerPrefix: SKIP_SIZE_COMMENT_MARKER,
|
|
631
586
|
summaryMarkdown: renderStepSummary(skip.summary, input.ciMode),
|
|
632
|
-
outputs: ciGateSkipOutputs("skipped-size"
|
|
587
|
+
outputs: ciGateSkipOutputs("skipped-size"),
|
|
633
588
|
};
|
|
634
589
|
}
|
|
635
590
|
|
|
@@ -654,25 +609,25 @@ export function planCiExcludedSkip(input: {
|
|
|
654
609
|
},
|
|
655
610
|
input.ciMode,
|
|
656
611
|
),
|
|
657
|
-
outputs: ciGateSkipOutputs("skipped-excluded"
|
|
612
|
+
outputs: ciGateSkipOutputs("skipped-excluded"),
|
|
658
613
|
};
|
|
659
614
|
}
|
|
660
615
|
|
|
661
|
-
export function
|
|
662
|
-
input:
|
|
616
|
+
export function planCiLimitsSkip(
|
|
617
|
+
input: CiLimitsGateSkipInput & { force: boolean; ciMode: CiMode },
|
|
663
618
|
): CiGateSkipPlan | null {
|
|
664
619
|
// CI `--force` is the `/crysk review` comment. It answers "run this one
|
|
665
|
-
// anyway" for every CI skip, including the
|
|
666
|
-
//
|
|
667
|
-
// here: the caller only invokes this plan when `isCi` is set.
|
|
620
|
+
// anyway" for every CI skip, including the platform limits. The platform
|
|
621
|
+
// also omits the limits for a forced dispatch. Local `--force` never
|
|
622
|
+
// reaches here: the caller only invokes this plan when `isCi` is set.
|
|
668
623
|
if (input.force) return null;
|
|
669
|
-
const skip =
|
|
624
|
+
const skip = ciLimitsGateSkip(input);
|
|
670
625
|
if (skip === null) return null;
|
|
671
626
|
return {
|
|
672
627
|
comment: skip.comment,
|
|
673
628
|
markerPrefix: SKIP_BUDGET_COMMENT_MARKER,
|
|
674
629
|
summaryMarkdown: renderStepSummary(skip.summary, input.ciMode),
|
|
675
|
-
outputs: ciGateSkipOutputs("skipped-budget"
|
|
630
|
+
outputs: ciGateSkipOutputs("skipped-budget"),
|
|
676
631
|
};
|
|
677
632
|
}
|
|
678
633
|
|
|
@@ -752,10 +707,12 @@ function buildManualRequiredComment(
|
|
|
752
707
|
"",
|
|
753
708
|
"What the gate does with the next pushes: no review reads them, so it never turns green on its own. " +
|
|
754
709
|
"A red verdict stays red while a blocking finding is unanswered. A green verdict, or a red one whose " +
|
|
755
|
-
"blocking findings all have a reply from someone with write access
|
|
756
|
-
"
|
|
757
|
-
`${commandHint(OVERRIDE_COMMAND)} merges it unverified.
|
|
758
|
-
"
|
|
710
|
+
"blocking findings all have a reply from someone with write access, waits as `pending` until a review " +
|
|
711
|
+
"verifies the head or " +
|
|
712
|
+
`${commandHint(OVERRIDE_COMMAND)} merges it unverified. A reply counts when it is posted in the ` +
|
|
713
|
+
"finding's thread and starts with `applied` (a plain comment is enough), or when it is a `dismissed` " +
|
|
714
|
+
"the CI adjudicator upheld (`crysk triage reply`). Reply before you push: the gate reads the replies " +
|
|
715
|
+
"when the push arrives.",
|
|
759
716
|
"",
|
|
760
717
|
"The existing review comment still describes the last head Crysk reviewed.",
|
|
761
718
|
"",
|
|
@@ -842,7 +799,7 @@ export function planCiReviewSkip(input: {
|
|
|
842
799
|
),
|
|
843
800
|
markerPrefix: SKIP_COVERAGE_COMMENT_MARKER,
|
|
844
801
|
summaryMarkdown: renderStepSummary(summary, input.ciMode),
|
|
845
|
-
outputs: ciGateSkipOutputs("skipped-coverage"
|
|
802
|
+
outputs: ciGateSkipOutputs("skipped-coverage"),
|
|
846
803
|
};
|
|
847
804
|
}
|
|
848
805
|
|
|
@@ -875,7 +832,7 @@ export function planCiReviewManualRequired(input: {
|
|
|
875
832
|
),
|
|
876
833
|
markerPrefix: MANUAL_REQUIRED_COMMENT_MARKER,
|
|
877
834
|
summaryMarkdown: renderStepSummary(summary, input.ciMode),
|
|
878
|
-
outputs: ciGateSkipOutputs("manual-required"
|
|
835
|
+
outputs: ciGateSkipOutputs("manual-required"),
|
|
879
836
|
};
|
|
880
837
|
}
|
|
881
838
|
|
|
@@ -898,7 +855,6 @@ export function planCiReview(input: {
|
|
|
898
855
|
prNumber: number;
|
|
899
856
|
headSha: string;
|
|
900
857
|
findings: readonly Finding[];
|
|
901
|
-
costUsdEst: number;
|
|
902
858
|
wallMs: number;
|
|
903
859
|
model: string;
|
|
904
860
|
repoWebUrl?: string;
|
|
@@ -914,7 +870,6 @@ export function planCiReview(input: {
|
|
|
914
870
|
prNumber: input.prNumber,
|
|
915
871
|
headSha: input.headSha,
|
|
916
872
|
findings: input.findings,
|
|
917
|
-
costUsdEst: input.costUsdEst,
|
|
918
873
|
wallMs: input.wallMs,
|
|
919
874
|
model: input.model,
|
|
920
875
|
...(input.repoWebUrl === undefined ? {} : { repoWebUrl: input.repoWebUrl }),
|
|
@@ -927,7 +882,6 @@ export function planCiReview(input: {
|
|
|
927
882
|
findings_count: input.findings.length,
|
|
928
883
|
blocking_count: blockingCount,
|
|
929
884
|
advisory_count: input.findings.length - blockingCount,
|
|
930
|
-
cost_usd_est: input.costUsdEst,
|
|
931
885
|
run_dir: input.runDir,
|
|
932
886
|
},
|
|
933
887
|
};
|
|
@@ -960,7 +914,7 @@ export function shouldWriteCiOutputs(
|
|
|
960
914
|
|
|
961
915
|
// Spec 2.1: step-summary writing is additionally gated on the tri-state
|
|
962
916
|
// `--step-summary`/`--no-step-summary` flag (`stepSummary`), unset meaning
|
|
963
|
-
// the shell's own default of on — mirroring `summary
|
|
917
|
+
// the shell's own default of on — mirroring `summary`'s own
|
|
964
918
|
// unset-means-default convention (preflight.ts's CliOptions).
|
|
965
919
|
export function shouldWriteStepSummary(
|
|
966
920
|
isCi: boolean,
|