Commit Graph
2 Commits
Author SHA1 Message Date
92a0c2787c fix(models): put the rot check on a timer, and prove every cron has one (#359)
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>
2026-08-25 18:08:37 +00:00
cd97483a72 fix(groq): the default model 404s — repin, and make model rot detectable (#350)
`GROQ_FAST_MODEL` has been `llama-3.3-70b-versatile` since this file was
written. Groq no longer lists that model. Every call has returned

    HTTP 404 {"error":{"message":"The model `llama-3.3-70b-versatile` does not
    exist or you do not have access to it.","code":"model_not_found"}}

since 2026-08-18. Verified against the live API with the box's own key: the key
is healthy (200, 13 models) and that id is simply not among them.

The frontier digest dates the outage to the day. `frontier_digests.model` reads
`llama-3.3-70b-versatile` through 2026-08-17 and `fallback` for all eight days
since — a canned "Today on the AI & robotics frontier" headline every night,
with nobody told.

Blast radius, hard-broken (these have NO fallback — every direct callGroqText):
frontier digest + proposal generator, activity digests and digest emails,
calendar-event extraction, extract-proposal, hosted-runner analyze,
today/watch compose, and Loki's degraded-gateway fallback.

Degraded but alive: Loki's main chain, which is `ai-ration`'s multi-vendor
chain, not this constant. Its Groq link is dead so it falls through to
OpenRouter — losing the fastest vendor and the whole 100k/day Groq budget.
Checked for the failure mode that costs money: every OpenRouter link carries
`:free`, so no traffic silently moved onto a paid model.

`openai/gpt-oss-20b` replaces it — verified live, returns clean strict JSON.

It is a REASONING model, which is the part worth reading twice. At default
effort a trivial prompt spent 86 of 106 completion tokens on hidden reasoning,
and callers here budget 200–300 max_tokens; a straight id swap would have
truncated real answers while looking fine in a smoke test. `callGroqText` now
sends `reasoning_effort: "low"` (same prompt: 6 reasoning tokens, 28 total),
which keeps every existing caller's budget honest. It is an option, so a caller
that raises maxTokens can raise the effort with it. Sent only to models that
accept it — an allow-list, because an unknown parameter is a 400.

── the part that matters more than the repin ────────────────────────────────

`npm run probe:models` already existed. Its own docstring calls this class out:
"That was the fourth pinned-free-model rot in this fleet, so the class gets a
command instead of another one-off fix." This is the fifth, and it ran for
eight days.

Two reasons it did not catch this. It probes the Loki CHAT chain and the VISION
chain — `GROQ_FAST_MODEL` is in neither, and a checker that does not enumerate
its subjects cannot report the one it never knew about. And it is a command
someone must remember to type, which is not automation; it also costs real
tokens, so it can never be put on a schedule.

So: `src/config/model-registry.ts` is now the SSOT for every model id this app
can call, each one IMPORTED from the constant that uses it rather than retyped,
so an entry cannot drift from what it describes. `npm run check:models` asserts
every entry still exists at its provider using one GET /models per provider and
ZERO tokens — which is the whole point, because it is cheap enough to schedule.

Proven three ways rather than assumed:
  A. no key      → "4 id(s) UNCHECKED … that is not a pass for them", exit 0.
                   Could-not-look stays distinct from both "all present" and
                   "all missing"; a failed lookup must never invent an outage.
  B. live        → all 4 registered ids present, exit 0.
  C. MUTATION    → re-pin the dead id and it goes RED, exit 1, naming what
                   breaks ("frontier digest + proposal generator, activity
                   digests, …"). A gate that cannot go red is decoration.

Deliberately not done here, and worth saying out loud rather than leaving as an
un-encoded intention:

- `check:models` is not wired to a schedule yet. Scheduling it means an alert,
  and FleetCrown still has no delivery channel (TELEGRAM_CHAT_ID unset,
  push_subscriptions empty). The next step is to surface it where a channel is
  not required — the /api/health env issues list.
- `ai-ration` pins the SAME two dead Groq models fleet-wide
  (`llama-3.3-70b-versatile`, `llama-3.1-8b-instant`; neither exists). That is
  a fix in that repo, not this one, and it affects every app on the package.
  The env escape hatch it was built for (`LOKI_GROQ_MODELS`) is unset on the box.
- The frontier loop has surfaced no proposal since 2026-06-24 — two months, of
  which Groq was healthy for 54 days. That is a SEPARATE fault from this one and
  is still unattributable, because runFrontierProposals returns its verdict
  (skipped-reason, drafts, per-judge scores) only as an HTTP response the cron
  discards, logging just "HTTP 200".

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-25 12:13:07 +00:00