fix(eval-model): kinds are a literal union, not string

Record<string,string> widened EvalModelKind to string, so a typo'd
kind only failed at runtime; as const satisfies keeps the closed set
the doc comment promises.
This commit is contained in:
Garry Tan 2026-08-14 17:15:49 -07:00
parent c9215c438c
commit 6f63bbd66c
No known key found for this signature in database
GPG Key ID: C1F69E85C74EFE1D
1 changed files with 6 additions and 3 deletions

View File

@ -17,13 +17,16 @@
* distill free-text distillation (cheap, structured): haiku (pinned)
*/
const DEFAULTS: Record<string, string> = {
// `as const satisfies` keeps EvalModelKind the literal union
// 'capture' | 'warmup' | 'distill' — a `Record<string, string>` annotation
// would widen it to string and let any typo through the type gate.
const DEFAULTS = {
capture: "claude-opus-4-7",
warmup: "claude-haiku-4-5",
distill: "claude-haiku-4-5-20251001",
};
} as const satisfies Record<string, string>;
export type EvalModelKind = keyof typeof DEFAULTS & string;
export type EvalModelKind = keyof typeof DEFAULTS;
export function resolveEvalModel(
kind: EvalModelKind,