@@ -190,15 +190,19 @@ describe("prepared model runtime snapshots", () => {
190190 ) ;
191191 } ) ;
192192
193- it ( "publishes a static turn generation without live catalog discovery" , async ( ) => {
193+ it . each ( [
194+ [ "omitted options" , undefined ] ,
195+ [ "partial options" , { retainIdleRunOwner : true } ] ,
196+ [ "explicit static mode" , { catalogMode : "static" as const } ] ,
197+ ] ) ( "defaults %s to static turn facts without live catalog discovery" , async ( _name , options ) => {
194198 const lease = await acquireAgentRunPreparedModelRuntime (
195199 {
196200 config : { } ,
197201 agentId : "default" ,
198202 agentDir : state . agentDir ( "static-run-agent" ) ,
199203 workspaceDir : "/tmp/static-run-workspace" ,
200204 } ,
201- { catalogMode : "static" } ,
205+ options ,
202206 ) ;
203207
204208 expect ( mocks . prepareStaticCatalog ) . toHaveBeenCalledOnce ( ) ;
@@ -223,7 +227,8 @@ describe("prepared model runtime snapshots", () => {
223227 retainIdleRunOwner : true ,
224228 } ) ;
225229 reusedLease . release ( ) ;
226- expect ( mocks . ensureOpenClawModelsJson ) . toHaveBeenCalledOnce ( ) ;
230+ expect ( mocks . prepareStaticCatalog ) . toHaveBeenCalledOnce ( ) ;
231+ expect ( mocks . ensureOpenClawModelsJson ) . not . toHaveBeenCalled ( ) ;
227232
228233 const secondInput = {
229234 ...firstInput ,
@@ -238,7 +243,8 @@ describe("prepared model runtime snapshots", () => {
238243 "prepared model runtime owner was not published" ,
239244 ) ;
240245 await expect ( prepareModelRuntimeSnapshot ( secondInput ) ) . resolves . toBe ( secondLease . snapshot ) ;
241- expect ( mocks . ensureOpenClawModelsJson ) . toHaveBeenCalledTimes ( 2 ) ;
246+ expect ( mocks . prepareStaticCatalog ) . toHaveBeenCalledTimes ( 2 ) ;
247+ expect ( mocks . ensureOpenClawModelsJson ) . not . toHaveBeenCalled ( ) ;
242248 } ) ;
243249
244250 it ( "retains an exact dynamic workspace owner after gateway run admission" , async ( ) => {
@@ -275,7 +281,8 @@ describe("prepared model runtime snapshots", () => {
275281 } ) ;
276282 expect ( retainedLease . snapshot ) . toBe ( firstLease . snapshot ) ;
277283 retainedLease . release ( ) ;
278- expect ( mocks . ensureOpenClawModelsJson ) . toHaveBeenCalledTimes ( 2 ) ;
284+ expect ( mocks . ensureOpenClawModelsJson ) . toHaveBeenCalledOnce ( ) ;
285+ expect ( mocks . prepareStaticCatalog ) . toHaveBeenCalledOnce ( ) ;
279286 } ) ;
280287
281288 it ( "joins an in-flight dynamic owner publication" , async ( ) => {
@@ -284,10 +291,10 @@ describe("prepared model runtime snapshots", () => {
284291 await refreshPreparedModelRuntimeSnapshots ( config , { gatewayLifecycle : true } ) ;
285292 const finishDynamicGate = createDeferred ( ) ;
286293 let finishDynamic ! : ( ) => void ;
287- mocks . ensureOpenClawModelsJson . mockImplementationOnce ( async ( _config , targetDir ) => {
294+ mocks . prepareStaticCatalog . mockImplementationOnce ( async ( ) => {
288295 finishDynamic = ( ) => finishDynamicGate . resolve ( ) ;
289296 await finishDynamicGate . promise ;
290- return { agentDir : String ( targetDir ) , wrote : false } ;
297+ return { entries : [ ] } ;
291298 } ) ;
292299 const input = {
293300 agentId : "default" ,
@@ -301,15 +308,16 @@ describe("prepared model runtime snapshots", () => {
301308 let secondPending : ReturnType < typeof acquireAgentRunPreparedModelRuntime > | undefined ;
302309 try {
303310 firstPending = acquireAgentRunPreparedModelRuntime ( input ) ;
304- await vi . waitFor ( ( ) => expect ( mocks . ensureOpenClawModelsJson ) . toHaveBeenCalledTimes ( 2 ) ) ;
311+ await vi . waitFor ( ( ) => expect ( mocks . prepareStaticCatalog ) . toHaveBeenCalledOnce ( ) ) ;
305312 secondPending = acquireAgentRunPreparedModelRuntime ( input ) ;
306313 await Promise . resolve ( ) ;
307- expect ( mocks . ensureOpenClawModelsJson ) . toHaveBeenCalledTimes ( 2 ) ;
314+ expect ( mocks . prepareStaticCatalog ) . toHaveBeenCalledOnce ( ) ;
308315 finishDynamic ( ) ;
309316 const [ first , second ] = await Promise . all ( [ firstPending , secondPending ] ) ;
310317
311318 expect ( second . snapshot ) . toBe ( first . snapshot ) ;
312- expect ( mocks . ensureOpenClawModelsJson ) . toHaveBeenCalledTimes ( 2 ) ;
319+ expect ( mocks . ensureOpenClawModelsJson ) . toHaveBeenCalledOnce ( ) ;
320+ expect ( mocks . prepareStaticCatalog ) . toHaveBeenCalledOnce ( ) ;
313321 first . release ( ) ;
314322 second . release ( ) ;
315323 } finally {
@@ -519,7 +527,8 @@ describe("prepared model runtime snapshots", () => {
519527
520528 expect ( lease . snapshot . config ) . toBe ( latestConfig ) ;
521529 expect ( lease . snapshot . workspaceDir ) . toBe ( "/tmp/dynamic-replacement-workspace" ) ;
522- expect ( mocks . ensureOpenClawModelsJson ) . toHaveBeenCalledTimes ( 3 ) ;
530+ expect ( mocks . ensureOpenClawModelsJson ) . toHaveBeenCalledTimes ( 2 ) ;
531+ expect ( mocks . prepareStaticCatalog ) . toHaveBeenCalledOnce ( ) ;
523532 lease . release ( ) ;
524533 } finally {
525534 finishReplacementGate . resolve ( ) ;
0 commit comments