Skip to content

[WIP] clean up the c1z interfaces#986

Open
kans wants to merge 1 commit into
mainfrom
kans/cleaner-c1z-interfaces
Open

[WIP] clean up the c1z interfaces#986
kans wants to merge 1 commit into
mainfrom
kans/cleaner-c1z-interfaces

Conversation

@kans

@kans kans commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@kans kans requested a review from a team June 25, 2026 17:23
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

General PR Review: [WIP] clean up the c1z interfaces

Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 23465ff7a59e.
Review mode: full
View review run

Review Summary

Scanned the full PR diff for security and correctness. This PR introduces explicit OpenStore/CreateStore lifecycle constructors (deprecating the open-or-create NewStore/NewC1ZFile/C1File), adds EngineLifecycleDriver with SQLite/Pebble implementations, a new engine-neutral GenerateSyncDiffFromFiles and a SanitizeResumableCheckpointWriter capability, and migrates all non-test call sites. New behavior defaults to old behavior, exported additions are additive, and the changes are covered by new tests (open_create_test.go, diff_files_test.go, sanitize_checkpoint_test.go, engine_registry_test.go). The prior review's wrapOpenExistingStoreError finding is now addressed: isStoreCorruptionError uses a corruption allow-list (ErrInvalidFile, EOF, v3 magic/truncation, zstd decode errors) and returns transient I/O errors unwrapped, so they no longer satisfy errors.Is(err, ErrStoreCorrupt).

Security Issues

None found.

Correctness Issues

None found.

Suggestions

  • pkg/sync/syncer.go:2547-2553OpenStore ignores WithEngine and opens by on-disk format, so a resume into an existing SQLite file with storageEngine == EnginePebble no longer auto-converts to Pebble the way NewStore did. Likely intended (safer for resume), but a silent default change worth confirming. (low confidence)
Prompt for AI agents
Verify each finding against the current code and only fix it if needed.

## Suggestions

In `pkg/sync/syncer.go`:
- Around line 2547-2553: The migration from dotc1z.NewStore to OpenStore/CreateStore
  changes engine-selection behavior for the resume path. Previously NewStore ->
  selectStoreDriver would auto-convert an existing writable V1/SQLite file to Pebble
  in place when WithEngine(EnginePebble) was set. OpenStore deliberately ignores
  WithEngine and opens by the file's on-disk format, so resuming into an existing
  SQLite file while storageEngine == EnginePebble now keeps it SQLite instead of
  converting. Confirm this is intended; if downstream relied on auto-convert-on-open,
  either document the change as a deliberate compatibility break or restore an explicit
  conversion step for this path.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

Comment thread pkg/dotc1z/engine_registry.go Outdated
Comment thread pkg/dotc1z/engine_registry.go
@kans kans force-pushed the kans/cleaner-c1z-interfaces branch from 363a37e to acd49f1 Compare June 25, 2026 18:34
Comment thread pkg/synccompactor/compactor.go

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

@kans kans force-pushed the kans/cleaner-c1z-interfaces branch from acd49f1 to 4a090e6 Compare June 25, 2026 20:03
Comment thread pkg/dotc1z/engine_registry.go
@kans kans force-pushed the kans/cleaner-c1z-interfaces branch 2 times, most recently from 3469dd1 to 126ebb7 Compare June 26, 2026 20:02
Comment thread pkg/dotc1z/engine_registry.go

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking issues found — see review comments.

@kans kans force-pushed the kans/cleaner-c1z-interfaces branch from 126ebb7 to 2752d22 Compare June 26, 2026 21:02
Comment thread pkg/sync/syncer.go Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking issues found — see review comments.

@kans kans force-pushed the kans/cleaner-c1z-interfaces branch from 2752d22 to 939088a Compare June 29, 2026 15:35
if inferred == "" {

// Auto-select: any Pebble input → Pebble output.
if hasPebble {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: Mixed SQLite/Pebble inputs now resolve to Pebble output, and the doc above claims "SQLite inputs in a Pebble run are converted ... automatically; callers are not required to pre-convert." That holds only for the overlay path (compactPebble, which calls convertSQLiteInputToPebble). The fold path (compactPebbleFold) opens each input and uses enginepkg.AsEngine, returning "input is not a pebble c1z" for SQLite inputs — it has no conversion step. Because resolvePebbleMode selects fold purely on size, a mixed-input run that meets the fold size-gate will fail. Consider converting SQLite inputs in the fold path too, or gating fold off when any input is SQLite. (medium confidence)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking issues found — see review comments.

@kans kans force-pushed the kans/cleaner-c1z-interfaces branch 2 times, most recently from 2d59897 to aa3d331 Compare June 30, 2026 18:14

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking issues found — see review comments.

@kans kans force-pushed the kans/cleaner-c1z-interfaces branch from aa3d331 to c52a8e2 Compare June 30, 2026 18:20
Comment thread pkg/dotc1z/engine_registry.go Outdated
errors.Is(err, context.DeadlineExceeded) ||
errors.Is(err, syscall.ENOSPC) ||
os.IsPermission(err) {
return err

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: The OpenStore doc comment (line 202) promises transient I/O failures are "returned as-is and do not satisfy errors.Is(err, ErrStoreCorrupt)", but this allow-list only covers context cancellation, ENOSPC, and permission errors. Other genuinely transient failures (e.g. EMFILE/too-many-open-files, EIO, EROFS, temp-dir extraction failures) get wrapped as StoreCorruptError. A downstream caller that quarantines/deletes files on errors.Is(err, ErrStoreCorrupt) could destroy a valid c1z after a transient failure. Consider classifying as corrupt only for known decode errors (e.g. ErrInvalidFile, format/manifest read failures) rather than treating everything off the allow-list as corruption. (medium confidence)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking issues found — see review comments.

@kans kans force-pushed the kans/cleaner-c1z-interfaces branch from c52a8e2 to 0f00845 Compare June 30, 2026 18:35

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

@kans kans force-pushed the kans/cleaner-c1z-interfaces branch from 0f00845 to a62e1de Compare June 30, 2026 19:05
Comment thread pkg/sync/syncer.go
Comment on lines +2547 to +2553
// OpenStore is strict about existing files and requires a valid c1z.
// CreateStore accepts missing paths and zero-byte placeholders so callers
// can touch a target path before the first sync.
if stat, statErr := os.Stat(s.c1zPath); statErr == nil && stat.Size() > 0 {
store, err = dotc1z.OpenStore(ctx, s.c1zPath, storeOpts...)
} else {
store, err = dotc1z.CreateStore(ctx, s.c1zPath, storeOpts...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion (low confidence): Behavior change worth confirming. The old NewStore/selectStoreDriver path would auto-convert an existing V1/SQLite file to Pebble in place when WithEngine(EnginePebble) was set and the file was writable. OpenStore deliberately ignores WithEngine and opens by the on-disk format, so a resume into an existing SQLite file while storageEngine == EnginePebble now stays SQLite instead of converting. This is arguably the safer behavior for resume, but it is a silent default change for this code path — confirm it's intended and that no downstream relied on the auto-convert-on-open.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant