Shell 17: platform-single-instance (#809) #890
Closed
charles
wants to merge 0 commits from
shell-17-platform-single-instance into shell
pull from: shell-17-platform-single-instance
merge into: charles:shell
charles:main
charles:camera
charles:dailyuse
charles:textchat
charles:fix-1008-idle-in-voice
charles:camera-21-acceptance
charles:feat-1000-app-sounds-output
charles:fix-1001-local-time
charles:camera-20-parity-list-for-the
charles:fix-931-silent-voices
charles:camera-15-ui-settings-voice-video
charles:camera-14-ui-camera-buttons-camera
charles:camera-16-ui-layout-with-cameras
charles:camera-17-core-toggle-camera-shortcut
charles:camera-13-ui-mirrored-video-and
charles:camera-12-appsfluxer-camera-runtime-and
charles:camera-10-capture-camera-on-linux
charles:camera-11-capture-camera-on-windows
charles:camera-9-voice-the-camera-track
charles:camera-7-core-the-own-camera
charles:camera-6-capture-camera-trait-mode
charles:camera-8-core-remote-cameras-tile
charles:camera-3-spike-a-camera-track
charles:camera-4-video-camera-formats-and
charles:camera-18-devserver-camera-scenario
charles:camera-1-spike-capture-linux
charles:camera-5-core-camera-ports-commands
charles:camera-2-spike-capture-windows
charles:camera-plan
charles:shell
charles:fix-925-keybinds-persist
charles:feat-934-935-stream-view
charles:feat-933-stream-output-device
charles:shell-44-acceptance
charles:feat-946-select-message-text
charles:shell-43-parity-list-for-the
charles:fix-589-black-band-linux-sender
charles:shell-37-ui-system-wide-shortcuts
charles:shell-ship
charles:fix-931-voices-silent-after-long-uptime
charles:shell-39-ui-settings-notifications
charles:shell-36-ui-settings-keybinds
charles:shell-16-core-autostart
charles:fix-923-late-publication-next-share
charles:fix-921-share-teardown-publish-race
charles:shell-1-spike-iced-daemon-hide
charles:shell-10-core-instance-messages-tasks
charles:shell-11-core-keybinds-actions-combos
charles:shell-13-core-badge-attention-sound
charles:shell-14-core-notification-settings-inactive
charles:shell-18-platform-desktop-entry-and
charles:shell-2-spike-tray-on-linux
charles:shell-3-spike-wayland-global-shortcuts
charles:shell-41-devserver-shell-scenario
charles:shell-5-spike-overlay-technique-for
charles:shell-6-core-shell-ports-settings
charles:shell-7-platform-settings-shell-keybinds
charles:shell-8-core-tray-model-and
charles:shell-9-core-window-rules-close
charles:fix-913-keep-awake-retry
charles:shell-35-ui-in-window-voice
charles:shell-sync-textchat
charles:shell-34-app-shortcuts-runtime
charles:fix-913-keep-screen-awake
charles:fix-910-deepfilter-windows-timing
charles:shell-33-app-shell-runtime
charles:shell-28-platform-shortcuts-on-wayland
charles:fix-910-deepfilter-late-frame
charles:shell-29-platform-shortcuts-by-direct
charles:shell-27-platform-shortcuts-on-x11
charles:shell-24-platform-badge-displays-and-24
charles:shell-26-platform-shortcuts-on-windows
charles:shell-21-platform-tray-on-linux
charles:shell-22-platform-tray-on-windows
charles:fix-908-flaky-stream-end-test
charles:shell-30-platform-wayland-activation
charles:shell-38-ui-settings-desktop
charles:shell-19-platform-autostart
charles:shell-25-platform-shortcut-back-end
charles:shell-23-platform-badge-displays-and
charles:shell-40-ui-companion-apps-control
charles:shell-31-statusapi-default-avatars
charles:shell-12-core-system-wide-shortcut
charles:shell-20-platform-tray-trait-icons
charles:shell-32-ui-daemon-window-lifecycle
charles:shell-4-spike-raising-a-wayland
charles:shell-15-core-status-payload-gaps
charles:fix-876-share-resolution-and-bars
charles:shell-42-packaging-windows-shortcuts-and
charles:fix-874-tests-must-not-notify
charles:fix-868-deepfilternet-start
charles:gamenight-plan
charles:fix-867-869-stream-end-soundboard-limits
charles:feat-229-windows-hardware-encoding
charles:fix-857-vaapi-hardware-encoding
charles:fix-849-inert-cards
charles:fix-848-pinned-messages-clickable
charles:shell-plan
charles:fix-764-nvenc-above-720p30
charles:serveradmin
charles:feat-780-forum-archived-filter
charles:serveradmin-35-acceptance
charles:feat-781-no-join-chime-with-entrance-sound
charles:feat-784-rejoin-voice-after-update
charles:fix-779-782-search-dropdown-paste-preview
charles:fix-783-781-dm-rail-entrance-sound
charles:serveradmin-34-parity-screenshots
charles:serveradmin-31-ui-channel-permissions
charles:fix-773-cargo-deny-advisories
charles:serveradmin-33-ui-sudo-delete-transfer
charles:serveradmin-28-ui-members-page
charles:serveradmin-26-ui-role-permissions
charles:serveradmin-30-ui-voice-overview-channel-invites
charles:serveradmin-fix-27-29
charles:serveradmin-25-ui-roles-tab
charles:serveradmin-27-ui-menus-moderation-modals
charles:serveradmin-29-ui-channel-settings
charles:fix-589-stream-top-strip-encode
charles:serveradmin-24-ui-moderation-invites-bans
charles:feat-760-version-in-title
charles:fix-751-stream-audio-pipewire
charles:serveradmin-20-core-menu-rows
charles:fix-752-linux-notification-panic
charles:serveradmin-17-core-overrides
charles:fix-740-updater-always-latest
charles:serveradmin-23-ui-community-settings-overview
charles:serveradmin-12-core-roles
charles:serveradmin-19-core-sudo-delete-transfer
charles:serveradmin-32-ui-sidebar-drag
charles:serveradmin-15-core-members-page
charles:serveradmin-16-core-channel-settings
charles:serveradmin-14-core-bans-invites
charles:fix-615-restore-on-stored-session-start
charles:serveradmin-22-runtime
charles:serveradmin-13-core-member-moderation
charles:serveradmin-18-core-channel-reorder
charles:fix-732-status-api-speaking
charles:serveradmin-10-core-permission-lists
charles:serveradmin-11-core-forms-community
charles:serveradmin-21b-devserver-channels-members-sudo
charles:serveradmin-4-api-community-roles-sudo
charles:serveradmin-9b-core-hierarchy-bulk-events
charles:serveradmin-21a-devserver-community-roles
charles:serveradmin-9a-core-ports
charles:serveradmin-8-form-widgets
charles:serveradmin-5-api-channels-members-bans
charles:serveradmin-7-settings-shell
charles:serveradmin-1-proto-community-roles
charles:serveradmin-3-proto-members-bans-invites
charles:serveradmin-6-reorder-widget
charles:serveradmin-2-proto-channel-admin
charles:fix-706-presence-after-reconnect
charles:fix-615-start-on-last-view
charles:feat-663-create-channel
charles:serveradmin-plan
charles:fix-662-long-text-wrap
charles:fix-660-661-menu-toolbar-paste-focus
charles:fix-620-forum-list-reactions
charles:fix-657-windows-console
charles:fix-622-emoji-in-names
charles:fix-smoke-645-648
charles:fix-614-install-location
charles:dailyuse-41-acceptance
charles:fix/597-copy-id
charles:dailyuse-40-parity-screenshots
charles:dailyuse-35-ui-quick-switcher-keybinds
charles:dailyuse-38-ui-profile-modal
charles:fix/voice-view
charles:fix/side-panel-composer
charles:dailyuse-37b-ui-composer-barriers-blocked
charles:fix/image-viewer
charles:fix/619-picker-flicker
charles:fix/editor-forum-edit
charles:dailyuse-32-ui-status-picker
charles:dailyuse-34b-ui-add-guild-invite-modal
charles:dailyuse-28-app-dailyuse-runtime
charles:dailyuse-36-ui-voice-badge-refusals
charles:fix/594-menu-placement-textchat
charles:fix/589-stream-top-strip
charles:fix/594-menu-placement
charles:dailyuse-39-ui-report-modal
charles:dailyuse-37a-ui-attachment-audio-group-icon
charles:dailyuse-24-core-notification-icon-passive
charles:fix/587-quiet-voice
charles:dailyuse-30-ui-notification-settings-modal
charles:dailyuse-31-ui-user-dm-menus
charles:dailyuse-22b-core-composer-barriers-blocked
charles:dailyuse-22a-core-mark-unread-attachments
charles:dailyuse-29-ui-channel-guild-menus
charles:dailyuse-18-core-user-dm-menus
charles:dailyuse-33-ui-confirm-friends-page
charles:dailyuse-22c-core-trusted-domains-hide-muted
charles:dailyuse-20-core-keyboard-navigation
charles:dailyuse-15-core-friends-blocking
charles:dailyuse-23-core-profile-report-flow
charles:dailyuse-19-core-quick-switcher
charles:dailyuse-14-core-status-idle-presence
charles:dailyuse-17-core-channel-guild-menus
charles:ci/27-linux-cache
charles:dailyuse-37c-ui-trust-links-hide-muted
charles:dailyuse-13-core-honour-mutes
charles:dailyuse-34a-ui-invite-cards-accept
charles:dailyuse-16b-core-create-invites-guilds
charles:dailyuse-12-core-notification-settings-mutes
charles:dailyuse-16a-core-invite-links
charles:dailyuse-25-audio-attachments
charles:dailyuse-21-core-voice-refusals
charles:dailyuse-11b-core-state-skeleton
charles:dailyuse-11a-core-dailyuse-ports
charles:dailyuse-26b-devserver-dailyuse-b
charles:dailyuse-26a-devserver-dailyuse-a
charles:dailyuse-4-api-settings-acks-reports
charles:dailyuse-5-api-relationships-invites-guilds
charles:dailyuse-27-platform-notification-idle
charles:dailyuse-10-highlight-languages
charles:fix-search-focus-hover-emoji
charles:dailyuse-8-context-menu-widget
charles:dailyuse-9-image-load-retry
charles:dailyuse-7-chat-navigation-persistence
charles:dailyuse-2-proto-relationships-invites-reports
charles:dailyuse-1-proto-notification-presence
charles:dailyuse-6-gateway-op12-presence
charles:textchat-next
charles:fix-stream-black
charles:fix-reactions-hover
charles:textchat-68-app-video-playback-runtime
charles:textchat-35-acceptance
charles:textchat-34-parity-screenshots
charles:textchat-74-app-updater-runtime
charles:textchat-67-ui-video-player
charles:textchat-stage-46-47
charles:textchat-47-ui-media-channel
charles:textchat-75-promote-stable-workflow
charles:textchat-46-ui-forum-composer
charles:textchat-73-ui-update-button
charles:textchat-64-media-playback-crate
charles:textchat-stage-43-48
charles:textchat-72-platform-updater
charles:textchat-44-ui-thread-view
charles:textchat-70-release-update-feed
charles:textchat-48-ui-announcements
charles:textchat-45-ui-forum-view
charles:textchat-71-core-updater
charles:textchat-43-ui-sidebar-links-notes
charles:textchat-stage-40
charles:textchat-42-app-channel-types-runtime
charles:textchat-39-core-forums
charles:textchat-40-core-announcements-thread-admin
charles:textchat-60-ui-entrance-sounds
charles:textchat-63-ffmpeg-lgpl-packaging
charles:textchat-stage-batch6
charles:textchat-69-proto-update-manifest
charles:textchat-61-app-soundboard-entrance-runtime
charles:textchat-52-app-audio-devices-runtime
charles:textchat-38-core-channel-routing
charles:soundboard-effect-emoji
charles:status-api-rebind
charles:textchat-28-ui-gif-picker
charles:textchat-41-devserver-channel-types
charles:voice-panel-soundboard
charles:textchat-29-ui-message-actions
charles:textchat-37-api-channel-types
charles:textchat-66-core-video-players
charles:autoupdate-plan
charles:textchat-33-ui-message-list-settings
charles:textchat-32-ui-dms
charles:textchat-62-rename-flaxative
charles:fix-chatcolumn-tree
charles:textchat-65-audio-media-source
charles:textchat-31-ui-threads
charles:textchat-stage-27
charles:textchat-30-ui-search-pins-inbox
charles:textchat-53-ui-audio-sources-menu
charles:textchat-27-ui-expression-picker
charles:textchat-57-core-entrance-library
charles:textchat-36-proto-channel-types
charles:textchat-26-ui-upload-tray
charles:textchat-59-ui-soundboard-popout-parity
charles:textchat-58-audio-sound-edit
charles:textchat-55-proto-api-entrance-library
charles:textchat-25-ui-composer
charles:textchat-56-core-soundboard-parity
charles:rename-video-plan
charles:textchat-stage-25
charles:textchat-stage-23-24
charles:soundboard-plan
charles:textchat-24-ui-message-row
charles:textchat-22-ui-attachments-media
charles:textchat-23-ui-embeds
charles:textchat-14-core-expressions
charles:textchat-21-app-textchat-runtime
charles:textchat-16-core-navigation-read
charles:textchat-17-core-search
charles:textchat-19-core-dms-settings
charles:textchat-stage-13-15-18
charles:textchat-54-livekit-stereo-audio
charles:textchat-50-core-stream-audio-sources
charles:textchat-12-core-uploads
charles:textchat-15-core-message-actions
charles:textchat-11-core-composer
charles:textchat-18-core-threads
charles:textchat-13-core-reactions
charles:textchat-51-audio-pipewire-devices
charles:textchat-49-capture-audio-targets
charles:audio-plan
charles:textchat-plan2
charles:textchat-20-devserver-textchat
charles:textchat-6-api-chat-endpoints
charles:textchat-10-core-chat-ports
charles:textchat-9-ui-code-highlighting
charles:textchat-3-proto-expressions-threads-prefs
charles:textchat-5-api-messages-uploads
charles:textchat-2-proto-chat-requests-events
charles:textchat-8-ui-inline-flow-emoji
charles:screenshare
charles:textchat-7-platform-files-clipboard
charles:textchat-1-proto-message-content
charles:textchat-4-emoji-crate
charles:screenshare-31-acceptance
charles:screenshare-29-parity-screenshots
charles:textchat-plan
charles:screenshare-24-ui-focus-layout
charles:screenshare-27-ui-stream-menu
charles:screenshare-30-packaging-ci
charles:screenshare-21-app-screenshare-runtime
charles:screenshare-22-ui-sidebar-live
charles:screenshare-23-ui-stream-tile
charles:screenshare-26-ui-source-picker
charles:screenshare-28-ui-screenshare-settings
charles:screenshare-13-core-previews
charles:screenshare-12-core-codec-negotiation
charles:screenshare-25-ui-share-controls
charles:screenshare-18-hw-encode-linux
charles:screenshare-19-spike-hw-encode-windows
charles:screenshare-11-core-stream-params
charles:screenshare-20-devserver-screenshare
charles:screenshare-10-core-go-live
charles:screenshare-17-voice-livekit-video
charles:screenshare-14-audio-capture-linux
charles:wip/screenshare-17
charles:screenshare-integration
charles:feat-user-profile
charles:fix-voice-join
charles:feat-entity-images
charles:screenshare-16-voice-video-session
charles:screenshare-9-core-watching
charles:screenshare-5-capture-windows
charles:fix-wire-livekit
charles:screenshare-4-capture-linux
charles:screenshare-15-audio-capture-windows
charles:fix-member-list
charles:screenshare-8-core-stream-ports
charles:fix-live-protocol
charles:screenshare-6-ui-video-widget
charles:screenshare-3-capture-crate
charles:fix-altcha-captcha
charles:screenshare-1-video-frames
charles:screenshare-7-proto-api-streams
charles:screenshare-2-spike-livekit-video
charles:voice
charles:voice-26-acceptance
charles:voice-23-voice-e2ee
charles:voice-25-packaging-ci
charles:voice-13-voice-livekit-interop
charles:voice-24-parity-screenshots
charles:voice-19-ui-soundboard
charles:voice-20-ui-participant-menu
charles:voice-22-ui-dm-calls
charles:voice-21-ui-voice-settings
charles:voice-18-ui-call-view
charles:voice-14-app-voice-runtime
charles:voice-10-core-soundboard
charles:voice-17-ui-voice-panel
charles:voice-9-core-voice-settings-advert
charles:voice-5-audio-clips-chimes
charles:voice-15-devserver-voice
charles:voice-8-core-live-room-volumes
charles:voice-11-core-calls-status
charles:voice-12-voice-session
charles:voice-4-audio-devices-mixer
charles:voice-16-ui-voice-sidebar
charles:voice-7-core-voice-connection
charles:foundation
charles:voice-2-proto-api-soundboard-rtc
charles:voice-6-core-voice-states
charles:voice-3-audio-dsp
charles:voice-1-proto-voice-gateway
charles:task/26-acceptance
charles:task/25-packaging-release
charles:task/24-screenshot-tests
charles:task/20-ui-message-list-composer
charles:task/22-ui-settings-parity
charles:task/18-ui-main-layout
charles:task/23-notifications
charles:task/17-ui-shell-login
charles:task/14-app-runtime
charles:ci/51-windows-disk-space
charles:task/12-platform-persistence
charles:task/13-devserver
charles:task/21-ui-avatar-image-cache
charles:task/10-core-messages-readstate
charles:task/9-core-guilds-channels
charles:task/7-gateway-machine-transport
charles:task/11-core-presence-ui
charles:task/19-ui-rich-text
charles:task/8-core-store-session
charles:task/16-ui-theme-fonts-icons
charles:task/15-status-api
charles:task/4-proto-gateway-events
charles:task/5-openapi-vendor-contract
charles:task/6-api-client
charles:task/3-proto-rest-models
charles:task/2-proto-primitives
charles:task/1-workspace-scaffold
No reviewers
Labels
Clear labels
bug
A bug found while working on something else; steps to reproduce and the commit seen on
ci
Build, CI runners and workflows
follow-up
Deferred reviewer finding, linked from the PR it came from
good-first-task
Small, well-scoped, no cross-crate knowledge needed
parity
Settings/behaviour parity with the Electron client
question
Design question that needs Charles; blocks its task until answered
ready-to-merge
Reviewer approved, foundation merged in, CI green on both runners; waiting for the orchestrator to merge
task
A plan task (one per Foundation plan task)
No labels
bug
ci
follow-up
good-first-task
parity
question
ready-to-merge
task
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
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!890
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "shell-17-platform-single-instance"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
fluxer_platform::single_instance(Desktop shell spec §7.2, §12; plan Task 17), andUpdateLock::release()for the #754 relaunch.acquire(scope) -> io::Result<Instance>:Instance::Primary(InstanceListener)orInstance::Secondary(InstanceSender). Runs without an async runtime (first thing inmain, Task 33); the primary's listener serves on its own thread with a private current-thread tokio runtime.InstanceListener::next().await -> Option<(InstanceMessage, Reply)>,Reply::{ok, busy}(dropped unanswered =error),close()/ drop releases at once (stop thread, remove socket, unlock),endpoint().InstanceSender::send(&InstanceMessage, limit) -> SendOutcome::{Ok, Busy, NoAnswer, Refused}(blocking, own small runtime; retries a channel that is not there yet until the limit).wait_and_acquire(scope, limit),wait_for_pid_exit(pid, limit);acquire_in/wait_and_acquire_in/socket_pathtake the runtime directory explicitly (tests).flock(stdFile::try_lock) on<runtime>/flaxative/<scope hash>.lock, socket<hash>.sockbeside it; runtime =$XDG_RUNTIME_DIR, else the data directory. Directory created 0700; one wider, a link or another user's is refused (PermissionDenied); socket 0600; peer uid checked per connection via tokio'speer_cred(SO_PEERCRED), own uid read the same way from a socket pair (nolibcdependency); stale socket removed only while holding the lock.Local\Flaxative-<hash>; pipe\\.\pipe\flaxative-<SID>-<hash>withfirst_pipe_instance(true),reject_remote_clients(true), security attributes from SDDLD:P(A;;GA;;;<SID>); SID from the process token (ConvertSidToStringSidW). Everyunsafehas aSAFETY:comment.InstanceMessage::encode, max 4 KiB (a longer length is answerederrorbefore reading any of it), whole message within 2 s (else closed unanswered), answer frameok/busy/error. Messages are decoded by Task 10's codec; nothing is executed, used as a path or logged in full. At most 16 queued; more are answeredbusy.update/lock.rs:UpdateLock::release(self), and docs that the lock file is close-on-exec (std opens withO_CLOEXEC; not inheritable on Windows).Tests
crates/fluxer-platform/tests/single_instance.rs(temp runtime dirs; same tests drive the pipe on the Windows runner except the threecfg(unix)ones):first_is_primary_second_is_secondary,message_arrives_and_is_answered,busy_answer,oversize_and_malformed_refused,slow_sender_times_out,no_primary_is_no_answer,stale_socket_replaced(unix),wide_runtime_dir_refused(unix; modes and a symlink),uid_check(thepeer_allowed/dir_acceptablepredicates),released_on_close_and_on_drop,wait_and_acquire_gives_up_at_the_limit,wait_and_acquire_takes_over_once_released,relaunch_waits_for_pid_then_acquires(a child of the test binary holds the instance),wait_for_pid_exit_of_a_missing_process,update_lock_not_inherited(unix: a child started while both locks are held keeps neither). Unit tests: scope hash, dropped reply. The tests passed several times in a row locally;FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green. No real-desktop test is needed (no display involved); none run.The Windows code was compiled and clippy-checked (
-D warnings) forx86_64-pc-windows-msvcin a scratch crate with the samewindows0.62.2 /tokio1.54.1 (the full crate cannot be checked for that target here: C build scripts). The Windows tests have not been run.Deviations from the plan
InstanceListener::next()isasyncand returnsOption<…>(Noneonce the listener stopped) instead of a bare tuple.SendOutcomehas a fourth variant,Refused(the primary answerederror: malformed, too long, or the reply was dropped), as the spec'sok/busy/erroranswers need one.release()and the regression test. Releasing both locks before the relaunch is wired by Task 33.ERROR_ACCESS_DENIED(a primary that just released the mutex may still be closing its pipe handles); a pipe still there after that is refused.Cargo.toml: tokionet; on Windows thewindowsdependency gainsWin32_Security_Authorization(on the crate's line, not the workspace's).wait_and_acquire_in(another test spawning a process forks this one, and until that childexecs it shares the open lock file for a few milliseconds).For Charles to check on Windows (Task 44)
\\.\pipe\flaxative-<SID>-<hash>exists only while the first runs.single_instancetests pass on the Windows runner.Stacked on: origin/shell-10-core-instance-messages-tasks (already merged into shell at the base commit)
Closes #809
🤖 Generated with Claude Code
https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Independent review: Shell 17, platform single instance (
fd598bf4)Scope:
git diff 2412c1d0..origin/shell-17-platform-single-instance.Local gate:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask cionfd598bf4: all steps passed (Linux).tests/single_instance.rs: 16/16 passed. The two unit tests passed too.Findings
crates/fluxer-platform/tests/single_instance.rs:12hasuse std::path::{Path, PathBuf};, butPathis only used inside the#[cfg(unix)]teststale_socket_replaced(line 326). On the Windows runner,cargo xtask cirunsclippy --workspace --all-targets -D warnings, so this becomeserror: unused import: Path. I reproduced it with rustc 1.98.1--target x86_64-pc-windows-msvc -D warningson a minimal file with the same shape. Fix: usestd::path::Pathinside that test, or put the import behind#[cfg(unix)]. The other imports and items in the test file are used on Windows.windows.rs::connect) does not check who owns the pipe server. The pipe name is predictable, since a SID is not secret. Another local user could create\\.\pipe\flaxative-<SID>-<hash>before the primary does. In that case the primary'sfirst_pipe_instancefails after 1 s and it runs with no channel, while later launches hand their message (a URL or an activation token) to the squatter. The client already defaults toSECURITY_IDENTIFICATION, so the squatter cannot impersonate. The plan does not ask for this check. A follow-up could compare the token user ofGetNamedPipeServerProcessIdwith the client's own SID.next()is async and returnsOption<(InstanceMessage, Reply)>, andSendOutcomegainsRefused. Both are reasonable and documented. Task 33 must matchRefusedand theNonethatnext()returns after the listener stops.deliveranswersbusywhen the queue is full (16 messages) or closed, butbusyis documented as "shutting down". A sender then waits up to 10 s and stays a secondary. This is acceptable, but Task 33 should drainnext()promptly.wait_for_pid_exittreats anyOpenProcessfailure, including ACCESS_DENIED for a process running elevated or as another user, as "exited". On Unix, thekill -0fallback without/proctreats EPERM the same way.acquire_inandInstanceSender::send_framebuild and drop a current-thread runtime in the caller's thread, so calling them from inside a tokio runtime panics.senddocuments this.acquire/wait_and_acquireonly say that they need no runtime, not that they must not run inside one.Checks
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,released_on_close_and_on_drop,relaunch_waits_for_pid_then_acquires,update_lock_not_inherited). They assert the spec's values: 4 KiB (MAX_MESSAGE_BYTES= 4096, an oversize frame and au32::MAXprefix both refused), the 2 s read limit, a 0700 directory, a 0600 socket, and refusal of a wide directory or a symlink.acquire(&Path) -> io::Result<Instance>,Instance::{Primary, Secondary},Reply::{ok, busy},close(),send(&InstanceMessage, Duration) -> SendOutcome::{Ok, Busy, NoAnswer, +Refused},wait_and_acquire(scope, limit),wait_for_pid_exit(pid, limit) -> bool, andUpdateLock::release()are all present.peer_credon accept, and again on connect). On Windows, the DACL isD:P(A;;GA;;;<SID>), withreject_remote_clientsandfirst_pipe_instance. Frames are at most 4096 bytes, and the codec refuses unknown kinds and fields. Nothing is executed. Logs carry onlyInstanceCodecErrortext and no message content or paths.LocalFree. The descriptor outlives every pipe instance. The shadowedOwnedHandletoken stays alive until the function returns.GetLastErroris read right afterCreateMutexW. The mutex and pipe handles are not inheritable. Every unsafe block has aSAFETY:comment.READ_LIMIT, and the answer is read before the handle closes. OK.netfeature andWin32_Security_Authorizationare each a single-line registration change. No secrets.fluxer_desktop/src/main/Bootstrap.ts:213-223:configureUserDataPath(), thenrequestSingleInstanceLock()); (b) second launches that arrive before the sink is set are buffered (ModuleBootHandoff.ts:94-112), which the mpsc queue does here; (c) the original ignores a launch while it is quitting, and the spec'sbusyanswer replaces that. All three match.apps/fluxer/src/update_rt.rs, and plan Task 33 says it "releases the instance and update locks before any relaunch". Leaving the call to Task 33 is correct.Verdict: changes requested. One blocking finding (#1, the Windows clippy failure). Linux gate green.
Review round 1 addressed in
c84f8bed(cargo xtask cigreen locally withFLUXER_SCREENSHOT_TESTS=1).Blocking
tests/single_instance.rsunusedPathon Windows: the import is nowuse std::path::PathBuf;only; the Unix-onlystale_socket_replacednamesstd::path::Pathin its closure.Minor
GetNamedPipeServerProcessId; needs a newwindowsfeature and a Windows-runner test).next() -> Option<(InstanceMessage, Reply)>,SendOutcome::Refused): kept on purpose (Noneonce the listener stopped;Refusedfor a malformed or refused message, which must not make the sender wait for the lock). Task 33 must treatNoneas "no more messages" andRefusedlike a failed hand-off (exit without waiting). Both are documented in the crate README.busyon a full or closed queue: split. A closed queue (listener stopped, shutting down) still answersbusy; a full queue (client running but not taking messages) now answerserror(SendOutcome::Refused), so the sender does not wait 10 s for a lock it will not get. Test first:full_queue_refuses_closed_queue_is_busy(unit test ofdeliver). Docs ofSendOutcome::{Busy, Refused}and the README updated.wait_for_pid_exitand denied access: Windows now treatsERROR_ACCESS_DENIEDfromOpenProcessas running and polls until the process is gone or the limit passes (then waits on the handle with the remaining time). Unix without/procnow asksps -p <pid> -o stat=(lists every user process; zombies count as ended) instead ofkill -0, which cannot tell EPERM from ESRCH. Tests:unix::tests::{ps_states, other_users_process_is_alive}(pid 1 through both paths). The Windows branch is compiled and linted by the Windows runner only.acquire_in/send_frameinside a tokio runtime: they now run their own runtime on a scoped thread of their own whenHandle::try_current()succeeds, instead of panicking (the caller thread still blocks, as documented). Test first:usable_inside_a_runtime(failed with "Cannot start a runtime from within a runtime" before the fix).Independent review, round 2: Shell 17, platform single instance (
c84f8bed)Scope:
git diff 2412c1d0..origin/shell-17-platform-single-instance(fd598bf4+c84f8bed).Local gate:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask cionc84f8bed, run twice in the review worktree:testfailed influxer-platform --lib:update::lock::tests::one_holder_at_a_time_and_released_on_droppanicked atcrates/fluxer-platform/src/update/lock.rs:78:14:free after drop. The other 50 lib tests passed.tests/single_instance.rs17/17; the lib testsfull_queue_refuses_closed_queue_is_busy,ps_states,other_users_process_is_aliveanddropped_reply_answers_errorpassed. Three separate runs ofcargo test -p fluxer-platform --libalso passed.Windows: I type-checked the Windows code here. I made a stub crate holding
single_instance/{mod,unix,windows}.rsandtests/single_instance.rsunchanged, withfluxer-corefrom this branch andwindows0.62.2 (Win32_Foundation,Win32_Security,Win32_System_Threading,Win32_Security_Authorization), on toolchain 1.98.1.cargo clippy --target x86_64-pc-windows-msvc --all-targets -- -D warningsis clean for the lib and the integration test. A deliberate type error inwindows.rswas reported, so the cfg(windows) code really was checked. Not linked and not run.Findings
update/lock.rs:76-78. The new assertion takes the update lock again right afterdrop(first)and expects it free at once. Tests in the same lib test binary start child processes on other threads: the newsingle_instance::unix::tests::other_users_process_is_aliverunspsup to three times, anddesktop_entry::linux::tests::missing_tool_is_an_error_not_a_hangspawns too. A child forked in that window shares theflock's open file description until itexecs, so the lock is briefly still held. That is the same race thatprimary_soonintests/single_instance.rsalready documents and works around. It failed in my first gate run. Fix: retry the post-drop and post-releaseacquisitions for a short bounded time, asprimary_soon/update_lock_not_inheriteddo. Do not assert immediate availability inside a binary whose tests spawn processes.next()isasyncand returnsOption<…>, andSendOutcomegainsRefused. Both are documented in the README and in PR comment 8929, and the spec allowserror(§7.2). Task 33 must build against the code:Nonemeans no more messages, andRefusedmeans exit without waiting for the lock.follow-up), which is acceptable: the DACL,FILE_FLAG_FIRST_PIPE_INSTANCE,PIPE_REJECT_REMOTE_CLIENTSand the SID in the name are all present, and a primary that fails to create the first instance drops its mutex, so later launches do not reach a squatter in the usual case.ANSWER_LIMITis 5 s, but spec §7.2 has the secondary give up after 2 s with no answer. A primary that answers between 2 s and 5 s is therefore treated as NoAnswer, and the sender waits for the lock. Task 33 should answer promptly or use a send limit that agrees.Checks
first_is_primary_second_is_secondary,message_arrives_and_is_answered,busy_answer,oversize_and_malformed_refused,slow_sender_times_out,stale_socket_replaced(unix),wide_runtime_dir_refused(unix),uid_check,released_on_close_and_on_drop,relaunch_waits_for_pid_then_acquires,update_lock_not_inherited(unix; on Windowsstdhandles are not inheritable). They use the spec's values: 4096 bytes (MAX_FRAME_BYTES=MAX_MESSAGE_BYTES; an oversize frame and au32::MAXprefix both answerederror),READ_LIMIT2 s, directory 0700, socket 0600, and refusal of a wide directory (0755/0750/0707/0777) or a symlink. The round-1 fixes also have tests.acquire(&Path) -> io::Result<Instance>,Instance::{Primary(InstanceListener), Secondary(InstanceSender)},Reply::{ok, busy}(dropped =error),InstanceListener::close,InstanceSender::send(&InstanceMessage, Duration) -> SendOutcome::{Ok, Busy, NoAnswer, +Refused},wait_and_acquire(scope, limit),wait_for_pid_exit(pid, limit) -> bool, andUpdateLock::release. They match the plan apart from the documented deviations in finding 2.fluxer-platformandfluxer-coreis untouched. The only new dependencies are tokionetand thewindowsWin32_Security_Authorizationfeature, both named by the plan and spec §5.5. Logs carry no message content (InstanceCodecErrorcarries none), no paths and no keys;Debugof the listener, sender and reply is opaque. A decode error cannot panic: frames are length-checked before allocation, and every error is answered or closes the connection. Everyunsafeblock has aSAFETY:comment. No secrets.fluxer_desktop/src/main):Bootstrap.ts:219-223/index.ts:374-376: the lock is taken early and the loser forwards and quits, which matchesInstance::Secondaryplus send.DeepLinks.ts:223-242: the second-instance kinds update → task → link → show map ontoUpdateRelaunch,Task,OpenUrlandActivate, all carried and tested inmessage_arrives_and_is_answered.ModuleBootHandoff.ts:94-112: second instances are buffered until the sink is armed, which matches the bounded queue of 16 held untilnext().SO_PEERCREDis checked on both ends against the uid from a socket pair, and on Windows the user-only DACLD:P(A;;GA;;;<SID>)and remote clients are rejected.{"kind":"run",…}and{"kind":"task","task":"format-disk"}).Verdict: changes requested. One blocking finding: the flaky update-lock unit test (finding 1). Everything else is ready. With the lock test made tolerant of the fork window, I would approve.
Round 2 fixes (
3ee93d87):update/lock.rsflaky test:one_holder_at_a_time_and_released_on_dropnow retries the post-drop and post-release acquisitions for up to 5 s (acquire_soon), since a child forked by another test shares the open lock file until it execs. LocalFLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen.next()async/Option,SendOutcome::Refused): already documented onnext();Refuseddocs now state the second launch exits without waiting for the lock. Task 33 should treatNoneas no more messages.ANSWER_LIMIT5 s vs 2 s secondary: value kept; its doc now says the app answers each message at once (before acting on it) or gives the sender a send limit at least this long. For Task 33.🤖 Generated with Claude Code
Independent review: Shell 17 (platform single instance), commit
3ee93d87Scope:
git diff 2412c1d0..origin/shell-17-platform-single-instance(single_instance/{mod,unix,windows}.rs, update/lock.rs, tests/single_instance.rs, Cargo.toml, lib.rs, README).Checks
first_is_primary_second_is_secondary,message_arrives_and_is_answered,busy_answer,oversize_and_malformed_refused(4 KiB + 1, au32::MAXlength prefix, malformed JSON, unknown kinds and tasks, extra fields),slow_sender_times_out(2 sREAD_LIMIT, others still served),stale_socket_replaced(checks socket 0600 and dir 0700),wide_runtime_dir_refused(0755/0750/0707/0777 and a symlink),uid_check,released_on_close_and_on_drop,relaunch_waits_for_pid_then_acquires(a real child process),update_lock_not_inherited. The extras cover use inside a runtime, no primary, and thewait_and_acquirelimit and takeover.acquire,Instance::{Primary, Secondary},Reply::{ok, busy},close,send(&InstanceMessage, limit),wait_and_acquire,wait_for_pid_exitexist. Two differences from the plan's block are listed under minor findings.fluxer-platform. The only dependency changes are tokionetand the windows featureWin32_Security_Authorization, both named by the task. No secrets or paths in logs. Message contents are never logged: errors areInstanceCodecError's fixed strings. Nothing from a message is executed or used as a path. A malformed frame cannot panic the client: reads are bounded and every error is mapped.fluxer_desktop/src/main/Bootstrap.ts:219-223: the lock is taken afterconfigureUserDataPath(), so it is scoped to the data directory, asacquire(scope)is here. When the lock is lost, the launch is forwarded and that process quits, which matchesSecondary.ModuleBootHandoff.ts:90-112: second launches are buffered until the sink is set, which matches the queue of 16 waiting fornext(). During quit the original ignores a second launch; here it is answeredbusyand the sender takes over, the deviation spec §7.2 asks for (#754).D:P(A;;GA;;;SID)and carries the SID in its name. Only well-formed messages of at most 4 KiB reach the client, and nothing in them is executed.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cirun locally in the review worktree: all steps passed (EXIT=0). This includestests/single_instance.rsandupdate::lock::tests::one_holder_at_a_time_and_released_on_drop. As an extra check for the Windows code,cargo clippy -p fluxer-platform --target x86_64-pc-windows-gnu --all-targets -- -D warningsis clean. This is the mingw target, not the MSVC runner, but the cfg(windows) code is the same.Findings
InstanceListener::next()is async and returnsOption<(InstanceMessage, Reply)>, withNoneonce the listener has stopped.SendOutcomehas a fourth variant,Refused(malformed, queue full or reply dropped: exit without waiting). Task 33'smatchmust handleRefused. Neither difference breaks code that is merged today.ANSWER_LIMIT(5 s), the connection closes without an answer, but the message stays queued and is delivered to the client later. The sender has already seenNoAnswerafter 2 s and gone intowait_and_acquire. Task 33 must takenext()and answer straight away, before acting, as theANSWER_LIMITdoc now says. Otherwise a slow-starting primary can act on a launch whose sender believes it failed.Local\Flaxative-<hash>is created without an owner check, so a different user in the same logon session could hold the mutex and turn our launches into secondaries (DoS only: the pipe name carries our SID and its DACL is ours). This is already deferred to #896.Verdict: approved. No blocking findings, and the local gate is green.
Merged into
shellby hand (the merge API returns 405); the commits are in the branch.Pull request closed