Skip to content

fix(windows): close native transfer guards before rollback cleanup - #14

Closed
tudstudent wants to merge 2 commits into
xhluca:mainfrom
tudstudent:windows-native-cleanup
Closed

tudstudent wants to merge 2 commits into
xhluca:mainfrom
tudstudent:windows-native-cleanup

Conversation

@tudstudent

@tudstudent tudstudent commented Oct 9, 2026 •

Copy link
Copy Markdown

Windows can reject deletion of an open manifest with WinError 32, masking the underlying native import/finalization failure and leaving artifacts behind. This closes owned descriptors before identity-checked cleanup, including failed exports and atomic-write setup, while retaining guarded successful writes.

Includes Enrico's existing PR #8 atomic-write fix with original author attribution and source commit 8ee41da7433374803373ba7f66d6740a89757b0f. The follow-up extends it to native manifest cleanup and the separate directory-fsync path. PR #8 is still open; that retained commit can be dropped if it lands first.

  • No session-schema changes or dependency on the OpenCode v2 / Codex child follow-ups.
  • Simulated Windows open-file denial covers success, import failure and finalization failure for OpenCode, Kilo and shared database imports; Cursor/Antigravity use the same cleanup ordering. Failed export ownership and atomic setup cleanup also have regressions.
  • Full locked Linux suite: 1,535 passed, 55 skipped. Focused filesystem/transfer suite: 83 passed. Exact legacy OpenCode 1.17.20 selected native gate: 5 passed, no skips.
  • Ruff and formatting, 12 automation unit tests, wheel/sdist build, and both isolated installed-wheel entrypoints passed.

Native Windows was not run for this exact branch; Linux denial mocks do not establish Windows ACL privacy or crash durability. The additional development-guide Docker resume recipe could not run because basic-claude-uv:latest is absent; the pinned credential-free native gate did run. No real chats, credentials, production stores or supplier inference were used. Details: docs/windows-native-cleanup.md.

This is one of three independent, main-based follow-ups split from closed #10 following the maintainer review. @xhluca, this isolates the relevant contract and its validation for review; the other two follow-ups cover separate contracts.

The eligibility bot closed #10 because the author had 64 qualifying contributions against the required 100 older than one calendar month. Splitting does not change that eligibility or claim an exemption; this submission may receive the same automation outcome.

Sibling follow-ups: OpenCode v2: #15; Codex child history: #16. Each targets main independently.

enricodetoma and others added 2 commits October 9, 2026 18:43
On Windows every write failed. os.fchmod() is Unix-only, so on Python
<= 3.12 it raised AttributeError just after mkstemp() left the
descriptor open; the cleanup unlink() then hit WinError 32 ("the file
is being used by another process") and that secondary error replaced
the real one, so users saw "cannot write target session ...: <winerror
32>" pointing at a target file that never existed. On Python 3.13,
where os.fchmod exists, writes instead died in _fsync_directory():
Windows cannot os.open() a directory.

- skip os.fchmod() where it is unavailable; Windows keeps the creating
  user's ACLs
- skip the directory fsync on Windows; NTFS journaling keeps directory
  entries durable without it
- make the temporary-file unlink in the error path best-effort so a
  cleanup failure cannot mask the original error being reported

Add regression tests for both failure modes. Verified on Windows with
Python 3.11 and 3.13: a 371-record Codex-to-Claude transfer now
completes, and write, collision refusal, and rollback behave as on
POSIX.

Note: some existing tests remain POSIX-specific (permission-bit
assertions, pty imports, CRLF-sensitive fixture bytes) and cannot pass
on Windows regardless of this change; the Ubuntu CI matrix is
unaffected.

(cherry picked from commit 8ee41da)
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

🔴 Contributor eligibility requirements not met for @tudstudent.

  • 🟢 Account created: 2011-03-09; age: 5693 days (required: at least six calendar months).
  • 🔴 Contributions dated on or before 2026-09-09: 64 (required: at least 100).

Pull request authors must have a GitHub account at least six calendar months old and at least 100 GitHub contributions dated on or before the date one calendar month before the check.

See the contributor eligibility policy.

Closing this PR because these requirements were not met. This policy is intended to reduce spam from AI agents; it is not an assessment of the quality of your change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants