Architecture / Decision records / ADR-HIS-065
ADR-HIS-065 The policy decision service: OPA as a sidecar, a fixed evaluator over versioned rule content, and what the unit decides before the rules¶
| Status | Accepted |
| Decided | 2026-11-25 by session RC-1-S17 |
| Record | Drafted 2026-11-25; approved 2026-11-30 by the Enterprise Architecture Board |
| Where the rule lives | services/ess-runtime-decision/ (its README.md; module mod-ess-002: the evaluator src/main/resources/policy/his_authz.rego, the starter content policy/enterprise-access.v1.json and its test pack policy/enterprise-access.v1.test-pack.json, the migration db/mod_ess_002/; the kit's policy package) |
Context¶
Session RC-1-S17 builds the policy decision service, FR-ESS-AUZ-001, in the unit services/ess-runtime-decision. The unit's other module, MOD-ESS-001, already holds the subject attributes (ADR-HIS-061). The service serves policy-decision.v1 (IF-ESS-003) and publishes PolicyUpdated (EVT-ESS-003), the contracts of ADR-HIS-048.
Every enforcement point of every domain asks this service before it acts. The technology stack makes Open Policy Agent the decision engine (row 11, DEC-ESS-008). The specification leaves the following to the design (part 16): - the policy language and how the engine runs; - how policy versions reach the service and apply from their effective time; - how the caller-supplied and the held attributes are delivered, per attribute; - what the starter policy contains.
Decision¶
- OPA runs beside the unit, as a sidecar. The unit talks to it over its REST API at
his.authz.opa-url(HIS_AUTHZ_OPA_URL), on the loopback of the pod, with a 200 ms evaluation timeout. The image isopenpolicyagent/opa:1.22.3-static, pinned by digest. - OPA keeps no state of its own. The unit loads the evaluator and each policy version into it on first use. It loads them again whenever OPA answers without a result, which is what a restarted OPA does.
- An unreachable, failing or slow OPA is an outage. The service answers 503, which every enforcement point treats as Deny (part 10, D10-ESS 8.6). It is never a Permit, and never a refusal.
- Compiling Rego to WebAssembly and evaluating it in the JVM was set aside: it needs a compiler at every policy activation, and the Java runtime for it is at version 0.0.x.
- The evaluator is code. The rules are versioned content. The Rego module
his_authz.rego(packagehis.authz) is fixed with the unit and reviewed like the rest of it. A policy version is data that the evaluator reads atdata.his.policies[<version>]. It holds: - the registered resource types and their actions;
- the rules: effect, resource types, actions, roles, subject kinds, purposes, conditions, obligations, step-up, cache seconds, audit of the Permit;
- the emergency access roles and resource types. The roles are the Break-the-Glass permitted roles of CFG-ESS-006: physicians, nurses and midwives, pharmacists, allied health professionals. Students, supervised practitioners and administrative, finance or IT roles are not among them.
A condition compares an attribute path (request.*, subject.*, context.*, environment.*) with a value, a list or another path. It says what an absent attribute means (ifMissing). Otherwise an absent attribute is missing: a permit rule does not permit, and the trace names the attribute (PR-AUZ-001-3). A deny rule with a missing attribute does not apply.
The combination: - deny by default (PR-AUZ-001-1); - an explicit deny prevails over any permit (PR-AUZ-001-2); - a Deny of a patient's record becomes "deny-override-available" when the subject holds an emergency access role for the resource type (PR-AUZ-001-4). It does not when the deny came from the session, segregation of duties, a service identity's use or a non-overridable deny rule.
Facility scoping is architecture 7.5's, in the evaluator:
- a resource type the content marks facilityOwned (encounters, registrations, and every facility-owned record a domain registers) is seen and changed only from its own facility;
- for its recordActions (actions on an existing record) the caller must send attributes.owningFacility;
- absent, the request is denied as a missing required attribute (PR-AUZ-001-3);
- another facility is denied, and not overridable;
- a create takes the request's facility, and a search is filtered by it (the search filter clause).
Enterprise-scoped data is not facility-owned: the person, and the longitudinal clinical record as a whole. Clinical access to it crosses facilities under a care relationship and purpose of use, with Break-the-Glass as everywhere else, so the clinical rules do not compare facilities. A clinical record view names the facility of its entry (attributes.owningFacility, the provenance 7.5 gives clinical entries); absent, it is denied. Within one facility no legal entity is needed. Across facilities both attributes.owningLegalEntity and attributes.requestLegalEntity are required: a missing one, or different ones, withholds the record until a legal basis is recorded (PR-AUZ-001-3). Neither rule is overridable.
Each decision stores the policy version and the evaluator's hash, so it can be explained, and repeated, against what made it (part 6.8).
3. Policy versions come from the configuration lifecycle.
- Content is authored, tested and approved in MOD-ESS-012 as the item types ess.authorization-policy (key enterprise-access) and ess.privacy-label-taxonomy.
- On ConfigurationChanged the unit reads the version through readConfigurationVersion. It checks the content hash against the event's, stores the version as approved, and applies it from its effective time.
- A decision uses the version in force at its own time. A job then makes the version Active, makes the one it replaces Superseded, and publishes PolicyUpdated in the same transaction.
- A rollback reactivates the version it names, which must already be held here. The withdrawn version becomes Rolled Back.
- A version number already stored with other content is refused, never overwritten.
- The policy version is the configuration version's integer as text, as ADR-HIS-048 says.
- The starter content is not an approved policy. enterprise-access.v1.json is what a security officer takes into the configuration lifecycle as the governed version 1, and a privacy officer or designated approver approves it (part 3).
- The unit installs it only where a deployment turns it on (his.authz.seed-enabled, off by default), and never in production, where the setting is ignored. That is for development and integration environments before the configuration service holds the policy.
- It is installed under a policy identifier of its own, enterprise-access-starter, so it never takes a version number of the governed policy. Its audit says it is the unapproved starter.
- It decides only while the governed policy has no version in force.
- Without it, and without a governed version, every decision is an outage (503): nothing unapproved ever decides in production.
4. What the unit decides before the rules (RC-1-S16's follow-up), from MOD-ESS-001's api. The results go to the rules as checks and appear in the trace:
- the session: the account state, sessions revoked after the token's issue, and the maximum lifetime;
- the roles in force at the request's facility, where privileged roles count only at aal2;
- for a service identity of another environment, or a display device, MOD-ESS-001's use check;
- the transaction-level segregation of duties on attributes.earlierActors.
A service identity acts only within its scopes. A rule's scope is the action code itself, unless the rule names another one or admits any active registered service (anyService, for reads every unit needs). A refusal of a service identity is recorded by MOD-ESS-001 as misuse. A subject the register does not know is denied.
5. Attribute delivery, per attribute (DEC-ESS-008).
- Held by the unit, never read from a token: roles, scopes, organizational unit, locations and state.
- Supplied by the caller in attributes, because no owning domain publishes them yet: care-team assignment (careTeam), the patient's unit (patientUnit), shift (shift), referral and specialties, and labels.
- Supplied by the enforcement point from the subject's token: the authentication assurance and the session. IF-ESS-003 has no field for them, and MOD-ESS-001 does not hold a session's acr. The kit's PolicyEnforcer sends attributes.subjectAssurance (the token's acr) and attributes.subjectSession (issuedAt, authTime, sessionId) when the subject is the token's. Absent, the assurance is aal1, so a privileged role does not count. This refuses more, never less.
6. The answer.
- A Deny is a 200 answer. An unregistered action or resource type is a Deny, logged and counted for the calling domain's support (part 10). A malformed request is a 400 with the field pointers.
- cacheLifetimeSeconds is the rule's cache seconds, bounded by CFG-ESS-009 (60 seconds), which is never more than CFG-ESS-025. It is 0 for a Deny and for a Permit that asks for a step-up.
- The search filter is one clause per permit rule that applied: the request's facility, and the rule's own filter conditions.
- Every decision is stored, immutable, in mod_ess_002.decision. Every Deny, and every Permit of a rule marked auditPermit, is audited as ess.auz.decision in the transaction that stores it. The subject is the actor and the calling service is the one acting for them.
- Only an active, registered service identity with the scope ess.policy-decision:decide in this environment asks for decisions (part 13). The unit's own modules ask in process, through LocalPolicyDecisionClient.
7. The kit's enforcement point, in this unit's copy (a template follow-up):
- it sends the field names of policy-decision.v1 (patientRef, encounterRef) and leaves absent fields out;
- it sends the session attributes of point 5;
- it offers an outage cache for Tier 1 clinical read paths (D10-ESS 8.6, DEC-ESS-018). A unit turns it on with his.policy.outage-cache and marks a check tier1ClinicalRead(). Then the cache keeps the Permit of the same subject, action, resource, patient, encounter, facility and purpose. While the decision point is unavailable, a Permit no older than CFG-ESS-025 is used, never for content whose accessLevel is restricted. Until FR-ESS-AUZ-003 brings the label model, restricted content is what the caller marks so. The use is audited as cached-decision-used. PolicyUpdated drops every cached Permit, IdentityChanged drops the subject's, and a Deny drops the one for its key.
Consequences¶
- A facility-owned resource type needs its owning facility. A domain that registers one marks it
facilityOwned, with itsrecordActions. Its enforcement point then sendsowningFacility, or the request is denied. - A production environment needs the governed policy before go-live. The configuration service must activate an approved version; until then every decision is 503.
- Every unit's actions need rules in the policy content. The starter version 1 covers the RC-1 units that exist (87 rules over 53 resource types), each rule with its source: the section 9.2 row or the requirement. An action without a rule is denied and counted.
- Caller service identities must be registered. Each calling unit needs a service identity in MOD-ESS-001 with the decision scope, in the unit's environment. In the end-to-end stack this is RC-1-S26's.
- Privileged roles at other units need the kit update. A privileged role counts only where the enforcement point sends the assurance. Units made from the template before this change must take the kit update (point 7), or their privileged users are denied.
- The deployment runs OPA as a sidecar of the unit's pod, from the pinned image, with no bundle and no persistence. The deployment topology unit owns the manifest.
- The test pack travels with the content.
enterprise-access.v1.test-pack.jsonis AC-03's test evidence. A later version brings its own pack through the configuration lifecycle. - Emergency sessions and consent are not evaluated yet. No emergency access session exists until FR-ESS-AUZ-002 is built, so a deny always prevails. Consent is not evaluated until MOD-ESS-003 is built, and the starter rules do not reference it.
Alternatives considered¶
- OPA embedded through WebAssembly. Set aside, as point 1 says.
- OPA bundles from an object store. Set aside: policy versions come from the configuration lifecycle, which already gives approval, effective time and rollback. The unit loads OPA itself and records which version decided.
- A Rego module per policy version. Set aside: a security officer would author code, and the test pack would test the engine as well as the policy. A fixed evaluator over data keeps authoring declarative and reviewable.
- Permissions from the role catalogue's permission sets. The sets hold
<Type>:<verb>, while units send finer action codes. The rules name roles, and may name a permission. Aligning the catalogue's sets with the policy is a follow-up for a role version.