You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proposed fix: normalize Windows SQL migration line endings #32643
SQLx hashes the exact migration SQL bytes. Official Windows Codex builds have embedded CRLF migration files, while a Windows source checkout with core.autocrlf=false embeds LF files. A locally built binary can therefore reject a healthy database created by the official Windows package with:
migration 1 was previously applied but has been modified
The proposed fix canonicalizes runtime migrations to CRLF on Windows before SQLx executes or validates them. This makes Windows builds compatible with official Windows databases regardless of the developer checkout's line-ending configuration. It applies centrally to state, logs, goals, memories, and thread-history runtime migrators.
This addresses the native-Windows side of the migration checksum failures discussed in #23841, #23848, and #23863. Those reports also involve WSL processes opening the same Windows database; accepting both legacy LF and CRLF histories cross-platform may be a preferable broader policy. The attached patch is deliberately limited to compatibility with already-released Windows databases.
The CRLF hash exactly matched the live database. Read-only inspection and byte-level hashing confirmed that all 40 applied state migrations matched their CRLF forms. The database was not corrupt, and no migration-table rows were edited.
I've prepared a complete fix for this CRLF/LF migration checksum issue and would like to contribute it, but I'm unable to open a pull request because PRs in this repository are currently restricted to collaborators. Could a maintainer pull my branch (or invite me as a collaborator) to review it?
Canonicalizes runtime migrations to LF line endings on all platforms in runtime_migrator(), so embedded checksums no longer depend on the checkout's core.autocrlf / 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. Databases created by either CRLF or LF builds can then be opened interchangeably.
Applies to all six migrators (state, logs, goals, memories, queue, thread history) via the existing open_runtime_db path.
This goes beyond the Windows-only approach described in the issue: it also covers the WSL/Linux side opening a database created by a Windows build (and vice versa), which is exactly the shared-home scenario tracked in #25216 and reported in #23777 / #23841 / #23848 / #23863.
Verification
just test -p codex-state: 174 passed, including 4 new tests (LF invariant across all runtime migrators, CRLF→LF canonicalization, CRLF-applied history accepted after repair, LF-applied history unchanged).
just fix -p codex-state: clean (clippy).
cargo fmt --check: clean.
Changes are limited to codex-rs/state/src/migrations.rs, codex-rs/state/src/sqlite.rs, and codex-rs/state/src/migrations_tests.rs (+205/-1 total).
Activity
jamespud commentedon Aug 14, 2026
I've prepared a complete fix for this CRLF/LF migration checksum issue and would like to contribute it, but I'm unable to open a pull request because PRs in this repository are currently restricted to collaborators. Could a maintainer pull my branch (or invite me as a collaborator) to review it?
Branch:
jamespud:fix/32643-state-migration-line-endingsCommit:
6247dabb4What it does
runtime_migrator(), so embedded checksums no longer depend on the checkout'score.autocrlf/ line-ending policy.repair_migration_line_ending_checksums(): when opening any runtime SQLite database,_sqlx_migrationsrows whose checksum was computed from CRLF migration files are rewritten to the canonical LF checksum. Databases created by either CRLF or LF builds can then be opened interchangeably.open_runtime_dbpath.This goes beyond the Windows-only approach described in the issue: it also covers the WSL/Linux side opening a database created by a Windows build (and vice versa), which is exactly the shared-home scenario tracked in #25216 and reported in #23777 / #23841 / #23848 / #23863.
Verification
just test -p codex-state: 174 passed, including 4 new tests (LF invariant across all runtime migrators, CRLF→LF canonicalization, CRLF-applied history accepted after repair, LF-applied history unchanged).just fix -p codex-state: clean (clippy).cargo fmt --check: clean.Changes are limited to
codex-rs/state/src/migrations.rs,codex-rs/state/src/sqlite.rs, andcodex-rs/state/src/migrations_tests.rs(+205/-1 total).