Align OSchema/UDS layout with canonical hero_osis/hero_voice pattern #15
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
hero_livekitwires OSchema → Rust / OpenRPC / OSIS codegen, but its layout drifts from the canonical pattern used across the Hero ecosystem (hero_osis,hero_voice). The canonical pattern (peroschema_code_generation§4 + §9 and observed in siblings) placesschemas/,docs/schemas/, andsdk/at the workspace root and uses a richerbuild.rsthat auto-generates the SDK client crate and declares the CLI/companion/UI layout so the multi-socket OServer wiring comes for free.Canonical reference —
hero_voiceCanonical reference —
hero_osisbuild.rs extrasThese flags make the generator emit: (a) the SDK crate's client code directly into
../hero_osis_sdk/src/…, (b) the single-bin CLI registering rpc.sock + ui.sock per domain with the admin UI router mounted in-process.Current
hero_livekitlayout (drift)crates/hero_livekit_server/schemas/livekit/livekit.oschema— nested inside server cratecrates/hero_livekit_server/docs/schemas/— nested inside server cratecrates/hero_livekit_server/sdk/js/— nested inside server cratecrates/hero_livekit_server/build.rs— runs codegen; lives in the server crate, not a core cratebuild.rsuses only.schemas_dir("schemas").docs_dir("docs/schemas").domain("livekit", ...).generate_server().nested_layout().debug(true)— missingclient_crate_dir,sdk_dir,single_bin,bin_companions,bin_ui,sdk_types_crateopenrpc.jsonsits atsrc/livekit/core/openrpc.json(deeply nested) instead of at the server crate root next tomain.rs(likehero_voice_server/openrpc.json)hero_livekit_sdkcrate → UI and examples reach into the server crate for client types (coupling violation — see also issue #3)Why it matters
openrpc_client!macro in a futurehero_livekit_sdkwants the OpenRPC spec at a stable relative path. Siblings followcrates/<svc>_server/openrpc.json..single_bin+.bin_uiis how the multi-socket OServer gets generated (per-domainrpc.sock+ui.sock, withX-Hero-Context/X-Hero-Claims/X-Forwarded-Prefixheaders handled for free). Without these, the CLI in issue #1 will have to re-implement wiring the generator already produces.docs/schemas/+sdk/is what Hero's doc tooling scans.Goals
crates/hero_livekit_server/schemas/→schemas/livekit/livekit.oschema.crates/hero_livekit_server/docs/schemas/→docs/schemas/.crates/hero_livekit_server/sdk/js/→sdk/js/.crates/hero_livekit/(core crate) — thin crate that hostsbuild.rsand exposeshero_livekit::livekit::{core, server}generated modules. Movebuild.rshere; server crate depends on it.openrpc.json— emit/copy tocrates/hero_livekit_server/openrpc.jsonnext tomain.rs(matchinghero_voice_server), not nested undersrc/livekit/core/.build.rs(in the new core crate) to:crates/hero_livekit_sdk/Cargo.toml+src/lib.rsthat callsopenrpc_client!("../hero_livekit_server/openrpc.json")and re-exports core types fromhero_livekit(see #3).main.rs— replaceinclude_str!("../../hero_livekit_server/src/livekit/core/openrpc.json")style paths withinclude_str!("../openrpc.json"), matchinghero_voice_server/src/main.rs:40.hero_livekit_sdk, drop any directopenrpc_client!/ hand-rolled clients.Cargo.tomlmembers list and the workspace README / docs pointing at the new schema/doc locations.cargo build --workspace+cargo clippy --workspace -- -D warningsboth succeed after the move.Related skills:
oschema,oschema_code_generation,hero_sockets,hero_crates_best_practices_check,hero_stack_getting_started.Related issues:
.single_bin()output).client_crate_dir()output)Implementation Spec for Issue #15
Objective
Restructure the hero_livekit workspace to match the canonical OSchema layout used by hero_voice and hero_os. This involves promoting schemas, docs, and sdk directories to the workspace root, creating a new
hero_livekitcore crate that owns the build.rs and domain types, creating ahero_livekit_sdkcrate with a generated OSIS client, moving server-specific generated code to the server crate, relocating openrpc.json to the server crate root, and updating all downstream crates that reference the old deeply-nested paths.Requirements
schemas/livekit/livekit.oschemadocs/schemas/sdk/js/crates/hero_livekit/core crate hosts build.rs and exposes generated types/core modulescrates/hero_livekit_sdk/crate provides a generated OSIS clientcrates/hero_livekit_server/openrpc.json(next to Cargo.toml)cargo build --workspaceandcargo clippy --workspacesucceedFiles to Create
schemas/livekit/livekit.oschemacrates/hero_livekit_server/schemas/livekit/livekit.oschemacrates/hero_livekit/Cargo.tomlcrates/hero_livekit/build.rscrates/hero_livekit/src/crates/hero_livekit_sdk/Cargo.tomlcrates/hero_livekit_sdk/src/lib.rsFiles to Modify
Cargo.toml(workspace root)crates/hero_livekitandcrates/hero_livekit_sdkto members; add workspace depscrates/hero_livekit_server/Cargo.tomlhero_livekit; remove[build-dependencies]crates/hero_livekit_server/src/livekit/mod.rscrates/hero_livekit_server/src/livekit/server/rpc.rscrates/hero_livekit_server/src/livekit/server/authz.rscrates/hero_livekit_ui/src/main.rscrates/hero_livekit_examples/examples/basic_usage.rscrates/hero_livekit_examples/examples/health.rscrates/hero_livekit_rhai/src/client.rsdocs/architecture.mddocs/api.mdFiles to Delete
crates/hero_livekit_server/schemas/crates/hero_livekit_server/docs/crates/hero_livekit_server/sdk/crates/hero_livekit_server/build.rscrates/hero_livekit_server/src/livekit/core/Implementation Plan
Step 1: Promote schemas, docs/schemas, and sdk to workspace root
Files:
schemas/,docs/schemas/,sdk/js/crates/hero_livekit_server/schemas/livekit/livekit.oschematoschemas/livekit/livekit.oschemacrates/hero_livekit_server/docs/schemas/todocs/schemas/crates/hero_livekit_server/sdk/js/types_generated.jstosdk/js/types_generated.jsDependencies: none
Step 2: Create the hero_livekit core crate
Files:
crates/hero_livekit/Cargo.toml,crates/hero_livekit/build.rs,crates/hero_livekit/src/Dependencies: Step 1
Step 3: Create the hero_livekit_sdk crate
Files:
crates/hero_livekit_sdk/Cargo.toml,crates/hero_livekit_sdk/src/lib.rsDependencies: Step 2
Step 4: Update workspace Cargo.toml
Files:
Cargo.tomlcrates/hero_livekitandcrates/hero_livekit_sdkto membersDependencies: Steps 2, 3
Step 5: Refactor the server crate to depend on the core crate
Files:
crates/hero_livekit_server/Cargo.toml,crates/hero_livekit_server/src/livekit/mod.rs,crates/hero_livekit_server/src/livekit/server/rpc.rs,crates/hero_livekit_server/src/livekit/server/authz.rsDependencies: Step 4
Step 6: Update downstream crates (UI, examples, rhai)
Files:
crates/hero_livekit_ui/src/main.rs,crates/hero_livekit_examples/examples/basic_usage.rs,crates/hero_livekit_examples/examples/health.rs,crates/hero_livekit_rhai/src/client.rs"../hero_livekit_server/src/livekit/core/openrpc.json"to"../hero_livekit_server/openrpc.json"Dependencies: Step 5
Step 7: Update documentation
Files:
docs/architecture.md,docs/api.mdDependencies: Step 5
Step 8: Build, fix, and verify
cargo build --workspaceto trigger code generationcargo clippy --workspacecargo test --workspaceDependencies: Steps 5, 6, 7
Acceptance Criteria
schemas/livekit/livekit.oschemaexists at workspace rootdocs/schemas/exists at workspace rootsdk/js/types_generated.jsexists at workspace rootcrates/hero_livekit/exists with canonical build.rscrates/hero_livekit_sdk/exists with generated client codecrates/hero_livekit_server/openrpc.jsonat server crate rootcargo build --workspacesucceedscargo clippy --workspacesucceedscargo test --workspacepassesNotes
hero_rpc_osis::buildto minimize churn. A later issue can upgrade tohero_rpc_generatorif needed.server_crate_dir("../hero_livekit_server")to keep server-generated code in the server crate (hero_os pattern), since the server has substantial hand-written code (rpc.rs 880+ lines, authz.rs 290+ lines).hero_livekit_ui::build_routerwhich does not yet exist. These declarative options can be set now and the actual binary generation addressed in a follow-up.pub use hero_livekit::livekit::core as core;re-export in the server's livekit/mod.rs so existing relative imports continue to work.Test Results
cargo build --workspace: PASScargo clippy --workspace -- -D warnings: PASScargo test --workspace: PASS -- 34 tests passed, 0 failed, 4 doc-tests ignoredTest breakdown
All existing tests pass after the restructuring.
Implementation Summary
Changes Made
New crates created:
crates/hero_livekit/-- Core crate with build.rs, generated types, server logic, and domain handlerscrates/hero_livekit_sdk/-- Generated OSIS client crate withLivekitClientfor consuming the APIDirectories promoted to workspace root:
schemas/livekit/livekit.oschema(wascrates/hero_livekit_server/schemas/)docs/schemas/(wascrates/hero_livekit_server/docs/schemas/)sdk/js/types_generated.js(wascrates/hero_livekit_server/sdk/js/)Server crate refactored:
build.rs(moved to core crate)src/livekit/core/directory (types now live in core crate)hero_livekitcore crateauthz.rs(authorization wrapper) in the server crateopenrpc.jsonnow at server crate root (was deeply nested atsrc/livekit/core/openrpc.json)Core crate build.rs uses full canonical config:
schemas_dir,docs_dir,sdk_dirpointing to workspace rootclient_crate_dirauto-generates SDK crate codesdk_types_crate,single_bin,bin_companions,bin_uideclared for future usegenerate_server(),with_wasm(),nested_layout()Downstream crates updated:
hero_livekit_ui,hero_livekit_examples,hero_livekit_rhai--openrpc_client!paths updated to"../hero_livekit_server/openrpc.json"Documentation updated:
docs/architecture.md-- updated code layout diagramdocs/api.md-- updated spec and schema pathsWorkspace Cargo.toml:
crates/hero_livekitandcrates/hero_livekit_sdkto membershero_livekit,hero_livekit_sdk,hero_rpc_client,herolib_otomlto workspace dependenciesTest Results
cargo build --workspace: PASScargo clippy --workspace -- -D warnings: PASScargo test --workspace: 34 tests passed, 0 failedNotes
single_binoption in build.rs generates asrc/bin/hero_livekit.rsorchestrator binary. This was removed (viaautobins = false) as it requireshero_livekit_ui::build_routerwhich does not yet exist. The CLI self-start binary will be addressed in issue #1.hero_rpc_client::OsisClient(cross-platform client) rather than theopenrpc_client!macro. Downstream crates can migrate tohero_livekit_sdkin a follow-up.Pull request opened: #18
This PR implements the changes discussed in this issue.