mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-27 19:35:13 +01:00
fix(heartbeat): preserve wake diagnostics history
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
3a21bb3b48
commit
e3f5f1a1ca
2 files changed
+16
-2
No files matched your search
@@ -32,7 +32,8 @@ describeEmbeddedPostgres("agent wakeup request retention", () => {
|
||||
|
||||
it("prunes old skipped and coalesced rows in bounded batches while preserving audit and referenced rows", async () => {
|
||||
const now = new Date("2026-08-27T12:00:00.000Z");
|
||||
const old = new Date("2026-08-19T12:00:00.000Z");
|
||||
const old = new Date("2026-08-12T12:00:00.000Z");
|
||||
const withinDiagnosticsWindow = new Date("2026-08-19T12:00:00.000Z");
|
||||
const recent = new Date("2026-08-26T12:00:00.000Z");
|
||||
const companyId = randomUUID();
|
||||
const agentId = randomUUID();
|
||||
@@ -41,6 +42,7 @@ describeEmbeddedPostgres("agent wakeup request retention", () => {
|
||||
coalesced: randomUUID(),
|
||||
completed: randomUUID(),
|
||||
failed: randomUUID(),
|
||||
diagnosticsWindowSkipped: randomUUID(),
|
||||
recentSkipped: randomUUID(),
|
||||
referencedSkipped: randomUUID(),
|
||||
};
|
||||
@@ -100,6 +102,15 @@ describeEmbeddedPostgres("agent wakeup request retention", () => {
|
||||
requestedAt: old,
|
||||
finishedAt: old,
|
||||
},
|
||||
{
|
||||
id: ids.diagnosticsWindowSkipped,
|
||||
companyId,
|
||||
agentId,
|
||||
source: "assignment",
|
||||
status: "skipped",
|
||||
requestedAt: withinDiagnosticsWindow,
|
||||
finishedAt: withinDiagnosticsWindow,
|
||||
},
|
||||
{
|
||||
id: ids.recentSkipped,
|
||||
companyId,
|
||||
@@ -147,6 +158,7 @@ describeEmbeddedPostgres("agent wakeup request retention", () => {
|
||||
|
||||
expect(remaining).toEqual([
|
||||
ids.completed,
|
||||
ids.diagnosticsWindowSkipped,
|
||||
ids.failed,
|
||||
ids.recentSkipped,
|
||||
ids.referencedSkipped,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { sql } from "drizzle-orm";
|
||||
import type { Db } from "@paperclipai/db";
|
||||
|
||||
export const WAKEUP_REQUEST_TERMINAL_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
|
||||
// Keep terminal requests for at least as long as the issue diagnostics lookback.
|
||||
// The diagnostics service currently supports a 14-day wake-history window.
|
||||
export const WAKEUP_REQUEST_TERMINAL_RETENTION_MS = 14 * 24 * 60 * 60 * 1000;
|
||||
export const WAKEUP_REQUEST_RETENTION_BATCH_SIZE = 10_000;
|
||||
|
||||
export function wakeupRequestRetentionService(db: Db) {
|
||||
|
||||
Reference in new issue
Block a user