Shell 17: fluxer-platform single instance #809

Closed
opened 2026-11-17 23:02:55 +00:00 by charles · 0 comments
Owner

Task 17 of the Desktop shell plan (docs/superpowers/plans/2026-11-17-desktop-shell.md, section "### Task 17:"). The plan on the shell branch is the source of truth; this copy is for reading.

Closes: — (#754: the lock and second-instance items) Depends on: 10

Files:

  • Create: crates/fluxer-platform/src/single_instance/{mod.rs,unix.rs,windows.rs} · Modify: lib.rs, crates/fluxer-platform/src/update/ (release the update lock before a relaunch; the lock file opened close-on-exec), Cargo.toml (tokio net), README · Test: crates/fluxer-platform/tests/single_instance.rs

Interfaces:

  • Produces: acquire(scope: &Path) -> io::Result<Instance>; Instance::Primary(InstanceListener) (next() -> (InstanceMessage, Reply); Reply::{ok, busy}; close() releases at once) or Instance::Secondary(InstanceSender) (send(&InstanceMessage, timeout) -> SendOutcome::{Ok, Busy, NoAnswer}); wait_and_acquire(scope, limit); wait_for_pid_exit(pid, limit).

  • Unix: flock on <runtime>/flaxative/<scope hash>.lock, socket beside it; the directory 0700 (created, or refused if owned by someone else or wider), the socket 0600, the peer's uid checked (SO_PEERCRED), a stale socket replaced only while holding the lock; without XDG_RUNTIME_DIR, the data directory. Windows: mutex Local\Flaxative-<scope hash>, pipe \\.\pipe\flaxative-<user SID>-<scope hash> created with first_pipe_instance(true), reject_remote_clients(true) and a security descriptor for the current user only. Frames: 4-byte length + JSON, at most 4 KiB, one message per connection, 2 s read limit.

  • Step 1: failing tests (temp runtime dir; the pipe tests cfg(windows), run by the Windows runner): first_is_primary_second_is_secondary, message_arrives_and_is_answered, busy_answer, oversize_and_malformed_refused, slow_sender_times_out, stale_socket_replaced, wide_runtime_dir_refused, uid_check (the predicate), released_on_close_and_on_drop, relaunch_waits_for_pid_then_acquires, update_lock_not_inherited.

  • Step 2–5: FAIL → implement → PASS → commit feat(platform): single instance.

Task 17 of the Desktop shell plan (`docs/superpowers/plans/2026-11-17-desktop-shell.md`, section "### Task 17:"). The plan on the `shell` branch is the source of truth; this copy is for reading. **Closes:** — (#754: the lock and second-instance items) **Depends on:** 10 **Files:** - Create: `crates/fluxer-platform/src/single_instance/{mod.rs,unix.rs,windows.rs}` · Modify: `lib.rs`, `crates/fluxer-platform/src/update/` (release the update lock before a relaunch; the lock file opened close-on-exec), `Cargo.toml` (tokio `net`), README · Test: `crates/fluxer-platform/tests/single_instance.rs` **Interfaces:** - Produces: `acquire(scope: &Path) -> io::Result<Instance>`; `Instance::Primary(InstanceListener)` (`next() -> (InstanceMessage, Reply)`; `Reply::{ok, busy}`; `close()` releases at once) or `Instance::Secondary(InstanceSender)` (`send(&InstanceMessage, timeout) -> SendOutcome::{Ok, Busy, NoAnswer}`); `wait_and_acquire(scope, limit)`; `wait_for_pid_exit(pid, limit)`. - Unix: `flock` on `<runtime>/flaxative/<scope hash>.lock`, socket beside it; the directory 0700 (created, or refused if owned by someone else or wider), the socket 0600, the peer's uid checked (`SO_PEERCRED`), a stale socket replaced only while holding the lock; without `XDG_RUNTIME_DIR`, the data directory. Windows: mutex `Local\Flaxative-<scope hash>`, pipe `\\.\pipe\flaxative-<user SID>-<scope hash>` created with `first_pipe_instance(true)`, `reject_remote_clients(true)` and a security descriptor for the current user only. Frames: 4-byte length + JSON, at most 4 KiB, one message per connection, 2 s read limit. - [ ] **Step 1: failing tests** (temp runtime dir; the pipe tests `cfg(windows)`, run by the Windows runner): `first_is_primary_second_is_secondary`, `message_arrives_and_is_answered`, `busy_answer`, `oversize_and_malformed_refused`, `slow_sender_times_out`, `stale_socket_replaced`, `wide_runtime_dir_refused`, `uid_check` (the predicate), `released_on_close_and_on_drop`, `relaunch_waits_for_pid_then_acquires`, `update_lock_not_inherited`. - [ ] **Step 2–5:** FAIL → implement → PASS → commit `feat(platform): single instance`.
charles added this to the Desktop shell milestone 2026-11-17 23:02:55 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/fluxer-native#809
No description provided.