mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 18:47:42 +01:00
* chore: add a formatter, matching the style this repo already writes singleQuote=false was chosen by counting this repo's own imports, not by fleet decree. The fleet is genuinely split and the two repos that already had a .prettierrc disagreed with each other, so there was no standard to restore. Quote style does not cross repo boundaries; having a gate does. Markdown is ignored for now — prettier rewraps prose, which would bury the real diff. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: format with prettier (1062 files) Mechanical. No behaviour change. This SHA is listed in .git-blame-ignore-revs so `git blame` skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: teach git blame to skip the reformat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(lint): reattach two guards the reformat detached Both effects were one-liners, so a trailing eslint-disable-line covered the setState call: useEffect(() => { setSelected(new Set()); }, [q.length]); // eslint-disable-line ... prettier expanded the block. The comment stayed on the closing line while the call moved above it, so the guard protected nothing and the rule its author had deliberately silenced failed the build. This is the second shape of the same defect — hirnli had the eslint-disable-NEXT-line variant. Both come from the same fact: an eslint directive binds to a line number, so reformatting can silently unbind it, which makes 'mechanical, no behaviour change' false for any bulk reformat. * chore(desktop): bump the runner version the reformat requires desktop-release-drift enforces that anything built into Fleet Runner which differs from the last released tag must carry a version ahead of that tag — main read 0.8.15 and fleet-runner-v0.8.15 already shipped. A whole-repo reformat changes bytes under desktop/, so the gate fires. The alternative was adding desktop/ to .prettierignore, which would buy a quiet PR by carving a permanent hole in the formatter's coverage — the precise shape of silent drift this test was written to catch. Bumping is what the rule asks for and costs one patch release whose only content is whitespace. * chore: merge main and re-format A whole-repo reformat conflicts with any concurrent commit, and a conflicting PR runs no checks at all while reporting nothing. Conflicts resolved to main, which is correct because this branch changes formatting and nothing else. * chore: leave desktop/ out of this reformat desktop-release-drift is right to refuse this. Everything under desktop/ is built into Fleet Runner, so changing it means shipping: bump the version AND add a FLEET_RUNNER_RELEASES entry, whose stated audience is 'person who installed Fleet Runner and wants to know what changed'. For a whitespace-only build the honest answer is 'nothing', so that release should not exist — and I should not write release notes claiming otherwise. I had bumped to 0.8.16 to get the gate green. That was the wrong direction: publishing a build to three OS runners to keep a formatting PR quiet. Reverted. desktop/ is excluded in .prettierignore with the reasoning recorded there, to be formatted alongside the next real runner change, where the bump and the notes are true anyway. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
207 lines
8.3 KiB
TypeScript
207 lines
8.3 KiB
TypeScript
/**
|
|
* Model-rot detection: three states, never two.
|
|
* Run: npx tsx scripts/test/model-check.ts
|
|
*
|
|
* The failure this guards against is the checker inventing an outage. If a
|
|
* catalogue read fails and we treat the result as an empty catalogue, EVERY
|
|
* pinned id reads as "gone" and the operator gets a maximally alarming alert
|
|
* caused entirely by our own network blip. The inverse is just as bad: letting
|
|
* "could not look" count as a pass is how a dead pin survives for eight days.
|
|
*
|
|
* So: got-it / absent / could-not-look must stay three distinct outcomes.
|
|
*/
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
checkRegisteredModels,
|
|
describeRot,
|
|
type CatalogReader,
|
|
type CallProbe,
|
|
} from "../../src/lib/model-check";
|
|
import { supportsReasoningEffort } from "../../src/lib/groq";
|
|
import { REGISTERED_MODELS, registeredIdsFor } from "../../src/config/model-registry";
|
|
|
|
const ALL_PROVIDERS = [...new Set(REGISTERED_MODELS.map((m) => m.provider))];
|
|
|
|
async function main() {
|
|
// ── Everything present → clean bill of health ────────────────────────────────
|
|
{
|
|
const everythingLives: CatalogReader = async (p) => new Set(registeredIdsFor(p));
|
|
const report = await checkRegisteredModels(everythingLives);
|
|
|
|
assert.equal(
|
|
report.missing.length,
|
|
0,
|
|
"no pin should be missing when the catalogue holds them all",
|
|
);
|
|
assert.equal(
|
|
report.uncheckedIds.length,
|
|
0,
|
|
"nothing is unchecked when every catalogue was read",
|
|
);
|
|
assert.ok(report.presentCount > 0, "should have confirmed at least one id present");
|
|
assert.ok(
|
|
report.providers.every((r) => r.reachable),
|
|
"every provider was reachable in this scenario",
|
|
);
|
|
}
|
|
|
|
// ── A catalogue we CANNOT READ is not a catalogue full of dead models ────────
|
|
{
|
|
const cannotLook: CatalogReader = async () => null;
|
|
const report = await checkRegisteredModels(cannotLook);
|
|
|
|
assert.equal(
|
|
report.missing.length,
|
|
0,
|
|
"UNREADABLE CATALOGUE MUST NOT REPORT ROT — this is the check inventing an outage from its own failure",
|
|
);
|
|
assert.ok(
|
|
report.uncheckedIds.length > 0,
|
|
"unreadable catalogues must surface as UNCHECKED ids",
|
|
);
|
|
assert.equal(report.presentCount, 0, "nothing can be confirmed present when nothing was read");
|
|
assert.ok(
|
|
report.providers.every((r) => !r.reachable),
|
|
"providers should be marked unreachable",
|
|
);
|
|
}
|
|
|
|
// ── An EMPTY catalogue is treated as unreadable, not as total annihilation ───
|
|
// The real fetchCatalog collapses `data: []` to null. Asserted here because a
|
|
// provider returning 200 with an empty list is a likelier glitch than every
|
|
// model on the platform disappearing at the same instant.
|
|
{
|
|
const emptyIsUnreadable: CatalogReader = async () => null; // what fetchCatalog does with `data: []`
|
|
const report = await checkRegisteredModels(emptyIsUnreadable);
|
|
assert.equal(report.missing.length, 0, "an empty catalogue must not read as universal rot");
|
|
}
|
|
|
|
// ── A genuinely dead pin IS reported, and says what it breaks ────────────────
|
|
{
|
|
const victim = REGISTERED_MODELS[0];
|
|
const oneIsDead: CatalogReader = async (p) => {
|
|
const ids = registeredIdsFor(p).filter((id) => !(p === victim.provider && id === victim.id));
|
|
return new Set(ids);
|
|
};
|
|
const report = await checkRegisteredModels(oneIsDead);
|
|
|
|
assert.ok(
|
|
report.missing.length > 0,
|
|
"a pin absent from a READ catalogue must be reported as rot",
|
|
);
|
|
assert.ok(
|
|
report.missing.every((m) => m.id === victim.id),
|
|
"only the removed id should be reported missing",
|
|
);
|
|
assert.equal(report.uncheckedIds.length, 0, "readable catalogues leave nothing unchecked");
|
|
|
|
const text = describeRot(report);
|
|
assert.ok(text.includes(victim.id), "the alert text must name the dead id");
|
|
assert.ok(
|
|
text.includes(victim.usedFor.slice(0, 24)),
|
|
"the alert text must say what breaks — an id alone is not actionable",
|
|
);
|
|
}
|
|
|
|
// ── Mixed: one provider readable, another not ────────────────────────────────
|
|
if (ALL_PROVIDERS.length > 1) {
|
|
const [first, ...rest] = ALL_PROVIDERS;
|
|
const mixed: CatalogReader = async (p) => (p === first ? new Set(registeredIdsFor(p)) : null);
|
|
const report = await checkRegisteredModels(mixed);
|
|
|
|
assert.equal(
|
|
report.missing.length,
|
|
0,
|
|
"the unreadable provider must not contribute phantom rot",
|
|
);
|
|
assert.ok(report.presentCount > 0, "the readable provider still yields confirmations");
|
|
assert.ok(
|
|
report.uncheckedIds.length > 0,
|
|
`the unreadable provider(s) ${rest.join(",")} must surface as unchecked`,
|
|
);
|
|
}
|
|
|
|
// ── Callability: present in the catalogue is not the same as usable ─────────
|
|
// qwen/qwen3.6-27b was listed by Groq the whole time every call to it 400'd,
|
|
// and the existence check reported `rotted: 0` throughout. These assert the
|
|
// three verdicts land where they belong.
|
|
{
|
|
const readable: CatalogReader = async (p) => new Set(registeredIdsFor(p));
|
|
const chatPin = REGISTERED_MODELS.find((m) => m.kind === "chat")!;
|
|
|
|
const refusing: CallProbe = async (m) =>
|
|
m.id === chatPin.id
|
|
? { verdict: "rejected", error: "`reasoning_effort` must be one of `none` or `default`" }
|
|
: { verdict: "accepted" };
|
|
const report = await checkRegisteredModels(readable, refusing);
|
|
|
|
assert.equal(report.missing.length, 0, "a refused model is not MISSING — it is listed");
|
|
assert.equal(report.rejected.length, 1, "a 400 on our own request shape must be reported");
|
|
assert.equal(report.rejected[0].model.id, chatPin.id, "the right id must be named");
|
|
|
|
const text = describeRot(report);
|
|
assert.ok(text.includes(chatPin.id), "the alert text must name the refusing id");
|
|
assert.ok(
|
|
text.includes("reasoning_effort"),
|
|
"the provider's own message must survive into the alert — it names the parameter, which is the fix",
|
|
);
|
|
assert.ok(
|
|
text.includes(chatPin.usedFor.slice(0, 24)),
|
|
"a refusal must say what it breaks, exactly as a removal does",
|
|
);
|
|
}
|
|
|
|
// A transient 429 or a network blip is NOT rot. Same discipline as an
|
|
// unreadable catalogue: three states, and "could not look" is its own.
|
|
{
|
|
const readable: CatalogReader = async (p) => new Set(registeredIdsFor(p));
|
|
const flaky: CallProbe = async () => ({ verdict: "unknown", error: "HTTP 429" });
|
|
const report = await checkRegisteredModels(readable, flaky);
|
|
assert.equal(report.rejected.length, 0, "a rate limit must never be reported as a dead model");
|
|
}
|
|
|
|
// Transcription ids live on a different endpoint; probing them with a chat
|
|
// completion would 400 for a reason that has nothing to do with the fault.
|
|
{
|
|
const readable: CatalogReader = async (p) => new Set(registeredIdsFor(p));
|
|
const probed: string[] = [];
|
|
const recorder: CallProbe = async (m) => {
|
|
probed.push(m.id);
|
|
return { verdict: "accepted" };
|
|
};
|
|
await checkRegisteredModels(readable, recorder);
|
|
|
|
const transcribe = REGISTERED_MODELS.filter((m) => m.kind === "transcribe").map((m) => m.id);
|
|
assert.ok(
|
|
transcribe.length > 0,
|
|
"expected at least one transcription pin — has the registry changed?",
|
|
);
|
|
for (const id of transcribe) {
|
|
assert.ok(
|
|
!probed.includes(id),
|
|
`${id} is a transcription model and must not be probed as chat`,
|
|
);
|
|
}
|
|
assert.ok(probed.length > 0, "the probe must actually run on the chat pins");
|
|
}
|
|
|
|
// The probe must build its request from the SAME predicate the real call path
|
|
// uses. A probe with its own opinion would pass while production 400s — the
|
|
// checker/consumer split that made this bug invisible in the first place.
|
|
assert.equal(
|
|
supportsReasoningEffort("qwen/qwen3.6-27b"),
|
|
false,
|
|
"qwen no longer accepts the reasoning_effort values this app sends — it must not be in the allow-list",
|
|
);
|
|
assert.ok(
|
|
supportsReasoningEffort("openai/gpt-oss-20b"),
|
|
"gpt-oss still accepts reasoning_effort; dropping it would silently change every call",
|
|
);
|
|
|
|
console.log(
|
|
`✓ model-check: existence AND callability across ${ALL_PROVIDERS.length} provider(s), ${REGISTERED_MODELS.length} pin(s)`,
|
|
);
|
|
}
|
|
|
|
void main();
|