crysk 0.5.1 → 0.6.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 +2 -1
- package/package.json +3 -2
- package/skills/crysk-ci-setup/assets/workflow.yml +3 -0
- package/src/asset-manifest.ts +11 -0
- package/src/assets.ts +1 -1
- package/src/ci/credential-refresh.ts +524 -0
- package/src/ci/crysk-secrets.ts +20 -6
- package/src/ci/outcome.ts +165 -15
- package/src/ci/platform.ts +155 -7
- package/src/ci/setup.ts +64 -6
- package/src/ci/trigger.ts +20 -4
- package/src/commands/ci-setup.ts +12 -3
- package/src/commands/doctor.ts +25 -23
- 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/plan.ts +6 -1
- package/src/pr/review-pr.ts +32 -6
- package/src/pr/target.ts +16 -7
- package/src/production-runtime.ts +100 -13
- package/src/review/pipeline.ts +193 -58
- package/src/review/preflight.ts +91 -9
- package/src/review/prompt-set.ts +68 -0
- package/src/review/review.ts +21 -11
- 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/ui/config-edit.ts +9 -0
- package/src/ui/config.ts +1 -0
- package/src/ui/menu.ts +9 -2
- package/src/updater.ts +21 -13
- package/src/wizard.ts +23 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { Effort } from "./catalog";
|
|
2
|
+
import { CLAUDE_PROFILE } from "./profiles/claude";
|
|
3
|
+
import { OPENAI_PROFILE } from "./profiles/openai";
|
|
4
|
+
|
|
5
|
+
// Model profiles (odd/tasks/model-profiles.md S1-S3): which model and effort
|
|
6
|
+
// each step role runs, as data. Claude is one profile among others and the
|
|
7
|
+
// fallback when nothing else is chosen, not a default hard-wired into the
|
|
8
|
+
// engine.
|
|
9
|
+
//
|
|
10
|
+
// Resolution per step (routing.ts, resolveStepChoices): `--model` > the spec's
|
|
11
|
+
// own model > `models[role]` > `models.default` > a user or lab prompt set's
|
|
12
|
+
// frontmatter > the active profile > the fallback profile. A prompt set its
|
|
13
|
+
// caller marks as the bundled one (`bundledAgents`) takes its routing from the profile,
|
|
14
|
+
// never from its own frontmatter. Phase 1: no production caller sets that
|
|
15
|
+
// flag yet, so production still reads the bundled frontmatter, which equals
|
|
16
|
+
// this profile (test/fixtures/model-profiles/baseline proves both paths).
|
|
17
|
+
//
|
|
18
|
+
// Only a type import from catalog.ts on purpose: catalog.ts reads its role
|
|
19
|
+
// efforts from the fallback profile, so a value import back from there would
|
|
20
|
+
// be a load cycle. Profile modules import only types from this file.
|
|
21
|
+
|
|
22
|
+
// The roles a profile assigns. `hunter` covers every `hunter.<key>` the
|
|
23
|
+
// profile does not name in `hunters`. `refuter` covers the verifier and the
|
|
24
|
+
// adjudicator too: they run the refuter's prompt family under its step key.
|
|
25
|
+
export const PROFILE_ROLES = [
|
|
26
|
+
"hunter",
|
|
27
|
+
"refuter",
|
|
28
|
+
"consolidate",
|
|
29
|
+
"scout",
|
|
30
|
+
"summary",
|
|
31
|
+
"judge",
|
|
32
|
+
] as const;
|
|
33
|
+
export type ProfileRole = (typeof PROFILE_ROLES)[number];
|
|
34
|
+
|
|
35
|
+
export interface ProfileRoute {
|
|
36
|
+
// A model name in the new form (`claude:sonnet-latest`,
|
|
37
|
+
// `opencode:openai/gpt-5`), the same names `models` takes.
|
|
38
|
+
readonly model: string;
|
|
39
|
+
// Absent: no effort is sent, so the model runs at its provider's default
|
|
40
|
+
// level (an OpenCode route gets no variant).
|
|
41
|
+
readonly effort?: Effort;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ModelProfile {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
// A role the profile leaves out falls back to the fallback profile's.
|
|
47
|
+
readonly roles: Readonly<Partial<Record<ProfileRole, ProfileRoute>>>;
|
|
48
|
+
// Per-hunter overrides, keyed by specialty (`logic`, `parity`, ...).
|
|
49
|
+
readonly hunters?: Readonly<Record<string, ProfileRoute>>;
|
|
50
|
+
// The profile's prompt set (S4): the name of a set under
|
|
51
|
+
// `prompts/profiles/<name>/` that holds only the files that differ from the
|
|
52
|
+
// default set, every other prompt falling back to the default file by file
|
|
53
|
+
// (profilePromptSet, src/review/prompt-set.ts). Absent: the default set, as
|
|
54
|
+
// `claude` uses it. A user `agents_dir` still outranks it for the five
|
|
55
|
+
// agent files.
|
|
56
|
+
readonly promptSet?: string;
|
|
57
|
+
// What was measured on the profile's models (S5). Absent: the fallback
|
|
58
|
+
// profile's measurements, as a role the profile leaves out takes its route.
|
|
59
|
+
readonly measured?: MeasuredFacts;
|
|
60
|
+
// The models the materiality judge may run on when nothing was measured on
|
|
61
|
+
// the profile's models: an owner's choice, recorded as one and never as a
|
|
62
|
+
// measurement (openai-profile S9). `measured.judgeModels` wins when both
|
|
63
|
+
// are set. Absent: the measured list, else the fallback profile's.
|
|
64
|
+
readonly judgeModels?: readonly string[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Facts a lab run established for a profile, read by the gates that may only
|
|
68
|
+
// run on what was measured.
|
|
69
|
+
export interface MeasuredFacts {
|
|
70
|
+
// The model names (as `models` writes them) the materiality judge was
|
|
71
|
+
// measured on. `models.judge` may pick among these only, and a plan's judge
|
|
72
|
+
// runs only on one of their routes (routing.ts, judgeModelChoice and
|
|
73
|
+
// isMeasuredJudgeRoute). Absent: the fallback profile's list.
|
|
74
|
+
readonly judgeModels?: readonly string[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// THE registry: every profile the engine knows, each one data in its own
|
|
78
|
+
// module under src/model/profiles/. Engine code reads the active profile and
|
|
79
|
+
// never imports a profile module; only this file does (pinned by
|
|
80
|
+
// test/architecture/profile-registry.test.ts). Adding a profile is one module
|
|
81
|
+
// plus one line here.
|
|
82
|
+
export const MODEL_PROFILES: Readonly<Record<string, ModelProfile>> =
|
|
83
|
+
Object.freeze({
|
|
84
|
+
[CLAUDE_PROFILE.id]: CLAUDE_PROFILE,
|
|
85
|
+
[OPENAI_PROFILE.id]: OPENAI_PROFILE,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// The profile a run uses when nothing chooses one, and the one that fills a
|
|
89
|
+
// role another profile leaves out. Being the fallback is the only thing that
|
|
90
|
+
// sets it apart from any other profile.
|
|
91
|
+
export const FALLBACK_PROFILE_ID = "claude";
|
|
92
|
+
|
|
93
|
+
export function modelProfile(id: string): ModelProfile {
|
|
94
|
+
const profile = MODEL_PROFILES[id];
|
|
95
|
+
if (profile === undefined) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
`unknown model profile "${id}": known profiles are ${Object.keys(MODEL_PROFILES).join(", ")}`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
return profile;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const FALLBACK_PROFILE: ModelProfile = modelProfile(FALLBACK_PROFILE_ID);
|
|
104
|
+
|
|
105
|
+
// The active profile for a config's `profile` value (openai-profile S1, S3):
|
|
106
|
+
// the registered one, or the fallback when the config names none. The parser
|
|
107
|
+
// already refused an unknown id, so one here is a programming error.
|
|
108
|
+
export function resolveProfile(id: string | undefined): ModelProfile {
|
|
109
|
+
return id === undefined ? FALLBACK_PROFILE : modelProfile(id);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// What the `profile` key accepts, for the config parser and `crysk config`.
|
|
113
|
+
export function profileIdProblem(value: unknown): string | undefined {
|
|
114
|
+
const known = `profile must be one of ${Object.keys(MODEL_PROFILES).join(", ")}`;
|
|
115
|
+
if (typeof value !== "string") return known;
|
|
116
|
+
return Object.hasOwn(MODEL_PROFILES, value) ? undefined : known;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// The route a profile gives a step role: `hunter.<key>`, or a fixed role. A
|
|
120
|
+
// role the profile leaves out falls back to the fallback profile's (S3's last
|
|
121
|
+
// seat).
|
|
122
|
+
export function profileRoute(
|
|
123
|
+
profile: ModelProfile,
|
|
124
|
+
role: string,
|
|
125
|
+
): ProfileRoute {
|
|
126
|
+
if (role.startsWith("hunter.")) {
|
|
127
|
+
const key = role.slice("hunter.".length);
|
|
128
|
+
const own = profile.hunters?.[key] ?? profile.roles.hunter;
|
|
129
|
+
if (own !== undefined) return own;
|
|
130
|
+
return FALLBACK_PROFILE.hunters?.[key] ?? fallbackRoute("hunter");
|
|
131
|
+
}
|
|
132
|
+
if (!isProfileRole(role)) {
|
|
133
|
+
throw new Error(`no profile role "${role}"`);
|
|
134
|
+
}
|
|
135
|
+
return profile.roles[role] ?? fallbackRoute(role);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// The effort a role runs at wherever an engine path needs one: the Claude Code
|
|
139
|
+
// launch flag and the recorded step. The profile's own, else the fallback
|
|
140
|
+
// profile's for the role. An OpenCode route never gets this one: there only
|
|
141
|
+
// the profile's own effort becomes the variant (routing.ts, profileSeat), so a
|
|
142
|
+
// role the profile gives no effort runs at the provider's default level.
|
|
143
|
+
export function profileRoleEffort(profile: ModelProfile, role: string): Effort {
|
|
144
|
+
const own = profileRoute(profile, role).effort;
|
|
145
|
+
if (own !== undefined) return own;
|
|
146
|
+
const fallback = profileRoute(FALLBACK_PROFILE, role).effort;
|
|
147
|
+
if (fallback === undefined) {
|
|
148
|
+
throw new Error(
|
|
149
|
+
`${FALLBACK_PROFILE.id} profile lacks an effort for ${role}`,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
return fallback;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Every model a profile's routes name, the fallback profile's for a role it
|
|
156
|
+
// leaves out: what the CI steps and the doctor read to decide which CLIs a run
|
|
157
|
+
// may need (openai-profile S6). The judge is included: it may join a plan.
|
|
158
|
+
export function profileModels(profile: ModelProfile): string[] {
|
|
159
|
+
return [
|
|
160
|
+
...PROFILE_ROLES.map((role) => profileRoute(profile, role).model),
|
|
161
|
+
...Object.values(profile.hunters ?? {}).map((route) => route.model),
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Whether a profile id names a registered profile whose every route runs on
|
|
166
|
+
// OpenCode: what the CI steps that run before `bun install` read to name the
|
|
167
|
+
// backend of a standalone `profile` input, with no profile named here.
|
|
168
|
+
export function profileRunsOnlyOnOpenCode(id: unknown): boolean {
|
|
169
|
+
if (typeof id !== "string") return false;
|
|
170
|
+
const trimmed = id.trim();
|
|
171
|
+
if (!Object.hasOwn(MODEL_PROFILES, trimmed)) return false;
|
|
172
|
+
const profile = MODEL_PROFILES[trimmed];
|
|
173
|
+
return (
|
|
174
|
+
profile !== undefined &&
|
|
175
|
+
profileModels(profile).every((model) => model.startsWith("opencode:"))
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// The models a profile's materiality judge may run on (S5): what was measured
|
|
180
|
+
// on it, else the models its owner chose without a measurement (openai-profile
|
|
181
|
+
// S9), else the fallback profile's list, so a profile with neither judges only
|
|
182
|
+
// where the fallback would: a judge on an unmeasured model is a different
|
|
183
|
+
// judge.
|
|
184
|
+
export function profileJudgeModels(profile: ModelProfile): readonly string[] {
|
|
185
|
+
const own = profile.measured?.judgeModels ?? profile.judgeModels;
|
|
186
|
+
if (own !== undefined) return own;
|
|
187
|
+
const fallback = FALLBACK_PROFILE.measured?.judgeModels;
|
|
188
|
+
if (fallback === undefined) {
|
|
189
|
+
throw new Error(`${FALLBACK_PROFILE.id} profile lacks judgeModels`);
|
|
190
|
+
}
|
|
191
|
+
return fallback;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function isProfileRole(role: string): role is ProfileRole {
|
|
195
|
+
return (PROFILE_ROLES as readonly string[]).includes(role);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function fallbackRoute(role: ProfileRole): ProfileRoute {
|
|
199
|
+
const route = FALLBACK_PROFILE.roles[role];
|
|
200
|
+
if (route === undefined) {
|
|
201
|
+
throw new Error(`${FALLBACK_PROFILE.id} profile lacks ${role}`);
|
|
202
|
+
}
|
|
203
|
+
return route;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// A profile model in the form a prompt's frontmatter writes it: the Claude CLI
|
|
207
|
+
// alias for a `claude:<alias>-latest` name (`sonnet`), the name as written for
|
|
208
|
+
// anything else. It is what a step records as its model and what the no-plan
|
|
209
|
+
// path sends, so a zero-config run records exactly what it always recorded.
|
|
210
|
+
export function profileModelAlias(model: string): string {
|
|
211
|
+
const match = /^claude:([a-z]+)-latest$/.exec(model);
|
|
212
|
+
return match?.[1] ?? model;
|
|
213
|
+
}
|
package/src/model/routing.ts
CHANGED
|
@@ -11,6 +11,13 @@ import {
|
|
|
11
11
|
modelNameFromAlias,
|
|
12
12
|
parseModelName,
|
|
13
13
|
} from "./model-name";
|
|
14
|
+
import {
|
|
15
|
+
FALLBACK_PROFILE,
|
|
16
|
+
type ModelProfile,
|
|
17
|
+
profileJudgeModels,
|
|
18
|
+
profileModelAlias,
|
|
19
|
+
profileRoute,
|
|
20
|
+
} from "./profiles";
|
|
14
21
|
|
|
15
22
|
export type { ResolvedModelRoute, RunnerBackend };
|
|
16
23
|
|
|
@@ -65,7 +72,7 @@ export class InvalidModelError extends ModelRoutingError {}
|
|
|
65
72
|
const NEW_FORM_PREFIXES = ["claude:", "opencode:"];
|
|
66
73
|
|
|
67
74
|
// Where a step's model came from, for the error a bad one raises.
|
|
68
|
-
type ModelSource = "--model" | "spec" | "models" | "prompt";
|
|
75
|
+
type ModelSource = "--model" | "spec" | "models" | "prompt" | "profile";
|
|
69
76
|
|
|
70
77
|
function toModelName(
|
|
71
78
|
value: string,
|
|
@@ -172,17 +179,28 @@ export interface ResolveStepRouteInput {
|
|
|
172
179
|
readonly cliModel?: string;
|
|
173
180
|
readonly specModel?: string;
|
|
174
181
|
readonly frontmatterModel?: string;
|
|
182
|
+
// The active profile's model for this step's role (model-profiles S3), the
|
|
183
|
+
// seat after the prompt's own. Absent: no profile seat, so a step with no
|
|
184
|
+
// other model fails as it always did.
|
|
185
|
+
readonly profileModel?: string;
|
|
186
|
+
// That profile route's effort (openai-profile S4). It becomes the OpenCode
|
|
187
|
+
// variant only on an OpenCode route, exactly as a `models` entry's effort
|
|
188
|
+
// does; a Claude route's effort keeps riding the role effort as before, so
|
|
189
|
+
// the `claude` profile's plans do not change.
|
|
190
|
+
readonly profileEffort?: string;
|
|
175
191
|
readonly models?: ModelsConfig;
|
|
176
192
|
}
|
|
177
193
|
|
|
178
|
-
// The precedence (L5, L6 item 5):
|
|
194
|
+
// The precedence (L5, L6 item 5; model-profiles S3):
|
|
179
195
|
// 1. `--model` (cliModel), the operator's override for one run;
|
|
180
196
|
// 2. the review spec's own model for the agent (AgentSpec.model: the lab's
|
|
181
197
|
// spec and the diversity legs, whose whole point is to differ);
|
|
182
198
|
// 3. `models[role]`;
|
|
183
199
|
// 4. `models.default`;
|
|
184
|
-
// 5. the prompt's own alias, converted to `claude:<alias>-latest
|
|
185
|
-
//
|
|
200
|
+
// 5. the prompt's own alias, converted to `claude:<alias>-latest`;
|
|
201
|
+
// 6. the active profile's model for the role (profiles.ts), which already
|
|
202
|
+
// falls back to the `claude` profile role by role.
|
|
203
|
+
// 1, 2, 5 and 6 are internal or legacy inputs and keep accepting bare aliases.
|
|
186
204
|
//
|
|
187
205
|
// Only `models` holds a list. Its first model is the step's route and the rest
|
|
188
206
|
// are its fallbacks, tried in order when the provider fails the one before
|
|
@@ -228,6 +246,14 @@ function resolveStepChoices(
|
|
|
228
246
|
{ name: toModelName(input.frontmatterModel, "prompt", input.stepKey) },
|
|
229
247
|
];
|
|
230
248
|
}
|
|
249
|
+
if (input.profileModel !== undefined) {
|
|
250
|
+
const name = toModelName(input.profileModel, "profile", input.stepKey);
|
|
251
|
+
return [
|
|
252
|
+
name.backend === "opencode" && input.profileEffort !== undefined
|
|
253
|
+
? { name, effort: input.profileEffort }
|
|
254
|
+
: { name },
|
|
255
|
+
];
|
|
256
|
+
}
|
|
231
257
|
throw new ModelRoutingError(
|
|
232
258
|
`agent ${input.stepKey} has no model and no override given`,
|
|
233
259
|
);
|
|
@@ -349,8 +375,13 @@ interface RouteAgent {
|
|
|
349
375
|
// The `models` key an agent reads. A hunter reads `hunter.<specialty>`, so a
|
|
350
376
|
// diversity leg (`reliability--<leg>`) reads its base hunter's role. The
|
|
351
377
|
// refuter role also covers the verifier and the adjudicator: they run under
|
|
352
|
-
// the refuter agent's step key and so share its route.
|
|
353
|
-
|
|
378
|
+
// the refuter agent's step key and so share its route. The same key names the
|
|
379
|
+
// agent's profile role (profiles.ts).
|
|
380
|
+
export function agentModelRole(agent: {
|
|
381
|
+
readonly key: string;
|
|
382
|
+
readonly role: string;
|
|
383
|
+
readonly specialty?: string;
|
|
384
|
+
}): string | undefined {
|
|
354
385
|
if (agent.role === "hunter") return hunterRole(agent.specialty ?? agent.key);
|
|
355
386
|
if (agent.role === "refuter") return "refuter";
|
|
356
387
|
return undefined;
|
|
@@ -385,17 +416,40 @@ export interface BuildRoutePlanInput {
|
|
|
385
416
|
readonly agents: readonly RouteAgent[];
|
|
386
417
|
readonly cliModel?: string;
|
|
387
418
|
readonly models?: ModelsConfig;
|
|
419
|
+
// The active profile (S3). Absent: `claude`. Phase 1 has no config key for
|
|
420
|
+
// it, so only tests pass another.
|
|
421
|
+
readonly profile?: ModelProfile;
|
|
422
|
+
// The agents' prompt set is the engine's bundled one. Its frontmatter is
|
|
423
|
+
// then never read for routing: the profile decides (S3, "only the bundled
|
|
424
|
+
// set may drop those lines"). Absent or false: a user or lab set, whose
|
|
425
|
+
// frontmatter wins over the profile and which gets no profile seat at all,
|
|
426
|
+
// so a user prompt with no `model:` still fails as it did before profiles.
|
|
427
|
+
readonly bundledAgents?: boolean;
|
|
388
428
|
readonly frontmatterModel?: (agentKey: string) => string | undefined;
|
|
389
|
-
|
|
429
|
+
// `bundled` marks an engine-owned root prompt resolved through the active
|
|
430
|
+
// profile's prompt set (model-profiles S4): its frontmatter is then never
|
|
431
|
+
// read for routing and the profile holds the seat, the bundled agents' rule.
|
|
432
|
+
// Unmarked (the lab's direct callers, older harnesses): the frontmatter wins
|
|
433
|
+
// over the profile as before, and the summarizer has no profile seat, so a
|
|
434
|
+
// summarizer prompt with no `model:` still fails the plan.
|
|
435
|
+
readonly summarizer?: {
|
|
436
|
+
model?: string;
|
|
437
|
+
frontmatterModel?: string;
|
|
438
|
+
bundled?: boolean;
|
|
439
|
+
};
|
|
440
|
+
// `defaultModel` is the legacy spelling of the profile seat, still passed by
|
|
441
|
+
// callers that predate profiles; it outranks the profile when given.
|
|
390
442
|
readonly scout?: {
|
|
391
443
|
model?: string;
|
|
392
444
|
frontmatterModel?: string;
|
|
393
445
|
defaultModel?: string;
|
|
446
|
+
bundled?: boolean;
|
|
394
447
|
};
|
|
395
448
|
readonly consolidate?: {
|
|
396
449
|
model?: string;
|
|
397
450
|
frontmatterModel?: string;
|
|
398
451
|
defaultModel?: string;
|
|
452
|
+
bundled?: boolean;
|
|
399
453
|
};
|
|
400
454
|
// The materiality judge (odd/tasks/materiality-gate.md S14). Present only
|
|
401
455
|
// when the gate is enabled, so a run with the gate off keeps its plan's step
|
|
@@ -406,33 +460,38 @@ export interface BuildRoutePlanInput {
|
|
|
406
460
|
// The step key the materiality judge runs under in every route plan.
|
|
407
461
|
export const MATERIALITY_STEP_KEY = "materiality";
|
|
408
462
|
|
|
409
|
-
// The judge
|
|
410
|
-
// (
|
|
411
|
-
//
|
|
412
|
-
//
|
|
413
|
-
//
|
|
414
|
-
//
|
|
415
|
-
//
|
|
416
|
-
export const MATERIALITY_JUDGE_MODEL =
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
]
|
|
463
|
+
// The judge runs only on a model the active profile measured it on
|
|
464
|
+
// (profileJudgeModels; on `claude`, sonnet and opus through the Claude Code
|
|
465
|
+
// CLI). A judge on any other model or transport is a different, unmeasured
|
|
466
|
+
// judge. So `models.judge` may pick among those only, and neither `--model`
|
|
467
|
+
// nor `models.default` ever moves it (L6 item 5). MATERIALITY_JUDGE_MODEL is
|
|
468
|
+
// the alias a run with no route plan sends, read from the `claude` profile's
|
|
469
|
+
// judge.
|
|
470
|
+
export const MATERIALITY_JUDGE_MODEL = profileModelAlias(
|
|
471
|
+
profileRoute(FALLBACK_PROFILE, "judge").model,
|
|
472
|
+
);
|
|
473
|
+
// The `claude` profile's measured judge models, for callers with no profile.
|
|
474
|
+
export const MEASURED_JUDGE_MODELS: readonly string[] =
|
|
475
|
+
profileJudgeModels(FALLBACK_PROFILE);
|
|
421
476
|
|
|
422
477
|
// The judge's model, and what `models.judge` listed that it cannot use. With no
|
|
423
|
-
// `models.judge`, the measured
|
|
424
|
-
export function judgeModelChoice(
|
|
478
|
+
// `models.judge`, the active profile's judge, held to the same measured list.
|
|
479
|
+
export function judgeModelChoice(
|
|
480
|
+
models: ModelsConfig | undefined,
|
|
481
|
+
profile: ModelProfile = FALLBACK_PROFILE,
|
|
482
|
+
): {
|
|
425
483
|
model?: string;
|
|
426
484
|
dropped: string[];
|
|
427
485
|
} {
|
|
428
486
|
// Names only: models.judge takes no effort (D3), so an entry is its name.
|
|
429
|
-
const listed = (
|
|
430
|
-
|
|
431
|
-
)
|
|
432
|
-
const
|
|
487
|
+
const listed = (models?.judge ?? [profileRoute(profile, "judge").model]).map(
|
|
488
|
+
(entry) => modelEntry(entry).name,
|
|
489
|
+
);
|
|
490
|
+
const measured = profileJudgeModels(profile);
|
|
491
|
+
const usable = listed.filter((name) => measured.includes(name));
|
|
433
492
|
return {
|
|
434
493
|
...(usable.length === 0 ? {} : { model: usable[0] }),
|
|
435
|
-
dropped: listed.filter((name) => !
|
|
494
|
+
dropped: listed.filter((name) => !measured.includes(name)),
|
|
436
495
|
};
|
|
437
496
|
}
|
|
438
497
|
|
|
@@ -442,31 +501,57 @@ export function judgeModelChoice(models: ModelsConfig | undefined): {
|
|
|
442
501
|
// keeps route admission from gating the run on a step that will never spawn.
|
|
443
502
|
export function resolveMaterialityJudgeRoute(
|
|
444
503
|
models: ModelsConfig | undefined,
|
|
504
|
+
profile: ModelProfile = FALLBACK_PROFILE,
|
|
445
505
|
): ResolvedStepRoute | undefined {
|
|
446
|
-
const { model } = judgeModelChoice(models);
|
|
506
|
+
const { model } = judgeModelChoice(models, profile);
|
|
447
507
|
if (model === undefined) return undefined;
|
|
448
508
|
return stepRouteFor(MATERIALITY_STEP_KEY, "other", {
|
|
449
509
|
name: parseModelName(model),
|
|
450
510
|
});
|
|
451
511
|
}
|
|
452
512
|
|
|
453
|
-
//
|
|
454
|
-
//
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
513
|
+
// Whether a route is one the active profile measured the judge on: the same
|
|
514
|
+
// backend, provider and model as a measured name's route. On `claude`, sonnet
|
|
515
|
+
// or opus through the Claude Code CLI talking to Anthropic; a pinned id
|
|
516
|
+
// (`claude-sonnet-5-5`) is a different model. The variant is not compared:
|
|
517
|
+
// the judge takes no effort (D3), so its route carries none.
|
|
518
|
+
export function isMeasuredJudgeRoute(
|
|
519
|
+
route: ResolvedModelRoute,
|
|
520
|
+
profile: ModelProfile = FALLBACK_PROFILE,
|
|
521
|
+
): boolean {
|
|
522
|
+
return profileJudgeModels(profile).some((name) => {
|
|
523
|
+
const measured = resolveModelRoute(name);
|
|
524
|
+
return (
|
|
525
|
+
route.backend === measured.backend &&
|
|
526
|
+
route.provider === measured.provider &&
|
|
527
|
+
route.modelSnapshot === measured.modelSnapshot
|
|
528
|
+
);
|
|
529
|
+
});
|
|
461
530
|
}
|
|
462
531
|
|
|
463
532
|
export function buildResolvedRoutePlan(
|
|
464
533
|
input: BuildRoutePlanInput,
|
|
465
534
|
): ResolvedRoutePlan {
|
|
466
535
|
assertHunterRolesExist(input.models, input.agents);
|
|
536
|
+
const profile = input.profile ?? FALLBACK_PROFILE;
|
|
537
|
+
// A role's profile seat: its model, and its effort when it has one. Reached
|
|
538
|
+
// only when no `models` entry and no prompt names the step's model, so an
|
|
539
|
+
// override on another model never inherits the profile's effort.
|
|
540
|
+
const profileSeat = (role: string) => {
|
|
541
|
+
const { model, effort } = profileRoute(profile, role);
|
|
542
|
+
return effort === undefined
|
|
543
|
+
? { profileModel: model }
|
|
544
|
+
: { profileModel: model, profileEffort: effort };
|
|
545
|
+
};
|
|
467
546
|
const stepRoutes: ResolvedStepRoute[] = [];
|
|
468
547
|
for (const agent of input.agents) {
|
|
469
548
|
const modelRole = agentModelRole(agent);
|
|
549
|
+
const prompt =
|
|
550
|
+
input.bundledAgents === true
|
|
551
|
+
? modelRole === undefined
|
|
552
|
+
? {}
|
|
553
|
+
: profileSeat(modelRole)
|
|
554
|
+
: { frontmatterModel: input.frontmatterModel?.(agent.key) };
|
|
470
555
|
stepRoutes.push(
|
|
471
556
|
resolveStepRoute({
|
|
472
557
|
stepKey: agentStepKey(agent),
|
|
@@ -474,7 +559,7 @@ export function buildResolvedRoutePlan(
|
|
|
474
559
|
...(modelRole === undefined ? {} : { modelRole }),
|
|
475
560
|
cliModel: input.cliModel,
|
|
476
561
|
specModel: agent.model,
|
|
477
|
-
|
|
562
|
+
...prompt,
|
|
478
563
|
models: input.models,
|
|
479
564
|
}),
|
|
480
565
|
);
|
|
@@ -487,7 +572,11 @@ export function buildResolvedRoutePlan(
|
|
|
487
572
|
modelRole: "summary",
|
|
488
573
|
cliModel: input.cliModel,
|
|
489
574
|
specModel: input.summarizer.model,
|
|
490
|
-
|
|
575
|
+
...(input.summarizer.bundled === true
|
|
576
|
+
? profileSeat("summary")
|
|
577
|
+
: // No profile seat for an unmarked prompt: the summarizer never had
|
|
578
|
+
// a default, so one without `model:` keeps failing the plan.
|
|
579
|
+
{ frontmatterModel: input.summarizer.frontmatterModel }),
|
|
491
580
|
models: input.models,
|
|
492
581
|
}),
|
|
493
582
|
);
|
|
@@ -500,8 +589,13 @@ export function buildResolvedRoutePlan(
|
|
|
500
589
|
modelRole: "scout",
|
|
501
590
|
// `--model` outranks `--scout-model`, as the scout step records it.
|
|
502
591
|
cliModel: input.cliModel ?? input.scout.model,
|
|
503
|
-
|
|
504
|
-
|
|
592
|
+
...(input.scout.bundled === true
|
|
593
|
+
? {}
|
|
594
|
+
: {
|
|
595
|
+
frontmatterModel:
|
|
596
|
+
input.scout.frontmatterModel ?? input.scout.defaultModel,
|
|
597
|
+
}),
|
|
598
|
+
...profileSeat("scout"),
|
|
505
599
|
models: input.models,
|
|
506
600
|
}),
|
|
507
601
|
);
|
|
@@ -513,26 +607,37 @@ export function buildResolvedRoutePlan(
|
|
|
513
607
|
role: "other",
|
|
514
608
|
modelRole: "consolidate",
|
|
515
609
|
cliModel: input.consolidate.model ?? input.cliModel,
|
|
516
|
-
|
|
517
|
-
|
|
610
|
+
...(input.consolidate.bundled === true
|
|
611
|
+
? {}
|
|
612
|
+
: {
|
|
613
|
+
frontmatterModel:
|
|
614
|
+
input.consolidate.frontmatterModel ??
|
|
615
|
+
input.consolidate.defaultModel,
|
|
616
|
+
}),
|
|
617
|
+
...profileSeat("consolidate"),
|
|
518
618
|
models: input.models,
|
|
519
619
|
}),
|
|
520
620
|
);
|
|
521
621
|
}
|
|
522
622
|
if (input.materiality) {
|
|
523
623
|
// No `cliModel` and no `models.default` on purpose (judgeModelChoice).
|
|
524
|
-
const judge = resolveMaterialityJudgeRoute(input.models);
|
|
624
|
+
const judge = resolveMaterialityJudgeRoute(input.models, profile);
|
|
525
625
|
// With no `models.judge`, the judge joins only a plan that already runs a
|
|
526
|
-
//
|
|
527
|
-
//
|
|
528
|
-
//
|
|
529
|
-
//
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
626
|
+
// step on its backend and provider (on `claude`, a Claude step): on a plan
|
|
627
|
+
// with none, the runner may hold no credential for it, and a judge it
|
|
628
|
+
// cannot bind must stand down rather than fail admission for the whole
|
|
629
|
+
// run. An explicit `models.judge` is the operator saying the judge can
|
|
630
|
+
// run, so it always joins.
|
|
631
|
+
const sharesCredential =
|
|
632
|
+
judge !== undefined &&
|
|
633
|
+
stepRoutes.some(
|
|
634
|
+
(s) =>
|
|
635
|
+
s.route.backend === judge.route.backend &&
|
|
636
|
+
s.route.provider === judge.route.provider,
|
|
637
|
+
);
|
|
533
638
|
if (
|
|
534
639
|
judge !== undefined &&
|
|
535
|
-
(input.models?.judge !== undefined ||
|
|
640
|
+
(input.models?.judge !== undefined || sharesCredential)
|
|
536
641
|
) {
|
|
537
642
|
stepRoutes.push(judge);
|
|
538
643
|
}
|
package/src/pr/plan.ts
CHANGED
|
@@ -53,10 +53,12 @@ import {
|
|
|
53
53
|
} from "#review/preflight";
|
|
54
54
|
import type { ParsedAgent } from "#review/prompt-set";
|
|
55
55
|
import { type DiffStat, estimateCost } from "#review/report";
|
|
56
|
+
import { isBundledAgentsDir } from "#review/route-preflight";
|
|
56
57
|
import {
|
|
57
58
|
enforceCapabilityGate,
|
|
58
59
|
type LoadedRunConfig,
|
|
59
60
|
resolvePipelineRoute,
|
|
61
|
+
routingConfigured,
|
|
60
62
|
} from "#review/run";
|
|
61
63
|
import type { SizeGateVerdict } from "#review/size-gate";
|
|
62
64
|
import type { ReviewSpec } from "#review/spec";
|
|
@@ -125,6 +127,7 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
125
127
|
config: LoadedRunConfig["config"];
|
|
126
128
|
summary: LoadedRunConfig["summary"];
|
|
127
129
|
loaded: LoadedRunConfig["loaded"];
|
|
130
|
+
profile: LoadedRunConfig["profile"];
|
|
128
131
|
isCi: boolean;
|
|
129
132
|
// The one resolution of the run's CI mode (resolveCiPosture, reviewPr). Passed
|
|
130
133
|
// down, never re-resolved here.
|
|
@@ -242,12 +245,14 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
242
245
|
}
|
|
243
246
|
}
|
|
244
247
|
const productionRoute = await resolvePipelineRoute({
|
|
245
|
-
modelsConfigured: params.config
|
|
248
|
+
modelsConfigured: routingConfigured(params.config),
|
|
246
249
|
workspaceRoot: params.worktreePath,
|
|
247
250
|
spec: params.spec,
|
|
248
251
|
options: params.options,
|
|
249
252
|
agentFiles: params.agentFiles,
|
|
253
|
+
bundledAgents: isBundledAgentsDir({ source: params.agentsDirSource }),
|
|
250
254
|
models: params.config.models,
|
|
255
|
+
profile: params.profile,
|
|
251
256
|
summary: params.summary,
|
|
252
257
|
summarizerEnabled: params.summary.enabled && !params.skipDiscovery,
|
|
253
258
|
scoutEnabled: params.options.scout && !params.skipDiscovery,
|