Skip to content

Prevent Separate OpenMindAI Processes from Installing Models into the Same Root - #442

Open
smshagor-dev wants to merge 4 commits into
mainfrom
fix/cross-process-model-install-lock
Open

smshagor-dev wants to merge 4 commits into
mainfrom
fix/cross-process-model-install-lock

Conversation

@smshagor-dev

Copy link
Copy Markdown
Owner

Background

PR #438 merged green as 7a9914c6daa474a86f28a2e850b407d3176f8592, protecting two views sharing the same manager instance from concurrent download status and cancellation corruption. A separate desktop process with its own manager could still install models into the same portable root simultaneously, racing the checkpoint, voice/config and manifest writes.

Changes

  • Add a persistent <portable-root>/.openmindai-model-install.lock, opened read/write and guarded with Rust standard-library exclusive OS File::try_lock (no extra dependencies). The OS releases the lock automatically when its file handle is dropped or its owner exits.
  • Acquire it before changing status, cancellation token or model files, after the existing in-memory permit. Hold it through the complete model/dependency/manifest installation and final status recording. Reject an overlapping process immediately with a readable error; never steal its progress or cancel it.
  • Reject symlink/non-regular lock destinations and check root containment; fail closed on unsupported or failed locks. Keep the lock file persistent rather than deleting a possibly locked inode.
  • Add no-network Rust regression tests for two independently instantiated managers targeting one root, a separate unaffected root, lock reacquisition after release, unsafe lock destination rejection, and preserving status on refused install.
  • Document advisory-lock semantics, crash recovery, and filesystem limitations.

Review gates

Keep draft until all current-head Windows/macOS/Linux CI, Security/CodeQL, Release Readiness, and real Kokoro cross-platform + production Model Download Manager install-and-speak checks pass. This protects cooperating OpenMindAI processes; it does not claim unrelated software respects advisory locks or that removable/network disks guarantee identical behavior.

@smshagor-dev
smshagor-dev marked this pull request as ready for review October 20, 2026 16:57

Copy link
Copy Markdown
Owner Author

CI investigation (2026-10-20): On head 26d062dc733e3cd3312df5cc37a9f4542d26e6c7, all four authentic Kokoro tests, Security/CodeQL, Release Readiness, Frontend validation, Cargo lockfile and Windows Tauri build passed. Windows, macOS and Linux Rust validation failed at the same cargo fmt --check gate, with three formatting diffs in src-tauri/src/model_download.rs: the TryLockError match arms, the rejected-lock assertion, and the error-message assertion. Applied exactly those rustfmt adjustments in commit f200ddef180bd09c79b5612eb11e9c67721f9b76. Fresh head workflows: CI #39461831089, Security #39461831025, Release Readiness #39461831187, and Kokoro Real Voice Inference #39461831771. The PR remains draft and unmerged pending all current-head checks green.

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.

1 participant