crysk 0.5.1 → 0.6.1
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 +15 -1
- package/dist/SKILL-nncgwkx7.md +553 -0
- package/dist/cli.js +6379 -5561
- package/dist/index.js +967 -467
- package/dist/workflow-ag62s87j.yml +163 -0
- package/package.json +3 -2
- package/skills/crysk-ci-setup/assets/workflow.yml +3 -0
- package/skills/crysk-loop/SKILL.md +2 -2
- package/src/asset-manifest.ts +11 -0
- package/src/assets.ts +34 -11
- package/src/ci/credential-refresh.ts +524 -0
- package/src/ci/crysk-secrets.ts +20 -6
- package/src/ci/gates.ts +2 -24
- package/src/ci/outcome.ts +165 -15
- package/src/ci/platform.ts +205 -7
- package/src/ci/setup.ts +64 -6
- package/src/ci/trigger.ts +84 -8
- package/src/commands/ci-setup.ts +12 -3
- package/src/commands/doctor.ts +25 -23
- package/src/commands/status.ts +2 -0
- package/src/diversity/identity.ts +11 -1
- package/src/diversity/pipeline-integration.ts +19 -6
- package/src/doctor.ts +133 -4
- package/src/execution/contracts.ts +15 -3
- package/src/harness/materiality-judge.ts +153 -0
- package/src/harness/pipeline-plan.ts +133 -0
- package/src/harness/replay-rows.ts +172 -0
- package/src/harness/route-runner.ts +288 -0
- package/src/harness/single-step.ts +153 -0
- package/src/index.ts +1 -1
- package/src/model/catalog.ts +10 -7
- package/src/model/model-name.ts +14 -0
- package/src/model/profiles/claude.ts +34 -0
- package/src/model/profiles/openai.ts +44 -0
- package/src/model/profiles.ts +213 -0
- package/src/model/routing.ts +155 -50
- package/src/pr/answered-findings.ts +3 -0
- package/src/pr/ci-admission-gate.ts +1 -0
- package/src/pr/discovery.ts +1 -0
- package/src/pr/plan.ts +6 -1
- package/src/pr/pr-status.ts +18 -3
- package/src/pr/publish-outcome.ts +14 -13
- package/src/pr/review-pr.ts +49 -8
- package/src/pr/target.ts +16 -7
- package/src/production-runtime.ts +100 -13
- package/src/rereview/prepare.ts +13 -2
- package/src/review/exit-code.ts +60 -0
- package/src/review/findings.ts +3 -3
- package/src/review/pipeline.ts +193 -58
- package/src/review/preflight.ts +100 -10
- package/src/review/prompt-set.ts +73 -0
- package/src/review/review.ts +32 -13
- package/src/review/route-preflight.ts +117 -67
- package/src/review/run.ts +34 -4
- package/src/security/credential-broker.ts +21 -9
- package/src/security/oauth-providers.ts +101 -0
- package/src/transport-registry.ts +33 -0
- package/src/transports/opencode-sdk.ts +33 -1
- package/src/triage/adjudication.ts +35 -2
- package/src/ui/config-edit.ts +9 -0
- package/src/ui/config.ts +1 -0
- package/src/ui/menu.ts +9 -2
- package/src/ui/result.ts +1 -1
- package/src/updater.ts +21 -13
- package/src/watch/preflight.ts +34 -8
- package/src/watch/watch.ts +8 -4
- package/src/wizard.ts +23 -0
package/src/pr/pr-status.ts
CHANGED
|
@@ -39,8 +39,10 @@ import { bindPriorsToPosted } from "#rereview/prepare";
|
|
|
39
39
|
import { parseStateBlock, type StateFinding } from "#rereview/state";
|
|
40
40
|
import { parseFindingCommentBadge } from "#review/report";
|
|
41
41
|
import {
|
|
42
|
-
|
|
42
|
+
type AdjudicatorTrust,
|
|
43
|
+
CI_ADJUDICATOR_TRUST,
|
|
43
44
|
parseAdjudicationMarker,
|
|
45
|
+
trustedAdjudicator,
|
|
44
46
|
} from "#triage/adjudication";
|
|
45
47
|
import {
|
|
46
48
|
type ParsedTriageMarker,
|
|
@@ -149,7 +151,7 @@ const TRIGGER_COMMANDS = [REVIEW_COMMAND, REVIEW_FULL_COMMAND, RECHECK_COMMAND];
|
|
|
149
151
|
// shape has them (rereview/prepare.ts PostedForPrior): without them the marker's anchor stands.
|
|
150
152
|
export interface PrStatusReviewComment extends PrStatusComment {
|
|
151
153
|
in_reply_to_id: number | null;
|
|
152
|
-
// The GitHub login that posted it. The CI adjudicator's ruling is trusted only from
|
|
154
|
+
// The GitHub login that posted it. The CI adjudicator's ruling is trusted only from trustedAdjudicator.
|
|
153
155
|
user?: string;
|
|
154
156
|
path?: string;
|
|
155
157
|
line?: number | null;
|
|
@@ -162,6 +164,8 @@ export interface PrStatusInput {
|
|
|
162
164
|
statuses: CommitStatusFact[];
|
|
163
165
|
issueComments: PrStatusComment[];
|
|
164
166
|
reviewComments: PrStatusReviewComment[];
|
|
167
|
+
// Whose CI ruling counts. Absent is a run's standalone read: only github-actions[bot].
|
|
168
|
+
adjudicatorTrust?: AdjudicatorTrust;
|
|
165
169
|
}
|
|
166
170
|
|
|
167
171
|
// The window a pending status is trusted for, named from the constant that defines it, so
|
|
@@ -448,9 +452,20 @@ function ciVerdictOf(
|
|
|
448
452
|
id: number;
|
|
449
453
|
verdict: "upheld" | "rejected" | "inconclusive";
|
|
450
454
|
} | null = null;
|
|
455
|
+
const findingAuthor = input.reviewComments.find(
|
|
456
|
+
(c) => c.id === threadId,
|
|
457
|
+
)?.user;
|
|
451
458
|
for (const comment of input.reviewComments) {
|
|
452
459
|
if (comment.in_reply_to_id !== threadId) continue;
|
|
453
|
-
if (
|
|
460
|
+
if (
|
|
461
|
+
!trustedAdjudicator(
|
|
462
|
+
comment.user,
|
|
463
|
+
findingAuthor,
|
|
464
|
+
input.adjudicatorTrust ?? CI_ADJUDICATOR_TRUST,
|
|
465
|
+
)
|
|
466
|
+
) {
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
454
469
|
const marker = parseAdjudicationMarker(comment.body);
|
|
455
470
|
if (marker === null) continue;
|
|
456
471
|
if (marker.reply !== newestTriageId || marker.head !== input.head) continue;
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
import path from "node:path";
|
|
28
28
|
import { classifyCliError } from "#ci/classify-error";
|
|
29
29
|
import { recordReviewDelivered, writeCliRecord } from "#ci/cli-record";
|
|
30
|
-
import { ciExitCode } from "#ci/gates";
|
|
31
30
|
import {
|
|
32
31
|
ingestReviewMetrics,
|
|
33
32
|
notionalCostInput,
|
|
@@ -42,11 +41,12 @@ import {
|
|
|
42
41
|
} from "#pr/admission";
|
|
43
42
|
import { publishCiReviewIfEligible } from "#pr/ci-publish";
|
|
44
43
|
import type { PrDiscoveryResult } from "#pr/discovery";
|
|
45
|
-
import {
|
|
44
|
+
import type { InlinePostOutcome } from "#pr/inline";
|
|
46
45
|
import type { PostMinSeverity } from "#pr/post-floor";
|
|
47
46
|
import { type PostingStageResult, postFindingsIfEnabled } from "#pr/posting";
|
|
48
47
|
import type { CiMode } from "#pr/preflight";
|
|
49
48
|
import { unresolvedBlockingCount } from "#rereview/state";
|
|
49
|
+
import { reviewExitCode } from "#review/exit-code";
|
|
50
50
|
import type { Telemetry } from "#review/findings";
|
|
51
51
|
import type { PipelineResult } from "#review/pipeline";
|
|
52
52
|
import type { CliOptions } from "#review/preflight";
|
|
@@ -359,15 +359,16 @@ export async function publishRunOutcome(
|
|
|
359
359
|
"completed",
|
|
360
360
|
"review complete",
|
|
361
361
|
);
|
|
362
|
-
//
|
|
363
|
-
//
|
|
364
|
-
//
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
362
|
+
// One table for every mode (src/review/exit-code.ts): findings never change
|
|
363
|
+
// the code (spec 2.1), an incomplete review exits 3, a review that did not
|
|
364
|
+
// happen or a dropped posting exits 1.
|
|
365
|
+
return reviewExitCode({
|
|
366
|
+
sessionFailed: result.sessionFailed,
|
|
367
|
+
...(result.noReviewerRan === undefined
|
|
368
|
+
? {}
|
|
369
|
+
: { noReviewerRan: result.noReviewerRan }),
|
|
370
|
+
runStatus: doc.run_status,
|
|
371
|
+
droppedFindingIds: posted?.droppedFindingIds.length ?? 0,
|
|
372
|
+
blockingCount,
|
|
373
|
+
});
|
|
373
374
|
}
|
package/src/pr/review-pr.ts
CHANGED
|
@@ -95,6 +95,8 @@ import {
|
|
|
95
95
|
} from "#review/preflight";
|
|
96
96
|
import { code, estimateCost } from "#review/report";
|
|
97
97
|
import {
|
|
98
|
+
claudeAuthorityRequired,
|
|
99
|
+
isBundledAgentsDir,
|
|
98
100
|
pipelineConsolidateInput,
|
|
99
101
|
pipelineMaterialityInput,
|
|
100
102
|
pipelineScoutInput,
|
|
@@ -112,6 +114,7 @@ import {
|
|
|
112
114
|
type AdjudicationOutcome,
|
|
113
115
|
adjudicationMarker,
|
|
114
116
|
CI_ADJUDICATOR_LOGIN,
|
|
117
|
+
trustedAdjudicator,
|
|
115
118
|
} from "#triage/adjudication";
|
|
116
119
|
import { dryRunHunterCount, reviewingLine } from "#ui/plan";
|
|
117
120
|
import { log, styleEnabled, terminalWidth } from "#ui/primitives";
|
|
@@ -262,9 +265,23 @@ export async function postAdjudicationReplies(input: {
|
|
|
262
265
|
commentId,
|
|
263
266
|
spawnFn: input.spawnFn,
|
|
264
267
|
}).catch(() => undefined);
|
|
265
|
-
|
|
268
|
+
// In platform mode the run posts as the platform App's bot, the login the platform's token
|
|
269
|
+
// exchange returned (CRYSK_PLATFORM_ACTOR). Its ruling counts only on a finding that bot
|
|
270
|
+
// posted, so the finding's own author is read too, as the gate's read does.
|
|
271
|
+
const platformActor = process.env.CRYSK_PLATFORM_ACTOR;
|
|
272
|
+
const findingAuthor =
|
|
273
|
+
author === undefined || author === CI_ADJUDICATOR_LOGIN
|
|
274
|
+
? undefined
|
|
275
|
+
: await readCommentAuthor({
|
|
276
|
+
operatorRoot: input.operatorRoot,
|
|
277
|
+
commentId: entry.threadId,
|
|
278
|
+
spawnFn: input.spawnFn,
|
|
279
|
+
}).catch(() => undefined);
|
|
280
|
+
if (
|
|
281
|
+
!trustedAdjudicator(author, findingAuthor, { kind: "ci", platformActor })
|
|
282
|
+
) {
|
|
266
283
|
process.stdout.write(
|
|
267
|
-
`::warning::crysk: the CI adjudication for ${entry.priorId} was not recorded under ${CI_ADJUDICATOR_LOGIN}; the finding still counts toward the gate\n`,
|
|
284
|
+
`::warning::crysk: the CI adjudication for ${entry.priorId} was not recorded under ${CI_ADJUDICATOR_LOGIN} or the platform's bot; the finding still counts toward the gate\n`,
|
|
268
285
|
);
|
|
269
286
|
}
|
|
270
287
|
}
|
|
@@ -281,7 +298,16 @@ export async function reviewPr(
|
|
|
281
298
|
// module.
|
|
282
299
|
const step1 = await resolvePrRunOptions(options, prArg);
|
|
283
300
|
options = step1.options;
|
|
284
|
-
const {
|
|
301
|
+
const {
|
|
302
|
+
operatorRoot,
|
|
303
|
+
prNumber,
|
|
304
|
+
home,
|
|
305
|
+
isCi,
|
|
306
|
+
loaded,
|
|
307
|
+
config,
|
|
308
|
+
summary,
|
|
309
|
+
profile,
|
|
310
|
+
} = step1;
|
|
285
311
|
// S5: the Claude credential this run uses, chosen once, here, from
|
|
286
312
|
// `credentials.claude` and what is set. The CI ceiling, the admission, every
|
|
287
313
|
// runner and binding, and the child read its env, which holds that one
|
|
@@ -310,6 +336,7 @@ export async function reviewPr(
|
|
|
310
336
|
loaded,
|
|
311
337
|
config,
|
|
312
338
|
summary,
|
|
339
|
+
profile,
|
|
313
340
|
isCi,
|
|
314
341
|
operatorRoot,
|
|
315
342
|
claudeRun,
|
|
@@ -718,6 +745,7 @@ export async function reviewPr(
|
|
|
718
745
|
config,
|
|
719
746
|
summary,
|
|
720
747
|
loaded,
|
|
748
|
+
profile,
|
|
721
749
|
isCi,
|
|
722
750
|
ciMode,
|
|
723
751
|
statusContext,
|
|
@@ -782,7 +810,11 @@ export async function reviewPr(
|
|
|
782
810
|
await withCiWorkflowGroup(isCi, "crysk review", log, async () => {
|
|
783
811
|
log(reviewingLine(hunterCount, summary, options));
|
|
784
812
|
// runnerAuthority resolved before confirm with the exact-binding gate.
|
|
785
|
-
|
|
813
|
+
// A plan with no claude-code route never starts the Claude CLI.
|
|
814
|
+
if (
|
|
815
|
+
runnerAuthority.error !== undefined &&
|
|
816
|
+
claudeAuthorityRequired(routePlan)
|
|
817
|
+
) {
|
|
786
818
|
throw new CliError(
|
|
787
819
|
`execution authority unavailable: ${runnerAuthority.error}`,
|
|
788
820
|
);
|
|
@@ -847,6 +879,8 @@ export async function reviewPr(
|
|
|
847
879
|
gotchasPath,
|
|
848
880
|
agentsDir,
|
|
849
881
|
...(agents.files ? { agentFiles: agents.files } : {}),
|
|
882
|
+
// The same answer the plan was built with (pr/plan.ts).
|
|
883
|
+
...(isBundledAgentsDir(agents) ? { bundledAgents: true } : {}),
|
|
850
884
|
runDir,
|
|
851
885
|
outPath: path.join(runDir, "findings.json"),
|
|
852
886
|
mcpConfigPath,
|
|
@@ -854,12 +888,19 @@ export async function reviewPr(
|
|
|
854
888
|
...(options.model ? { model: options.model } : {}),
|
|
855
889
|
parityTriggerPaths: config.parity_trigger_paths,
|
|
856
890
|
suspicionPriors: config.suspicion_priors,
|
|
857
|
-
|
|
858
|
-
...(skipDiscovery
|
|
859
|
-
|
|
891
|
+
modelProfile: profile,
|
|
892
|
+
...(skipDiscovery
|
|
893
|
+
? {}
|
|
894
|
+
: pipelineSummarizerInput(summary, { profile })),
|
|
895
|
+
...(skipDiscovery
|
|
896
|
+
? {}
|
|
897
|
+
: pipelineScoutInput(options, { profile })),
|
|
898
|
+
...(skipDiscovery ? {} : pipelineConsolidateInput({ profile })),
|
|
860
899
|
// Gated on skipDiscovery like consolidation: an empty-delta
|
|
861
900
|
// re-review posts no new findings, so there is nothing to judge.
|
|
862
|
-
...(skipDiscovery
|
|
901
|
+
...(skipDiscovery
|
|
902
|
+
? {}
|
|
903
|
+
: pipelineMaterialityInput(config, { profile })),
|
|
863
904
|
prTitle: target.title,
|
|
864
905
|
...(resolveSharedPrefix(options) ? { sharedPrefix: true } : {}),
|
|
865
906
|
// NOT gated on skipDiscovery: an empty-delta re-review still
|
package/src/pr/target.ts
CHANGED
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
} from "#review/preflight";
|
|
48
48
|
import type { ParsedAgent, PromptSetIdentity } from "#review/prompt-set";
|
|
49
49
|
import type { estimateCost } from "#review/report";
|
|
50
|
-
import { buildCliRoutePlan } from "#review/route-preflight";
|
|
50
|
+
import { buildCliRoutePlan, isBundledAgentsDir } from "#review/route-preflight";
|
|
51
51
|
import {
|
|
52
52
|
type LoadedRunConfig,
|
|
53
53
|
loadRunConfig,
|
|
@@ -79,6 +79,7 @@ export interface ResolvedPrRunOptions {
|
|
|
79
79
|
loaded: LoadedRunConfig["loaded"];
|
|
80
80
|
config: LoadedRunConfig["config"];
|
|
81
81
|
summary: LoadedRunConfig["summary"];
|
|
82
|
+
profile: LoadedRunConfig["profile"];
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
// Step 1's first half: the operator root, the PR number, `home`, and the
|
|
@@ -112,12 +113,14 @@ export async function resolvePrRunOptions(
|
|
|
112
113
|
// yet at this point, and a `.crysk/config.json` committed by the PR author
|
|
113
114
|
// must stay unread (O-8). Same loader as local mode, so the two modes
|
|
114
115
|
// cannot drift on precedence.
|
|
115
|
-
const { loaded, config, summary, scout, post } = await loadRunConfig(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
const { loaded, config, summary, scout, post, profile } = await loadRunConfig(
|
|
117
|
+
{
|
|
118
|
+
root: operatorRoot,
|
|
119
|
+
home,
|
|
120
|
+
configFlag: options.config,
|
|
121
|
+
options,
|
|
122
|
+
},
|
|
123
|
+
);
|
|
121
124
|
// ROADMAP Pillar 3 (GitHub Actions CI). isCi folds in HERE, alongside
|
|
122
125
|
// scout/post, so `options.yes` carries the headless bypass (spec 2.1:
|
|
123
126
|
// "MUST run headlessly ... equivalent to --yes") through every downstream
|
|
@@ -138,6 +141,7 @@ export async function resolvePrRunOptions(
|
|
|
138
141
|
loaded,
|
|
139
142
|
config,
|
|
140
143
|
summary,
|
|
144
|
+
profile,
|
|
141
145
|
};
|
|
142
146
|
}
|
|
143
147
|
|
|
@@ -189,6 +193,8 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
189
193
|
operatorRoot: string;
|
|
190
194
|
// The summarizer's settings, for its route (openCodeRouteProviders).
|
|
191
195
|
summary: LoadedRunConfig["summary"];
|
|
196
|
+
// The run's profile (openai-profile S3), for the same routes.
|
|
197
|
+
profile: LoadedRunConfig["profile"];
|
|
192
198
|
// S5: the run's Claude credential, chosen once at run start (reviewPr). Its env
|
|
193
199
|
// holds only the chosen credential, so the ceiling follows the choice: the
|
|
194
200
|
// subscription has no metered ceiling, the API key keeps it. Absent (tests that
|
|
@@ -201,6 +207,7 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
201
207
|
const { agents, spec, agentFiles, promptSet } = await resolvePromptSet(
|
|
202
208
|
params.options,
|
|
203
209
|
params.loaded,
|
|
210
|
+
{ profile: params.profile },
|
|
204
211
|
);
|
|
205
212
|
// The OpenCode half from the routes the run can take, not from the auth file
|
|
206
213
|
// existing (cryskai/platform#12): a file built for a ChatGPT subscription, one
|
|
@@ -216,8 +223,10 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
216
223
|
spec,
|
|
217
224
|
options: params.options,
|
|
218
225
|
agentFiles,
|
|
226
|
+
bundledAgents: isBundledAgentsDir(agents),
|
|
219
227
|
models: params.config.models,
|
|
220
228
|
summary: params.summary,
|
|
229
|
+
profile: params.profile,
|
|
221
230
|
}),
|
|
222
231
|
authFilePresent: existsSync(resolveOpenCodeAuthPath()),
|
|
223
232
|
openCodeSecretNames: readOpenCodeSecretNames(),
|
|
@@ -8,6 +8,12 @@ import {
|
|
|
8
8
|
type ModelVariantsProbe,
|
|
9
9
|
} from "#model/free-discovery";
|
|
10
10
|
import type { ModelsConfig } from "#model/model-name";
|
|
11
|
+
import {
|
|
12
|
+
FALLBACK_PROFILE,
|
|
13
|
+
type ModelProfile,
|
|
14
|
+
profileModelAlias,
|
|
15
|
+
profileRoute,
|
|
16
|
+
} from "#model/profiles";
|
|
11
17
|
import type { ProviderCapabilityReport } from "#model/provider-capabilities";
|
|
12
18
|
import {
|
|
13
19
|
type CapabilityGateDecision,
|
|
@@ -80,6 +86,10 @@ import {
|
|
|
80
86
|
resolveOpenCodeAuthPath,
|
|
81
87
|
} from "./security/credential-broker";
|
|
82
88
|
import { authorizeWorkspaceCwd } from "./security/execution-authority";
|
|
89
|
+
import {
|
|
90
|
+
REVIEW_EXPIRY_MARGIN_MS,
|
|
91
|
+
recordExpiresAt,
|
|
92
|
+
} from "./security/oauth-providers";
|
|
83
93
|
import { readOpenCodeSecretNames } from "./security/opencode-secret-manifest";
|
|
84
94
|
import {
|
|
85
95
|
type AdmitRoutePlanOptions,
|
|
@@ -874,29 +884,68 @@ export async function probeBindingsReadiness(
|
|
|
874
884
|
};
|
|
875
885
|
}
|
|
876
886
|
|
|
877
|
-
// The plan `crysk doctor` probes: the
|
|
878
|
-
//
|
|
879
|
-
// `models` names, fallbacks included, so
|
|
880
|
-
// could open is checked before a review
|
|
881
|
-
// entry: an OpenCode effort is the route's
|
|
882
|
-
// while a Claude effort is not part of
|
|
883
|
-
|
|
887
|
+
// The plan `crysk doctor` probes: the active profile's hunter and refuter (on
|
|
888
|
+
// `claude`, the sonnet hunter and opus refuter a zero-config review runs),
|
|
889
|
+
// plus one step per distinct route `models` names, fallbacks included, so
|
|
890
|
+
// every binding a configured review could open is checked before a review
|
|
891
|
+
// needs it. Distinct by route, not by entry: an OpenCode effort is the route's
|
|
892
|
+
// variant and so a binding of its own, while a Claude effort is not part of
|
|
893
|
+
// the route and is probed once.
|
|
894
|
+
//
|
|
895
|
+
// `claudeRequired: false` (model-profiles S6, doctor.ts reviewNeedsClaude)
|
|
896
|
+
// means `models` sends every step elsewhere, so the profile's two steps, which
|
|
897
|
+
// no review would run, are left out: probing them would demand a Claude binding
|
|
898
|
+
// the configuration never opens. Absent or true keeps them, as before.
|
|
899
|
+
export function buildDoctorRoutePlan(
|
|
900
|
+
models?: ModelsConfig,
|
|
901
|
+
options: {
|
|
902
|
+
readonly claudeRequired?: boolean;
|
|
903
|
+
readonly profile?: ModelProfile;
|
|
904
|
+
} = {},
|
|
905
|
+
): ResolvedRoutePlan {
|
|
906
|
+
const profile = options.profile ?? FALLBACK_PROFILE;
|
|
907
|
+
// A Claude route keeps the alias it always probed. Any other route takes the
|
|
908
|
+
// profile's seat (bundled), so its effort becomes the same OpenCode variant a
|
|
909
|
+
// review's route carries and the probe checks the binding the review opens.
|
|
910
|
+
const agent = (key: string, role: "hunter" | "refuter", seat: string) => {
|
|
911
|
+
const model = profileRoute(profile, seat).model;
|
|
912
|
+
return model.startsWith("claude:")
|
|
913
|
+
? { key, role, model: profileModelAlias(model) }
|
|
914
|
+
: { key, role };
|
|
915
|
+
};
|
|
884
916
|
const base = buildResolvedRoutePlan({
|
|
885
917
|
agents: [
|
|
886
|
-
|
|
887
|
-
|
|
918
|
+
agent("reliability", "hunter", "hunter.reliability"),
|
|
919
|
+
agent("refuter", "refuter", "refuter"),
|
|
888
920
|
],
|
|
921
|
+
bundledAgents: true,
|
|
922
|
+
profile,
|
|
889
923
|
});
|
|
890
924
|
if (models === undefined) return base;
|
|
925
|
+
// A profile step stays when it is not on Claude (openai-profile S6): under
|
|
926
|
+
// `openai` the profile's own steps are the routes a review runs.
|
|
927
|
+
const baseSteps =
|
|
928
|
+
options.claudeRequired === false
|
|
929
|
+
? base.steps.filter((step) => step.route.backend !== "claude-code")
|
|
930
|
+
: base.steps;
|
|
891
931
|
const distinct = new Map<string, ResolvedStepRoute>();
|
|
892
932
|
for (const entry of Object.values(models).flat()) {
|
|
893
933
|
const step = resolveModelEntryRoute("doctor-model", "other", entry);
|
|
934
|
+
// claudeRequired=false means no step the review runs is on Claude (a
|
|
935
|
+
// Claude judge with the gate off, say), so probing it would contradict
|
|
936
|
+
// the "not needed" answer and fail on a machine without the CLI.
|
|
937
|
+
if (
|
|
938
|
+
options.claudeRequired === false &&
|
|
939
|
+
step.route.backend === "claude-code"
|
|
940
|
+
) {
|
|
941
|
+
continue;
|
|
942
|
+
}
|
|
894
943
|
if (!distinct.has(step.routeFingerprint)) {
|
|
895
944
|
distinct.set(step.routeFingerprint, step);
|
|
896
945
|
}
|
|
897
946
|
}
|
|
898
947
|
return createResolvedRoutePlan([
|
|
899
|
-
...
|
|
948
|
+
...baseSteps,
|
|
900
949
|
...[...distinct.values()].map((step, i) => ({
|
|
901
950
|
...step,
|
|
902
951
|
stepKey: `doctor-model-${i + 1}`,
|
|
@@ -907,6 +956,11 @@ export function buildDoctorRoutePlan(models?: ModelsConfig): ResolvedRoutePlan {
|
|
|
907
956
|
export async function collectDoctorExactBindingReports(input: {
|
|
908
957
|
readonly workspaceRoot: string;
|
|
909
958
|
readonly models?: ModelsConfig;
|
|
959
|
+
// Whether any step the configuration resolves runs on the Claude CLI
|
|
960
|
+
// (doctor.ts reviewNeedsClaude). Absent: required, as before.
|
|
961
|
+
readonly claudeRequired?: boolean;
|
|
962
|
+
// The configuration's profile (openai-profile S6). Absent: the fallback.
|
|
963
|
+
readonly profile?: ModelProfile;
|
|
910
964
|
readonly authorityDeps?: ResolveRunnerAuthorityDeps;
|
|
911
965
|
readonly env?: RunnerAuthorityOptions["env"];
|
|
912
966
|
readonly observeOpenCodeIdentity?: OpenCodeIdentityObserver;
|
|
@@ -914,7 +968,12 @@ export async function collectDoctorExactBindingReports(input: {
|
|
|
914
968
|
import("./transports/opencode-client").OpenCodeSdkLike
|
|
915
969
|
>;
|
|
916
970
|
}): Promise<readonly ExactBindingCapabilityReport[]> {
|
|
917
|
-
const plan = buildDoctorRoutePlan(input.models
|
|
971
|
+
const plan = buildDoctorRoutePlan(input.models, {
|
|
972
|
+
...(input.claudeRequired === undefined
|
|
973
|
+
? {}
|
|
974
|
+
: { claudeRequired: input.claudeRequired }),
|
|
975
|
+
...(input.profile === undefined ? {} : { profile: input.profile }),
|
|
976
|
+
});
|
|
918
977
|
// U3: the doctor binds OpenCode routes the way a review's admission does, so
|
|
919
978
|
// it reads the setup step's CRYSK_* manifest too.
|
|
920
979
|
const openCodeSecretNames = planRoutes(plan).some(
|
|
@@ -1198,7 +1257,8 @@ export interface OpenCodeCredentialRefusal {
|
|
|
1198
1257
|
readonly message: string;
|
|
1199
1258
|
readonly failureClass:
|
|
1200
1259
|
| "missing_provider_record"
|
|
1201
|
-
| "missing_subscription_record"
|
|
1260
|
+
| "missing_subscription_record"
|
|
1261
|
+
| "subscription_expiring";
|
|
1202
1262
|
readonly params: {
|
|
1203
1263
|
readonly backend: "opencode";
|
|
1204
1264
|
readonly provider: string;
|
|
@@ -1285,6 +1345,7 @@ export async function openCodeCredentialRefusal(
|
|
|
1285
1345
|
openCodeSecretNames: readonly string[] | undefined,
|
|
1286
1346
|
freeVerdicts: ReadonlyMap<string, boolean>,
|
|
1287
1347
|
env: Readonly<Record<string, string | undefined>>,
|
|
1348
|
+
now: number = Date.now(),
|
|
1288
1349
|
): Promise<OpenCodeCredentialRefusal | undefined> {
|
|
1289
1350
|
const needs = new Map<
|
|
1290
1351
|
string,
|
|
@@ -1321,7 +1382,33 @@ export async function openCodeCredentialRefusal(
|
|
|
1321
1382
|
kind === "opencode_chatgpt_oauth"
|
|
1322
1383
|
? await lookupOpenCodeOAuthRecord(reader)
|
|
1323
1384
|
: await lookupOpenCodeApiRecord(reader, provider);
|
|
1324
|
-
if (lookup.ok)
|
|
1385
|
+
if (lookup.ok) {
|
|
1386
|
+
// A subscription login that would expire during the review: the review never
|
|
1387
|
+
// renews it (the broker empties a rotating provider's refresh token), so its
|
|
1388
|
+
// later steps would fail on a dead token. Refused before anything is spent.
|
|
1389
|
+
const expiresAt =
|
|
1390
|
+
kind === "opencode_chatgpt_oauth"
|
|
1391
|
+
? recordExpiresAt(lookup.record)
|
|
1392
|
+
: undefined;
|
|
1393
|
+
if (
|
|
1394
|
+
expiresAt !== undefined &&
|
|
1395
|
+
expiresAt - now <= REVIEW_EXPIRY_MARGIN_MS
|
|
1396
|
+
) {
|
|
1397
|
+
refused.push({
|
|
1398
|
+
sentence: `models name OpenCode provider ${provider} (${stepKeys.join(", ")}), but its subscription login ${expiresAt <= now ? "has expired" : `expires at ${new Date(expiresAt).toISOString()}, before the review would finish`}: the Crysk platform renews it ahead of time, or reconnect it in the Crysk dashboard (locally, run any \`opencode\` request to renew it)`,
|
|
1399
|
+
refusal: {
|
|
1400
|
+
failureClass: "subscription_expiring",
|
|
1401
|
+
params: {
|
|
1402
|
+
backend: "opencode",
|
|
1403
|
+
provider,
|
|
1404
|
+
model: step.route.modelSnapshot,
|
|
1405
|
+
step: stepKeys[0] ?? step.stepKey,
|
|
1406
|
+
},
|
|
1407
|
+
},
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
continue;
|
|
1411
|
+
}
|
|
1325
1412
|
if (
|
|
1326
1413
|
lookup.failureClass !== "missing_provider_record" &&
|
|
1327
1414
|
lookup.failureClass !== "missing_subscription_record"
|
package/src/rereview/prepare.ts
CHANGED
|
@@ -9,9 +9,9 @@ import type { Severity } from "#review/findings";
|
|
|
9
9
|
import { parseFindingCommentBadge } from "#review/report";
|
|
10
10
|
import {
|
|
11
11
|
type AdjudicationSubject,
|
|
12
|
-
CI_ADJUDICATOR_LOGIN,
|
|
13
12
|
MAX_ADJUDICATIONS_PER_RUN,
|
|
14
13
|
parseAdjudicationMarker,
|
|
14
|
+
trustedAdjudicator,
|
|
15
15
|
} from "#triage/adjudication";
|
|
16
16
|
import { parseTriageMarker } from "#triage/triage";
|
|
17
17
|
import {
|
|
@@ -981,6 +981,8 @@ export function enrichPriorsFromThreads(input: {
|
|
|
981
981
|
created_at?: string;
|
|
982
982
|
}[];
|
|
983
983
|
summaryUpdatedAt: string | null;
|
|
984
|
+
// In platform mode, the login the platform's token exchange returned (CRYSK_PLATFORM_ACTOR).
|
|
985
|
+
platformActor?: string;
|
|
984
986
|
}): PriorRecord[] {
|
|
985
987
|
const bound = bindPriorsToPosted(input.priors, input.posted);
|
|
986
988
|
return input.priors.map((prior) => {
|
|
@@ -1010,8 +1012,17 @@ export function enrichPriorsFromThreads(input: {
|
|
|
1010
1012
|
// so a verdict on an earlier head is stale and a later head needs a new
|
|
1011
1013
|
// recheck. With no headSha, no bot verdict can be shown current.
|
|
1012
1014
|
if (triage?.replyId !== undefined && input.headSha !== undefined) {
|
|
1015
|
+
// The finding itself sits among the replies (a review comment with no parent).
|
|
1016
|
+
const findingAuthor = input.replies.find((r) => r.id === parent.id)?.user;
|
|
1013
1017
|
for (const reply of thread) {
|
|
1014
|
-
if (
|
|
1018
|
+
if (
|
|
1019
|
+
!trustedAdjudicator(reply.user, findingAuthor, {
|
|
1020
|
+
kind: "ci",
|
|
1021
|
+
platformActor: input.platformActor,
|
|
1022
|
+
})
|
|
1023
|
+
) {
|
|
1024
|
+
continue;
|
|
1025
|
+
}
|
|
1015
1026
|
const adjudication = parseAdjudicationMarker(reply.body);
|
|
1016
1027
|
if (
|
|
1017
1028
|
adjudication === null ||
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// The exit code of a review, in every mode: local, `--pr`, and headless CI.
|
|
2
|
+
//
|
|
3
|
+
// The exit code says whether the TOOL did its job, never what it found.
|
|
4
|
+
// Spec 2.1, the assistant posture: "The CLI MUST NOT exit with a non-zero code
|
|
5
|
+
// merely because findings (even `blocking` ones) were discovered". The
|
|
6
|
+
// verdict belongs to the `crysk` commit status and the posted comments.
|
|
7
|
+
//
|
|
8
|
+
// 0 the review is complete, with or without findings
|
|
9
|
+
// 1 no usable review: every hunter failed, no reviewer ran, or findings that
|
|
10
|
+
// should have been posted were dropped
|
|
11
|
+
// 2 usage error (src/cli.ts, before any review starts)
|
|
12
|
+
// 3 the review is incomplete: it ran, but a step failed (a hunter, the
|
|
13
|
+
// refuter, verify, adjudicate, or the pipeline ceiling). Run it again.
|
|
14
|
+
//
|
|
15
|
+
// WHY 3 exists, instead of folding an incomplete review into 0 or 1: until
|
|
16
|
+
// this module, an incomplete review exited 0. In GitHub the job check then
|
|
17
|
+
// stayed green while the gate's own `crysk` status read "review partial", and
|
|
18
|
+
// a pipeline outside GitHub (a script running `crysk review && merge`) had no
|
|
19
|
+
// machine-readable way to learn that a reviewer never looked. Exit 1 would
|
|
20
|
+
// have fixed the signal but merged two different next steps: 1 means
|
|
21
|
+
// something is broken, 3 means retry, the same unlock the partial status
|
|
22
|
+
// names ("/pr-hero review retries it").
|
|
23
|
+
|
|
24
|
+
import type { RunStatus } from "#review/findings";
|
|
25
|
+
|
|
26
|
+
export const EXIT_REVIEW_COMPLETE = 0;
|
|
27
|
+
export const EXIT_REVIEW_FAILED = 1;
|
|
28
|
+
export const EXIT_REVIEW_INCOMPLETE = 3;
|
|
29
|
+
|
|
30
|
+
export type ReviewExitCode =
|
|
31
|
+
| typeof EXIT_REVIEW_COMPLETE
|
|
32
|
+
| typeof EXIT_REVIEW_FAILED
|
|
33
|
+
| typeof EXIT_REVIEW_INCOMPLETE;
|
|
34
|
+
|
|
35
|
+
export function reviewExitCode(input: {
|
|
36
|
+
// Every hunter failed (PipelineResult.sessionFailed).
|
|
37
|
+
readonly sessionFailed: boolean;
|
|
38
|
+
// The pipeline's own statement that no hunter ran on a run meant to review
|
|
39
|
+
// (PipelineResult.noReviewerRan). A re-review that skipped discovery on
|
|
40
|
+
// purpose leaves it false. Absent reads as false.
|
|
41
|
+
readonly noReviewerRan?: boolean;
|
|
42
|
+
// findings.json's `run_status`: "partial" whenever any step failed.
|
|
43
|
+
readonly runStatus: RunStatus;
|
|
44
|
+
// Findings the posting stage could not deliver. 0 when nothing was posted.
|
|
45
|
+
readonly droppedFindingIds: number;
|
|
46
|
+
// Accepted and deliberately NEVER read (spec 2.1): it exists so a test can
|
|
47
|
+
// pass a high blocking count and assert the code does not change, which
|
|
48
|
+
// fails loudly if a future change wires findings into the exit code.
|
|
49
|
+
readonly blockingCount?: number;
|
|
50
|
+
}): ReviewExitCode {
|
|
51
|
+
if (input.sessionFailed || input.noReviewerRan === true) {
|
|
52
|
+
return EXIT_REVIEW_FAILED;
|
|
53
|
+
}
|
|
54
|
+
// WHY a dropped posting outranks an incomplete review: a retry repairs the
|
|
55
|
+
// missing step, but findings that never reached the PR are a delivery
|
|
56
|
+
// failure the author cannot see at all.
|
|
57
|
+
if (input.droppedFindingIds > 0) return EXIT_REVIEW_FAILED;
|
|
58
|
+
if (input.runStatus === "partial") return EXIT_REVIEW_INCOMPLETE;
|
|
59
|
+
return EXIT_REVIEW_COMPLETE;
|
|
60
|
+
}
|
package/src/review/findings.ts
CHANGED
|
@@ -661,9 +661,9 @@ export function deriveTier(
|
|
|
661
661
|
// gets this power — `inconclusive` still blocks, mirroring the rule that
|
|
662
662
|
// `refuted` requires positive disproof. Silence is not a demotion.
|
|
663
663
|
if (finding.refuter_verdict === "downgraded-latent") return "advisory";
|
|
664
|
-
// The blocking tier does not change the job's exit code:
|
|
665
|
-
//
|
|
666
|
-
//
|
|
664
|
+
// The blocking tier does not change the job's exit code: reviewExitCode
|
|
665
|
+
// never reads findings (src/review/exit-code.ts, spec 2.1), and
|
|
666
|
+
// test/review/exit-code.test.ts pins that. What it does change is the pr-hero commit status, and only in
|
|
667
667
|
// gate mode (the CI default, S4): there that status, which is the required
|
|
668
668
|
// check, goes red on blocking findings. In advisory mode the tier buys only
|
|
669
669
|
// the report's loudest register: the red badge, the "Blocking" section, and
|