openai / openai/codex

[Windows App] Request to submit deferred migration line-ending checksum fix

Open
#38,528 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI windows-os
Dominant language
Rust
Stars
125k
Forks
19.5k
PR merge metrics
PR metrics pending

Description

Hello,

I have a reviewed and tested fix for the SQL migration CRLF/LF checksum issue tracked in #32643.

Root cause:

SQLx checksums the exact migration bytes embedded at compile time. Migration files checked out with CRLF (for example, on Windows with core.autocrlf=true) therefore produce different checksums than LF checkouts. Databases created by one build fail to open in another with:

migration N was previously applied but has been modified

This also breaks the Windows + WSL shared-Codex-home scenario tracked in #25216 (see #23777, #23841, #23848, #23863), where a WSL runtime must open a database created by a Windows build and vice versa.

Fix:

  • Canonicalizes runtime migrations to LF line endings on all platforms in runtime_migrator(), so embedded checksums no longer depend on checkout line-ending policy.
  • Adds repair_migration_line_ending_checksums(): when opening any runtime SQLite database, _sqlx_migrations rows whose checksum was computed from CRLF migration files are rewritten to the canonical LF checksum, so histories created by either build are accepted interchangeably.
  • Applies to all six runtime migrators (state, logs, goals, memories, queue, thread history).
  • Genuine migration drift is still rejected: the repair only rewrites rows that exactly match the CRLF form of the current migration.

Validation:

  • codex-state: 174/174 tests passed, including 4 new tests (LF invariant across all runtime migrators, CRLF→LF canonicalization, CRLF-applied history accepted after repair, LF-applied history unchanged)
  • scoped Clippy (just fix -p codex-state): clean
  • cargo fmt --check: clean
  • Change is limited to codex-rs/state (+205/-1 across 3 files)
Prepared patch

The fix is available in my fork:

GitHub currently blocks PR creation because only collaborators may open pull requests in this repository.

Could you please either:

  • invite jamespud as a collaborator with permission to open the PR, or
  • open the PR from the prepared fork branch?

Thank you.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the prepared fix on the fix/32643-state-migration-line-endings branch, limited to codex-rs/state and its runtime_migrator and repair_migration_line_ending_checksums entry points. Run the reported codex-state tests, scoped Clippy, and cargo fmt check; done means the prepared change can be submitted and the stated migration checksum cases pass without accepting genuine drift.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sqlite
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.