Implementation plan / Session plan / Handover RC-6-S01
Handover RC-6-S01 Contract: Contracts and stubs: D10 ESS (slice RC-6)¶
Card: RC-6-S01. Issue: cema-care/his#127. Branch: session/RC-6-S01. Slice: RC-6. Decision record: ADR-HIS-084.
What was built and where¶
The slice needs one D10 requirement, FR-ESS-AUZ-004: scoped, time-limited and revocable delegated authorization for staff-launched and patient-authorized applications (MOD-ESS-002). This session adds it to contracts/ess/ as compatible additions. Nothing of RC-1, RC-2 or RC-3 is removed or changed in meaning.
api/application-grants.v1.openapi.yaml, new (version 1.0). It is the grant part of IF-ESS-003 (part 9, "Grant register: API resource"), with 10 operations, all x-his-facility: enterprise:
| Part of FR-ESS-AUZ-004 | Operations | Caller |
|---|---|---|
| 6.1, 11: registrations, through the configuration lifecycle | listApplications, readApplication, validateApplicationRegistration (hook of item type ess.application-registration) |
identity provider, D07-PEX, UI-ESS-003 |
| 5 (third-party authorization request), 3 (patient or representative, recorded as a consent directive) | createAuthorizationRequest, readAuthorizationRequest, answerAuthorizationRequest |
identity provider; D07-PEX consent screen (FR-PEX-ACC-005 parts 6.1, 7) |
| 5 (application launch), 6.2, 6.3 | issueGrant (staff launch only) |
launching workspace or identity provider (SMART EHR launch) |
| 9: grant register | listGrants, readGrant |
D07-PEX connected applications (FR-PEX-ACC-005 part 6.2, AC-04), UI-ESS-003 |
| 6.5, AC-03 | revokeGrant |
D07-PEX "Stop access", launching user, security officer |
api/policy-decision.v1.openapi.yaml, 1.0 to 1.1. The decision request takes an optional grant {grantId, requiredScope} (part 6.4). The Domain 2 gateway sends it on every request of an application token. In the same answer it learns whether the grant is current and what may be returned (FR-ISE-GWY-003 parts 6.1 and 6.4). The description fixes the Deny cases of AC-01 to AC-04 and a cache ceiling of 5 seconds under a grant (NFR-ESS-003).
api/consent.v1.openapi.yaml, 1.0 to 1.1. Scope.applicationScopes (optional) lets a directive name the scopes of a recipient application (part 4). This is how a patient-authorized grant is "recorded as a consent directive" (part 3).
Also in this change:
- Section 7.3 additions in D10-ESS data, for approval by the domain leads, each attribute with its source:
- the sections application registration, application grant and authorization request, after DE-ESS-006;
- grant_ref and required_scope on DE-ESS-005;
- scope.application_scopes on DE-ESS-007.
- contract.yaml: the new API.
- README.md: the names ESS registers for RC-6 (policy resource types, configuration item type, consent type, stub applications), and the token claims of an application grant (grant_id, scope, patient, exp within the grant, DPoP cnf).
- TRACE.md: the trace of every new field.
- CONTRACT-POINTS.md: what RC-6-S04, RC-6-S02 with RC-6-S05, RC-6-S03, RC-6-S08 with RC-6-S15, and a later Domain 3 launch must meet.
- stubs/stub.json: regenerated.
- ADR-HIS-084 and its row in the decision record index (84 records). It records five decisions:
- the grant register is its own contract beside the decision API;
- the patient's approval is answered to an authorization request, and the directive is written in the same transaction as the grant;
- every request under a grant is a policy decision with the grant;
- revocation uses no new event, but a 5-second cache ceiling and the ConsentChanged of the withdrawn directive;
- the token carries the grant and is sender-constrained with DPoP.
No event was added or changed. D10-ESS section 8.5 names no grant event, and the event catalogue is untouched.
The failing scenario test named under "Leaves behind" and "Ends when" belongs, by the card's own scope, to "the last contract session of the slice", RC-6-S03, which joins the domains. This session writes nothing under e2e/scenarios/RC-6/, as RC-3-S01 did for its slice. The walk RC-6-S03 should test for scenario step 6 is in CONTRACT-POINTS.md.
Checks and their result¶
Run in contracts/ess, after pnpm install --frozen-lockfile in contracts/common and here:
| Check | Command | Result |
|---|---|---|
| Conventions | pnpm build (his-contract lint .) |
passed |
Compatibility with origin/main, stubs up to date |
pnpm test (his-contract check .) |
passed: policy-decision 1.0 → 1.1, consent 1.0 → 1.1, application-grants new |
| Stub against the provider contract test | scripts/verify-stub.sh |
passed, 557 cases (532 before, 25 new), no violation |
| Ends when | scripts/ends-when.sh with his-env env of the full profile exported, started as HIS_SESSION=RC-6-S01 (his-rc-6-s01) |
passed: check and stubs; verify against the stub, with a synthetic token and with a token of the realm his; the 11 ESS event schemas registered in Apicurio, unchanged on the second run |
| Documentation links | python3 docs/implementation_plan/tools/check_links.py |
0 broken, 0 duplicate anchors |
| Documentation site | mkdocs build |
builds |
| Secret scan | platform/delivery-pipeline/bin/secret-scan code origin/main and docs origin/main |
no secret. A first run flagged a false positive in the ADR (the generic-api-key rule matched an upper-case word followed by the backquoted contract name). The line was reworded and the unpushed commit amended, so no commit of the branch carries it |
| Static analysis | platform/delivery-pipeline/bin/static-analysis contracts/ess |
no blocking finding |
The host's Node.js 22.22 has no TypeScript type stripping, so the Node checks ran in the pinned image node:22.18-bookworm (pnpm 10.34.9 through corepack), with the worktree and its git directory mounted and --network host for the full-profile step, as RC-3-S01 did. The integration environment was reset afterwards.
node scripts/cross-references.ts in contracts/adm passes (460 references, at the second update from main). It failed earlier on main because of RC-3-S01's adm.person.merge example in audit.v1, which main has since corrected. It also caught a sentence of this contract's revokeGrant prose ("patient: the caller …") that its example check read as a person identifier. The sentence is reworded.
After the review round 1, 2 and 3 fixes (2026-11-27), lint, the compatibility check against origin/main, the stub regeneration, scripts/verify-stub.sh, check_links.py, mkdocs build and both secret scans were run again and pass. The fixes touch no event schema, so the registry step was not repeated.
How the "Ends when" lines are met:
- Contracts pass the compatibility check: pnpm test, step 1 of ends-when.sh.
- Every contract field traces to a requirement, a business rule or a section 7.3 attribute: contracts/ess/TRACE.md, section "Application grants", with the 7.3 additions above.
- Stubs run in the integration environment: step 3 of ends-when.sh.
- The scenario test runs and fails only because the behaviour is not built: RC-6-S03's, as above.
Requirements and test scenarios¶
A contract session covers requirements by contract.
| Requirement / scenario | Where the contract covers it | Who tests it |
|---|---|---|
| FR-ESS-AUZ-004 part 6.1 (registration) | listApplications, readApplication, validateApplicationRegistration; item type ess.application-registration |
RC-6-S04 (verify; validation findings) |
| Parts 6.2, 6.3, PR-AUZ-004-1 (issue, intersection, narrowing) | issueGrant, answerAuthorizationRequest; grantedScopes, withheldScopes |
RC-6-S04 |
| Part 6.4 (each request through the policy decision service) | policy-decision.v1 1.1 grant |
RC-6-S04; RC-6-S05 (gateway) |
| Part 6.5, PR-AUZ-004-2 (revocation, consent withdrawn or expired) | revokeGrant; revocation causes; the directive withdrawn only on the patient's or representative's own revocation |
RC-6-S04 |
| Part 6.6, part 12 (audit) | ess.auz.app-grant with patient reference; contract point 7 of RC-6-S04 |
RC-6-S04 |
| AC-01 other patient, AC-02 after expiry, AC-03 after revocation, AC-04 beyond the launching user | Deny cases of decide with grant (contract point 5 of RC-6-S04) |
RC-6-S04, tagged FR-ESS-AUZ-004 TEST-ESS-011 |
| TEST-ESS-011 | All four cases above | RC-6-S04; step 6 of the slice scenario by RC-6-S03 and RC-6-S17 |
Contract changes¶
All are additive within version 1, and his-contract check passes against origin/main:
- application-grants.v1 is new;
- policy-decision.v1 goes from 1.0 to 1.1, with one optional request field;
- consent.v1 goes from 1.0 to 1.1, with one optional field of Scope, in request and answer.
Consumers of 1.0 are unaffected. A provider of 1.0 keeps answering 1.0 requests as before.
Differences from the card or specification¶
- No scenario test, as above: the card's scope gives it to RC-6-S03.
- No grant event. Section 8.5 has none, and a contract session adds only section 7.3 attributes (session rule 3). Revocation reaches the gateway through the decision itself (a cache of at most 5 seconds under a grant, NFR-ESS-003). For a patient-authorized grant that the patient or representative revokes, it also goes through ConsentChanged of the withdrawn directive. ADR-HIS-084 point 4 gives the reasons.
- The consent type of a patient's grant is
external-sharing, the existing type of the Indonesia profile for "sharing with external parties", with the application as recipient. The consent model (CFG-ESS-010) has no type of its own for applications. The domain leads confirm this with the contracts. - A suspended or revoked portal link revokes the patient's grants (FR-PEX-ACC-005 PR-ACC-005-3, "revokes or suspends"). The D10 grant lifecycle has no Suspended state (part 11), so revocation is the only reading both specifications allow. It fails safe: a reinstated link does not bring the grants back, and the patient authorizes again. The domain leads confirm this reading with the contracts (under "Needs a person").
- Only the patient's or representative's own revocation withdraws the directive (review round 1). A revocation by the launching user, a security officer or the service revokes the grant and writes no directive version. FR-ESS-CNS-001 part 3 lets only the patient or representative through Domain 7, or a consent recording user, withdraw a directive. The revoked grant is denied whatever the directive says (PR-AUZ-004-3).
- Nothing is fixed for a representative whose access ends (review rounds 1 and 2). The first version revoked the grants they authorized, a behaviour the specification does not state. That behaviour and its cause value
representative-access-changedare removed.RevocationRecord.causeis markedx-his-extensible-enum, so a revoking answer is a compatible change. The question (Q-RC6-1) is on #127. Building no handler would itself decide that the grants stay active, so contract point 6 of RC-6-S04 no longer says "build no behaviour": RC-6-S04 takes the answer from #127, or stops on this point under rule 3 if it is still open. requestedByis bound to the caller (review round 2).revokeGrantno longer takesrequestedByon the caller's word:patientandrepresentativeare accepted only from the D07-PEX portal service identity (policy actionrevoke-for-patient), with a newactingForthat names the grant's patient and, for a representative, the D07-PEX representative grant;useronly from the grant's launching user (revoke-own-launch);security-officeronly for a subject permittedrevoke-any.
A patient-authorized grant accepts patient, representative and security-officer, and a staff-launch grant accepts user and security-officer. Any mismatch is 403, audited, with nothing changed (contract point 10 of RC-6-S04). So no caller can write a consent withdrawal the patient never made (FR-ESS-CNS-001 part 3).
- A representative's approval needs recorded authority, and an answer is bound to its patient (review round 3).
- answerAuthorizationRequest requires grantor.representative.representativeGrant and authority {basis, documentId}, recorded on the directive as consent.v1 records it (FR-ESS-CNS-001 parts 4, 6.4 and 10).
- A grant is issued only on an active directive (FR-ESS-AUZ-004 part 4; PR-CNS-001-4). So when the consent model would refuse the directive, or hold it as proposed, the answer is refused with 400 at /grantor/representative/authority and nothing is written. The specification settles this, so no question was raised.
- An answer for a patient other than the one createAuthorizationRequest named is 403, and the request stays pending.
- The README lists the three revoke actions of ess.ApplicationGrant, as the caller check uses them.
- Authorization requests are a record the specification does not name as an entity. FR-PEX-ACC-005 part 7 takes "Authorization request: from authorization service" as input and "Patient decision: approve / decline", and the request carries both. It is written into section 7.3 for approval.
- lastUsedAt on a grant comes from the "last used" [A] of the UI-PEX-011 brief. It is optional and set from the uses part 6.6 records anyway.
Needs a person¶
These items are listed in the pull request. None of them blocks the merge.
- Domain leads of the slice (D2 ISE, D7 PEX, D10 ESS): review of the contracts and of the section 7.3 additions (session plan section 4, end of each contract session).
- Enterprise Architecture Board: approval of ADR-HIS-084.
- Q-RC6-1, specification owner of D10-ESS with D07-PEX (asked on #127): when a representative's access to a patient is suspended or revoked (RepresentativeAccessChanged), what happens to the application grants that representative authorized for the patient, and to the consent directive each is recorded as? The contract settles neither. RC-6-S04 needs the answer: it takes it from #127, or stops on this point under session rule 3 (contract point 6). A revoking answer adds a cause to the extensible
RevocationRecord.cause, which is a compatible change. - Domain leads (D7 PEX, D10 ESS): confirm that a suspended portal link revokes, not suspends, the patient's application grants (PR-ACC-005-3 "revokes or suspends"; the D10 grant lifecycle has no Suspended state).
- Q-RC6-2, Security and Privacy Office: the policy maximum of a grant's lifetime (part 7, "Expiry: within policy maximum") has no value in the specification. Each registration carries its own
maximumGrantLifetime, and the validation hook keeps it within the policy maximum once that is set. RC-6-S04 needs a value for its tests only. The contract does not depend on it. - For the owners (follow-up, not blocking): confirm
external-sharingas the consent type of a patient-authorized application grant (CFG-ESS-010), and add rows for the application registration, application grant and authorization request to the D10-ESS section 7.2 catalogue.
Follow-ups outside the card¶
- RC-6-S03 (D07-PEX contracts):
- give PortalAccessChanged the fields of contract point "RC-6-S03" (and RepresentativeAccessChanged the representative grant identifier, so that an answer to Q-RC6-1 needs no PEX change);
- call the authorization request and grant operations;
- write the slice scenario, with step 6 walked as listed there.
- RC-6-S02 / RC-6-S05 (gateways): send
grantin every decision request of an application token, check the DPoP proof, and drop cached decisions on ConsentChanged (contract points). - Identity provider (Keycloak, MOD-ESS-001, in
services/ess-runtime-decision): the SMART grant tokens of the README section "Tokens of an application grant":grant_id, sender constraint,expwithin the grant, refresh refused once the grant is not active. RC-6-S04 is the unit's session in this slice. If its card does not cover the identity provider configuration, the work goes to the next identity session. - Domain 3 (a later slice): the launching workspace calls
issueGrantfor a staff launch (CDS-014). - Decision record numbering: ADR-HIS-083 (RC-3-S02) and ADR-HIS-085 (RC-3-S03) were merged to
mainwhile this pull request was open. This record stays ADR-HIS-084, which is still free onmainand in every open pull request and session branch (checked 2026-11-27, at the second update frommain), and the index counts 84 records. - Design system: none from this session.