feat(import): deterministic per-turn checkpoint IDs · Entire

feat(import): deterministic per-turn checkpoint IDs

d658cc8→main·

computermode·3w ago·2 files·+39 added/-0 removed

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

Sessions

d027d2f148a0View transcript

[?
Implement Claude History Import FeatureClaude Code·Opus 4.8·3 steps](/content/gh/entireio/cli/session/897809d4-ecab-4dc6-aa21-97661cb62607#timeline-d027d2f148a0/index.html)

Changes

2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

// Package importclaude imports pre-existing Claude Code transcripts into Entire
// as read-only, commit-less ("orphaned") checkpoints on the local-only
// entire/imports/v1 ref.
package importclaude

import (
    "crypto/sha256"
    "encoding/hex"

"github.com/entireio/cli/cmd/entire/cli/checkpoint/id"
)

// DeriveCheckpointID produces a stable 12-hex checkpoint ID for an imported
// turn. Re-importing the same (sessionID, turnUUID) yields the same ID, which
// is how import stays idempotent.
func DeriveCheckpointID(sessionID, turnUUID string) id.CheckpointID {
    sum := sha256.Sum256([]byte(sessionID + "/" + turnUUID))
    hexID := hex.EncodeToString(sum[:6]) // 6 bytes = 12 lowercase hex chars
    return id.MustCheckpointID(hexID)
}

Acmd/entire/cli/importclaude/id.go+20

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

package importclaude

import "testing"

func TestDeriveCheckpointID_StableAndDistinct(t *testing.T) {
    t.Parallel()
    a := DeriveCheckpointID("sess", "turn-1")
    b := DeriveCheckpointID("sess", "turn-1")
    c := DeriveCheckpointID("sess", "turn-2")
    if a != b {
        t.Errorf("not deterministic: %s != %s", a, b)
    }
    if a == c {
        t.Errorf("collision across turns: %s == %s", a, c)
    }
    if a.IsEmpty() {
        t.Error("derived id is empty")
    }
}

Acmd/entire/cli/importclaude/id_test.go+19