Skip to content

Commit 2e9e766

Browse files
committed
Address copilot comments
Entire-Checkpoint: 614e7faf1c5f
1 parent c42959d commit 2e9e766

2 files changed

Lines changed: 27 additions & 16 deletions

File tree

cmd/entire/cli/attach.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ func runAttach(ctx context.Context, w io.Writer, sessionID string, agentName typ
183183
return fmt.Errorf("failed to write checkpoint: %w", err)
184184
}
185185
}
186-
// IsCheckpointsV2Enabled is true whenever checkpoints_version is 2, so this
187-
// covers both the v2 and dual-write paths. Only v2 propagates the error.
186+
// IsCheckpointsV2Enabled is true whenever v2 writes are enabled, including
187+
// both v2-only mode (checkpoints_version == 2) and dual-write mode. Only
188+
// v2-only mode propagates the error.
188189
if settings.IsCheckpointsV2Enabled(logCtx) {
189190
if err := writeAttachCheckpointV2(logCtx, repo, writeOpts); err != nil {
190191
if v2 {

cmd/entire/cli/settings/settings.go

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,20 @@ func CheckpointsVersion(ctx context.Context) int {
618618
if err != nil {
619619
return 1
620620
}
621-
return s.CheckpointsVersion()
621+
version := s.CheckpointsVersion()
622+
if s.StrategyOptions != nil {
623+
if configured, ok := s.StrategyOptions["checkpoints_version"]; ok {
624+
if _, supported := parseCheckpointsVersion(configured); !supported {
625+
checkpointsVersionWarningOnce.Do(func() {
626+
fmt.Fprintf(os.Stderr,
627+
"[entire] unsupported strategy_options.checkpoints_version %v detected in settings. Falling back to the default version (1).\n",
628+
configured,
629+
)
630+
})
631+
}
632+
}
633+
}
634+
return version
622635
}
623636

624637
// IsPushV2RefsEnabled checks if pushing v2 refs is enabled in settings.
@@ -736,33 +749,30 @@ func (s *EntireSettings) CheckpointsVersion() int {
736749
if !ok {
737750
return 1
738751
}
739-
740-
warnUnsupported := func(configured any) {
741-
checkpointsVersionWarningOnce.Do(func() {
742-
fmt.Fprintf(os.Stderr,
743-
"[entire] unsupported checkpoints version %v detected in settings. Falling back to the default version (1).\n",
744-
configured,
745-
)
746-
})
752+
version, ok := parseCheckpointsVersion(val)
753+
if ok {
754+
return version
747755
}
756+
return 1
757+
}
748758

759+
func parseCheckpointsVersion(val any) (int, bool) {
749760
v, ok := val.(int)
750761
if ok && (v == 1 || v == 2) {
751-
return v
762+
return v, true
752763
}
753764
floatV, ok := val.(float64)
754765
if ok && (floatV == 1 || floatV == 2) {
755-
return int(floatV)
766+
return int(floatV), true
756767
}
757768
stringV, ok := val.(string)
758769
if ok {
759770
parsed, err := strconv.Atoi(stringV)
760771
if err == nil && (parsed == 1 || parsed == 2) {
761-
return parsed
772+
return parsed, true
762773
}
763774
}
764-
warnUnsupported(val)
765-
return 1
775+
return 1, false
766776
}
767777

768778
// IsPushV2RefsEnabled checks if pushing v2 refs is enabled.

0 commit comments

Comments
 (0)