fix(servuo): detect a shard launched relative from its root (#47) #48

Merged
whitlocktech merged 1 commits from fix/running-shard-detection into main 2026-11-27 02:05:37 -06:00
Member

What & why

Closes #47. Also fixes #45 item 5 (wrong pid in the refusal).

find_running only matched a process's exe and argv. A shard started from inside its root as mono ServUO.exe (systemd WorkingDirectory=, or tmux, which is how the UOM shard runs) only shows the root in its working directory. So it was reported as not running, and install/update went ahead and deployed under a live shard.

The decision now lives in a pure classify(), which covers every launch shape:

Launch Decided by
ServUO.exe as the executable (Windows) its exe path
mono /opt/ServUO/ServUO.exe the old exe+argv substring rule, kept as is
cd root; mono ServUO.exe (systemd, tmux) the relative arg resolved against the cwd (new)
cd /opt; mono ServUO/ServUO.exe the same (new)
  • Paths are compared by component, so /opt/ServUO2 does not count as inside /opt/ServUO.
  • A process still has to name servuo.exe, so the tmux shell or an editor sitting in the root never matches.
  • Unreadable cwd fails closed (decided by the org lead 2026-11-27). A relative ServUO.exe whose cwd can't be read gets its own refusal: "cannot rule out … stop it, or re-run with sudo". It is not overridable. doctor counts only certain matches.
  • #45 item 5: Linux lists threads beside their process, so a thread could match first and the refusal printed a TID. Threads (thread_kind().is_some()) are now skipped.

Docs: RunicGateway/docs PR (installer/PLAN.md and INSTALL.md troubleshooting).

How it was tested

  • On Windows: cargo fmt --check, cargo clippy --all-targets -- -D warnings, and cargo test all pass (196 tests).
  • New unit tests cover each launch shape, a second shard on the host, the ServUO2 sibling, a shell or editor in the root, the unreadable-cwd case, and the uncertain refusal wording.
  • New Linux-only live test a_live_relative_launch_from_the_root_is_found_by_its_pid: it spawns a real process with cwd = root and a relative ServUO.exe in argv, then asserts find_running returns that pid. It runs only on the ubuntu CI leg. I have no local Linux toolchain, so I couldn't run it myself.
  • Not done: re-running the issue's Case A with a released Linux binary against real Mono. That needs a release build.

Checklist

  • I have read CONTRIBUTING.md.
  • The change builds and existing tests/checks pass locally.
  • I have added or updated tests/docs where it makes sense.
  • My commits are reasonably scoped with clear messages.

AI-assisted contributions (required)

  • No AI tools were used to produce this contribution.
  • AI tools were used. Tool(s): Claude Code (Claude Opus 5.5). I have reviewed and understand
    every change, and take responsibility for it. AI-authored commits are
    marked with a Co-Authored-By / Assisted-By trailer.

License

  • I agree that my contribution is licensed under this project's license
    (GNU GPL v3.0 or later), and I have the right to contribute it.

🤖 Generated with Claude Code

https://claude.ai/code/session_014HJEmd5sBSpNXicS4gmT1t

## What & why Closes #47. Also fixes #45 item 5 (wrong pid in the refusal). `find_running` only matched a process's exe and argv. A shard started from inside its root as `mono ServUO.exe` (systemd `WorkingDirectory=`, or tmux, which is how the UOM shard runs) only shows the root in its **working directory**. So it was reported as `not running`, and install/update went ahead and deployed under a live shard. The decision now lives in a pure `classify()`, which covers every launch shape: | Launch | Decided by | |---|---| | `ServUO.exe` as the executable (Windows) | its exe path | | `mono /opt/ServUO/ServUO.exe` | the old exe+argv substring rule, kept as is | | `cd root; mono ServUO.exe` (systemd, tmux) | the relative arg resolved against the cwd (**new**) | | `cd /opt; mono ServUO/ServUO.exe` | the same (**new**) | - Paths are compared by component, so `/opt/ServUO2` does not count as inside `/opt/ServUO`. - A process still has to name `servuo.exe`, so the tmux shell or an editor sitting in the root never matches. - **Unreadable cwd fails closed** (decided by the org lead 2026-11-27). A relative `ServUO.exe` whose cwd can't be read gets its own refusal: "cannot rule out … stop it, or re-run with sudo". It is not overridable. `doctor` counts only certain matches. - **#45 item 5:** Linux lists threads beside their process, so a thread could match first and the refusal printed a TID. Threads (`thread_kind().is_some()`) are now skipped. Docs: RunicGateway/docs PR (installer/PLAN.md and INSTALL.md troubleshooting). ## How it was tested - On Windows: `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, and `cargo test` all pass (196 tests). - New unit tests cover each launch shape, a second shard on the host, the `ServUO2` sibling, a shell or editor in the root, the unreadable-cwd case, and the uncertain refusal wording. - New **Linux-only live test** `a_live_relative_launch_from_the_root_is_found_by_its_pid`: it spawns a real process with cwd = root and a relative `ServUO.exe` in argv, then asserts `find_running` returns **that** pid. It runs only on the ubuntu CI leg. I have no local Linux toolchain, so I couldn't run it myself. - **Not done:** re-running the issue's Case A with a released Linux binary against real Mono. That needs a release build. ## Checklist - [x] I have read [CONTRIBUTING.md](CONTRIBUTING.md). - [x] The change builds and existing tests/checks pass locally. - [x] I have added or updated tests/docs where it makes sense. - [x] My commits are reasonably scoped with clear messages. ## AI-assisted contributions (required) - [ ] No AI tools were used to produce this contribution. - [x] AI tools were used. Tool(s): `Claude Code (Claude Opus 5.5)`. I have reviewed and understand every change, and take responsibility for it. AI-authored commits are marked with a `Co-Authored-By` / `Assisted-By` trailer. ## License - [x] I agree that my contribution is licensed under this project's license (**GNU GPL v3.0 or later**), and I have the right to contribute it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014HJEmd5sBSpNXicS4gmT1t
wtclaude added 1 commit 2026-11-27 01:59:03 -06:00
fix(servuo): detect a shard launched relative from its root (#47)
All checks were successful
PR Checks / rust-gates (pull_request) Successful in 2m2s
51bfd34d74
find_running matched only on a process's exe + argv, so `mono ServUO.exe`
started from inside the root (systemd WorkingDirectory=, tmux) was reported
"not running" and install/update deployed under a live shard.

The decision moves to a pure classify(): ServUO.exe as the executable is
decided by its path; the old exe+argv substring rule is kept; otherwise a
relative ServUO.exe argument is resolved against the process's cwd and must
land inside the root (component-wise, so /opt/ServUO2 is not /opt/ServUO).
An unreadable cwd fails closed with its own refusal (stop it or re-run with
sudo); doctor counts only certain matches.

Also skips Linux thread entries in the scan so the refusal names the real
pid, not a TID (#45 item 5).

Closes #47

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014HJEmd5sBSpNXicS4gmT1t
whitlocktech approved these changes 2026-11-27 02:05:17 -06:00
whitlocktech merged commit 6a9dfac1ac into main 2026-11-27 02:05:37 -06:00
whitlocktech deleted branch fix/running-shard-detection 2026-11-27 02:05:40 -06:00
Sign in to join this conversation.
No description provided.