Scaffolder/generator: remove hardcoded socket and data paths; drop legacy indexer probe fallback #143
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_rpc#143
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
While auditing socket-path resolution against the
hero_socketsspec and lab's--start --ephemeralpivot (lab clears every env var exceptPATH_ROOT, so any path the generated code hardcodes silently escapes the scratch dir and connects to the contributor's real~/hero/var/), a handful of stale path constructions surfaced in the generator and the scaffolded output. None of them are addressed by #142 (which only owns the bind half viaServiceRpcServer/ServiceAdminServer). They are independent cleanups.Following the principle articulated by #142 (
service.tomlis the only path declaration; consumers never spell directory names): every site in the generator that constructs a socket or data path by string-concat should be replaced by a typed helper that reads the canonical resolver chain (PATH_ROOT→PATH_VAR→HERO_SOCKET_DIR→~/hero/var/sockets).Goals
crates/generator/src/build/scaffold.rs:3313-3314— scaffoldedAppState::from_envcurrently doesresolve_socket_dir().join("{service_name}_server/rpc.sock"). The server's ownservice.tomldeclares{svc}/rpc.sock(no_serversuffix perhero_sockets.md§2). Replace with apeer_socket_path(SERVICE_NAME, "rpc")call against the helper added in #142 (or, if #142 doesn't add it, withresolve_socket_dir().join(SERVICE_NAME).join("rpc.sock")). Scaffolded UI as it stands today cannot connect to the scaffolded server.crates/generator/src/generate/e2e.rs:99— generatedclient_server.rsexample setslet data_dir = "/tmp/herozero_{}_e2e";. Hardcoded/tmpdefeats lab'sPATH_ROOTpivot and anyHERO_DATA_DIRoverride. Resolve viaherolib_core::base::hero_var_dir().join("osisdb").join(...)(or whichever helper survives the #142 consolidation) so the example respects the same env contract as production.crates/generator/src/build/find_tests_emit.rs:160-165— emittedindexer_reachable()helper probes<base>/hero_indexer/rpc.sockthen falls back to legacy flat<base>/hero_indexer_server.sock. The legacy path violateshero_sockets.md§2 (no flat-file sockets directly under$PATH_VAR/sockets/) and is no longer produced by any current hero_indexer build. Drop the fallback; canonical path only.benches/benches/index_perf.rs:537-551— same legacyhero_indexer_server.sockfallback inindexer_socket_path(). Drop the fallback symmetrically with the find-tests emitter so a single canonical layout is enforced everywhere.crates/generator/src/build/scaffold.rsdoc/string drift (lines 1666, 1741, 1790, 2611, 2674, 3290, 3311, 4057, 4059) — README cells and rustdoc comments still reference{name}_server/rpc.sock,{name}_admin/admin.sock,{name}_web/web.sock. Sweep to the canonical{name}/rpc.sock/{name}/admin.sock/{name}/web_<name>.sockshape. (Doc-only; no behaviour change.)Verify the scaffolder snapshot tests still pass after the doc sweep; add a unit test that asserts
AppState::from_envconnects to<svc>/rpc.sock(not<svc>_server/rpc.sock) so the regression can't return.Out of scope
hero_lifecycle/ServiceRpcServer/ServiceAdminServer— that's #142.hero_admin_lib::admin_socket_pathhelper which today computes{name}_admin/admin.sock— #142'sServiceAdminServer.serve()routing throughprepare_socketsmakes that helper obsolete; deletion happens in #142's PR.PATH_VARvsHERO_SOCKET_DIR) — surfaced as a comment on #142.Merged in PR #144 (commit
a302c6955d) ondevelopment.Changes
scaffold.rsUIAppState::from_envnow joins{service_name}/rpc.sock(was{service_name}_server/rpc.sock).generate/e2e.rsdata dir resolved fromresolve_socket_dir().parent()instead of/tmp/herozero_*_e2e.find_tests_emit.rsemittedindexer_reachable()probes only canonicalhero_indexer/rpc.sock.benches/index_perf.rsindexer_socket_path()same legacy fallback dropped.test_scaffold_ui_state_uses_canonical_service_socket_path.151 generator tests pass;
cargo build --workspaceclean.Left for follow-up
The admin/web
main.rstemplate docstrings atscaffold.rs:1666and:1790({name}_admin/admin.sock,{name}_web/web.sock) sit inside the emitters that #142 is rewriting — they will be canonicalised in that PR's scaffolder sweep.The scaffolder itself still emits
herolib_core::base::*calls everywhere (consistent with the rest of the scaffolded code). Migrating those tohero_lifecycle::base::*directly is a follow-up that becomes mechanical once theherolib_core::basedeprecation re-export shim lands inhero_lib.