ALL-539: Monitor evaluator + state machine (Phase 2 engine)
completedPhase 2 engine: BullMQ recurring evaluator (60s) + per-entity state machine. Queries texture-monitor-* ES, feeds matches into state machine, writes MonitorEntityState + MonitorTransition + MonitorTransitionOutbox in one Postgres txn. Includes shared resolveTargetEntityIdsForTargets() refactor extracted from monitorService.previewMonitor. Scope ends at outbox row write — publisher daemon is ALL-945.
Event Timeline
created
progress
step 1/4 done: esQueryBuilder + 17 tests passing; step 0 (targetResolver refactor) shipped earlier with monitor service tests still green
progress
Resumed ALL-539. Phase 2 engine already shipped (esQueryBuilder + stateMachine + evaluator + BullMQ scheduler + transactional outbox writes, 170/170 tests). Addressed remaining Cursor Bugbot findings #4 (High — PENDING→OK no-transition state not persisted) and #5 (Medium — RECOVERING entities stuck forever when recoveryDelayMs>0) in commit d7b9584689. Used existing.lastTransitionedAt as the recoveryStartedAt proxy (RECOVERING is only entered via a transition write, so that timestamp is exact). Pushed; CI re-running.
progress
Bugbot remediation on PR #10812 complete. 15:22 UTC review flagged 2 unresolved issues: (1) entitiesEvaluated/Skipped double-count on write failure, (2) WriteEvaluationResultInput.existing type collapsing to any via Map.get ReturnType. Both already fixed by commit 4b324ced at 15:28; Bugbot re-ran at 15:33 with no new issues. All 7 review threads resolved. CI green: test-device-domain, Cursor Bugbot, CodeRabbit, DeepSource JS, DeepSource coverage, Docker build, Apollo schema check — all SUCCESS on head 4b324ced. PR review-ready.
progress
PR #10812: 3 Bugbot issues resolved in commit 5cf2d17e40 — (1) CHANGE family default-off behind env flag, (2) terms query chunked at 5k IDs to avoid ES max_terms_count, (3) buildDataPresenceQuery no longer re-applies targeting. 72 evaluator tests pass, biome+tsc clean on touched files. All 3 Bugbot threads marked resolved. Pushed; CI rerunning. Active CI watch set.
failed
lease expired — re-queued for retry
in_progress → queued
progress
PR #10812: DeepSource JS analysis failure fixed in commit 46572598cc. Two issues resolved: (1) esQueryBuilder.ts switch exhaustiveness added default branch w/ never-assertion; (2) evaluator.ts no-op try/catch removed. 75/75 evaluator tests pass, lint clean. DeepSource JS now passes. Remaining pending: test-device-domain, Cursor Bugbot, DeepSource test-coverage. Watch continues at HEAD 46572598cc.
status_change
queued → completed