Deprecate OServer — migrate hero_os to HeroRpcServer #30

Open
opened 2026-03-17 10:30:47 +00:00 by timur · 3 comments
Owner

Context

With HeroRpcServer (#27) handling socket binding, lifecycle, and mandatory endpoints for all Hero services, OServer in hero_rpc_server is now redundant.

What OServer Does Today

  1. Socket binding + CLI + lifecycle → now HeroRpcServer
  2. Domain registration (register:: with OsisAppRpcHandler + OsisDomainInit) → ServerState + UnixRpcServer::register_app() — already reusable without OServer
  3. Core management socket (context.list, context.add, context.import/export, domain.list) → can become routes on the service's HeroRpcServer
  4. Per-domain sockets (hero_db_{context}_{domain}.sock) → replaced by single socket with _context in params
  5. Context registry (TOML persistence) → ContextRegistry stays, just not tied to OServer

Migration Plan

hero_os_server

Replace OServer::run_cli() with:

HeroRpcServer::new("hero_os_server", include_str!("../openrpc.json"))
    .description("Hero OS")
    .serve(|| async {
        let state = ServerState::new(...);
        // Register domains per context
        let server = UnixRpcServer::with_state(state.clone());
        for ctx in &contexts {
            server.register::<OsisDesktop>(ctx, "desktop").await?;
        }
        // Build router with /rpc using dispatch_jsonrpc_auto_context
        Ok(Router::new()
            .route("/rpc", post(rpc_handler))
            .with_state(state))
    })
    .await

Same pattern as hero_osis_server migration.

hero_os_ui (WASM/Dioxus)

Works with HeroUiServer as-is. The WASM app is just different static assets — the server pattern is identical:

HeroUiServer::new("hero_os_ui")
    .serve(|| async { Ok(build_dioxus_router()) })
    .await

Cleanup

  • Deprecate OServer, ServerCli, ServerCommand in hero_rpc_server
  • Keep ServerState, ContextRegistry, domain registration helpers — they're still useful
  • Move management RPC methods (context.list, etc.) to a reusable Axum handler module
  • Eventually remove hero_rpc_server crate dependency from services (replace with hero_service + hero_rpc_osis)

Depends On

  • #27 — HeroRpcServer/HeroUiServer (done)
  • #29 — Standard tests (validates migration)
## Context With `HeroRpcServer` (#27) handling socket binding, lifecycle, and mandatory endpoints for all Hero services, `OServer` in `hero_rpc_server` is now redundant. ## What OServer Does Today 1. **Socket binding + CLI + lifecycle** → now `HeroRpcServer` 2. **Domain registration** (register::<A> with OsisAppRpcHandler + OsisDomainInit) → `ServerState` + `UnixRpcServer::register_app()` — already reusable without OServer 3. **Core management socket** (context.list, context.add, context.import/export, domain.list) → can become routes on the service's HeroRpcServer 4. **Per-domain sockets** (hero_db_{context}_{domain}.sock) → replaced by single socket with `_context` in params 5. **Context registry** (TOML persistence) → `ContextRegistry` stays, just not tied to OServer ## Migration Plan ### hero_os_server Replace `OServer::run_cli()` with: ```rust HeroRpcServer::new("hero_os_server", include_str!("../openrpc.json")) .description("Hero OS") .serve(|| async { let state = ServerState::new(...); // Register domains per context let server = UnixRpcServer::with_state(state.clone()); for ctx in &contexts { server.register::<OsisDesktop>(ctx, "desktop").await?; } // Build router with /rpc using dispatch_jsonrpc_auto_context Ok(Router::new() .route("/rpc", post(rpc_handler)) .with_state(state)) }) .await ``` Same pattern as hero_osis_server migration. ### hero_os_ui (WASM/Dioxus) Works with `HeroUiServer` as-is. The WASM app is just different static assets — the server pattern is identical: ```rust HeroUiServer::new("hero_os_ui") .serve(|| async { Ok(build_dioxus_router()) }) .await ``` ### Cleanup - Deprecate `OServer`, `ServerCli`, `ServerCommand` in `hero_rpc_server` - Keep `ServerState`, `ContextRegistry`, domain registration helpers — they're still useful - Move management RPC methods (context.list, etc.) to a reusable Axum handler module - Eventually remove `hero_rpc_server` crate dependency from services (replace with `hero_service` + `hero_rpc_osis`) ## Depends On - #27 — HeroRpcServer/HeroUiServer (done) - #29 — Standard tests (validates migration)
Author
Owner

Migration Strategy

Before starting the OServer deprecation, merging outstanding branches into development first:

  1. development_timurdevelopment — lifecycle/zinit/service config work (8 commits). This is foundational since it set up the OServer::run_cli() pattern we're now replacing.
  2. development_dioxus_bootstrap_2development — Bootstrap OS shell, island windows, scrolling fixes (20 commits). Orthogonal but large; integrating first avoids painful 3-way merges later.
  3. development_mik_6_1development — Dock layout and popup grid improvements (5 commits).

Then create a fresh development_deprecate_oserver branch from the merged development and do the migration there.

Why merge first

  • Issue #30 touches hero_os_server/src/main.rs which the lifecycle commits also modified — working on the final state avoids conflicts
  • The bootstrap branches add new crate structure (island registration, OS shell) — need the full picture before refactoring
  • HeroRpcServer / HeroUiServer are already implemented in hero_rpc/crates/service/ — the dependency (#27) is ready
## Migration Strategy Before starting the OServer deprecation, merging outstanding branches into `development` first: 1. **`development_timur` → `development`** — lifecycle/zinit/service config work (8 commits). This is foundational since it set up the `OServer::run_cli()` pattern we're now replacing. 2. **`development_dioxus_bootstrap_2` → `development`** — Bootstrap OS shell, island windows, scrolling fixes (20 commits). Orthogonal but large; integrating first avoids painful 3-way merges later. 3. **`development_mik_6_1` → `development`** — Dock layout and popup grid improvements (5 commits). Then create a fresh **`development_deprecate_oserver`** branch from the merged `development` and do the migration there. ### Why merge first - Issue #30 touches `hero_os_server/src/main.rs` which the lifecycle commits also modified — working on the final state avoids conflicts - The bootstrap branches add new crate structure (island registration, OS shell) — need the full picture before refactoring - `HeroRpcServer` / `HeroUiServer` are already implemented in `hero_rpc/crates/service/` — the dependency (#27) is ready
Author
Owner

Starting Migration

All three branches merged into development

Now working on development_deprecate_oserver — starting with hero_os_server migration from OServer::run_cli()HeroRpcServer, then hero_os_uiHeroUiServer.

## Starting Migration All three branches merged into `development` ✓ Now working on `development_deprecate_oserver` — starting with `hero_os_server` migration from `OServer::run_cli()` → `HeroRpcServer`, then `hero_os_ui` → `HeroUiServer`.
Author
Owner

Migration Complete

Branch: development_deprecate_oserver (3d15262)

hero_os_server

  • OServer::run_cli()HeroRpcServer::run_simple()
  • Single socket at ~/hero/var/sockets/hero_os_server.sock
  • /rpc handler dispatches Type.method calls to OsisDesktop domain directly
  • Removed hero_rpc_server dep, added hero_service

hero_os_ui

  • Manual ZinitLifecycle + LifecycleCommandHeroServer::run_raw()
  • Keeps TCP + Unix dual binding (custom serve args via clap::Args)
  • Removed hero_rpc_server dep, added hero_service

Cleanup

  • hero_rpc_server patch removed from workspace (no longer used)
  • Fixed pre-existing duplicate trigger functions in desktop/rpc.rs
  • Updated lifecycle docs with new patterns

Both crates compile clean. Ready for PR when reviewed.

## Migration Complete Branch: `development_deprecate_oserver` ([3d15262](https://forge.ourworld.tf/lhumina_code/hero_os/commit/3d15262)) ### hero_os_server - `OServer::run_cli()` → `HeroRpcServer::run_simple()` - Single socket at `~/hero/var/sockets/hero_os_server.sock` - `/rpc` handler dispatches `Type.method` calls to `OsisDesktop` domain directly - Removed `hero_rpc_server` dep, added `hero_service` ### hero_os_ui - Manual `ZinitLifecycle` + `LifecycleCommand` → `HeroServer::run_raw()` - Keeps TCP + Unix dual binding (custom serve args via `clap::Args`) - Removed `hero_rpc_server` dep, added `hero_service` ### Cleanup - `hero_rpc_server` patch removed from workspace (no longer used) - Fixed pre-existing duplicate trigger functions in `desktop/rpc.rs` - Updated lifecycle docs with new patterns Both crates compile clean. Ready for PR when reviewed.
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/home#30
No description provided.