checkpoint resume: address PR review feedback · Entire
checkpoint resume: address PR review feedback
e4021a7→main·
pfleidi·1w ago·3 files·+12 added/-8 removed
Tighten the checkpoint-prefix shape gate: a ULID's leading timestamp character cannot exceed 7, so requiring [0-7] stops revision syntax like HEAD from shape-matching and triggering store lookups. Isolate git config env in the worktree-clash test, which shells out to the git CLI.
Sessions
01KX4BWWR8MB2SND1PY7E5QPD3View transcript
[?
Implement Checkpoint Resume CommandClaude Code·8 steps](/content/gh/entireio/cli/session/ba137a72-eaf9-443b-b868-49da78b39915#timeline-01KX4BWWR8MB2SND1PY7E5QPD3/index.html)
Changes
3
cmd/entire/cli
checkpoint/id
Mid.go+4/-3
Mid_test.go+3/-1
Mcheckpoint_resume_test.go+5/-4
45 unmodified lines
46
47
48
49
50
51
49
50
51
52
53
54
55
45 unmodified lines
// prefixShapeRegex matches strings shaped like a checkpoint ID or a prefix
// of one: 1-12 lowercase hex characters (legacy) or 1-26 Crockford base32
// characters (ULID). Kept next to Pattern/ulidPattern as a reminder to update
// them together when the ID formats change.
var prefixShapeRegex = regexp.MustCompile(`^(?:[0-9a-f]{1,12}|[0-9ABCDEFGHJKMNPQRSTVWXYZ]{1,26})$`)
// characters starting with 0-7 (a ULID's leading timestamp character cannot
// exceed 7, per isULID/ParseStrict). Kept next to Pattern/ulidPattern as a
// reminder to update them together when the ID formats change.
var prefixShapeRegex = regexp.MustCompile(`^(?:[0-9a-f]{1,12}|[0-7][0-9ABCDEFGHJKMNPQRSTVWXYZ]{0,25})$`)
// CouldBePrefix reports whether s is shaped like a checkpoint ID or a prefix
// of one. It is a cheap gate for callers deciding whether a free-form target
Mcmd/entire/cli/checkpoint/id/id.go+4/-3
319 unmodified lines
320
321
322
323
323
324
325
326
327
328
319 unmodified lines
{"abc123def456", true},
{"01HZXW5J8KQ2M3N4P5Q6R7S8T9", true},
{"01HZXW", true},
{"HEAD", true},
{"HEAD", false},
{"7ZZZZZ", true},
{"8ZZZZZ", false},
{"", false},
{"abc123def4567", false},
{"feature/foo", false},
Mcmd/entire/cli/checkpoint/id/id_test.go+3/-1
11 unmodified lines
12
13
14
15
16
17
18
122 unmodified lines
141
142
143
143
144
144
145
146
147
146
147
148
149
150
67 unmodified lines
218
219
220
221
222
223
224
11 unmodified lines
"github.com/entireio/cli/cmd/entire/cli/checkpoint"
"github.com/entireio/cli/cmd/entire/cli/checkpoint/id"
"github.com/entireio/cli/cmd/entire/cli/testutil"
"github.com/spf13/cobra"
"github.com/go-git/go-git/v6"
122 unmodified lines
}
}
// "HEAD" is shaped like a checkpoint prefix (Crockford ULID alphabet) and
// happens to also resolve via branchCommit's origin/<name> fallback (as
// "HEAD" resolves via branchCommit's origin/<name> fallback (as
// refs/remotes/origin/HEAD) in the old auto-detection order. With no local
// branch or checkpoint named "HEAD", it must fall through to commit
// resolution and resume the checkpoint referenced by HEAD's trailer.
// branch named "HEAD", it must fall through to commit resolution and resume
// the checkpoint referenced by HEAD's trailer.
func TestCheckpointResumeAuto_HeadResolvesAsCommit(t *testing.T) {
repo, w, head := setupCheckpointResumeRepo(t)
cpID := id.MustCheckpointID("abc123def456")
67 unmodified lines
// When the checkpoint's branch is checked out in another worktree, resume must
// point there instead of switching branches or restoring logs.
func TestCheckpointResume_WorktreeClash(t *testing.T) {
testutil.IsolateGitConfigEnv(t)
repo, w, baseHead := setupCheckpointResumeRepo(t)
cpID := id.MustCheckpointID("abc123def456")
writeCommittedResumeCheckpoint(t, repo, cpID, "session-clash", time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC))
Mcmd/entire/cli/checkpoint_resume_test.go+5/-4