# Return checkpoint policy errors verbatim

`84957f8`→[main](/content/gh/entireio/cli/commits/main/index.html)·  pfleidi·3w ago·7 files·+17 added/-10 removed

Address review feedback on the checkpoint format compatibility work.

Make unsupportedVersionError a value-based error wrapping a package sentinel, and detect it with errors.Is instead of errors.As. Drop the no-op fmt.Errorf("%w", err) wraps at every EnsureCanReadVersion call site so the clean, purpose-built policy message reaches the user.

Add checkpointpolicy to wrapcheck's ignore-package-globs, mirroring the existing coreapi entry: the policy error is already user-facing and is classified by callers via IsUnsupportedVersion, so wrapping would only obscure it.

## Sessions

e1760e4dd114View transcript

## Changes

7

- M.golangci.yaml+6

- cmd/entire/cli

- checkpointpolicy

- Mversion.go+5/-4

- Mexplain.go+1/-1

- Mexplain_export.go+2/-2

- Mresume.go+1/-1

- Mrewind.go+1/-1

- strategy

- Mmanual_commit_rewind.go+1/-1

```
87 unmodified lines

87 unmodified lines

# RFC 7807 problem detail via errors.As. Per-call-site wrapping would
      # only be unwrapped again, so the command closures return coreapi
      # errors verbatim.
      #
      # checkpointpolicy.EnsureCanReadVersion already returns a clean,
      # user-facing message (including the checkpoint ID and version), and
      # callers classify it via IsUnsupportedVersion. Wrapping would obscure
      # that purpose-built message, so call sites return it verbatim.
      ignore-package-globs:
        - github.com/entireio/cli/internal/coreapi
        - github.com/entireio/cli/cmd/entire/cli/checkpointpolicy
    forbidigo:
      analyze-types: true
      forbid:
```

M.golangci.yaml+6

```
6 unmodified lines

7
8
9
10
11
12
11
12
13
14
15
16
6 unmodified lines

23
24
25
25
26
27
28
28
29
30
31
32

6 unmodified lines

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

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

func IsUnsupportedVersion(err error) bool {
	var unsupported *unsupportedVersionError
	return errors.As(err, &unsupported)
	return errors.Is(err, errUnsupportedVersion)
}

func EnsureCanReadVersion(checkpointID, version string) error {
6 unmodified lines

return fmt.Errorf("checkpoint %s has invalid checkpoint_version %q: %w", checkpointID, version, err)
	}
	if !CanRead(format) {
		return &unsupportedVersionError{
		return unsupportedVersionError{
			CheckpointID: checkpointID,
			Version:      version,
			Err:          errors.New("not read-supported by this Entire CLI"),
			Err:          errUnsupportedVersion,
		}
	}
	return nil
}
```

Mcmd/entire/cli/checkpointpolicy/version.go+5/-4

```
755 unmodified lines

756
757
758
759
759
760
761
762

755 unmodified lines

return nil, nil, fmt.Errorf("failed to read checkpoint: %w", err)
	}
	if err := checkpointpolicy.EnsureCanReadVersion(cpID.String(), summary.CheckpointVersion); err != nil {
		return nil, nil, fmt.Errorf("%w", err)
		return nil, nil, err
	}

content, contentErr := checkpoint.ReadLatestSessionContent(ctx, store, cpID, summary)
```

Mcmd/entire/cli/explain.go+1/-1

```
266 unmodified lines

267
268
269
270
270
271
272
273
90 unmodified lines

364
365
366
367
367
368
369
370

266 unmodified lines

return fmt.Errorf("failed to read checkpoint: %w", err)
	}
	if err := checkpointpolicy.EnsureCanReadVersion(cpID.String(), summary.CheckpointVersion); err != nil {
		return fmt.Errorf("%w", err)
		return err
	}

idx, err := resolveSessionIndex(summary, opts.sessionIndex)
90 unmodified lines

envelope, failedSessions := buildCheckpointJSONEnvelope(ctx, store, summary, cpID)
```

Mcmd/entire/cli/explain_export.go+2/-2

```
368 unmodified lines

369
370
371
372
372
373
374
375

368 unmodified lines

return nil, fmt.Errorf("read checkpoint: %w", err)
	}
	if err := checkpointpolicy.EnsureCanReadVersion(checkpointID.String(), summary.CheckpointVersion); err != nil {
		return nil, fmt.Errorf("%w", err)
		return nil, err
	}
	info := &strategy.CheckpointInfo{
		CheckpointID:     checkpointID,
```

Mcmd/entire/cli/resume.go+1/-1

```
733 unmodified lines

734
735
736
737
737
738
739
740

733 unmodified lines

return "", fmt.Errorf("failed to read checkpoint: %w", err)
	}
	if err := checkpointpolicy.EnsureCanReadVersion(cpID.String(), summary.CheckpointVersion); err != nil {
		return "", fmt.Errorf("%w", err)
		return "", err
	}

logContent, returnedSessionID, err := checkpoint.ReadRawSessionLogForCheckpoint(ctx, stores.Persistent, cpID)
```

Mcmd/entire/cli/rewind.go+1/-1

```
652 unmodified lines

653
654
655
656
656
657
658
659

652 unmodified lines

return nil, fmt.Errorf("failed to read checkpoint: %w", err)
	}
	if err := checkpointpolicy.EnsureCanReadVersion(point.CheckpointID.String(), summary.CheckpointVersion); err != nil {
		return nil, fmt.Errorf("%w", err)
		return nil, err
	}

// Get worktree root for agent session directory lookup
```
