Skip to content

Implementation plan / Session plan / Handover RC-1-S13

Handover RC-1-S13 Build: Platform: event backbone

Card: RC-1-S13. Issue: cema-care/his#27. Branch: session/RC-1-S13. Slice: RC-1. Decision record: ADR-HIS-063.

What was built and where

The unit platform/event-backbone, workload ise-event-backbone, made from the service template (services/_template/new-unit.sh --into platform/event-backbone ise-event-backbone MOD-ISE-004). It has one module, mod-ise-004 (package care.cema.his.ise.mod004, schema mod_ise_004). The pipeline builds it as a Java unit, because the folder has a settings.gradle.kts. Its README.md documents what it does, how a producer and a consumer use it, the policy actions, the settings, and how to build and test.

Part What Where (mod-ise-004/src/main/)
Topic register DE-ISE-009 for every topic of every contract: owner, classification, tier, retention, authorized consumers. Types and versions come from each domain's contract.yaml, copied into the jar. Applied at start; changes audited as ise.config.changed. Makes the broker topics: the topic, its .ingress, its .rejected, and the dead-letter topic of each authorized consumer catalogue/, resources/backbone/topic-register.yaml
Publication gate Reads every <topic>.ingress and checks the envelope, causation, registration of type and version, owner and source, scope, sequence, time and payload schema. Forwards valid events unchanged with the same key, or refuses them (recorded, returned on .rejected; a producer mismatch is audited as ise.service-identity.denied) gate/
Broker abstraction Broker with KafkaBroker and PostgresLogBroker; BrokerEventTransport (the kit's transport on either); BrokerMigration (retained records and consumer positions moved between brokers) broker/
Observer and monitor Domain event archive (2 years); propagation latency of the critical ADT, order and result topics; lag, oldest unconsumed age, retention-risk and unregistered-consumer alerts observe/
Dead letters Collected from every subscription's dead-letter topic into DE-ISE-010; InterfaceMessageDeadLettered published; list, read, close deadletter/
Replay From dead letters or from a retained position, into one subscription. Original records in original order per aggregate; items not valid against the contract are Held. The two decisions of BR-ISE-006 for replay-sensitive targets; EventReplayExecuted on completion replay/
Counts and API Reconciliation counts; the nine operations of event-operations.v1 with the policy decision point and Idempotency-Key counts/, api/
Migrations db/mod_ise_004/V1__event_backbone.sql; V2__replay_decision_by_two_people.sql (one decision per person on a replay)

This unit's copy of the kit (platform/event-backbone/service-kit/):

  • his.events.outbox.topic-suffix: the relay writes to <topic><suffix>. It is .ingress here, so the backbone's own events pass its gate.
  • DomainEventPublisher sets the causation of a root event to its correlation identifier (FR-ISE-EVT-002 behaviour 1 makes the causation mandatory).
  • InboxProcessor puts his-dlt-attempts and his-dlt-first-failed-at on a dead letter.
  • Taken from services/ess-audit's kit (RC-1-S04): the contract's audit payload, publishUnsequenced, PolicyEnforcer.require(check, RefusalAudit), and the pinned lz4-java 1.11.4 and snappy-java 1.1.10.9.

Dependencies added in mod-ise-004/build.gradle.kts, with every gradle.lockfile rewritten by ./gradlew dependencies --write-locks:

  • com.networknt:json-schema-validator 3.0.9, as in services/ess-audit;
  • kafka-clients, managed by Spring Boot (4.2.2), already in the kit;
  • snakeyaml, managed by Spring Boot (2.6).

Also:

  • scripts/ends-when.sh, this card's "Ends when" check on the full profile.
  • ADR-HIS-063 and its row in the decision record index (59 records).

Checks and their result

The integration environment ran as HIS_SESSION=RC-1-S13 (his-rc-1-s13). The host has JDK 21 and Docker, and no Node.js: the contract test runs his-contract in the pinned node:22.18-bookworm image, as services/ess-audit does.

Check Command Result
Build and all tests, light profile ./gradlew build in platform/event-backbone passed: 72 tests, none failed; 2 skipped, the Kafka tests (as in the pipeline)
Build and all tests, full profile (Kafka) HIS_SESSION=RC-1-S13 platform/event-backbone/scripts/ends-when.sh passed: 74 tests (module, kit, unit, contract), none skipped, none failed; the Kafka tests included
Contract test contract/EventOperationsContractTest (tag contract): his-contract verify contracts/ise for the nine operations against the unit on a random port, and his-contract validate-event on the InterfaceMessageDeadLettered and EventReplayExecuted events it published passed, in both runs above
Dependency scan and SBOM platform/delivery-pipeline/bin/dependency-scan platform/event-backbone 0 blocking, 4 medium; 535 components
Static analysis platform/delivery-pipeline/bin/static-analysis platform/event-backbone no blocking finding
Secret scan, protected files platform/delivery-pipeline/bin/secret-scan code origin/main HEAD and docs; bin/protected-files origin/main HEAD no secret found; no exception added
Documentation links and site python3 docs/implementation_plan/tools/check_links.py; .venv/bin/mkdocs build 0 broken, 0 duplicate anchors; the site builds

The pipeline builds the unit on the light profile. The Kafka tests are skipped there, as the kit's own Kafka test is: KafkaBackboneTest, KafkaEventTransportTest, and the Kafka pairs of BrokerReplacementTest. scripts/ends-when.sh runs them.

How the "Ends when" lines are met:

  • Every acceptance criterion has a passing test: the table below.
  • The listed test scenarios pass: TEST-ISE-018 (ConsumerIsolationTest), TEST-ISE-019 (BrokerReplacementTest), TEST-ISE-020 (PublicationGateTest, DeliveryGuaranteesTest, ReplayControlTest, KafkaBackboneTest), each tagged with its scenario.
  • The contract tests pass: EventOperationsContractTest.
  • Only the files of the unit, its tests and migrations: everything is under platform/event-backbone/. The rest is this handover and ADR-HIS-063 with its index row. No contract changed.
  • Safety-critical functions (D02-ISE 11.1):
  • Secondary consumer isolation, verified by failure injection: ConsumerIsolationTest, below.
  • Event ordering, verified by out-of-order tests: DeliveryGuaranteesTest.outOfOrder, PublicationGateTest.orderKept, and the order assertions of poisonDeadLetteredOthersContinueThenReplayed and BrokerReplacementTest.

Both controls are built as 11.1 states them; no existing control was changed, so no hazard log entry changes. The safety review of the card's "Safety" row is under "Needs a person" in the pull request.

Requirements and test scenarios

Tests are in platform/event-backbone/mod-ise-004/src/test/java/care/cema/his/ise/mod004/. Each class is tagged with its requirement and scenario, and each display name starts with them. All data is synthetic (SyntheticEvents).

Requirement, criterion Test (class: method) Scenario
FR-ISE-EVT-001 AC-01 (broker replaced; semantics unchanged; retained events kept) BrokerReplacementTest: replace. Kit producer and ordered consumer; part consumed; more published during the consumer's outage; migrate; the consumer resumes on the new broker and applies exactly the rest, in order; every record identical, same partition and order. PostgreSQL log to PostgreSQL log on the light profile; Kafka to PostgreSQL log and back on the full profile TEST-ISE-019
FR-ISE-EVT-001 AC-02 (billing, analytics and registry consumers fail; bedside transactions complete) ConsumerIsolationTest: secondaryConsumerFailureDoesNotBlockBedside. 30 encounter transactions through the kit's outbox while analytics is down, registry fails every event and billing is slow; each commits in under a second TEST-ISE-018
FR-ISE-EVT-001 AC-03 (p95 under 5 s) the same test: p95 of commit to consumer, measured by the backbone's observer. 442 to 748 ms over the runs TEST-ISE-018
FR-ISE-EVT-001 AC-04 (consumer back after an outage gets every event) the same test (analytics gets all 30 after its outage; the registry's dead letters are replayed to it); BrokerReplacementTest TEST-ISE-018
FR-ISE-EVT-001 behaviours 1, 2, 3, PR-EVT-001-2, PR-EVT-001-3 PublicationGateTest: throughTheOutbox, nonOwnerRefused; ConsumerIsolationTest
FR-ISE-EVT-001 behaviour 7, PR-EVT-001-1, section 10 (lag, retention alert) CountsAndMonitorTest: alerts; KafkaBackboneTest
FR-ISE-EVT-001 preconditions, section 11, section 12 (register, audit of topic changes) RegisterTest: registerMatchesContracts, provisioned, creationAuditedOnce
FR-ISE-EVT-002 AC-01 (replay, duplicate delivery, schema evolution) DeliveryGuaranteesTest: poisonDeadLetteredOthersContinueThenReplayed (replay), duplicate, schemaEvolution; ReplayControlTest TEST-ISE-020
FR-ISE-EVT-002 AC-02 (out of order, consumer outage: no misordered application, no loss) DeliveryGuaranteesTest: outOfOrder; ConsumerIsolationTest TEST-ISE-020, TEST-ISE-018
FR-ISE-EVT-002 AC-03 (no event identifier or schema version: rejected) PublicationGateTest: missingIdRejected, missingSchemaVersionRejected, eachMandatoryFieldRequired (10 fields); KafkaBackboneTest TEST-ISE-020
FR-ISE-EVT-002 AC-04 (poison event dead-lettered; other keys continue) DeliveryGuaranteesTest: poisonDeadLetteredOthersContinueThenReplayed TEST-ISE-020
FR-ISE-EVT-002 behaviours 2, 4, section 10, PR-EVT-002-1 PublicationGateTest: schemaInvalidRejected, unregisteredRejected, scopeAndTime, orderKept, nonOwnerRefused TEST-ISE-020
FR-ISE-EVT-002 behaviour 7, BR-ISE-006, CUX-64, section 12 ReplayControlTest: sensitiveNeedsBoth, twoDifferentPeople, twoDifferentPeopleConcurrently, rejectionRefuses, requestedByOwningDomain, owningDomainNeedsPolicy, idempotent, closure, policy, unreadableBody TEST-ISE-020
FR-ISE-EVT-002 behaviour 8 (counts) CountsAndMonitorTest: counts
IF-ISE-007, EVT-ISE-002, EVT-ISE-018 contract/EventOperationsContractTest: verifyAgainstContract

Non-functional targets, as designed for:

  • NFR-ISE-005 (security): every API call goes to the policy decision point and fails closed (an outage answers 503, not a refusal). Only the gate writes a domain topic, and a producer that does not match what the event claims is a security event. The claim itself is not authenticated until FR-ISE-KEY-003 (see differences). Payloads are given only by reference. The scans are clean.
  • NFR-ISE-009 (interoperability): the envelope and schemas are exactly the contracts' (copied by the build), and the contract test passes.
  • NFR-ISE-012 (observability): the metrics his.backbone.gate, .propagation (p95), .consumer.lag, .consumer.oldest-age, .alerts, .dead_lettered, .replays and .observer.ungated; the kit's traces and ECS logs, with the correlation identifier carried through gate and replay.
  • NFR-ISE-016 (time integrity): UTC throughout. The gate refuses a recorded-at earlier than the occurred-at, or later than its clock, beyond 1 second (CFG-ISE-020).
  • NFR-ISE-018 (localization): the backbone has no user-facing text beyond API error messages; display is the screens'.

Differences from the card or specification

  • The gate is in the path only for producers whose kit writes to the ingress. That is this unit, today. The template and the units made from it still publish to their topics directly. Their events are archived, counted and replayable, and they are counted as his.backbone.observer.ungated, but they are not validated or refused until the template adopts topic-suffix: .ingress and the causation rule (follow-up). "Publish only by the topic owner" is only partly enforced. The gate refuses an event whose envelope names another producer or source than the topic's owner. It cannot check "producer equals authenticated workload" (FR-ISE-EVT-002 sections 7 and 10), because workloads do not authenticate to the broker yet: no SASL or mTLS, and FR-ISE-KEY-003 is later. Until then, any workload that can write a topic's ingress can claim to be its owner, and the gate accepts it. Broker ACLs on authenticated workloads close this; EnvelopeValidator.check already takes the authenticated workload for when it exists.
  • The causation identifier is required at the gate (FR-ISE-EVT-002 behaviour 1), though the envelope schema of contracts/common leaves it optional. The specification decides. At the root of a chain the causation is the request, named by the correlation identifier. The audit intake channel is exempt: it carries submissions, not domain events. A replay checks items against the contract only, so an event published before the gate is not Held for lacking it.
  • "Known facility" is checked against his.event-backbone.facilities when it is set, and otherwise only for form. The backbone does not call the D10 facility register yet.
  • Consumer authorization from Domain 10 is the register's consumers list (DE-ISE-009 authorized_consumers), reviewed by pull request. A group that is not in the list raises an unregistered-consumer alert; broker ACLs come with workload authentication. Such a consumer also has no dead-letter topic in production.
  • Storage pressure (FR-ISE-EVT-001 section 10, "lower-tier topics throttled first") is not built. It needs broker disk metrics (MOD-ISE-008) and quotas (FR-ISE-PLT-003).
  • The two decisions of a replay-sensitive replay are given by two different people. A person who recorded one cannot record the other (403 unauthorized). This follows FR-ISE-INT-005 behaviour 7 (the owning domain's confirmation, and "a second Integration Operations Analyst") and CUX-64 ("two different named users"); the contract states only that the requester cannot be the second authorizer. Asked for in review round 1.
  • A replay goes to the topic, not only to the target subscription. The other subscriptions acknowledge it as a duplicate with no effect (BR-ISE-005); the records carry his-replay-target. Reasons are in ADR-HIS-063.
  • Delivered and acknowledged are read from the consumer group's committed offset (the kit commits after its inbox transaction) and from the dead letters. An event is acknowledged when it was delivered and was not dead-lettered, or when it was dead-lettered and then sent again by a replay whose copy was delivered.
  • Workload names of the other platform units in the register (ise-observability, ise-network-protection, ise-delivery-pipeline, ise-secrets-keys, ise-deployment-topology) follow this unit's convention ise-<folder>. Each unit's session confirms its own, or changes the register.
  • The PostgresLogBroker is the second implementation for the replacement exercise and for the light profile. It allows one active consumer per group and is not meant as the production broker.

Questions for a person

None that blocks this session. The card's approvals and reviews are under "Needs a person" in the pull request: ADR-HIS-063 (Enterprise Architecture Board), and the safety review of the two safety-critical functions this card implements a control for.

One planning question for the owner of the session plan, posted on issue #27: which card takes the service template's adoption of the gate (follow-ups, first item)? No card covers services/_template after FN-S03. Without that card, the gate validates this unit's own events only.

Follow-ups outside the card

  • Service template (services/_template), then each unit. No card of the plan covers the template after FN-S03, so no session can be named to take this. It is raised on the issue (#27) and under "Needs a person" in the pull request. Until a card takes it, FR-ISE-EVT-001 PR-EVT-001-2 and FR-ISE-EVT-002 AC-03 hold only for this unit's own events. The template's adoption covers:
  • set his.events.outbox.topic-suffix: .ingress, so producers publish through the gate;
  • set the causation of a root event (this unit's DomainEventPublisher.causation);
  • add the dead-letter headers his-dlt-attempts and his-dlt-first-failed-at (this unit's InboxProcessor);
  • read <topic>.rejected and flag the outbox item (PR-EVT-002-1);
  • optionally, drop a replayed record whose his-replay-target names another subscription.
  • Every consuming unit: add its consumer group to the topic's consumers in platform/event-backbone/mod-ise-004/src/main/resources/backbone/topic-register.yaml. ess-audit.audit-intake is there already.
  • D10 (RC-1-S16 policy, RC-1-S04 audit):
  • register the policy actions and resource types of this unit's README;
  • seed ise.message.replayed, ise.dead-letter.closed and ise.service-identity.denied in the audit catalogue. Until then the audit service quarantines them; nothing is lost.
  • Platform units RC-1-S10, S11, S14, S19, S20: confirm the workload name in the register; RC-1-S10 adds alert rules on his.backbone.alerts and the propagation SLO.
  • RC-1-S26 (integrate):
  • start ise-event-backbone on the full profile with replication-factor and tier1-min-in-sync 1;
  • measure the 5-second target with Kafka and the real units;
  • add the backbone to stack.json.
  • Workload identity (FR-ISE-KEY-003): broker ACLs, so that each workload writes only its own topics' ingress and reads only the topics it is authorized for.
  • The archive: partition event_archive by day if integration shows the need.
  • Design system: none from this session.

Review round 1

The review asked for three changes, all made on this branch:

  • Two different people for the two decisions of a replay into a replay-sensitive target. Replays.authorize now refuses, as 403 unauthorized, a person who already recorded the other decision. ReplayControlTest.twoDifferentPeople covers both orders. The grounds are in "Differences" above.
  • "Producer equals authenticated workload" is not checked yet. The handover, ADR-HIS-063 and the gate's documentation now say plainly that the gate checks only what the event claims. Until FR-ISE-KEY-003, any workload that can write an ingress can claim to be the topic's owner.
  • The template's adoption of the gate has no card. It is asked on issue #27 and listed under "Needs a person".

Review round 2

  • The two-people rule held only for calls one after the other. Two simultaneous calls by one person, one per role, could both pass the check, which read the decisions before the transaction. Replays.authorize now repeats both checks under the replay's row lock: the role is not yet decided, and the other decision is not the caller's. The migration V2__replay_decision_by_two_people.sql adds the unique key (replay_id, by_id) as the last guard; a violation is answered 403 unauthorized. ReplayControlTest.twoDifferentPeopleConcurrently sends both decisions at once, five times. Exactly one is recorded, the other is refused as unauthorized, and the replay stays Awaiting approval. The test also shows that the database refuses a second decision by the same person.