From 4000854b697f77a61c493438828780ce527aada7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 16 Apr 2026 22:56:43 -0400 Subject: [PATCH] fix(heartbeat): remove silent-default try/catch around getHeartbeatPolicy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit P2-35: The policy row is the gate that decides whether the agent runs; pretending cooldown is 10s when the read fails hides data corruption. db.getHeartbeatPolicy already supplies field-level defaults from policy JSON — and the only reason to throw here is 'agent not found', which is already impossible because the caller just loaded db.getAgent. --- src/main/orchestration/heartbeat.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/orchestration/heartbeat.ts b/src/main/orchestration/heartbeat.ts index 831e9bdc..889de063 100644 --- a/src/main/orchestration/heartbeat.ts +++ b/src/main/orchestration/heartbeat.ts @@ -46,13 +46,11 @@ export function createHeartbeat( if (getRunEligibilityFailure(agent, connector, null)) { return null; } - // Extended heartbeat policy checks (Paperclip parity) - let heartbeatPolicy = { cooldownSec: 10, maxConcurrentRuns: 1, wakeOnDemand: true }; - try { - heartbeatPolicy = db.getHeartbeatPolicy(agent.id); - } catch { - // Non-fatal: use defaults - } + // Extended heartbeat policy checks (Paperclip parity). + // Let getHeartbeatPolicy throw — a missing row signals data corruption + // and silently falling back hides the gate that decides whether the + // agent runs at all. + const heartbeatPolicy = db.getHeartbeatPolicy(agent.id); // maxConcurrentRuns check: count active runs for this agent const activeRunCount = db.countActiveRunsForAgent(agent.id, companyId);