Implementation plan / Session plan / Foundation for agent work
Sessions FN: Foundation for agent work¶
Sessions that prepare the repository so that later sessions can start cold and finish with a check. The code repository is this repository (cema-care): code lives beside docs/, which stays as it is. They implement no functional requirement; the platform requirements of Domain 2 are delivered and proven in the slices, starting with RC-1.
The rules every session follows are in sections 2 to 4 of the session plan. Sessions on the same step of a slice have no order between them and can run in parallel. A session of one slice can also come after a session of an earlier slice; its "After" row names it.
| Step | Session | Kind | Scope | After | Status |
|---|---|---|---|---|---|
| 1 | FN-S01 | Foundation | Repository layout and agent instructions | – | Done |
| 2 | FN-S02 | Foundation | Local integration environment | FN-S01 | Done |
| 2 | FN-S06 | Foundation | Application shell skeleton and design system | FN-S01 | Done |
| 3 | FN-S03 | Foundation | Service template | FN-S02 | Done |
| 4 | FN-S04 | Foundation | Contract and event tooling | FN-S03 | Done |
| 4 | FN-S05 | Foundation | Continuous integration pipeline | FN-S03 | Done |
| 4 | FN-S07 | Foundation | End-to-end test harness and evidence record | FN-S03, FN-S06 | Done |
FN-S01 Foundation: Repository layout and agent instructions¶
| Status | Done (#8) |
| After | – |
| Enables | FN-S02, FN-S06, RC-1-S01, RC-1-S02 |
| Scope | Lay out the code in this repository (cema-care), beside docs/, along the deployable units of the architecture: top-level folders for services, web workspaces, contracts, platform (infrastructure as code and environments), end-to-end tests and decision records. Each deployable unit, each domain workspace and each domain's contract folder has its own dependency manifest and lockfile, so that sessions running side by side never change the same file; nothing at the repository root is edited by an ordinary session; docs/, mkdocs.yml and the documentation site stay as they are; read .github/workflows/, mkdocs.yml and .gitignore at the repository root first. Write the agent instruction file: build and test commands, naming, the session rules of this plan, where handovers and decision records go. The decision records already exist in docs/architecture/decisions/ (drafted 2026-11-24): point the instruction file at them, and record there, as the next numbered record, any further decision the layout or the template needs. |
| Reads | Architecture, sections 5, 6.6, 7.5 and 10.3 Technology stack Session plan, sections 2 to 4 |
| Leaves behind | The code folders beside docs/, the agent instruction file at the repository root, any new decision records, and .gitignore entries for build output. |
| Ends when | A new session can find, from the instruction file alone, where code goes and how to build and test it; the documentation site still builds and passes its link check. The Enterprise Architecture Board has approved the decision records. |
| Needs a person | The Enterprise Architecture Board approves the decision records ADR-HIS-001 to ADR-HIS-038 and any the session adds |
FN-S02 Foundation: Local integration environment¶
| Status | Done (#9) |
| After | FN-S01 |
| Enables | FN-S03, RC-1-S01, RC-1-S02 |
| Scope | One command brings up the backing services a slice needs: PostgreSQL, Kafka with the schema registry, Keycloak with a test realm, the secrets store in development mode, and the telemetry stack. Synthetic data only. Several sessions run on one server, each in its own checkout, so the environment is separate for each: its containers, networks and volumes are named after the session (from the HIS_SESSION and COMPOSE_PROJECT_NAME variables the launcher sets), it publishes no fixed host port, and reset touches only its own. A light profile with PostgreSQL alone is enough for unit and contract tests against stubs; the full profile is for integrate and gate sessions. |
| Reads | Technology stack Architecture, section 10 |
| Leaves behind | Environment definition with a light and a full profile, start and reset commands, a smoke check. |
| Ends when | Start, smoke check and reset run clean from a fresh checkout; two environments under different session names run at the same time on one server, and resetting one leaves the other untouched. |
FN-S03 Foundation: Service template¶
| Status | Done (#11) |
| After | FN-S02 |
| Enables | FN-S04, FN-S05, FN-S07, RC-1-S01, RC-1-S02 |
| Scope | A domain service that does nothing but carries everything every service must: health endpoints, token validation, the call to the policy decision point, audit emission, the transactional outbox and idempotent inbox, schema migrations, telemetry with correlation identifiers, and the test layout. The service has its own dependency manifest and lockfile, and its unit and contract tests run on the light profile of the integration environment. |
| Reads | Architecture, sections 6, 7.3 and 8 Technology stack |
| Leaves behind | The template service and a generator or copy procedure for new services. |
| Ends when | A service made from the template starts in the integration environment, publishes and consumes one test event idempotently, and its tests pass. |
FN-S04 Foundation: Contract and event tooling¶
| Status | Done (#12) |
| After | FN-S03 |
| Enables | RC-1-S01, RC-1-S02 |
| Scope | Conventions and tooling for API and event contracts: file layout, the event envelope, registration in the schema registry, the compatibility check, stub generation from a contract, and contract tests on both sides. The shared type library of architecture section 6.6 (qualified identifier, coded value, quantity, money, instant and period, references, provenance, status with reason), aligned with FHIR R4 datatypes, and the facility identifier and facility denial cases that section 7.5 requires. |
| Reads | Architecture, sections 6.2, 6.3, 6.6 and 7.5 Event catalogue |
| Leaves behind | Contract folder with one worked example, the shared type library, compatibility check, stub generator, contract test harness. |
| Ends when | The example contract passes the check, a breaking change to it fails the check, and a stub generated from it answers a contract test. |
FN-S05 Foundation: Continuous integration pipeline¶
| Status | Done (#13) |
| After | FN-S03 |
| Enables | RC-1-S01, RC-1-S02 |
| Scope | The pipeline every pull request runs: build, tests, static analysis, dependency and image scan, secret scan, the software bill of materials, and the contract compatibility check once it exists. It is built in GitHub Actions beside the existing documentation workflow, which keeps running (ADR-HIS-038). Each job runs only when the files it covers change. Keep the logic of each job in a script the workflow calls, so that the pipeline can be moved to the self-managed GitLab before production with little rewriting. |
| Reads | Architecture, section 10.3 Technology stack |
| Leaves behind | Pipeline definition and its documentation in the agent instruction file. |
| Ends when | A pull request with a failing test, a planted secret or a vulnerable dependency is stopped; a clean one passes; a documentation-only change still runs the documentation jobs and nothing else. |
FN-S06 Foundation: Application shell skeleton and design system¶
| Status | Done (#10) |
| After | FN-S01 |
| Enables | FN-S07, RC-1-S01, RC-1-S02 |
| Scope | The staff application shell frame, the design tokens and base components of the design system, and the component and accessibility test setup. An empty workspace for each of the ten domains, laid out so that screen sessions can run side by side: every screen has a folder of its own, named by its screen identifier, and registers its route and navigation entry with the shell from a file in that folder, so adding a screen changes no file outside its folder. Record this layout as the next numbered decision record. |
| Reads | Application shell Design system Clinical UX safety rules Architecture, section 11 |
| Leaves behind | Shell and design-system packages, the ten domain workspaces with one example screen folder, the decision record of the layout, test setup. |
| Ends when | The example screen loads in the shell; a second screen folder added to the same workspace appears in the shell without a change to any other file; the component and accessibility checks run in the pipeline. |
FN-S07 Foundation: End-to-end test harness and evidence record¶
| Status | Done (#14) |
| After | FN-S03, FN-S06 |
| Enables | RC-1-S01, RC-1-S02 |
| Scope | The runner for slice scenarios against the integration environment, synthetic data builders, tagging of tests with requirement and test identifiers, and the evidence record with the fields PRS section 17.3 requires. |
| Reads | Stage gates, section 1 Vertical slices, section 1 |
| Leaves behind | Scenario runner, data builders, evidence record generator. |
| Ends when | A sample scenario through the template service and the example workspace runs and produces a complete evidence record. |