Architecture / Decision records / ADR-HIS-086
ADR-HIS-086 Security-event forwarding in the audit unit: a queue written with the event, one sender per destination, reconciliation until it matches, disposal that leaves its place in the chain, and a retention rule that keeps what it cannot judge¶
| Status | Accepted |
| Decided | 2026-11-27 by session RC-3-S04 |
| Record | Drafted 2026-11-27; approved 2026-11-30 by the Enterprise Architecture Board |
| Where the rule lives | services/ess-audit/mod-ess-006: ForwardingSelection, ForwardingSender, TlsSyslogTransport, ForwardingReconciler, ForwardingRules, ItemTypeRegistrar, ReviewViews, EvidenceHolds, Disposals, RetentionRule, SecondApprovals; migration V5__forwarding_holds_disposal.sql; the unit's README.md |
Context¶
FR-ESS-AUD-003 asks the audit service to: - forward audit and security events to security monitoring; - confirm and reconcile their receipt; - offer review views and dashboard measures; - keep events under evidence hold from disposal.
ADR-HIS-082 fixed the contract (audit.v1 1.1): syslog over TLS carrying the stored event, receipts pushed back by Domain 2, forwarding rules as configuration items, and disposal refused as a whole under a hold. ADR-HIS-050 fixed the store: one intake path, a SHA-256 chain, and database triggers that refuse any change. Session RC-3-S04 builds FR-ESS-AUD-003 on that store. The card and the contract leave these questions of build open:
- How the queue stays durable and ordered, and how fast the minimum set leaves (AC-03: emergency access within 5 seconds).
- When a record counts as sent, and what happens to one that never gets a receipt.
- How a period reconciles when an outage spans it (AC-02 wants "no gap" once the destination returns).
- How the unit knows its destinations.
- How events can be disposed of from an append-only store whose chain verification reports any removal.
- What the retention rule (CFG-ESS-018) contains, and what the unit does with a retention trigger it cannot evaluate.
- How a second person's step-up signature is checked when IF-ESS-002 offers no operation to look one up.
- Which of the new operations a service identity may call.
- What some review views select.
Decision¶
- The queue is a table, written with the event.
AuditStorecreates the forwarding records (forwarding_record) in the transaction that stores the event. An event is never stored without its forwarding, and the queue survives a restart or a failover (NFR-ESS-008).- Each destination receives its records in
queue_sequenceorder. - One sender works on a destination at a time, on any instance, under a PostgreSQL advisory lock taken in the send transaction.
- Once a transaction that selected events commits, the sender is woken at once on its own thread (
send-on-commit). A job also runs every 2 seconds, and sends again what has no receipt. The minimum set is therefore never held back by a timer (contract point 8). - "Sent" means written, and a missing receipt means send again.
- A record is marked sent once its octet-counted frame is written to the TLS connection, and nothing of a failed write is marked.
- The connection is kept between sends and checked before it is reused. The collector never writes, so a read that ends the stream means the collector has closed the connection.
- A record sent and not acknowledged within the rule's
unavailableAlertDelayis sent again, with attempt + 1 and the same event identifier, on which the destination deduplicates. - An acknowledged record is final: a later receipt for it is a duplicate.
- Every record is checked against
ForwardedAuditRecord.v1(copied from the contract into the jar, like the intake schema) before it is sent. One that does not conform is failed with the reason and alerted, never sent. - A period is evaluated again until it matches.
- Periods are an hour of the events' recorded time. A period is evaluated once it has ended and the destination's delay has passed.
- It is matched when every selected event is acknowledged.
- It is pending while all its unacknowledged events were sent within the delay, so their receipts may still come.
- Otherwise it is a mismatch. An outage longer than the delay is a mismatch, because security monitoring has not received the events. It raises the exception task once (workflow.v1 createTask with the reconciliation identifier as Idempotency-Key, tried again while the workflow service is out).
- A period that has not matched is evaluated again at each run, so once the queue drains it becomes matched (AC-02), and it keeps the exception task it raised.
- The destinations come from configuration and the D02 registry, and stay as last read.
- Every minute the unit reads the active enterprise versions of
ess.audit-forwarding-rule(configuration.v1 listConfigurationVersions; X-Facility is the settinghis.audit-service.clients.facility, since that list is facility-owned and the rules are enterprise-scoped). - For each rule's interface it reads the endpoint and status from integration.v1 readInterface.
- A destination whose interface is not Active is not sent to; its records wait and the destination shows unavailable.
- When either service cannot be reached, the destinations stay as last read (D10-ESS 8.6).
- A destination whose rule is no longer active drains what was already selected for it, and is selected for no new event.
- The unit registers the item type
ess.audit-forwarding-rulewith its validation hook at start (contract point 13), under a fixed Idempotency-Key. - Disposal leaves the event's place in the chain.
- A disposal run writes each disposed event's chain, sequence and digests to
disposed_event, then deletes the event, both in one transaction. - The append-only guard of
audit_event(same trigger name, new function) lets a deletion through only when a running run has recorded that event, with the same chain position and digest, in the same transaction as the deletion. A tombstone written beforehand opens no way in. Updates and truncation stay refused, anddisposed_eventis itself written once. -
Integrity verification reads the tombstones as links of the chain: their digest links are checked and their content is not. A tombstone counts only when its run accounts for it:
- the run completed, with as many tombstones as it disposed of and its own
ess.aud.integrityaudit event (which the chain itself protects), or is still running and started within the hour; - the event named no patient, and was past retention under the rule version the run recorded;
- the event is within the run's criteria.
Any other tombstone is reported as
missing, like a removal outside a run (FR-ESS-AUD-002 part 6.2, AC-02). A forged tombstone therefore hides nothing. - Holds are matched in SQL by their criteria, the same conditions a search uses. - Placing a hold and a disposal batch share one advisory lock. A batch reads the active holds only after taking it, so a hold commits either before the batch reads the holds or after it has removed its events, never in between (PR-AUD-003-3). - An on-demand request is refused as a whole before anything is touched (contract point 12). A scheduled run skips held events and counts them. 6. The retention rule holds classes, and keeps what it cannot judge. - The content ofess.audit-retention(keyaudit-retention) is a list of classes:class,categories,eventTypes,retention(an ISO 8601 period) andtrigger. - An event belongs to the first class naming its type, otherwise to the first naming its category. - Only a class with triggereventmakes an event eligible, once its event time is older than the retention. - The audit service does not know a patient's last visit. So an event that names a patient (audit about patient data, D10-ESS 7.6), an event of a class with any other trigger, and an event of no class are always within retention. - Keeping an event longer than the minimum errs on the side the retention minimum sets. Disposing of it early would not be reversible. 7. A second approval counts only with a verified step-up, and none can be verified yet. The unit checks: - the approver is a person and not the caller; - the approval is not dated in the future beyond 5 seconds of clock skew (NFR-ESS-015); - itssignatureIdhas not signed another approval (used_signature); - itssignatureIdis a verified step-up of the approver (the portStepUpVerifier), as contract points 11 and 12 require ("a valid step-up of IF-ESS-002"). - the run completed, with as many tombstones as it disposed of and its own
The policy also decides the second person, who must hold the role the requirement names (FR-ESS-IAM-002 part 3): ess.AuditDisposal approve for a disposal, and ess.EvidenceHold release with attribute secondPerson for a hold release, each asked for that person. IF-ESS-002 is the identity provider's OpenID Connect flows and offers a receiving service no lookup of a step-up (FR-ESS-IAM-002 part 14). The unit's only verifier, UnverifiableStepUps, therefore verifies none. Every hold release and every on-demand disposal is refused as validation-failed with its rule (PR-AUD-003-4; FR-ESS-AUD-002 part 6.7), as the contract answers a missing second person. This holds until the specification owner answers whether an unverified step-up may serve these controls (RC-3-S04 handover Q2), or IF-ESS-002 offers a verification, behind which a verifier of that port is put. Contract points 4 and 12 already refuse resend and on-demand disposal in the same way, until an answer comes. A hold stays active meanwhile, which is the preserving side.
8. Three operations accept a service identity. The policy decides each, as for a person; none of them answers audit content:
- submitForwardingReceipts, for the D02 pipeline. A person is refused here, because receipts come over the service channel.
- validateForwardingRule, called by the configuration service as the item type's hook.
- readSecurityIndicators, read by the Domain 8 feed; counts only.
Every other read stays for persons with an audit-access role (ADR-HIS-050). 9. What some review views select. - access-by-user is every event of the actor. - access-outside-assignment is record access flagged "no care relationship recorded", or made for a facility to which none of the actor's permitted locations belongs: - the locations are read from the account as it is now (identity.v1 has no account history), and their facility from master-data.v1 at the event time; - an actor without an account has no permitted location, so the access is outside every assignment. - privileged-activity is events in a role whose privileged flag is set (identity.v1 listRoles), and audit access. - The groups are counts over the whole period, with no threshold. - A view that needs the identity or master-data service answers 503 while that service is out, never a partial result.
Consequences¶
- An event is never stored without its forwarding records, and a forwarded event can be traced from the audit store (readAuditEventForwarding) to the SIEM's receipt.
- During an outage the queue grows in the unit's database. The capacity alert at
queueDepthAlertThresholdis the operational guard. Throughput at peak is measured at integration (NFR-ESS-005, TEST-ESS-039). - The append-only guard has exactly one way through: a removal recorded by a running disposal run. A database owner can still bypass triggers, which verification detects (ADR-HIS-050).
- Until the retention rule's item type is registered with an approval authority (a question for a person), no retention version can be active. Until then the scheduled run does nothing, and an on-demand run is refused with PR-AUD-002-3.
- No evidence hold can be released, and no on-demand disposal approved, until a step-up can be verified or Q2 is answered. Holds stay active meanwhile, which preserves evidence and never loses any.
- Audit about patient data is never disposed of by this unit until a source of the patient's last visit exists. Disposal of it then needs a change of this decision.
- access-outside-assignment walks the period's record access in the unit. A long period over a busy store is slow, which bounded criteria limit.
Alternatives considered¶
- Publishing to the backbone and letting Domain 2 forward. ADR-HIS-082 chose syslog from the audit service, so that the audit service owns the receipt and the reconciliation.
- Marking a record sent only on a TCP-level acknowledgement, or opening a connection per send. Syslog over TLS has no application acknowledgement, and the receipts of IF-ISE-006 are the acknowledgement. A connection per batch costs a TLS handshake per event at the low rates of emergency access, for no gain in what is known.
- Deleting disposed events without a trace, and teaching verification to skip a date range. A skipped range would also hide a removal outside a run inside it.
- Treating unknown retention triggers as "event". That would dispose of patient-data audit 10 years after the event instead of 25 years after the last visit.