diff --git a/AGENT.md b/AGENT.md index e048654..f6b5fa2 100644 --- a/AGENT.md +++ b/AGENT.md @@ -1,106 +1,104 @@ -# AGENT.md — Requirements-Driven Architecture Design +# AGENT.md — Health App Architecture Implementation ## Mission -Design a coherent software architecture for the Health App based on the supplied requirements and relevant design constraints. Produce an architecture that can satisfy the application's required behaviour and is explicitly reasoned about in terms of potential energy efficiency. +Implement the **approved architecture for HealthAppRepositoryB** using the existing Health App implementation as the functional starting point. -Your task is **architecture design, not implementation**. Do not generate, edit, inspect, or request application source code. Do not implement services, infrastructure, scripts, tests, or deployment configurations. +The objective is to realize the architecture specified in `ArchitectureProposal/` while preserving the application's required and externally observable behaviour. This is **architectural restructuring**, not a new application, an opportunity to redesign functionality, or a general code-cleanup exercise. -Design an architecture justified by the documented requirements, constraints, and engineering trade-offs. Do not introduce complexity merely to produce a different architectural structure. +The architectural proposal is a design to implement, **not evidence of lower energy consumption**. Do not claim energy savings from implementation, reduced resource usage, faster execution, or architectural plausibility alone. -Evaluate architectural alternatives with **energy efficiency as an important design objective**. Explain which architectural characteristics could influence energy consumption, why, and under what assumptions. Consider potential trade-offs when selecting the proposed architecture. +## Authority and source material -## Inputs and authority +Read and classify the available documentation before starting work: -All documentation relevant to the application is located under `Docs/`. +1. **`Docs/` — authoritative functional and domain requirements.** Preserve user stories, acceptance criteria, domain rules, API contracts and externally observable success, alternative and failure behaviour. Where an older design in `Docs/` conflicts with the approved proposed architecture, retain its functional requirements but do not automatically retain its structural decisions. +2. **`ArchitectureProposal/` — target architecture.** Follow its architecture specification, decisions, diagrams, component boundaries, data ownership, communication, security and deployment requirements. Treat the proposal as approved only to the extent the user has explicitly designated it as the implementation target. If the proposal contains unresolved alternatives, open questions, or internal contradictions affecting implementation, ask before proceeding. +3. **`../HealthAppRepository/` — original Health App implementation and behavioural reference.** This is the sibling directory one level above `HealthAppRepositoryB`. Verify that it exists and is the intended original Git repository. Record its exact Git commit before using it as the starting reference. Inspect and copy required source files only into `HealthAppRepositoryB`; the original implementation is strictly read-only. Never commit or modify files in `../HealthAppRepository/`. +4. **Existing tests and public interfaces — behavioural evidence.** Preserve the original tests and their intent. Tests may need architecture-dependent wiring or integration adjustments, but never weaken, delete, or rewrite assertions simply to make failures disappear. -Before designing the architecture, recursively inspect and read the documentation contained in `Docs/`, including its subdirectories. +When requirements, proposed architecture and source implementation disagree, explicitly document the conflict. Functional requirements govern behaviour; the approved architecture governs structure; original source code helps establish existing observable semantics. **Do not silently choose between contradictory instructions.** -Use this documentation to establish the system's functional requirements, business rules, constraints, and expected behaviour. +## Scope -Distinguish mandatory requirements from existing architectural and design decisions. Existing architectural and design decisions may be reconsidered unless they represent explicit requirements or constraints. +In scope: -Where documents contain contradictions, ambiguities, or missing information that materially affect architectural decisions, request clarification rather than silently making assumptions. +- Restructure modules/services, ownership boundaries, dependencies, communication and data flows to conform to the approved architecture. +- Adapt persistence, deployment configuration, integration points, authentication boundaries and infrastructure as required by the proposed architecture. +- Make minimal supporting code changes that are necessary consequences of the architectural restructuring. +- Adapt or add tests to verify preservation of functional behaviour and conformity to the new architecture. +- Document material decisions, deviations, migrations, and steps needed to build and run the result. -Do not modify the original documentation under `Docs/`. Place all newly produced architecture documentation in `ArchitectureProposal/`. +Out of scope unless separately approved: -Treat sources according to their role: +- New or removed user-facing functionality, changed business rules, changed domain semantics or changed externally observable API behaviour. +- Algorithm replacements, micro-optimisations, speculative performance tuning, unrelated refactoring or technology substitutions not required by the approved architecture. +- Unrequested changes to the architecture proposal, functional requirements or the original source repository. +- Energy measurement, benchmarking as proof of energy savings, or invented claims of energy improvement. -1. **Functional requirements, acceptance criteria, and externally observable behaviour** are binding. Preserve them, including error and alternative scenarios. -2. **Domain concepts and genuine constraints** from the documentation must be respected where required by the functional requirements, acceptance criteria, documented non-functional requirements, or explicit user clarification. Record assumptions and unresolved ambiguities. -3. **Existing structural or technology decisions** described in documentation (such as service boundaries, number of databases, gateway placement, persistence allocation, protocols, or deployment topology) are **not binding solely because they appear in an earlier design**. Determine whether each is an explicit requirement or a design choice. If its status materially affects the architecture and is unclear, ask for clarification. +**Same functionality does not mean byte-for-byte identical code.** Code may change to implement different architectural boundaries, but each change must be justifiable as necessary for the target architecture or preserving functionality. -Design the architecture that best satisfies the documented requirements and constraints, with energy efficiency as an important design objective. +## Mandatory preparation — stop before coding -Evaluate relevant architectural alternatives and justify the selected approach based on their advantages, disadvantages, and expected consequences. +1. Inventory `Docs/` and `ArchitectureProposal/`, including all editable `.drawio` diagrams and their accompanying text. Identify inconsistencies or missing detail. +2. Locate and inspect the original implementation at **`../HealthAppRepository/`**. Verify its Git repository identity and current commit. Record the exact commit hash; if its working tree contains uncommitted changes or the intended baseline is ambiguous, ask which revision to use before copying any code. Treat this directory as read-only. +3. Record the original baseline revision, the target architecture revision, and the current `HealthAppRepositoryB` revision. Ensure the working tree is clean or obtain instructions on how to handle pre-existing changes. +4. Establish how the original system builds, starts and tests. Inventory its observable APIs, existing test suite, dependencies, supported deployment assumptions and data migration considerations. +5. Produce `ImplementationPlan/implementation-plan.md` containing: + - A mapping of every major proposed architectural decision to affected modules/files and concrete implementation tasks. + - A functional preservation plan, including how user stories/acceptance criteria and API contracts will be checked. + - A list of anticipated migrations, operational risks, and architectural uncertainties. + - A sequence of small, reviewable changes with verification checkpoints. + - Any decisions requiring user approval. +6. **Present the plan and request explicit approval before implementing architectural changes.** Do not begin code migration while material ambiguities remain unresolved. -Existing architectural decisions may be retained, modified, or replaced based on their suitability. Do not favour an architecture merely because it already exists, nor reject one because it resembles an existing design. +## Implementation rules -Prioritize architectural suitability and justified decisions over novelty or the number of changes proposed. +- Work only in `HealthAppRepositoryB` after approval; never modify the original implementation. +- Use the approved proposal as the architecture contract. If implementation cannot conform, stop, explain why and propose a documented deviation for approval before making it. +- Preserve functional requirements and observable behaviour, including authorization, validation, status codes, error cases, persistence semantics and key workflows, where specified. +- Avoid creating functionality simply because the target architecture makes it convenient. +- Make cohesive, incremental changes. Keep each commit focused and meaningful; do not mix architectural migration with unrelated cleanups. +- Preserve repository history and research evidence. Never rewrite history, force-push, delete source identifiers or erase original input documents without explicit authorization. +- Do not make silent changes to `Docs/` or `ArchitectureProposal/`. Record proposed corrections or necessary deviations in `ImplementationPlan/` for review. +- Do not modify tests to conceal regressions. New test infrastructure and architecture-specific integration tests are allowed; record why each test change was necessary. +- Security properties, data handling, failure behaviour, and deployability must not be weakened as a side effect of architectural restructuring. +- If essential information is missing, ask a focused question rather than inventing a design or requirement. -Never edit the supplied requirements or design input files. Record suggested clarifications separately. +## Verification -## Design boundaries +At each meaningful checkpoint: -- Work at **software architecture and system design level**: components and responsibilities, boundaries, interactions, domain concepts and relationships, conceptual class structures, data ownership, persistence, caching, concurrency, deployment topology, communication, and relevant architectural patterns. Domain and class diagrams describe the design, not existing source code. -- Preserve required capabilities and externally observable API semantics where specified. Do not invent new functional requirements. -- Prefer architectural simplicity where alternatives otherwise satisfy the requirements and design objectives comparably. Evaluate whether additional complexity offers justified benefits, including potential energy-efficiency benefits. -- You may consider a monolith, modular monolith, microservices, or another pattern; no pattern is inherently preferred unless the supplied requirements mandate it. -- Consider energy-related consequences of architectural decisions, including idle resource use, inter-process/network communication, duplicated runtime overhead, database footprint, serialization, and scaling behaviour. -- Distinguish **energy consumption** from latency, throughput, CPU usage, and memory usage. These are not interchangeable measurements. -- Exclude code-level tuning, compiler flags, algorithm replacement, and micro-optimizations. Do not include the energy cost of operating an LLM. -- Maintain security, data protection, maintainability, deployability, and correctness; energy is not the only design objective. +1. Build the affected components and run appropriate existing automated tests. +2. Check functional equivalence using requirements and observable interfaces, not merely successful compilation or an increased test count. +3. Verify architectural conformance against the specification and Draw.io diagrams (service/component boundaries, dependencies, communication, persistence, deployment and security). +4. Document tests that could not be executed and why; do not present untested behaviour as validated. +5. Record deviations, regressions, operational prerequisites and unresolved risks. -## Working procedure +At completion, provide a requirement-to-test/conformance summary. Distinguish **verified**, **partially verified** and **not verified**. Do not claim strict functional equivalence where evidence is insufficient. -1. **Inventory the inputs.** Identify each requirements and design source, its purpose, and missing information. Read all relevant material before designing. -2. **Create a requirements-and-constraints register.** Separate binding functional behaviour, non-functional requirements, domain rules, assumed constraints, and optional existing design decisions. Cite file paths and requirement/user-story IDs. -3. **Identify architectural drivers.** Explain which requirements and expected runtime behaviours influence topology, boundaries, data flow, storage, and energy use. Identify important unknowns, especially expected workload and deployment environment. -4. **Consider alternatives.** Compare at least two feasible architectural approaches at a high level, including likely strengths, weaknesses, and energy-related hypotheses. Do not assume the most distributed or most consolidated design is superior. -5. **Select and develop one complete proposed architecture.** Justify the choice; define necessary components, responsibilities, interfaces, domain concepts, conceptual class relationships, data ownership, communication, persistence, security boundaries, and deployment assumptions. Document the architecture in an authoritative written specification and consistent editable diagrams. Avoid implementation-specific details unless necessary to make the design unambiguous. -6. **Check coverage and consistency.** Map every user story and acceptance criterion to the components and interactions responsible for satisfying it. Flag gaps and conflicts; do not silently redefine requirements. -7. **Evaluate the design critically.** Identify risks, trade-offs, likely bottlenecks, uncertainties, and expected energy-related consequences of architectural decisions. Explain the reasoning and assumptions behind those expectations. +## Required implementation artifacts -If essential requirements are contradictory or a decision could materially alter the architecture, **stop and ask a focused question**. For smaller uncertainties, make the smallest explicit, reversible assumption and record it. +Maintain these in `ImplementationPlan/` (create when needed): -## Outputs +- `implementation-plan.md` — mapping, sequence, risks, approval status and checkpoints. +- `architecture-conformance.md` — architectural decisions implemented, evidence and approved deviations. +- `functional-equivalence.md` — mapped requirements, contracts, tests, outcomes and coverage limitations. +- `implementation-log.md` — architecture-driven changes with relevant commit IDs and reasons. +- `open-questions.md` — unresolved conflicts, assumptions and decisions awaiting approval. -Write all new artifacts under `ArchitectureProposal/`; do not overwrite or rewrite the provided `Docs/` inputs. +Also update build/deployment/readme instructions **in the implementation repository** as needed to accurately explain how to run the resulting architecture. Do not replace the approved architectural documentation unless the user explicitly authorizes it. -Create: +## Completion criteria -- `ArchitectureProposal/README.md` — overview, scope, status, input list, assumptions, and navigation. -- `ArchitectureProposal/software-architecture.md` — authoritative written specification of the chosen architecture, including architectural style, system boundaries, components and responsibilities, interfaces and interactions, data flows and persistence, domain model, security and trust boundaries, deployment and runtime behaviour, failure handling, and key assumptions. Refer to the diagrams and keep the written specification consistent with them. -- `ArchitectureProposal/requirements-traceability.md` — mapping from every functional requirement, user story, and acceptance criterion to the proposed architecture; gaps and open questions. -- `ArchitectureProposal/architecture-decisions.md` — significant decisions and rationale, alternatives considered, consequences, and rejected options. -- `ArchitectureProposal/energy-hypotheses.md` — for each energy-relevant decision: anticipated mechanism, expected effect, assumptions, dependencies, and possible counter-effects. These are design expectations, not measured results; do not invent numerical savings or measurement procedures. -- `ArchitectureProposal/risks-and-open-questions.md` — uncertainties, unresolved constraints, potential behavioural incompatibilities, and trade-offs. -- `ArchitectureProposal/diagrams/` — editable **`.drawio` source files** for at least: - - **System context diagram** — actors, external systems, and system boundary. - - **Logical component diagram** — architectural components, responsibilities, interfaces, and interactions. - - **Domain model diagram** — domain concepts, their relationships, and relevant constraints; independent of source-code classes. - - **Conceptual class diagram** — design-level classes/types, responsibilities, key attributes and associations needed to explain the domain and design; do not reverse-engineer or invent code-level implementation details. - - **Data ownership/persistence diagram** — ownership and storage relationships. - - **Deployment topology diagram** — runtime units, hosts/containers where relevant, and communication boundaries. - Add sequence diagrams for important cross-component use cases when useful. Do not provide image-only diagrams as the sole source. +Do not report the implementation as complete unless: -The proposed architecture must be sufficiently precise to guide implementation, but **do not write implementation code**. +- [ ] The approved target architecture is implemented or deviations are explicitly approved and documented. +- [ ] All functional requirements and acceptance criteria have been checked for preservation, with gaps disclosed. +- [ ] Tests and build/deployment verification results are documented honestly. +- [ ] Original source repository and original input documentation remain unchanged. +- [ ] Architecture-specific code and configuration changes are traceable to approved decisions. +- [ ] Changes unrelated to architectural restructuring have not been introduced without approval. +- [ ] No unmeasured energy-efficiency improvement is presented as an empirical result. -## Quality gate before declaring completion - -Confirm in the README that: - -- [ ] Every functional requirement, user story, and acceptance criterion is traceable to the proposed architecture; unresolved coverage gaps are explicitly identified. No requirement has been silently omitted or changed. -- [ ] All significant input design constraints have been classified as mandatory, assumed, or optional, with uncertainty recorded. -- [ ] The proposed architecture is internally consistent, satisfies the documented requirements and constraints, and its significant decisions are justified independently of whether they resemble existing designs. -- [ ] The authoritative software architecture specification is complete and consistent with the diagrams. -- [ ] The domain model and conceptual class diagram cover relevant domain concepts and design relationships without prescribing unnecessary implementation detail. -- [ ] All components have clear responsibilities and ownership of data. -- [ ] Key communication, security, deployment, and failure-handling concerns are addressed. -- [ ] Expected energy-related effects are presented with reasoning, assumptions, and potential counter-effects, not as established savings. -- [ ] Draw.io source diagrams are editable and consistent with the written design. -- [ ] No application source code or original input documents were changed. - -## Interaction and change control - -Work only on the architecture assignment defined here. You may add or revise files in `ArchitectureProposal/`. Do not change requirements, original design documents, or other repository areas without explicit authorization. Explain important uncertainties and seek approval when a requirement conflicts with a proposed decision. Do not present expected energy benefits as measured results. +This assignment is complete only when a functioning architecture-conformant implementation and its verification evidence have been produced, or when blockers and incomplete areas have been clearly reported. diff --git a/AGENTOldOutdated.md b/AGENTOldOutdated.md new file mode 100644 index 0000000..e048654 --- /dev/null +++ b/AGENTOldOutdated.md @@ -0,0 +1,106 @@ +# AGENT.md — Requirements-Driven Architecture Design + +## Mission + +Design a coherent software architecture for the Health App based on the supplied requirements and relevant design constraints. Produce an architecture that can satisfy the application's required behaviour and is explicitly reasoned about in terms of potential energy efficiency. + +Your task is **architecture design, not implementation**. Do not generate, edit, inspect, or request application source code. Do not implement services, infrastructure, scripts, tests, or deployment configurations. + +Design an architecture justified by the documented requirements, constraints, and engineering trade-offs. Do not introduce complexity merely to produce a different architectural structure. + +Evaluate architectural alternatives with **energy efficiency as an important design objective**. Explain which architectural characteristics could influence energy consumption, why, and under what assumptions. Consider potential trade-offs when selecting the proposed architecture. + +## Inputs and authority + +All documentation relevant to the application is located under `Docs/`. + +Before designing the architecture, recursively inspect and read the documentation contained in `Docs/`, including its subdirectories. + +Use this documentation to establish the system's functional requirements, business rules, constraints, and expected behaviour. + +Distinguish mandatory requirements from existing architectural and design decisions. Existing architectural and design decisions may be reconsidered unless they represent explicit requirements or constraints. + +Where documents contain contradictions, ambiguities, or missing information that materially affect architectural decisions, request clarification rather than silently making assumptions. + +Do not modify the original documentation under `Docs/`. Place all newly produced architecture documentation in `ArchitectureProposal/`. + +Treat sources according to their role: + +1. **Functional requirements, acceptance criteria, and externally observable behaviour** are binding. Preserve them, including error and alternative scenarios. +2. **Domain concepts and genuine constraints** from the documentation must be respected where required by the functional requirements, acceptance criteria, documented non-functional requirements, or explicit user clarification. Record assumptions and unresolved ambiguities. +3. **Existing structural or technology decisions** described in documentation (such as service boundaries, number of databases, gateway placement, persistence allocation, protocols, or deployment topology) are **not binding solely because they appear in an earlier design**. Determine whether each is an explicit requirement or a design choice. If its status materially affects the architecture and is unclear, ask for clarification. + +Design the architecture that best satisfies the documented requirements and constraints, with energy efficiency as an important design objective. + +Evaluate relevant architectural alternatives and justify the selected approach based on their advantages, disadvantages, and expected consequences. + +Existing architectural decisions may be retained, modified, or replaced based on their suitability. Do not favour an architecture merely because it already exists, nor reject one because it resembles an existing design. + +Prioritize architectural suitability and justified decisions over novelty or the number of changes proposed. + +Never edit the supplied requirements or design input files. Record suggested clarifications separately. + +## Design boundaries + +- Work at **software architecture and system design level**: components and responsibilities, boundaries, interactions, domain concepts and relationships, conceptual class structures, data ownership, persistence, caching, concurrency, deployment topology, communication, and relevant architectural patterns. Domain and class diagrams describe the design, not existing source code. +- Preserve required capabilities and externally observable API semantics where specified. Do not invent new functional requirements. +- Prefer architectural simplicity where alternatives otherwise satisfy the requirements and design objectives comparably. Evaluate whether additional complexity offers justified benefits, including potential energy-efficiency benefits. +- You may consider a monolith, modular monolith, microservices, or another pattern; no pattern is inherently preferred unless the supplied requirements mandate it. +- Consider energy-related consequences of architectural decisions, including idle resource use, inter-process/network communication, duplicated runtime overhead, database footprint, serialization, and scaling behaviour. +- Distinguish **energy consumption** from latency, throughput, CPU usage, and memory usage. These are not interchangeable measurements. +- Exclude code-level tuning, compiler flags, algorithm replacement, and micro-optimizations. Do not include the energy cost of operating an LLM. +- Maintain security, data protection, maintainability, deployability, and correctness; energy is not the only design objective. + +## Working procedure + +1. **Inventory the inputs.** Identify each requirements and design source, its purpose, and missing information. Read all relevant material before designing. +2. **Create a requirements-and-constraints register.** Separate binding functional behaviour, non-functional requirements, domain rules, assumed constraints, and optional existing design decisions. Cite file paths and requirement/user-story IDs. +3. **Identify architectural drivers.** Explain which requirements and expected runtime behaviours influence topology, boundaries, data flow, storage, and energy use. Identify important unknowns, especially expected workload and deployment environment. +4. **Consider alternatives.** Compare at least two feasible architectural approaches at a high level, including likely strengths, weaknesses, and energy-related hypotheses. Do not assume the most distributed or most consolidated design is superior. +5. **Select and develop one complete proposed architecture.** Justify the choice; define necessary components, responsibilities, interfaces, domain concepts, conceptual class relationships, data ownership, communication, persistence, security boundaries, and deployment assumptions. Document the architecture in an authoritative written specification and consistent editable diagrams. Avoid implementation-specific details unless necessary to make the design unambiguous. +6. **Check coverage and consistency.** Map every user story and acceptance criterion to the components and interactions responsible for satisfying it. Flag gaps and conflicts; do not silently redefine requirements. +7. **Evaluate the design critically.** Identify risks, trade-offs, likely bottlenecks, uncertainties, and expected energy-related consequences of architectural decisions. Explain the reasoning and assumptions behind those expectations. + +If essential requirements are contradictory or a decision could materially alter the architecture, **stop and ask a focused question**. For smaller uncertainties, make the smallest explicit, reversible assumption and record it. + +## Outputs + +Write all new artifacts under `ArchitectureProposal/`; do not overwrite or rewrite the provided `Docs/` inputs. + +Create: + +- `ArchitectureProposal/README.md` — overview, scope, status, input list, assumptions, and navigation. +- `ArchitectureProposal/software-architecture.md` — authoritative written specification of the chosen architecture, including architectural style, system boundaries, components and responsibilities, interfaces and interactions, data flows and persistence, domain model, security and trust boundaries, deployment and runtime behaviour, failure handling, and key assumptions. Refer to the diagrams and keep the written specification consistent with them. +- `ArchitectureProposal/requirements-traceability.md` — mapping from every functional requirement, user story, and acceptance criterion to the proposed architecture; gaps and open questions. +- `ArchitectureProposal/architecture-decisions.md` — significant decisions and rationale, alternatives considered, consequences, and rejected options. +- `ArchitectureProposal/energy-hypotheses.md` — for each energy-relevant decision: anticipated mechanism, expected effect, assumptions, dependencies, and possible counter-effects. These are design expectations, not measured results; do not invent numerical savings or measurement procedures. +- `ArchitectureProposal/risks-and-open-questions.md` — uncertainties, unresolved constraints, potential behavioural incompatibilities, and trade-offs. +- `ArchitectureProposal/diagrams/` — editable **`.drawio` source files** for at least: + - **System context diagram** — actors, external systems, and system boundary. + - **Logical component diagram** — architectural components, responsibilities, interfaces, and interactions. + - **Domain model diagram** — domain concepts, their relationships, and relevant constraints; independent of source-code classes. + - **Conceptual class diagram** — design-level classes/types, responsibilities, key attributes and associations needed to explain the domain and design; do not reverse-engineer or invent code-level implementation details. + - **Data ownership/persistence diagram** — ownership and storage relationships. + - **Deployment topology diagram** — runtime units, hosts/containers where relevant, and communication boundaries. + Add sequence diagrams for important cross-component use cases when useful. Do not provide image-only diagrams as the sole source. + +The proposed architecture must be sufficiently precise to guide implementation, but **do not write implementation code**. + +## Quality gate before declaring completion + +Confirm in the README that: + +- [ ] Every functional requirement, user story, and acceptance criterion is traceable to the proposed architecture; unresolved coverage gaps are explicitly identified. No requirement has been silently omitted or changed. +- [ ] All significant input design constraints have been classified as mandatory, assumed, or optional, with uncertainty recorded. +- [ ] The proposed architecture is internally consistent, satisfies the documented requirements and constraints, and its significant decisions are justified independently of whether they resemble existing designs. +- [ ] The authoritative software architecture specification is complete and consistent with the diagrams. +- [ ] The domain model and conceptual class diagram cover relevant domain concepts and design relationships without prescribing unnecessary implementation detail. +- [ ] All components have clear responsibilities and ownership of data. +- [ ] Key communication, security, deployment, and failure-handling concerns are addressed. +- [ ] Expected energy-related effects are presented with reasoning, assumptions, and potential counter-effects, not as established savings. +- [ ] Draw.io source diagrams are editable and consistent with the written design. +- [ ] No application source code or original input documents were changed. + +## Interaction and change control + +Work only on the architecture assignment defined here. You may add or revise files in `ArchitectureProposal/`. Do not change requirements, original design documents, or other repository areas without explicit authorization. Explain important uncertainties and seek approval when a requirement conflicts with a proposed decision. Do not present expected energy benefits as measured results. diff --git a/implemented_architecture/README.md b/implemented_architecture/README.md new file mode 100644 index 0000000..cc2c02f --- /dev/null +++ b/implemented_architecture/README.md @@ -0,0 +1,24 @@ +# Implemented architecture and design + +This folder describes the **as-is Architecture B implementation**, inspected on 2026-10-14 at repository revision `0205f983904e548aff533c8fa81d5a1a87fdaf2e`. The tested implementation revision is `36740d249225898df1b3be720c453b365ffb9fa7`; the later revision records its evidence. These documents describe existing software, not a new proposal or authorization to change it. + +Health App is a .NET 10 ASP.NET Core HTTPS application with five in-process modules and one PostgreSQL database. Profile and Observations own separate schemas. Analytics calculates on request, Overview composes an authorized snapshot, and Guidance supplies versioned local reference content. Module calls use typed interfaces; there is no business-service HTTP network or persisted analytics result. + +## Reading guide + +| Document | Content | +|---|---| +| [Architecture](architecture.md) | System context, components, dependencies and design decisions | +| [Detailed design](design.md) | Classes, interfaces, transactions, concurrency and calculations | +| [API and security](api-and-security.md) | Routes, access boundaries, tickets and failure semantics | +| [Data model](data-model.md) | Ownership, tables, constraints and update semantics | +| [Runtime interactions](interactions.md) | Executable-path sequence diagrams and failure paths | +| [Deployment](deployment.md) | Native installation, configuration, certificates and operations | +| [Traceability and evidence](traceability-and-evidence.md) | Authority, verification results and known limits | +| [Source inventory](source-inventory.md) | Actual projects and source files supporting these views | +| [Snapshot manifest](snapshot.json) | Revisions and SHA-256 hashes of inspected implementation files | +| [Documentation validation](documentation-validation.json) | Link and source-hash checks; rendering/test limits | + +Diagrams are embedded as editable Mermaid source in the Markdown documents. They can be read alongside the text without a separate diagram package. The source inventory and manifest provide the supporting implementation references; existing test evidence is linked rather than duplicated. + +The approved proposal and requirements remain authoritative inputs. Existing evidence reports 283 passing tests and native local/remote installation on Debian 12 in isolated systemd environments. Other intended Linux distributions and independent clinical validity are not established by that evidence. No energy-efficiency conclusion is made. diff --git a/implemented_architecture/api-and-security.md b/implemented_architecture/api-and-security.md new file mode 100644 index 0000000..0c983d7 --- /dev/null +++ b/implemented_architecture/api-and-security.md @@ -0,0 +1,57 @@ +# Public API and security design + +## Routes + +All routes return JSON as applicable. GUID route constraints apply. Login and guidance are anonymous; other routes require bearer authentication. Professional health-data reads additionally require a current configured assignment. + +| Method | Route | Purpose / allowed role | +|---|---|---| +| POST | /api/authentication/login | Account/password login; anonymous | +| GET | /api/measurement-guidance | Versioned guidance; anonymous | +| GET | /api/professionals/me/patients | Configured assigned identifiers; professional | +| POST | /api/patients | Create own profile; patient | +| GET | /api/patients/me | Own profile; patient | +| GET | /api/patients/{patientId} | Own/assigned profile | +| PUT | /api/patients/{patientId} | Update own profile; patient | +| POST | /api/patients/{patientId}/observations | Record own observation; patient | +| GET | /api/patients/{patientId}/observations | Inclusive period/context-selected history | +| GET | /api/patients/{patientId}/observations/latest | Latest overall observation | +| GET | /api/observations/{observationId} | Actual owner's authorized observation | +| PUT | /api/observations/{observationId} | Update three measurement values; patient | +| PATCH | /api/observations/{observationId} | Presence-aware partial update; patient | +| DELETE | /api/observations/{observationId} | Delete own observation; patient | +| GET | /api/patients/{patientId}/insights | Numerical selected-period summary | +| GET | /api/patients/{patientId}/trends | Selected-period trend assessment | +| GET | /api/patients/{patientId}/overview | Profile, latest overall, selected insight | +| GET | /health/live | Authenticated process probe | +| GET | /health/ready | Authenticated key/catalog/schema-version probe | + +History/insights/trends/overview require from/to and accept setting/activityCondition selection. Offset-free timestamps mean UTC; intervals are inclusive. Both selected dimensions must match. Unknown is an explicit category. Latest ignores the period/context selections. Overview explains the different latest and insight bases. + +## Identity and authorization + +PrototypeAccounts uses configured password hashes with framework PasswordHasher. ASP.NET Core AddBearerToken issues opaque protected tickets containing account identity and role, with configured expiry (default 30 minutes, permitted 1–1440). There is no refresh mechanism. The persistent Data Protection key ring retains the application discriminator `HealthApp.ApiGateway`. Tickets contain no patient associations or professional assignment list. + +AccessPolicy resolves the current account association through ProfileQueries, or checks predefined ProfessionalAssignments. Observation access first resolves its actual owner. Only the host can construct AuthorizedPatientContext; commands enforce its write capability. Professionals are read-only. The boundary checks access before body validation so unauthorized callers cannot learn resource details from model errors. No /by-account endpoint, backend ports, service-key authentication or internal HTTP callback exists. + +Production rejects non-HTTPS requests. Protected responses and login use no-store; guidance is exempt. Config/leaf private key are protected by filesystem ownership; token keys are service-owned. Remote database connections require VerifyFull certificate and hostname verification. These are prototype security controls, not a claim of production certification. + +## Outcomes and failure boundary + +| Condition | Observable behavior | +|---|---| +| Successful creation / deletion | 201 with relative Location / 204 | +| Missing, invalid or expired ticket | 401 | +| Forbidden role/write | 403 | +| Other patient's resource or unavailable owner | Empty 404; non-disclosure | +| Invalid model/period/selection | 400 | +| Duplicate account profile | 409 | +| Empty selected history | 200 [] with X-Measurement-Setting and X-Activity-Condition headers | +| Empty insight / empty trend | 404 / 200 with explicit unavailable values | +| Overview without observations | 200 with nullable latest/insight and explanation | +| Missing overview profile | 404 | +| Dependency unavailable or admission exhausted | 503; overload includes Retry-After: 1 | +| Request deadline / recognized dependency timeout | 504 if response can still be written | +| Caller abort | Connection aborted; transaction cleaned up | + +Default bounded pool is 32, health admission 32, assessment admission 4, deadline 30 seconds. Login/guidance bypass health admission and DB transaction creation; professional-list and health probes also bypass this boundary. Readiness has its own DB metadata access. These values are configurable starting limits, not measured capacity guarantees. Failure logs include operation/status/correlation, not clinical payloads or identifying route values. Framework/EF logging is restricted by host filters. diff --git a/implemented_architecture/architecture.md b/implemented_architecture/architecture.md new file mode 100644 index 0000000..ea28463 --- /dev/null +++ b/implemented_architecture/architecture.md @@ -0,0 +1,69 @@ +# As-is software architecture + +## Context and runtime boundary + +Patients authenticate and manage their own profile and blood-pressure observations. Healthcare professionals authenticate and read patients assigned in protected configuration. Anonymous clients can obtain measurement guidance and attempt login. Administrators install the application and provision its database, configuration, TLS material and service identity. + +```mermaid +flowchart LR + P[Patient client] -->|HTTPS / JSON| H[HealthApp ASP.NET Core host] + C[Assigned professional client] -->|HTTPS / JSON| H + A[Anonymous client] -->|Login or guidance| H + H -->|Npgsql pooled connection| D[(PostgreSQL B database)] + O[Administrator] --> I[Transient native installer and provisioner] + I -->|Fresh schemas and roles| D + I -->|Protected configuration, TLS, unit| H +``` + +The public host is `src/HealthApp`. Five module assemblies execute inside its process; they are not separately addressable services. PostgreSQL may be local or remote. There is no frontend application in the implemented solution. Reference/ArchitectureA is an archived behavioral reference excluded from the solution. + +## Components and responsibilities + +| Component | Owns | Calls / dependencies | +|---|---|---| +| HealthApp | Controllers, authentication, access policy, admission and deadlines, host composition, health probes | All modules, Contracts, Infrastructure | +| Profile | Patient entities, account association, profile queries/commands, profile schema | Contracts and Infrastructure | +| Observations | Measurements, recorded context, owner-scoped queries/commands, observations schema | Contracts and Infrastructure; runtime ProfileQueries for recording | +| Analytics | Summary, numerical trends, comparability and preserved clinical policy | ObservationQueries, ReferenceCatalog, RequestTransaction | +| Overview | Composition of profile, latest overall observation and selected insight | ProfileQueries, ObservationQueries, AnalyticsQueries | +| Guidance | Static home-measurement guidance and reviewed reference catalog | Contracts; no database | +| Contracts | DTOs, requests, typed interfaces, authorized patient capability | No module implementation | +| Infrastructure | Shared connection/transaction mechanics | Npgsql and EF Core; no health-table policy | +| HealthApp.Provisioning | Installation secrets, TLS, fresh database/roles/migrations and verification | Framework/Npgsql; separate transient executable | + +```mermaid +flowchart TD + H[HealthApp host] --> P[Profile] + H --> O[Observations] + H --> A[Analytics] + H --> V[Overview] + H --> G[Guidance] + V -. ProfileQueries .-> P + V -. ObservationQueries .-> O + V -. AnalyticsQueries .-> A + A -. ObservationQueries .-> O + A -. ReferenceCatalog .-> G + O -. ProfileQueries .-> P + P --> I[Infrastructure: RequestTransaction] + O --> I + A --> I + I --> DB[(Single PostgreSQL database)] +``` + +Solid module-to-Infrastructure edges are assembly dependencies. Dotted edges are runtime interface calls resolved by host dependency injection, not project references to sibling implementations. All modules reference Contracts. Overview and Guidance do not reference Infrastructure. Profile and Observations use separate internal DbContexts sharing the request connection; Analytics has no DbContext. The host registers policies/catalog/admission/data source as singletons and facades/access/transaction as scoped services. + +## Implemented decisions and consequences + +| Decision | Concrete realization | Consequence / boundary | +|---|---|---| +| Consolidated application | One Web SDK project and one systemd service | Shared process failure boundary; no internal HTTP service credentials | +| Encapsulated persistence | Internal entities/contexts, typed DTO facades | Sibling modules cannot use each other's entity/context directly; some internals are exposed to tests | +| Central authorization | Host issues AuthorizedPatientContext after account/assignment checks | Module APIs are trusted in-process interfaces, not independent security endpoints | +| Shared read snapshot | RepeatableRead request transaction | Overview reads one coherent snapshot; connection released before calculation | +| Serialized mutation | ReadCommitted writes, owner-scoped row locks and DB constraints | Concurrent patches preserve disjoint edits; commits precede success responses | +| On-demand calculation | Original formulas moved into Analytics policies | No analytics database, background job, result cache or clinical algorithm replacement | +| Local references | Guidance and reviewed catalog are bundled/versioned | No publisher dependency; updating clinical outputs remains approval-sensitive | +| Fresh provisioning | Independent B DB and schema owners/runtime role | No live A import or production-data migration | +| Portable native deployment | APT/DNF/pacman adapters and systemd | Explicit intended distro support; executed verification narrower than intended support | + +These decisions implement Q1–Q5 in the [approval](../Docs/ApprovalRequirements/architecture-b-implementation-approval.md). Detailed architectural conformance remains in the [implementation register](../ImplementationPlan/architecture-conformance.md). diff --git a/implemented_architecture/data-model.md b/implemented_architecture/data-model.md new file mode 100644 index 0000000..8804648 --- /dev/null +++ b/implemented_architecture/data-model.md @@ -0,0 +1,57 @@ +# Persistence and data ownership + +One fresh B PostgreSQL database contains profile and observations schemas. Each has a separate NOLOGIN owner and schema_version table; installed runtime credentials have DML and metadata-read permissions, not schema ownership or DDL privileges. Analytics, Overview and Guidance own no database tables. + +```mermaid +erDiagram + PROFILE_PATIENT ||--o{ OBSERVATIONS_OBSERVATION : "patient_id FK (RESTRICT)" + PROFILE_PATIENT { + uuid patient_id PK + text account_id UK + varchar name + date date_of_birth + varchar contact_info + timestamp created_at + timestamp updated_at + } + OBSERVATIONS_OBSERVATION { + uuid observation_id PK + uuid patient_id FK + timestamp measured_at + int systolic + int diastolic + int pulse + varchar context + varchar note + text setting + text activity_condition + numeric rest_duration_minutes + text body_position + text measured_arm + text device_details + text cuff_details + text additional_circumstances + timestamp created_at + timestamp updated_at + } +``` + +Table names are `profile.patient` and `observations.observation`. Every diagram timestamp column is `timestamp without time zone`. Runtime normalizes measurement instants to UTC with DateTimeKind.Unspecified for stored/wire compatibility. Nullable columns: patient contact_info; observation context, note and optional preparation fields. Account ID, name, birth date, identifiers, measurements, categories and audit timestamps are required. Domain class nullability is not a substitute for SQL constraints. + +## Constraints and query semantics + +- Patient account_id has unique index IX_patient_account_id. A profile is created from trusted ticket identity, not caller-supplied account binding. +- Observations have a restricted FK to profile.patient; deleting a referenced profile is prohibited by SQL. No public profile-delete route exists. +- Systolic, diastolic and pulse are positive integers; rest_duration_minutes is null or nonnegative. +- Setting is Home/Clinic/Other/Unknown; activity is AtRest/DuringActivity/AfterActivity/Unknown. SQL defaults are Unknown. +- Index ix_observation_patient_time spans patient_id, measured_at, created_at, observation_id. +- Latest sorts measured_at, created_at and UUID descending. Selected history sorts measured_at then UUID ascending. PostgreSQL UUID ordering preserves the baseline unsigned network-byte tie behavior. +- Each schema_version has integer primary-key version; both migrations install version 1. Runtime does not apply privileged migrations. + +Profile owns account association and mutable patient fields; Observations owns all measurement/context state and asks ProfileQueries when recording. Runtime modules do not join across schema-owned health tables. The FK is a provisioned integrity boundary, not permission to read another module's entity. + +## Mutations and derived data + +Profile update preserves identity, account binding, date of birth and original creation time. Observation PUT updates only the three measured values. PATCH distinguishes omitted properties from explicit null: omissions retain state, nullable values can clear, categories reset to Unknown, and clearing the structured context does not implicitly erase legacy context/note. Validation precedes persistence and row locks serialize edits. Owner filters apply to retrieval and mutation. + +Summary/trend/overview responses are derived from current immutable observations; they are not persisted or cached. Credentials/accounts/assignments live in protected configuration, token keys on disk, and versioned guidance/reference data in assemblies. There is no event bus, outbox, replica, background analytics store or historical A import. Exact DDL: [Profile migration](../src/Modules/Profile/Migrations/001-profile.sql) and [Observations migration](../src/Modules/Observations/Migrations/001-observations.sql). diff --git a/implemented_architecture/deployment.md b/implemented_architecture/deployment.md new file mode 100644 index 0000000..10f97d1 --- /dev/null +++ b/implemented_architecture/deployment.md @@ -0,0 +1,53 @@ +# As-is deployment and operational design + +## Topology + +```mermaid +flowchart LR + C[Client with trusted application CA] -->|HTTPS default 5443| S[systemd healthapp-b.service] + subgraph Linux application host + S --> A[/opt/healthapp-b: published .NET app] + S --> F[/etc/healthapp-b: config and TLS] + S --> K[/var/lib/healthapp-b: token keys] + end + S -->|Local restricted transport or remote VerifyFull TLS| DB[(Fresh B PostgreSQL database)] +``` + +Native runtime needs .NET 10 ASP.NET runtime and systemd. The application does not require Docker or Architecture A services. Test containers are verification infrastructure only. The release contains app, transient provisioner, migration scripts, installer/adapters, unit and installation guide. Build instructions and exact command options are maintained in [INSTALLATION](../deploy/INSTALLATION.md). + +## Installation flow + +1. Build a new release directory with deploy/build-release.sh. +2. Installer preflights root/systemd, distribution and fresh installation paths; existing installation is rejected before overwrite. +3. APT/DNF/pacman adapter supplies dependencies. Local mode initializes/starts PostgreSQL; remote mode does not install/start it. +4. Provisioner prepares private installation material, random runtime/account secrets and generated or supplied HTTPS material. +5. It creates a new database, separate NOLOGIN schema owners, restricted runtime role, module migrations and grants. Remote administration uses an owner-only connection file and VerifyFull. +6. Installer creates service identity, publishes protected config/certificate/key paths and registers/enables/starts one unit. +7. Verifier exercises trusted HTTPS, login, readiness and representative profile/measurement/history/insight/overview flows; it stops the app while DB remains ready and repeats after restart with a new PID. + +Local provisioning adds a SCRAM loopback rule scoped to the new database/runtime role while retaining existing PostgreSQL rules and a protected backup. No A database is accessed. Installer verification leaves identified synthetic prototype records. The generated professional starts without assignments. There is no assignment-management endpoint. + +## Configuration and security material + +| Setting/material | Actual purpose/default | +|---|---| +| HEALTHAPP_CONFIGURATION_FILE | Optional explicit JSON file loaded after standard host configuration; installed path /etc/healthapp-b/appsettings.json | +| ConnectionStrings:HealthDatabase | Generated restricted runtime credentials and DB location | +| Database:Remote | Remote mode enforces VerifyFull; nonlocal host also enforces it | +| Authentication:Accounts | Prototype account password hashes/roles | +| Authentication:KeyDirectory | Persistent protected Data Protection key ring | +| Authentication:TokenLifetimeMinutes | 30; valid range 1–1440 | +| Access:ProfessionalAssignments | Predefined many-to-many account/patient assignment map | +| Resources:MaxPoolSize | 32 | +| Resources:MaxConcurrentRequests | 32 | +| Resources:MaxConcurrentAssessments | 4 | +| Resources:RequestDeadlineSeconds | 30 | +| HTTPS PFX / trust CA | Generated leaf/private key or supplied material; clients establish CA trust separately | + +Installed config and private key are root-owned/service-group readable; key directory is service-owned mode 700. Generated leaf is valid one year, CA two years; automatic renewal is absent. The service uses NoNewPrivileges, PrivateTmp, ProtectSystem=strict, ProtectHome and a state-only writable path, restarting on failure. It has no PostgreSQL Requires relationship: DB readiness is independent and guidance/login can remain available during DB-only outages. + +## Support and limits + +Intended systemd x86_64 distributions: Debian 12/13, Ubuntu 24.04, Fedora 43/44, compatible RHEL-family feeds and rolling Arch/Manjaro. Adapters implement family-specific handling; package availability still must pass preflight. Actual native verification is Debian 12 bookworm local PostgreSQL 15.19 and remote PostgreSQL 18.6, .NET/ASP.NET 10.0.13, inside isolated privileged systemd Linux containers sharing a Manjaro host kernel. Remote tests include incorrect-hostname rejection and absence of local PostgreSQL. This is not bare-metal, VM, all-distro or measurement-environment verification. + +Partial failures retain protected state and identify the failed stage. Installation has no transactional rollback or automatic resume. Future backup/upgrade/certificate operations are administrative; no HA, backup SLA, automated renewal, live data import or production certification is implemented. Measurement/comparison setup is separate: [measurement context](../ImplementationPlan/measurement-context.md). diff --git a/implemented_architecture/design.md b/implemented_architecture/design.md new file mode 100644 index 0000000..5196eae --- /dev/null +++ b/implemented_architecture/design.md @@ -0,0 +1,67 @@ +# Detailed implementation design + +## Object and interface boundaries + +| Type / group | Role and state | +|---|---| +| Program | Composition root, framework middleware and endpoints | +| Seven controllers | HTTP/model/status translation; typed facade calls and explicit transaction completion | +| AccessPolicy | Account-to-patient ownership or configured professional assignment lookup | +| AuthorizedPatientContext | Read-only PatientId/CanWrite; internal constructor accessible to host; RequireWrite guard | +| RequestAdmission | Singleton health and assessment semaphores | +| RequestBoundaryMiddleware | Authorization before model validation; transaction, admission, cancellation and dependency failure boundary | +| ReleaseTransactionFilter | Disposes unfinished transaction after action processing | +| RequestTransaction | Scoped Npgsql connection/transaction; BeginAsync, EnlistAsync, FinishAsync, DisposeAsync | +| ProfileFacade / PatientDbContext / Patient | Internal profile implementation and mutable persistence model | +| ObservationFacade / ObservationDbContext / BloodPressureObservation | Internal measurement implementation and mutable persistence model | +| AnalyticsFacade | Loads immutable selected observations once, closes snapshot, invokes policies | +| SummaryPolicy / TrendPolicy / ClinicalPolicy | Stateless numerical and interpretation responsibilities | +| OverviewFacade | Composes immutable response; no persistence | +| GuidanceQueries / ReviewedReferenceCatalog | Bundled guidance and reference metadata; no patient state | + +The exported interfaces are ProfileQueries (ResolveAccountAsync/GetAsync), ProfileCommands (CreateAsync/UpdateAsync), ObservationQueries (ResolveOwnerAsync/GetAsync/LatestAsync/SelectedAsync), ObservationCommands (RecordAsync/PatchAsync/DeleteAsync), AnalyticsQueries (InsightAsync/TrendAsync), OverviewQueries (GetAsync) and ReferenceCatalog (Pulse/Pressure/Version). CancellationToken flows through I/O. DTO records carry values, not tracked EF entities. Observation requests retain presence flags where omitted and explicit null differ. The internal InsightCalculator is a test-compatible calculation entry, not another public component. + +```mermaid +classDiagram + ProfileFacade ..|> ProfileQueries + ProfileFacade ..|> ProfileCommands + ObservationFacade ..|> ObservationQueries + ObservationFacade ..|> ObservationCommands + AnalyticsFacade ..|> AnalyticsQueries + OverviewFacade ..|> OverviewQueries + ReviewedReferenceCatalog ..|> ReferenceCatalog + ProfileFacade --> PatientDbContext + PatientDbContext --> Patient + ObservationFacade --> ObservationDbContext + ObservationDbContext --> BloodPressureObservation + ObservationFacade --> ProfileQueries + AnalyticsFacade --> ObservationQueries + AnalyticsFacade --> SummaryPolicy + AnalyticsFacade --> TrendPolicy + TrendPolicy --> ClinicalPolicy + ClinicalPolicy --> ReferenceCatalog + OverviewFacade --> ProfileQueries + OverviewFacade --> ObservationQueries + OverviewFacade --> AnalyticsQueries + ProfileFacade --> RequestTransaction + ObservationFacade --> RequestTransaction + AnalyticsFacade --> RequestTransaction +``` + +This is a selected implementation class view; the [source inventory](source-inventory.md) provides complete source-file coverage, including request and response classes. + +## Transaction lifecycle and concurrency + +Protected health requests enter the boundary after framework authentication/authorization. Admission is immediate rather than queued. The boundary opens a read RepeatableRead or write ReadCommitted transaction and resolves route ownership before MVC binding/validation. Controllers also obtain an authorized scope for the facade operation. Separate DbContexts enlist in the same connection and transaction; Infrastructure knows transaction mechanics only. + +Successful simple reads/writes call FinishAsync, committing and returning the connection. Analytics captures selected data then calls FinishAsync before synchronous calculation. Overview reads profile and latest first, then Analytics reads the selected series and finishes that same snapshot. Early returns, validation errors and exceptions dispose uncommitted work; the filter and middleware provide cleanup. Row locks protect updates/deletes, and database uniqueness/FK/check constraints enforce integrity. There is no automatic ambiguous-write retry. + +Cancellation combines client abort with a configurable deadline. I/O receives the token. Existing synchronous numerical policy code checks cancellation before and after calculation; it is not preempted within each arithmetic loop. A response already started is aborted if a failure cannot be represented safely. + +## Numerical and clinical policy + +Summary arithmetic uses eligible observations, decimal means and final two-decimal rounding away from zero. Trends retain raw mean/min/max/range, group equal measurement instants by metric mean, and process ordered distinct instants with equal weight. Adjacent nonzero changes determine direction/reversals; total successive change sums absolute steps. Full-period OLS uses scaled time; slope/day is rounded to six decimals, while sign uses the unrounded slope. Fewer than two distinct instants produce unavailable temporal direction while retaining descriptive values. + +TrendPolicy separates numerical description, recorded comparability and ClinicalPolicy. Home high-BP references are 135/85, clinic 140/90 (inclusive); resting pulse boundaries are below 50/above 100 (exclusive). Applicability depends on recorded context and preparation limitations. Preserved finite English/Danish phrase detection can withhold interpretation and is not general language understanding. There is no personalized target, diagnosis, significance test or combined good/bad score. + +The method version is baseline-2026-10-05; guidance is baseline-2026-10-04. Exact algorithms, applicability, labels and caveats are documented in [TRENDS](../src/TRENDS.md) and [clinical provenance](../ImplementationPlan/clinical-provenance.md). Source review dates are inherited baseline metadata, not evidence of a new clinical review. diff --git a/implemented_architecture/documentation-validation.json b/implemented_architecture/documentation-validation.json new file mode 100644 index 0000000..fbea93a --- /dev/null +++ b/implemented_architecture/documentation-validation.json @@ -0,0 +1,8 @@ +{ + "date": "2026-10-14", + "markdownFiles": 9, + "localLinksChecked": 144, + "sourceFilesHashChecked": 110, + "errors": [], + "method": "Filesystem link existence and SHA-256 checks; Mermaid source reviewed, renderer not executed; no application tests rerun." +} diff --git a/implemented_architecture/interactions.md b/implemented_architecture/interactions.md new file mode 100644 index 0000000..5b7ac3b --- /dev/null +++ b/implemented_architecture/interactions.md @@ -0,0 +1,72 @@ +# Runtime interaction views + +These sequences describe successful code paths. Framework authentication and role policies precede the boundary. Scope checks also occur in controllers; the views condense repeated checks without implying they are removed. + +## Record an observation + +```mermaid +sequenceDiagram + participant C as Patient client + participant H as Host / boundary + participant X as AccessPolicy + participant O as ObservationFacade + participant P as ProfileFacade + participant T as RequestTransaction + participant D as PostgreSQL + C->>H: POST patient observations + bearer ticket + H->>T: BeginAsync(write): ReadCommitted + T->>D: Open pooled connection / begin + H->>X: Authorize actual patient before binding + X->>P: ResolveAccountAsync(account) + P->>D: Own schema account lookup + X-->>H: AuthorizedPatientContext + H->>O: RecordAsync(scope, validated request) + O->>P: GetAsync(scope) + P->>D: Read patient in shared transaction + O->>D: Validate / insert owned observation + O-->>H: Immutable ObservationDto + H->>T: FinishAsync + T->>D: Commit and release connection + H-->>C: 201 + relative Location +``` + +Denial yields empty 404 before body validation. SQL/model failures cannot produce a successful creation response. Concurrent updates lock the owner-scoped row; failures roll back on disposal. + +## Coherent overview + +```mermaid +sequenceDiagram + participant C as Authorized client + participant H as Host / boundary + participant T as RequestTransaction + participant V as OverviewFacade + participant P as ProfileQueries + participant O as ObservationQueries + participant A as AnalyticsFacade + participant S as SummaryPolicy + C->>H: GET overview with period / selection + H->>T: BeginAsync(read): RepeatableRead + H->>H: Authorize patient + H->>V: GetAsync(scope, period, selection) + V->>P: GetAsync(scope) + P-->>V: Profile snapshot + V->>O: LatestAsync(scope) + O-->>V: Latest overall snapshot + V->>A: InsightAsync(scope, period, selection) + A->>O: SelectedAsync (once) + O-->>A: Immutable selected series + A->>T: FinishAsync: release snapshot connection + A->>S: CalculateSummary + S-->>A: Insight or null + A-->>V: Selected insight + V-->>H: DTO with separate bases / explanations + H-->>C: 200 overview +``` + +A concurrent commit after snapshot capture is invisible to all in-flight overview reads; a later request can see it. Missing profile returns 404. Empty selection leaves profile/latest intact and produces a null insight explanation. Overview does not call the trend calculator. + +## Trends and failure handling + +Trend requests follow the same authorization/read transaction path, then one SelectedAsync capture, FinishAsync, and TrendPolicy → ClinicalPolicy → ReferenceCatalog calls. Computation occurs after database release. No remote reference fetch or analytics write occurs. + +Immediate admission refusal returns 503 with Retry-After. Database errors map to dependency 503 or recognized timeout 504; the deadline maps to 504 when writable. Empty data follows distinct successful absence paths. Cleanup releases admission slots and disposes unfinished transactions. Caller abort closes the connection. Login and static guidance do not require a healthy database. diff --git a/implemented_architecture/snapshot.json b/implemented_architecture/snapshot.json new file mode 100644 index 0000000..16fd24f --- /dev/null +++ b/implemented_architecture/snapshot.json @@ -0,0 +1,117 @@ +{ + "inspectedOn": "2026-10-14", + "snapshotRevision": "0205f983904e548aff533c8fa81d5a1a87fdaf2e", + "testedCodeRevision": "36740d249225898df1b3be720c453b365ffb9fa7", + "files": { + "HealthApp.slnx": "c7a5f7c7e30d1608074c5ff2c520eff093e3b905b5b2f3a8642a64930d101c56", + "README.md": "1e8b6aa234af98738b1a28565b3acd89ada0c56a67d58c294f8176e5064fa684", + "deploy/HealthApp.Provisioning/HealthApp.Provisioning.csproj": "23ee60031a40d85fdfd7d9af08b316012daf399f9f5788c7bd6a9078c12a32bc", + "deploy/HealthApp.Provisioning/Installation.cs": "14e0f6fc539f1796cde395cdca112d36062810e54e638e20681f4eaaf3f76a34", + "deploy/HealthApp.Provisioning/Program.cs": "1f7c6493b4916d3887a1b6f59625685c5e6904def311a0a98c3112791d3b40a9", + "deploy/INSTALLATION.md": "43e381629f4591c49853da91e8c43454b9068836c637a9c2652022b3d4c71391", + "deploy/appsettings.example.json": "63352e440f873cbe2414f459eaed39ede2f6343ef694643671a660993af5c815", + "deploy/build-release.sh": "62ce01b4cf1dbf97db2346a24617e219f7c2803afb2e3ce6a03509acfab1b117", + "deploy/installer/bootstrap.sh": "ff77323066e0e08bb1aeb059da69a8da1aa9414d5eeb93db37fd3f195c8656a1", + "deploy/installer/install.sh": "d1ecf7f7aba14744422891ebd622a0bd6462e8f067851ee599e5ac824d0b56df", + "deploy/systemd/healthapp-b.service": "41dcdfa953d35710367fe84c3c43cba2bf72ced681c989eede9de12fe4b18adc", + "global.json": "b48d6da8fa62c0da7cc8a2da4ea036ac55836660a448ba533135abb5b8451b73", + "src/HealthApp/Controllers/AuthenticationController.cs": "2f1c58f0c91dd9b3600f8ff6b38f029b55963a0fe8b8cb10aee590afbfe7d191", + "src/HealthApp/Controllers/HealthOverviewController.cs": "f57c824acf2d40ebea350d4f841cbb20fa423fb4b94a73e5faf688f8e84c4a40", + "src/HealthApp/Controllers/InsightsController.cs": "2938aefa87b21c2bb49ab98420654e2452149339154c5df439b000b5706f0fdb", + "src/HealthApp/Controllers/MeasurementGuidanceController.cs": "05cb4eab5b1c5f6fccd3fbc9a3012a7c359a7c2f8912d745a2afed0c21f00923", + "src/HealthApp/Controllers/ObservationController.cs": "f473c8ea4a83f70ee9acde12335ab6ede1ce5b81407959da2f9c5be349242cc6", + "src/HealthApp/Controllers/PatientController.cs": "c411429e4a4f0ccd915ab3c464f3e969f635f165d2ee6ec9941cfa9dda1e31f4", + "src/HealthApp/Controllers/ProfessionalController.cs": "2b73ec65320436d5b898b13a462fe24eb6adb1e25b3233b294aa748b03155fad", + "src/HealthApp/HealthApp.csproj": "4ecc63649e1732047ad6231cc9e9bf60ba7612093bf54b62019aa01ffd7158df", + "src/HealthApp/Program.cs": "4ca7c9432644e8e13db2a64c4de930bc919421dab86c16c4000d3fa606e20d45", + "src/HealthApp/Security/AccessPolicy.cs": "f9572d457ce960ac958cc14f912d947ce6f182fbcf679a03e822164cf9215e22", + "src/HealthApp/Security/ProfessionalAssignments.cs": "4afa06b7498e0e9c8028c7858cddca0b29caed6b60b7aea3db4e50ee911efa53", + "src/HealthApp/Security/PrototypeAccounts.cs": "ebeb71b3955db41e05389cdad20a6dfda2ac394ab5d1d77164987e7a71028622", + "src/HealthApp/Security/RequestBoundaryMiddleware.cs": "21ad8bab3d282dae34ca466a2efad25d88a89a4425c12eb9b0a72009e09fee7c", + "src/HealthApp.Contracts/AnalyticsFacades.cs": "c18e5b06eed9433f68dc4b05d84542d08001385e56e24745424f3a463c48f483", + "src/HealthApp.Contracts/AuthorizedPatientContext.cs": "76730b1f40f2a47d4354f9882f6e07bd05b0fa293af375db1763b308d7de8010", + "src/HealthApp.Contracts/ClinicalRuleProvenance.cs": "788de4b769cd03288c03c693f1870c377974b1a1c64f6cfd047e88e8036404f5", + "src/HealthApp.Contracts/ContextSelection.cs": "6368c56eeb81a38c47e61fb75f4316d51d92f3796779673413447267cf21f067", + "src/HealthApp.Contracts/CreatePatientRequest.cs": "8189ef656a915e678ef5fbb6eb3d7270b086cbc66f04d893c6dba6b692cf4d43", + "src/HealthApp.Contracts/HealthApp.Contracts.csproj": "b7412db9b99568e8c78143b2ef1aca5af0b1686d98d2c7fd1ff8b7b2564b8a9d", + "src/HealthApp.Contracts/HealthInsight.cs": "131b66c4b8b80222b9b081dd5add45e1849000127151ca7feb15a7f1805a25c5", + "src/HealthApp.Contracts/HealthOverviewDto.cs": "0b8fab13249ab8588fe441ac010a10a9dac794de1135f6226ad9435b67622303", + "src/HealthApp.Contracts/MeasurementContext.cs": "02a6ba328661ffb271891808a353d9d87791dabd0f8e56eb9445f7420cb334b0", + "src/HealthApp.Contracts/MeasurementContextPatch.cs": "1aff952166ad851d6a538d35442242ba5e2b5e6bad215b9975624b0b46e03b5b", + "src/HealthApp.Contracts/ObservationDto.cs": "cf71b5ff3e7fef9cdcec0d76422c7ad1ab68f3d8821e82f2ccb902ded06b17e0", + "src/HealthApp.Contracts/ObservationFacades.cs": "2dac8fcc37f55556ccc9272275454e498755bbbdfb799dcfda60f640dc82ff25", + "src/HealthApp.Contracts/PatchObservationRequest.cs": "5f212133cbd6b4b8408bcc57255c6439d7b272c82768902b985c088f9a8344e1", + "src/HealthApp.Contracts/PatientDto.cs": "391a3cb88505aee002b001ff8bba534d508626d9038cd9600ae088bd2f62e178", + "src/HealthApp.Contracts/RecordObservationRequest.cs": "85008ac86b29ec4d7b24abff8b8f15adad4e3b24d6a92023789a969bc49ecc37", + "src/HealthApp.Contracts/TrendAssessment.cs": "5525c317690091ffd62292a64b5efaa269f3a53276353ab7e0d99374d782888f", + "src/HealthApp.Contracts/UpdateObservationRequest.cs": "f873acbc47ae7660aed06b83552a28ee4c38f805451cadfebf0d2b91de73bfbd", + "src/HealthApp.Contracts/UpdatePatientRequest.cs": "a6ac1c72ecac6290f22fd065a91c6adc795c4d6f1e33d6d27be41a0ff0cee713", + "src/HealthApp.Infrastructure/HealthApp.Infrastructure.csproj": "0928f24c1d6ba2a34c882e089de26f55f35858f7edf15afacf30a416afeb70da", + "src/HealthApp.Infrastructure/RequestTransaction.cs": "e6a85512c1bdfe7fc5381f954cbe8b6740501207e6ad24ba705db766faca7994", + "src/Modules/Analytics/Analytics.csproj": "6b98f81ea2730f93d778d9e544faf85a4219dc596cb30caaa13253acb9217d5e", + "src/Modules/Analytics/AnalyticsFacade.cs": "45f75df083cf0bbf9d75d45b297a8ff218a0de71c6e78def833b658ba4f67e57", + "src/Modules/Analytics/AssemblyInfo.cs": "ebce47e2dbe8b618bf608f974211697db2f9ed4cdb74d2fefaeb9342f19d2978", + "src/Modules/Analytics/ClinicalPolicy.cs": "0579e379d9a314edfdab4bdeac6ebe230401046f835100052d9c574fda3cf040", + "src/Modules/Analytics/SummaryPolicy.cs": "b6720517c4487022bb90ea35ac3c5c393e6925812722e06ab1d2af58d0fc2562", + "src/Modules/Analytics/TrendPolicy.cs": "b38fffa1e9410c961d9f033f499f957ec35b8c873aad693b0e4a93991ba39e5f", + "src/Modules/Guidance/Guidance.csproj": "861ea2e0a59fcdb91ca297e2743c569b8154898a3f21fda9c764debc63fcfa41", + "src/Modules/Guidance/GuidanceQueries.cs": "de16f581d9924a7aaf39761158dfde7ccc95070eeb3861ebcc63d0c952a8bb17", + "src/Modules/Guidance/ReviewedReferenceCatalog.cs": "d8527b459c7ad0f3856afb91cb25587299927c8e4bdcbcb0b14679a0d93794e9", + "src/Modules/Observations/AssemblyInfo.cs": "ebce47e2dbe8b618bf608f974211697db2f9ed4cdb74d2fefaeb9342f19d2978", + "src/Modules/Observations/Domain/BloodPressureObservation.cs": "5147ce1785f754359a6b23529ca02db40266768ae1c4d4ba86fd47dde0fea8da", + "src/Modules/Observations/Migrations/001-observations.sql": "f0b77fe9d3e374557cc2c1edca7dcfdb388a8fa9454dbe69e50a1e6ce4651817", + "src/Modules/Observations/ObservationFacade.cs": "3adfb1de8f9ba8d0b8bc562cf9b766f1ef270039a341f9e7cafc3208f1edeb85", + "src/Modules/Observations/Observations.csproj": "6b98f81ea2730f93d778d9e544faf85a4219dc596cb30caaa13253acb9217d5e", + "src/Modules/Observations/Persistence/ObservationDbContext.cs": "a3d01ed387b343767121c2a8b911fe2dbfd4da5ad1cde0692b585c901fc81155", + "src/Modules/Overview/Overview.csproj": "861ea2e0a59fcdb91ca297e2743c569b8154898a3f21fda9c764debc63fcfa41", + "src/Modules/Overview/OverviewFacade.cs": "69925884c4d8e487408b446496e3e243032e51e27704981ea89ac821731bcbb2", + "src/Modules/Profile/AssemblyInfo.cs": "ebce47e2dbe8b618bf608f974211697db2f9ed4cdb74d2fefaeb9342f19d2978", + "src/Modules/Profile/Domain/Patient.cs": "0aceabc7e269ff3f00a617987790cd71ae5ac7716751fc6a82224fe1ddef737d", + "src/Modules/Profile/Migrations/001-profile.sql": "fc2cac4c965d2a1e28f3a837bbce78b889ac65d56468e52524cb14b672662660", + "src/Modules/Profile/Persistence/PatientDbContext.cs": "5919d5faa0f223650d4ec16a6c3c5a54458cfdf70e2b4a7efa2d6cc21c76a690", + "src/Modules/Profile/Profile.csproj": "6b98f81ea2730f93d778d9e544faf85a4219dc596cb30caaa13253acb9217d5e", + "src/Modules/Profile/ProfileFacade.cs": "c3d46a921f1861abbc77f60cef1f34cda7e82fe83ef64ff8c628859ebe5330c3", + "src/TRENDS.md": "7b987403073ad4d4894287c7cac7fc542d6251e7241445d559e9c24ec27cf809", + "tests/HealthApp.AcceptanceTests/AuthenticationIntegrationTests.cs": "e7af7779d24981f86d82c1fb7fa2bc3c9cc78d0c36a48cb9e67e3f691d1bbe44", + "tests/HealthApp.AcceptanceTests/ConformanceTests.cs": "3823f83f25e1cca1f06c27485e166504fe443c1feb17b0655a5b7cbf65c5f699", + "tests/HealthApp.AcceptanceTests/ContextFilteredHistoryTests.cs": "3eadcb8473e0cd1f0df6a367dc490798ac551bb2ffa4af82b53c9981624c8db9", + "tests/HealthApp.AcceptanceTests/ContextSelectedInsightTests.cs": "ff67d93991202661155b1676ee19b3258cd15c510aaddd940f81ee2e3c8a9229", + "tests/HealthApp.AcceptanceTests/CreatePatientTests.cs": "8fffa446a01959731289799fa1e14ffb25248915089ad1b3b9f25fb687fded52", + "tests/HealthApp.AcceptanceTests/DeleteContextualisedObservationTests.cs": "1c3bbfab934d41428001b6d1d181cf7f08c90eb99ebcc9933ba48c334299c0d7", + "tests/HealthApp.AcceptanceTests/DeleteObservationTests.cs": "a3eaaf6bf14fe18e07f6e75fc0b414d906b37d1ba636e231d8218a58027b38fe", + "tests/HealthApp.AcceptanceTests/FoundationTests.cs": "71df3c6ef3bdc165a717d0e4cd0af024dfe4e55b5adb5eeda1fc41c24725d897", + "tests/HealthApp.AcceptanceTests/GlobalUsings.cs": "48b09638b804452944adcd5e70c9381670b6af24fdc681b7532624e6dfdc15b5", + "tests/HealthApp.AcceptanceTests/HealthApp.AcceptanceTests.csproj": "15c8581595bb7c477c528f7b2a6c7671491a11f526e260c78efbbe3eb5dbc20f", + "tests/HealthApp.AcceptanceTests/HealthInsightTests.cs": "aa1f3ec51f1072b6c165517b9510149666449c494ea8527b66fc95e047be7815", + "tests/HealthApp.AcceptanceTests/HealthOverviewTests.cs": "df772f0d79b8ec7331b113d1d43b15e23e137dfa05c138bbbbe97f69d48e87b9", + "tests/HealthApp.AcceptanceTests/HealthTrendTests.cs": "cb9f62039ff099551e20ae75969a9eb5d7c4f96a9d702033e319c719ce982e09", + "tests/HealthApp.AcceptanceTests/LatestObservationTests.cs": "9d815836f94d74a85c6764d23a4f7ef7b840290af18be88918bd39ac01223c7e", + "tests/HealthApp.AcceptanceTests/MeasurementContextMigrationTests.cs": "d401a2c9ace967412cc55b3f482333e6d521739b59cf1f8efba8273a11209be9", + "tests/HealthApp.AcceptanceTests/MeasurementGuidanceTests.cs": "80e527e632891f63e54288ba1d420beec7f2cdff08e03f0558cb76f5687bd2b2", + "tests/HealthApp.AcceptanceTests/ObservationApiFixture.cs": "c61f837d0a930027bede1e67d4792d9e7d7e408466e18fab8a7b726175685ca4", + "tests/HealthApp.AcceptanceTests/ObservationConcurrencyTests.cs": "09d516babae8ef2685babb1a5f16019d033ac1dcdfebc7c12f4d6201bc622f62", + "tests/HealthApp.AcceptanceTests/ObservationHistoryTests.cs": "73e11a578e9a9e34489cdf38840692e239c5013e0903f14852524236828e3d70", + "tests/HealthApp.AcceptanceTests/OperationalTests.cs": "799e0c1c1b18d51efac2e6ff16c0ee68b10594dfeb1dd5376e4f1481d481aff7", + "tests/HealthApp.AcceptanceTests/PatchObservationTests.cs": "a4096b2d3c5046b948e96dc79e40c302c46c8e64704e2f77069fb8ea984e6d48", + "tests/HealthApp.AcceptanceTests/PatientApiFixture.cs": "665d2b1955dd3c03a5d11330bd9dafae3942cfde1f4e9d413c5dbd4b970b3e2d", + "tests/HealthApp.AcceptanceTests/PatientAuthenticationTests.cs": "b6130edc59e800312b9a8e4a2f3b084c36fe4230b36a9e8ee9159791c1ecdf30", + "tests/HealthApp.AcceptanceTests/ProfessionalAccessTests.cs": "9fbeff0cc2a02cbb2587f9f9bec08dc6e623b3d59a833f8be7d5e7823807d743", + "tests/HealthApp.AcceptanceTests/ProfileLifecycleTests.cs": "3f00b214300a44930ba5707b52cdd7f2f335b155cf131ccb65ef2b4baa4ad647", + "tests/HealthApp.AcceptanceTests/RecordMeasurementContextTests.cs": "bde451e9aee2a9097f0bd41622f967e2b8fccc3db5809c29d261995114931165", + "tests/HealthApp.AcceptanceTests/RecordObservationTests.cs": "1cd5f551712a4f592dadbe2cbf772c9f1fdb7953d938971771af74c0760be90f", + "tests/HealthApp.AcceptanceTests/SnapshotTests.cs": "287e96f3ec808dbc9831a17243660fd611251521939a2f1f42d46f076810db1c", + "tests/HealthApp.AcceptanceTests/Support/AuthenticatedTestClient.cs": "be81a81d5264ac8b06ec4ccf66b8d9653c3249c0f5db2abd894e035c6a0d4c97", + "tests/HealthApp.AcceptanceTests/UpdateObservationTests.cs": "7ff2a356e9ac385237a9043d56659ba3ae819c6710e1aaa4f5945a243ac1a736", + "tests/HealthApp.AcceptanceTests/UpdatePatientTests.cs": "a5f3765146a0a28fbb26ee08caceec7722358dec01659399736b227653fdab10", + "tests/HealthApp.AcceptanceTests/ViewObservationContextTests.cs": "e356b4b34c078edf3902cb38796ac4ac6597eca026a423b16e7e754bfaf5e104", + "tests/HealthApp.DeploymentTests/HealthApp.DeploymentTests.csproj": "4f5ff1a801773f09dc10a37e1a4ef55096ec2a5c3823976a08643bf5a7ed5330", + "tests/HealthApp.DeploymentTests/ProvisioningTests.cs": "ebc5d2247693863f05122bb15255d82bdcc56267cd4573b6c0c5cc766831eef8", + "tools/comparison/dataset.json": "240b2d19292dcc6178a94e7c60bb4e0a6f3df9441abf147ea10308b19fcf5686", + "tools/comparison/initialize.py": "b45ba8defb1cf1ddeb290b34c123fbf30a37db8b2180c9b0f7877ca99c76faf4", + "tools/native-install-test/Dockerfile": "1420907951a8b74dca7fb55483d9f9a554d84e203f6f7f3c565580e0e4aba952", + "tools/native-install-test/README.md": "7e3f15bfb3873924818f6e503aca2be3eea68e2230c15fb55ac3ae655840a080", + "tools/native-install-test/local.py": "326ba644a9867226f7111fce7ea07475a8871a74fe96bb67a89b1f74f72f3cf1", + "tools/native-install-test/remote.py": "d56114b60eb4f62558ee82f65c49246240861631de0f8cedce714db7726e24f1", + "tools/run-disposable-tests.py": "7b43367af34772e1bd2c8ea6d86bf434822547d7e5e7af591d7465072165fe51" + } +} diff --git a/implemented_architecture/source-inventory.md b/implemented_architecture/source-inventory.md new file mode 100644 index 0000000..48f20e6 --- /dev/null +++ b/implemented_architecture/source-inventory.md @@ -0,0 +1,122 @@ +# Supporting source inventory + +Generated from the inspected implementation; generated build output is excluded. Each entry links to the actual file. Hashes are in [snapshot.json](snapshot.json). This includes application, provisioning, tests and verification/comparison tooling, not the archived Architecture A source. + +## src + +- [src/HealthApp/Controllers/AuthenticationController.cs](../src/HealthApp/Controllers/AuthenticationController.cs) +- [src/HealthApp/Controllers/HealthOverviewController.cs](../src/HealthApp/Controllers/HealthOverviewController.cs) +- [src/HealthApp/Controllers/InsightsController.cs](../src/HealthApp/Controllers/InsightsController.cs) +- [src/HealthApp/Controllers/MeasurementGuidanceController.cs](../src/HealthApp/Controllers/MeasurementGuidanceController.cs) +- [src/HealthApp/Controllers/ObservationController.cs](../src/HealthApp/Controllers/ObservationController.cs) +- [src/HealthApp/Controllers/PatientController.cs](../src/HealthApp/Controllers/PatientController.cs) +- [src/HealthApp/Controllers/ProfessionalController.cs](../src/HealthApp/Controllers/ProfessionalController.cs) +- [src/HealthApp/HealthApp.csproj](../src/HealthApp/HealthApp.csproj) +- [src/HealthApp/Program.cs](../src/HealthApp/Program.cs) +- [src/HealthApp/Security/AccessPolicy.cs](../src/HealthApp/Security/AccessPolicy.cs) +- [src/HealthApp/Security/ProfessionalAssignments.cs](../src/HealthApp/Security/ProfessionalAssignments.cs) +- [src/HealthApp/Security/PrototypeAccounts.cs](../src/HealthApp/Security/PrototypeAccounts.cs) +- [src/HealthApp/Security/RequestBoundaryMiddleware.cs](../src/HealthApp/Security/RequestBoundaryMiddleware.cs) +- [src/HealthApp.Contracts/AnalyticsFacades.cs](../src/HealthApp.Contracts/AnalyticsFacades.cs) +- [src/HealthApp.Contracts/AuthorizedPatientContext.cs](../src/HealthApp.Contracts/AuthorizedPatientContext.cs) +- [src/HealthApp.Contracts/ClinicalRuleProvenance.cs](../src/HealthApp.Contracts/ClinicalRuleProvenance.cs) +- [src/HealthApp.Contracts/ContextSelection.cs](../src/HealthApp.Contracts/ContextSelection.cs) +- [src/HealthApp.Contracts/CreatePatientRequest.cs](../src/HealthApp.Contracts/CreatePatientRequest.cs) +- [src/HealthApp.Contracts/HealthApp.Contracts.csproj](../src/HealthApp.Contracts/HealthApp.Contracts.csproj) +- [src/HealthApp.Contracts/HealthInsight.cs](../src/HealthApp.Contracts/HealthInsight.cs) +- [src/HealthApp.Contracts/HealthOverviewDto.cs](../src/HealthApp.Contracts/HealthOverviewDto.cs) +- [src/HealthApp.Contracts/MeasurementContext.cs](../src/HealthApp.Contracts/MeasurementContext.cs) +- [src/HealthApp.Contracts/MeasurementContextPatch.cs](../src/HealthApp.Contracts/MeasurementContextPatch.cs) +- [src/HealthApp.Contracts/ObservationDto.cs](../src/HealthApp.Contracts/ObservationDto.cs) +- [src/HealthApp.Contracts/ObservationFacades.cs](../src/HealthApp.Contracts/ObservationFacades.cs) +- [src/HealthApp.Contracts/PatchObservationRequest.cs](../src/HealthApp.Contracts/PatchObservationRequest.cs) +- [src/HealthApp.Contracts/PatientDto.cs](../src/HealthApp.Contracts/PatientDto.cs) +- [src/HealthApp.Contracts/RecordObservationRequest.cs](../src/HealthApp.Contracts/RecordObservationRequest.cs) +- [src/HealthApp.Contracts/TrendAssessment.cs](../src/HealthApp.Contracts/TrendAssessment.cs) +- [src/HealthApp.Contracts/UpdateObservationRequest.cs](../src/HealthApp.Contracts/UpdateObservationRequest.cs) +- [src/HealthApp.Contracts/UpdatePatientRequest.cs](../src/HealthApp.Contracts/UpdatePatientRequest.cs) +- [src/HealthApp.Infrastructure/HealthApp.Infrastructure.csproj](../src/HealthApp.Infrastructure/HealthApp.Infrastructure.csproj) +- [src/HealthApp.Infrastructure/RequestTransaction.cs](../src/HealthApp.Infrastructure/RequestTransaction.cs) +- [src/Modules/Analytics/Analytics.csproj](../src/Modules/Analytics/Analytics.csproj) +- [src/Modules/Analytics/AnalyticsFacade.cs](../src/Modules/Analytics/AnalyticsFacade.cs) +- [src/Modules/Analytics/AssemblyInfo.cs](../src/Modules/Analytics/AssemblyInfo.cs) +- [src/Modules/Analytics/ClinicalPolicy.cs](../src/Modules/Analytics/ClinicalPolicy.cs) +- [src/Modules/Analytics/SummaryPolicy.cs](../src/Modules/Analytics/SummaryPolicy.cs) +- [src/Modules/Analytics/TrendPolicy.cs](../src/Modules/Analytics/TrendPolicy.cs) +- [src/Modules/Guidance/Guidance.csproj](../src/Modules/Guidance/Guidance.csproj) +- [src/Modules/Guidance/GuidanceQueries.cs](../src/Modules/Guidance/GuidanceQueries.cs) +- [src/Modules/Guidance/ReviewedReferenceCatalog.cs](../src/Modules/Guidance/ReviewedReferenceCatalog.cs) +- [src/Modules/Observations/AssemblyInfo.cs](../src/Modules/Observations/AssemblyInfo.cs) +- [src/Modules/Observations/Domain/BloodPressureObservation.cs](../src/Modules/Observations/Domain/BloodPressureObservation.cs) +- [src/Modules/Observations/Migrations/001-observations.sql](../src/Modules/Observations/Migrations/001-observations.sql) +- [src/Modules/Observations/ObservationFacade.cs](../src/Modules/Observations/ObservationFacade.cs) +- [src/Modules/Observations/Observations.csproj](../src/Modules/Observations/Observations.csproj) +- [src/Modules/Observations/Persistence/ObservationDbContext.cs](../src/Modules/Observations/Persistence/ObservationDbContext.cs) +- [src/Modules/Overview/Overview.csproj](../src/Modules/Overview/Overview.csproj) +- [src/Modules/Overview/OverviewFacade.cs](../src/Modules/Overview/OverviewFacade.cs) +- [src/Modules/Profile/AssemblyInfo.cs](../src/Modules/Profile/AssemblyInfo.cs) +- [src/Modules/Profile/Domain/Patient.cs](../src/Modules/Profile/Domain/Patient.cs) +- [src/Modules/Profile/Migrations/001-profile.sql](../src/Modules/Profile/Migrations/001-profile.sql) +- [src/Modules/Profile/Persistence/PatientDbContext.cs](../src/Modules/Profile/Persistence/PatientDbContext.cs) +- [src/Modules/Profile/Profile.csproj](../src/Modules/Profile/Profile.csproj) +- [src/Modules/Profile/ProfileFacade.cs](../src/Modules/Profile/ProfileFacade.cs) +- [src/TRENDS.md](../src/TRENDS.md) + +## deploy + +- [deploy/HealthApp.Provisioning/HealthApp.Provisioning.csproj](../deploy/HealthApp.Provisioning/HealthApp.Provisioning.csproj) +- [deploy/HealthApp.Provisioning/Installation.cs](../deploy/HealthApp.Provisioning/Installation.cs) +- [deploy/HealthApp.Provisioning/Program.cs](../deploy/HealthApp.Provisioning/Program.cs) +- [deploy/INSTALLATION.md](../deploy/INSTALLATION.md) +- [deploy/appsettings.example.json](../deploy/appsettings.example.json) +- [deploy/build-release.sh](../deploy/build-release.sh) +- [deploy/installer/bootstrap.sh](../deploy/installer/bootstrap.sh) +- [deploy/installer/install.sh](../deploy/installer/install.sh) +- [deploy/systemd/healthapp-b.service](../deploy/systemd/healthapp-b.service) + +## tests + +- [tests/HealthApp.AcceptanceTests/AuthenticationIntegrationTests.cs](../tests/HealthApp.AcceptanceTests/AuthenticationIntegrationTests.cs) +- [tests/HealthApp.AcceptanceTests/ConformanceTests.cs](../tests/HealthApp.AcceptanceTests/ConformanceTests.cs) +- [tests/HealthApp.AcceptanceTests/ContextFilteredHistoryTests.cs](../tests/HealthApp.AcceptanceTests/ContextFilteredHistoryTests.cs) +- [tests/HealthApp.AcceptanceTests/ContextSelectedInsightTests.cs](../tests/HealthApp.AcceptanceTests/ContextSelectedInsightTests.cs) +- [tests/HealthApp.AcceptanceTests/CreatePatientTests.cs](../tests/HealthApp.AcceptanceTests/CreatePatientTests.cs) +- [tests/HealthApp.AcceptanceTests/DeleteContextualisedObservationTests.cs](../tests/HealthApp.AcceptanceTests/DeleteContextualisedObservationTests.cs) +- [tests/HealthApp.AcceptanceTests/DeleteObservationTests.cs](../tests/HealthApp.AcceptanceTests/DeleteObservationTests.cs) +- [tests/HealthApp.AcceptanceTests/FoundationTests.cs](../tests/HealthApp.AcceptanceTests/FoundationTests.cs) +- [tests/HealthApp.AcceptanceTests/GlobalUsings.cs](../tests/HealthApp.AcceptanceTests/GlobalUsings.cs) +- [tests/HealthApp.AcceptanceTests/HealthApp.AcceptanceTests.csproj](../tests/HealthApp.AcceptanceTests/HealthApp.AcceptanceTests.csproj) +- [tests/HealthApp.AcceptanceTests/HealthInsightTests.cs](../tests/HealthApp.AcceptanceTests/HealthInsightTests.cs) +- [tests/HealthApp.AcceptanceTests/HealthOverviewTests.cs](../tests/HealthApp.AcceptanceTests/HealthOverviewTests.cs) +- [tests/HealthApp.AcceptanceTests/HealthTrendTests.cs](../tests/HealthApp.AcceptanceTests/HealthTrendTests.cs) +- [tests/HealthApp.AcceptanceTests/LatestObservationTests.cs](../tests/HealthApp.AcceptanceTests/LatestObservationTests.cs) +- [tests/HealthApp.AcceptanceTests/MeasurementContextMigrationTests.cs](../tests/HealthApp.AcceptanceTests/MeasurementContextMigrationTests.cs) +- [tests/HealthApp.AcceptanceTests/MeasurementGuidanceTests.cs](../tests/HealthApp.AcceptanceTests/MeasurementGuidanceTests.cs) +- [tests/HealthApp.AcceptanceTests/ObservationApiFixture.cs](../tests/HealthApp.AcceptanceTests/ObservationApiFixture.cs) +- [tests/HealthApp.AcceptanceTests/ObservationConcurrencyTests.cs](../tests/HealthApp.AcceptanceTests/ObservationConcurrencyTests.cs) +- [tests/HealthApp.AcceptanceTests/ObservationHistoryTests.cs](../tests/HealthApp.AcceptanceTests/ObservationHistoryTests.cs) +- [tests/HealthApp.AcceptanceTests/OperationalTests.cs](../tests/HealthApp.AcceptanceTests/OperationalTests.cs) +- [tests/HealthApp.AcceptanceTests/PatchObservationTests.cs](../tests/HealthApp.AcceptanceTests/PatchObservationTests.cs) +- [tests/HealthApp.AcceptanceTests/PatientApiFixture.cs](../tests/HealthApp.AcceptanceTests/PatientApiFixture.cs) +- [tests/HealthApp.AcceptanceTests/PatientAuthenticationTests.cs](../tests/HealthApp.AcceptanceTests/PatientAuthenticationTests.cs) +- [tests/HealthApp.AcceptanceTests/ProfessionalAccessTests.cs](../tests/HealthApp.AcceptanceTests/ProfessionalAccessTests.cs) +- [tests/HealthApp.AcceptanceTests/ProfileLifecycleTests.cs](../tests/HealthApp.AcceptanceTests/ProfileLifecycleTests.cs) +- [tests/HealthApp.AcceptanceTests/RecordMeasurementContextTests.cs](../tests/HealthApp.AcceptanceTests/RecordMeasurementContextTests.cs) +- [tests/HealthApp.AcceptanceTests/RecordObservationTests.cs](../tests/HealthApp.AcceptanceTests/RecordObservationTests.cs) +- [tests/HealthApp.AcceptanceTests/SnapshotTests.cs](../tests/HealthApp.AcceptanceTests/SnapshotTests.cs) +- [tests/HealthApp.AcceptanceTests/Support/AuthenticatedTestClient.cs](../tests/HealthApp.AcceptanceTests/Support/AuthenticatedTestClient.cs) +- [tests/HealthApp.AcceptanceTests/UpdateObservationTests.cs](../tests/HealthApp.AcceptanceTests/UpdateObservationTests.cs) +- [tests/HealthApp.AcceptanceTests/UpdatePatientTests.cs](../tests/HealthApp.AcceptanceTests/UpdatePatientTests.cs) +- [tests/HealthApp.AcceptanceTests/ViewObservationContextTests.cs](../tests/HealthApp.AcceptanceTests/ViewObservationContextTests.cs) +- [tests/HealthApp.DeploymentTests/HealthApp.DeploymentTests.csproj](../tests/HealthApp.DeploymentTests/HealthApp.DeploymentTests.csproj) +- [tests/HealthApp.DeploymentTests/ProvisioningTests.cs](../tests/HealthApp.DeploymentTests/ProvisioningTests.cs) + +## tools + +- [tools/comparison/dataset.json](../tools/comparison/dataset.json) +- [tools/comparison/initialize.py](../tools/comparison/initialize.py) +- [tools/native-install-test/Dockerfile](../tools/native-install-test/Dockerfile) +- [tools/native-install-test/README.md](../tools/native-install-test/README.md) +- [tools/native-install-test/local.py](../tools/native-install-test/local.py) +- [tools/native-install-test/remote.py](../tools/native-install-test/remote.py) +- [tools/run-disposable-tests.py](../tools/run-disposable-tests.py) diff --git a/implemented_architecture/traceability-and-evidence.md b/implemented_architecture/traceability-and-evidence.md new file mode 100644 index 0000000..606ffb6 --- /dev/null +++ b/implemented_architecture/traceability-and-evidence.md @@ -0,0 +1,42 @@ +# Authority, traceability and verification limits + +## Snapshot and authoritative inputs + +| Reference | Revision / location | +|---|---| +| As-is documentation snapshot | 0205f983904e548aff533c8fa81d5a1a87fdaf2e | +| Tested implementation | 36740d249225898df1b3be720c453b365ffb9fa7 | +| Original read-only implementation | 2117236366130775214d9fd2611984d4348f2b79 | +| Approved target proposal | 3426236c6cfcece36e94642ae84d1843288f86d5 | +| Approval revision | 20ab461c0194b3098504eabc96e9852a61356953 | + +[AGENT.md](../AGENT.md), [approval decisions](../Docs/ApprovalRequirements/architecture-b-implementation-approval.md), functional requirements in Docs and approved ArchitectureProposal govern the implementation. This folder is descriptive and does not supersede them. Pre-existing instruction-file working-tree changes are excluded from this documentation work. + +## Supporting registers + +| Concern | Maintained evidence | +|---|---| +| Approved stages and scope | [Implementation plan](../ImplementationPlan/implementation-plan.md), [approval register](../ImplementationPlan/open-questions.md) | +| Decision/component conformance | [Architecture conformance](../ImplementationPlan/architecture-conformance.md) | +| Functional preservation | [Functional equivalence](../ImplementationPlan/functional-equivalence.md), [146-criterion acceptance register](../ImplementationPlan/acceptance-register.md) | +| Changed topology-dependent tests | [Test adaptations](../ImplementationPlan/test-adaptations.md) | +| Changes/revisions | [Implementation log](../ImplementationPlan/implementation-log.md) | +| Mathematical/clinical provenance | [Clinical provenance](../ImplementationPlan/clinical-provenance.md), [trend method](../src/TRENDS.md) | +| Independent build/test evidence | [Final verification manifest](../ImplementationPlan/evidence/final-verification.json) | +| Native deployment | [Local summary](../ImplementationPlan/evidence/native-debian12-summary.json), [remote summary](../ImplementationPlan/evidence/native-debian12-remote-summary.json) | +| Inputs and baseline | [Input manifest](../ImplementationPlan/baseline-manifest.json), [reference-file manifest](../ImplementationPlan/reference-files.json) | +| Controlled comparison | [Measurement context](../ImplementationPlan/measurement-context.md), tools/comparison | + +## What the existing evidence establishes + +The recorded Release build has zero warnings/errors. Final automated suites report 276 acceptance and seven deployment tests passing, zero failures/skips (283 total). The B-local original baseline reports 299 passes; counts differ because topology-dependent integration tests were explicitly adapted, not because an equal count proves equivalence. Exact adaptations and retained assertions are recorded in the linked register. + +Evidence covers ownership/assignment, forged/expired tickets, non-disclosure before validation, rollback/retry, database constraints and restricted runtime role, concurrent patches, coherent overview under concurrent commit, one selected-series capture, connection release before calculation, admission/deadline/outage behavior, numerical/context semantics and module boundaries. Native installation evidence exercises real systemd units and local/verified-remote database provisioning. + +Of 146 mapped acceptance entries, 140 are recorded functionally verified and six partially verified for independent clinical support (11-AC-21, 22, 23, 26, 29; 15-AC-02). Preserved clinical outputs and regression tests do not establish clinical validity. The provenance register records inherited uncertain claims. + +## Unresolved limitations + +Other intended Linux distributions are not natively verified. Native tests used isolated containers, not physical/VM measurement hosts. Clinical review is incomplete. No A production-data migration, HA, automatic installer rollback/resume, certificate renewal or energy measurement is included. Synchronous original arithmetic is cancellable at policy boundaries, not per-iteration preemptible. No new architectural deviation is introduced by these documents; approved consolidation/failure/provisioning/portability decisions remain documented in the existing registers. + +This documentation change does not rerun application tests. Its validation checks local links, source manifest hashes and source/project inventory against the inspected working tree. Existing build/test/install outcomes above are attributed to their recorded revisions, not to a new execution.