Skip to content

Implementation plan / Session plan / Handover FN-S07

Handover FN-S07 Foundation: End-to-end test harness and evidence record

Card: FN-S07. Issue: #7. Branch: session/FN-S07. Decision record: ADR-HIS-047 End-to-end harness: scenario runner, scenario API and evidence record.

What was built and where

All code is in e2e/harness/. Its README.md is the reference for the sessions that write, run and gate slice scenarios.

  • Scenario runner: e2e/harness/scenario run <folder> (lib/runner.py, Python standard library only). For a scenario folder, it:
  • reads stack.json, which names the profile, the units, the contract stubs, the shell and the stub policy decision point;
  • starts the session's environment;
  • serves each contract stub that "stubs" names, a folder under contracts/, with FN-S04's his-contract serve. All of them run in one runner container, and they permit the builders' facilities SYN-FAC-01 and SYN-FAC-02. Each unit gets the stubs' addresses as HIS_CONTRACT_STUB_<DOMAIN>_URL;
  • builds each unit with ./gradlew :app:bootJar and runs it with java -jar on a free port, creating its database if his-env has not;
  • starts the shell's Vite development server, which includes example screens;
  • runs every *.scenario.ts with Playwright 1.64.1 in the pinned image mcr.microsoft.com/playwright, with host networking, one worker and no retries;
  • stops everything and writes the evidence record.

Its containers carry the session label, so his-env reset also cleans up after an interrupted run. The runner includes a stub policy decision point that permits by default, records what it is asked, and can be made to deny or fail like an outage. - Scenario API @his/e2e-harness (src/). scenario(caseId, title, { covers, defects }, body) is one test case, and step names the steps of the story. The fixtures: - unit(name, defaults): a client for a unit by its folder name, or for a contract stub by its domain (unit("adm")). It sets the IF-ISE-001 headers as the template spells them, with a new correlation identifier per call, and logs every call; - stubs: the contract stubs, with violations(), events(domain) and facilities. They are reset before every test, and any violations are attached after it; - tokens: tokens from the test realm; - policy: the stub; - shell.open(screenId) and shell.screenshot(name); - data: the builders below; - evidence: further attachments and notes. - Synthetic data builders (src/data/), seeded from the run seed and the test case ID, so that the same data can be built again: - facility, person (with an exact age, a FHIR gender and an optional family name), identifier, coded, instant, period, reference, text and key; - shapes as in architecture 6.6, aligned with FHIR R4; - identifiers and codes in the system urn:his:e2e:synthetic unless the caller names one; - every value built is attached to the test as synthetic-data.json. - Tagging (src/ids.ts). Identifiers go in covers, which become Playwright tags, or in titles, as CLAUDE.md section 4 says. The kinds are FR, NFR, BR, WF, IF, EVT, UI, CUX, SAFE, ACC and CFG; TEST for the 15.2 catalogue; and session identifiers. A malformed identifier fails when the file loads, and a test that names no requirement cannot be declared with scenario(). - Evidence record generator: scenario evidence generate|check|approve|waive (lib/evidence.py, standard library only). From the Playwright JSON report, the run context and the unit logs it writes three things: - evidence.json, validated against e2e/harness/schema/evidence-record.schema.json; - evidence.md, with links into docs/; - SHA256SUMS.

Each PRS 17.3 field is filled as follows (README table): - Test case ID: from scenario(). - Requirement ID: resolved to where docs/ defines it, plus the requirements of each cited TEST-* row of the 15.2 catalogue. - Build and version: the commit, and the git tree of each component under test. - Environment: the session, profile, backing service images, Java, Node.js, Playwright, the browser and the runner image. - Test data classification: synthetic, with the seed. - Tester: the session, or --tester. - Dates and outcomes. - Defect references. - Screenshots, the API call log and the unit log lines with each call's correlation identifier, each hashed. - Approver and waiver: filled in by people with approve and waive, which refuse a changed record. A waiver recorded after approval resets the approval to pending, because the signed outcome changed.

check validates the schema, completeness and the hashes. --strict turns warnings into failures for gate runs. The warnings are an uncommitted build, a failure with no defect reference, a skip without a waiver, and a passed test with nothing attached. - Sample scenario (sample/), through the template unit (services/_template with MOD-TPL-000), the contract stub of contracts/common/example (domain tpl) and the example screen UI-ADM-000: - FN-S07-SAMPLE-001: a probe is recorded with a test-realm token. The decision point is asked with subject, action, facility and purpose, and the event goes through the outbox and Kafka and is consumed once. - FN-S07-SAMPLE-002: the failure branches. No token gives 401, a policy denial 403, a decision point outage 503 with Retry-After, and an unknown probe 404, each with its error class. - FN-S07-SAMPLE-003: the example screen opens in the shell and moves from Draft to Saved, with a screenshot. - FN-S07-SAMPLE-004: a consumer calls the contract stub. A probe is recorded and read back in its facility. It is hidden (404) from the other permitted facility, an unpermitted facility is refused (403), and no call broke the contract. - Harness self-tests: scenario selftest. It runs the type check and 13 TypeScript tests in the runner image, and 10 Python tests on the host, of the generator, the stack loader (including "stubs") and the stub decision point. - Other changes: - CLAUDE.md section 3: the FN-S07 entry is marked as landed, with the commands; - ADR-HIS-047 and its row in the decision record index, identical to what build_adrs.py writes (checked on a scratch copy; the plan build was not run in the checkout); - dependencies, new in e2e/harness/package.json and pnpm-lock.yaml: @playwright/test 1.64.1, typescript 5.9.3 and @types/node 22.20.5.

