fix(server): preserve binary cursor keys on Windows - #1464
Open
knqiufan wants to merge 1 commit into
Open
Conversation
This was referenced Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue or RFC does this PR close?
Closes #1463.
Found while investigating the Windows native-service check on #1459. This fix is based directly on
masterand is independent of the DSH changes.Rationale for this change
On Windows,
os.opendefaults to text mode. Writing a random 32-byte cursor key containing LF expands it to CRLF on disk. The first Server process uses the original key and starts successfully; the next process reads the expanded file and fails startup because its length is no longer 32 bytes. Retrying CI can avoid the random LF byte and conceal the defect.What changes are included in this PR?
O_BINARYwhere supported, preserving exclusive creation and existing POSIX file permissions.Are there any user-facing changes?
Newly generated cursor keys retain their original bytes on Windows, allowing subsequent Server starts. Existing valid keys and cursor formats are unchanged. This does not automatically replace malformed key files or rotate signing keys.
How was this change tested?
python -m pytest -q tests/test_cursor_secret.py tests/test_server.py: 51 passed on Windows/Python 3.12.13.powercontext[cli,server]plus pytest into a fresh.native-venv; the exact new Windows CI regression command passed 4 tests, including HTTP cursor reuse after restart.uv lock --check,uv run --no-sync prek run -a,uv run --no-sync ty check, andgit diff --check: passed.schtasks /Createby this host. The existing GitHub-hosted Windows lifecycle job remains required to validate install/stop/start/uninstall; its checks are not skipped or relaxed.2fb02a2e: 17/17 checks passed, including Python 3.11–3.14, SQLite/OceanBase acceptance, and native Linux/macOS/Windows services. The Windows job passed all four deterministic cursor checks and all four applicable real lifecycle tests; its one skip is the macOS-only scenario.AI usage statement
Implemented with OpenAI Codex. The failure was traced to the uploaded CI service logs, reproduced deterministically on Windows before changing production code, and checked against both source and the built distribution. No credentials or private model configuration are included.