mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
A release-readiness QA pass over the whole product. The commits split into defects a user would hit and gates that were reporting green while measuring nothing. ## Fixes that change behaviour Rate limiting was bypassable on every install: TRUST_PROXY defaulted to true, so request.ip came from a client-set header and a forged X-Forwarded-For got past the login limiter. The default is now a private-network trust list. A transient Postgres outage stranded in-flight jobs, leaving finished output on disk with no row pointing at it. A reconciler now resolves those rows and adopts the bytes rather than dropping the work. A Redis connection that moved to a new address wedged every read-blocked consumer, so completions stopped signalling while health still answered 200. Socket timeouts plus subscriber pings recover it. Installing more than one AI bundle left the shared venv multi-versioned and silently broke three tools. The installer now reconciles distributions to one version each. Converting an image to JXL at quality 1 through 4 returned a 500, because libjxl 0.7 rejects the distance those values compute. The quality is floored at what the encoder honours. A missing ffmpeg was also reported to the user as a corrupt upload; it now says the engine is unavailable. RAW uploads reached an unpatched LibRaw on arm64, so it is built from source at 0.22.2, and the release scan was split so it can fail on an unfixed critical instead of hiding it behind ignore-unfixed. ## Gates that could not fail Two mutation lanes ran zero mutants because Stryker crawled the gitignored docs build; coverage discarded its whole report on any failing test; the lint gate skipped root tests, scripts, and two workspaces; and several generated matrices counted a host missing ffmpeg as a passing tool. Each now measures what it claims. Full evidence and the outstanding release items are tracked locally and are not part of this branch.
117 lines
4.1 KiB
TypeScript
117 lines
4.1 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { installedAiCapabilityGate } from "../../helpers/installed-ai-capability-gate.js";
|
|
|
|
const INTEGRATION_ROOT = join(process.cwd(), "tests/integration");
|
|
const INSTALLED_AI_SUITES = [
|
|
{
|
|
path: "tools/audio/transcribe-audio.test.ts",
|
|
toolId: "transcribe-audio",
|
|
oracles: ["expectKnownTranscript"],
|
|
},
|
|
{
|
|
path: "tools/video/auto-subtitles.test.ts",
|
|
toolId: "auto-subtitles",
|
|
oracles: ["expectKnownTranscript"],
|
|
},
|
|
{
|
|
path: "tools/image/blur-background.test.ts",
|
|
toolId: "blur-background",
|
|
oracles: ["expectObservablePixelChange", "expectForegroundPreserved"],
|
|
},
|
|
{
|
|
path: "tools/image/background-replace.test.ts",
|
|
toolId: "background-replace",
|
|
oracles: [
|
|
"expectObservablePixelChange",
|
|
"expectConfiguredBackground",
|
|
"expectForegroundPreserved",
|
|
],
|
|
},
|
|
] as const;
|
|
|
|
describe("installed AI integration capability gate", () => {
|
|
it.each([
|
|
{
|
|
installed: false,
|
|
required: false,
|
|
runInstalledContract: false,
|
|
runUnavailableContract: true,
|
|
},
|
|
{
|
|
installed: false,
|
|
required: true,
|
|
runInstalledContract: true,
|
|
runUnavailableContract: true,
|
|
},
|
|
{
|
|
installed: true,
|
|
required: false,
|
|
runInstalledContract: true,
|
|
runUnavailableContract: false,
|
|
},
|
|
{
|
|
installed: true,
|
|
required: true,
|
|
runInstalledContract: true,
|
|
runUnavailableContract: false,
|
|
},
|
|
])(
|
|
"installed=$installed required=$required selects the correct contract lanes",
|
|
({ installed, required, runInstalledContract, runUnavailableContract }) => {
|
|
expect(installedAiCapabilityGate("transcribe-audio", required, () => installed)).toEqual({
|
|
installed,
|
|
runInstalledContract,
|
|
runUnavailableContract,
|
|
});
|
|
},
|
|
);
|
|
|
|
it.each(INSTALLED_AI_SUITES)(
|
|
"$toolId has no unconditional suite disable and accounts for both capability lanes",
|
|
({ path, toolId }) => {
|
|
const source = readFileSync(join(INTEGRATION_ROOT, path), "utf8");
|
|
expect(source).not.toContain("describe.skip(");
|
|
expect(source).toContain("REQUIRE_AI_FEATURES");
|
|
expect(source).toContain("isToolInstalled");
|
|
expect(source).toMatch(new RegExp(`installedAiCapabilityGate\\(\\s*"${toolId}"`));
|
|
expect(source).toContain("describe.skipIf(!AI_CAPABILITY.runInstalledContract)");
|
|
expect(source).toContain("it.skipIf(!AI_CAPABILITY.runUnavailableContract)");
|
|
},
|
|
);
|
|
|
|
it.each(INSTALLED_AI_SUITES)(
|
|
"$toolId settles every installed 202 and applies a tool-specific output oracle",
|
|
({ path, oracles }) => {
|
|
const source = readFileSync(join(INTEGRATION_ROOT, path), "utf8");
|
|
const installedContract = source.slice(
|
|
source.indexOf("// -- Installed/required capability contract --"),
|
|
);
|
|
const admissionPattern = /expect\(res\.statusCode\)\.toBe\(202\)/g;
|
|
const settlementPattern = /await waitForDownloadedJobArtifact\(/g;
|
|
const admissions = [...installedContract.matchAll(admissionPattern)];
|
|
const settlements = [...installedContract.matchAll(settlementPattern)];
|
|
const oracleMatches = oracles.map(
|
|
(oracle) =>
|
|
[oracle, [...installedContract.matchAll(new RegExp(`${oracle}\\(`, "g"))]] as const,
|
|
);
|
|
|
|
expect(admissions.length).toBeGreaterThan(0);
|
|
expect(settlements).toHaveLength(admissions.length);
|
|
for (const [, matches] of oracleMatches) expect(matches).toHaveLength(admissions.length);
|
|
for (const [index, admission] of admissions.entries()) {
|
|
const start = admission.index ?? -1;
|
|
const end = admissions[index + 1]?.index ?? Number.MAX_VALUE;
|
|
expect(settlements[index].index).toBeGreaterThan(start);
|
|
expect(settlements[index].index).toBeLessThan(end);
|
|
for (const [, matches] of oracleMatches) {
|
|
expect(matches[index].index).toBeGreaterThan(settlements[index].index ?? start);
|
|
expect(matches[index].index).toBeLessThan(end);
|
|
}
|
|
}
|
|
expect(installedContract).not.toContain("just verify job was accepted");
|
|
},
|
|
);
|
|
});
|