mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 22:32:04 +00:00
feat(ai): gate document, lab and medication extraction on their capabilities
Reading a stored document (suggest, summary, extract, index, chat, reindex), scanning a lab report and turning medication text into a schedule now answer under documentAi, labsOcr and medicationExtract. The operator's master switch and the new reading-documents switch stop the work and the egress; a module off for the record, a delegate inside somebody else's record, and a missing receipt refuse with the capability envelope. Existing no-provider codes keep their status. The document pick and the labs pick re-check the capability for the provider they picked, immediately before anything is sent, so a job enqueued before a switch flipped finds no provider and falls back to the provider-free text layer. Consent follows the document rule for all three: any provider that leaves the machine needs an ai_extraction or ai_full receipt, answered for the provider actually picked. The fenced Coach chat and attachments answer under coach and documentAi. Uploads are always stored and indexed; the background summary is only enqueued while documentAi is open. The capability probes report the capability beside the provider answer and keep a read offered when only the receipt is missing. medications/extract keeps its 503 for no provider and adds ai.provider.none, and its budget refusal gains the coach.budget.exceeded code.
This commit is contained in:
1 parent
a19900c854
commit
bd8ea9d86b
39 files changed
+1420
-376
No files matched your search
@@ -31,9 +31,10 @@
|
||||
* matcher that stopped matching cannot agree with an empty world.
|
||||
*
|
||||
* Mutation checks: adding `await requireAssistantSurface("coach")` to any
|
||||
* route outside the frozen list turns guard 3 red by file name; removing the
|
||||
* `documentAi` entry from `AWAITING_READER` turns guard 2 red; putting
|
||||
* `assistantCorrelationsEnabled` back on the schema turns guard 1 red.
|
||||
* route outside the frozen list turns guard 3 red by file name; deleting the
|
||||
* `requireAiCapability("documentAi"` calls from the document routes (the only
|
||||
* reader of that switch's capabilities in the route tree) turns guard 2 red;
|
||||
* putting `assistantCorrelationsEnabled` back on the schema turns guard 1 red.
|
||||
*/
|
||||
import { readdirSync, readFileSync, statSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
@@ -99,13 +100,7 @@ const PLUMBING = [
|
||||
* Switches with no reader yet, and why that is correct for now. An entry is
|
||||
* a claim with an expiry: the test below fails as soon as a reader appears.
|
||||
*/
|
||||
const AWAITING_READER: Record<string, string> = {
|
||||
documentAi:
|
||||
"The capabilities it covers (documentAi, labsOcr, medicationExtract) are " +
|
||||
"resolved and published, but the document, lab-scan and medication " +
|
||||
"extraction routes move onto requireAiCapability in the same release; " +
|
||||
"until then the master switch is what stops them.",
|
||||
};
|
||||
const AWAITING_READER: Record<string, string> = {};
|
||||
|
||||
/**
|
||||
* Every file that still calls the retired gate. Only ever shrinks.
|
||||
@@ -132,7 +127,6 @@ const RETIRED_GATE_CALLERS = [
|
||||
"src/app/api/insights/pregenerate/route.ts",
|
||||
"src/app/api/insights/pulse-status/route.ts",
|
||||
"src/app/api/insights/weight-status/route.ts",
|
||||
"src/app/api/medications/extract/route.ts",
|
||||
"src/app/coach/page.tsx",
|
||||
];
|
||||
|
||||
|
||||
Reference in new issue
Block a user