@@ -1051,6 +1051,45 @@ describe("sandbox crash-recovery replay (#5961, #6228)", () => {
10511051 expect ( resumedRun . calls . error . mock . calls . flat ( ) . join ( "\n" ) ) . toContain ( "--recreate-sandbox" ) ;
10521052 } ) ;
10531053
1054+ it ( "recreates after stable resolved create-intent drift when explicitly requested (#9297)" , async ( ) => {
1055+ const session = createSession ( { sessionId : "sess-1" , agent : "openclaw" } ) ;
1056+ const updateSession = vi . fn ( ( mutator : ( value : typeof session ) => void ) => {
1057+ mutator ( session ) ;
1058+ return session ;
1059+ } ) ;
1060+ const firstRun = createDeps ( { getSandboxReuseState : ( ) => "missing" , updateSession } ) ;
1061+
1062+ await handleSandboxState ( {
1063+ ...baseOptions ( firstRun . deps , session ) ,
1064+ resume : false ,
1065+ sandboxName : "my-assistant" ,
1066+ } ) ;
1067+
1068+ const resumedRun = createDeps ( { getSandboxReuseState : ( ) => "missing" , updateSession } ) ;
1069+ const defaultResolve = resumedRun . calls . resolveCreateIntent . getMockImplementation ( ) ;
1070+ expect ( defaultResolve ) . toBeDefined ( ) ;
1071+ resumedRun . calls . resolveCreateIntent . mockImplementation ( async ( input ) => {
1072+ const resolved = await defaultResolve ! ( input ) ;
1073+ return {
1074+ ...resolved ,
1075+ policy : { ...resolved . policy , basePolicyPath : "/repo/changed-policy.yaml" } ,
1076+ } ;
1077+ } ) ;
1078+
1079+ await handleSandboxState ( {
1080+ ...baseOptions ( resumedRun . deps , session ) ,
1081+ resume : true ,
1082+ recreateSandbox : ( ) => true ,
1083+ sandboxName : "my-assistant" ,
1084+ } ) ;
1085+
1086+ expect ( resumedRun . calls . createSandbox ) . toHaveBeenCalledOnce ( ) ;
1087+ expect ( resumedRun . calls . createSandbox . mock . calls [ 0 ] ?. at ( - 1 ) ) . toEqual (
1088+ expect . objectContaining ( { recreate : true } ) ,
1089+ ) ;
1090+ expect ( resumedRun . calls . error ) . not . toHaveBeenCalled ( ) ;
1091+ } ) ;
1092+
10541093 it ( "rejects reasoning capability drift before replaying a recorded sandbox create (#7570)" , async ( ) => {
10551094 const session = createSession ( { sessionId : "sess-1" , agent : "openclaw" } ) ;
10561095 const updateSession = vi . fn ( ( mutator : ( value : typeof session ) => void ) => {
0 commit comments