fix(clients): suggest --root when only the root daemon socket is up #161

Open
mahmoud wants to merge 1 commit from fix/client-root-scope-hint-151 into development
Owner

Closes #151.

What changed

  • New tools/modules/clients/lib.nu exposes client_check_socket [user, root, service] — when the user-scoped socket is missing, it sudo test -e's the root-scoped one and either tells the operator to add --root or to run service_<name> start.
  • Each of the five client wrappers (mycelium, proc, router, proxy, codescalers) calls the helper in its non-root branch before delegating to openrpc_call. (codescalers was not listed in the issue body but follows the exact same pattern.)
  • tools/modules/openrpc.nu: extracted openrpc_socket_exists so the helper and openrpc_call share one sudo-aware probe; trimmed the now-redundant Is the service running? from the bare openrpc_call error since the wrapper owns that messaging now.
  • tools/modules/clients/mod.nu re-exports the new helper.

Live verification on kristof6

This machine had only a root-scoped mycelium daemon when the change was tested — exactly the bug repro from the issue.

Before (today, on development):

~> mycelium address
Error: Socket not found: /home/mahmoud/hero/var/sockets/mycelium/rpc.sock
Is the service running?
  -> tools/modules/openrpc.nu:56

After:

~> mycelium address
Error: mycelium daemon socket not found at /home/mahmoud/hero/var/sockets/mycelium/rpc.sock.
A root-scoped daemon is running — re-run this command with --root.

~> mycelium address --root
4c0:b29a:2940:5d2:42e4:4a63:7002:1ac0

All 8 modified/new modules parse-checked: openrpc.nu, clients/lib.nu, clients/mod.nu, clients/mycelium.nu, clients/proc.nu, clients/router.nu, clients/proxy.nu, clients/codescalers.nu.

Test plan

  • All client modules parse
  • mycelium address (root-only daemon) → new actionable error
  • mycelium address --root → unchanged success
  • Manual: bring user-scoped mycelium up, confirm both mycelium address and mycelium address --root succeed (no false-positive on the helper)
  • Manual: stop both daemons, confirm mycelium address produces the service_mycelium start hint
Closes #151. ## What changed - New `tools/modules/clients/lib.nu` exposes `client_check_socket [user, root, service]` — when the user-scoped socket is missing, it `sudo test -e`'s the root-scoped one and either tells the operator to add `--root` or to run `service_<name> start`. - Each of the five client wrappers (`mycelium`, `proc`, `router`, `proxy`, `codescalers`) calls the helper in its non-root branch before delegating to `openrpc_call`. (`codescalers` was not listed in the issue body but follows the exact same pattern.) - `tools/modules/openrpc.nu`: extracted `openrpc_socket_exists` so the helper and `openrpc_call` share one sudo-aware probe; trimmed the now-redundant `Is the service running?` from the bare `openrpc_call` error since the wrapper owns that messaging now. - `tools/modules/clients/mod.nu` re-exports the new helper. ## Live verification on kristof6 This machine had only a root-scoped mycelium daemon when the change was tested — exactly the bug repro from the issue. Before (today, on `development`): ``` ~> mycelium address Error: Socket not found: /home/mahmoud/hero/var/sockets/mycelium/rpc.sock Is the service running? -> tools/modules/openrpc.nu:56 ``` After: ``` ~> mycelium address Error: mycelium daemon socket not found at /home/mahmoud/hero/var/sockets/mycelium/rpc.sock. A root-scoped daemon is running — re-run this command with --root. ~> mycelium address --root 4c0:b29a:2940:5d2:42e4:4a63:7002:1ac0 ``` All 8 modified/new modules parse-checked: `openrpc.nu`, `clients/lib.nu`, `clients/mod.nu`, `clients/mycelium.nu`, `clients/proc.nu`, `clients/router.nu`, `clients/proxy.nu`, `clients/codescalers.nu`. ## Test plan - [x] All client modules parse - [x] `mycelium address` (root-only daemon) → new actionable error - [x] `mycelium address --root` → unchanged success - [ ] Manual: bring user-scoped mycelium up, confirm both `mycelium address` and `mycelium address --root` succeed (no false-positive on the helper) - [ ] Manual: stop both daemons, confirm `mycelium address` produces the `service_mycelium start` hint
fix(clients): suggest --root when only the root daemon socket is up
All checks were successful
Build and Publish Skills / build-and-publish (pull_request) Successful in 5s
b7715b1dac
When a non-root user runs a Hero RPC client (mycelium / proc / router /
proxy / codescalers) without --root but only a root-scoped daemon is up,
the command used to fail with a generic "Socket not found" pointing at
internals of openrpc.nu. The user had to guess that --root was the fix.

Add a small client_check_socket helper in tools/modules/clients/lib.nu
that probes the root-scoped socket (via openrpc_socket_exists, which
sudo-tests /root/... paths) and either:
  - errors with "re-run with --root" if a root daemon is up, or
  - errors with "Try: service_<name> start" if neither daemon is up.

Each <prefix>_call wrapper invokes the helper in its non-root branch
before delegating to openrpc_call. openrpc_call itself stays
scope-agnostic — its own missing-socket error is trimmed to drop the
now-redundant "Is the service running?" line.

Verified live on kristof6: with only a root mycelium daemon running,
`mycelium address` now produces "A root-scoped daemon is running —
re-run this command with --root." instead of the openrpc-internal error,
and `mycelium address --root` is unchanged.

#151
All checks were successful
Build and Publish Skills / build-and-publish (pull_request) Successful in 5s
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/client-root-scope-hint-151:fix/client-root-scope-hint-151
git switch fix/client-root-scope-hint-151

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch development
git merge --no-ff fix/client-root-scope-hint-151
git switch fix/client-root-scope-hint-151
git rebase development
git switch development
git merge --ff-only fix/client-root-scope-hint-151
git switch fix/client-root-scope-hint-151
git rebase development
git switch development
git merge --no-ff fix/client-root-scope-hint-151
git switch development
git merge --squash fix/client-root-scope-hint-151
git switch development
git merge --ff-only fix/client-root-scope-hint-151
git switch development
git merge fix/client-root-scope-hint-151
git push origin development
Sign in to join this conversation.
No reviewers
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
lhumina_code/hero_skills!161
No description provided.