hero_shrimp binds sockets under $XDG_RUNTIME_DIR, diverging from the Hero socket-dir convention (breaks lab smoke tests) #87
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_shrimp#87
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?
Summary
hero_shrimpresolves its Unix-socket directory differently from every other Hero service. It inserts anXDG_RUNTIME_DIRstep above the Hero-standard$HOME/hero/var/socketsdefault. BecauseXDG_RUNTIME_DIR=/run/user/<uid>is always set in a login/desktop session, the daemon binds its sockets at/run/user/<uid>/hero_shrimp/{rpc,web}.sockwhilelab(and the rest of the ecosystem) expect them under$PATH_SOCKET = $HOME/hero/var/sockets/hero_shrimp/.Result:
lab buildregisters the services withhero_procsuccessfully, but every socket-probe smoke test fails because the sockets are not where lab looks:Evidence
Resolution order in
crates/hero_shrimp_types/src/paths.rs(default_socket_dir):HERO_SHRIMP_SOCKET_DIRHERO_SOCKET_DIRXDG_RUNTIME_DIR← outranks the Hero-standard default$HOME/hero/var/sockets/tmpLive verification on a
lab-launched stack:hero_proc.ss -xlshows them bound at/run/user/1000/hero_shrimp/rpc.sockand.../web.sock.$HOME/hero/var/sockets/hero_shrimp/is empty -> all smoke probes fail.XDG_RUNTIME_DIR=/run/user/1000,HERO_SOCKET_DIRunset.Sibling services do not have the XDG step — they use
HERO_SOCKET_DIR->$HOME/hero/var/sockets->/tmp:hero_aibroker(crates/hero_aibroker_server/src/socket.rs)hero_proc(crates/hero_proc_sdk/src/socket.rs)hero_router(crates/hero_router/src/config.rs)hero_shrimpis the only outlier.Proposed fix (primary)
Remove the
XDG_RUNTIME_DIRbranch fromdefault_socket_dir()(or demote it below the$HOME/hero/var/socketsdefault) sohero_shrimpmatches the other Hero services. Add a regression test asserting that, withHERO_SOCKET_DIRunset andXDG_RUNTIME_DIRset, the resolved dir is$HOME/hero/var/sockets/hero_shrimp.Secondary / ecosystem gap
lab user initemitsPATH_SOCKETbut neverHERO_SOCKET_DIR. Services key offHERO_SOCKET_DIR, so today they only agree with lab by coincidence — every service's hardcoded default equals$PATH_SOCKET. If anyone sets a non-defaultPATH_SOCKET, every service silently ignores it.labshould also exportHERO_SOCKET_DIR="$PATH_SOCKET"so the two are actually wired together. (Tracking here for visibility; may warrant a separate issue against thelabrepo.)Workaround
Export
HERO_SOCKET_DIR="$PATH_SOCKET"in the environment that launches the stack (must be present in thehero_procdaemon's env, since services inherit it), then relaunch. This is operational-only and does not fix the convention divergence.Repro
XDG_RUNTIME_DIRis set (default on any desktop session) andHERO_SOCKET_DIRis unset.lab build --restartinhero_shrimp.ss -xl | grep shrimpshows sockets under/run/user/<uid>/instead of$HOME/hero/var/sockets/.Implementation Spec for Issue #87
Objective
Make
hero_shrimpresolve its Unix-socket directory using the same chain as every other Hero service by removing theXDG_RUNTIME_DIRbranch fromdefault_socket_dir(). After the fix, withHERO_SHRIMP_SOCKET_DIRandHERO_SOCKET_DIRunset andXDG_RUNTIME_DIRset, the resolved directory must be$HOME/hero/var/sockets/hero_shrimp(not/run/user/<uid>/hero_shrimp), restoringlabsmoke-test compatibility.Requirements
XDG_RUNTIME_DIRresolution branch fromdefault_socket_dir().HERO_SHRIMP_SOCKET_DIR->HERO_SOCKET_DIR->$HOME/hero/var/sockets/hero_shrimp->/tmp/hero_shrimp.HERO_SHRIMP_SOCKET_DIRandHERO_SOCKET_DIRunset butXDG_RUNTIME_DIRset, the resolved dir is$HOME/hero/var/sockets/hero_shrimp.socket_path,default_rpc_socket, etc.).Files to Modify/Create
crates/hero_shrimp_types/src/paths.rs(only file touched — both source and tests live here)Implementation Plan
Step 1: Remove the XDG branch from
default_socket_dir()Files:
crates/hero_shrimp_types/src/paths.rs// XDG runtime dircomment plus theif let Ok(xdg) = std::env::var("XDG_RUNTIME_DIR") ...block that returnsPathBuf::from(xdg).join(COMPONENT).HERO_SOCKET_DIRblock immediately followed by theHOMEHero-standard block.Dependencies: none
Step 2: Update the module doc comment to reflect the new chain
Files:
crates/hero_shrimp_types/src/paths.rs//! 3. $XDG_RUNTIME_DIR/hero_shrimpdoc line and renumber so$HOME/hero/var/sockets/hero_shrimpbecomes step 3 and/tmp/hero_shrimpbecomes step 4.Dependencies: Step 1
Step 3: Convert the obsolete XDG test into the regression test
Files:
crates/hero_shrimp_types/src/paths.rsxdg_runtime_dir_used_when_socket_dir_unsetcurrently asserts the resolved path is under/run/user/<uid>/; this assertion now fails.xdg_runtime_dir_ignored_falls_back_to_hero_standard) and change the expectation to assertdefault_socket_dir()returns$HOME/hero/var/sockets/hero_shrimpwhileXDG_RUNTIME_DIRis set andHERO_SOCKET_DIRunset.with_envhelper andENV_LOCKmutex pattern exactly (no new crate, no#[serial]attribute).Dependencies: Step 1
Acceptance Criteria
default_socket_dir()contains no reference toXDG_RUNTIME_DIR.HERO_SHRIMP_SOCKET_DIRandHERO_SOCKET_DIRunset,XDG_RUNTIME_DIR=/run/user/1000,HOME=/home/op:default_socket_dir()==/home/op/hero/var/sockets/hero_shrimpanddefault_rpc_socket()==/home/op/hero/var/sockets/hero_shrimp/rpc.sock.HERO_SHRIMP_SOCKET_DIR->HERO_SOCKET_DIR->$HOME/hero/var/sockets->/tmp.cargo test -p hero_shrimp_typespasses (no remaining test asserts an XDG-based path).cargo build/cargo clippyclean; module doc comment matches actual behavior.Notes
ENV_LOCK: Mutex<()>and awith_envhelper that snapshots and restores prior values. Continue using that pattern; do not introduce theserial_testcrate.std::env::set_var/remove_varare wrapped inunsafeblocks (Rust 2024 edition), already present in the helper.XDG_RUNTIME_DIRis referenced only incrates/hero_shrimp_types/src/paths.rs. No callers elsewhere depend on the XDG behavior.hero_proc_sdk/hero_aibrokerresolve viaHERO_SOCKET_DIR -> $HOME/hero/var/sockets -> /tmpwith no XDG step. This change alignshero_shrimpwith that convention (it does not adopt a shared helper, which would be a larger refactor out of scope here).Test Results
cargo test -p hero_shrimp_typesAll tests pass.
cargo build -p hero_shrimp_typescompiles clean.The regression test
xdg_runtime_dir_ignored_falls_back_to_hero_standardpasses.Doc-tests: 6 passed, 0 failed.
Implementation Summary
The socket-directory divergence is fixed.
hero_shrimpnow resolves its Unix-socket directory using the same chain as every other Hero service.Changes
File modified:
crates/hero_shrimp_types/src/paths.rsXDG_RUNTIME_DIRbranch fromdefault_socket_dir(). The resolution order is now:$HERO_SHRIMP_SOCKET_DIR/hero_shrimp$HERO_SOCKET_DIR/hero_shrimp$HOME/hero/var/sockets/hero_shrimp/tmp/hero_shrimpxdg_runtime_dir_used_when_socket_dir_unsettest into a regression testxdg_runtime_dir_ignored_falls_back_to_hero_standard, which asserts that withHERO_SHRIMP_SOCKET_DIRandHERO_SOCKET_DIRunset butXDG_RUNTIME_DIR=/run/user/1000set andHOME=/home/op, bothdefault_socket_dir()anddefault_rpc_socket()resolve under$HOME/hero/var/sockets/hero_shrimp.Test Results
cargo test -p hero_shrimp_types: 17 unit tests + 6 doc-tests, all passing, 0 failures.cargo build -p hero_shrimp_typesclean.Notes
XDG_RUNTIME_DIRis no longer referenced anywhere indefault_socket_dir(). No new dependencies added.hero_shrimpnow matches the sibling-service convention (HERO_SOCKET_DIR->$HOME/hero/var/sockets->/tmp), restoringlabsmoke-test compatibility.lab user initnot exportingHERO_SOCKET_DIR="$PATH_SOCKET") is out of scope for this repo and is tracked separately against thelabrepo.