# fix(strategy): never flag imported sessions as orphaned in clean

`21fcaf5`→[main](/content/gh/entireio/cli/commits/main/index.html)·

computermode·1w ago·2 files·+49 added/-0 removed

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

## Sessions

01KX49VPTETHKDW2GD7PGCMMKYView transcript

[?\
Fix Imported Sessions Handling in CLIClaude Code·Opus 4.8·34 steps](/content/gh/entireio/cli/session/91fa7c44-6634-48ab-ae5f-d394502f50d5#timeline-01KX49VPTETHKDW2GD7PGCMMKY/index.html)

## Changes

2

- cmd/entire/cli/strategy

- Mcleanup.go+6

- Acleanup_imported_test.go+43

```
347 unmodified lines

348
349
350
351
352
353
354
355
356
357
358
359

347 unmodified lines

continue
 }

// Imported sessions are read-only and commit-less by design — no shadow
 // branch is ever expected. Never offer them for cleanup.
 if state.Kind == session.KindImported {
 continue
 }

// Check if session has checkpoints in committed checkpoint storage
 hasCheckpoints := sessionsWithCheckpoints[state.SessionID]
```

Mcmd/entire/cli/strategy/cleanup.go+6

```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

package strategy

import (
	"context"
	"testing"
	"time"

"github.com/entireio/cli/cmd/entire/cli/session"
	"github.com/entireio/cli/cmd/entire/cli/testutil"
)

func TestListOrphanedSessionStates_SkipsImported(t *testing.T) {
	// Not parallel: t.Chdir.
	dir := t.TempDir()
	testutil.InitRepo(t, dir)
	testutil.WriteFile(t, dir, "f.txt", "x")
	testutil.GitAdd(t, dir, "f.txt")
	testutil.GitCommit(t, dir, "init")
	t.Chdir(dir)

ctx := context.Background()
	store, err := session.NewStateStore(ctx)
	if err != nil {
		t.Fatalf("NewStateStore: %v", err)
	}
	old := time.Now().Add(-24 * time.Hour) // past sessionGracePeriod
	if err := store.Save(ctx, &session.State{
		SessionID: "imported-orphan", Kind: session.KindImported,
		Phase: session.PhaseEnded, StartedAt: old, EndedAt: &old,
	}); err != nil {
		t.Fatalf("save: %v", err)
	}

items, err := ListOrphanedSessionStates(ctx)
	if err != nil {
		t.Fatalf("ListOrphanedSessionStates: %v", err)
	}
	for _, it := range items {
		if it.ID == "imported-orphan" {
			t.Fatal("imported session was flagged as orphaned")
		}
	}
}
```

Acmd/entire/cli/strategy/cleanup_imported_test.go+43
