Maintenance system
Architecture entry point for the maintenance domain. Authoritative behavioral specs live under ../lifecycle/maintenance/ and must stay aligned with implementation.
Engineering map: ../../maintainer/systems/maintenance.md.
Documentation map
| Topic | Location |
|---|---|
| Overview & definitions | ../lifecycle/maintenance/ |
Status & departmentApprovalStatus | ../lifecycle/maintenance/status-transitions.md |
| RBAC, archive / purge | ../lifecycle/maintenance/permissions-matrix.md |
finalSnapshot, list vs detail | ../lifecycle/maintenance/snapshot-behavior.md |
| Cache contracts | ../lifecycle/cache/ |
Storage
- Primary: PostgreSQL (
maintenance_requestsvia Drizzle) - Attachments: R2 + metadata table (not duplicated in
finalSnapshotby default) - Audit / logs: Structured maintenance and security pipelines; purge emits structured
meta(see snapshot doc)
Core model
status:pending|in_progress|completed|cancelled|declined(underscore form only)departmentApprovalStatus: dashboard / summary field; invariants tied tostatusin lifecycle docs- Prefer
status+completedAtover a separate completed boolean - User refs:
submittedBy,approvedBy,assignedBy,assignedTo(IDs);departmentIdwith APIdepartment: { id, name } - Terminal:
completed,cancelled,declined— further changes limited to archive / purge / reads per matrix finalSnapshot: JSONv: 1, written once with the terminal transition, immutable; includesdepartmentandrelatedUsers
API shape
relatedUsers: enriched array;canViewProfileserver-only; no emailpermissions: includescanArchive,canPurge- List: no full snapshot;
takenAtfromfinalSnapshot.takenAtwhen closed, elsenull - Detail: full
finalSnapshotfor closed tasks
Code map
| Area | Path |
|---|---|
| Routes | apps/worker/src/routes/maintenance/ |
| Services | apps/worker/src/lib/services/maintenance/ |
| Cache | apps/worker/src/lib/services/cache/ |