diff --git a/Docs/Requirements/US16 easy installation and deployment installer.txt b/Docs/Requirements/US16 easy installation and deployment installer.txt new file mode 100644 index 0000000..cc20bfa --- /dev/null +++ b/Docs/Requirements/US16 easy installation and deployment installer.txt @@ -0,0 +1,142 @@ +# US-16 – Install and Deploy Services Independently + +## User Story + +As a system administrator, +I want to install one or more HealthApp services on a Linux system, +so that each service can be deployed independently or multiple services can be colocated on the same machine without losing their independent service boundaries. + +## Description + +The HealthApp consists of independently deployable services. + +The installation mechanism must support both: + +1. installing an individual service on a machine; and +2. installing multiple or all HealthApp services on the same machine. + +When multiple services are installed on the same machine, each service must remain an independent operating-system process with its own configuration and service registration. + +Installing services together must not combine them into a single process or otherwise remove the architectural separation between services. + +The installation mechanism must support the services defined by the current architecture, including the API Gateway and application microservices. + +## Acceptance Criteria + +### AC-16-A – Install a Single Service + +**Given** a supported Linux system +**When** the administrator selects one HealthApp service for installation +**Then** only the selected service is installed +**And** it can be started and stopped independently +**And** installation does not require the other HealthApp services to be installed on the same machine. + +--- + +### AC-16-B – Install Multiple Services on One Machine + +**Given** a supported Linux system +**When** the administrator selects multiple HealthApp services for installation +**Then** all selected services are installed +**And** each service runs as an independent operating-system process +**And** each service can be started, stopped and restarted independently. + +--- + +### AC-16-C – Install the Complete System on One Machine + +**Given** a supported Linux system +**When** the administrator chooses to install the complete HealthApp system +**Then** all required HealthApp services are installed +**And** every service remains an independently managed service/process +**And** the services can communicate using the same network interfaces used when deployed on separate machines. + +--- + +### AC-16-D – Independent Configuration + +**Given** an installed HealthApp service +**When** its deployment configuration is provided +**Then** service-specific configuration can be supplied independently of the configuration of other services. + +This includes configuration required by that service, such as: + +- network address and port; +- dependent service endpoints; +- database connection information where applicable; +- service credentials and other deployment-specific settings. + +No service may require hard-coded knowledge that another service is installed on the same machine. + +--- + +### AC-16-E – Separate-Machine Deployment + +**Given** HealthApp services installed on different machines +**When** their service endpoints and required credentials are configured correctly +**Then** the services can communicate according to the documented architecture +**Without** requiring shared process memory, shared local files, or localhost-specific assumptions. + +--- + +### AC-16-F – Service Management + +**Given** an installed service +**When** the operating system starts, stops or restarts that service +**Then** the service can be managed independently from the other HealthApp services. + +Stopping or restarting one service must not directly stop or restart another service. + +--- + +### AC-16-G – Persistence Independence + +**Given** a service that owns persistent data +**When** that service is installed +**Then** its persistence configuration is independent of the persistence configuration of other services. + +Installing multiple services on one machine must not cause services to share persistence that the documented architecture defines as separately owned. + +Services without persistence must not gain persistence merely because they are installed together with persistent services. + +--- + +### AC-16-H – Installation Does Not Change Architecture + +**Given** any supported installation arrangement +**When** services are installed individually or together +**Then** the logical service boundaries, communication paths, persistence ownership and responsibilities defined by the architecture remain unchanged. + +Deployment location must not change the behaviour or responsibility of a service. + +--- + +### AC-16-I – Installation Verification + +**Given** a completed installation +**When** installation verification is performed +**Then** each installed service can be shown to: + +- start successfully; +- run as its own process; +- accept its configured network traffic where applicable; +- use its configured dependencies; +- stop and restart independently. + +For a complete-system installation, representative application operations must successfully pass through the deployed services. + +--- + +## Notes + +This user story concerns deployment and installation only. + +It does not authorize: + +- merging microservices; +- changing service responsibilities; +- introducing shared persistence; +- changing the documented communication architecture; +- changing existing functional user stories. + +The same application executables should support both colocated and distributed deployment through configuration rather than separate implementations. diff --git a/Docs/Requirements/us16-addendum b/Docs/Requirements/us16-addendum new file mode 100644 index 0000000..3fcb335 --- /dev/null +++ b/Docs/Requirements/us16-addendum @@ -0,0 +1,135 @@ +## Required installer behaviour + +The installer must support installing: + +- one selected HealthApp service; +- multiple selected services; +- all HealthApp services on the same machine. + +Each application service must still run as an independent systemd service/process. + +### PostgreSQL + +Where an installed service requires PostgreSQL persistence, the installer must: + +- detect whether PostgreSQL is already available; +- install PostgreSQL when necessary on supported Linux distributions; +- create the required database(s); +- create dedicated database user credentials; +- generate suitable passwords rather than using hard-coded credentials; +- assign only the permissions required by the owning service; +- configure the application service to use its database; +- run any required database migrations. + +Patient Profile and Observation persistence must remain separately owned. + +Installing both services on the same PostgreSQL server is allowed, but they must use separate databases and service credentials. + +Services without persistence must not receive databases. + +### Application/service credentials + +The installer must generate the credentials needed for communication between the deployed HealthApp services. + +Credentials must: + +- not be hard-coded in the repository; +- be generated during installation; +- be stored in files or configuration readable only by the appropriate service account/root where practical; +- be configured automatically into the relevant services. + +The administrator should not have to manually invent and distribute inter-service credentials for a normal installation. + +### HTTPS certificates + +The installer must configure HTTPS for the installed services. + +For the prototype, certificates do not need to be publicly trusted. + +The installer may generate a local/self-signed certificate or a small local certificate authority and issue certificates from it. + +The goal is encrypted HTTPS communication, not public PKI validation. + +The installer must: + +- generate the required certificate/key material if none is supplied; +- configure each installed service to use HTTPS; +- configure the relevant local trust relationships required for HealthApp services to communicate successfully; +- protect private key material using appropriate filesystem permissions. + +It should remain possible to replace the generated prototype certificates with externally supplied trusted certificates later. + +### Service configuration + +The installer must generate the configuration necessary for the selected deployment, including as applicable: + +- listening address; +- HTTPS port; +- URLs of dependent HealthApp services; +- database connection strings; +- database credentials; +- inter-service credentials; +- certificate paths; +- environment-specific configuration. + +A normal installation must not require manually editing application configuration files after installation. + +### Linux service installation + +For each selected HealthApp service, the installer must: + +- install/publish the application; +- create the necessary service account where appropriate; +- create its systemd unit; +- enable the service; +- start the service; +- verify that it starts successfully. + +### Verification + +At the end of installation, perform an installation verification that checks at minimum: + +- each selected systemd service is running; +- each selected service is listening on its configured HTTPS endpoint; +- required PostgreSQL databases are reachable; +- service-to-service communication works for the installed topology; +- representative application functionality works when the complete system is installed. + +If installation or verification fails, report clearly which step failed. + +## Deployment principle + +The installer should make the selected topology work. + +For example: + +Machine A: +- API Gateway +- Patient Profile +- Observation +- Insights +- Health Overview +- PostgreSQL + +or: + +Machine A: +- API Gateway + +Machine B: +- Patient Profile +- PostgreSQL + +Machine C: +- Observation +- PostgreSQL + +Machine D: +- Insights + +Machine E: +- Health Overview + +The application binaries and architectural boundaries must remain the same in either case. + +Do not require the administrator to manually create PostgreSQL databases, application credentials, or prototype HTTPS certificates as a prerequisite for installation. diff --git a/suggestions/test-requirements-architecture-alignment-review-2026-10-05.md b/suggestions/test-requirements-architecture-alignment-review-2026-10-05.md new file mode 100644 index 0000000..5dacb58 --- /dev/null +++ b/suggestions/test-requirements-architecture-alignment-review-2026-10-05.md @@ -0,0 +1,256 @@ +# Test alignment review — 2026-10-05 + +Reviewed baseline: `b6342af`, including the renamed non-persistence ER illustrations. +Scope: all test classes/support/fixtures in both test projects; US-01–US-15 and +common requirements; current architecture diagrams/correction; authentication design; +relevant gateway/client/DTO behaviour needed to interpret what a test actually exercises. + +Fresh verification: `dotnet test HealthApp.slnx -c Release --no-restore` against isolated +real PostgreSQL: **265 passed, zero failed, zero skipped** (29 PatientProfile, 236 +Observation project). The projects also built as part of that run. The temporary database +container was removed afterwards. No implementation, requirements or test expectations +were changed by this review. + +## Conclusion + +The suite broadly agrees with the specified product and its logical service/data +boundaries. There is useful automated evidence for every story. However, passing +265 tests does **not** demonstrate complete acceptance or deployment coverage. +There are misleading/mismatched test fixtures and coverage gaps below. These are +primarily test-evidence findings, not proof that the corresponding production +operation is broken. Earlier claims that every acceptance criterion was covered +were too broad, especially for all-route authentication and process isolation. + +Keep the existing behavioural expectations; strengthen coverage rather than +weakening tests or changing the requirements. This report replaces the earlier +coverage review's remaining-work conclusions for test alignment only; that older +review remains a historical pre-implementation snapshot. + +## Findings and recommended corrections + +### F1 — High: authentication coverage is incomplete for the current route set + +References: +- `tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs:63` +- `tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs:200` +- `tests/Observation.AcceptanceTests/ProfessionalAccessTests.cs:197` +- `tests/Observation.AcceptanceTests/PatchObservationTests.cs:182` +- `tests/Observation.AcceptanceTests/HealthTrendTests.cs:383` +- `tests/Observation.AcceptanceTests/HealthOverviewTests.cs:196` + +US-13 explicitly applies missing, invalid and expired authentication behaviour to +every applicable operation. The test named +`Missing_and_invalid_tokens_reject_every_existing_patient_operation` omits PATCH, +trends and overview. PATCH separately checks missing/invalid tokens, and trend/ +overview tests separately check missing tokens and owner/assignment rejection. +Expired-token testing is concentrated on profile retrieval and assignment-list access; +invalid/expired-token rejection is not explicitly exercised for trends and overview. +The additional shared middleware makes rejection plausible, but is not equivalent to +an assertion on each endpoint (an accidental endpoint exception could escape). + +Recommendation: a route/method table using real login, existing protected resources, +valid request bodies/periods, and explicit actors. Cover missing/invalid/expired tokens, +patient-owner/other-patient and assigned/unassigned professional reads. Verify no +protected body and unchanged state on rejected writes. Include PATCH and both newer +GET routes. This extends documented scenarios, not product functionality. + +### F2 — Medium: several missing-resource tests pass before reaching the intended service + +References: +- `tests/Support/AuthenticatedTestClient.cs:76` +- `tests/PatientProfile.AcceptanceTests/CreatePatientTests.cs:94` +- `tests/PatientProfile.AcceptanceTests/UpdatePatientTests.cs:36` +- `tests/Observation.AcceptanceTests/RecordObservationTests.cs:113` +- `tests/Observation.AcceptanceTests/UpdateObservationTests.cs:112` +- `tests/Observation.AcceptanceTests/PatchObservationTests.cs:169` +- `tests/Observation.AcceptanceTests/DeleteObservationTests.cs:79` +- `src/ApiGateway/Security/PatientAccessMiddleware.cs` + +For an unknown identifier the automatic authenticated client falls back to its last +account. An account without a profile, or an account whose own profile differs from +the random patient ID, gets an empty gateway 404 before the requested profile/record +operation is called. Observation-ID operations resolve the observation during access +checking and return 404 there before forwarding update/patch/delete to the operation. + +Those tests validly establish public rejection/non-disclosure/no mutation. They do +not separately prove the downstream controller/application/repository missing-resource +handling suggested by their names. Common requirements assume authorised callers for +ordinary missing-resource scenarios; the distinction should be explicit. + +There is already a genuinely assigned missing-profile GET test under US-14 and an +assigned missing-profile Overview test, so missing profile reads are not entirely +uncovered. Unknown observation ownership cannot simply be assigned to a caller. + +Recommendation: retain the public security tests and label them accurately. Add +service-component tests or authenticated internal-service HTTP tests for the remaining +missing-resource branches, using the actual service protection mechanism. Do not relax +public ownership checks or invent a public route that bypasses authorization. + +### F3 — Medium: trend calculator fixtures declare selections inconsistent with their data + +References: +- `tests/Observation.AcceptanceTests/HealthTrendTests.cs:20` +- `tests/Observation.AcceptanceTests/HealthTrendTests.cs:113` +- `tests/Observation.AcceptanceTests/HealthTrendTests.cs:137` +- `tests/Observation.AcceptanceTests/HealthTrendTests.cs:187` + +The calculator helper always supplies `Home` and `AtRest`. Some callers supply Clinic, +Unknown or AfterActivity observations. In the architecture the calculator consumes +already-selected observations; the HTTP history client performs selection. These +fixtures therefore describe an impossible selected-input/result-metadata combination +for those cases. Their numerical/context assertions are still useful unit assertions, +but they cannot demonstrate a valid selected-series assessment. + +Recommendation: let the helper accept an explicit selection. Use unrestricted +selection for mixed/unknown series and the matching Clinic selection for Clinic-only +series. Assert selection metadata as well as the relevant numerical/context behaviour. +Keep actual selection/exclusion assertions in the existing HTTP tests. + +### F4 — Medium: the suite does not verify independent OS-process deployment + +References: +- `tests/Observation.AcceptanceTests/ObservationApiFixture.cs:66` +- `tests/PatientProfile.AcceptanceTests/PatientApiFixture.cs:49` +- the microservice process boundary in `AGENTS.md` +- `Docs/Architecture/02_microservice_architecture.jpg` + +The main fixture creates real Kestrel endpoints and real HTTP calls, but all five +WebApplicationFactory hosts live inside the test process. The profile fixture uses +Kestrel for the profile and a gateway test server. Restart methods recreate hosts; +they do not restart separate operating-system processes. Development uses loopback +HTTP and a common fixture gateway-key value for multiple services. + +This is an acceptable integration-test arrangement, not itself a production architecture +violation. It cannot certify separate deployment, separate-machine networking, +production HTTPS/certificate configuration, independently surviving process failure, +systemd behaviour, or per-service credentials in an actual deployment. Test-only +project references and fixture DB inspection/seeding are not production cross-service +coupling; common requirements explicitly allow independent scenario setup. + +Recommendation: add a small separate-process acceptance/smoke test that starts the +published five executables with external configuration, distinct service credentials, +and independent patient/observation databases. Exercise representative reads/writes +and stop/restart an individual process. A deployment check should additionally verify +production HTTPS and systemd on the intended Linux hosts. Separate-machine operation +requires deployment evidence or equivalent network separation, not a claim based on +localhost tests alone. These checks need not replace fast existing integration tests. + +### F5 — Medium: US-11 clinical/context edge cases are mostly calculator-level evidence + +References: +- `tests/Observation.AcceptanceTests/HealthTrendTests.cs:12` +- `tests/Observation.AcceptanceTests/HealthTrendTests.cs:149` +- `tests/Observation.AcceptanceTests/HealthTrendTests.cs:173` +- `tests/Observation.AcceptanceTests/HealthTrendTests.cs:237` +- `tests/Observation.AcceptanceTests/HealthTrendTests.cs:341` +- US-11 context scenarios and AC-11-A through AC-11-N + +Separate metric interpretations, reversals, equal-timestamp handling and exercise- +narrative conflict are checked directly against InsightCalculator. HTTP tests cover +scope, filters, counts, invalid requests, context correction, deletion and access. +The layers together provide substantial evidence, but there is no full HTTP conflict +scenario proving original text travels from PostgreSQL through both gateway calls +into the trend calculation, nor an HTTP all-tied-timestamps scenario or a HTTP +storage/insertion-order equivalence check. Context clearing affecting clinical +interpretation is not directly checked by the trend API tests. + +Recommendation: add representative end-to-end cases for conflicting recorded text, +all-tied timestamps, context clearing and order independence. For clearing, preserve +numerical description but check withdrawn references/changed comparability and correct +Unknown-only selection. Verify all three metrics' relevant fields, not just systolic. + +The current missing-optional-details tests use either fully populated preparation +fields except additional circumstances, or all preparation fields missing. Add +individual omitted-detail cases to test US-11's narrower rule that a missing optional +detail only limits claims that depend on it. Distinguish reference comparison from +stronger trajectory/comparability claims; do not add invented clinical thresholds. + +### F6 — Lower priority: Overview's unknown-context case is not a fully absent-context fixture + +Reference: `tests/Observation.AcceptanceTests/HealthOverviewTests.cs:110`. + +That case submits null setting/activity but still supplies rest, posture, arm, device +and cuff through the record helper. It correctly verifies unknown categories. It does +not prove all preparation details remain absent when the latest reading truly has no +context while an older reading has complete context. + +Recommendation: add an older complete reading and a newest submission omitting the +entire context object, then assert Unknown categories and null optional fields in +latest. Assert that the insight's own context explanation is retained independently. + +## Additional evidence limits + +- Tests asserting clinical boundaries, a source-domain substring or words such as + "favourable" are regression evidence for the chosen implementation. They do not + independently validate the medical applicability of each inference. The US-11 + source-to-claim mapping in `src/TRENDS.md` remains part of the evidence and needs + explicit review when rules or sources change. This audit is not a clinical validation. +- The documented OLS slope has sign checks, but no exact irregular-spacing slope + fixture. A deterministic example with a hand-calculated slope would strengthen + evidence for the documented mathematical method without prescribing a new method. +- The suite verifies offset equivalence but does not rerun equivalent requests under + different service time zones. That would strengthen the machine-independent + offset-free UTC contract. +- HTTP failure tests usually stop a dependency to provoke a connection failure. + Invalid upstream JSON, upstream timeouts and client-disconnect cancellation are + not comprehensively tested. These are robustness/implementation-contract coverage + suggestions, not new user-story acceptance criteria. +- Many tests assert exact HTTP status, DTO equality, headers and explanation wording. + These are compatible implementation contracts, but common requirements do not make + every exact string/status a product requirement. Keep essential behaviour checks + distinct from presentation-contract regression tests. + +## Story-to-test traceability + +This table identifies existing evidence and qualifications, not an assertion that +all possible cases or every deployment property have been proven. + +| Story | Existing automated evidence | Qualification | +| --- | --- | --- | +| US-01 | CreatePatientTests; PatientAuthenticationTests login/create/retry/concurrency/restart/database-trigger rollback | Atomic association and recovery tested; F1 applies to cross-cutting authentication. | +| US-02 | CreatePatientTests retrieval after restart; ProfessionalAccessTests assigned/missing profile reads | Legacy random-ID test is gateway rejection (F2); assigned missing read is genuine evidence. | +| US-03 | UpdatePatientTests update/restart/no-mutation validation; ProfessionalAccessTests forbidden writes | Missing update is gateway rejection, not independent service behaviour (F2). | +| US-04 | RecordObservationTests; RecordMeasurementContextTests; MeasurementContextMigrationTests | Values, partial/absent/conflicting context, validation, migration and access covered; missing-patient recording needs F2 qualification. | +| US-05 | ViewObservationContextTests; RecordObservationTests; professional/ownership tests | Complete/partial/historical text and protected context have strong evidence; missing ID often stops at ownership lookup. | +| US-06 | LatestObservationTests | Actual deterministic seeded measurement/recording/ID ties and edits/restart covered. DB seeding is explicitly allowed. | +| US-07 | ObservationHistoryTests; ContextFilteredHistoryTests | Independent/combined/unknown filters, metadata, chronology, inclusive/equal/offset bounds and access covered. | +| US-08 | UpdateObservationTests; PatchObservationTests; selected-insight/trend/overview freshness tests | Partial correction/clearing/atomic rejection covered; F2 for missing operation and F5 for cleared trend interpretation. | +| US-09 | DeleteObservationTests; DeleteContextualisedObservationTests; trend/overview deletion tests | Persisted removal and exclusion are covered; missing delete component path is F2. | +| US-10 | HealthInsightTests; ContextSelectedInsightTests | Arithmetic means/extrema, exact rounding fixtures, selection metadata, pooled context and freshness covered. | +| US-11 | HealthTrendCalculationTests and HealthTrendTests (both in HealthTrendTests.cs) | Explicit AC-A–N numerical/interpretation evidence is divided between unit and HTTP tests; F3/F5 and source-validation limits apply. | +| US-12 | HealthOverviewTests | Profile/latest/selected insight/empty insight/limits/freshness/access/failure covered; F1/F4/F6 remain. | +| US-13 | PatientAuthenticationTests; AuthenticationIntegrationTests; story-level access tests | Real credentials/bearer validation/expiration/tampering/association tested; complete operation matrix missing (F1). | +| US-14 | ProfessionalAccessTests; story-level assigned/unassigned/write-rejection tests | Multiple/shared/empty assignments, spoofing, ownership and non-disclosure covered; newer-route invalid/expired authentication still F1. | +| US-15 | MeasurementGuidanceTests; RecordObservationTests valid submissions without guidance | Public, labelled, sourced, ordered/static guidance and no upstream access covered; source accuracy is not established by string assertions alone. | + +## Architecture alignment + +- Main interservice flows are actual HTTP through the API Gateway, consistent with + Observation, Insights and Overview class models. Production projects do not contain + references to other service implementations. +- Patient and observation fixture databases are separate. Migration/persistence tests + inspect only controlled test databases. This does not authorize production services + to access another service's database. +- Insights and Overview have no DB/repository registration; freshness is tested with + current corrections and deletions. The explicitly renamed ER illustrations do not + require persisted calculated results. +- The real authentication implementation is used for main functional/security tests. + A replacement handler is used only in specifically labelled replaceability tests; + it is not evidence for bearer cryptography and is not a measured workload. +- Fixtures replace the clock for deterministic expiry and load synthetic accounts; + deployment/measurement must use recorded production settings and real service + processes. The current test harness is not an energy-measurement workload. +- Production HTTPS is tested narrowly for the gateway login/guidance entry point. + Main service integration uses Development HTTP. Production transport protection + for every service and systemd deployment remains a separate verification task. + +## Recommended next work + +1. Complete the current route/method authentication matrix (F1). +2. Correct the inconsistent trend unit-fixture selections (F3) and clarify/add + missing-resource component evidence (F2). +3. Add the small number of end-to-end trend and absent-context overview cases (F5/F6). +4. Verify the separate-process deployed baseline (F4), before architectural/energy comparison. + +No architecture redesign or requirement rewrite is needed to improve these tests. +The review does not approve changed clinical rules or new product behaviour.