From 6f63bbd66c740c6b037657f64d361652c66a4861 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Fri, 14 Aug 2026 17:15:49 -0700 Subject: [PATCH] fix(eval-model): kinds are a literal union, not string Record widened EvalModelKind to string, so a typo'd kind only failed at runtime; as const satisfies keeps the closed set the doc comment promises. --- lib/eval-model.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/eval-model.ts b/lib/eval-model.ts index 7aafab3eb..00e2723ca 100644 --- a/lib/eval-model.ts +++ b/lib/eval-model.ts @@ -17,13 +17,16 @@ * distill — free-text distillation (cheap, structured): haiku (pinned) */ -const DEFAULTS: Record = { +// `as const satisfies` keeps EvalModelKind the literal union +// 'capture' | 'warmup' | 'distill' — a `Record` 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; -export type EvalModelKind = keyof typeof DEFAULTS & string; +export type EvalModelKind = keyof typeof DEFAULTS; export function resolveEvalModel( kind: EvalModelKind,