CODEX TASK 5
You are Cedric (Codex), worker #1, pass 5: Jenny's chunked backend review (council seat, Gemini). Accepted findings below. Same rules as pass 4: surgical changes, a test that FAILS on the old code for each behavior change, commit per item with the per-command identity and the trailers. Then run the full DONE suite and append "Pass 5 (Jenny findings)" to docs/VERIFY.md with a table: finding → commit → test.
- Torn BP (LakehouseRunner.cs:~75-76):
latest_systolicandlatest_diastolicmust come from the SAME most recent BP observation row (the panel with both components). Apply the same rule in the operational/Risk path if it pairs readings independently. Test: newer systolic-only plus older full panel → no torn pair. - OpenTelemetry filter inverted (ServiceDefaults/Extensions.cs:19-23): the Filter must EXCLUDE /health and /alive and record everything else. Also redact patient ids from
url.path(e.g. replace path segments after /patients/ with{id}) before export. Test the predicate. - SyncService.cs:26-57:
- (a) Verify
raw.ResourceType == type; quarantine mismatches without advancing that type's watermark. - (b) Within a batch, a resource first inserted and then updated before SaveChanges counts as ONE insert, not insert + update.
- (c) Advance the watermark only after a successful map, or make the quarantine dedupe from pass 4 cover replay.
- Tests for each.
- Auth-enabled tests (ApiSecurityTests): parameterize TestHost with
authEnabled. Assert 401 without a token on /api/patients, /api/sync, POST allergies and the CDS POST, and 200 with a valid test token (a test auth handler is fine). - Lakehouse status/time filters:
- Exclude
entered-in-error/cancelled/refutedstatuses from silver→gold aggregations (Condition.verificationStatus, AllergyIntolerance.verificationStatus, Observation.status, Immunization.status). - Bound facts to
effective <= as_of. - Mirror the same status rules in the operational risk path.
- Tests.
- Migration-name claim (SourceSafetyTests.cs:84): Jenny says
IMigrationsIdGenerator.GetName("202611120001_InitialOperational")truncates the name, because the 12-digit prefix doesn't match EF's 14-digit timestamp format, so MigrateAsync breaks. VERIFY it: - If the test currently passes because the path isn't exercised or the name resolves, write the receipt in VERIFY.md and either make the migration ids standard 14-digit or call
MigrateAsyncwith the full id. - If it's a real bug, fix it. Never rename an applied migration without a new migration.
- Process-wide env-var mutation in tests (SourceSafetyTests.cs:18-26): put those tests in a non-parallel xUnit collection, or inject the setting instead of mutating the env.
If pass 4 left anything NOT DONE, finish it first. Then git push origin HEAD.