feat: Align with Hero Socket Convention — HTTP over UDS + standardized socket layout #65
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_compute#65
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?
Context
Per Kristof's architecture mandate, all Hero services must:
$HERO_SOCKET_DIR/<service>/<type>.sock)hero_compute currently uses raw newline-delimited JSON-RPC via
UnixRpcServerwith flat socket files (hero_compute_server.sock). This needs to become HTTP-over-UDS viaAxumRpcServerwith proper directory layout.Two-Phase Approach
Phase 1: Socket Layout + HTTP-over-UDS Migration (this issue)
Phase 2: Replace TCP Bridges with Hero Proxy (future issue)
Phase 1 Tasks
1.1 — SDK: Update socket constants and helpers
File:
crates/hero_compute_sdk/src/lib.rsSERVER_SOCKET_NAMEandUI_SOCKET_NAMEconstants with path helper functionssocket_dir()helper readingHERO_SOCKET_DIRenv var (default~/hero/var/sockets)rpc_socket_path()→$HERO_SOCKET_DIR/hero_compute/rpc.sockui_socket_path()→$HERO_SOCKET_DIR/hero_compute/ui.sockexplorer_rpc_socket_path()→$HERO_SOCKET_DIR/hero_compute/explorer_rpc.sockraw_rpc_unix()to use HTTP POST over UDS (server will now speak HTTP)1.2 — Server: Switch from UnixRpcServer to AxumRpcServer
File:
crates/hero_compute_server/src/main.rsReplace:
With:
rpc_socket_path()instead of hardcoded pathAxumRpcServer(HTTP over UDS)create_dir_allfor socket parent (AxumRpcServer handles this)File:
crates/hero_compute_server/src/config.rsserver_socket_namefield andHERO_COMPUTE_SERVER_SOCKET_NAMEenv var1.3 — Explorer: Switch from UnixRpcServer to AxumRpcServer
File:
crates/hero_compute_explorer/src/main.rs$HERO_SOCKET_DIR/hero_compute/explorer_rpc.sockFile:
crates/hero_compute_explorer/src/config.rsexplorer_socket_namefield andHERO_COMPUTE_EXPLORER_SOCKET_NAMEenv varFile:
crates/hero_compute_explorer/src/explorer/proxy.rsNodeProxy::call_unix()to use HTTP POST over UDS instead of raw JSON-RPCcall_tcp()stays for now (phase 2)1.4 — UI: Update socket path references
File:
crates/hero_compute_ui/src/server.rsdefault_server_socket()→ use SDK'srpc_socket_path()default_explorer_socket()→ use SDK'sexplorer_rpc_socket_path()$HERO_SOCKET_DIR/hero_compute/ui.sock1.5 — CLI: Update socket references and .env generation
File:
crates/hero_compute/src/main.rs.envgeneration:EXPLORER_ADDRESSESin master mode uses new path1.6 — Examples: Update socket paths
Files:
crates/hero_compute_examples/examples/basic_usage.rs,health.rsrpc_socket_path()instead of hardcoded paths1.7 — Config files and metadata
.env.example: Remove old socket name vars, addHERO_SOCKET_DIRdocsheroservice.json: Update socket path and protocolCargo.toml(workspace): Verifyhero_rpc_osisfeatures for AxumRpcServer1.8 — Heartbeat sender: Update for HTTP
File:
crates/hero_compute_server/src/heartbeat_sender.rsown_socket_pathin heartbeat payload to new pathSocket Layout (Before → After)
Before:
After:
Key Technical Details
AxumRpcServerfromhero_rpc_osisis a drop-in replacement forUnixRpcServer—register_app()has the identical signaturehero_rpccommita0f4a08(2026-04-06) added full hero_sockets compliance withX-Hero-Context,X-Hero-Claims,X-Forwarded-Prefixheader extractionVerification
cargo build --workspacecompilescargo test --workspacepasses~/hero/var/sockets/hero_compute/{rpc,ui,explorer_rpc}.sockcurl --unix-socket ~/hero/var/sockets/hero_compute/rpc.sock http://localhost/healthreturns OKImplementation Spec for Issue #65
Objective
Migrate hero_compute from raw newline-delimited JSON-RPC via
UnixRpcServerwith flat socket files to HTTP-over-UDS viaAxumRpcServerwith standardized Hero socket directory layout under$HERO_SOCKET_DIR/hero_compute/.Requirements
UnixRpcServerwithAxumRpcServerin server and explorer~/hero/var/sockets/hero_compute/{rpc,ui,explorer_rpc}.sockHERO_SOCKET_DIRenv var (default~/hero/var/sockets)Socket Layout (Before → After)
~/hero/var/sockets/hero_compute_server.sock~/hero/var/sockets/hero_compute/rpc.sock~/hero/var/sockets/hero_compute_ui.sock~/hero/var/sockets/hero_compute/ui.sock~/hero/var/sockets/hero_compute_explorer.sock~/hero/var/sockets/hero_compute/explorer_rpc.sockFiles to Modify
crates/hero_compute_sdk/src/lib.rscrates/hero_compute_server/src/main.rscrates/hero_compute_server/src/config.rscrates/hero_compute_server/src/heartbeat_sender.rscrates/hero_compute_explorer/src/main.rscrates/hero_compute_explorer/src/config.rscrates/hero_compute_explorer/src/explorer/proxy.rscrates/hero_compute_ui/src/server.rscrates/hero_compute/src/main.rscrates/hero_compute_examples/examples/basic_usage.rscrates/hero_compute_examples/examples/health.rs.env.examplecrates/hero_compute_server/heroservice.jsonImplementation Plan
Step 1: SDK -- Add Path Helpers and Rewrite Transport (Foundation)
Files:
crates/hero_compute_sdk/src/lib.rs,crates/hero_compute_sdk/Cargo.tomlSERVER_SOCKET_NAME/UI_SOCKET_NAMEconstants withsocket_dir(),server_socket_path(),ui_socket_path(),explorer_socket_path()functionsraw_rpc_unix()to HTTP POST over UDS using hyperSERVER_RPC_PATH,EXPLORER_RPC_PATH)Step 2: Server -- Switch to AxumRpcServer
Files:
crates/hero_compute_server/src/main.rs,config.rsUnixRpcServerwithAxumRpcServer+RpcServerConfigserver_socket_path()for socket pathStep 3: Explorer -- Switch to AxumRpcServer
Files:
crates/hero_compute_explorer/src/main.rs,config.rsexplorer_socket_path()Step 4: Explorer Proxy + Heartbeat Sender -- HTTP Transport
Files:
crates/hero_compute_explorer/src/explorer/proxy.rs,crates/hero_compute_server/src/heartbeat_sender.rscall_unix()/call_tcp()andsend_unix()/send_tcp()to use HTTP POSTStep 5: UI, CLI, Examples, Config Files -- Update All References
Files:
crates/hero_compute_ui/src/server.rs,crates/hero_compute/src/main.rs, examples,.env.example,heroservice.jsonAcceptance Criteria
cargo build --workspacesucceedscargo test --workspacepasses~/hero/var/sockets/hero_compute/{rpc,ui,explorer_rpc}.sockHERO_SOCKET_DIRenv var worksNotes
AxumRpcServeris a drop-in forUnixRpcServer--register_app()has the same signature/api/{context}/{domain}/rpc; SDK clientconnect_socket()must target this pathTest Results
All tests pass. No compilation warnings or errors.
Implementation Summary
Changes Made
SDK (
crates/hero_compute_sdk/src/lib.rs)SERVER_SOCKET_NAME/UI_SOCKET_NAMEconstants with path helper functions:socket_dir(),server_socket_path(),ui_socket_path(),explorer_socket_path()SERVER_RPC_PATHandEXPLORER_RPC_PATHconstantsraw_rpc_unix()withhttp_rpc_unix()— HTTP/1.1 POST over Unix Domain SocketServer (
crates/hero_compute_server/)UnixRpcServertoAxumRpcServerwithRpcServerConfig$HERO_SOCKET_DIR/hero_compute/rpc.sockserver_socket_nameconfig field andHERO_COMPUTE_SERVER_SOCKET_NAMEenv varExplorer (
crates/hero_compute_explorer/)UnixRpcServer→AxumRpcServermigration$HERO_SOCKET_DIR/hero_compute/explorer_rpc.sockNodeProxy::call_unix()andcall_tcp()to use HTTP POST transportexplorer_socket_path: PathBufUI (
crates/hero_compute_ui/src/server.rs)default_server_socket(),default_explorer_socket(), and UI socket binding to use SDK helpersraw_rpc_unixcalls withhttp_rpc_unixCLI (
crates/hero_compute/src/main.rs)build_service_definition()andwrite_env()to use SDK path helpersExamples — Updated socket paths to use SDK helpers
Config files — Updated
.env.exampleandheroservice.jsonwith new socket layout documentationSocket Layout (Before → After)
hero_compute_server.sock(raw)hero_compute/rpc.sock(HTTP)hero_compute_ui.sock(HTTP)hero_compute/ui.sock(HTTP)hero_compute_explorer.sock(raw)hero_compute/explorer_rpc.sock(HTTP)Notes
HERO_SOCKET_DIRenv var supported with default~/hero/var/socketsImplementation committed:
9805acfBrowse:
9805acf