Deposit Release Acknowledged Auto-Transition
Deposit Release Acknowledged Auto-Transition
Introduced in v0.1.322
This workflow automates the final step in the deposit release acknowledgement process. Once every required party has acknowledged a proposed release, the system automatically advances the release to acknowledged status — no manual intervention required.
Overview
When a deposit release is proposed, each relevant party receives an acknowledgement request recorded as a depositReleaseAcknowledgement record with status = 'pending'. This workflow monitors those records and transitions the parent depositRelease to acknowledged as soon as all parties have responded.
Triggers
The workflow runs under two conditions:
| Trigger | Description |
|---|---|
| Event-driven | Fires immediately when a deposit/release.ack.responded event is received (i.e. a party submits their acknowledgement in real time). |
| Nightly sweep | Runs on a cron schedule at 03:00 UTC every day (0 3 * * *) to catch any releases where all acknowledgements may already be complete but the transition was not yet applied. |
Workflow Logic
1. Receive releaseId (from event payload or sweep query)
2. Fetch all depositReleaseAcknowledgements WHERE releaseId = :releaseId
3. IF any record has status = 'pending'
→ Exit. No state change.
4. IF ALL records have status = 'acknowledged'
→ UPDATE depositReleases SET status = 'acknowledged' WHERE id = :releaseId
→ EMIT event: deposit/release.acknowledged
→ INSERT notifications for org admins (success)
→ INSERT auditLog entry
State Transition
depositReleases.status
proposed
│
│ (all acknowledgements received)
▼
acknowledged
The transition only occurs when every depositReleaseAcknowledgement record linked to the releaseId carries status = 'acknowledged'. A single outstanding 'pending' record blocks the transition.
Side Effects
When the transition fires, the following actions occur atomically:
1. Status Update
The depositReleases record for the given releaseId is updated:
status: 'proposed' → 'acknowledged'
2. Downstream Event
The deposit/release.acknowledged event is emitted, allowing other workflows or integrations to react to the completed acknowledgement.
3. Notifications
Success notifications are inserted into the notifications table for all org admins (orgMembers with admin roles) associated with the release's organisation.
4. Audit Log
An entry is written to auditLog recording:
- The
releaseIdthat transitioned - The old and new status values
- The timestamp of the transition
- The trigger source (event or nightly sweep)
Affected Entities
| Entity | Operation |
|---|---|
depositReleases | UPDATE — status field |
depositReleaseAcknowledgements | SELECT — read all records for a releaseId |
notifications | INSERT — success notifications for org admins |
auditLog | INSERT — transition record |
orgMembers | SELECT — identify org admins to notify |
Notes
- The nightly sweep at
03:00 UTCacts as a safety net. In normal operation, the event-driven path handles transitions in real time. - If a
depositReleaseis already inacknowledgedstatus when the workflow runs, no duplicate writes occur. - Notifications are scoped to org admins only; individual tenants and landlords are not directly notified via this workflow (downstream events may trigger separate notifications).