feat(deadline-monitor): scheduled contract deadline monitor - #168
Merged
SudiptaPaul-31 merged 3 commits intoJul 26, 2026
Merged
Conversation
…monitor' into 153-scheduled-contract-deadline-monitor # Conflicts: # components/dashboard/notification-item.tsx # lib/notifications.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a scheduled service that monitors milestone deadlines so overdue work and approaching due dates are surfaced automatically, instead of relying on someone checking manually. This is a net-new feature — no existing deadline-tracking service was in place.
What was built
lib/deadline-monitor/service.ts—DeadlineMonitorService.runCheck()runs two independent, idempotent sweeps:is_overdue = trueand both parties are notified.Both sweeps skip milestones already in a terminal status (
approved,paid,rejected), and both are guarded by bookkeeping columns (reminder_sent_at,is_overdue) so re-running the sweep on a tight interval never sends duplicate notifications.lib/notifications.ts— extendedNotificationTypewithmilestone_deadline_approachingandmilestone_overdue, so these events reuse the existing notifications table/API/pagination instead of introducing a parallel event log.components/dashboard/notification-item.tsx— added icon/label/description handling for the two new notification types so they render properly in the dashboard notification panel.scripts/deadline-monitor.ts— standalone worker process (npm run deadline-monitor), following the same long-running-process pattern as the existingscripts/sync-worker.ts. Runs an initial check on startup, then repeats on an interval controlled byDEADLINE_CHECK_INTERVAL_MS(default 5 minutes).lib/db/migrations/007_deadline_monitor.sql— addsis_overdue,overdue_at,reminder_sent_attomilestones, plus a partial index for the overdue sweep query.docs/deadline-monitor.md— architecture, configuration, and testing docs.Acceptance criteria
due_date < NOW()sweep, excluding already-terminal milestones.is_overduewith anoverdue_attimestamp.Testing
Added
__tests__/deadline-monitor/service.test.tsandtypes.test.ts, covering: no-op behavior when nothing is due, reminder notification + bookkeeping, overdue flagging + notification, and both sweeps running independently within a singlerunCheck()call. Full suite passes; no new lint or type errors introduced.Closes #153