( env: DecisionCacheEnv, conversationKey: string, contentHash: string, classifierModel: string )
| 90 | model: z.string().min(1), |
| 91 | // Taxonomy route the model was decided on, for route-change telemetry. |
| 92 | // Nullable/defaulted so entries written before the field existed parse. |
| 93 | routeKey: z.string().min(1).nullish().default(null), |
| 94 | // Exact catalog variant the model was decided with. Null for legacy |
| 95 | // model-only sticky records and for candidates without a variant. |
| 96 | variant: z.string().min(1).nullish().default(null), |
| 97 | }); |
| 98 | export type StickyDecision = z.infer<typeof StickyDecisionSchema>; |
| 99 | |
| 100 | export async function getCachedClassification( |
| 101 | env: DecisionCacheEnv, |
| 102 | conversationKey: string, |
| 103 | contentHash: string, |
| 104 | classifierModel: string |
| 105 | ): Promise<ClassifierOutput | null> { |
| 106 | try { |
| 107 | const value = await cacheStub(env, conversationKey).getEntry( |
| 108 | entryKey(contentHash, classifierModel) |
| 109 | ); |
| 110 | if (!value) return null; |
| 111 | // Entries may have been written by an older worker version; validate |
| 112 | // before serving. |
| 113 | const parsed = ClassifierOutputSchema.safeParse(value); |
no test coverage detected