mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 07:19:41 +01:00
Groq removed `llama-3.3-70b-versatile` on 2026-08-18 and FleetCrown asked for it for eight days. `npm run check:models` answers exactly that question — but it was a command a human had to remember to type, which is the same shape as the thing that failed. Now the clock types it, daily at 06:30 UTC, ahead of the 08:00 frontier digest. Zero tokens by design: one GET /models per provider, no inference. The Groq free tier is 100k tokens/day org-wide across every feature, so a synthetic canary would spend ~25% of the product's daily budget competing with it for the resource it exists to protect. Three states stay distinct — ROT (absent from a catalogue we read) alerts; UNCHECKED (catalogue unreadable, incl. a 200 with an empty list) logs a warning and is never a pass; OK logs, so the checker's silence differs from "never ran". Treating a failed fetch as an empty catalogue would report every pin as dead and manufacture an outage out of our own network blip. Alerts land via refreshOrInsertActiveAlert on /system, deduped until dismissed, with Telegram as a once-per-episode bonus — so this works without TELEGRAM_CHAT_ID being set. Detection moved to src/lib/model-check.ts, imported by both the CLI and the cron, so the scheduled and manual checks cannot drift about what rot means. Closes the sibling class too: a cron route can ship and deploy while nothing ever calls it, and no gate can see that absence. cron-schedule-coverage asserts every requireCronAuth route has a timer and every timer has a route, keyed off the code rather than a hand-maintained list. Proven by mutation in both directions. Co-authored-by: t <t@t.t> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
/**
|
|
* Does every model id this app pins still EXIST at its provider?
|
|
*
|
|
* The cheap half of model-rot defence. `probe:models` answers "can this model
|
|
* drive the tool loop" and costs real tokens; this answers "is it still there
|
|
* at all" with one GET /models per provider and zero tokens.
|
|
*
|
|
* The detection logic itself lives in `src/lib/model-check.ts`, shared with the
|
|
* `check-model-ids` CRON that runs this on the clock. This file is only the
|
|
* human-facing rendering of that verdict — because the 2026-08-18 rot went
|
|
* eight days unnoticed precisely because the only check was a command someone
|
|
* had to remember to type.
|
|
*
|
|
* Exit 1 when any registered id is missing, so it can gate or alarm.
|
|
*
|
|
* Run: npx tsx scripts/check-model-ids.ts (npm run check:models)
|
|
*/
|
|
import { config } from "dotenv";
|
|
config({ path: ".env.local" });
|
|
|
|
import { checkRegisteredModels } from "../src/lib/model-check";
|
|
import { REGISTERED_MODELS } from "../src/config/model-registry";
|
|
|
|
async function main() {
|
|
const report = await checkRegisteredModels();
|
|
|
|
for (const p of report.providers) {
|
|
if (!p.reachable) {
|
|
// Could-not-look is its own state, distinct from "all present" and from
|
|
// "all missing". Never let it read as a pass OR as an outage.
|
|
console.log(
|
|
`? ${p.provider}: could not read the model list (no key, or the request failed) — ${p.uncheckedIds.length} id(s) UNCHECKED`,
|
|
);
|
|
continue;
|
|
}
|
|
for (const id of p.presentIds) console.log(`✓ ${p.provider}/${id}`);
|
|
for (const m of p.missing) {
|
|
console.error(`✗ ${m.provider}/${m.id} — GONE from the provider's model list`);
|
|
console.error(` breaks: ${m.usedFor}`);
|
|
}
|
|
}
|
|
|
|
console.log("");
|
|
if (report.missing.length > 0) {
|
|
console.error(
|
|
`${report.missing.length} pinned model id(s) no longer exist. Pick a live one and re-probe before shipping.`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
if (report.uncheckedIds.length > 0) {
|
|
console.log(
|
|
`All checked ids exist. ${report.uncheckedIds.length} could not be checked — that is not a pass for them.`,
|
|
);
|
|
return;
|
|
}
|
|
console.log(`All ${REGISTERED_MODELS.length} registered model id(s) exist at their provider.`);
|
|
}
|
|
|
|
void main();
|