Skip to content

Commit 8d6f824

Browse files
h0tak88rclaude
andcommitted
fix(programs): replace rolling-sweep monitor with passive watch + status panel
Tear out the 1-program-every-3s rolling sweep daemon (program_monitor.go); replace with a passive watch that piggybacks on data the warmer already fetches. The Programs page already has `latest_target_updated_at` for every program — use it. How it works now: - internal/api/program_watch.go: ProgramWatchOnRefresh(programs) is called from refreshProgramsCache after every catalogue rebuild. It scans latest_target_updated_at, fires one Discord alert per program whose timestamp exceeds the persisted watermark (settings key program_watch_latest_seen), then advances the watermark. Capped at 10 alerts/cycle to defeat one-time corpus shifts. - BOOT INTRO: once per process (post-restart), sends a "📌 Scope watch ready — most recent update: X" message so the operator sees immediate confirmation the watch is alive. Removes the 1-hour "is it working?" black box. - Programs page: new "Scope Update Watch" status card at the top showing daemon state, freshest update right now, watermark age, alerts this session, plus a 🔔 Test webhook button (POST /api/scope/watch-test) that fires a sample Discord message instantly. No more "wait an hour to know if it works". - GET /api/scope/watch-status powers the panel; POST /api/scope/watch-test does the manual delivery probe. Webhook helper: utils.SendMonitorWebhookErr (returns delivery error) and utils.MonitorWebhookConfigured added — SendMonitorWebhook keeps logging behavior. Removed: program_monitor.go (272 lines), the boot StartProgramMonitor() call, PROGRAM_MONITOR_SPACING_MS env, the full rolling-sweep cost model. The program_assets table + RecordProgramScopeAssets stay (used by the one-shot reset on previous boot); they're dormant going forward. Verified: go build/vet/db+utils tests, node --check programs.js — all clean. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent dc8544f commit 8d6f824

8 files changed

Lines changed: 380 additions & 288 deletions

File tree

internal/api/api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,8 @@ func SetupAPI() *gin.Engine {
581581
apiGroup.GET("/scope/platforms", apiScopePlatforms)
582582
apiGroup.GET("/scope/programs", apiListPrograms)
583583
apiGroup.POST("/scope/program-summaries", apiProgramScopeSummaries)
584+
apiGroup.GET("/scope/watch-status", apiProgramWatchStatus)
585+
apiGroup.POST("/scope/watch-test", apiProgramWatchTest)
584586
// AI finding validation & reporting
585587
apiGroup.POST("/findings/validate", apiValidateFinding)
586588
apiGroup.POST("/findings/report", apiReportFinding)

internal/api/program_monitor.go

Lines changed: 0 additions & 272 deletions
This file was deleted.

0 commit comments

Comments
 (0)