@@ -148,6 +148,51 @@ describe("pristine startup state", () => {
148148 expect ( canSkipPristineStartupStateMigrations ( env ) ) . toBe ( true ) ;
149149 } ) ;
150150
151+ it ( "accepts canonical internal hook configuration" , ( ) => {
152+ const env = createFixture ( {
153+ hooks : {
154+ internal : {
155+ enabled : true ,
156+ entries : {
157+ "session-memory" : {
158+ enabled : true ,
159+ env : { OPENCLAW_HOOK_TEST : "enabled" } ,
160+ customOption : "value" ,
161+ } ,
162+ } ,
163+ } ,
164+ } ,
165+ } ) ;
166+
167+ expect ( planPristineStartupStateMigrations ( env ) ) . toEqual ( {
168+ skipAllStateMigrations : true ,
169+ skipCoreStateMigrations : true ,
170+ } ) ;
171+ } ) ;
172+
173+ it ( "retains migrations for legacy, external, and malformed hook configuration" , ( ) => {
174+ const unsafeHooks = [
175+ { gmail :
{ account :
"[email protected] " } } , 176+ { internal : { installs : { "session-memory" : { source : "bundled" } } } } ,
177+ { internal : { handlers : [ ] } } ,
178+ { internal : { load : { extraDirs : [ "/tmp/hooks" ] } } } ,
179+ { internal : { enabled : "yes" } } ,
180+ { internal : { entries : [ ] } } ,
181+ { internal : { entries : { "session-memory" : { enabled : "yes" } } } } ,
182+ { internal : { entries : { "session-memory" : { env : { INVALID : true } } } } } ,
183+ ] ;
184+
185+ for ( const hooks of unsafeHooks ) {
186+ expect (
187+ planPristineStartupStateMigrations ( createFixture ( { hooks } ) ) ,
188+ JSON . stringify ( hooks ) ,
189+ ) . toEqual ( {
190+ skipAllStateMigrations : false ,
191+ skipCoreStateMigrations : false ,
192+ } ) ;
193+ }
194+ } ) ;
195+
151196 it ( "retains migrations for bundled plugins with doctor state surfaces" , ( ) => {
152197 const env = addBundledPlugin (
153198 createFixture ( { plugins : { entries : { example : { enabled : true } } } } ) ,
0 commit comments