@@ -214,6 +214,52 @@ describe("channel package-state probes", () => {
214214 ) . toBe ( true ) ;
215215 } ) ;
216216
217+ it ( "preserves parent-mounted source overlay precedence over packaged package-state probes" , ( ) => {
218+ const root = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-package-state-parent-overlay-" ) ) ;
219+ tempDirs . push ( root ) ;
220+ const extensionsRoot = path . join ( root , "extensions" ) ;
221+ const sourceRoot = path . join ( extensionsRoot , "matrix" ) ;
222+ const builtRoot = path . join ( root , "dist" , "extensions" , "matrix" ) ;
223+ fs . mkdirSync ( sourceRoot , { recursive : true } ) ;
224+ fs . mkdirSync ( builtRoot , { recursive : true } ) ;
225+ fs . writeFileSync (
226+ path . join ( sourceRoot , "auth-presence.js" ) ,
227+ "module.exports.hasAnyMatrixAuth = () => true;\n" ,
228+ "utf8" ,
229+ ) ;
230+ fs . writeFileSync (
231+ path . join ( builtRoot , "auth-presence.js" ) ,
232+ "module.exports.hasAnyMatrixAuth = () => false;\n" ,
233+ "utf8" ,
234+ ) ;
235+ isBundledSourceOverlayPathMock . mockImplementation (
236+ ( { sourcePath } : { sourcePath : string } ) => path . resolve ( sourcePath ) === extensionsRoot ,
237+ ) ;
238+
239+ listChannelCatalogEntriesMock . mockReturnValue ( [
240+ {
241+ pluginId : "matrix" ,
242+ origin : "bundled" ,
243+ rootDir : sourceRoot ,
244+ channel : {
245+ id : "matrix" ,
246+ persistedAuthState : {
247+ specifier : "./auth-presence" ,
248+ exportName : "hasAnyMatrixAuth" ,
249+ } ,
250+ } ,
251+ } satisfies PluginChannelCatalogEntry ,
252+ ] ) ;
253+
254+ expect (
255+ hasBundledChannelPackageState ( {
256+ metadataKey : "persistedAuthState" ,
257+ channelId : "matrix" ,
258+ cfg : { } ,
259+ } ) ,
260+ ) . toBe ( true ) ;
261+ } ) ;
262+
217263 it ( "tries dist-runtime package-state probes before falling back to source" , ( ) => {
218264 const root = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-package-state-runtime-" ) ) ;
219265 tempDirs . push ( root ) ;
0 commit comments