Repository navigation
Description
Problem
On Windows, exporting a managed optimization campaign while its writer holds .session.lock raises a raw PermissionError instead of the documented retryable SnapshotBusy / writer-active error.
infra.artifacts.file_lock calls msvcrt.locking(..., LK_NBLCK, 1). Lock contention raises PermissionError: [Errno 13] Permission denied. apps.delivery.project catches BlockingIOError, so this Windows contention case bypasses the public error translation.
Reproduction and observed evidence
Environment was Windows and CPython 3.12. Run the existing regression with the checkout installed or its src on PYTHONPATH.
python -m pytest -o addopts= -q --tb=short tests/test_result_delivery.py::test_progress_uses_committed_control_and_a_fixed_clockThe test holds optimization._locked(root) and calls delivery.project(root, export_id="busy"). It expects ValueError matching writer is active through the SnapshotBusy subclass. The observed exception originates at src/inferrsi/infra/artifacts.py:28 and escapes through src/inferrsi/apps/delivery/__init__.py:123.
The same test fails on an unmodified archive of base 8aba657da79e8ed9f6e6fbb33437e9d9fdd8f1c7 and on #493. The storage implementation bodies in #493 are unchanged; its direct import migration does not introduce this failure. No assertion or platform coverage was weakened.
Proposed bounded correction and acceptance
- Normalize genuine lock contention at the appropriate owning boundary so Apps reports its existing retryable writer-active error on Windows and POSIX.
- Preserve real permission, missing-path and unrelated filesystem errors; do not treat every
OSErroras a busy writer. - Keep the existing nested-lock regression and add focused coverage distinguishing contention from unrelated I/O failures, including lock release/retry.
- Verify on Windows and POSIX. Existing Linux full-check and the narrower Windows host-compatibility checks do not establish that this full Windows test passes.
This issue tracks the baseline limitation requested during #490's design and implementation follow-up. This correction is separate from the physical directory migration in #493.
Activity
Dong1017 commentedon Nov 18, 2026
Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).
Assessment: This looks like a valid, well-scoped Windows-only bug.
msvcrt.locking(..., LK_NBLCK, 1)reports lock contention asPermissionError(Errno 13). On POSIX the equivalent contention surfaces asBlockingIOError, whichapps.delivery.projectcatches. So the Windows path skips theSnapshotBusy/ "writer is active" translation. The issue's claim that this predates #493 is credible. It reproduces on base8aba657and the storage bodies in #493 are unchanged. I haven't run anything myself. This is based on the issue text only.Where to fix it: I'd normalize at the owning boundary,
infra.artifacts.file_lock. That function is where the platform difference originates, and it avoids Apps needing to know aboutmsvcrtsemantics. Two options:file_lockcatches the Windows contention error and re-raisesBlockingIOError(or a dedicatedLockContentionsubclass ofBlockingIOError). Apps then stays unchanged and POSIX behavior is identical.exceptinapps.deliveryto includePermissionError. I'd avoid this because it treats genuine permission failures as a busy writer, which the acceptance criteria forbid.Option 1 is preferable.
Risks and gaps to settle before implementing:
PermissionErroris ambiguous. On Windows,msvcrt.lockingfailing underLK_NBLCKreportsEACCES(13), and a real denied-open also reportsEACCES. The safest split is by call site. Only exceptions raised by themsvcrt.lockingcall itself, after the lock file has been opened successfully, should be mapped to contention. Errors fromopen()or the path stay untouched. The issue should state this explicitly.msvcrterrors.EDEADLOCK(36) can also occur with the blockingLK_LOCKvariants. Confirm it is not reachable here, or map it deliberately.file_lock. Check whether other callers (the optimization writer, other apps) depend on seeingPermissionErrortoday. Changing the exception type is a behavior change for them.msvcrt.lockingto raisePermissionError, and separately makeopenraisePermissionErrorandFileNotFoundError. Keep one real-lock test that runs on both platforms.tests/test_result_delivery.py, or the whole suite, would close that gap. It could be a follow-up if the Windows runner cost is a concern. Say which.Suggested next steps:
infra/artifacts.py, keeptest_progress_uses_committed_control_and_a_fixed_clockas is, and add the focused tests listed above.Not verified: I have not run the regression or inspected the code at
artifacts.py:28ordelivery/__init__.py:123. The points above rely on the issue's description.david6666666 commentedon Nov 18, 2026
Could the Windows regression exercise both directions of contention on the same
.session.lock? At the merged storage commit, Apps export acquires it throughinfra.artifacts.file_lock, while Harness optimization uses its separate R2artifact_primitives.file_lock. An Infra-only change can fix the existing writer-to-export case without testing what the Harness caller sees. Please verify both directions and reacquisition, and state whether error normalization is export-only or shared without reintroducing a Harness-to-Infra import.