Repository navigation
fix: SQLite snapshot reads fail on Windows EFS-encrypted profile directories - #169159
JasonBuildAI wants to merge 5 commits into
Conversation
… with EXDEV Windows profile directories encrypted with EFS reject same-directory renames with a false cross-device error, which aborted every private SQLite read-only snapshot publication and stopped doctor state migrations. Keep the rename as the primary path and fall back to copying the verified staged bytes.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR falls back to copying private SQLite snapshot files when publication renames fail with EXDEV. Example: Run openclaw doctor on Windows 11 with EFS encryption inherited by LOCALAPPDATA/openclaw.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a concrete Windows snapshot failure, and the prior wrapper-inventory and CI-attribution blockers are resolved. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherDoctor and other SQLite inspection callers request a consistent private snapshot; the snapshot owner prepares and publishes database files, then returns a location with cleanup operations. flowchart TD
A[Doctor or inspection caller] --> B[Snapshot source owner]
B --> C[Isolated snapshot worker]
C --> D[Verified private staging files]
D --> E[Rename or EXDEV copy]
E --> F[Private reader and cleanup]
Technical reviewBest possible solution: Land the focused EXDEV fallback through the normal merge gates without requiring cache relocation or new configuration. Do we have a high-confidence way to reproduce the issue? Current-main source shows the unhandled EXDEV path, and the reporter supplies concrete Windows EFS failures and filesystem controls; this review did not run a Windows reproduction. Is this the best way to solve the issue? The fallback repairs the shared publication owner after source verification, preserves fatal non-EXDEV errors, and relies on existing private-directory ownership and cleanup rather than adding migration or configuration machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against af288ea70b81. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +34, Tests +35, Other +1. Total +70 across 4 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 11, 2026, 1:41 PM ET / 17:41 UTC (Revision 5). |
The trusted-anchor PR wrapper inventory must stay closed over runtime imports; add the new src/infra/sqlite-snapshot-rename.ts entry so eager-import-closure tests resolve ./sqlite-snapshot-rename.js.
…ite-snapshot-rename-jbai-x7q4
|
CI attribution for the current head (
Local verification on this head: EXDEV snapshot repro publishes and cleans up for both plain and WAL sources; the two focused EXDEV regression tests pass; the two wrapper-closure tests above pass; |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…ite-snapshot-rename-jbai-x7q4
|
CI attribution for the outstanding review item - the Matching-base failure evidence (the same assertion failed on main):
Why this diff cannot be the cause: its only behavioral delta is the Windows EXDEV fallback in Repair: merged current upstream/main into the branch ( |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…ite-snapshot-rename-jbai-x7q4 # Conflicts: # src/infra/sqlite-readonly-location.test.ts # src/infra/sqlite-readonly-location.ts
|
Thanks @JasonBuildAI for the EFS characterization and fix. Landed a smaller credited replacement in #190087 (8662c66): removed the intermediate rename and added the EXDEV-only fallback at final snapshot publication. The three regressions fail on main before the fix and pass afterward; CI is green. Your Co-authored-by credit is preserved in the merged commit. Closing this as superseded. |
Related: #169157
What Problem This Solves
Fixes: read-only SQLite snapshot publication fails with
EXDEV: cross-device link not permittedwhen the private staging directory inherits the EFS Encrypted attribute (for example%LOCALAPPDATA%\openclawunder a corporate encryption policy), which makesopenclaw doctorstop at state-migration detection and block every later migration step.User Impact
User impact: on affected Windows machines, read-only state inspection and
openclaw doctornow complete instead of refusing to continue with "check filesystem health and write permissions or set XDG_CACHE_HOME to a writable filesystem". No user action or data migration is required, and behavior on unencrypted filesystems is unchanged (the rename fast path is still used).Why This Change Was Made
Node's Windows rename path reports same-directory moves as a cross-device error on EFS-encrypted directories even though both paths are on one volume. That made the two publication renames inside the private staging directory (
first->database.sqlite.partial, and thedatabase.sqlite.partial*->database.sqlite*loop) abort every snapshot. The publication helper now falls back to copying the already-verified staged bytes (descriptor copy + fsync) and removing the staged file only when the rename is rejected with EXDEV; other rename failures still fail closed. The staged files are closed private copies in a single-process staging directory, so the rename's atomicity is not load-bearing here. The helper lives in a small sibling module becausesqlite-readonly-location.tsis at the repo's 700-line cap.Evidence
Before the fix (2026.9.9, commit 3258dd8, Windows 11 build 26200, EFS-encrypted
%LOCALAPPDATA%), minimal reproduction calling the snapshot API on a plain SQLite source:openclaw doctorwith a fresh state home stopped at migration detection:After the fix, the same reproduction and the same doctor command on the same machine:
with no
step-refusedorblocked-by-prior-refusalfailures in the output.Trigger characterization on the affected machine:
cipher /c C:\Users\Jason\AppData\Localreports "New files added to this directory will be encrypted" anddir /ashowsEonAppData\Local\openclaw;fs.renameSyncwithin one directory fails with EXDEV under%LOCALAPPDATA%and%APPDATA%(file and directory renames), whilecmdmove, PowerShellRename-Item, and[System.IO.File]::Movesucceed in the same directory, and the same Node rename succeeds under%LOCALAPPDATA%\Temp, the profile root, andD:\Temp.Checks run locally:
node scripts/run-vitest.mjs run --config test/vitest/vitest.infra.config.ts src/infra/sqlite-readonly-location.test.ts -t "EXDEV"-> 2 passed. Without the fix, the new EXDEV test fails atsrc/infra/sqlite-readonly-location.ts:370withEXDEV: cross-device link not permitted, so the regression test demonstrably detects the defect.pnpm tsgo:core-> exit 0.pnpm exec oxfmt --checkon the changed files -> clean.node --import ./scripts/tsx.mjs scripts/check-line-cap-ratchet.mts --base upstream/main-> OK.check-assertion-safety-ratchet.mts --base upstream/main-> OK.node --import ./scripts/tsx.mjs scripts/run-lint.mts --base upstream/main-> Control UI Lit ratchet OK; the plugin-sdk boundary dts generation step then timed out after 300 s on this machine (load/network-bound, unrelated to this change).Known gaps: the regression test simulates the EXDEV rejection so it runs deterministically on every OS; the EFS reproduction itself is Windows-only. Repo-wide
pnpm checkfails on this base commit before this change as well (line-cap, database-worker, assertion-safety, and changelog-attribution ratchet failures reproduce with a pristine checkout); the two ratchets that this change can affect now pass. The background reclamation claim rename insrc/infra/sqlite-snapshot-staging.tsshares the same failure mode but only degrades cleanup logging, so it is intentionally out of scope for this minimal fix (noted in the issue).AI disclosure: this change was drafted with AI assistance at my request, under my direction and review.