Skip to content

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

Handover RC-1-S15 Build: Coordination services

Card: RC-1-S15. Issue: cema-care/his#29. Branch: session/RC-1-S15. Slice: RC-1. Decision record: ADR-HIS-058.

What was built and where

The unit services/ess-coordination, made from the service template with new-unit.sh ess-coordination MOD-ESS-007 MOD-ESS-008 MOD-ESS-009. mod-ess-007 (notifications, RC-2) and mod-ess-009 (documents) are the template's empty modules. The unit's services/ess-coordination/README.md lists its packages, the definition form and its settings.

MOD-ESS-008 in mod-ess-008 serves all 23 operations of workflow.v1 (IF-ESS-010). It publishes TaskStateChanged (EVT-ESS-010) on his.ess.task.v1 and WorkflowInstanceStateChanged (EVT-ESS-014) on his.ess.workflowinstance.v1, through the outbox, with an enterprise envelope and the facility in the payload.

  • Workflow definitions and durable execution (FR-ESS-WFL-001):
  • versioned definitions, installed from ConfigurationChanged (item type ess.workflow-definition, content read through IF-ESS-012); an instance is bound to the version active at start (BR-ESS-027);
  • a start with the same business key, or the same Idempotency-Key, answers the existing instance;
  • steps of kind api (a command to the owning domain), task, timer or signal, run one after the other;
  • state is persisted before each dispatch, with a lease. Every attempt carries the same idempotency key, so a restart repeats no completed step and a repeated command has one effect;
  • bounded retries with backoff. An unavailable target spends no attempt, and its circuit holds the domain's steps back;
  • compensation of the completed steps in reverse order, Compensated or Failed with compensation-incomplete;
  • no blind replay (part 6.11): a replay-sensitive step whose outcome is unknown is not sent again. The list (CFG-ISE-007: medication, billing, identity) fails closed: by default every step into Domains 1, 3 and 5 and Domain 10's identity operations. A definition can add a step to the list, never take one off. The instance is Failed with reconciliation-required until the owning domain's step-result signal. A manual retry needs the domain's replayPermitted and a second person whom the policy decision point permits;
  • the recovery worklist of UI-ESS-009: state=failed, stuck=true, retry with a reason, skip under procedure (an ess.workflow-step-skip-approval task to the queue supervisor, approved or refused by completing it), and compensation.
  • Tasks and work queues (FR-ESS-WFL-002):
  • tasks of registered types, created by the owning domain's service, with an owner at all times (BR-ESS-026). The facility of a facility-scoped queue is required and immutable;
  • claim and start (Assigned to In Progress), release, completion checked against the type's evidence schema and outcomes. Where the owning domain confirms, a person's completion is recorded and the task stays open until the domain completes it (part 6.10);
  • cancellation by the owning domain, and reassignment and recovery with a reason, audited with actor, reason, previous and new assignee;
  • Overdue at the due time, and Escalated through the notification port where the type names an escalation policy;
  • IdentityChanged: a suspended or deactivated account, or a revoked role assignment, returns its tasks to their queue with the flag returned-to-queue;
  • queue measures (open, overdue, oldest open, eligible active users, median completion time), and stuck queues, tasks and instances (CFG-ESS-015), alerted once per episode;
  • the pathway conflict review rule of part 6.11 (PathwayConflicts).
  • Registrations at start (workflow/registrations.json, only what is missing):
  • task types ess.workflow-step-skip-approval, ess.configuration-approval, ess.emergency-change-review and ess.decision-record-review (RC-1-S05's follow-up);
  • adm.duplicate-review and queue adm.identity-stewardship (RC-1-S03's follow-up, scenario step 6);
  • ebp.pathway-conflict-review.
  • Cross-cutting duties:
  • the policy decision before every action, for the record's facility (architecture 7.5), with lists filtered by it;
  • audit ess.wfl.definition, ess.wfl.instance and ess.wfl.task (D10-ESS 9.5) in the action's transaction;
  • Idempotency-Key replay, and ETag with If-Match;
  • correlation (the instance's correlation identifier on every step) and telemetry from the kit.
  • Migration V1__workflow_and_tasks.sql. A trigger keeps a task's facility unchanged.

Unit-wide, beside the module: - the unit's kit takes RC-1-S05's HisException errors and status override, the missing query parameter as validation-failed, and PolicyEnforcer.requireFor; - json-schema-validator 3.0.9 (networknt, Apache-2.0) in gradle/libs.versions.toml and mod-ess-008, for completion evidence; - the lz4-java and snappy-java constraints of RC-1-S05 in buildSrc; - every lockfile written with ./gradlew dependencies --write-locks.

ADR-HIS-058 and its row in the decision record index (57 records). ADR-HIS-057 is taken by the open pull request of RC-1-S09, so this record is 058.

Checks and their result

The integration environment ran as HIS_SESSION=RC-1-S15 (his-rc-1-s15), light profile.

Check Command Result
Build and every test of the unit ./gradlew build in services/ess-coordination passed: 92 tests (MOD-ESS-008 60, kit 27, app 3, MOD-ESS-007 1, MOD-ESS-009 1)
Provider contract test ./gradlew :mod-ess-008:test --tests '*WorkflowContractTest' passed: all 23 operations of workflow.v1 pass his-contract verify contracts/ess, 58 cases. The 22 published TaskStateChanged and WorkflowInstanceStateChanged events pass his-contract validate-event
Dependency scan and SBOM platform/delivery-pipeline/bin/dependency-scan services/ess-coordination 0 blocking (6 medium)
Image scan platform/delivery-pipeline/bin/image-scan services/ess-coordination 0 blocking (15 low, 38 medium)
Static analysis platform/delivery-pipeline/bin/static-analysis services/ess-coordination no blocking finding
Secret scan platform/delivery-pipeline/bin/secret-scan code origin/main HEAD and docs no secret; no exception file added
Documentation check_links.py; mkdocs build 0 broken links; site builds

All operations of workflow.v1 are enterprise-scoped (x-his-facility: enterprise), so verify has no facility cases. The facility rules are covered by TaskCoordinationTest.facilityScoping.

Requirements and test scenarios

Every test carries @Tag with its requirement and scenario, and its display name starts with them. Tests are in services/ess-coordination/mod-ess-008/src/test/java/care/cema/his/ess/mod008/.

Requirement, criterion Test
FR-ESS-WFL-001 AC-01 restart resumes without repeating completed steps WorkflowExecutionTest.resumesAfterRestart
FR-ESS-WFL-001 AC-02 a step delivered twice has one business effect; PR-WFL-001-5 WorkflowExecutionTest.duplicateDeliveryOneEffect; resumesAfterRestart; ReplaySafetyTest.ordinaryStepResumes
FR-ESS-WFL-001 AC-03 beyond the retry limit, on the recovery worklist with the reason; PR-WFL-001-2 WorkflowExecutionTest.recoveryWorklist
FR-ESS-WFL-001 AC-04 compensation in reverse order, Compensated WorkflowExecutionTest.compensation; part 10 compensationIncomplete
FR-ESS-WFL-001 AC-05 running instances complete under their version; PR-WFL-001-3 WorkflowExecutionTest.newVersionDuringRun; RegistryTest.definitionFromConfiguration
FR-ESS-WFL-001 PR-WFL-001-1, -4; parts 3, 6.6, 6.9, 10, 12 duplicateStart; circuitOpen; timersAndContext; startRefusals; manualRetryAndCancel; skipUnderProcedure; RegistryTest.invalidDefinitionRefused
FR-ESS-WFL-001 part 6.11 no blind replay into medication, billing or identity ReplaySafetyTest (all seven; identityWritesFailClosed with Domain 1's real identity operations; definitionCannotExemptListedStep; definitionAddsStep)
FR-ESS-WFL-002 AC-01 suspended assignee: back to the queue, flagged; PR-WFL-002-1 TaskCoordinationTest.suspendedAssignee; revokedRole
FR-ESS-WFL-002 AC-02 overdue with escalation: supervisor notified, shows as Overdue; PR-WFL-002-2 TaskCoordinationTest.overdueEscalated
FR-ESS-WFL-002 AC-03 queue without eligible active users raises an alert; PR-WFL-002-3 TaskCoordinationTest.stuckQueue; part 6.6 stuckTask
FR-ESS-WFL-002 AC-04 stewardship queue report: assigned, resolved, measured by age TaskCoordinationTest.stewardshipReport
FR-ESS-WFL-002 AC-05 reassignment audited with actor, reason, previous and new assignee TaskCoordinationTest.reassignmentAudited
FR-ESS-WFL-002 AC-06 PathwayConflictDetected twice: one task to the attending practitioner, else the unit supervisor on duty; PR-WFL-002-5 TaskCoordinationTest.pathwayConflict
FR-ESS-WFL-002 PR-WFL-002-4; parts 4, 6.1, 6.10, 10, 13; architecture 7.5 createAndClaimRules; completionRules; facilityScoping; lifecycle; taskStepOfWorkflow; RegistryTest.taskTypesAndQueues
IF-ESS-010, EVT-ESS-010, EVT-ESS-014 contract/WorkflowContractTest

Scenarios: - TEST-ESS-028 (restart mid-instance; duplicate step delivery; permanent failure with compensation; new version during run) is WorkflowExecutionTest. - TEST-ESS-029 (assignee suspended; overdue task; queue without eligible users; manual reassignment) is TaskCoordinationTest. - TEST-ESS-043 (recovery after outage with a medication or billing step pending) is ReplaySafetyTest.

All pass.

Done differently from the specification or contract, and why

  • PathwayConflictDetected is not subscribed yet (AC-06). The rule is built and tested as PathwayConflicts.received. Domain 9 has no event contract for EVT-EBP-021 (its contracts come with slice PA), so there is no topic or schema to subscribe to.
  • IF-ESS-001 version 1 also cannot find the account of a practitioner, and IdentityChanged does not carry the practitioner link. The default PractitionerAccounts resolves none, so until a lookup exists every review goes to the unit supervisor on duty (CFG-EBP-015).
  • That is the specification's own fallback, and nobody is left without the task, but the attending practitioner is not reached. Question Q2.
  • Escalation and stuck alerts are recorded, not sent. The notification service (MOD-ESS-007, IF-ESS-009) is delivered in RC-2, as the slice notes. Requests go through the module's notification port, which records each in notification_request in the action's transaction and logs it.
  • Claim moves a task to In Progress. Section 4.3 says Assigned becomes In Progress on "Claimed or started". The contract's claim example shows assigned. The specification decides; examples are not normative, and the contract test checks the schema.
  • Eligible active users are counted enterprise-wide. IdentityChanged carries the role of an assignment but not its facility scope. For a facility-scoped queue the count may include users of other facilities, so a stuck-queue alert there can come late. Follow-up for the IAM contract.
  • The replay-sensitive list is a setting. CFG-ISE-007 is Domain 2 configuration with no contract to read it. The default fails closed (every step into Domains 1, 3 and 5, and Domain 10's identity operations). A definition can add a step to the list but never take one off, so the list stays the one list of part 6.11.
  • The second person of a replay is not proven to have confirmed in place (CUX-64, OV-112). secondPerson in workflow.v1 is an account ID the requester supplies. The unit checks it is a different person and asks the policy decision point about that person in their own right, but it cannot verify that person's step-up. Follow-up for the ESS contract session.
  • Definitions, task types and queues arrive as configuration under three item types (ess.workflow-definition, ess.task-type, ess.work-queue) that the governance unit has not registered yet. Until it does, they come from the seed or from a configuration published under those types. Follow-up for the governance unit.
  • Escalated in the same run as Overdue. Where a task type names an escalation policy, the overdue check marks the task Overdue and requests the escalation at once, so the state ends Escalated. It still shows as overdue (overdue=true, the history, the TaskStateChanged with state overdue). A type without a policy stays Overdue. Question Q1.
  • The kit's audit wire format is the template's provisional one (RC-1-S01 follow-ups T1 to T7), as in the other units.

Review round 1

  • The replay-sensitive default failed open for Domain 1's identity writes. adm:*identit* did not match addPersonIdentifier, createPerson, registerPatient, assignFacilityIdentifier, correctPersonIdentifier or updateDemographics of contracts/adm. The default now fails closed: adm:*, cli:*, fin:* and Domain 10's identity operations. Round 1 also let a definition decide for its step; round 2 narrowed that, so a definition can only add a step. The test ReplaySafetyTest.identityWritesFailClosed uses those six operation IDs and an interrupted addPersonIdentifier. ADR-HIS-058 point 2 and the unit README say so.
  • secondPerson cannot be verified (follow-up, not blocking): recorded under "Done differently" and as a follow-up for the ESS contract session.
  • Issue #29's comments hold only the launcher's start notice; there are no answers from people.

Review round 2

  • A definition could take a step off the list. Round 1 let "replaySensitive": false override CFG-ISE-007, against part 6.11's "one list". Now a definition can only add a step (true); a step the list matches stays replay-sensitive. ADR-HIS-058 point 2 and its consequences, the unit README and this handover say so.
  • Tests. The tests of WorkflowExecutionTest that show retry and resend after a restart, and ReplaySafetyTest.ordinaryStepResumes, now use definitions of Domain 6 (HIM), which are outside the list; none marks false any more. New: ReplaySafetyTest.definitionCannotExemptListedStep, where a medication step marked false stays replay-sensitive and is not replayed after an interruption. Also new: definitionAddsStep.
  • Q1 and the secondPerson follow-up stay as they were, as the review notes.

Questions for a person

None blocks this session. Each takes the reading above and is listed under "Needs a person" in the pull request.

# Question Owner What the unit does now
Q1 FR-ESS-WFL-002 AC-02 says the overdue task "shows as Overdue", while section 4.3 moves it on to Escalated when "the escalation rule fires". Does the first step of an escalation policy fire at the due time, or after a delay the policy sets (CFG-ESS-014, not set)? Owner of D10-ESS, clinical governance At the due time: Overdue, then Escalated in the same run, with the supervisor notified
Q2 FR-ESS-WFL-002 part 6.11: until IF-ESS-001 can find a practitioner's account, may a pathway conflict review always go to the unit supervisor on duty? Owner of D10-ESS with Domain 9; contract owner of IF-ESS-001 Yes: the specification's fallback

Follow-ups outside the card

  • ESS contract session (next minor version of workflow.v1): a verifiable in-place confirmation for retryWorkflowStep in place of the bare secondPerson account ID, for example a step-up assertion as emergency-access.v1 uses (CUX-64, OV-112).
  • ESS contract session (next minor version of identity.v1):
  • a lookup of an account by practitionerRef (for Q2);
  • the facility scope of an assignment in IdentityChanged (for eligible active users).
  • Domain 9 contract session (PA slice): the PathwayConflictDetected event contract, with conflict identifier, patient, encounter, facility, unit and the two instance identifiers; then this unit adds its subscription to PathwayConflicts.
  • Governance unit (services/ess-governance):
  • register the item types ess.workflow-definition, ess.task-type and ess.work-queue, with the content forms of ADR-HIS-058 points 4 and 5;
  • a validation hook that refuses a definition naming an unregistered API (FR-ESS-WFL-001 part 10).
  • Domain 2: publish CFG-ISE-007 in a form this unit can read, replacing the default of replay-sensitive-targets.
  • RC-1-S16 and RC-1-S17 (policy): register the actions and resource types of ADR-HIS-058 point 9, the eligibility and supervision rules on eligibleRoles and supervisorRoles, ess.wfl.instance.replay-confirm, and the roles ess.workflow-administrator, identity-steward, identity-steward-lead and ebp.unit-supervisor-on-duty.
  • Domain 1 (services/adm-identity): register adm.duplicate-review and adm.identity-stewardship as configuration; the seed holds them until then.
  • RC-2 (MOD-ESS-007): take over the recorded requests of notification_request through IF-ESS-009.
  • RC-1-S26 (integrate): add ess-coordination to e2e/scenarios/RC-1/stack.json, and set his.governance.workflow-url of the governance unit to it.
  • Service template: RC-1-S05's follow-ups (kit errors, the CVE constraints) apply to the template too; this unit took them in its own copy.