@@ -3,7 +3,6 @@ import { createHash, randomBytes } from "node:crypto";
33import fs from "node:fs" ;
44import os from "node:os" ;
55import path from "node:path" ;
6- import { performance } from "node:perf_hooks" ;
76import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
87import { recordAcpParentStreamEvents } from "../../agents/subagents/spawn/acp-parent-stream-store.sqlite.js" ;
98import { executeSqliteQuerySync , getNodeSqliteKysely } from "../../infra/kysely-sync.js" ;
@@ -67,30 +66,20 @@ describe("SQLite transcript archive worker", () => {
6766 ) ;
6867 await replaceTranscriptEvents ( { sessionKey, sessionId, storePath } , events ) ;
6968
70- const heartbeatTimes = [ performance . now ( ) ] ;
69+ let heartbeatCount = 0 ;
7170 const heartbeat = setInterval ( ( ) => {
72- heartbeatTimes . push ( performance . now ( ) ) ;
71+ heartbeatCount += 1 ;
7372 } , 5 ) ;
7473 let materialized : Awaited < ReturnType < typeof materializeSessionStateDeletePlans > > ;
7574 try {
7675 const database = openLifecycleTestDatabase ( storePath ) ;
7776 const plan = planArchiveWorker ( database , path . dirname ( storePath ) , sessionId ) ;
7877 materialized = await materializeSessionStateDeletePlans ( [ plan ] ) ;
7978 } finally {
80- heartbeatTimes . push ( performance . now ( ) ) ;
8179 clearInterval ( heartbeat ) ;
8280 }
8381
84- const heartbeatGaps : number [ ] = [ ] ;
85- for ( let index = 1 ; index < heartbeatTimes . length ; index += 1 ) {
86- const current = heartbeatTimes [ index ] ;
87- const previous = heartbeatTimes [ index - 1 ] ;
88- if ( current !== undefined && previous !== undefined ) {
89- heartbeatGaps . push ( current - previous ) ;
90- }
91- }
92- expect ( heartbeatTimes . length - 2 ) . toBeGreaterThan ( 5 ) ;
93- expect ( Math . max ( ...heartbeatGaps ) ) . toBeLessThan ( 150 ) ;
82+ expect ( heartbeatCount ) . toBeGreaterThan ( 5 ) ;
9483 expect ( materialized ) . toHaveLength ( 1 ) ;
9584 const archivedPath = materialized [ 0 ] ?. archivedTranscript ?. archivedPath ;
9685 expect ( archivedPath ) . toBeTruthy ( ) ;
0 commit comments