Restructure project requirements and design documentation

This commit is contained in:
Steffen committed 2026-10-04 16:20:06 +02:00
1 parent fa5e20f4d6
commit ebf50827d6
32 files changed
+2078 -485

No files matched your search

@@ -0,0 +1,54 @@
# Replaceable prototype authentication
## Status and purpose
Proposed design for US-13 and US-14, pending review. This suggestion does not authorize implementation or modify the authoritative requirements or architecture.
Use a simple authentication placeholder for the thesis prototype while making it straightforward to replace with a proper identity provider. Keep the ownership and access rules defined by US-13 and US-14 independent of how credentials are validated.
## Responsibility and replacement point
Authentication and authorization remain responsibilities of the API gateway, as shown in `Docs/Architecture/02_microservice_architecture.jpg`.
Use ASP.NET Core's standard authentication handlers, authenticated identities (`ClaimsPrincipal`), and authorization policies. Implement one small prototype authentication handler at the gateway. Avoid a custom authentication framework, a new identity microservice, or shared authentication implementation libraries across services.
The prototype handler validates pre-created test credentials and produces a stable application account identifier and role (`Patient` or `HealthcareProfessional`). Authorization and controllers consume this normalized identity rather than credentials or details specific to the authentication handler.
Roles must come from trusted account data, never from a role supplied by the client.
## Simple prototype mechanism
Use HTTP Basic authentication over HTTPS for the placeholder. The gateway validates the account identifier and password on each request, using password hashes and an established platform password-hashing facility. This requires no login endpoint, token issuance, session store, registration, or account administration.
Provide pre-created accounts through external configuration with safe example values. Do not commit actual credentials or log passwords or authorization headers. Enable the placeholder explicitly through configuration so it cannot become an accidental fallback when a replacement scheme is selected.
HTTP Basic is the initial credential transport, not a dependency of controllers or access policies.
## Application access data and policies
For the prototype, use externally configured account-to-patient mappings and predefined professional-to-patient assignments. Keep these application access records separate from credential validation. They do not require a new database or service for this prototype proposal.
- A patient account maps to exactly one patient identifier and may perform the operations permitted by the existing stories only for that patient.
- A healthcare professional account may read information for assigned patients and retrieve only its own assignment list. It may not create, modify, or delete patient information.
- A patient account cannot use operations reserved for healthcare professionals.
- Missing or invalid authentication rejects the request before patient information is returned or changed.
The gateway must establish the actual owner of resources addressed by resource identifiers, such as an observation identifier. A patient identifier supplied by the client alone is not proof of ownership. Ownership checks must use the documented service APIs; they must not access service databases directly or rely on shared process memory.
Protected service APIs must be reachable only through an authorized gateway path. The deployment must prevent clients from bypassing gateway authorization, including when services run on separate machines. Client-supplied identity headers must not be treated as trusted identity. The concrete gateway-to-service protection must be reviewed before implementation if it requires additions to the documented deployment design.
## Replacing the placeholder
Replace the prototype handler with the appropriate standard ASP.NET Core authentication integration for the selected identity provider. Normalize its validated identity into the same application account identifier and role used by the access policies. Maintain an explicit mapping from the provider's trusted identity to the application account; do not assume an arbitrary provider subject already equals the application account identifier.
Patient mappings, professional assignments, controllers, and authorization rules remain in place. Gateway authentication configuration and identity mapping change. Clients will also need to adopt the replacement provider's login and credential transport; replacement does not imply an unchanged client authentication flow.
Selecting an identity provider, implementing account lifecycle management, and claiming production readiness are outside this proposal.
## Verification when implemented
Cover the US-13 and US-14 acceptance criteria with automated tests. Verify that the same authorization behaviour holds when a test authentication handler supplies the normalized identity instead of the prototype handler. Include resource-ownership checks for operations addressed by observation identifier and confirm that unauthorized requests cannot return or change patient data.
## Separate requirement clarification
US-01 generates a patient identifier when creating a profile, while US-13 associates a patient account with a patient. Before implementing authenticated profile creation, clarify how the generated identifier becomes associated with that account. This proposal does not silently choose or change that behaviour.
@@ -0,0 +1,47 @@
# Requirements consistency review
Reviewed all 15 files currently under `Docs/Requirements/`, with the authentication design consulted for its explicit requirement reconciliation. Recommendations only; no authoritative documents or implementation changed.
## Conflicts and reconciliation recommendations
1. **US-13 excludes clinicians, whereas US-14 permits assigned healthcare professionals.** US-14 explicitly supplies replacement purpose and account wording but does not explicitly remove US-13's clinician exclusion. Keep US-14's assigned, read-only professional access. Amend US-13's exclusion to exclude unassigned third parties and professional writes, rather than all clinicians. Preserve its patient ownership restrictions.
2. **Account/profile cardinality is inconsistent.** US-13 says every account has exactly one patient; US-14 narrows this to patient accounts, but still requires exactly one. The authentication design allows a patient account to have no profile before US-01 creation and exactly one afterwards. Keep the design's lifecycle and US-14's professional assignments. State: a patient account has zero profiles before initial creation and exactly one afterwards; professional accounts have predefined assignments. Add US-01 scenarios for authenticated initial creation, duplicate prevention, persistent association and retry/concurrency recovery. US-13 successful login must also cover an account awaiting profile creation rather than require an existing associated patient in every case.
3. **US-11 implementation prerequisite differs.** The original story says the exact mathematical definition should be specified before implementation; the trend/interpretation addendum expressly lets implementation choose and document methods. Keep the newer permission, constrained by the full-period, reproducibility and clinical-evidence requirements. Explicitly replace the original prerequisite while retaining its invalid-period and no-data acceptance criteria.
## Missing or ambiguous requirement references
4. **US-11 context addendum references absent material.** Its scope refers to an original v4 document, temporary conventions 12 and 13, endpoint-only acceptance scenarios and an original two-observation rule. None are present in the current requirements set. Keep the new full-period and temporal-sufficiency requirements; remove those references and state the operative rules directly. Two observations at distinct timestamps may be a minimum, but sufficiency must follow the documented method. Endpoint equality alone must not establish stability.
5. **US-06 tie rule has no original definition.** The context addendum claims to preserve timestamp tie rules, but the original US-06 supplies none. The new acceptance scenario selects the observation recorded most recently. Keep that new rule and state it explicitly in US-06: select greatest measurement timestamp, then latest recording time. Define a deterministic final tie rule if recording times also match; do not reuse recording order to determine US-11 direction.
6. **US-10 refers to unspecified rounding.** The addendum says existing rounding and one-observation behaviour remain unchanged, although the original story defines neither explicitly. `125.00` in an example does not define fractional rounding. Keep original arithmetic means and extrema, including a one-observation summary; explicitly document precision/rounding after checking existing behaviour. Do not silently infer two-decimal rounding from formatting.
7. **Repeated inclusive-boundary references lack a baseline definition.** Original period examples do not state boundary inclusion, while the new US-07 boundary scenario explicitly includes both endpoints. Keep the new inclusive rule and define it once for all period-based stories: start <= measurement timestamp <= end. Preserve rejection of end before start; clarify equal-bound periods as valid if that is the intended rule.
8. **Comparability and interpretation need a clear relationship.** The US-11 context addendum correctly says broad matching categories alone do not certify identical conditions. Clarify that missing preparation details limit the claims that can be made; they do not automatically prevent every setting-appropriate reference comparison. Keep both numerical assessment with limitations and evidence-based clinical interpretation. Applicable guidance determines which details are necessary for a particular clinical claim.
9. **Guidance access is unspecified.** US-15 protects patient data but does not explicitly choose whether general guidance itself requires authentication. This is a gap, not a conflict with US-13's protected patient-data operations. Recommendation: general guidance can be read without patient-data access; any patient-specific information remains protected. Record an explicit decision before implementing its access contract.
## Compatible additions to retain
- US-04's independently recordable setting/activity extends optional context; absent context and original free text remain valid. It does not make context mandatory.
- US-05 through US-09 preserve retrieval, latest-by-measurement-time selection, chronological history, numerical validation, ownership and deletion while adding context behaviour. US-08 adds context-only partial updates; the original does not forbid them.
- US-10 context filtering is optional; unfiltered arithmetic statistics still include all eligible observations, including unknown conditions. Numerical summaries and US-11 clinical assessments have different sufficiency needs.
- US-11's two addenda complement each other: one defines assessment behaviour, the other context selection and comparability. Preserve both, with explicit precedence over the original algorithm prerequisite.
- US-12 explicitly applies context selection to insight only and leaves latest observation overall. This is compatible with the original. Keep profile/latest when a selection produces no insight; do not add a trend component implicitly.
- US-15 is an additional story, compatible with valid observations made under nonrecommended conditions. Guidance must remain optional.
- The US-10 correction is compatible with numerical requirements but prescribes the baseline architecture. Recommend locating that architectural decision under Architecture and retaining architecture-neutral functional requirements so it does not constrain every experimental variant.
- US-01 through US-03 have no new numerical/context conflict. Authentication adds access preconditions; missing-resource behaviour applies after authorization without disclosing another patient's information.
- Functional invariance remains valid once the expanded requirements are applied to every compared variant and the acceptance suite. Previously completed stories need additional work for the new addenda; an old passing suite does not establish compliance with the expanded requirements.
## Separate design alignment
The Insights class diagram currently describes one Trend direction/description and an ObservationDto without structured measurement context. The new requirements need separate measurement assessments and context transfer. This is a design-alignment issue rather than a reason to discard the new requirements. Review and approve the necessary contract/design updates before implementation under AGENTS.md; keep service/process boundaries and on-demand calculation.
The endpoint-only proposal in `suggestions/us11-trend-definition.md` is unapproved and incompatible with the new US-11. It is not an authoritative requirement conflict; retire it after the new requirements are reconciled.
## Recommended consolidation
Keep the original US-01–US-12 behaviours wherever compatible, incorporate the new context requirements and full US-11 assessment, and retain US-13–US-15. Give each story one current definition, explicitly record replaced clauses, and state common access/period/context rules once. Do not rely on absent document versions or implementation conventions as requirements.
+23
View File
@@ -0,0 +1,23 @@
# US-11 — Proposed trend definition
## Required clarification
US-11 explicitly requires a mathematical definition before implementation. No definition was found in the requirements or design documents. The Insights class diagram defines a single `direction` and `description`, but does not identify the measured value, algorithm, or minimum sufficient data.
## Proposed definition (pending approval)
- Calculate on demand in the existing Insights Service using observations retrieved through the gateway for the requested patient and inclusive period. Do not store trend results.
- The single direction describes systolic blood pressure. State this explicitly in the response description; do not imply a combined trend across systolic, diastolic, and pulse.
- Require observations at two or more distinct measurement timestamps. Empty data, a single observation, or observations all measured at the same timestamp indicate insufficient data.
- Compare mean systolic values at the earliest and latest measurement timestamps. If multiple observations share either endpoint timestamp, use their decimal arithmetic mean, so identifier ordering does not determine direction.
- Return `Increasing` when the latest mean exceeds the earliest mean, `Decreasing` when it is lower, and `Stable` when equal. No tolerance threshold, regression, smoothing, or clinical interpretation is introduced. Intermediate observations do not affect this endpoint comparison.
- Return the documented patient identifier, period start/end, direction, and a description explaining the comparison.
- Use existing period validation and missing-data conventions: `400` for invalid bounds, `404` problem details for insufficient data, and `502`/`504` for upstream failures.
This simple definition identifies net change between the endpoints, not the shape of change during the period. Choosing a different measured value or a regression-based trend would produce different product behaviour and requires an explicit decision.
## Verification after approval
Cover increasing/decreasing/stable results, endpoint timestamp ties, sufficient/insufficient data, exclusion of other patients and out-of-period measurements, independence from insertion order, invalid periods, and fresh results following observation corrections/deletions. Retain existing Insights architecture and independent process boundaries.
This suggestion does not authorize implementation or modify authoritative requirements.