@@ -19,6 +19,7 @@ import { type RuntimeEvent } from '@maka/core/runtime-event';
1919import {
2020 createSessionStore ,
2121 createSqliteSessionMetadataStore ,
22+ isSessionNotFoundError ,
2223 OPERATIONAL_STATE_DATABASE_NAME ,
2324} from '@maka/storage' ;
2425import { createSqliteAgentRunStore , createWorkspaceRuntimeStore } from '@maka/storage' ;
@@ -328,6 +329,15 @@ describe('host-managed agent graph coordinator', () => {
328329 coordinator . toolsForSession ( childSessions [ 0 ] ! . id ) ,
329330 / o n l y t o r o o t S e s s i o n s / ,
330331 ) ;
332+ await assert . rejects (
333+ coordinator . listGraphEpochPage ( childSessions [ 0 ] ! . id , { limit : 32 } ) ,
334+ ( error : unknown ) =>
335+ error instanceof AgentGraphClientOperationError && error . code === 'operation_conflict' ,
336+ ) ;
337+ await assert . rejects (
338+ coordinator . listGraphEpochPage ( randomUUID ( ) , { limit : 32 } ) ,
339+ ( error : unknown ) => isSessionNotFoundError ( error ) ,
340+ ) ;
331341 let childStopEntered = false ;
332342 await assert . rejects (
333343 coordinator . stopExecution ( childSessions [ 0 ] ! . id , {
@@ -545,11 +555,18 @@ describe('host-managed agent graph coordinator', () => {
545555 test ( 'reads the epoch page and current marker from one storage observation' , async ( ) => {
546556 const controlStore = createSqliteSessionMetadataStore ( ':memory:' ) ;
547557 let resolveCalls = 0 ;
558+ let headerReads = 0 ;
548559 const coordinator = new AgentGraphCoordinator ( {
549560 sessionStore : {
550561 listForRecovery : async ( ) => [ ] ,
551- readHeader : async ( ) => {
552- throw new Error ( 'epoch listing must not read the Session header' ) ;
562+ readHeader : async ( sessionId : string ) => {
563+ headerReads += 1 ;
564+ return {
565+ id : sessionId ,
566+ status : 'active' ,
567+ isArchived : false ,
568+ orchestrationMode : 'graph' ,
569+ } as never ;
553570 } ,
554571 } ,
555572 runStore : { listSessionRuns : async ( ) => [ ] } ,
@@ -612,6 +629,12 @@ describe('host-managed agent graph coordinator', () => {
612629 assert . equal ( page . currentEpoch , 3 ) ;
613630 assert . equal ( page . epochs [ 0 ] ?. graphId , 'agent_graph_3' ) ;
614631 assert . equal ( resolveCalls , 0 ) ;
632+ assert . equal ( headerReads , 1 ) ;
633+ await assert . rejects (
634+ coordinator . listGraphEpochPage ( 'root-session' , { beforeEpoch : 999 , limit : 32 } ) ,
635+ ( error : unknown ) =>
636+ error instanceof AgentGraphClientOperationError && error . code === 'invalid_request' ,
637+ ) ;
615638 } finally {
616639 await coordinator . close ( ) ;
617640 controlStore . close ( ) ;
0 commit comments