CODEX TASK 10

You are Cedric on gpt-6-astra (high reasoning), worker #1, pass 10: Fable's re-gate of passes 6–7. Run AFTER pass 8 is committed. Follow docs/ANDREW-STYLE-GUIDE.md. Fallback tag: demo-safe-3. Surgical changes; for each behavior change, a test that fails on the old code; commit per item with 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.

  1. AppHost/Program.cs:~12: register the HAPI ehr-fhir container ONLY when Source:Mode=LocalEhr (or a --ehr flag). The offline default (Fixture) must not require Docker. Test the AppHost model for both modes.
  2. FixtureFhirSource.ReadAsync (SourceAdapters.cs:~30): parse the fixture tree ONCE per source instance (a cached index by resource type). No re-parse per type.
  3. LakehouseRunner.cs:~30 bronze:
  4. dedupe on (resource_type, id, version_id): a rerun must not grow bronze
  5. bulk insert (DuckDB appender, or one multi-row/COPY statement) instead of one statement per resource
  6. Test: run twice, same bronze count.
  7. Api Program.cs:~119 plus EhrFixtures.Transaction:~38: use \z (not $) for end-anchored validation regexes, or RegexOptions plus an explicit check. Test that "91936005\n" is rejected. Grep the whole solution for $" regex end anchors used for validation and fix them all.
  8. LakehouseRunner.cs:~55 silver coding:
  9. pick the coding by system priority exactly like ClinicalMapping.Coding (SNOMED/CVX/RxNorm/LOINC per type), and coding.display before text
  10. Condition onsetPeriod.start handled like in C#
  11. Extend the pass-7 parity test to cover Conditions/Immunizations/Medications labels.
  12. Status sets: make one FhirStatus static class in Core (invalid set; valid Observation set; per-type eligible sets). Use it from ClinicalMapping, ToRiskPatient, IsEligible, IntakeMapping (drop the legacy 'enteredinerror' acceptance unless the backfill requires it, and document that), and the backfill migration. Generate the SQL IN-lists for LakehouseRunner from it. Generate or emit a TS constant for web/mapping.ts from it at build time, or add a test asserting the TS list equals the C# list.
  13. IntakeMapping.cs:~54 / EhrFixtures.ReadAll:~21:
  14. derive "Ottehr sample" provenance from the source path (/ottehr/) or a capture-time tag, not hard-coded UUIDs
  15. detect non-resource fragments by a missing resourceType, not the filename
  16. Test with an extra Ottehr fixture.

DONE: dotnet build (0 warnings), dotnet test, npm test, npm run build:snapshot, npm run e2e, plus the fixture-mode AppHost starting WITHOUT Docker (prove it, e.g. with the Docker service query showing it isn't needed, or a test). Append "Pass 10 (Fable re-gate 2)" to VERIFY.md with the finding → commit → test table. Push.