feat(FN-3958): add heartbeat timer reconciliation self-healing

Adds scheduler heartbeat timer reconciliation with automatic self-healing when timers drift, including tests for tracked-only monitor recovery and documentation in the agents reference.

Fusion-Task-Id: FN-3958
This commit is contained in:
Fusion
2026-05-10 23:24:27 -07:00
committed by gsxdsm
parent e151cf2c55
commit 44a9fb8ed8
7 changed files with 176 additions and 5 deletions

View File

@@ -1181,6 +1181,28 @@ describe("InProcessRuntime", () => {
);
});
it("reconciles a missing timer for a tickable durable agent without state changes", async () => {
const store = getAgentStore(runtime);
const scheduler = runtime.getTriggerScheduler();
expect(scheduler).toBeDefined();
const agent = await store.createAgent({
name: "audit-rearm-agent",
role: "executor",
runtimeConfig: {
enabled: true,
heartbeatIntervalMs: 1_000,
},
});
expect(scheduler!.getRegisteredAgents()).toContain(agent.id);
scheduler!.unregisterAgent(agent.id);
expect(scheduler!.getRegisteredAgents()).not.toContain(agent.id);
await vi.advanceTimersByTimeAsync(60_000);
expect(scheduler!.getRegisteredAgents()).toContain(agent.id);
});
it("unregisters an agent when enabled is set to false in update", async () => {
// Create a new agent with heartbeat enabled
const store = getAgentStore(runtime);