@@ -98,6 +98,9 @@ function fixtureFiles(): Record<string, string> {
9898 path . join ( repoRoot , "src" , "infra" , "agent-run-registry.ts" ) ,
9999 ) ;
100100 const agentEventsPath = JSON . stringify ( path . join ( repoRoot , "src" , "infra" , "agent-events.ts" ) ) ;
101+ const workAdmissionPath = JSON . stringify (
102+ path . join ( repoRoot , "src" , "process" , "gateway-work-admission.ts" ) ,
103+ ) ;
101104 const activeSessionsPath = JSON . stringify (
102105 path . join ( repoRoot , "src" , "gateway" , "active-sessions-shutdown-tracker.ts" ) ,
103106 ) ;
@@ -211,11 +214,15 @@ function fixtureFiles(): Record<string, string> {
211214 "" ,
212215 ] . join ( "\n" ) ,
213216 "05-a-agent-run.test.ts" : [
217+ `import { getActiveGatewayRootWorkCount, markGatewayRestartDraining, tryBeginGatewayRootWorkAdmission } from ${ workAdmissionPath } ;` ,
214218 `import { getAgentRunContext, registerAgentRunContext } from ${ agentRunRegistryPath } ;` ,
215219 `import { emitAgentEvent, onAgentEvent } from ${ agentEventsPath } ;` ,
216220 `import { listActiveSessionsForShutdown, noteActiveSessionForShutdown } from ${ activeSessionsPath } ;` ,
217221 'import { expect, it } from "vitest";' ,
218222 'it("seeds process-global run contexts", () => {' ,
223+ " expect(tryBeginGatewayRootWorkAdmission()).not.toBeNull();" ,
224+ " expect(getActiveGatewayRootWorkCount()).toBe(1);" ,
225+ " markGatewayRestartDraining();" ,
219226 ' noteActiveSessionForShutdown({ cfg: {}, sessionKey: "session-a", sessionId: "session-a", storePath: "/tmp/fixture.sqlite", agentId: "main" });' ,
220227 " expect(listActiveSessionsForShutdown()).toHaveLength(1);" ,
221228 ' registerAgentRunContext("unrelated-run-a", { sessionKey: "session-a" });' ,
@@ -232,11 +239,16 @@ function fixtureFiles(): Record<string, string> {
232239 "" ,
233240 ] . join ( "\n" ) ,
234241 "05-b-agent-run.test.ts" : [
242+ `import { getActiveGatewayRootWorkCount, tryBeginGatewayRootWorkAdmission } from ${ workAdmissionPath } ;` ,
235243 `import { clearAgentRunContext, getAgentRunContext, registerAgentRunContext, sweepStaleRunContexts } from ${ agentRunRegistryPath } ;` ,
236244 `import { emitAgentEvent, onAgentEvent } from ${ agentEventsPath } ;` ,
237245 `import { listActiveSessionsForShutdown } from ${ activeSessionsPath } ;` ,
238246 'import { expect, it } from "vitest";' ,
239247 'it("clears agent run registry state", () => {' ,
248+ " expect(getActiveGatewayRootWorkCount()).toBe(0);" ,
249+ " const admission = tryBeginGatewayRootWorkAdmission();" ,
250+ " expect(admission).not.toBeNull();" ,
251+ " admission?.release();" ,
240252 " expect(listActiveSessionsForShutdown()).toEqual([]);" ,
241253 ' registerAgentRunContext("reused-run", { sessionKey: "reused-session" });' ,
242254 " let sequence;" ,
0 commit comments