Upgrade to hero_service template codegen pattern (HeroLifecycle + new OschemaBuildConfig) #44

Closed
opened 2026-05-20 05:56:43 +00:00 by timur · 1 comment
Owner

Context

From the #41 §3 assessment.

hero_logic is already on the OSchema codegen path — but the older version of it. The upgraded path (used by hero_service@518448c and the post-#55 hero_rpc) brings:

  • New OschemaBuildConfig fields (sdk_dir, client_crate_dir, server_crate_dir, server_types_crate, sdk_types_crate, with_wasm()).
  • HeroLifecycle + OServer::run_cli closure pattern (replaces today's OServerConfig::new + server.run().await).
  • Codegen emits typed CRUD wrappers (lets us delete admin's hand-rolled LogicRpcClient / rpc_client.rs).
  • JS / Rhai / Python SDK targets join the Rust SDK.
  • with_wasm() adds WASM-compatible type variants.

Full breakdown in the §3 comment.

What does NOT migrate

Domain code (engine/, seed.rs + seed_flows/, tracing_layer.rs, services/), admin templates + routes.rs, CLI clap tree, 21 hand-written logicservice.* methods. The migration is purely the codegen layer + bootstrap pattern.

Quirks to preserve

  • python_source field has an optional b64: prefix encoding. hero_logic_sdk::decode_python_source must stay as a hand-written helper — codegen won't infer it.

Cost estimate

~1–2 days of focused work (per §3 phase breakdown):

  • build.rs upgrade: 1–2h
  • Server main.rs → HeroLifecycle::run_cli: 2–4h
  • Reorganize types into shared hero_logic types crate: 4–8h
  • Delete admin/src/rpc_client.rs, switch to typed wrappers: 2–4h
  • Adopt JS / Rhai / Python SDK targets: 0–2h
  • E2E validation: 2h

Prerequisites

Do this AFTER the §2 audit cleanup (B1/B2/B7/B10 — bundled in hero_logic#43) lands. Migration PR stays purely about the codegen, not mixed with naming/CI/lint cleanups.

Already unblocked from the hero_rpc side: tier-3 of META #262 (hero_rpc#54/55/56) landed.

Out of scope (this issue)

The hero_rpc2 #[rpc(server, client)] trait-macro vendoring. That's a separate follow-up after this lands.

Acceptance

  • build.rs uses the new OschemaBuildConfig shape
  • Server uses HeroLifecycle + OServer::run_cli
  • Types live in a shared hero_logic types crate consumed by _server + _sdk
  • admin/src/rpc_client.rs deleted; admin uses typed SDK wrappers throughout
  • JS / Rhai / Python SDK targets emit alongside Rust
  • python_source b64-prefix helper preserved
  • lab infocheck clean; full smoke + admin click-through pass
## Context From the [#41 §3 assessment](https://forge.ourworld.tf/lhumina_code/hero_logic/issues/41#issuecomment-34478). hero_logic is already on the OSchema codegen path — but the *older* version of it. The upgraded path (used by `hero_service@518448c` and the post-#55 hero_rpc) brings: - New `OschemaBuildConfig` fields (`sdk_dir`, `client_crate_dir`, `server_crate_dir`, `server_types_crate`, `sdk_types_crate`, `with_wasm()`). - `HeroLifecycle + OServer::run_cli` closure pattern (replaces today's `OServerConfig::new + server.run().await`). - Codegen emits typed CRUD wrappers (lets us delete admin's hand-rolled `LogicRpcClient` / `rpc_client.rs`). - JS / Rhai / Python SDK targets join the Rust SDK. - `with_wasm()` adds WASM-compatible type variants. Full breakdown in the §3 comment. ## What does NOT migrate Domain code (`engine/`, `seed.rs` + `seed_flows/`, `tracing_layer.rs`, `services/`), admin templates + routes.rs, CLI clap tree, 21 hand-written `logicservice.*` methods. The migration is purely the codegen layer + bootstrap pattern. ## Quirks to preserve - `python_source` field has an optional `b64:` prefix encoding. `hero_logic_sdk::decode_python_source` must stay as a hand-written helper — codegen won't infer it. ## Cost estimate ~1–2 days of focused work (per §3 phase breakdown): - build.rs upgrade: 1–2h - Server main.rs → `HeroLifecycle::run_cli`: 2–4h - Reorganize types into shared `hero_logic` types crate: 4–8h - Delete `admin/src/rpc_client.rs`, switch to typed wrappers: 2–4h - Adopt JS / Rhai / Python SDK targets: 0–2h - E2E validation: 2h ## Prerequisites Do this AFTER the §2 audit cleanup (B1/B2/B7/B10 — bundled in [hero_logic#43](https://forge.ourworld.tf/lhumina_code/hero_logic/issues/43)) lands. Migration PR stays purely about the codegen, not mixed with naming/CI/lint cleanups. Already unblocked from the hero_rpc side: tier-3 of META #262 (hero_rpc#54/55/56) landed. ## Out of scope (this issue) The hero_rpc2 `#[rpc(server, client)]` trait-macro vendoring. That's a separate follow-up after this lands. ## Acceptance - `build.rs` uses the new `OschemaBuildConfig` shape - Server uses `HeroLifecycle + OServer::run_cli` - Types live in a shared `hero_logic` types crate consumed by `_server` + `_sdk` - `admin/src/rpc_client.rs` deleted; admin uses typed SDK wrappers throughout - JS / Rhai / Python SDK targets emit alongside Rust - `python_source` b64-prefix helper preserved - `lab infocheck` clean; full smoke + admin click-through pass
Author
Owner

Migration shipped in PR #46. All acceptance criteria green:

  • build.rs uses the new OschemaBuildConfig shape (sdk_dir, client_crate_dir, server_crate_dir, server_types_crate, sdk_types_crate, with_wasm, with_python_sdk, with_rhai)
  • Server uses HeroLifecycle + OServer::run_cli
  • Types live in shared hero_logic_types crate consumed by both _server and _sdk
  • admin/src/rpc_client.rs deleted; admin uses typed SDK wrappers throughout (typed logic_service_* calls + an AppState::rpc_call helper routing raw calls through the typed SDK transport)
  • JS / Rhai / Python SDK targets emit alongside Rust into top-level sdk/
  • python_source::decode_python_source b64-prefix helper preserved as a hand-written file the SDK builder auto-discovers across regens
  • cargo build --workspace clean; lab infocheck: 3 crate(s) clean, 0 with issues, 0 findings
  • Smoke verified end-to-end: server binds rpc.sock, CLI search/workflow versions succeed through typed SDK, admin pages render through both typed-SDK and raw-rpc paths

Three small hero_rpc generator follow-ups identified that would eliminate the build.rs post-process hack used here — see PR #46 description.

Migration shipped in PR #46. All acceptance criteria green: - ✅ `build.rs` uses the new `OschemaBuildConfig` shape (sdk_dir, client_crate_dir, server_crate_dir, server_types_crate, sdk_types_crate, with_wasm, with_python_sdk, with_rhai) - ✅ Server uses `HeroLifecycle + OServer::run_cli` - ✅ Types live in shared `hero_logic_types` crate consumed by both `_server` and `_sdk` - ✅ `admin/src/rpc_client.rs` deleted; admin uses typed SDK wrappers throughout (typed `logic_service_*` calls + an `AppState::rpc_call` helper routing raw calls through the typed SDK transport) - ✅ JS / Rhai / Python SDK targets emit alongside Rust into top-level `sdk/` - ✅ `python_source::decode_python_source` b64-prefix helper preserved as a hand-written file the SDK builder auto-discovers across regens - ✅ `cargo build --workspace` clean; `lab infocheck`: 3 crate(s) clean, 0 with issues, 0 findings - ✅ Smoke verified end-to-end: server binds rpc.sock, CLI search/workflow versions succeed through typed SDK, admin pages render through both typed-SDK and raw-rpc paths Three small hero_rpc generator follow-ups identified that would eliminate the build.rs post-process hack used here — see PR #46 description.
timur closed this issue 2026-05-20 09:35:45 +00:00
Sign in to join this conversation.
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_logic#44
No description provided.