hero_rpc#124: lab service --ephemeral / --json / --pid / --test verb #285
No reviewers
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_skills!285
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-124-lab-ephemeral"
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?
PR 2/3 for hero_rpc#124 (lifecycle alignment). Depends on the merged hero_rpc PR #126 (
MultiDomainBuilder+ scaffolder updates).Issue: lhumina_code/hero_rpc#124
PR1 (hero_rpc): lhumina_code/hero_rpc#126
What this PR does
Three new sub-flags on the existing
lab service <name>subcommand, plus one new verb. The scaffoldedtests/src/lib.rsin hero_rpc PR1 shells out to these — landing this PR makes those subprocess drivers actually work.lab service <name> --start --ephemeral [--json]/tmp/lab-<pid>-<n>/scratch dir.PATH_ROOToverride routeshero_var_dir()andresolve_socket_dir()at the tempdir — nothing leaks into the contributor's real~/hero/var/.--json: emits one line of{"name","pid","rpc_socket","data_dir","ready_at"}— the stable shapetests/src/lib.rs::spin_up_serviceparses.--json: human banner with pid, socket, data dir, and the matching--stop --pidrecipe.lab service <name> --stop --pid <N>/tmp/.lab-ephemeral-pid-<N>index file.ServiceHandle::Dropin scaffolded tests never panics in teardown.lab service <name> --test [layer]tests_pyramidfive layers.--start --ephemeralpath so a hang or leak in one layer can't pollute the next.layer1→cargo test --workspacelayer2→ spawn ephemeral →nu tests/smoke.nu --socket <path>→ stoplayer3→ same shape,tests/api_integration.nulayer4→ eachtests/e2e_*.nuin turnlayer5→ hero_browser MCP suite undertestcases/(placeholder — the dispatcher prints a follow-up message until the browser-suite shape is wired in a sibling PR)layer1/…/layer5/all) — leaves room for--test fastshorthands without breakage.hero_service_test_completeskill updateAdds a §0 saying
lab service <name> --testis the sanctioned cargo + nu + browser bridge, and the existing §1 rule ("restart only via /nu_service_use") is explicitly scoped to production-like runs — closes the "cargo Layer 1 is fine but unmentioned" gap the prior framing flagged.Implementation notes
parse_and_run_service_managepeels off value-bearing flags (--pid N,--test layerX) before the existing boolean contains-check. Backwards compatible — every legacy verb keeps its shape.--testmodifier (socket isolation when combined with--start) still works — it falls through to the legacycmd_service_managewhenever--testappears alongside another verb. Standalone--testis the new pyramid verb.crates/lab/src/service/ephemeral.rs(~330 lines,start_ephemeral+stop_ephemeral_by_pid+ spawn-and-wait helpers) andcrates/lab/src/service/test_verb.rs(~200 lines, layer dispatch).Acceptance
lab service <name> --start --ephemeral --jsonprints a single JSON line withname,pid,rpc_socket,data_dir,ready_at.lab service <name> --stop --pid Nis idempotent on a dead pid (verified by inspection of the SIGTERM/ESRCH path and the kill(pid, None) liveness check).lab service <name> --testdispatches per layer with fail-fast semantics.lab service hero_proc --start --test(legacy modifier) still works —--testfalls through tocmd_service_managewhen combined with another verb.cargo check -p labclean — no new warnings from the added code.cargo test -p lab --libgreen in clean env (one pre-existing test readsFORGE_TOKENenv; passes when shell env is clean).hero_service_test_completeSKILL.md§0calls outlab service --testas the sanctioned cargo + nu + browser bridge.Decisions taken without confirmation
<scratch>/var/osisdb/root— mirrors production's~/hero/var/osisdb/rootlayout so the sameMultiDomainBuilder::production()(from hero_rpc PR1) finds its data dir under the PATH_ROOT override without any code path divergence.<scratch>/var/sockets/<service>/rpc.sock— same shaperesolve_socket_dir()produces fromPATH_ROOTwhenHERO_SOCKET_DIRisn't set. Explicit env clear keeps the resolution deterministic./tmp, not in-memory state —--startand--stopcan be called from separatelabprocesses (the canonical test pattern is start in one process, stop fromDropin another).hero_service_test_complete; this PR prints a clear "follow-up" message and skips. Sibling browser-suite PR will replace the placeholder.cargo fmt --all— running it once on the worktree reformatted ~80 unrelated files (rebase noise the rest oflabwould catch on its nextfmt --check). Reverted those and shipped only the targeted edits. Pre-existing fmt drift ondevelopmentis a separate cleanup.Follow-ups not done here
hero_service_test_completefirst.--ephemeral(admin/web alongside server) — out of scope per the issue ("--ephemeralonly spawns the server binary by default").lab's ~80 fmt-drifted files in a separate cleanup PR.Test plan
cargo check -p labclean.cargo test -p lab --libgreen (in clean env).cargo clippy -p lab— no new warnings fromephemeral.rs/test_verb.rs.hero_servicefrom scratch and runslab service hero_service --testend-to-end.