@dzhechkov/harness-core 0.8.5 → 0.8.6
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/.dz-manifest.json +49 -49
- package/README.md +6 -1
- package/dist/feature-adr-checkpoints.d.ts +11 -2
- package/dist/feature-adr-checkpoints.d.ts.map +1 -1
- package/dist/feature-adr-checkpoints.js +37 -2
- package/dist/feature-adr-checkpoints.js.map +1 -1
- package/dist/feature-adr-routing.d.ts +56 -21
- package/dist/feature-adr-routing.d.ts.map +1 -1
- package/dist/feature-adr-routing.js +187 -58
- package/dist/feature-adr-routing.js.map +1 -1
- package/dist/guard.d.ts +25 -0
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +59 -1
- package/dist/guard.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loop-blobs.generated.js +8 -8
- package/dist/loop-blobs.generated.js.map +1 -1
- package/dist/loop-plan.d.ts +13 -1
- package/dist/loop-plan.d.ts.map +1 -1
- package/dist/loop-plan.js +15 -1
- package/dist/loop-plan.js.map +1 -1
- package/dist/loop-render.d.ts.map +1 -1
- package/dist/loop-render.js +51 -6
- package/dist/loop-render.js.map +1 -1
- package/dist/loop-trace.d.ts +20 -1
- package/dist/loop-trace.d.ts.map +1 -1
- package/dist/loop-trace.js +83 -1
- package/dist/loop-trace.js.map +1 -1
- package/dist/model-recommender.d.ts +8 -0
- package/dist/model-recommender.d.ts.map +1 -1
- package/dist/model-recommender.js +31 -4
- package/dist/model-recommender.js.map +1 -1
- package/dist/workflow-run.d.ts.map +1 -1
- package/dist/workflow-run.js +18 -12
- package/dist/workflow-run.js.map +1 -1
- package/package.json +18 -15
- package/sbom.json +48 -48
- package/src/feature-adr-checkpoints.ts +38 -2
- package/src/feature-adr-routing.ts +217 -54
- package/src/guard.ts +79 -1
- package/src/index.ts +2 -1
- package/src/loop-blobs.generated.ts +8 -8
- package/src/loop-plan.ts +36 -3
- package/src/loop-render.ts +50 -6
- package/src/loop-trace.ts +91 -2
- package/src/model-recommender.ts +35 -4
- package/src/workflow-run.ts +18 -11
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
*
|
|
15
15
|
* The load-bearing property: a model that WRITES code must not also SELF-QE.
|
|
16
16
|
* When `args.models.qe` is unset, the QE stage is auto-routed to the OTHER
|
|
17
|
-
* family than the resolved coder (codex-coder → Claude `
|
|
18
|
-
*
|
|
17
|
+
* family than the resolved coder (codex-coder → Claude `sonnet`; Claude-coder →
|
|
18
|
+
* the Codex-budget cell, or `opus` if codex is unavailable — never a block).
|
|
19
19
|
*
|
|
20
20
|
* DESIGN CONSTRAINT — the Workflow parser is STRICTER than `node --check`
|
|
21
21
|
* (no nested template literals, no inline `cond ? agent() : null` in arrays).
|
|
@@ -74,11 +74,15 @@ export interface RoutingEnv {
|
|
|
74
74
|
*/
|
|
75
75
|
readonly usageOverride?: boolean;
|
|
76
76
|
/**
|
|
77
|
-
* Per-stage reasoning for the usage-override spec (merged OVER {@link
|
|
78
|
-
* `args.usageReasoning` — stage →
|
|
77
|
+
* Per-stage reasoning for the usage-override spec (merged OVER {@link STAGE_EFFORT}).
|
|
78
|
+
* `args.usageReasoning` — stage → a supported reasoning level; a single stage may be overridden without
|
|
79
79
|
* touching the others.
|
|
80
80
|
*/
|
|
81
81
|
readonly usageReasoning?: Record<string, string>;
|
|
82
|
+
/** Raw `args.budget`: a named preset or a per-family object. */
|
|
83
|
+
readonly budget?: unknown;
|
|
84
|
+
/** The productive family for design + code; absent defaults to Claude. */
|
|
85
|
+
readonly primary?: 'claude' | 'codex';
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
// ── USAGE-ADAPTIVE ROUTING (pre-emptive codex switch at >= usageThreshold) ────
|
|
@@ -109,39 +113,33 @@ export interface UsageDecision {
|
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* flow); user-overridable via `env.usageReasoning`. An unknown stage falls back to `'high'`.
|
|
116
|
+
* GPT-5.6 reasoning ladder used by the routing tables. The model default is `medium`; `xhigh`
|
|
117
|
+
* and `max` stay valid explicit values but are absent from shipped defaults until evals justify them.
|
|
115
118
|
*/
|
|
116
|
-
export
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
export type ReasoningLevel = 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
120
|
+
export const STAGE_EFFORT: { override: Record<string, ReasoningLevel> } = { override: {
|
|
121
|
+
router: 'medium',
|
|
122
|
+
requirements: 'medium',
|
|
123
|
+
research: 'medium',
|
|
124
|
+
adr: 'high',
|
|
125
|
+
ideation: 'medium',
|
|
126
|
+
ddd: 'high',
|
|
127
|
+
architecture: 'high',
|
|
128
|
+
plan: 'high',
|
|
129
|
+
code: 'medium',
|
|
126
130
|
qe: 'high',
|
|
127
|
-
fleet: '
|
|
128
|
-
};
|
|
131
|
+
fleet: 'medium',
|
|
132
|
+
} };
|
|
129
133
|
|
|
130
|
-
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
/** One-release compatibility alias for existing public imports. */
|
|
135
|
+
// Frozen (QE round-1 F10): the alias exports the SAME object as the live effort table, so a
|
|
136
|
+
// consumer mutating the compatibility alias would silently mutate shipped routing. Freezing keeps
|
|
137
|
+
// the read-compatibility promise while making any such write throw loudly in strict mode.
|
|
138
|
+
export const OVERRIDE_REASONING = Object.freeze(STAGE_EFFORT.override);
|
|
139
|
+
|
|
140
|
+
/** The flagship Codex id, independent of the spellability allowlist's insertion order. */
|
|
136
141
|
export function topCodexId(env: RoutingEnv): string {
|
|
137
|
-
|
|
138
|
-
if (top === 'auto') {
|
|
139
|
-
const ids = Object.keys(KNOWN_CODEX);
|
|
140
|
-
for (let i = 0; i < ids.length; i++) {
|
|
141
|
-
if (ids[i] !== 'auto') top = ids[i] || top;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return top;
|
|
142
|
+
return env.CODEX_MODEL !== 'auto' ? env.CODEX_MODEL : CODEX_TIERS.flagship;
|
|
145
143
|
}
|
|
146
144
|
|
|
147
145
|
/**
|
|
@@ -190,11 +188,80 @@ export function decideUsageAction(
|
|
|
190
188
|
/** Known codex ids. Adding a new id (e.g. `'gpt-5.7'`) is a DATA-ONLY change. */
|
|
191
189
|
export const KNOWN_CODEX: Record<string, number> = { auto: 1, 'gpt-5.5': 1, 'gpt-5.6': 1, 'gpt-5.6-luna': 1, 'gpt-5.6-terra': 1, 'gpt-5.6-sol': 1 };
|
|
192
190
|
|
|
191
|
+
export type CodexTier = 'flagship' | 'workhorse' | 'high-volume';
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Capability tiers are routing data, separate from {@link KNOWN_CODEX}'s spellability role.
|
|
195
|
+
* The allowlist is not an availability check — probe every id before every run
|
|
196
|
+
* (`codex exec -m <id> "Reply with exactly: OK"`); ids drift in both directions on a
|
|
197
|
+
* timescale of days (probed 2026-08-18: 3 ids HTTP 400; probed 2026-08-29: all 3 exit 0).
|
|
198
|
+
*/
|
|
199
|
+
export const CODEX_TIERS: Record<CodexTier, string> = {
|
|
200
|
+
flagship: 'gpt-5.6-sol',
|
|
201
|
+
workhorse: 'gpt-5.6-terra',
|
|
202
|
+
'high-volume': 'gpt-5.6-luna',
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export function codexIdForTier(tier: CodexTier, env: RoutingEnv): string {
|
|
206
|
+
return env.CODEX_MODEL !== 'auto' ? env.CODEX_MODEL : CODEX_TIERS[tier];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export type BudgetLevel = 'normal' | 'eco';
|
|
210
|
+
export interface BudgetAxis {
|
|
211
|
+
readonly claude: BudgetLevel;
|
|
212
|
+
readonly codex: BudgetLevel;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export const BUDGET_PRESETS: Record<'normal' | 'eco' | 'hybrid', BudgetAxis> = {
|
|
216
|
+
normal: { claude: 'normal', codex: 'normal' },
|
|
217
|
+
eco: { claude: 'eco', codex: 'eco' },
|
|
218
|
+
hybrid: { claude: 'eco', codex: 'normal' },
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export function resolveBudgetMode(raw: unknown): BudgetAxis {
|
|
222
|
+
if (raw === undefined) return BUDGET_PRESETS.normal;
|
|
223
|
+
if (typeof raw === 'string') {
|
|
224
|
+
const preset = BUDGET_PRESETS[raw as keyof typeof BUDGET_PRESETS];
|
|
225
|
+
if (!preset) throw new RangeError('budget: unknown preset "' + raw + '" — valid: normal|eco|hybrid');
|
|
226
|
+
return preset;
|
|
227
|
+
}
|
|
228
|
+
if (raw && typeof raw === 'object') {
|
|
229
|
+
const value = raw as Record<string, unknown>;
|
|
230
|
+
for (const key of Object.keys(value)) {
|
|
231
|
+
if (key !== 'claude' && key !== 'codex') {
|
|
232
|
+
throw new RangeError('budget: unknown family key "' + key + '" — valid: claude|codex');
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
for (const key of ['claude', 'codex'] as const) {
|
|
236
|
+
const level = value[key];
|
|
237
|
+
if (level !== undefined && level !== 'normal' && level !== 'eco') {
|
|
238
|
+
throw new RangeError('budget.' + key + ': unknown level "' + level + '" — valid: normal|eco');
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
claude: (value.claude as BudgetLevel | undefined) || 'normal',
|
|
243
|
+
codex: (value.codex as BudgetLevel | undefined) || 'normal',
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
throw new RangeError('budget: expected a preset name or {claude,codex} object, got ' + typeof raw);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function budgetPresetName(axis: BudgetAxis): 'normal' | 'eco' | 'hybrid' | null {
|
|
250
|
+
for (const name of ['normal', 'eco', 'hybrid'] as const) {
|
|
251
|
+
const preset = BUDGET_PRESETS[name];
|
|
252
|
+
if (preset.claude === axis.claude && preset.codex === axis.codex) return name;
|
|
253
|
+
}
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
|
|
193
257
|
/** The Claude model names the Workflow runtime accepts as `agent()` `model`. */
|
|
194
258
|
export const CLAUDE_NAMES: Record<string, number> = { fable: 1, opus: 1, sonnet: 1, haiku: 1 };
|
|
195
259
|
|
|
196
|
-
/**
|
|
197
|
-
|
|
260
|
+
/**
|
|
261
|
+
* The codex-companion `--effort` vocabulary. `minimal` remains temporarily for compatibility
|
|
262
|
+
* until a live companion probe establishes whether it can be retired; `max` is part of GPT-5.6's ladder.
|
|
263
|
+
*/
|
|
264
|
+
export const VALID_REASONING: Record<string, number> = { none: 1, minimal: 1, low: 1, medium: 1, high: 1, xhigh: 1, max: 1 };
|
|
198
265
|
|
|
199
266
|
/**
|
|
200
267
|
* The proven DEFAULT TABLE, applied only when the user opts into routing.
|
|
@@ -215,6 +282,80 @@ export const DEFAULT_MODELS: Record<string, string | null> = {
|
|
|
215
282
|
fleet: 'sonnet',
|
|
216
283
|
};
|
|
217
284
|
|
|
285
|
+
type FamilyRoutingTables = Record<'claude' | 'codex', Record<BudgetLevel, Partial<Record<string, string | null>>>>;
|
|
286
|
+
|
|
287
|
+
/** Four family half-tables; presets compose the Claude and Codex halves independently. */
|
|
288
|
+
export const ROUTING_TABLES: Record<'claude' | 'codex', FamilyRoutingTables> = {
|
|
289
|
+
claude: {
|
|
290
|
+
claude: {
|
|
291
|
+
normal: { router: 'sonnet', requirements: 'sonnet', research: 'sonnet', adr: 'fable', ideation: 'sonnet', ddd: 'fable', architecture: 'fable', plan: 'opus', code: 'sonnet', fleet: 'sonnet' },
|
|
292
|
+
eco: { router: 'sonnet', requirements: 'sonnet', research: 'sonnet', adr: 'opus', ideation: 'sonnet', ddd: 'opus', architecture: 'opus', plan: 'sonnet', code: 'sonnet', fleet: 'sonnet' },
|
|
293
|
+
},
|
|
294
|
+
codex: { normal: {}, eco: {} },
|
|
295
|
+
},
|
|
296
|
+
codex: {
|
|
297
|
+
claude: {
|
|
298
|
+
normal: { router: 'sonnet', qe: 'sonnet', fleet: 'sonnet' },
|
|
299
|
+
eco: { router: 'sonnet', qe: 'sonnet', fleet: 'sonnet' },
|
|
300
|
+
},
|
|
301
|
+
codex: { normal: {}, eco: {} },
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
function codexCell(tier: CodexTier, effort: ReasoningLevel, env: RoutingEnv): string {
|
|
306
|
+
return 'codex:' + codexIdForTier(tier, env) + ':' + effort;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export function budgetTable(
|
|
310
|
+
primary: 'claude' | 'codex',
|
|
311
|
+
mode: BudgetAxis,
|
|
312
|
+
env: RoutingEnv,
|
|
313
|
+
): Partial<Record<string, string | null>> {
|
|
314
|
+
const claudeHalf = ROUTING_TABLES[primary].claude[mode.claude];
|
|
315
|
+
let codexHalf: Partial<Record<string, string | null>>;
|
|
316
|
+
if (primary === 'claude') {
|
|
317
|
+
const qeSpec = mode.codex === 'normal'
|
|
318
|
+
? codexCell('flagship', 'high', env)
|
|
319
|
+
: codexCell('workhorse', 'medium', env);
|
|
320
|
+
codexHalf = { ...ROUTING_TABLES.claude.codex[mode.codex], qe: env.codexAvailable === false ? 'opus' : qeSpec };
|
|
321
|
+
} else {
|
|
322
|
+
const normal = mode.codex === 'normal';
|
|
323
|
+
const design = codexCell(normal ? 'flagship' : 'workhorse', normal ? 'high' : 'medium', env);
|
|
324
|
+
codexHalf = {
|
|
325
|
+
requirements: design,
|
|
326
|
+
research: design,
|
|
327
|
+
adr: design,
|
|
328
|
+
ideation: design,
|
|
329
|
+
ddd: design,
|
|
330
|
+
architecture: design,
|
|
331
|
+
plan: codexCell(normal ? 'flagship' : 'workhorse', normal ? 'high' : 'low', env),
|
|
332
|
+
code: codexCell(normal ? 'flagship' : 'workhorse', 'medium', env),
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
return { ...claudeHalf, ...codexHalf };
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** Optional Claude precision review after A-normal's recall-oriented Sonnet QE. */
|
|
339
|
+
export function qePrecisionPassSpec(
|
|
340
|
+
primary: 'claude' | 'codex',
|
|
341
|
+
budget: BudgetAxis,
|
|
342
|
+
tier: 'S' | 'M' | 'L' | 'XL',
|
|
343
|
+
_env: RoutingEnv,
|
|
344
|
+
): string | null {
|
|
345
|
+
if (primary !== 'codex') return null;
|
|
346
|
+
if (budget.claude !== 'normal') return null;
|
|
347
|
+
if (tier !== 'L' && tier !== 'XL') return null;
|
|
348
|
+
return 'opus';
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** Build/test-time guard for the matrix's load-bearing cross-family property. */
|
|
352
|
+
export function assertCrossFamilyQe(codeSpec: string | null, qeSpec: string | null): void {
|
|
353
|
+
const fam = (s: string | null) => (s && String(s).split(':')[0] === 'codex') ? 'codex' : 'claude';
|
|
354
|
+
if (fam(codeSpec) === fam(qeSpec)) {
|
|
355
|
+
throw new Error('cross-family QE violated: code=' + codeSpec + ' qe=' + qeSpec);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
218
359
|
// ── Pure resolvers (byte-equivalent to the workflow's inline block) ──────────
|
|
219
360
|
|
|
220
361
|
/**
|
|
@@ -247,11 +388,8 @@ export function specToOpts(spec: string | null | undefined, env: RoutingEnv): St
|
|
|
247
388
|
id = env.CODEX_MODEL;
|
|
248
389
|
}
|
|
249
390
|
let reasoning = parts[2] || 'high';
|
|
250
|
-
// Clamp to the codex-companion --effort vocabulary so a bad token (e.g. `codex:gpt-5.6:banana`)
|
|
251
|
-
// can't silently reach the runtime as `--effort banana` (QE LOW). Unknown ⇒ 'high'.
|
|
252
391
|
if (!VALID_REASONING[reasoning]) {
|
|
253
|
-
|
|
254
|
-
reasoning = 'high';
|
|
392
|
+
throw new RangeError('models: invalid reasoning "' + reasoning + '" — valid: ' + Object.keys(VALID_REASONING).join('|'));
|
|
255
393
|
}
|
|
256
394
|
return { agentType: 'codex:codex-rescue', codexModel: id, _reasoning: reasoning };
|
|
257
395
|
}
|
|
@@ -278,33 +416,43 @@ export function resolveCoderSpec(env: RoutingEnv): string {
|
|
|
278
416
|
* `MODELS.code='codex'` still routes QE to Claude (never codex-self-QE).
|
|
279
417
|
*/
|
|
280
418
|
export function coderIsCodex(env: RoutingEnv): boolean {
|
|
281
|
-
if (env.CODER === 'codex' || env.CODER === 'codex-fallback') return true;
|
|
282
419
|
const codeSpec = env.MODELS.code;
|
|
283
|
-
if (codeSpec && String(codeSpec).split(':')[0] === 'codex'
|
|
284
|
-
return
|
|
420
|
+
if (codeSpec !== undefined && codeSpec !== null) return String(codeSpec).split(':')[0] === 'codex';
|
|
421
|
+
if (env.CODER === 'codex' || env.CODER === 'codex-fallback') return true;
|
|
422
|
+
return env.primary === 'codex';
|
|
285
423
|
}
|
|
286
424
|
|
|
287
425
|
/**
|
|
288
426
|
* The CROSS-MODEL QE default (load-bearing). Called only when `MODELS.qe` is
|
|
289
427
|
* unset. Resolves to the OTHER family than the coder:
|
|
290
|
-
* - coder is codex → `'
|
|
291
|
-
* - coder is Claude →
|
|
292
|
-
*
|
|
428
|
+
* - coder is codex → `'sonnet'` (the recall-oriented Claude reviewer)
|
|
429
|
+
* - coder is Claude → the Codex-budget cell (`sol:high` or `terra:medium`),
|
|
430
|
+
* or `'opus'` when Codex is unavailable (never block)
|
|
431
|
+
* A pinned `CODEX_MODEL` still outranks the tier selected by the budget table.
|
|
293
432
|
*/
|
|
294
|
-
export function
|
|
295
|
-
if (
|
|
433
|
+
export function resolveQeSpecForCoder(coderCodex: boolean, env: RoutingEnv): string {
|
|
434
|
+
if (coderCodex) return 'sonnet';
|
|
296
435
|
const CODEX_AVAILABLE = env.codexAvailable !== false;
|
|
297
436
|
if (!CODEX_AVAILABLE) return 'opus';
|
|
298
|
-
|
|
437
|
+
const budget = resolveBudgetMode(env.budget);
|
|
438
|
+
return budget.codex === 'eco'
|
|
439
|
+
? 'codex:' + codexIdForTier('workhorse', env) + ':medium'
|
|
440
|
+
: 'codex:' + codexIdForTier('flagship', env) + ':high';
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export function resolveQeSpec(env: RoutingEnv): string {
|
|
444
|
+
return resolveQeSpecForCoder(coderIsCodex(env), env);
|
|
299
445
|
}
|
|
300
446
|
|
|
301
447
|
/**
|
|
302
|
-
* Whether the caller opted into routing at all. When FALSE (no `args.models`,
|
|
303
|
-
*
|
|
448
|
+
* Whether the caller opted into routing at all. When FALSE (no axes, `args.models`,
|
|
449
|
+
* or Codex knobs), every Claude stage resolves to `{}` → byte-identical to today.
|
|
304
450
|
*/
|
|
305
451
|
export function routingRequested(env: RoutingEnv): boolean {
|
|
306
452
|
return (
|
|
307
453
|
Object.keys(env.MODELS).length > 0 ||
|
|
454
|
+
env.primary !== undefined ||
|
|
455
|
+
env.budget !== undefined ||
|
|
308
456
|
env.PLANNER === 'codex' ||
|
|
309
457
|
env.CODER === 'codex' ||
|
|
310
458
|
env.CODER === 'codex-fallback' ||
|
|
@@ -338,12 +486,12 @@ export function qeShouldUseCodex(env: RoutingEnv): boolean {
|
|
|
338
486
|
* Resolve a stage to its `agent()` opts fragment.
|
|
339
487
|
* 1. explicit `MODELS[stage]` wins
|
|
340
488
|
* 2. else if the user did NOT opt into routing → `{}` (byte-identical BC path)
|
|
341
|
-
* 3. else the
|
|
489
|
+
* 3. else the primary × per-family-budget table fills the gap
|
|
342
490
|
* 4. `code`/`qe` `null` sentinels resolve via the coder / cross-model rules
|
|
343
491
|
*/
|
|
344
492
|
export function resolveStageModel(stage: string, env: RoutingEnv): StageOpts {
|
|
345
493
|
if (env.usageOverride) {
|
|
346
|
-
const r = (env.usageReasoning && env.usageReasoning[stage]) ||
|
|
494
|
+
const r = (env.usageReasoning && env.usageReasoning[stage]) || STAGE_EFFORT.override[stage] || 'medium';
|
|
347
495
|
const o = specToOpts('codex:' + topCodexId(env) + ':' + r, env);
|
|
348
496
|
o._usageSwitched = true;
|
|
349
497
|
return o;
|
|
@@ -351,7 +499,18 @@ export function resolveStageModel(stage: string, env: RoutingEnv): StageOpts {
|
|
|
351
499
|
let spec = env.MODELS[stage];
|
|
352
500
|
if (spec === undefined) {
|
|
353
501
|
if (!routingRequested(env)) return {};
|
|
354
|
-
|
|
502
|
+
if (stage === 'code' && (env.CODER === 'codex' || env.CODER === 'codex-fallback')) {
|
|
503
|
+
return specToOpts(resolveCoderSpec(env), env);
|
|
504
|
+
}
|
|
505
|
+
if (stage === 'plan' && env.PLANNER === 'codex') {
|
|
506
|
+
return specToOpts('codex:' + env.CODEX_MODEL + ':high', env);
|
|
507
|
+
}
|
|
508
|
+
if (stage === 'qe') {
|
|
509
|
+
return specToOpts(resolveQeSpec(env), env);
|
|
510
|
+
}
|
|
511
|
+
const resolvedPrimary = env.primary || 'claude';
|
|
512
|
+
const cell = budgetTable(resolvedPrimary, resolveBudgetMode(env.budget), env)[stage];
|
|
513
|
+
spec = cell !== undefined ? cell : DEFAULT_MODELS[stage];
|
|
355
514
|
}
|
|
356
515
|
if (stage === 'code' && (spec === null || spec === undefined)) return specToOpts(resolveCoderSpec(env), env);
|
|
357
516
|
if (stage === 'qe' && (spec === null || spec === undefined)) return specToOpts(resolveQeSpec(env), env);
|
|
@@ -1545,6 +1704,7 @@ function codexCd(repo: string): string {
|
|
|
1545
1704
|
*/
|
|
1546
1705
|
export function codexExecCommand(input: {
|
|
1547
1706
|
readonly modelId?: string | null;
|
|
1707
|
+
readonly reasoning?: string | null;
|
|
1548
1708
|
readonly prompt?: string | null;
|
|
1549
1709
|
readonly timeoutBin?: string | null;
|
|
1550
1710
|
readonly timeoutSeconds?: number | null;
|
|
@@ -1553,12 +1713,15 @@ export function codexExecCommand(input: {
|
|
|
1553
1713
|
const o = input || {};
|
|
1554
1714
|
const modelId = String(o.modelId === undefined || o.modelId === null ? '' : o.modelId);
|
|
1555
1715
|
if (!isSafeCodexId(modelId)) return null;
|
|
1716
|
+
const reasoning = o.reasoning === undefined || o.reasoning === null || o.reasoning === '' ? 'high' : String(o.reasoning);
|
|
1717
|
+
if (!VALID_REASONING[reasoning]) return null;
|
|
1556
1718
|
const raw = Number(o.timeoutSeconds);
|
|
1557
1719
|
const seconds = raw === raw && raw !== Infinity && raw > 0 ? Math.floor(raw) : CODEX_EXEC_TIMEOUT_SECONDS;
|
|
1558
1720
|
const repo = String(o.repo === undefined || o.repo === null ? '' : o.repo);
|
|
1559
1721
|
const cd = repo === '' ? '' : ' -C ' + codexSq(repo);
|
|
1560
1722
|
return timeoutBinOrDefault(o.timeoutBin) + ' ' + seconds + ' codex exec' + cd
|
|
1561
|
-
+ ' -m ' + codexSq(modelId) + ' ' + codexSq(
|
|
1723
|
+
+ ' -m ' + codexSq(modelId) + ' -c model_reasoning_effort=' + codexSq(reasoning)
|
|
1724
|
+
+ ' ' + codexSq(String(o.prompt === undefined || o.prompt === null ? '' : o.prompt)) + ' < /dev/null';
|
|
1562
1725
|
}
|
|
1563
1726
|
|
|
1564
1727
|
export function codexReviewCommand(input: CodexReviewCommandInput): CodexReviewCommandResult {
|
package/src/guard.ts
CHANGED
|
@@ -69,6 +69,29 @@ export interface GuardFacts {
|
|
|
69
69
|
readonly counts?: readonly { readonly label: string; readonly a: number; readonly b: number }[];
|
|
70
70
|
/** for store-bloat-cap: current learned-store size vs its cap. */
|
|
71
71
|
readonly store?: { readonly count: number; readonly cap: number };
|
|
72
|
+
/** Advisory freshness evidence for the auto-cost outcome store. Missing evidence fails open. */
|
|
73
|
+
readonly routingFreshness?: { readonly unfedRunIds: readonly string[] };
|
|
74
|
+
/**
|
|
75
|
+
* for marketplace-parity: the CLI's read-only regeneration result. The whole field being absent
|
|
76
|
+
* means evidence could not be gathered, so this advisory rule reports nothing.
|
|
77
|
+
*/
|
|
78
|
+
readonly marketplaceParity?: {
|
|
79
|
+
/** false ⇒ this repository has no .claude-plugin/ showcase and is out of scope. */
|
|
80
|
+
readonly applicable: boolean;
|
|
81
|
+
/** true ⇒ exactly one of plugin.json / marketplace.json is present. */
|
|
82
|
+
readonly onlyOnePresent?: boolean;
|
|
83
|
+
/** true ⇒ registry-derived composition differs from a fresh regeneration. */
|
|
84
|
+
readonly diverged?: boolean;
|
|
85
|
+
/** Operator-owned published version, carried only to render the exact repair command. */
|
|
86
|
+
readonly publishedVersion?: string;
|
|
87
|
+
/** Existing published manifests that could not be read or parsed. */
|
|
88
|
+
readonly manifestFailures?: readonly {
|
|
89
|
+
readonly file: 'plugin.json' | 'marketplace.json';
|
|
90
|
+
readonly error: string;
|
|
91
|
+
}[];
|
|
92
|
+
/** true ⇒ regeneration was attempted but could not complete. */
|
|
93
|
+
readonly regenerateFailed?: boolean;
|
|
94
|
+
};
|
|
72
95
|
/** for skills-registrable: per skill pack, dirs that would ship un-registrable (no depth-1 SKILL.md). */
|
|
73
96
|
readonly skillPacks?: readonly { readonly name: string; readonly nonRegistrable: readonly string[] }[];
|
|
74
97
|
/** for readme-first: per publishable package, is a version bump staged without a README change? */
|
|
@@ -262,6 +285,8 @@ export const DEFAULT_RULES: readonly GuardRule[] = [
|
|
|
262
285
|
{ id: 'readme-consistency', severity: 'soft', ops: ['publish'], description: 'README counts agree (CJM header vs All Commands, etc.)' },
|
|
263
286
|
{ id: 'skills-registrable', severity: 'soft', ops: ['publish'], description: 'every skill directory in a skill pack has a depth-1 SKILL.md (a buried or missing one ships un-registrable — the health-advisor 1.2.0 class)' },
|
|
264
287
|
{ id: 'readme-first', severity: 'soft', ops: ['publish'], description: 'a package with a staged version bump must update its own README.md in the same change (README-first)' },
|
|
288
|
+
{ id: 'routing-store-stale', severity: 'soft', ops: ['publish'], description: 'harvested routing telemetry has been applied to the auto-cost outcome store' },
|
|
289
|
+
{ id: 'marketplace-parity', severity: 'soft', ops: ['publish'], description: 'the published .claude-plugin/ showcase composition matches a fresh regeneration from the live registry (version excluded — an operator field)' },
|
|
265
290
|
{ id: 'agents-md-policy-sync', severity: 'soft', ops: ['publish'], description: 'proves the AGENTS.md copy is in SYNC with its source — not that the runtime read or obeyed it; heal drift with dz agents-sync' },
|
|
266
291
|
{ id: 'lockfile-in-sync', severity: 'soft', ops: ['publish'], description: 'every workspace @dzhechkov/* dependency spec matches the specifier pnpm-lock.yaml records for that importer (a dep bump without a lockfile refresh breaks CI with ERR_PNPM_OUTDATED_LOCKFILE). SOFT-ONLY — a config cannot promote it to HARD' },
|
|
267
292
|
{ id: 'store-bloat-cap', severity: 'soft', ops: ['teach', 'consolidate'], description: 'the learned store is within its size cap' },
|
|
@@ -360,6 +385,59 @@ const CHECKERS: Record<string, (f: GuardFacts, sev: GuardSeverity) => Violation[
|
|
|
360
385
|
}
|
|
361
386
|
return out;
|
|
362
387
|
},
|
|
388
|
+
'routing-store-stale': (f, _sev) => {
|
|
389
|
+
const ids = f.routingFreshness?.unfedRunIds;
|
|
390
|
+
if (!Array.isArray(ids) || ids.length === 0) return [];
|
|
391
|
+
const valid = [...new Set(ids.filter((id): id is string => typeof id === 'string' && id !== ''))].sort();
|
|
392
|
+
if (valid.length === 0) return [];
|
|
393
|
+
return [{
|
|
394
|
+
rule: 'routing-store-stale',
|
|
395
|
+
severity: 'soft',
|
|
396
|
+
detail: `${valid.length} harvested run(s) are not reflected in the auto-cost store: ${valid.slice(0, 5).join(', ')}${valid.length > 5 ? '…' : ''} — run dz routing recommend --apply`,
|
|
397
|
+
}];
|
|
398
|
+
},
|
|
399
|
+
'marketplace-parity': (f, _sev) => {
|
|
400
|
+
const fact = f.marketplaceParity;
|
|
401
|
+
if (fact === undefined || fact.applicable !== true) return [];
|
|
402
|
+
const hasPublishedVersion = typeof fact.publishedVersion === 'string' && fact.publishedVersion !== '';
|
|
403
|
+
const fix = `dz plugin --version ${hasPublishedVersion ? fact.publishedVersion : 'X.Y.Z'}`;
|
|
404
|
+
const fixHint = hasPublishedVersion ? '' : ' (substitute the published version for X.Y.Z)';
|
|
405
|
+
const manifestFailures = Array.isArray(fact.manifestFailures)
|
|
406
|
+
? fact.manifestFailures.filter((failure) => failure
|
|
407
|
+
&& (failure.file === 'plugin.json' || failure.file === 'marketplace.json')
|
|
408
|
+
&& typeof failure.error === 'string'
|
|
409
|
+
&& failure.error !== '')
|
|
410
|
+
: [];
|
|
411
|
+
if (manifestFailures.length > 0) {
|
|
412
|
+
return manifestFailures.map((failure) => ({
|
|
413
|
+
rule: 'marketplace-parity',
|
|
414
|
+
severity: 'soft',
|
|
415
|
+
detail: `.claude-plugin/${failure.file} exists but could not be read or parsed: ${failure.error} — run \`${fix}\`${fixHint} and commit the result`,
|
|
416
|
+
}));
|
|
417
|
+
}
|
|
418
|
+
if (fact.onlyOnePresent === true) {
|
|
419
|
+
return [{
|
|
420
|
+
rule: 'marketplace-parity',
|
|
421
|
+
severity: 'soft',
|
|
422
|
+
detail: `.claude-plugin/ has only one of plugin.json / marketplace.json — a broken half-showcase; run \`${fix}\`${fixHint} and commit the result`,
|
|
423
|
+
}];
|
|
424
|
+
}
|
|
425
|
+
if (fact.regenerateFailed === true) {
|
|
426
|
+
return [{
|
|
427
|
+
rule: 'marketplace-parity',
|
|
428
|
+
severity: 'soft',
|
|
429
|
+
detail: 'could not verify .claude-plugin/ composition because fresh regeneration failed',
|
|
430
|
+
}];
|
|
431
|
+
}
|
|
432
|
+
if (fact.diverged === true) {
|
|
433
|
+
return [{
|
|
434
|
+
rule: 'marketplace-parity',
|
|
435
|
+
severity: 'soft',
|
|
436
|
+
detail: `.claude-plugin/ composition does not match a fresh regeneration from the live registry — run \`${fix}\`${fixHint} and commit the result`,
|
|
437
|
+
}];
|
|
438
|
+
}
|
|
439
|
+
return [];
|
|
440
|
+
},
|
|
363
441
|
'review-round': (f, sev) => {
|
|
364
442
|
// The publish gate had eleven rules and not one asked whether anyone but the author had read the
|
|
365
443
|
// code. MEASURED cost (health-advisor slice H): five rounds graded F, thirteen packages published
|
|
@@ -508,7 +586,7 @@ const CHECKERS: Record<string, (f: GuardFacts, sev: GuardSeverity) => Violation[
|
|
|
508
586
|
* may not understand a file, and "I might be wrong" plus "block the publish" is the wrong pair. Disabling
|
|
509
587
|
* such a rule stays allowed — only the promotion is refused.
|
|
510
588
|
*/
|
|
511
|
-
export const SOFT_ONLY_RULES: readonly string[] = ['lockfile-in-sync', 'agents-md-policy-sync'];
|
|
589
|
+
export const SOFT_ONLY_RULES: readonly string[] = ['lockfile-in-sync', 'agents-md-policy-sync', 'routing-store-stale', 'marketplace-parity'];
|
|
512
590
|
|
|
513
591
|
/**
|
|
514
592
|
* A well-formed PROMOTED rule: an id the engine does not know, made enforceable by a template +
|
package/src/index.ts
CHANGED
|
@@ -283,7 +283,7 @@ export {
|
|
|
283
283
|
codeCheckpointPersistAllowed,
|
|
284
284
|
codeStageResultShapeValid,
|
|
285
285
|
} from './feature-adr-checkpoints.js';
|
|
286
|
-
export type { CheckpointStage, CheckpointEntry, ResumeMode, ResumeDecision, ParsedCheckpointRead, TrainingPairFamily, TrainingPair, TrainingPairEvaluation, TrainingPairProvenance, TrainingPairTruncation,
|
|
286
|
+
export type { CheckpointStage, CheckpointEntry, ResumeMode, ResumeDecision, ParsedCheckpointRead, TrainingPairFamily, TrainingPair, TrainingPairEvaluation, TrainingPairProvenance, TrainingPairBudget, TrainingPairTruncation,
|
|
287
287
|
CheckpointWriteVerdict,
|
|
288
288
|
} from './feature-adr-checkpoints.js';
|
|
289
289
|
|
|
@@ -627,6 +627,7 @@ export {
|
|
|
627
627
|
resolveCoderSpec,
|
|
628
628
|
coderIsCodex,
|
|
629
629
|
resolveQeSpec,
|
|
630
|
+
resolveQeSpecForCoder,
|
|
630
631
|
crossFamilyQe,
|
|
631
632
|
decideModeBScope,
|
|
632
633
|
partitionReviewFindings,
|