# remove checkpoint\_version read gates

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

pfleidi·2w ago·11 files·+4 added/-359 removed

Drop the EnsureCanReadVersion gates at resume/explain/rewind/export and
the unreachable IsUnsupportedVersion error branches behind them. The
gates were forward-compat tripwires for checkpoint formats that never
shipped; checkpoint\_version is a pure label nothing dispatches on.

Also drop two ReadCheckpoint calls that existed only to feed the gate —
ReadRawSessionLogForCheckpoint already reads the checkpoint itself.

## Sessions

be8f0bd2169eView transcript

## Changes

11

- cmd/entire/cli
  - Dcheckpoint\_policy\_read\_test.go-44
  - checkpointpolicy
    - Dversion.go-45
  - Mexplain.go-5
  - Mexplain\_export.go-9
  - Mexplain\_export\_test.go-86
  - Mexplain\_test.go-18
  - Mresume.go+1/-32
  - Mresume\_test.go-95
  - Mrewind.go+2/-17
  - strategy
    - Mmanual\_commit\_rewind.go-5
- docs/architecture
  - Msessions-and-checkpoints.md+1/-3

```go
package cli

import (
	"context"
	"testing"

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

func TestReadCheckpointInfoFromStoreRejectsUnsupportedCheckpointVersion(t *testing.T) {
	t.Parallel()

cpID := id.MustCheckpointID("111111111111")
	_, err := readCheckpointInfoFromStore(context.Background(), checkpointInfoPolicyStub{
		summary: &checkpoint.CheckpointSummary{
			CheckpointID:      cpID,
			CheckpointVersion: "refs-v2",
		},
	}, cpID)

require.EqualError(t, err, `checkpoint 111111111111 uses unsupported checkpoint_version "refs-v2": not read-supported by this Entire CLI`)
}

type checkpointInfoPolicyStub struct {
	summary *checkpoint.CheckpointSummary
}

func (s checkpointInfoPolicyStub) Read(context.Context, id.CheckpointID) (*checkpoint.CheckpointSummary, error) {
	return s.summary, nil
}

func (s checkpointInfoPolicyStub) List(context.Context) ([]checkpoint.CheckpointInfo, error) {
	return nil, nil
}
}

func (s checkpointInfoPolicyStub) ReadSessionContent(context.Context, id.CheckpointID, int) (*checkpoint.SessionContent, error) {
	return nil, checkpoint.ErrCheckpointNotFound
}

func (s checkpointInfoPolicyStub) ReadSessionMetadata(context.Context, id.CheckpointID, int) (*checkpoint.Metadata, error) {
	return nil, checkpoint.ErrCheckpointNotFound
}
}
```

```go
package checkpointpolicy

import (
	"errors"
	"fmt"

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

var errUnsupportedVersion = errors.New("not read-supported by this Entire CLI")

func IsUnsupportedVersion(err error) bool {
	return errors.Is(err, errUnsupportedVersion)
}

func EnsureCanReadVersion(checkpointID, version string) error {
	if version == "" {
		version = checkpoint.CheckpointVersionBranchV1
	}

format, err := ParseFormat(version)
	if err != nil {
		return fmt.Errorf("checkpoint %s has invalid checkpoint_version %q: %w", checkpointID, version, err)
	}
	if !CanRead(format) {
		return unsupportedVersionError{
			CheckpointID: checkpointID,
			Version:      version,
		}
	}
	return nil
}

type unsupportedVersionError struct {
	CheckpointID string
	Version      string
}

func (e unsupportedVersionError) Error() string {
	return fmt.Sprintf("checkpoint %s uses unsupported checkpoint_version %q: %v", e.CheckpointID, e.Version, errUnsupportedVersion)
}

func (e unsupportedVersionError) Unwrap() error {
	return errUnsupportedVersion
}
}
```

```go
func TestLoadCheckpointForExplainRejectsUnsupportedCheckpointVersion(t *testing.T) {
	repo := setupExportRepo(t)

cpID := id.MustCheckpointID("bbbbccccdddd")
	writeCheckpointForExport(t, repo, cpID, checkpoint.WriteOptions{
		SessionID:  "session-explain-unsupported",
		Transcript: redact.AlreadyRedacted([]byte(`{"type":"user","message":{"content":[{"type":"text","text":"hi"}]}}` + "\n")),
	})
	rewriteExportCheckpointVersionToRefsV2(t, repo, cpID)

lookup, err := newExplainCheckpointLookup(context.Background())
	require.NoError(t, err)
	defer lookup.Close()

_, _, err = loadCheckpointForExplain(context.Background(), lookup, cpID)
	require.ErrorContains(t, err, `checkpoint bbbbccccdddd uses unsupported checkpoint_version "refs-v2"`)
}
```

### Checkpoint ID Linking

User-driven commands warn when the local policy indicates the CLI should be
upgraded. Explicit checkpoint-data writers such as `entire session attach`, `entire checkpoint explain --generate`, and `entire import <agent>` fail when
the local policy cannot be satisfied. Commands that need to decode checkpoint
contents, such as `entire checkpoint explain` and `entire session resume`, fail
when the target checkpoint uses an unsupported `checkpoint_version`.
