CODEX TASK 4
You are Cedric (Codex), worker #1, pass 4: council review fixes. Seats run at 28663e7: Fable (native), Gronktayvius red team, Susie (front end + infra), Jenny (chunked, may add more). Clahadore chaired. These are the ACCEPTED findings; fix them all. Keep changes surgical. Commit per group with the per-command identity (git -c user.name="Andrew Jones" -c user.email="andrewjonesdev1@gmail.com" commit) and the Co-Authored-By trailers for Cedric (Codex) and Claude Opus 5.5. Add or adjust a test for every behavior change. Tests must FAIL on the old code.
A. Data / clinical correctness¶
- LakehouseRunner.cs:~126 / LakehouseReports.cs:41:
gold_outreach.warning_countis a HUGEINT, which serializes as a BigInteger object. CAST the aggregates to INTEGER/BIGINT in SQL. Also convert anyBigInteger/decimalvalues to JSON numbers when building report rows. Test: the JSON contains a number. - ClinicalMapping.cs:~106 ToRiskPatient: stop hard-coding
BpTreated=null. - Derive
BpTreatedfrom active/recent MedicationRequest RxNorm codes in a small, explicit antihypertensive allowlist (e.g. amlodipine, lisinopril, losartan, hydrochlorothiazide, metoprolol, atenolol; use the RxNorm codes actually present in the fixtures, and comment the list's origin). It is null only when there is NO medication data. - Derive diabetes status from Condition SNOMED (44054006 and its descendants present in the fixtures; prediabetes 15777000 is NOT diabetes).
- Race: ONLY from the explicit US Core race extension (
http://hl7.org/fhir/us/core/StructureDefinition/us-core-race, ombCategory 2106-3 White / 2054-5 Black or African American). Never inferred. Otherwise keep "insufficient: race". - Add a test that at least one fixture patient now gets an ASCVD percentage, with its inputs cited.
- SyncService.cs:66 IsNewer: when both versionIds are empty or equal-but-empty, compare
lastUpdated. Test with no versionId plus a newer lastUpdated, which must update. - FhirSource.cs:215 ValidateCohort: skip OperationOutcome entries (and any
search.mode=outcome). Don't throw. Log them to quarantine/learnings. Test. - SyncService.cs:43: dedupe quarantine on (ResourceType, FhirId, VersionId). Re-running must not grow the count. Test.
- Api Program.cs:~175 ClinicalRows: project out RawJson where it's unused, and map rows once before the per-patient loop.
- Lakehouse effective timestamps: emit UTC ISO-8601 with a
Z(or the original offset) consistently with Track B. Test. - ClinicalMapping.Coding: pick the code system in a fixed priority per resource type (Observation: LOINC first; Immunization: CVX; Medication: RxNorm; Condition/Allergy: SNOMED) instead of FirstOrDefault across all of them. Test with SNOMED before LOINC on an A1c.
B. Security¶
- appsettings.json:
Demo:ReadOnlydefaults to TRUE;appsettings.Development.jsonsets it false. - On startup, refuse to bind a non-loopback address unless
Auth:Enabled=trueORDemo:PublicSynthetic=true(explicit). Log why. - Add
FallbackPolicywhen auth is enabled. - Deploy stack: REMOVE the
allUsersrun.invoker binding. Cloud Run stays private; the public demo is the static Pages site. Keep the budget, and add a note that budgets don't cap spend. - AppHost: remove
WithExternalHttpEndpoints(). The API stays loopback. /api/sync: requireContent-Type: application/json(an empty JSON body is fine), so a cross-site form POST can't trigger it. Update the web client and tests.- Allergy display validation: reject UnicodeCategory Control, Format, Surrogate and PrivateUse (bidi overrides, zero-width). Test with U+202E.
- CLI Program.cs:53: on auth/provision paths, print the exception type plus a scrubbed message, never
ToString(). - bi/metabase/get-driver.ps1: download to a temp path, verify the SHA-256, then move; delete on mismatch. AppHost mounts ONLY
lakehouse.duckdbread-only into Metabase, not the whole data dir.
C. Infra / CI¶
- Deploy stack backend: follow fleet-infra's pattern.
GcsBackendwith a placeholder bucket, thenAddOverride("terraform.backend.gcs.bucket", null), with the bucket supplied by-backend-config. A distinct prefix per stack (fhir-demo/gcp,fhir-demo/cf). Billing account and Cloudflare account id become TerraformVariables with NO defaults, set via*.auto.tfvars(gitignored) or env. Update DEPLOY.md. - Azure skeleton: Service Bus
public_network_access_enabled=false; Container App ingress internal withDemo__ReadOnly=true. Synth only. - CI (both .github/workflows/ci.yml and azure-pipelines.yml):
- run
npm testandnpm run e2e - synth
infra/FhirDemo.Deploy - a read-only smoke:
Demo__ReadOnly=true, expect 403 on POST /api/sync and 200 on the CDS POST - fail the build on
dotnet list package --vulnerableandnpm audit --audit-level=high - fix the health loop so a dead /health fails the step
- run
D. Front end¶
- Reports race: add a version guard plus a test (out-of-order resolution, the older one doesn't win).
- web/src/api.ts:23: replace the corrupted U+FFFD with "1-200". Grep the whole repo for U+FFFD and mojibake sequences and fix any you find.
- Static hosting CSP:
- Add
web/public/_headers(Cloudflare Pages):Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; object-src 'none'; base-uri 'self'; frame-ancestors 'none', plus nosniff and referrer-policy. - Apply the SAME style-src allowance to the API's CSP when it serves web/dist (Vuetify injects its theme style element).
- Verify in the Playwright e2e that no CSP violation fires: listen for
securitypolicyviolationand assert zero.
- Add
- Mobile polish: in the CDS cards, collapse the cited FHIR ids behind a "Sources (n)"
<details>toggle. On narrow screens, make the clinical tables readable (hide the Code column below 600px, or use Vuetify's mobile breakpoint).
DONE: dotnet build (0 warnings), dotnet test, npm test, npm run build:snapshot (regenerate the snapshot), npm run e2e (refresh the screenshots), and synth for both infra projects. Paste the REAL outputs into docs/VERIFY.md under "Pass 4 (council fixes)" with a table: finding → commit → test name. Windows Application Control blocks = BLOCKED, never "passed". Then git push origin HEAD.