Implementation plan / Session plan / Handover RC-1-S12
Handover RC-1-S12 Build: Platform: gateways¶
Card: RC-1-S12. Issue: cema-care/his#26. Branch: session/RC-1-S12. Slice: RC-1. Decision record: ADR-HIS-062.
What was built and where¶
Everything is in platform/gateways/; its README is the full description.
- Two gateways on Apache APISIX 3.19 (technology stack row 8), image pinned by digest:
internal: the web gateway for user channels and the API gateway for service APIs;partner: partner systems and patient-authorized applications, with the external, fail-closed rules.- The
his-gatewayplugin (apisix/lua/), which runs the whole of FR-ISE-GWY-001 on every route, in this order: - correlation identifier, made when absent and returned;
- TLS only: plain HTTP is bound to the loopback interface;
- version lifecycle: a retired major gets a 404 naming its successor; a deprecated one gets
DeprecationandSunset; - load shedding by tier;
- authentication:
- the token's signature, issuer and lifetime;
- the gateway in its audience;
- a registered, Active client;
- RFC 7662 introspection for revocation;
- CFG-ISE-001 rate limits per session, client or grant, and per route;
- validation against the published contract;
- the D10 policy decision, with the CFG-ISE-031 timeout, retry on another replica and circuit breaker, and the degraded path of D02-ISE 9.1;
- a circuit per target unit;
- Problem errors without internal detail;
- the JSON access log, metrics and traces;
- audit events.
- The model (
model/): - settings;
- client registrations (Active, Suspended, Revoked);
- the published APIs, derived from each contract's generated stub;
- environments.
bin/gateways(Python standard library):checkrefuses any drift from CFG-ISE-001, CFG-ISE-031 and CFG-ESS-025, a route without a contract, duplicate routes, and a deprecation shorter than CFG-ISE-002;renderwritesrendered/<env>/: the APISIX configuration, the contract documents, the Kubernetes manifests (read-only root filesystem, non-root, zone spread, PodDisruptionBudget, HorizontalPodAutoscaler, NetworkPolicy) and the Argo CD application;changesturns a model change intoise.config.changedaudit events with before and after values (part 12).rendered/reference/: 221 routes. Theinternalgateway publishes the ADM, ESS and ISE APIs of RC-1 under/<domain>/v<major>/. Thepartnergateway publishes nothing yet.observability/alert-rules.yaml: Prometheus alerts for:- the policy service unavailable (Tier 1);
- 15 minutes of outage (declare downtime);
- the audit path unconfirmed;
- a high rejection rate.
- The test bed (
test/testbed/) and the unit tests (test/unit/).ci.shis what the pipeline runs: the check, the rendering current, and all tests.
Checks and their result¶
| Check | Command | Result |
|---|---|---|
| Model | bin/gateways check |
passed (reference: 221 routes) |
| Rendering current | bin/gateways render --env reference --check |
passed |
| Unit tests | python3 test/run.py --unit |
18 of 18 passed |
| Test bed | HIS_SESSION=RC-1-S12 python3 test/run.py --testbed (full profile, his-rc-1-s12) |
29 of 29 passed |
| Everything the pipeline runs | HIS_SESSION=RC-1-S12 platform/gateways/ci.sh |
passed: model checked, rendering current, 47 of 47 tests |
| Static analysis | platform/delivery-pipeline/bin/static-analysis platform/gateways |
no blocking finding in tracked files. Semgrep also scans the ignored test/out/, where the test bed's copy of the contract tooling raises findings; the pipeline scans changed files only |
| Secret scan | platform/delivery-pipeline/bin/secret-scan code origin/main |
no secret. The test bed uses only the development values of FN-S02 and secrets of its own test realm, marked gitleaks:allow |
| Documentation links | python3 docs/implementation_plan/tools/check_links.py |
0 broken |
How the test bed works: - the gateways run with a read-only root filesystem, as in Kubernetes; - Docker networks stand for the edge zone and the internal zone (no route out); - Keycloak is the session's full profile, with real tokens; - behind the gateways are an echo unit, two controllable decision-service replicas, an audit intake and the ADM contract stub.
It needs Docker, Python 3.11 or later and openssl, and takes about two minutes after the environment has started.
Requirements and test scenarios¶
Every test names its requirement in its docstring. test/run.py writes them with their results to test/out/results.json.
| Requirement, criterion or behaviour | Test (test/testbed/test_gateway.py unless named) |
|---|---|
| FR-ISE-GWY-001 AC-01: no direct access, only the gateway path (BR-ISE-001) | T01Transport.test_direct_access_to_units_refused |
| Behaviour 1: TLS, unencrypted refused | T01Transport.test_unencrypted_requests_refused; test_model.test_no_plain_http_listener |
| Behaviour 2, PR-GWY-001-1: missing, malformed, forged credentials | T02Authentication.test_missing_and_invalid_credentials_rejected |
| AC-02: revoked credential rejected and logged | T02Authentication.test_revoked_credential_rejected_and_logged |
| Part 11: client states (Suspended, unregistered) | T02Authentication.test_client_registration_states; test_model.test_client_registration_rules |
| AC-03, PR-GWY-001-3, behaviour 4 (CFG-ISE-001) | T03RateLimits.test_limit_per_client_does_not_affect_others; test_model.test_configuration_values_of_the_specification |
| AC-04, behaviour 6, BR-ISE-004: one correlation identifier in gateway, service and audit records | T04Correlation.* |
| AC-05, PR-GWY-001-2: deny returns no data | T05PolicyDecision.test_deny_returns_no_data |
| Behaviour 3: the decision request carries identity, purpose and context, and passes them on; obligations; deny-override-available; purpose and facility | T05PolicyDecision.* |
| Behaviour 5: contract validation | T07Validation.test_malformed_requests_rejected; test_model.test_openapi_documents_resolve_references |
| Behaviour 7, PR-GWY-001-4: versions | T06Versions.*; test_model.test_deprecated_and_retired_versions, test_deprecation_window |
| Behaviour 8, part 12: telemetry and audit | T10External.test_external_patient_data_access_audited, T13Telemetry.*; test_model.TestChangeAudit |
| Behaviour 9: priority load shedding | T09Overload.test_load_shed_by_priority |
| Part 9, part 13: no internal detail; unit unavailable fails fast | T08Errors.* |
| Part 3: routes only from published contracts | T06Versions.test_unpublished_path_not_found; test_model.test_reference_model_checks, test_route_without_contract_refused |
| BR-ESS-022: external data held without the audit path | T10External.test_external_access_fails_closed_without_audit_path |
| TEST-ISE-007 (revoked credential, over limit, retired version, bypassing the gateway: all refused and logged; correlation identifier on accepted calls) | T01 to T08, T10 |
| TEST-ISE-039 (policy service stopped) | T11PolicyOutage.test_b_policy_service_outage and test_a_retry_on_another_replica_and_timeout |
| Contract tests: IF-ISE-001 through the gateway; IF-ESS-003 and IF-ESS-008 as sent | T12Contracts.test_provider_contract_through_the_gateway (his-contract verify contracts/adm through the gateway, 72 cases); T12Contracts.test_what_the_gateway_sent_to_domain_10_meets_its_contracts (every decision request and audit event replayed to the ESS stub, no violation) |
TEST-ISE-039 covers these points:
- the external request returns no data;
- a fresh cached Permit serves an internal Tier 1 read, and its use is audited;
- a stale cache and restricted content are denied;
- a write is rejected with "the action was not saved" and Retry-After;
- Break-the-Glass is forwarded;
- the circuit opens and stops calling the decision service;
- the alert metric is raised, and the downtime prompt comes after the outage limit;
- the half-open probe closes the circuit on recovery.
The test bed shortens two times so that TEST-ISE-039 runs in a minute: the cached-Permit maximum age is 8 seconds (60 minutes in CFG-ESS-025), and the downtime limit is 20 seconds (15 minutes in CFG-ISE-031). The model check refuses these overrides outside the test bed. The 15-minute outage itself is therefore not run in real time.
Non-functional targets:
- NFR-ISE-005: non-root, read-only root filesystem, TLS 1.2 and 1.3 only, no internal detail, the image pinned;
- NFR-ISE-009: contract validation and version lifecycle from the catalogue's contracts;
- NFR-ISE-012: correlation, trace and span identifiers in the access log, traces over OTLP, metrics;
- NFR-ISE-016: UTC timestamps, and leeway on token times above the drift threshold;
- NFR-ISE-018: the gateway has no console; Problem detail is English text with a stable code for screens to localize.
Differences from the card, the specification or the contracts¶
- Paths. The contract point of
contracts/isesays "routes map/v<major>/paths to the units". The gateway publishes them under a domain prefix,/<domain>/v<major>/…, because two contract paths are each claimed by two domains: /v1/servicesis an ESS path (master data) and an ISE one (service catalogue);/v1/identifier-resolutionsis an ADM path and an ESS one.
No contract changes. Screens and clients address /<domain>/v1/... through the gateway.
- The gateway's decision request names the resource ise.ApiOperation (<domain>.<api>.<operationId>), not the unit's own resource type. The reason is in ADR-HIS-062. D10 must register this resource type and its policy (follow-ups).
- Retired versions answer 404 not-found with successorVersion and a Link header. IF-ISE-001's error classes have no separate class for "retired".
- Audience. Tokens must name the gateway client ise-gateways in aud. Keycloak 26.8 introspects a token only for a client in its audience, so this is also what makes the revocation check of AC-02 work. The development realm and the production realm need an audience mapper (follow-ups); the test bed adds it to its own realm.
- External partner access is audited as ise.api.client-access, the type D02-ISE 9.5 gives to third-party application access through the gateway. Partner systems use the same type (question 4).
- Cached-Permit use is audited as ise.gateway.cached-permit-used, a type D02-ISE 9.5 does not list. It needs registering, or the audit service quarantines it (question 2).
- No RC-1 operation is declared a Tier 1 clinical read or restricted in the reference model. During a policy outage every internal read is therefore refused: no Permit fallback, which is the safe default of 9.1 ("Gateways never fall back to Permit by default"). The test bed declares ADM reads to exercise the path (question 3).
- Downtime. The declaration itself is FR-ISE-BCR-003, which is not in this slice. The gateway gives three signals: the metric, the alert, and the downtime wording in its answers.
- Cached decisions. IF-ESS-003 lets a caller reuse a decision for cacheLifetimeSeconds, and drops a cached decision on PolicyUpdated, IdentityChanged and ConsentChanged (PR-AUZ-001-5). The gateway consumes none of those events, so it reuses no Permit while the decision service answers; every request is decided afresh. The degraded path of 9.1 still reads the last Permit stored for a key. That key is the user, client application and class, channel, operation, patient, facility and purpose. A later Permit replaces the stored one, and a Deny or refused request deletes it. A Permit stored before one of the three events and not asked again since could therefore be used during an outage. Until the gateway drops stored Permits on those events, bin/gateways check refuses degraded_read in every environment but the test bed (question 5, follow-ups). In the reference model the degraded path serves no read.
- Bulk export concurrency (CFG-ISE-001: one concurrent bulk export job per client) is a job-level limit of the export API, which does not exist yet. It is not enforced at the gateway.
Review round 1¶
The pipeline's dependency scan of platform/gateways failed after all 45 tests had passed. It read test/out/node-work/contracts/common/pnpm-lock.yaml, the test bed's working copy of the contract tooling, which the test bed had left inside the unit folder. Trivy found two critical tinypool findings there. That copy is not a dependency of the unit: the folder tracks no lockfile at all. The test bed now keeps the copy in the system's temporary folder, per session (testbed.py, node_work), so the scan reads only what the unit ships. The contracts/common finding itself is a follow-up below.
Review round 2¶
The review asked for two fixes to how stored Permits are used.
- The drop events of IF-ESS-003. The gateway reused a Permit for its
cacheLifetimeSecondswithout dropping it on PolicyUpdated, IdentityChanged or ConsentChanged. It now reuses no Permit while the decision service answers (his-gateway.lua). A stored Permit is replaced by the next Permit, and deleted by a Deny or a refused request. The model check refusesdegraded_readoutside the test bed until the gateway consumes those events (gwy/model.py). Tests:T05PolicyDecision.test_permit_not_reused_while_the_decision_service_answersandtest_model.test_degraded_read_refused_until_cache_drop_events. The remaining question is Q5. - The client in the key. The Permit key now includes the calling client, its class and the channel (
policy.lua,cache_key). The test bed adds a second staff client,gwy-web.T11PolicyOutage.test_b_policy_service_outageshows that a Permit stored forhis-testdoes not serve the same user throughgwy-webduring an outage.
Questions for a person¶
Posted on issue #26 (Q5 in review round 2). None blocks this session, because each has a fail-closed default.
| # | Question | Owner | What the gateway does now |
|---|---|---|---|
| Q1 | D02-ISE 9.1: "Break-the-Glass stays available" during a policy outage. Is that met by the gateway forwarding the D10 emergency-access operation (startEmergencyAccess), with later reads under the session decided as usual? |
Clinical Governance; Security and Privacy Office | Forwards startEmergencyAccess; other reads follow the degraded rules |
| Q2 | D02-ISE 9.5 names no event type for "each use [of a cached Permit] is audited". May Domain 2 register ise.gateway.cached-permit-used (category authorization and emergency access)? |
Owner of D02-ISE; Domain 10 audit | Emits ise.gateway.cached-permit-used |
| Q3 | Which RC-1 operations are internal Tier 1 clinical read paths that may use a cached Permit? Is MPI lookup (searchPersons, readPerson) one of them? Which can return restricted content? |
Clinical Governance; owner of D01-ADM | None declared: every internal read is refused during an outage |
| Q4 | Is a partner system's read of patient data through the partner gateway audited as ise.api.client-access, or as ise.exchange.received? |
Owner of D02-ISE | ise.api.client-access |
| Q5 | IF-ESS-003 drops a cached decision on PolicyUpdated, IdentityChanged and ConsentChanged (PR-AUZ-001-5). DEC-ESS-018 lets a Tier 1 read use a cached Permit during an outage. Must the gateway have dropped the stored Permit on those events before it may use it, or is the audited use, reviewed after recovery, enough? | Clinical Governance; Security and Privacy Office | Neither: degraded_read is refused outside the test bed until the gateway consumes the three events, so no stored Permit is used |
Follow-ups outside the card¶
- D10 (RC-1-S16, RC-1-S17, runtime decision):
- register the policy resource type
ise.ApiOperationwith action codes view, query, create, update, delete and export, and a policy for it; - create the service identity
ise-gatewayswith introspection, decision and audit-intake rights. - D10 audit (RC-1-S04's catalogue): register
ise.gateway.cached-permit-usedonce Q2 is answered. - Identity realm (FN-S02's development realm, and the production realm in RC-1-S16):
- an audience mapper naming
ise-gatewayson every client that calls through a gateway (his-web,his-test); - the client
ise-gatewaysitself. - Observability (RC-1-S10): load
platform/gateways/observability/alert-rules.yaml, scrape port 9091, and raise ServiceStateChanged fromGatewayPolicyServiceUnavailable. - Network protection (RC-1-S11): the zone rules admit traffic to the application zone only from the edge gateways, which completes AC-01 on the cluster. The gateway's own NetworkPolicy limits its egress.
- Integrate (RC-1-S26):
- put the gateway in front of the units in
e2e/scenarios/RC-1/stack.json; - screens and the harness then call
/<domain>/v1/.... - Service kit (
services/_template): the kit'sPolicyEnforcerhas no Tier 1 cached-decision rule. During an outage a read let through by the gateway is still refused by the unit until the kit has one. - Supply chain: the gateway runs the upstream APISIX image with the plugin and contract documents from ConfigMaps. A built and signed image with them baked in is a later choice.
- FR-ISE-GWY-002 and FR-ISE-GWY-003 (RC-3-S13 and later) extend this unit:
- the catalogue and consumer inventory;
- redaction at the partner gateway, which is now refused instead (
supported_obligations). - Gateway (this unit, a later card), with D10: consume PolicyUpdated (
his.ess.policy.v1), IdentityChanged (his.ess.identity.v1) and ConsentChanged, and drop the stored Permits they concern. Then lift the check that refusesdegraded_read, once Q3 and Q5 are answered. A gateway has no database, so this needs a small consumer beside it that clears the decision store through a private endpoint. - Contract tooling (FN-S04,
contracts/common): its lockfile pinstinypool1.1.1, which has two critical findings (CVE-2026-104848, CVE-2026-104849; fixed in 2.1.2). The pipeline stops a change tocontracts/commonon them until it is upgraded. The gateway test bed runs this tooling from a copy outside the unit folder, so the unit's own scan does not read it. - Design system: none.