All checks were successful
## What & why Second sub-slice of **S-11 · Withdrawal (Flow 3)** (#12). S-11a (#88) made a withdrawal advance the aggregate to INGETROKKEN; this sub-slice **cancels the running Flowable process** so the withdrawn case leaves the behandelaar's werkbak. - **BPMN** (`registratie.bpmn`): an interrupting message boundary event (`RegistratieIngetrokken`) on the `Beoordelen` task, routing to a dedicated "Registratie ingetrokken" end event. - **Workflow Client**: `WithdrawBeoordelingAsync(executionId)` delivers `messageEventReceived` to the task's execution (PUT); `BeoordelingTask` now carries its `executionId`. - **`WithdrawRegistration` handler**: after the domain transition, finds the open `Beoordelen` task for the registration and delivers the withdrawal message — best-effort, mirroring how the beoordeling completes its task. - **Werkbak**: also filters out registrations that are no longer open, so a withdrawn case never surfaces even in the brief window before cancellation lands. - **ADR-0014** records the decision (message event in BPMN vs. deleting the instance from code). - **verify (`run-domain-check.sh`)**: a second registration parks at `Beoordelen`, is withdrawn via the domain, and the check asserts its `Beoordelen` task disappears — so verify-stack validates the live Flowable message correlation. Refs #12 (S-11c — the BFF + self-service "trek aanvraag in" button + e2e — closes it). ## Definition of Done - [x] Linked Gitea issue (#12). - [x] Failing tests committed before the implementation (red → green per commit). - [x] Implementation makes the tests pass. - [x] Conventional Commits referencing the issue (`refs #12`). - [ ] CI green — all Gitea Actions jobs. - [x] `docker compose up` unaffected (BPMN redeploys on a fresh CI DB via flowable-init). - [x] ADR added (ADR-0014). - [x] Docs — the user-visible demo note lands with S-11c. ## Notes for reviewers - Verified locally: `Big.Tests` 94/94 pass; `Big.Api` builds; `registratie.bpmn` is well-formed. - The Flowable message-correlation REST shape is validated **live** by verify-stack (the Workflow Client unit tests stub the exchange and assert only the request shape, per ADR-0009) — the new `run-domain-check.sh` withdrawal step is that live check. - Known gap (ADR-0014): a withdrawal that races ahead of the process reaching `Beoordelen` finds no task to cancel; the aggregate is still INGETROKKEN and the werkbak filter hides it, but that instance parks unattended. A process-level event subprocess would close the gap — deferred. Reviewed-on: #89
89 lines
4.5 KiB
C#
89 lines
4.5 KiB
C#
using Big.Domain;
|
|
|
|
namespace Big.Application;
|
|
|
|
/// <summary>
|
|
/// The port to the workflow engine. Implemented by the Workflow Client in Infrastructure — the
|
|
/// <em>only</em> code that talks to Flowable (CLAUDE.md §8.2). The application asks it to start the
|
|
/// registratie process; it never knows Flowable exists.
|
|
/// </summary>
|
|
public interface IWorkflowClient
|
|
{
|
|
/// <summary>
|
|
/// Start one <c>registratie</c> process instance for the given registration, carrying the
|
|
/// registration id so the <c>OpenZaakAanmaken</c> external task can be correlated back to its
|
|
/// aggregate. Returns the process instance id.
|
|
/// </summary>
|
|
Task<string> StartRegistrationProcessAsync(RegistrationId registrationId, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Cancel a running <c>registratie</c> process on withdrawal (S-11): correlate the
|
|
/// <c>RegistratieIngetrokken</c> message to the instance, tripping the interrupting message event
|
|
/// that ends it (ADR-0014). Best-effort — if the instance is not waiting on that message (already
|
|
/// ended, or not yet parked) it is a no-op; the aggregate is INGETROKKEN regardless.
|
|
/// </summary>
|
|
Task WithdrawProcessAsync(string processInstanceId, CancellationToken ct = default);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The port to the Anti-Corruption Layer. Implemented in Infrastructure by an HTTP client to the
|
|
/// ACL service — the <em>only</em> code that talks to ZGW (CLAUDE.md §8.1). The domain hands over a
|
|
/// bsn; the ACL default-fills the ZGW-mandatory fields (ADR-0003) and returns the created zaak URL.
|
|
/// </summary>
|
|
public interface IAclClient
|
|
{
|
|
/// <summary>Open a zaak for the registration. <paramref name="reference"/> is the registration's
|
|
/// own reference (its id); the ACL records it as the zaak's identificatie so the openbaar register
|
|
/// can show the same reference the zorgprofessional was given (S-09b follow-up, adr-proposal #78).</summary>
|
|
Task<Uri> OpenZaakAsync(string bsn, string reference, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Record the approval on the given zaak. The ACL translates this to the ZGW concept — setting
|
|
/// the zaak's final status — which OpenZaak notifies over NRC; the domain never names statustypen.
|
|
/// </summary>
|
|
Task ApproveZaakAsync(Uri zaakUrl, CancellationToken ct = default);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The port to the behandelaar's user tasks in the workflow engine (S-12). Implemented by the
|
|
/// Workflow Client — the only code that talks to Flowable (§8.2). The application lists the open
|
|
/// <c>Beoordelen</c> tasks (the werkbak), claims one for a behandelaar, and completes it with the
|
|
/// decision; it never names Flowable's REST shapes.
|
|
/// </summary>
|
|
public interface IUserTaskClient
|
|
{
|
|
/// <summary>The werkbak: the <c>Beoordelen</c> tasks awaiting a behandelaar, each with the
|
|
/// registration it belongs to.</summary>
|
|
Task<IReadOnlyList<BeoordelingTask>> GetOpenBeoordelingenAsync(CancellationToken ct = default);
|
|
|
|
/// <summary>Claim a beoordeling task for a behandelaar (assigns it to them).</summary>
|
|
Task ClaimAsync(string taskId, string behandelaar, CancellationToken ct = default);
|
|
|
|
/// <summary>Complete a beoordeling task, carrying the decision into the process as the
|
|
/// <c>besluit</c> variable so the workflow can continue on the chosen branch.</summary>
|
|
Task CompleteBeoordelingAsync(string taskId, BeoordelingsBesluit besluit, CancellationToken ct = default);
|
|
}
|
|
|
|
/// <summary>A <c>Beoordelen</c> user task in the werkbak: the Flowable task id (needed to claim and
|
|
/// complete it) and the registration it carries as a process variable.</summary>
|
|
public sealed record BeoordelingTask(string TaskId, RegistrationId RegistrationId);
|
|
|
|
/// <summary>
|
|
/// Persistence port for the <see cref="Registration"/> aggregate. In-memory for the minimal slice
|
|
/// (ADR-0009); an EF-backed store is a documented follow-up, and this port keeps that change additive.
|
|
/// </summary>
|
|
public interface IRegistrationStore
|
|
{
|
|
/// <summary>Insert or update the registration, keyed on its id.</summary>
|
|
Task SaveAsync(Registration registration, CancellationToken ct = default);
|
|
|
|
/// <summary>Load a registration by id, or <c>null</c> if none exists.</summary>
|
|
Task<Registration?> GetAsync(RegistrationId id, CancellationToken ct = default);
|
|
}
|
|
|
|
/// <summary>
|
|
/// An acquired <c>OpenZaakAanmaken</c> external-worker job: the Flowable job id (needed to complete
|
|
/// it) and the registration id it carries as a process variable.
|
|
/// </summary>
|
|
public sealed record OpenZaakJob(string JobId, RegistrationId RegistrationId);
|