Deposit Released Without Archive Watchdog
Deposit Released Without Archive Watchdog
Overview
The Deposit Released Without Archive Watchdog is a scheduled reconciliation workflow that runs daily at 04:00 UTC. It identifies deposit releases that have been finalised but whose tenancy archive never reached a complete state, then alerts org admins so the issue can be investigated and resolved before it becomes a compliance problem.
Trigger
| Property | Value |
|---|---|
| Schedule | 0 4 * * * (daily, 04:00 UTC) |
| Type | Reconciliation |
| Version | 0.1.327 |
Logic
Step 1 — Identify stale released deposits
The workflow queries the depositReleases table for records that meet both conditions:
status = 'released'
AND releasedAt < CURRENT_DATE - INTERVAL '10 days'
The 10-day window provides a reasonable buffer for archive jobs that may be slow to complete under normal circumstances, while still catching genuinely stuck cases.
Step 2 — Check the corresponding archive
For each matching depositRelease, the workflow looks up the associated record in tenancyArchives and evaluates its status:
| Archive status | Outcome |
|---|---|
complete | ✅ No action taken |
pending | 🚨 Alert fired |
error | 🚨 Alert fired |
| Not found | 🚨 Alert fired |
Step 3 — Alert and notify
When a problematic archive is detected, the workflow takes two actions:
- Admin alert — All org admins (sourced from
orgMembers) are notified. - Notification record — A
stuck-archivenotification is inserted into thenotificationstable, associated with the affected tenancy.
Entities
| Entity | Access | Purpose |
|---|---|---|
depositReleases | Read | Find released deposits older than 10 days |
tenancyArchives | Read | Verify archive completion status |
tenancies | Read | Provide tenancy context for alerts |
notifications | Write | Insert stuck-archive notification records |
orgMembers | Read | Identify org admins to alert |
What Admins Should Do
When you receive a stuck-archive alert, you should:
- Identify the affected tenancy — The notification will reference the tenancy and deposit release in question.
- Check the archive job status — Review the
tenancyArchivesrecord for anerrormessage or stuckpendingstate. - Re-trigger the archive if needed — If the archive job failed, it can be re-queued manually or via the admin interface once the root cause is resolved.
- Confirm resolution — The alert will clear once the
tenancyArchivesrecord reachesstatus = 'complete'.
Background
Deposit releases and tenancy archiving are closely coupled processes, but they run independently. A deposit can be marked released before its archive job completes — or the archive job may fail silently after the deposit is released. Without active monitoring, these partially-closed tenancies can accumulate undetected.
This watchdog ensures that no tenancy remains in a limbo state for more than 10 days after its deposit is released, supporting both operational hygiene and compliance with the Renters' Rights Act.