Migrate hero_service onto hero_rpc2 (hero_rpc#90 Phase 2) #5

Merged
timur merged 1 commit from issue-90-phase2-hero-service into development 2026-05-20 23:16:44 +00:00
Owner

First OSIS service migrated off OServer onto hero_rpc2 per hero_rpc#90 Phase 2. This validates the migration path and becomes the template for Phase 3 (hero_logic / hero_compute / hero_db).

Mirrors example/recipe_server from Phase 1 — the hero_rpc2 transport reference. Smoke transcript is in the commit message; here's the short version:

Endpoint Result
GET /health {status: ok, service: hero_service, version: 0.1.0}
GET /.well-known/heroservice.json canonical shape, protocol=openrpc, socket=rpc
GET /openrpc.json 7 methods, matches docs/openrpc.json exactly
POST /rpc rpc.health {status: ok, …, trusted: true}
POST /rpc servicecatalog.list [] (empty catalog, storage clean)
lab infocheck 2 crates clean, 0 findings

Depends on hero_rpc PR #99 (OpenRpcDocument::from_value constructor — merged). Otherwise the embedded docs/openrpc.json can't be piped through with_discover.

Changes

  • _server/src/main.rs rewritten to ServerBuilder + rpc2_adapter + with_discover(OpenRpcDocument::from_value(parsed)).
  • _server/Cargo.toml: dropped deleted hero_rpc_server, added hero_rpc2 + jsonrpsee.
  • _server/service.toml: socket path now hero_service/rpc.sock (canonical hero_sockets shape).
  • _sdk/Cargo.toml: hero_rpc_clienthero_rpc2 + jsonrpsee.
  • _sdk/src/catalog/{mod,osis_client_generated,types}.rs deleted; replaced by codegen-generated _sdk/src/catalog.rs (the rpc2 trait file).

Out of scope

  • Repo doesn't yet follow hero_rpc#70's sdk/{rust,rhai}/ workspace layout (it still has sibling _sdk / _rhai crates). Leave as-is for now — the client_crate_dir path keeps codegen pointed at the legacy location and everything still works. Lift the layout in a separate cleanup PR if/when desired.
First OSIS service migrated off OServer onto hero_rpc2 per [hero_rpc#90](https://forge.ourworld.tf/lhumina_code/hero_rpc/issues/90) Phase 2. This validates the migration path and becomes the template for Phase 3 (hero_logic / hero_compute / hero_db). Mirrors `example/recipe_server` from Phase 1 — the hero_rpc2 transport reference. Smoke transcript is in the commit message; here's the short version: | Endpoint | Result | |---|---| | `GET /health` | `{status: ok, service: hero_service, version: 0.1.0}` | | `GET /.well-known/heroservice.json` | canonical shape, `protocol=openrpc`, `socket=rpc` | | `GET /openrpc.json` | 7 methods, matches `docs/openrpc.json` exactly | | `POST /rpc rpc.health` | `{status: ok, …, trusted: true}` | | `POST /rpc servicecatalog.list` | `[]` (empty catalog, storage clean) | | `lab infocheck` | 2 crates clean, 0 findings | Depends on [hero_rpc PR #99](https://forge.ourworld.tf/lhumina_code/hero_rpc/pulls/99) (`OpenRpcDocument::from_value` constructor — merged). Otherwise the embedded `docs/openrpc.json` can't be piped through `with_discover`. ### Changes - `_server/src/main.rs` rewritten to `ServerBuilder` + `rpc2_adapter` + `with_discover(OpenRpcDocument::from_value(parsed))`. - `_server/Cargo.toml`: dropped deleted `hero_rpc_server`, added `hero_rpc2` + `jsonrpsee`. - `_server/service.toml`: socket path now `hero_service/rpc.sock` (canonical `hero_sockets` shape). - `_sdk/Cargo.toml`: `hero_rpc_client` → `hero_rpc2 + jsonrpsee`. - `_sdk/src/catalog/{mod,osis_client_generated,types}.rs` deleted; replaced by codegen-generated `_sdk/src/catalog.rs` (the rpc2 trait file). ### Out of scope - Repo doesn't yet follow hero_rpc#70's `sdk/{rust,rhai}/` workspace layout (it still has sibling `_sdk` / `_rhai` crates). Leave as-is for now — the `client_crate_dir` path keeps codegen pointed at the legacy location and everything still works. Lift the layout in a separate cleanup PR if/when desired.
OServer is gone in hero_rpc#90 Phase 1; this PR migrates the
hero_service template — the first real OSIS service to land on the new
path. Pattern mirrors example/recipe_server (Phase 1's reference).

What changed
============

crates/hero_service_server/src/main.rs (rewritten)
- Replaces OServer::run_cli with explicit lifecycle dispatch
  (--start / --stop / --info), prepare_sockets + print_startup_banner,
  jsonrpsee::RpcModule built from rpc2_adapter::register_methods, and
  hero_rpc2::ServerBuilder driving the UDS HTTP transport.
- Wires with_discover(OpenRpcDocument::from_value(parsed_spec)) using
  the embedded docs/openrpc.json (the canonical OpenRPC source per #73)
  so GET /openrpc.json + rpc.discover return the same authoritative
  document hero_router probes for service identity. This depends on
  hero_rpc2 v0.6.1+ (the from_value constructor landed in hero_rpc PR
  #99).
- Header lift now opts into x-forwarded-prefix so the OSIS handlers can
  pick up the routed prefix from hero_router.
- tokio::signal::ctrl_c() shutdown path so hero_proc's SIGTERM cleans
  up the socket file.

crates/hero_service_server/Cargo.toml
- Drops the deleted hero_rpc_server dep.
- Adds hero_rpc2 + jsonrpsee. jsonrpsee is direct so the
  #[rpc(server, client)] macro in the generated sdk/rust/<domain>.rs
  resolves ::jsonrpsee::… paths at consumer-crate expansion.

crates/hero_service_server/service.toml
- Socket path moved from `hero_service_server/rpc.sock` to
  `hero_service/rpc.sock` (canonical hero_sockets shape — service name
  directory, no binary-role suffix).

crates/hero_service_sdk
- Cargo.toml: hero_rpc_client → hero_rpc2 + jsonrpsee.
- src/catalog/{mod,osis_client_generated,types}.rs deleted — replaced
  by the auto-generated src/catalog.rs (`#[rpc(server, client)] pub
  trait Catalog`) emitted by the new rust_rpc2 emitter.

Smoke results
=============
PATH_ROOT=$HOME/hero HERO_SOCKET_DIR=/tmp/hero_service_smoke \
  ./target/debug/hero_service_server

curl --unix-socket /tmp/hero_service_smoke/hero_service/rpc.sock \
     http://localhost/health
  → {"service":"hero_service","status":"ok","version":"0.1.0"}

curl --unix-socket /tmp/hero_service_smoke/hero_service/rpc.sock \
     http://localhost/.well-known/heroservice.json
  → {"protocol":"openrpc","name":"hero_service","title":"Hero Service Catalog",
     "version":"0.1.0","description":"Hero Service Catalog — JSON-RPC server",
     "socket":"rpc"}

curl --unix-socket … http://localhost/openrpc.json | jq '.methods | length'
  → 7  (matches docs/openrpc.json)

curl … -X POST -d '{"jsonrpc":"2.0","id":1,"method":"rpc.health","params":[]}'
  → {"result":{"status":"ok","service":"hero_service","version":"0.1.0",
     "context":null,"trusted":true}}

curl … -X POST -d '{"jsonrpc":"2.0","id":2,"method":"servicecatalog.list","params":{}}'
  → {"result":[]}   (empty catalog — storage clean)

lab infocheck → 2 crates clean, 0 findings.
timur merged commit 017c31b0fc into development 2026-05-20 23:16:44 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_service!5
No description provided.