Skip to content

Implementation plan / Session plan / Handover RC-1-S28-F27

Handover RC-1-S28-F27 Fix: The event backbone audits refusals during a decision outage under the unregistered type access-check-unavailable

Card: RC-1-S28-F27. Issue: cema-care/his#279. Branch: session/RC-1-S28-F27. Slice: RC-1. This is a round 2 fix of the gate session RC-1-S28-G2. The unit platform/event-backbone belongs to RC-1-S13.

No new decision record. The markers come from ADR-HIS-101. The event types come from the rulings on #220, #277 (option A) and #279.

The failure

The gate's evidence is in the first comment on #279. Run 20261201T000308Z-fa9c quarantined 4 events from ise-event-backbone under access-check-unavailable, "not in the audit event catalogue" (audit-quarantine.csv). The run's API calls show what was refused. Each event is a GET /v1/subscription-counts answered 503 during the decision point timeout: 1 in RC-1-E2E-010 and 3 in RC-1-E2E-014 (attachments/<case>/api-calls.json of the gate's scenario record).

The cause was in api/Access.java. It called the kit's PolicyEnforcer.require without a refusal audit of its own, so the kit's default applied: - an outage was audited as access-check-unavailable with outcome failure; - a Deny was audited as access-denied.

Neither type is registered.

D02-ISE 9.5 has no audit type for a read of the backbone's topics, counts, dead letters or replays. This session therefore stopped once, on the rule 3 question of #277. The ruling on #279 settled it: - refused changes: under the action's own type; - refused reads: under ise.gateway.denied.

What was changed and where

Only platform/event-backbone.

Kit (service-kit), as RC-1-S28-F22 and F23 did in their units: - AuditRecord has two new components, decisionUnavailable and recordNotCreated, with builder methods of the same names. - build() refuses a marker on any outcome other than denied. It also refuses decisionUnavailable next to a decision. In both cases the audit service would quarantine the event. - AuditEmitter writes each marker as true when it is set, and leaves it out otherwise. - PolicyEnforcer's default refusal audit now uses outcome denied. - A Deny names its decision. - An outage names no decision and carries decisionUnavailable. - It uses deniedEventType for both. - AuditProperties.unavailableEventType, the access-check-unavailable default, is removed. No module of this unit uses the kit's default refusal audit any more.

mod-ise-004 api/Access passes its own refusal audit for every policy check. The outcome is denied. An outage carries decisionUnavailable and no decision; a Deny names its decision.

Refused action Audit event
ise.replay.request (and the owning domain's confirmation checked with it) ise.message.replayed, action create, recordNotCreated (Access.requireCreation, permitsCreation)
ise.replay.authorize, ise.replay.confirm ise.message.replayed, action update, the replay with its current version, changedFields: ["none: refused"] (Access.requireChange)
ise.dead-letter.close ise.dead-letter.closed, action update, the dead letter with its current version, changedFields: ["none: refused"]
ise.event-topic.read, ise.subscription-counts.read, ise.dead-letter.read, ise.replay.read ise.gateway.denied (Authorization and emergency access), action = the policy action, the resource where one is named
  • Callers:
  • Replays.request and Replays.authorize call the creation and change forms;
  • DeadLetters.close calls the change form;
  • Replays.authorize and DeadLetters.close read the item's current version for this.
  • The policy action is kept in beforeAfter.policyAction for the two change types.
  • README: the unit's README.md states the rule.

Tests: - RefusalAuditTest is new. - The kit's HttpPolicyDecisionClientTest reads a Permit and a Deny through a client with a 5 s timeout. The outage cases keep their 300 ms client. This is RC-1-S28-F23's change to its own kit, made here because the test failed on this host. - AuditCategoryRules.intakeErrors is new. It applies the audit service's rule (SubmissionValidator.categoryErrors, with the waivers of audit.v1 1.2) to the two categories concerned.

PostgreSQL log broker (broker/PostgresLogBroker, after the review; the pipeline stopped twice on ConsumerIsolationTest): - The defect: on every poll, a consumer read each partition of each matching topic with a query of its own, also when nothing was new. The observer matches every domain topic and the gate every ingress topic, at 6 partitions each, so each empty poll cost hundreds of queries. - Its effect: on a loaded database one poll took seconds, and this showed in the measured propagation. Split by stage, it took about 4.5 s from the transaction to the gate's forward and about 2 s from the forward to the observer, at a load average of about 10 to 20. - The change: LogConsumer.fetch reads the end of every partition in one query (partition_head.next_offset). It then reads only the partitions that have records past the consumer's position. - Unchanged: order, positions, commits and the at-least-once behaviour. Production on Kafka doesn't use this class. - The test: ConsumerIsolationTest is unchanged, with its 1 s and 5 s targets.

Test databases (service-kit test fixtures, HisTestDatabase): the throwaway database of each test context is set to synchronous_commit = off. - Why: on this host a commit waited about 90 ms for the disk (PostgreSQL's statement log), and each event goes through several commits. - Unchanged: every commit stays visible and in order. Only a crash of the environment could lose the last commits. Production databases are not affected.

No contract file, dependency, lockfile, setting or migration changed.

Checks and their result

Light profile as HIS_SESSION=RC-1-S28-F27, in platform/event-backbone. The host's load average was about 50 throughout.

Check Result
RefusalAuditTest with main's src/main (kit and module), the tests of this change kept 4 of 4 fail, each on the gate's defect: expected "ise.message.replayed" but was "access-check-unavailable" (replay decision outage); "access-check-unavailable" for the counts read outage; "access-denied" for the refused replay request and the refused read
./gradlew :mod-ise-004:test --tests '*RefusalAuditTest*' --tests '*ReplayControlTest*' with the change 14 of 14 pass (RefusalAuditTest 4, ReplayControlTest 10)
./gradlew build --continue (the owning session's tests) 79 tests: 75 passed, 2 skipped, 3 failed, all timing tests that this change does not touch. app: 3 of 3 passed. mod-ise-004: 48 tests, 1 skipped (the Kafka test of the full profile), 1 failed: ConsumerIsolationTest, a commit of 1.88 s against its 1 s limit. service-kit: 28 tests, 1 skipped, 2 failed: HttpPolicyDecisionClientTest.permit and deny, whose 300 ms client read the answer as an outage. The load average was about 50
HttpPolicyDecisionClientTest, after giving its reading tests a 5 s client (as RC-1-S28-F23 did in its kit; the outage cases keep 300 ms) ./gradlew :service-kit:test: 28 tests, 0 failed, 1 skipped
ConsumerIsolationTest alone, with this change and then with main's src/main Fails both times, at a load average of 30 to 40: a p95 of 12.4 s against 5 s with the change; a commit of 1.22 s against 1 s on main. It is a latency target (FR-ISE-EVT-001 AC-02 to AC-04), so it was not loosened. This change touches neither publication nor delivery
The pull request's pipeline, first run (platform/event-backbone job, self-hosted runner on this host) Failed on ConsumerIsolationTest alone: propagation p95 5.846 s against 5 s. The other 47 tests of mod-ise-004 and every other job passed
The pipeline, second run, after a handover commit Failed again on ConsumerIsolationTest's p95, at a host load average of about 10. The cause was more than load
ConsumerIsolationTest alone, before the broker change p95 7.2 s at a load average of 24 to 36; 5.9 s at about 10 (fails). 4.0 s at 6 to 12 (passes)
ConsumerIsolationTest alone, with the broker change Passes, p95 2.55 s at a load average of about 31. Observer stage about 0.2 s instead of about 2 s
The pipeline, third run, with the broker change Failed on ConsumerIsolationTest's p95 (7.5 s), with the pipeline's scanners running on the same 4 cores
./gradlew build --continue, again, with the broker change and the test database setting Only ConsumerIsolationTest failed: p95 6.4 s at a load average of 20 to 40. Everything else passed
./gradlew build --continue with the broker change, earlier 79 tests: 0 failed, 2 skipped. app 3; mod-ise-004 48, 1 skipped (Kafka); service-kit 28, 1 skipped. ConsumerIsolationTest p95 3.6 s at a load average of 20 to 30
platform/delivery-pipeline/bin/secret-scan code origin/main HEAD no secret found
platform/delivery-pipeline/bin/static-analysis platform/event-backbone no blocking finding
python3 docs/implementation_plan/tools/check_links.py 0 broken

The slice scenario was not run end to end on this host. The next gate round, RC-1-S28-G3, runs it. The same host failed to start the full profile for RC-1-S28-F22 and RC-1-S28-G2 (Keycloak unhealthy under CPU steal).

This change affects only the audit events of refused requests. No answer changes: an outage is still 503 and a Deny is still 403. No scenario step asserts on these audit events except through the quarantine.

What the gate line now shows

The line is criterion 6 (ACC-005), IF-ESS-008 audit intake, and criterion 4, FR-ESS-AUD-001, "every action audited, nothing quarantined", of slice gate RC-1. Its check is the audit quarantine after the slice run.

Gate events Before (main) With this change Shown by
4 outage refusals of GET /v1/subscription-counts access-check-unavailable, outcome failure: quarantined as an unregistered type ise.gateway.denied, denied, decisionUnavailable, no decision. Registered (V2 of services/ess-audit), and the decision is waived for Authorization and emergency access. Stored RefusalAuditTest.outageRefusalOfARead, which fails on main
Not in the gate run: a Deny of a read access-denied: would be quarantined ise.gateway.denied with its decision. Stored denyOfARead
Not in the gate run: refused replay requests, replay decisions and dead-letter closures access-denied or access-check-unavailable: would be quarantined Under their own types, as in the table above. Stored refusedReplayRequest, outageRefusalOfAChange

RC-1-S28-G3's quarantine should hold no event from ise-event-backbone of these kinds. The line as a whole passes only when the other emitters' fixes of the round are merged as well: F24, F25, F26 and F28.

Requirements and test scenarios of the card

Tests are in platform/event-backbone/mod-ise-004/src/test/java/care/cema/his/ise/mod004/RefusalAuditTest.java, tagged FR-ESS-AUD-001, IF-ESS-008 and FR-ISE-EVT-002. Each test checks every event with AuditCategoryRules.intakeErrors.

Requirement Test
FR-ESS-AUD-001, IF-ESS-008 (gate criteria 4 and 6): an outage refusal of a read is audited under a registered type, denied with decisionUnavailable, and accepted at intake outageRefusalOfARead (counts, one topic, the topic list)
FR-ESS-AUD-001: a Deny of a read is audited with its decision denyOfARead
FR-ESS-AUD-001 with the ruling on #224; FR-ISE-EVT-002 behaviour 7: a refused replay request, by Deny and by outage, says recordNotCreated refusedReplayRequest
FR-ESS-AUD-001; FR-ISE-EVT-002; FR-ISE-INT-005: an outage refusal of a replay decision and of a dead-letter closure names the item and its version outageRefusalOfAChange
The owning session's behaviour, unchanged ReplayControlTest and the rest of ./gradlew build

Done differently from the specification or contract

Nothing. A refused read uses ise.gateway.denied although D02-ISE 9.5 describes that type as a denial "at the gateway". This follows the ruling on #279.

Questions and follow-ups

  • D02-ISE owner (follow-up, not blocking, from the ruling on #279): consider a dedicated D02-ISE 9.5 type for refusals by the platform's own operations APIs (for example ise.operation.denied, Authorization and emergency access). With such a type, Access.REFUSED_REQUEST would change to it.
  • Template (FN-S03): services/_template's kit still defaults to access-check-unavailable and access-denied and audits an outage as failure. Units made from it inherit the defect. This kit's change is the one to copy.
  • Kit default access-denied: it is unregistered, and this unit no longer uses it. Its own default stays for a module that sets a registered type.
  • ConsumerIsolationTest (RC-1-S13's test) on the shared runner host: needs a person.
  • Fixed here, two of its causes:
    • the PostgreSQL log broker's polls (above);
    • commits of about 90 ms in the throwaway test databases, now made without waiting for the disk flush (HisTestDatabase, synchronous_commit = off).
  • What remains is CPU. The host has 4 cores and ran at a load average of 20 to 50: other sessions' builds, and the pipeline's own scanners next to this job.
    • In PostgreSQL's statement log, a 36-row relay batch spent about 170 ms in the database out of 1.6 s. The rest was waiting for CPU in the JVM.
    • With identical code, ConsumerIsolationTest passed at a low load average (p95 0.7 s at about 2; 2.1 to 3.6 s at 20 to 30) and failed at a high one (p95 6.4 s at 20 to 40; a 1.28 s bedside commit at above 40).
  • The test's limits are FR-ISE-EVT-001 AC-02 and AC-03's own (commit under 1 s, p95 under 5 s), so a session doesn't loosen them. A person decides between:
    • more capacity for the runners, or a dedicated one (HIS_RUNS_ON can send jobs to hosted runners);
    • keeping the pipeline's scanners off the host while a unit's tests run;
    • a different form for this test, which would need the requirement's owner.
  • Broker positions (RC-1-S13): LogConsumer.fetch still keeps up to 200 records per poll in topic order. One very busy topic can delay the others within a poll, as before this change.