Implementation plan / Session plan / Handover RC-3-S04
Handover RC-3-S04 Build: Audit (slice RC-3)¶
Card: RC-3-S04. Issue: cema-care/his#60. Branch: session/RC-3-S04. Slice: RC-3. Decision record: ADR-HIS-086.
What was built and where¶
FR-ESS-AUD-003 in the unit services/ess-audit, module mod-ess-006. It extends what RC-1-S04 built: the 1.0 operations and their behaviour are unchanged. The unit now serves the 16 operations that audit.v1 1.1 adds (IF-ESS-008), and meets contract points 1 to 14 of RC-3-S04 in contracts/ess/CONTRACT-POINTS.md. Its README.md describes each function, the wire format, the minimum set, the retention rule's content, who may do what, and the settings.
| Part | Files (in mod-ess-006/src/main/java/care/cema/his/ess/mod006/) |
|---|---|
| Selection with each stored event (minimum set, rule classes) | ForwardingSelection; called from AuditStore in the store transaction |
| Sending: queue order, advisory lock per destination, send on commit, resend without receipt, outage and capacity alerts | ForwardingSender, SyslogTransport, TlsSyslogTransport, ForwardedRecordFormat, ForwardingProperties |
| Forwarding reads, receipts, error queue, resend | Forwarding |
| Reconciliation and the exception task | ForwardingReconciler |
| Rules from configuration, interfaces from the D02 registry, validation hook, item type registration | ForwardingRules, ItemTypeRegistrar |
| Review views and dashboard measures | ReviewViews |
| Evidence holds, second approvals | EvidenceHolds, SecondApprovals |
| Disposal, retention rule | Disposals, RetentionRule |
| HTTP | ForwardingReviewController; the parameter checks shared with AuditController moved to Params |
Clients of other units (ports/) |
ConfigurationReader, InterfaceRegistry, TaskService, Workforce, their Http* implementations, Downstream, ServiceTokens, ClientProperties, Unavailable, Refused |
| Migration | resources/db/mod_ess_006/V5__forwarding_holds_disposal.sql: the RC-3 records of D10-ESS 7.3 (forwarding destination, forwarding record, forwarding reconciliation, evidence hold, disposal run), the disposal tombstones disposed_event, used_signature, and the append-only guard of audit_event, which now lets through only a removal that a running disposal run has recorded |
Changed from RC-1-S04:
- AccessGuard lets three operations be decided for a service identity (receipts, rule validation, indicators), passes further policy attributes, records refusals of another category, and asks the policy about a second person.
- IntegrityVerifications reads disposal tombstones as links of the chain, and reports as missing any tombstone that its disposal run does not account for (ADR-HIS-086 point 5).
- AuditQueries gains condition (criteria as SQL, for holds) and pageOf.
- The build copies ForwardedAuditRecord.v1.schema.json from the contract into the jar, beside the intake schema.
No dependency added. The lockfiles are unchanged.
ADR-HIS-086 records nine decisions: the queue written with the event; "sent" and resend; reconciliation evaluated again until it matches; destinations as last read; disposal tombstones; the retention rule's content and what it keeps; second approvals; the three service-callable operations; the review views' selections. Its row in the decision record index brings the count to 88.
Checks and their result¶
The integration environment ran as HIS_SESSION=RC-3-S04 (his-rc-3-s04), light profile. The host has JDK 21 and Docker. The contract tests ran his-contract in the pinned node:22.18-bookworm image, because the host's Node.js cannot run it (as RC-3-S01 and RC-3-S03 noted).
| Check | Command | Result |
|---|---|---|
| Build and all tests | ./gradlew build in services/ess-audit |
see "Results" below |
| Provider contract test | AuditContractTest (tag contract): his-contract verify contracts/ess against the unit on a random port, for all 29 audit operations; validate-event on what it published |
verify passed: intake 9 cases (emitter token), 1.0 reads 22 (reviewer), receipts and rule validation 6 (service token), the other 14 new operations 32 (reviewer); validate-event passed, 27 events |
| Consumer contract test | ConsumerContractTest (tag contract): this unit's clients against his-contract serve of contracts/ess and contracts/ise |
passed: no violation recorded by either stub |
| Dependency scan and SBOM | platform/delivery-pipeline/bin/dependency-scan services/ess-audit |
0 blocking, 4 medium (as before) |
| Image scan and SBOM | platform/delivery-pipeline/bin/image-scan services/ess-audit |
0 blocking; 15 low, 117 medium |
| Static analysis | platform/delivery-pipeline/bin/static-analysis services/ess-audit |
no blocking finding; no clinical artifact |
| Secret scan | platform/delivery-pipeline/bin/secret-scan code origin/main HEAD, and docs |
no secret found. The first scan flagged a false positive: a seeded hold identifier written beside idempotency_key in the contract test, which the generic API key rule took for a key. It became a bound parameter, and the commit was amended before any push, so no commit of the branch has it |
| Protected files | platform/delivery-pipeline/bin/protected-files origin/main HEAD |
no exception added |
| Documentation links | python3 docs/implementation_plan/tools/check_links.py |
0 broken, 0 duplicate anchors |
| Documentation site | .venv/bin/mkdocs build |
builds (its warnings are of other files, as before) |
Results¶
./gradlew build in services/ess-audit passed, after origin/main was merged in: 89 tests, all passed.
- Module: 58 tests. 34 came before this session: the 32 of RC-1-S04 and 2 that RC-1-S26 added. 24 are new: 8 forwarding, 1 alerting objective, 8 holds and disposal, 5 review, 2 consumer contract. The provider contract test is among them.
- Kit: 28 tests (with RC-1-S26's addition).
- Unit: 3 tests.
- The merge took in RC-1-S26's migration V4__adm_person_search_registration.sql, so this session's migration is V5__forwarding_holds_disposal.sql.
- After review round 1, the hold and disposal tests (including the concurrency test) were run three times in a row, and passed each time.
How the "Ends when" lines are met:
- Every acceptance criterion of the listed requirements has a passing test: the table below.
- The listed test scenarios pass: TEST-ESS-024 has three parts: outage and recovery, forwarding reconciliation, and evidence hold.
- SecurityEventForwardingTest.outageAndRecovery: no gap after recovery, and the mismatch raised.
- EvidenceHoldAndDisposalTest.disposalRefused and scheduledDisposal: disposal refused under a hold.
- Each test class is tagged TEST-ESS-024.
- The contract tests pass: AuditContractTest and ConsumerContractTest, above.
- The change touches only the files of its deployable unit, plus its contract tests and migrations: everything is under services/ess-audit/. The rest is this handover, and ADR-HIS-086 with its index row (CLAUDE.md section 5). No contract changed.
Requirements and test scenarios¶
The tests are in services/ess-audit/mod-ess-006/src/test/java/care/cema/his/ess/mod006/. Each class is tagged FR-ESS-AUD-003, and each display name starts with the requirement and the criterion.
The forwarding tests send to SyslogTestServer, a real syslog collector over mutual TLS whose keys keytool makes when the tests start. The other units are fakes (ForwardingFakes), whose HTTP clients ConsumerContractTest checks against the stubs. TestClock moves time on for the alert delays and the reconciliation periods.
| Requirement, criterion | Test (class: method) | Scenario |
|---|---|---|
| AC-01 (a sensitive-data access event is stored and its receipt by security monitoring confirmed) | SecurityEventForwardingTest: forwardedAndConfirmed. A record access selected by a rule's category is stored, queued in the same transaction, and sent over TLS with the RFC 5424 header of the contract. The record conforms to the schema and carries the stored event as readAuditEventForwarding answers it. The receipt makes it acknowledged, and its period reconciles as matched |
TEST-ESS-024 |
| AC-02 (outage; on return all delivered, reconciliation shows no gap), PR-AUD-003-1, PR-AUD-003-2, part 10 | SecurityEventForwardingTest: outageAndRecovery. While the collector is down, the records stay pending and the destination is unavailable. The capacity alert is raised at the threshold, and the operational alert once after the delay, not before. The ended period is a mismatch and raises one exception task (type and queue checked; not repeated). On return the queue drains in recorded order, the receipts come in, and the period becomes matched with its task kept |
TEST-ESS-024 |
| AC-03 (emergency access forwarded within the alerting objective, NFR-ESS-006) | EmergencyAccessForwardingTest: emergencyAccessWithinObjective. In a context without jobs, so only the send on commit can deliver: 20 Break-the-Glass invocations reach the collector at p95 within 5 seconds of their event time |
TEST-ESS-024 |
| AC-04 (disposal of held events refused), PR-AUD-003-3, PR-AUD-002-3, FR-ESS-AUD-002 part 6.7 | EvidenceHoldAndDisposalTest: disposalRefused. Refused in each of these cases, with nothing disposed of:- denied by the policy (403, audited); - no second approval, or approval by the requester (400); - the second person denied by the policy (403); - held events (400, PR-AUD-003-3, naming the hold); - events within retention (400, PR-AUD-002-3); - no active retention rule (400); - configuration out (503). A permitted run disposes of only what it names and records the rule version. holdPlacedDuringDisposal: a disposal batch waits while a hold is being placed, then leaves the held events and counts them.forgedTombstonesReported: a tombstone written in another transaction opens no way past the guard; removals behind a tombstone of a run that never completed, or of a real run for an event within retention, are reported as missing.scheduledDisposal: the scheduled run disposes of what is past retention and not held; it keeps held events, recent events and patient-data audit, and counts the held ones. Verification of the range passes over the tombstones; a deletion outside a run and a change to a tombstone are refused |
TEST-ESS-024 |
| Part 6.2 (minimum set), part 7 (rule classes) | SecurityEventForwardingTest: minimumSetAndRuleClasses. A failed sign-on, Break-the-Glass and audit access go to every destination as minimum-set; an event type named by the rule as rule; a successful sign-on and an unnamed record change not at all; a failed sign-on is sent as a notice |
TEST-ESS-024 |
| Part 6.1, contract point 5 (receipts) | receiptsIdempotent: unknown before sending and for a stranger event, recorded once, then duplicate; a person is refused; a rejection without a reason is 400. sentAgainWithoutReceipt: resent with attempt 2 after the delay |
TEST-ESS-024 |
| Part 10, contract point 4 (error queue, resend) | errorQueueAndResend: a rejected event is failed with the reason and alerted, and listed in the error queue. Resend denied by the policy is 403 and audited ess.aud.admin denied. Permitted, it requeues, answers the original outcome for a repeated key, and sends again in order with attempt 2, audited |
TEST-ESS-024 |
| Parts 3, 4, 7, contract point 13 (rule validation, item type) | ruleValidation: the item type is registered at start with its hook and the security officer as approver; a good rule has no findings; an unknown category, an unregistered type and a suspended interface are findings; a malformed rule is 400 |
TEST-ESS-024 |
| Parts 6.1, 9 (the forwarded record) | forwardedRecordReadable: it conforms to the schema, the stated purpose is required, it is 404 for another destination, and the policy is asked with ess.AuditForwarding |
TEST-ESS-024 |
| Part 6.7, PR-AUD-003-4 (holds) | EvidenceHoldAndDisposalTest: securityOfficerHoldReleasedByPrivacyOfficer and privacyOfficerHoldReleasedByPlacer.- Placing: unbounded criteria refused; placed with ETag; the repeated key answered with the same hold; the policy asked with placedByRole; audited.- Release refused: by the wrong role or a non-placer; without a second person, by the releaser as second person, or dated in the future; with a reused signature; of a hold no longer active. - Release: a stale If-Match is 412; released with both names, audited with both; the same key answers again; a hold is never deleted. - releaseNeedsAPermittedSecondPerson: a second person the policy refuses is 403, the hold stays active, and the signature is not spent.- unverifiedStepUpRefused: with the unit's own verifier, which verifies none, a release is refused with PR-AUD-003-4 and the hold stays active, and an on-demand disposal is refused with FR-ESS-AUD-002 part 6.7; the unverified signature is not spent |
TEST-ESS-024 |
| Part 6.5 (review views), PR-AUD-002-2, PR-AUD-002-4 | ReviewViewsTest:- userAndPatientViews: rows and paging; audited with view, criteria and purpose; actor, patient, purpose and bounds required; unknown view 400.- selfReviewRefused.- outsideAssignment: no care relationship; facility outside the permitted locations; actor without an account; groups; paging; 503 when identity is out.- patternViews: emergency access by actor and patient, privileged activity, failed sign-on by account and by device, the facility filter |
|
| Part 6.6 (dashboard measures) | ReviewViewsTest: securityIndicators. Read by the Domain 8 feed's service identity. Counts enterprise-wide and per facility, and the recertification status (open, decided, overdue), with no actor or patient identifier. Audited; 503 when identity is out |
|
| IF-ESS-008 1.1 | contract/AuditContractTest: verifyAgainstContract |
|
| IF-ESS-012, IF-ESS-010, identity.v1, master-data.v1, IF-ISE-006 (NFR-ESS-011) | contract/ConsumerContractTest: forwardingClients, reviewClients |
The tests of RC-1-S04 (FR-ESS-AUD-001, FR-ESS-AUD-002, TEST-ESS-022, 023, 044) all still pass.
Non-functional targets, as designed for:
- NFR-ESS-007 (security). Mutual TLS to the destination, with the Domain 2 client certificate and host-name checks. Every operation is decided by the policy decision point. Receipts come over the service channel only. Forwarded content is the stored event, never more (part 13).
- NFR-ESS-011 (interoperability). The provider and consumer contract tests.
- NFR-ESS-015 (time integrity). UTC throughout; a second approval dated more than 5 seconds ahead is refused.
- NFR-ESS-016 (localization). No user-facing text beyond error messages; display is UI-ESS-008's (RC-3-S23).
- NFR-ESS-017 (observability). The kit's traces and logs with the correlation identifier, plus:
- the gauge his.audit.forwarding.queue_depth and the counter his.audit.forwarding.sent, by destination;
- the alert kinds forwarding-unavailable, forwarding-capacity, forwarding-rejected, forwarding-failed and forwarding-reconciliation on his.audit.alerts.
- NFR-ESS-006, alerting objective. AC-03 above. The end-to-end latency through the D02 pipeline and Wazuh is measured at RC-3-S24 (TEST-ESS-040).
Differences from the card or specification¶
- Patient-data audit is never disposed of by this unit yet. Retention for it runs from the patient's last visit (D10-ESS 7.6, 25 years), which the audit service does not know. An event that names a patient, or whose class has any trigger other than the event time, is treated as within retention (ADR-HIS-086 point 6). This keeps events longer than the minimum, never shorter.
- The retention rule's item type is not registered, because the specification names no approval authority for CFG-ESS-018 (question below). Until it is registered, no retention version can be active: the scheduled disposal does nothing, and an on-demand run is refused with PR-AUD-002-3. The content the unit applies is in its README.
- Evidence holds cannot be released yet, and no on-demand disposal can be approved (review round 2). Contract points 11 and 12 require the second person's signatureId to be a valid step-up of IF-ESS-002, which offers no way to verify one.
- The unit checks the signature through the port
StepUpVerifier. Its only implementation,UnverifiableStepUps, verifies none, so every second approval is refused as validation-failed with its rule (PR-AUD-003-4, FR-ESS-AUD-002 part 6.7). Until Q2 below is answered or IF-ESS-002 offers a verification, every hold stays active. - The unit also checks that the approver is a person and not the caller, that the approval is not dated in the future, and that a signature signs one approval only. The policy decides the second person (FR-ESS-IAM-002 part 3), for hold releases as for disposals (ADR-HIS-086 point 7).
- The tests and the provider contract test stand in a verifying IF-ESS-002 (
ForwardingFakes.FakeStepUps). - "Outside permitted location" uses the account as it is now. identity.v1 has no history of accounts, so contract point 9's "at event time" is met for the location's facility (master-data.v1
asOf) but not for the account's list of locations. An actor without an account counts as outside every assignment. - A period that does not reconcile is evaluated again until it matches, and an outage longer than the rule's delay is a mismatch, raising the exception task. Contract point 7 is read literally: pending while unacknowledged records are within the delay. AC-02 holds because the same period then reconciles as matched once the queue drains (ADR-HIS-086 point 3).
- Three operations accept a service identity, decided by the policy: receipts, rule validation and indicators (ADR-HIS-086 point 8). ADR-HIS-050 had service identities append only.
- The task type
ess.audit-forwarding-exceptionand the queueess.security-operationsare not registered. Both are configuration versions of the workflow service (ess.task-type,ess.work-queue), approved through the configuration lifecycle by people. Until they are, createTask may refuse the exception, and the unit keeps trying at each run with the mismatch recorded (follow-up below). - The validation finding
rule-key-mismatch(rule key other than the destination identifier, D10-ESS 7.3 "rule_key equals destination_id") is a value the contract's extensibleruleenum allows.
Questions for a person¶
None blocks this session; each is listed under "Needs a person" in the pull request.
- Q1, specification owner of D10-ESS (access behaviour): who approves versions of the audit retention rule (CFG-ESS-018, configuration item type
ess.audit-retention)? D10-ESS 7.6 says retention is governed by Domain 6 policy (HIM-002), and FR-ESS-AUD-002 part 6.7 applies retention "under approved policy". Neither names the role that approves a version. Once named, the unit registers the item type with that approval authority, and the content shape in its README. - Q2, specification owner of D10-ESS (access behaviour; review round 1): FR-ESS-IAM-002 part 14 has the second person authenticate by step-up on the requester's screen. IF-ESS-002 gives a receiving service no way to verify that step-up, so the audit service receives only its identifier. Is an unverified step-up identifier acceptable for the two-person release of an evidence hold (PR-AUD-003-4) and for an on-demand disposal, or must IF-ESS-002 provide a verification first? Until it is answered, the unit refuses every hold release and every on-demand disposal (validation-failed, with the rule), and holds stay active. A "yes" puts in place a verifier that accepts an unused identifier; a "no" waits for the IF-ESS-002 verification.
- Q1 and Q2 of RC-3-S01 stay open: who may resend refused events, and who may start or approve an on-demand disposal. The unit asks the policy for
ess.AuditForwarding resend, and foress.AuditDisposal startandapprove. It grants no role itself.
Follow-ups outside the card¶
- Policy content (RC-1-S16/S17 or the policy owner).
- Grant
ess.AuditForwarding receiptto the D02 pipeline's service identity (observability, RC-3-S09). - Grant
readto the security and privacy officers and auditors. - Grant
ess.SecurityIndicators readto the Domain 8 feed (anl-data-platform). - Grant
ess.EvidenceHold placeandreleaseby the role attributes. - Grant
ess.AuditReviewView run, with self-review refused where policy forbids it. - Keep
resend,startandapproveto no one until the questions are answered. - Workflow configuration (ess-coordination, or the configuration owner before go-live). Register the task type
ess.audit-forwarding-exception(owning domain ess, evidence free) and the queueess.security-operations(security officers), asess.task-typeandess.work-queueversions. - RC-3-S09 (platform/observability).
- Accept this unit's syslog on mutual TLS at the endpoint of interface
ise-siem-wazuh. - Call
submitForwardingReceiptsonce Wazuh has indexed each record. - Issue the unit's client certificate (FR-ISE-KEY-003), which goes into
his.audit-service.forwarding.key-storethrough OpenBao. - RC-3-S24 (integrate).
- Add
ess-audittoe2e/scenarios/RC-3/stack.json, with the settingshis.audit-service.clients.*pointing at the stack's configuration, workflow, identity, master-data and integration endpoints. - Measure NFR-ESS-006 through the D02 pipeline (TEST-ESS-040), and the queue under peak load (NFR-ESS-005, TEST-ESS-039).
- D06 or HIM. A source of the patient's last visit, so that patient-data audit can be disposed of 25 years after it (ADR-HIS-086 point 6).
- D10 identity. An account history, or an as-of read of an account, would let "outside permitted location" use the locations at event time.
- IF-ESS-002. A way to verify a step-up signature (when, by whom, at what assurance). With it, a verifier of the port
StepUpVerifierlets holds be released, and the configuration service could check its signatures, not only their reuse. - Archive tier (D02 storage).
archiveUnavailableis still always false (as RC-1-S04 noted). - Design system: none from this session.