Checks and their result

The host had Docker and JDK 21, with no Node.js. Every environment ran under HIS_SESSION=FN-S07 (his-fn-s07), on the full profile.

Check Command Result
Ends when: a sample scenario through the template service and the example workspace runs and produces a complete evidence record HIS_SESSION=FN-S07 e2e/harness/scenario run e2e/harness/sample --strict, on a clean tree at the commit of the review fixes, 11f2203 Passed: 4 of 4 tests, including the contract stub. The record is complete with no warnings, and the exit status is 0. Afterwards no harness container or unit process was left
The record stands on its own e2e/harness/scenario evidence check <run folder> --strict passed; record complete (4 test cases, approval pending)
A failing scenario yields a complete record of the failure The first sample run, where an assertion was wrong about the template's createdBy Outcome failed, record complete. The error and the trace are attached, and "no defect reference yet" is a warning
Harness self-tests e2e/harness/scenario selftest Type check passes; 13 TypeScript tests and 10 Python tests pass
Decision record index matches the generator build_adrs.py on a scratch copy, then diff Identical
Link check of docs/ python3 docs/implementation_plan/tools/check_links.py 0 broken links, 0 duplicate anchors
Links in CLAUDE.md and e2e/harness/README.md A one-off script with the same rule 0 broken
Documentation site mkdocs build Builds

Requirements and test scenarios

The card names no functional requirement or test scenario. The harness's own tests are tagged FN-S07 in their describe titles and test names:

What Test
Tagging (session rule 5) test/ids.test.ts
Synthetic data builders (session rule 6) test/builders.test.ts
Screen routes (ADR-HIS-042) test/shell-route.test.ts
Evidence record: the PRS 17.3 fields, identifier resolution and catalogue via, completeness, schema, failures and defects, approver, waiver, a waiver after approval resetting it, tamper detection test/test_evidence.py, EvidenceRecordTest
Runner: stack.json validation, including "stubs" (by folder, keyed by domain; missing, outside contracts/ or duplicate refused); the stub decision point permits, denies, fails and records test/test_evidence.py, RunnerTest
The whole chain, end to end, including a contract stub sample/sample.scenario.ts. It covers the rules it exercises: IF-ISE-001, IF-ISE-002, IF-ESS-003, CUX-06 and CUX-10. These are tagged to show the mechanism; they are not evidence for those requirements' own sessions

Differences from the card, specification or architecture

  • The runner image runs Node.js 26. The web packages are built and tested on Node.js 22 (FN-S06), and engines asks for 22 or later. The shell's development server ran on 26 without trouble. The image is the one Playwright publishes for 1.64.1.
  • The shell is tested through its development server, not the production bundle. The production bundle leaves out example screens (ADR-HIS-042), and the sample needs UI-ADM-000. Slice screens are in both, so a gate session may want a preview mode later (follow-ups).
  • The decision record is numbered 047. When this session started, the open pull requests of FN-S04 and FN-S05 both added an ADR-HIS-045, so 045 and 046 were left to them. FN-S04's ADR-HIS-045 is now on main, and this branch is merged with it. The index lists both records and counts 46, as the generator writes it. 046 stays free for FN-S05, whose pull request brings the count up to date when it merges.
  • Provisional, as in ADR-HIS-044: the stub decision point answers in the service kit's provisional shape, and the headers are spelled as the template spells them.

Questions for a person

None that blocks. Two points for owners:

  • The Enterprise Architecture Board approves ADR-HIS-047. It is given on the merged work.
  • PRS 17.3 asks for evidence "in a controlled repository". The harness writes a self-checking file set, and the first gate evidence session (RC-1-S28) keeps it where its card says. Product governance may want to name that repository before the first slice gate.

Follow-ups outside the card

  • Contract sessions (RC-1-S01, RC-1-S02 and later): list the contract folders the slice's scenario crosses under "stubs" in stack.json, and assert stubs.violations() is empty. Integrate sessions swap each stub for its unit as it is built.
  • A later change to the harness: type the synthetic data builders against the shared type library contracts/common/types/types.v1.json (FN-S04, merged after this card's work began).
  • FN-S05:
  • run e2e/harness/scenario selftest when e2e/harness/ changes;
  • add e2e/harness/pnpm-lock.yaml to the dependency scan and SBOM;
  • scan the Playwright runner image.
  • ESS contract and build sessions:
  • replace the stub policy decision point with the D10 decision service, via "policy": "none" and HIS_POLICY_URL;
  • once sign-on (UI-ESS-001) exists, the shell fixture signs in with a test-realm user.
  • Integrate sessions: the non-functional checks of their cards (latency, throughput, failure injection) need a load tool. The harness gives the functional run and the evidence, not load generation.
  • Gate sessions: a --shell preview mode that serves the production bundle, once slices have real screens. Gate sessions also need a place for evidence records (see the question above).