feat(admin-schedules): orphan monitor + cleaner endpoints (internal#2006 backstops) #2008
Reference in New Issue
Block a user
Delete Branch "feat/schedule-orphan-monitor-cleaner"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Backstops for the recreate-orphan class. GET /admin/schedules/orphans lists schedules on removed/missing workspaces (monitor); POST /admin/schedules/reap-orphans re-points runtime schedules to live successor + disables dead ones (cleaner). Health() unchanged. +2 tests +2 routes. Part 2/3 (migration is #2007).
internal#2006 — backstops for the recreate-orphans-schedules class. The primary fix is migration-on-recreate (separate PR); these are defense-in-depth so a future regression is detected + recoverable instead of silent. GET /admin/schedules/health reports only LIVE workspaces' schedules (JOIN … WHERE status != 'removed'), so a schedule stranded on a removed/recreated workspace silently stops firing and never shows there — which is exactly why tonight's orphans went unnoticed. - GET /admin/schedules/orphans (Orphans): the monitor surface — lists every schedule bound to a removed OR missing workspace (id, name, source, enabled, ws_status). A monitor polls this and pages on non-empty. - POST /admin/schedules/reap-orphans (ReapOrphans): the cleaner — re-points runtime schedules onto the live successor agent (matched by role+parent), then disables any remaining dead-bound schedules so the scheduler stops firing into removed workspaces. Idempotent; returns {repointed, disabled}. Health() is unchanged (no churn to its tests). +2 tests, +2 routes. Build + handler tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>APPROVED — migrate runtime schedules from removed predecessor on recreate; matched by stable role, template state still re-derived. +3 tests, build green.
APPROVED — best-effort, idempotent (NOT EXISTS dedup); only source=runtime migrated. Closes the recreate-orphan gap.