feat(generator): emit Python SDK clients alongside Rust #45
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_rpc#45
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
Python clients for OSIS (and other OpenRPC) services are currently generated at runtime by
hero_routervia thepython_codegenmodule. The on-disk artefacts live in~/.hero/var/router/python/and are written by hero_router whenever it scans / a consumer hitsrouter.python_client.This works but couples hero_router to consumer-language codegen, which isn't really its job. The Rust SDK is already emitted by
hero_rpc's generator into the configuredsdk_dir/<domain>/(seehero_osis_sdkfor examples). Python should follow the same pattern.Proposal
Extend
hero_rpc'sOschemaBuilder/ generator to also emit Python clients into<sdk_dir>/python/per domain. The codegen logic itself can be lifted fromhero_router/crates/hero_router/src/python_codegen.rs— it already knows how to:@dataclasspercomponents.schemasentry (with required fields first, optional fields withOptional[T] = None/field(default_factory=list)defaults)*_getreturns the typed dataclass instance viaType(**_raw); array-of-$refreturns wraps each elementfrom→from_)*_interface.pyLLM-context stub alongside the full*_client.pyMigration plan
python_codegen.rsfrom hero_router intohero_rpc/crates/generator/src/python/as a sibling of the Rust emitters..with_python_sdk()(or an equivalent) toOschemaBuildConfig.build.rs(e.g.hero_osis_server/build.rs) to opt in.pip install(or path-import) the generated package; agents (e.g. service_agent'scompile_stubs) read from the SDK rather than asking hero_router to generate.Why backlog
The runtime codegen path works end-to-end today (verified in
hero_logic/scripts/e2e_typed_client.pyand the newpython_codegen::test_dataclass_emission_and_method_wrappinglock-in test). So this is a refactor for ownership / coupling rather than a correctness fix — appropriate for the backlog.Acceptance criteria
hero_osisbuild emitshero_osis_sdk/python/<domain>/<service>_client.pyfor each domain (mirrors the Rust SDK layout).router.python_clientreturns today.hero_router/python_codegenregression test (test_dataclass_emission_and_method_wrapping) ports cleanly.hero_logic/scripts/e2e_typed_client.py) imports from the SDK path, not from~/.hero/var/router/python/.Related
11e5c6a— base-field injection (sid/created_at/updated_at) in OpenRPC schemas