Initial commit: architecture design instructions and documentation

This commit is contained in:
Steffen committed 2026-10-13 13:38:21 +02:00
commit 4bbf5afe3e
64 files changed
+8819

No files matched your search

@@ -0,0 +1,62 @@
# Requirements-to-implementation traceability
Authoritative scope: [common requirements](../Docs/Requirements/00-common-requirements.md), numbered US-01–US-15, [US-16](<../Docs/Requirements/US16 easy installation and deployment installer.txt>) and [installer addendum](../Docs/Requirements/us16-addendum). This is a static implementation/test review, not a new acceptance-test execution report.
**Implemented** means required behavior is visible in source and mapped tests. **Implemented with limits** means mechanisms exist but some scope/operational evidence is incomplete. No whole US-01–US-15 was found absent. That does not certify every clinical statement or possible deployment/input case. Test coverage references are evidence of checks present, not a claim they passed during this task.
## Story mapping
| Story | Observable implementation / acceptance behavior | Source and relevant tests | Status / limits |
| --- | --- | --- | --- |
| [US-01 create profile](../Docs/Requirements/us01-create-patient-profile.md) | Authenticated initial creation; required name/birth date; generated ID and atomic account association; repeat 409; unique index handles concurrent creation; persistence/retry/DB rollback | [application](../src/PatientProfileService/Application/PatientApplicationService.cs), [repository](../src/PatientProfileService/Persistence/SqlPatientRepository.cs), [CreatePatientTests](../tests/PatientProfile.AcceptanceTests/CreatePatientTests.cs), [PatientAuthenticationTests](../tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs) | Implemented. Interrupted DB writes are checked with a trigger; lost response is approximated by retry after success. No separate process-kill-at-every-write-boundary test. |
| [US-02 view profile](../Docs/Requirements/us02-view-patient-profile.md) | Persisted DTO includes ID/name/date/contact; protected own/assigned reads; absent 404 | [controller](../src/PatientProfileService/Controllers/PatientController.cs), [CreatePatientTests](../tests/PatientProfile.AcceptanceTests/CreatePatientTests.cs), [ProfessionalAccessTests](../tests/Observation.AcceptanceTests/ProfessionalAccessTests.cs) | Implemented. Covered in creation/access suites rather than a separate ViewPatientTests file. |
| [US-03 update profile](../Docs/Requirements/us03-update-patient-profile.md) | Update name/contact; ID/birth/account/original creation preserved; missing does not create | [SQL repository](../src/PatientProfileService/Persistence/SqlPatientRepository.cs), [UpdatePatientTests](../tests/PatientProfile.AcceptanceTests/UpdatePatientTests.cs) | Implemented. Birth-date editing is not an accepted story behavior. |
| [US-04 record observation](../Docs/Requirements/us04-record-observation.md) | Timestamp and positive numerical values; patient lookup before own DB save; independent context dimensions, optional details, unknown defaults, legacy text retained, later read | [application](../src/ObservationService/Application/ObservationApplicationService.cs), [mapping](../src/ObservationService/Persistence/ObservationDbContext.cs), [RecordObservationTests](../tests/Observation.AcceptanceTests/RecordObservationTests.cs), [RecordMeasurementContextTests](../tests/Observation.AcceptanceTests/RecordMeasurementContextTests.cs), [migration test](../tests/Observation.AcceptanceTests/MeasurementContextMigrationTests.cs) | Implemented with limits: preservation is general; narrative conflict interpretation uses US-11 finite phrases. No arbitrary-language conflict detector. |
| [US-05 view observation](../Docs/Requirements/us05-view-observation.md) | Read by observation ID includes current measurements/time/context/note; owner/assignment lookup before access; missing 404 | [controller](../src/ObservationService/Controllers/ObservationController.cs), [ViewObservationContextTests](../tests/Observation.AcceptanceTests/ViewObservationContextTests.cs) | Implemented. Directly seeded Given states verify retrieval independently of creating a reading. |
| [US-06 latest](../Docs/Requirements/us06-latest-observation.md) | Greatest measurement time, then original recording time, then greatest UUID; context completeness ignored; no observations 404 | [repository](../src/ObservationService/Persistence/SqlObservationRepository.cs), [LatestObservationTests](../tests/Observation.AcceptanceTests/LatestObservationTests.cs) | Implemented, including deterministic complete ties across restart. |
| [US-07 history](../Docs/Requirements/us07-observation-history.md) | Inclusive/equal periods, ascending time/UUID, selected dimensions AND, explicit Unknown, no-selection includes all, empty array, metadata headers, invalid selections rejected | [controller](../src/ObservationService/Controllers/ObservationController.cs), [repository](../src/ObservationService/Persistence/SqlObservationRepository.cs), [ObservationHistoryTests](../tests/Observation.AcceptanceTests/ObservationHistoryTests.cs), [ContextFilteredHistoryTests](../tests/Observation.AcceptanceTests/ContextFilteredHistoryTests.cs) | Implemented. Full unpaginated result is actual contract; no requirement for pagination. |
| [US-08 correction](../Docs/Requirements/us08-update-observation.md) | Numeric PUT; partial PATCH adds/corrects/clears individual context fields; omitted fields preserved; unsupported fields/category rejected before save; current selection/calculation membership | [patch](../src/ObservationService/Contracts/PatchObservationRequest.cs), [repository](../src/ObservationService/Persistence/SqlObservationRepository.cs), [UpdateObservationTests](../tests/Observation.AcceptanceTests/UpdateObservationTests.cs), [PatchObservationTests](../tests/Observation.AcceptanceTests/PatchObservationTests.cs) | Implemented. No concurrent-update conflict detection, outside explicit story criteria. |
| [US-09 delete](../Docs/Requirements/us09-delete-observation.md) | Physical row/context deletion; no later read/history/statistics contribution; unaffected remaining data; access controls | [repository](../src/ObservationService/Persistence/SqlObservationRepository.cs), [DeleteObservationTests](../tests/Observation.AcceptanceTests/DeleteObservationTests.cs), [DeleteContextualisedObservationTests](../tests/Observation.AcceptanceTests/DeleteContextualisedObservationTests.cs) | Implemented. No separate stored result/context lifecycle to clean up. |
| [US-10 numerical insight](../Docs/Requirements/us10-calculated-insight.md) | Current filtered observations; arithmetic means/final two-decimal half-up; BP extrema; single sufficient; empty insufficient 404; explicit selection/count/context limitations | [calculator](../src/InsightsService/Domain/InsightCalculator.cs), [HealthInsightTests](../tests/Observation.AcceptanceTests/HealthInsightTests.cs), [ContextSelectedInsightTests](../tests/Observation.AcceptanceTests/ContextSelectedInsightTests.cs) | Implemented. No stored summary per baseline correction. |
| [US-11 trend](../Docs/Requirements/us11-health-trend.md) | Three separate metric assessments, full-period direction/OLS/variation, reversals and timestamp ties, reference scopes/limits, context comparability, selections and unavailable parts; corrections/deletions fresh | [calculator](../src/InsightsService/Domain/InsightCalculator.Trends.cs), [HealthTrendTests](../tests/Observation.AcceptanceTests/HealthTrendTests.cs), [method documentation](../src/TRENDS.md) | Implemented with limits: finite narrative phrases and locally coded clinical inferences need separate clinical review for broader claims; not independently validated here. |
| [US-12 overview](../Docs/Requirements/us12-health-overview.md) | Profile + latest overall + selected-period insight; latest context distinct; no-match keeps available parts; unknown/mixed explanations; invalid period/access/failures | [application](../src/HealthOverviewService/Application/HealthOverviewApplicationService.cs), [HealthOverviewTests](../tests/Observation.AcceptanceTests/HealthOverviewTests.cs) | Implemented. No trend component and no cross-service snapshot, both documented. |
| [US-13 patient authentication](../Docs/Requirements/us13-patient-authentication.md) | Valid generic login; opaque expiry/tamper checks; own-data restrictions by actual owner; profile-less login/create; persistence/bypass protection | [security](../src/ApiGateway/Security/PatientAccessMiddleware.cs), [PatientAuthenticationTests](../tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs), [AuthenticationIntegrationTests](../tests/PatientProfile.AcceptanceTests/AuthenticationIntegrationTests.cs) | Implemented. Test clocks/replacement handlers are test-only; native secrets/files/network remain deployment responsibilities. |
| [US-14 professional reads](../Docs/Requirements/us14-professional-access.md) | Login role, own assignment list, many-to-many assignment reading including context/trends/overview; empty/missing results; unassigned concealment; all writes rejected | [assignments](../src/ApiGateway/Security/ProfessionalAssignments.cs), [ProfessionalAccessTests](../tests/Observation.AcceptanceTests/ProfessionalAccessTests.cs), [trend](../tests/Observation.AcceptanceTests/HealthTrendTests.cs), [overview](../tests/Observation.AcceptanceTests/HealthOverviewTests.cs) | Implemented. Fresh installer professional has no assignments; configured examples/tests demonstrate assigned workflow. Assignment administration is excluded. |
| [US-15 guidance](../Docs/Requirements/us15-measurement-guidance.md) | Public ordered sourced home/rest instructions, applicability/review dates, pulse/activity limits, unavailable setting explanation, no record/certification side effects; valid submission independent of viewing | [controller](../src/ApiGateway/Controllers/MeasurementGuidanceController.cs), [MeasurementGuidanceTests](../tests/PatientProfile.AcceptanceTests/MeasurementGuidanceTests.cs), [record-context tests](../tests/Observation.AcceptanceTests/RecordMeasurementContextTests.cs) | Implemented. Clinical references are compiled metadata, not dynamically refreshed guidance or evidence of current source validation in this task. |
| US-16 independent installation plus addendum | Selected payloads/processes/config; matching keys/HTTPS trust; runtime/PostgreSQL provisioning, separate DBs/roles/migrations; colocated/distributed origins; verification | [installer](../deploy/installer/install.sh), [provisioner](../deploy/HealthApp.Provisioning/Program.cs), [InstallationTests](../tests/Deployment.AcceptanceTests/InstallationTests.cs), [BootstrapTests](../tests/Deployment.AcceptanceTests/BootstrapTests.cs) | Implemented with operational/verification limits detailed below. Windows/macOS extend the Linux requirement text. |
## US-11 acceptance groups
| Criteria | Implementation/test basis |
| --- | --- |
| A/B/C: separate metrics, patient/period, direction | `CalculateTrend`, `AssessMeasurement`; separate units and all-timepoint calculations; tests `Full_period_direction_and_separate_units_and_levels`, `Inclusive_patient_period_and_equal_offset_instants_apply_before_sufficiency` |
| D/E: intermediate excursion and reversal | Raw range plus grouped adjacent absolute change/sign reversals; tests `Equal_endpoints_do_not_hide_intermediate_excursion_or_reversal`, `Overall_decrease_can_coexist_with_reversals_and_large_variation` |
| F/G/H/I: levels/interpretations/conflicting metrics | Applicable reference comparisons and separate hints; tests `Low_variation_outside_reference_is_not_healthy`, `Favourable_pressure_decrease_can_still_be_high_while_falling_pulse_is_concerning`, pulse boundary/tie excursion tests; independent clinical assessment remains unperformed |
| J/K/L: missing context, insufficiency, reference values | `AssessComparability`/`SelectReference`, explicit unavailable parts and provisional references; missing preparation/inadequate rest/setting-specific reference tests |
| M/N: ordering independence and freshness | Timestamp grouping/sorting; fresh HTTP history on each call; tests `Retrieval_and_identifier_order_do_not_change_results_including_ties`, `Corrected_values_context_and_deletions_are_used_on_every_request_after_restart` |
| Context additions | Filtered history retrieval, metadata and comparability evidence; selected Home/Clinic/Unknown, empty/single series and contradictory phrase tests |
All named tests above are in [HealthTrendTests.cs](../tests/Observation.AcceptanceTests/HealthTrendTests.cs).
## US-16 acceptance groups and operational gaps
| Criterion | Evidence | Remaining uncertainty / incomplete verification |
| --- | --- | --- |
| A/B/C selected/single/multiple/all | Release selection, installer selection, distinct payloads/units, direct independent processes | Normal single-node partial installation must reuse a plan with reachable remote dependencies or defer final topology check; creating a new default plan is not discovery of an existing deployment. |
| D independent config | Per-service env/JSON/certificates/origins/DB values; native configuration tests | Source templates and generated units differ; document generated behavior. |
| E separate machines | Runtime origins and HTTP are location-independent; scoped SSH/SCP distribution tests | Real separate-machine native deployment/network evidence not established by loopback/double tests. |
| F independent service management | Native registrations have no peer coupling; direct process stop/restart tests | Linux/Windows/macOS manager behavior must be demonstrated on native hosts; no new native run was performed here. |
| G persistence ownership | Separate DB/role generation, PUBLIC revocation, dedicated credential checks | Normal DB credentials own schema for migrations; mandatory encrypted DB transport is not implemented. |
| H preserve architecture | Same DLLs and Gateway-routed APIs on all layouts | No container/shared-memory/merged-service runtime path present. |
| I installation verification | Native active/PID checks (Linux/Windows), HTTPS/DB/callback probes, complete synthetic workflow | Live verifier does not explicitly stop/restart each service; macOS has no explicit distinct-PID comparison. Literal `all` enables complete verification in local wrappers; listing all five names does not. |
| Addendum dependencies/config | Apt ancestry/package checks; generated secrets/CA/PFX/roles/config/migration/native startup | Package doubles do not prove every distro/version/CPU; Linux automation limited to Debian/Ubuntu family; Windows/macOS packages/native execution require native evidence. |
## Missing functionality versus scope exclusions
No wholly unimplemented accepted backend user story was identified by this static review. Concrete incomplete **verification** items are native stop/restart demonstration in the live verifier, explicit macOS PID separation, complete-workflow verification for the five-name selection form, and actual multi-machine/native-platform evidence. General narrative understanding and independent clinical applicability remain **unknown**, rather than established complete capabilities. See [discrepancies](discrepancies.md) for exact evidence.
Registration, recovery, MFA, refresh tokens, professional credential verification, consent/emergency access, professional writes, assignment administration, a product frontend, pagination, optimistic concurrency, backup/restore, HA and production hardening are not accepted features established by the inspected stories. Their absence is recorded without adding scope or treating suggestions as approved requirements.
## Shared constraints
Ownership/professional access applies across all patient-specific routes; guidance alone is public. Inclusive/equal periods and offset normalization apply consistently to history, summary, trend and overview insight. `Unknown` is independently selectable; legacy narrative is never converted to a definite category. Persistence/restart tests and migration tests check ownership and context continuity. The snapshot is backend/source complete but not a claim that tests, external clinical sources or every deployment platform were freshly validated.