CODEX TASK 13
You are Cedric on gpt-6-astra (high reasoning), pass 13: LOCAL MODEL SPIKE (MedGemma in-tenant tier + simulated BAA tier). It runs on a side branch wt/WT-dc65/medgemma-spike cut from the latest fhir-demo branch, and it never blocks the demo-safe tags. Synthetic data only. Follow docs/ANDREW-STYLE-GUIDE.md and the pass-11 quality bar. Commit and push each item yourself as its check passes.
Design source: fhir-pipeline-demo-docs/AI-SUMMARY-ARCHITECTURE-PLAN-v2.md, steps 1-16. Release-1 scope is QUOTE-ONLY: Tier 1 code facts plus verbatim note excerpts. No paraphrase is shown to users, and nothing is exported.
Models (both local, on the gaming PC RTX 4090, through its existing Ollama OpenAI-compatible endpoint)¶
- In-tenant tier:
google/medgemma-4b-it - Gated. Andrew accepted the Health AI Developer Foundations terms on 2026-11-12.
- Weights are at
J:\models\medgemma-4b-iton greatroom, at the pinned revision recorded in hf_download.log. Copy them to the gaming PC. - Import into Ollama: convert to GGUF with llama.cpp
convert_hf_to_gguf.py, then use a Modelfile. Record the exact commands and the SHA-256 of the GGUF. - NOTE: MedGemma is Gemma-3 based. FreeToken's model list shows Gemma-4, not Gemma-3/MedGemma, so use Ollama/llama.cpp. Record whether FreeToken loads it as an optional extra.
- Simulated BAA tier:
gpt-oss:20b(OpenAI open-weight, Apache 2.0). Andrew's choice (2026-11-12, about 11:40 PM): "maybe we should use the openai model". - It mirrors the realistic production path for an Azure shop, where OpenAI-family models are hosted in Azure under the Microsoft agreement.
- Use the OFFICIAL Ollama
gpt-oss:20b(id 17052f91a42e). NEVER usehuihui_ai/gpt-oss-abliteratedor any other abliterated model; those have their safety tuning removed. - Keep
muse-glimmer:30b(Meta) as a second, swappable simulated endpoint, to prove the gateway is vendor-neutral. - Label it everywhere as "SIMULATED BAA ENDPOINT, local, synthetic data only".
- Reach it ONLY through the
ExportGateway, which enforces the attestation, outage-switch and scanner-digest rules, using a self-signed test attestation and a test verify key. - Swapping in a real vendor later is configuration only.
- Ollama endpoint:
http://10.0.0.7:11434(gaming PC). If it only listens on localhost, run the model calls on the gaming PC overssh gamingand record that.
Build (interfaces + real local calls behind them)¶
INoteExcerptSelectorwith MedGemma: given ONE pinned span (passed through the confidentiality filter), return the verbatim sentences most relevant to a pre-visit summary.- The output must be exact substrings of the span; verify this in code and reject anything else.
- Tests use the real model with recorded fixtures, plus a fake for CI.
FactGuard+ a ConText/NegEx-style tagger (C#), with the adversarial corpus: negation flip, family-history flip, dose-to-wrong-drug, discontinued-as-current. Run a MedGemma PARAPHRASE mode in the test harness ONLY, to show the guard rejecting real model output. Paraphrase is never shown in the UI in release 1.ExportGateway→ gpt-oss:20b (Muse Glimmer as the swap test), wired with:- the attestation check (pinned verify-only key)
- the operator outage switch as the only trigger, with an expiry
- a scanner-signed digest
- single-use tokens
Tests: latency and low confidence with the switch off send nothing; a planted name in the payload is blocked; a deploy-signed attestation is rejected.
3b. PRE-COMPUTE THE EXAMPLES COMPARISON (feeds pass 12's Examples page, section 1e).
- Run every use-case packet (data/fixtures scenarios from pass 12; if pass 12 hasn't landed yet, run on the 6 note-bearing synthetic patients and re-run after it lands) through:
- (a) MedGemma 4B in quote mode and in paraphrase mode
- (b) gpt-oss:20b through the ExportGateway, as the simulated BAA tier
- (c) muse-glimmer:30b through the same gateway, as the vendor-swap proof
- Apply FactGuard to every output.
- Write web/public/snapshot/examples/<usecase>/<tier>.json with: model id + digest, prompt hash, temperature 0, timestamp, raw output, FactGuard verdict per line, and latency/tokens.
- Commit them to the spike branch. The orchestrator merges them into the demo branch.
4. docs/MEDGEMMA-SPIKE.md, with real numbers:
- tokens/s and p95 latency on the 4090
- VRAM used
- excerpt precision on 12 synthetic patients
- the FactGuard rejection table
- what would change for MedGemma 27B (separately gated; Andrew has not accepted it yet)
Gaming-PC etiquette¶
The fleet listener defers jobs while Andrew is gaming. Wait for it to accept; do not force it, and do not run long jobs while he plays.
DONE¶
- build 0 warnings, NUnit green
- Stryker on FactGuard + gateway: break ≥ 60, mutants > 0
- a real-model run log
- screenshots of the release-1 quote-only card
- VERIFY.md "Pass 13 (spike)"