Files
Trent a17bc2b734
CI / changes (push) Successful in 17s
dotnet8-ci / build-and-test (push) Successful in 8m23s
CI / backend (push) Successful in 8m24s
node-ci / build (push) Failing after 2m1s
CI / frontend (push) Failing after 2m2s
Harden API memory and CPU usage across Phases 19–22.
Bound list/PDF payloads, stream MinIO I/O with cancellation, paginate history and FHIR $everything, tighten OCR lifetimes/buffers, and add phase tracking docs.
2026-11-30 23:55:56 +08:00

71 lines
3.0 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Phase 22 — Polish and Ops
## What exists
- [`PromotionService`](../../VigilCareRecordsAPI/Services/PromotionService.cs) loads all same-DOB patients for Levenshtein logging before creating a new patient.
- [`SeedDocumentStorage`](../../VigilCareRecordsAPI/Data/Seed/SeedDocumentStorage.cs) StatObject/Put per batch on bootstrap.
- `PromoteAsync` / seed paths used by hosted services omit `CancellationToken`.
- [`docker-compose.prod.yml`](../../docker-compose.prod.yml) sets API `memory: 1G` with no measured guidance comment.
- [`UserDirectoryService.ListByRoleAsync`](../../VigilCareRecordsAPI/Services/UserDirectoryService.cs) is unbounded.
Requires [Phase 21](./phase-21-plan.md). Tracker: [performance-hardening-overview.md](./performance-hardening-overview.md).
## What needs to be built
Long-running / edge-case hardening and ops documentation. Do not raise the container memory limit with invented numbers — document how to measure with `dotnet-counters` and only change the limit if justified by measured peak.
---
## Step 1 — Cap fuzzy same-DOB candidates
- Before Levenshtein, `.Take(50)` (or equivalent) on same-DOB projection.
- Keep warning logs for near-misses within the capped set.
---
## Step 2 — Seed MinIO loop + CT
- Honor `CancellationToken` through seed document storage.
- Reduce N+1 pressure: skip exists checks when unnecessary, or batch/limit work; bootstrap must still succeed on empty and re-run environments.
---
## Step 3 — PromoteAsync CancellationToken
- Add CT to `IPromotionService.PromoteAsync` and pass from [`PromotionRetryService`](../../VigilCareRecordsAPI/BackgroundServices/PromotionRetryService.cs).
- Propagate into EF calls inside promote where practical.
---
## Step 4 — Ops notes + user directory clamp
- Add a short comment near the 1 G limit in `docker-compose.prod.yml` pointing at counters workflow in the overview (do not invent a new limit).
- Clamp `UserDirectoryService.ListByRoleAsync` with a sane max (e.g. 500) or document intentional unbounded small directories — prefer clamp for safety.
---
## Success criteria
- [x] Same-DOB fuzzy path never loads more than the configured Take cap
- [x] Seed bootstrap respects CT and does not regress empty-DB seed
- [x] Promotion retry still promotes with CT plumbed
- [x] User directory list is capped
- [x] Overview + this plan checklists updated; gap-analysis matrix rows 26–31 marked Done when Phases 19–22 complete
- [x] `dotnet test` passes
## Out of scope
- Premature GC mode changes
- Raising memory limit without measured peak evidence
- Frontend redesign
## Verification
1. `dotnet test VigilCareRecordsAPI.Tests/VigilCareRecordsAPI.Tests.csproj`
2. Smoke bootstrap against local compose
3. Mark overview Phase 22 + findings 9, 14, 15 → Done; mark Phases 19–22 complete in PRD / plans README when all merge
## Gate
Performance hardening stream complete when this phase and overview checklists are Done.