@@ -57,6 +57,15 @@ process.exit(0);
5757 return mockCodexPath ;
5858}
5959
60+ async function pathExists ( targetPath : string ) : Promise < boolean > {
61+ try {
62+ await fs . access ( targetPath ) ;
63+ return true ;
64+ } catch {
65+ return false ;
66+ }
67+ }
68+
6069describe ( "runSession" , ( ) => {
6170 it ( "shows an empty compact prior preview when no continuity audit history exists" , async ( ) => {
6271 const repoDir = await tempDir ( "cam-session-empty-history-repo-" ) ;
@@ -576,6 +585,65 @@ describe("runSession", () => {
576585 expect ( statusPayload . localLocation . exists ) . toBe ( false ) ;
577586 } , 30_000 ) ;
578587
588+ it ( "keeps session load and status read-only on an uninitialized project" , async ( ) => {
589+ const homeDir = await tempDir ( "cam-session-readonly-home-" ) ;
590+ const projectDir = await tempDir ( "cam-session-readonly-project-" ) ;
591+ const memoryRootParent = await tempDir ( "cam-session-readonly-memory-parent-" ) ;
592+ const memoryRoot = path . join ( memoryRootParent , "memory-root" ) ;
593+ await initRepo ( projectDir ) ;
594+
595+ await writeProjectConfig (
596+ projectDir ,
597+ configJson ( ) ,
598+ { autoMemoryDirectory : memoryRoot }
599+ ) ;
600+
601+ const statusResult = runCli ( projectDir , [ "session" , "status" , "--json" ] , {
602+ env : { HOME : homeDir }
603+ } ) ;
604+ const loadResult = runCli ( projectDir , [ "session" , "load" , "--json" , "--print-startup" ] , {
605+ env : { HOME : homeDir }
606+ } ) ;
607+
608+ expect ( statusResult . exitCode , statusResult . stderr ) . toBe ( 0 ) ;
609+ expect ( loadResult . exitCode , loadResult . stderr ) . toBe ( 0 ) ;
610+ expect ( JSON . parse ( statusResult . stdout ) ) . toMatchObject ( {
611+ projectLocation : {
612+ exists : false
613+ } ,
614+ localLocation : {
615+ exists : false
616+ } ,
617+ latestContinuityAuditEntry : null ,
618+ latestContinuityDiagnostics : null ,
619+ pendingContinuityRecovery : null ,
620+ startup : {
621+ sourceFiles : [ ] ,
622+ candidateSourceFiles : [ ] ,
623+ continuityMode : "startup" ,
624+ continuityProvenanceKind : "temporary-continuity"
625+ }
626+ } ) ;
627+ expect ( JSON . parse ( loadResult . stdout ) ) . toMatchObject ( {
628+ projectLocation : {
629+ exists : false
630+ } ,
631+ localLocation : {
632+ exists : false
633+ } ,
634+ latestContinuityAuditEntry : null ,
635+ latestContinuityDiagnostics : null ,
636+ pendingContinuityRecovery : null ,
637+ startup : {
638+ sourceFiles : [ ] ,
639+ candidateSourceFiles : [ ] ,
640+ continuityMode : "startup" ,
641+ continuityProvenanceKind : "temporary-continuity"
642+ }
643+ } ) ;
644+ expect ( await pathExists ( memoryRoot ) ) . toBe ( false ) ;
645+ } , 30_000 ) ;
646+
579647 it ( "refresh replaces only the selected scope" , async ( ) => {
580648 const repoDir = await tempDir ( "cam-session-refresh-scope-repo-" ) ;
581649 const memoryRoot = await tempDir ( "cam-session-refresh-scope-memory-" ) ;
0 commit comments