remove checkpoint_version read gates · Entire

remove checkpoint_version read gates

bc49bc8→main·

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

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
}
}
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
}
}
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.