fail resume on unsupported checkpoint · Entire

fail resume on unsupported checkpoint

8a53e8f→main·

pfleidi·3w ago·2 files·+9 added/-16 removed

Return unsupported checkpoint-version errors instead of skipping them when selecting from multiple checkpoint IDs.

This nudges users to upgrade instead of resuming from a potentially older readable checkpoint.

Sessions

67f0307b2665View transcript

[?
Implement Checkpoint Policy Management SystemCodex·GPT-5.5·3 steps](/content/gh/entireio/cli/session/019ef111-70d5-7203-b653-e4834b8b92c0#timeline-67f0307b2665/index.html)

Changes

2

339 unmodified lines

340
341
342
343
343
344
345
346
348
349
350
351
347
348
349
350
5 unmodified lines

356
357
358
363
364
365
359
360
361

339 unmodified lines

// the checkpoint with the latest CreatedAt.
func resolveLatestCheckpoint(ctx context.Context, store checkpointInfoReader, checkpointIDs []id.CheckpointID) (*strategy.CheckpointInfo, bool, error) {
    infoMap := make(map[id.CheckpointID]strategy.CheckpointInfo, len(checkpointIDs))
    var unsupportedErr error
    for _, cpID := range checkpointIDs {
        metadata, readErr := readCheckpointInfoFromStore(ctx, store, cpID)
        if readErr != nil {
            if checkpointpolicy.IsUnsupportedVersion(readErr) {
                if unsupportedErr == nil {
                    unsupportedErr = readErr
                }
                continue
            }
            return nil, false, readErr
        }
        logging.Debug(ctx, "resolveLatestCheckpoint: checkpoint metadata read failed",
            slog.String("checkpoint_id", cpID.String()),
5 unmodified lines

}
    latest, found := strategy.ResolveLatestCheckpointFromMap(checkpointIDs, infoMap)
    if !found {
        if unsupportedErr != nil {
            return nil, false, unsupportedErr
        }
        return nil, false, nil
    }
    return &latest, true, nil
}

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

632 unmodified lines

633
634
635
636
636
637
638
639
11 unmodified lines

651
652
653
654
655
656
654
655
656
657
658
659
658
659
660
661
662
661
662
663
664
665

632 unmodified lines

}
}

func TestResolveLatestCheckpointSkipsUnsupportedCheckpointWhenReadableCheckpointExists(t *testing.T) {
func TestResolveLatestCheckpointReturnsUnsupportedWhenAnyCheckpointIsUnsupported(t *testing.T) {
    t.Parallel()

unsupportedID := id.MustCheckpointID("aaa111bbb222")
11 unmodified lines

},
    }

latest, found, err := resolveLatestCheckpoint(context.Background(), reader, []id.CheckpointID{unsupportedID, newID})
    if err != nil {
        t.Fatalf("resolveLatestCheckpoint() error = %v", err)
    _, found, err := resolveLatestCheckpoint(context.Background(), reader, []id.CheckpointID{unsupportedID, newID})
    if err == nil {
        t.Fatal("resolveLatestCheckpoint() error = nil, want unsupported version")
    }
    if !found {
        t.Fatal("resolveLatestCheckpoint() found = false")
    }
    if found {
        t.Fatal("resolveLatestCheckpoint() found = true")
    }
    if latest.CheckpointID != newID {
        t.Errorf("resolveLatestCheckpoint() = %s, want %s", latest.CheckpointID, newID)
    }
    if !checkpointpolicy.IsUnsupportedVersion(err) {
        t.Fatalf("resolveLatestCheckpoint() error = %v, want unsupported version", err)
    }
}

Mcmd/entire/cli/resume_test.go+8/-8