Skip to content

fix(encode-db): write valid snapshots safely - #90

Merged
corylanou merged 3 commits into
mainfrom
issue-81-encode-db-writes-a-version-1-header-the-library-itself-rejec
Aug 12, 2026
Merged

fix(encode-db): write valid snapshots safely#90
corylanou merged 3 commits into
mainfrom
issue-81-encode-db-writes-a-version-1-header-the-library-itself-rejec

Conversation

@corylanou

Copy link
Copy Markdown
Collaborator

Summary

  • encode database snapshots with the current LTX version
  • atomically replace destination files while rejecting input/output aliases and preserving existing output on failure
  • add command-level round-trip and file-safety regression coverage

Test Plan

  • go test ./... -count=1
  • go vet ./...
  • go build ./cmd/ltx
  • encode a real SQLite database and verify the generated snapshot with the CLI

Fixes #81
Fixes #87

Use the current in-memory format version and atomically replace output
files. Reject aliased input/output paths and preserve existing output on
failure.

Add command-level round-trip and safety regression coverage.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af5b0aadb7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/ltx/encode_db.go Outdated
Keep CreateTemp's restrictive mode for new snapshots so chmod cannot
bypass umask protections. Restore the recorded mode only when replacing
an existing destination.

Add coverage for secure new files and existing mode preservation.
@corylanou
corylanou merged commit 5fe9bd7 into main Aug 12, 2026
2 checks passed
@corylanou
corylanou deleted the issue-81-encode-db-writes-a-version-1-header-the-library-itself-rejec branch August 12, 2026 16:13
corylanou added a commit that referenced this pull request Aug 12, 2026
The command test arrived with #90 while this branch was in flight. On main
ltx.Version is 3 so it passed; here encryption raises the constant to 4
while unencrypted output correctly stays v3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants