@@ -44,6 +44,18 @@ describe("config observe recovery", () => {
4444 gateway : { mode : "local" } ,
4545 channels : { telegram : { enabled : true , dmPolicy : "pairing" , groupPolicy : "allowlist" } } ,
4646 } ;
47+ const recoverableCoreConfig = {
48+ meta : { lastTouchedVersion : "2026.4.22" } ,
49+ update : { channel : "beta" } ,
50+ gateway : { mode : "local" as const } ,
51+ } ;
52+ const largeRecoverableCoreConfig = {
53+ ...recoverableCoreConfig ,
54+ gateway : {
55+ ...recoverableCoreConfig . gateway ,
56+ trustedProxies : Array . from ( { length : 60 } , ( _ , index ) => `192.0.2.${ index } ` ) ,
57+ } ,
58+ } ;
4759
4860 async function withSuiteHome < T > ( fn : ( home : string ) => Promise < T > ) : Promise < T > {
4961 const home = path . join ( fixtureRoot , `case-${ homeCaseId ++ } ` ) ;
@@ -176,14 +188,23 @@ describe("config observe recovery", () => {
176188 ) {
177189 const configPath = path . join ( home , ".openclaw" , "openclaw.json" ) ;
178190 const error = vi . fn ( ) ;
191+ // Keep recovery validation out of host/workspace plugin state. Preserve the
192+ // caller's env identity because rollback tests inspect that exact object.
193+ const env = options . env ?? ( { } as NodeJS . ProcessEnv ) ;
194+ env . HOME ??= home ;
195+ env . USERPROFILE ??= home ;
196+ env . OPENCLAW_CONFIG_PATH ??= configPath ;
197+ env . OPENCLAW_STATE_DIR ??= path . join ( home , ".openclaw" ) ;
198+ env . OPENCLAW_DISABLE_BUNDLED_PLUGINS ??= "1" ;
199+ env . VITEST ??= "true" ;
179200 return {
180201 configPath,
181202 warn,
182203 error,
183204 io : createConfigIO ( {
184205 fs,
185206 json5 : JSON5 ,
186- env : options . env ?? ( { } as NodeJS . ProcessEnv ) ,
207+ env,
187208 homedir : ( ) => home ,
188209 configPath,
189210 logger : { warn, error } ,
@@ -456,17 +477,7 @@ describe("config observe recovery", () => {
456477 await withSuiteHome ( async ( home ) => {
457478 const { io, configPath, warn } = createTestConfigIO ( home ) ;
458479 const auditPath = path . join ( home , ".openclaw" , "logs" , "config-audit.jsonl" ) ;
459- await seedConfigBackup ( configPath , {
460- ...recoverableTelegramConfig ,
461- channels : {
462- telegram : {
463- enabled : true ,
464- dmPolicy : "pairing" ,
465- groupPolicy : "allowlist" ,
466- allowFrom : Array . from ( { length : 60 } , ( _ , index ) => `telegram-user-${ index } ` ) ,
467- } ,
468- } ,
469- } ) ;
480+ await seedConfigBackup ( configPath , largeRecoverableCoreConfig ) ;
470481 const clobbered = await writeConfigRaw ( configPath , {
471482 meta : { lastTouchedVersion : "2026.5.28" } ,
472483 } ) ;
@@ -489,7 +500,7 @@ describe("config observe recovery", () => {
489500 it ( "loadConfig auto-restores tiny valid clobbers before using defaults" , async ( ) => {
490501 await withSuiteHome ( async ( home ) => {
491502 const { io, configPath, warn } = createTestConfigIO ( home ) ;
492- await seedConfigBackup ( configPath , recoverableTelegramConfig ) ;
503+ await seedConfigBackup ( configPath , recoverableCoreConfig ) ;
493504 await writeConfigRaw ( configPath , {
494505 meta : { lastTouchedVersion : "2026.5.28" } ,
495506 } ) ;
@@ -515,7 +526,7 @@ describe("config observe recovery", () => {
515526 await withSuiteHome ( async ( home ) => {
516527 const env = { } as NodeJS . ProcessEnv ;
517528 const { io, configPath } = createTestConfigIO ( home , vi . fn ( ) , { env } ) ;
518- await seedConfigBackup ( configPath , recoverableTelegramConfig ) ;
529+ await seedConfigBackup ( configPath , recoverableCoreConfig ) ;
519530 await writeConfigRaw ( configPath , {
520531 meta : { lastTouchedVersion : "2026.5.28" } ,
521532 env : { vars : { OPENCLAW_CLOBBER_ONLY : "bad" } } ,
@@ -532,7 +543,7 @@ describe("config observe recovery", () => {
532543 await withSuiteHome ( async ( home ) => {
533544 const env = { } as NodeJS . ProcessEnv ;
534545 const { io, configPath } = createTestConfigIO ( home , vi . fn ( ) , { env } ) ;
535- await seedConfigBackup ( configPath , recoverableTelegramConfig ) ;
546+ await seedConfigBackup ( configPath , recoverableCoreConfig ) ;
536547 await writeConfigRaw ( configPath , {
537548 meta : { lastTouchedVersion : "2026.5.28" } ,
538549 env : { vars : { OPENCLAW_CLOBBER_ONLY : "bad" } } ,
@@ -549,7 +560,7 @@ describe("config observe recovery", () => {
549560 await withSuiteHome ( async ( home ) => {
550561 const { io, configPath } = createTestConfigIO ( home , vi . fn ( ) , { observe : false } ) ;
551562 const auditPath = path . join ( home , ".openclaw" , "logs" , "config-audit.jsonl" ) ;
552- await seedConfigBackup ( configPath , recoverableTelegramConfig ) ;
563+ await seedConfigBackup ( configPath , recoverableCoreConfig ) ;
553564 const clobbered = await writeConfigRaw ( configPath , {
554565 meta : { lastTouchedVersion : "2026.5.28" } ,
555566 } ) ;
@@ -567,17 +578,7 @@ describe("config observe recovery", () => {
567578 await withSuiteHome ( async ( home ) => {
568579 const { io, configPath } = createTestConfigIO ( home ) ;
569580 const auditPath = path . join ( home , ".openclaw" , "logs" , "config-audit.jsonl" ) ;
570- const includedConfig = {
571- ...recoverableTelegramConfig ,
572- channels : {
573- telegram : {
574- enabled : true ,
575- dmPolicy : "pairing" ,
576- groupPolicy : "allowlist" ,
577- allowFrom : Array . from ( { length : 60 } , ( _ , index ) => `telegram-user-${ index } ` ) ,
578- } ,
579- } ,
580- } ;
581+ const includedConfig = largeRecoverableCoreConfig ;
581582 await seedConfigBackup ( configPath , includedConfig ) ;
582583 await fsp . writeFile (
583584 path . join ( path . dirname ( configPath ) , "base.json5" ) ,
@@ -747,7 +748,7 @@ describe("config observe recovery", () => {
747748 it ( "does not auto-restore backup candidates rejected by the caller" , async ( ) => {
748749 await withSuiteHome ( async ( home ) => {
749750 const { io, configPath } = createTestConfigIO ( home ) ;
750- await seedConfigBackup ( configPath , recoverableTelegramConfig ) ;
751+ await seedConfigBackup ( configPath , recoverableCoreConfig ) ;
751752 const clobbered = await writeConfigRaw ( configPath , {
752753 meta : { lastTouchedVersion : "2026.5.28" } ,
753754 } ) ;
@@ -805,11 +806,8 @@ describe("config observe recovery", () => {
805806 const { io, configPath } = createTestConfigIO ( home ) ;
806807 await seedConfigBackup ( configPath , {
807808 meta : { lastTouchedVersion : "9999.1.1" } ,
808- channels : {
809- telegram : {
810- enabled : true ,
811- allowFrom : Array . from ( { length : 60 } , ( _ , index ) => `telegram-user-${ index } ` ) ,
812- } ,
809+ gateway : {
810+ trustedProxies : largeRecoverableCoreConfig . gateway . trustedProxies ,
813811 } ,
814812 } ) ;
815813 const clobbered = await writeConfigRaw ( configPath , { } ) ;
0 commit comments