@@ -180,6 +180,7 @@ async function verifyDoctorRepair(root: string) {
180180 const stateDir = path . join ( root , ".openclaw" ) ;
181181 const configPath = path . join ( stateDir , "openclaw.json" ) ;
182182 const sessionFile = await seedBrokenSession ( stateDir ) ;
183+ const originalTranscript = await fs . readFile ( sessionFile ) ;
183184 await fs . mkdir ( path . dirname ( configPath ) , { recursive : true } ) ;
184185 await fs . writeFile ( configPath , JSON . stringify ( { plugins : { enabled : false } } , null , 2 ) ) ;
185186
@@ -240,10 +241,17 @@ async function verifyDoctorRepair(root: string) {
240241 ) ,
241242 "doctor repair left runtime context in active transcript" ,
242243 ) ;
243- const backups = ( await fs . readdir ( path . dirname ( sessionFile ) ) ) . filter ( ( name ) =>
244- name . includes ( ".pre-doctor-branch-repair-" ) ,
244+ const archiveDir = path . join ( stateDir , "agents" , "main" , "session-sqlite-import-archive" ) ;
245+ const archives = ( await fs . readdir ( archiveDir ) ) . filter ( ( name ) =>
246+ name . includes ( `.${ path . basename ( sessionFile ) } .imported-` ) ,
245247 ) ;
246- assert ( backups . length === 1 , `expected one doctor backup, got ${ backups . length } ` ) ;
248+ const [ archiveName ] = archives ;
249+ assert (
250+ archives . length === 1 && archiveName ,
251+ `expected one doctor transcript archive, got ${ archives . length } ` ,
252+ ) ;
253+ const archivedTranscript = await fs . readFile ( path . join ( archiveDir , archiveName ) ) ;
254+ assert ( archivedTranscript . equals ( originalTranscript ) , "doctor changed the archived original" ) ;
247255}
248256
249257async function main ( ) {
0 commit comments