Files
timmy-talking-turd/src/vision-readiness.js
T
Timmy 46f961668f
Quality gates / quality (pull_request) Successful in 3m29s
feat: pin the self-hosted worker container and gate readiness on the loaded model (#15)
A worker that answers /v1/models has not necessarily loaded its weights, so the app
was offering an AI control that could only fail after the upload. Readiness now
passes only once the pinned model is loaded, and the not-loaded state reaches manual
Bristol entry in one tap. Verified against the real pinned llama.cpp build: it serves
503 while loading and the gate reports the distinct not-loaded state.

Adds the reproducible container recipe (digest-pinned bases, pinned llama.cpp commit,
hash-verified read-only weights, unprivileged, loopback-only publish), one shared
post-load readiness gate used by the host bootstrap and the image healthcheck, and a
target-GPU benchmark that refuses to write a receipt it did not measure.

Refs #15
2026-10-13 08:20:21 +00:00

48 lines
1.6 KiB
JavaScript

// Decides whether the photo-first flow can promise AI analysis.
// When it cannot, logging must still reach manual Bristol entry in one action.
const MANUAL_LABEL = 'Continue without AI';
const DISABLED_LABEL = 'Log it manually';
export function visionReadiness(status) {
if (!status) {
return {
phase: 'checking',
ready: false,
manualOnly: true,
manualLabel: MANUAL_LABEL,
message: 'Checking the vision worker. Manual logging is already available.',
};
}
if (status.enabled === false) {
return {
phase: 'disabled',
ready: false,
manualOnly: true,
manualLabel: DISABLED_LABEL,
message: 'AI photo analysis is off in this build. Manual logging is fully available.',
};
}
if (status.providerReady !== true) {
return {
phase: 'offline',
ready: false,
manualOnly: true,
manualLabel: MANUAL_LABEL,
message: 'Vision worker offline. Manual logging is still available.',
};
}
// A worker that answers /v1/models has not necessarily loaded the model yet (#15), so readiness
// passes only once the pinned model is confirmed loaded. An unconfirmed model fails closed to the
// manual path instead of offering an AI control that fails after the upload.
if (status.modelSeen !== true) {
return {
phase: 'loading',
ready: false,
manualOnly: true,
manualLabel: MANUAL_LABEL,
message: 'The vision worker is up but the model is not loaded yet. Manual logging is available.',
};
}
return { phase: 'ready', ready: true, manualOnly: false, manualLabel: '', message: '' };
}