Implementation plan / Session plan / Handover RC-1-S28-F18
Handover RC-1-S28-F18 Fix: adm-patient-administration audits a refused creation as one, and names the patient of every existing record¶
Card: RC-1-S28-F18. Issue: cema-care/his#224. Branch: session/RC-1-S28-F18. Slice: RC-1. This is a round 1 fix of the gate session RC-1-S28. The unit belongs to RC-1-S09.
The failure and where it came from¶
The issue's first comment holds the gate's evidence. In audit-quarantine.csv, the audit service quarantined two kinds of adm-patient-administration event:
- 11 adm.person.view events, with /patientRef "required for a patient-scoped event type (FR-ESS-AUD-001 part 7, GAP-ESS-016)";
- 1 adm.person.change event, with /patientRef, /resourceRef and /beforeAfter/changedFields.
The code shows that none of the 12 concerns a patient who exists:
| Events | Source | Why there is no patient |
|---|---|---|
adm.person.view (11) |
warm_units of the stack's provisioning (e2e/scenarios/RC-1/provision/provision.py): GET /v1/encounters/{random id}, about ten rounds |
The encounter does not exist, so no facility owns it. The decision point denies the read (403), and Encounters.read audits the refusal (AC-06) with the encounter's identifier only. For an encounter that exists, the event already named the patient, refused or not |
adm.person.change (1) |
RC-1-E2E-004, "a registration at a facility where the clerk holds no role" | A refused registration of a new person. No person, registration or version exists |
So the unit had no real value to add to these events. The session asked on #224 how such events are to be audited. The answer is the ruling of the Security and Privacy Office with the Domain 10 and Domain 1 owners (#224, comment 7276976245), with #220's ruling on the same contract version:
The operative lines of the ruling on #224, quoted:
- Part 1 stands: no objection. D01 registers
adm.person.viewandadm.person.changeas not patient-scoped under GAP-ESS-016 point 2, with emitter tests that every event about an existing record still carries the patient.- Part 2: option A, together with #220's option A. An optional marker in audit.v1 1.1 (for example
recordNotCreated: true) says the refused action had no record. The audit service then waives version, changed fields and patient reference for that event only. Everything else is checked as now.
And of the ruling on #220 (its comment from the repository owner), as it bears on this marker:
- An outage refusal carries outcome
denied, together with that marker [decisionUnavailable], as D02-ISE 9.5 words it forise.gateway.denied.- The same contract change also carries #224's marker for a refused creation (its option A), so one audit.v1 1.1 covers both.
audit.v1 was already at 1.1 on main (RC-3-S01), so #253 makes the markers version 1.2. In short:
- D01 registers
adm.person.viewandadm.person.changeas not patient-scoped (GAP-ESS-016 point 2). Emitter tests check that every event about an existing record still names the patient (point 4). - A refused creation says so with an optional marker
recordNotCreated: true, which is new in audit.v1. For that event only, the audit service waives the record reference and version, the changed fields and the patient reference.
What was changed and where¶
The work is split with RC-1-S28-F14 (cema-care/his#253), which also changes the contract and the audit service for #220. To keep the two pull requests apart, the sessions agreed that #253 carries every change outside this unit:
- the recordNotCreated field in contracts/ess/schemas/AuditEventSubmission.v1.schema.json, with audit.v1 going to 1.2 (1.1 is RC-3-S01's). It is defined as { "const": true } and is allowed with outcome denied only;
- the waiver in services/ess-audit's SubmissionValidator. With the marker, a record-change event needs no resourceRef or version and no changed fields, and an event of any type needs no patientRef. A reference that is known is still sent and stored. With any other outcome, the marker is itself an error;
- the registration of point 1, as migration V8 of mod-ess-006, after F14's V6 and V7. The reasons are worded as on #224.
This branch changes only services/adm-patient-administration:
- Kit (
service-kit): AuditRecordhas a new componentrecordNotCreated, with a new builder methodrecordNotCreated();AuditEmitterwrites"recordNotCreated": truewhen the component is set, and leaves the field out otherwise (ADR-HIS-048).- Registration (
mod-adm-002AuditTrail.refusal): anadm.person.changewith no record identifier that the decision point denied is a refused creation, so it is sent with the marker. It names the patient only when the registration was for a person who already exists (selected). - Encounter (
mod-adm-004Encounters.refusal): anadm.encounter.changewith no encounter identifier (a creation) that the decision point denied is sent with the marker and names the requested patient. - A refusal during a decision point outage keeps outcome
failureand gets no marker, because the contract allows the marker withdeniedonly. Under #220's ruling, an outage refusal becomesdeniedwithdecisionUnavailable. That applies to every refusal site of the unit, so it is a follow-up (below). It is the same gate line and the same code, and F14's handover had found it as a follow-up (adm.encounter.change(1) in its run). - Refused reads keep their resource reference and name the patient whenever the record exists. That was already so; the new tests now check it.
- Review round 1, the pipeline: the unit's build failed on
mod-adm-009'sTransferTransitionTest(the transfer corrected by the supervisor). This change does not touch that test, and it passed locally. It asked the timeline atago(0), which is now truncated to the second. When the correction fell in the same second, that instant came beforecorrectedAt, so the test found the transfer's period instead of the corrected one. It now asks atInstant.now(). All 17 tests of mod-adm-009 pass.
The schema of audit intake is open, so the marker can be sent before #253 merges. The audit service ignores it until then. No contract file, dependency or lockfile changed here. No decision record: the rule comes from the ruling, and the code's own choice is local. That choice is that a refused change with no record identifier is a refusal of a creation, and it is written in AuditTrail's Javadoc.
Checks and their results¶
Light profile as HIS_SESSION=RC-1-S28-F18, in services/adm-patient-administration:
| Check | Result |
|---|---|
The new tests with main's mod-adm-002 and mod-adm-004 sources |
The two creation tests fail: [recordNotCreated] Expecting value to be true but was false. The two read tests pass, as the behaviour they pin was already right |
| The same tests after the fix | 4 of 4 pass; with the test of review round 2, 5 of 5 (mod-adm-002: 48 tests, 0 failures) |
./gradlew build --continue |
Successful: 216 tests, 0 failed, 1 skipped (the Kafka test of the full profile), contract tests included |
python3 docs/implementation_plan/tools/check_links.py |
0 broken |
The slice scenario on this pull request's code (review round 2). HIS_SESSION=RC-1-S28-F18 e2e/harness/scenario run e2e/scenarios/RC-1 --fresh --keep, full profile, after CI=true pnpm install --frozen-lockfile in contracts/common, ess, adm and ise:
- run 20261130T122822Z-3b59, on commit bd2fce39;
- its code is that of this head; the later commits add the test of a refused registration of a person who exists, and documentation.
| Result | |
|---|---|
| Cases | 4 of 15 pass (003, 005, 002 and 012). The gate's own run passed 11 of 12 |
| The 11 failures | Each one is a 503 "Authorization service unavailable" from the decision point, or what follows from one: no answer for the audit search (001, 008), the stewardship task list (007), a screen that never showed its result (006), a timeout while the decision service was restarting (004), and stackReady's registration path in 010, 011 and 013. RC-1-E2E-014 and 015 also fail this way, before reaching ess-governance's own audit gap (RC-1-S28-F12). The provisioning got 503s too. The host has 4 cores and was shared with the CI runners and other sessions' runs; its load average was 70 to 99 during the run. No failing step asserts on audit content, and nothing this change touches answers or refuses a request differently. RC-1-S28-F14's run 20261130T121316Z-f057, on #253's code without this change, failed the same way (8 of 15) |
Its audit quarantine (mod_ess_006.quarantine_entry in ess_audit after the run, the gate's query), for adm-patient-administration, with ess-audit as on main (no V8 and no waiver yet):
| Type | Outcome | Marker | Count | Why |
|---|---|---|---|---|
adm.person.view |
denied | no | 54 | The warm-up reads of encounters that do not exist (the gate's 11). The type is still patient-scoped on main |
adm.person.change |
denied | recordNotCreated |
1 | RC-1-E2E-004's refused registration of a new person. The marker is sent; main's intake ignores it |
adm.person.view 6, adm.person.change 6, adm.encounter.change 4 |
failure | no | 16 | Refusals during the decision point's outages: no decision. These clear when the unit sends #220's decisionUnavailable (follow-up) |
A combined run with #253 was attempted and did not run. The checkout was this branch with origin/session/RC-1-S28-F14 merged (1610d631, then e00003af), which also brings in newer main. There were six attempts between 13:16 and 15:22 UTC:
- four stopped in his-env start full, because Keycloak was not healthy within its window: runs 20261130T131629Z-1554, …132429Z-ef4d, …133145Z-7797 and …133906Z-d6a9, plus one more in the main worktree;
- two got the units up, but the provisioning stopped at POST /v1/identity-source-events, which ess-runtime-decision answered "The registry service is unavailable" (runs 20261130T135917Z-e002 and …145152Z-ee0b);
- one more start failed on an unhealthy Kafka.
The load average stayed between 20 and 40. No scenario case ran on the combined code. The gate line is therefore shown by merge order, below.
What the gate line now shows¶
The line is criterion 6 (ACC-005), IF-ESS-008, and criterion 4, FR-ESS-AUD-001, of slice gate RC-1. Its check is the audit quarantine after the slice run. For the gate's 12 events:
| Merged | The 11 refused reads (adm.person.view, denied) |
The refused registration of a new person (adm.person.change, denied) |
Shown by |
|---|---|---|---|
| Neither (main) | quarantined, /patientRef |
quarantined: /patientRef, /resourceRef, /beforeAfter/changedFields |
the gate run |
| #267 only | quarantined, as on main | quarantined, as on main (the marker is ignored) | run 20261130T122822Z-3b59 above: 54 and 1 |
| #253 only | stored | quarantined, as on main | RC-1-S28-F14's run 20261130T121316Z-f057: "None quarantined. 58 stored" and "1 (denied: no record, changed fields)" |
| Both | stored | stored | not run end to end (above). Evidence for both columns follows this table |
The evidence for the "Both" row:
- The refused reads: they do not depend on this pull request. #253's V8 alone stores them, as its run shows.
- The refused registration: this unit's test RefusalAuditTest.refusedRegistrationOfNewPerson shows the event the unit sends: action create, outcome denied, recordNotCreated: true, the decision, and no patient, record or changed fields. That is the case #253's AuditIntakeTest.refusedCreationWithoutRecord shows stored, "a refused creation with recordNotCreated and no patient, record or changed fields is stored (adm.person.change)", with action create as #253 requires.
The next gate round, RC-1-S28-G2, should therefore find none of the gate's 12 in the quarantine. It will still find this unit's outage refusals (outcome failure), as many as that run's outages produce, until the follow-up for #220's marker is done.
Requirements and test scenarios of the card¶
| Requirement | Test |
|---|---|
| FR-ESS-AUD-001 AC-06 with D10-ESS 9.5 and the ruling on #224: a refused creation is audited as one, and is accepted at intake | RefusalAuditTest.refusedRegistrationOfNewPerson (mod-adm-002; it also checks that the outage refusal gets no marker); RefusalAuditTest.refusedRegistrationOfExistingPerson (the marker and the known patient together, GAP-ESS-016 point 4); EncounterRefusalAuditTest.refusedCreation (mod-adm-004) |
| GAP-ESS-016 point 4: every event about an existing record names its patient | RefusalAuditTest.existingRecordNamesPatient; EncounterRefusalAuditTest.refusedReads (also the gate's case: a refused read of an encounter that does not exist) |
| IF-ESS-008 audit intake (gate criterion 6, ACC-005) | Each test checks every event against AuditIntakeRules (mod-adm-002 test fixtures). That is the audit service's rule for these types, as the ruling settles it. Tags FR-ESS-AUD-001, IF-ESS-008, with FR-ADM-REG-001 or FR-ADM-ENC-001 |
Done differently from the specification or contract¶
The specification: nothing. The marker and the registration are the ruling on #224.
The contract (session rule 4). Until #253 merges, this unit sends recordNotCreated, a field that audit.v1 1.1 on main does not define. That is acceptable only because the intake schema is open. AuditEventSubmission.v1.schema.json says: "The object is open: an emitter may send a field this version does not name, and the service ignores it." No consumer is broken:
- the audit service ignores the field, and such an event is quarantined exactly as before;
- a validator of the same schema, such as the ESS stub's, accepts it, because the schema does not forbid other fields.
The field is defined in audit.v1 1.2 by #253 ({ "const": true }, with outcome denied only), a backward compatible minor version checked by his-contract check there. This branch changes no contract file.
Questions and follow-ups¶
- Merge order: #253 should merge for the fix to take effect. The two pull requests touch different folders and can merge in either order.
- Outage refusals in this unit (#220's ruling): every refusal site of the unit sends outcome
failurewith no decision when the decision point is down. Under #220's ruling, these becomedeniedwithdecisionUnavailable: true(audit.v1 1.2), and a refused creation then also carriesrecordNotCreated. That is the emitter half of #220, across every module. Until then, those events are quarantined. The gate's run had none from this unit. - adm-identity sends the same kind of refused
adm.person.change(2 in F14's run). It needs the same marker in its ownAuditTrail.refusal, in a fix of its own. - Other refused creations in this unit are outside the gate's run and were not changed: bed reservations (
adm.bed.change), transfers (adm.adt.change), consent and payer references, and the delivery tracker. Each should sendrecordNotCreatedwhen it refuses a creation. A later session on the unit can use the same rule and theAuditIntakeRulesfixture. - Template (
services/_template, FN-S03): the kit'sAuditRecordandAuditEmitterthere should getrecordNotCreatedtoo, once audit.v1 1.2 is on main. - D10-ESS 7.3: DE-ESS-013 has no attribute for the marker yet. Writing it is a 7.3 addition for the ESS contract session and the Domain 10 lead (#253 adds the field).