Hero client commands should suggest --root when only the root-scoped daemon socket exists #151
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_skills#151
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Split out from #135.
Symptom
After starting mycelium with
service_mycelium start --rooton a fresh machine (root-scoped install), running the client without--rootfails with a generic socket-missing error pointing at internal source:The service is running — just under root. The error message doesn't say so, and the operator has to guess that
--rootis the answer (or read the source).Why this is a problem
Hero supports two scopes for nearly every service: the user's own daemon (sockets under
$HOME/hero/var/sockets/...) and the root-scoped one (/root/hero/var/sockets/...). Most service commands accept--rootto switch scope. When a user runs the client without--rootbut only a root-scoped daemon is up, the client checks the user-scoped socket, finds it missing, and raises the generic openrpc "Socket not found" error.This is a class of problem — same trap exists for
proc,router,proxy, and any future client that usesopenrpc_call. The error originates deep insidetools/modules/openrpc.nu, so it can't easily distinguish "daemon not running anywhere" from "daemon only running with the other scope".Suggested fix
Move the diagnostic from
openrpc_call(which is correctly scope-agnostic and shouldn't grow scope-aware fallbacks) up one level into each client wrapper (tools/modules/clients/mycelium.nu,proc.nu,router.nu,proxy.nu).Before making the call, when running without
--root:mycelium daemon is running under root but not under your user. Try: mycelium <subcommand> --root.service_mycelium starthint).A shared helper in
tools/modules/clients/mod.nu(something likeclient_resolve_socket name rootreturning the scoped path and asserting clean error text on miss) would let all four clients pick this up without duplication.Files
tools/modules/openrpc.nu:55-57— current generic socket-missing error.tools/modules/clients/mycelium.nu,proc.nu,router.nu,proxy.nu— sites that resolve socket paths from the--rootflag.tools/modules/clients/mod.nu— natural home for a sharedclient_resolve_sockethelper.Picking this up. Planned scope:
client_check_sockethelper intools/modules/clients/mod.nu. When the user-scoped socket is missing, itsudo test -e's the root-scoped socket and throws either did you mean--root? (root daemon up) or tryservice_<name> start(neither up). Reuses the existingopenrpc_needs_sudofromtools/modules/openrpc.nu.<prefix>_callin the five client wrappers —mycelium,proc,router,proxy,codescalers(the issue body said four, butcodescalers.nufollows the same pattern; including it for consistency).Is the service running?line fromopenrpc.nu— the wrapper owns that messaging now.openrpc_callitself stays scope-agnostic per the issue's recommendation.No behaviour change when commands succeed; only the failure UX is improved. PR will follow.
PR #161 ready for review. Live-tested on
kristof6—mycelium addressnow produces the new--roothint,mycelium address --rootis unchanged.