Move catalog/openrpc.json out of src/ to a top-level spec location #73
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#73
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?
Problem
The scaffolder emits the OpenRPC spec at
crates/<name>/src/<domain>/openrpc.json— buried inside the core lib'ssrc/. That's a poor home: it's not Rust source, it's the contract every SDK target consumes.Suggested
Move it to one of:
sdk/openrpc.json(alongside the language SDKs — most natural since every SDK target generates from this spec)spec/openrpc.json(dedicated top-level dir)openrpc.json(simplest)Propose one in a comment before implementing. My lean:
sdk/openrpc.jsonsince it's the upstream input to the language-specific SDK packages and they'll all reference it.What to do
OschemaBuildConfig/ generator to emit there._admin's<hero-api-docs>integration (currently includes the file via build-time path).hero_service_scaffold.mdskill.hero_servicetemplate repo to match.Acceptance
openrpc.jsonat the chosen location.<hero-api-docs>in scaffolded_adminstill resolves and renders correctly.openrpc.jsonleft undercrates/<name>/src/.Location locked:
docs/openrpc.json(top-level).Note: this is the API contract, distinct from the per-schema doc trees that were dropped in #71 —
docs/openrpc.jsonis consumed by every SDK target + the<hero-api-docs>admin widget, so it belongs in a discoverable top-level location, not undersrc/. Thedocs/schemas/dir from #71 stays gone;docs/just contains this one canonical file (plus whatever a contributor adds — README, ADRs, etc.).Action items for the implementing agent:
OschemaBuildConfig/ generator to emit atdocs/openrpc.json(workspace root).<hero-api-docs>build-time include path in scaffolded_adminmain.rs.hero_service_scaffold.mdskill inhero_skillsso the documented layout matches.hero_servicetemplate repo +example/recipe_serverso they reflect the new path.Implementation up on branch
issue-73-openrpc-location. Commit24d8b25covers everything in scope for this repo:OschemaBuildConfiggains aworkspace_dirsetting. The builder auto-detects the workspace root by walking up fromCARGO_MANIFEST_DIRfor aCargo.tomlwith[workspace]; explicit override is available for non-standard layouts (and unit tests, which fall back to the manifest dir).Generatorgets a matchingworkspace_dirfield.write_openrpc_jsonnow writes a single<workspace>/docs/openrpc.jsoninstead of per-domain copies undersrc/{domain}/.rust_typesno longer emits the in-tree spec at all —rust_serveris the single emission point.rust_servercomputes theinclude_str!path from the server file's directory to<workspace>/docs/openrpc.jsonso the prior hardcodedinclude_str!("openrpc.json")/include_str!("../core/openrpc.json")layout fix-ups go away. Same path-computation works for nested layout,server_crate_dir, and flat in-tree alike._admin/main.rstemplate now embeds the canonical spec at build time (include_str!("../../../docs/openrpc.json")) and serves it on/openrpc.jsonso<hero-api-docs spec-url="/openrpc.json">resolves out of the box.example/recipe_serverregenerated:docs/openrpc.jsonis the single canonical file; bothcrates/hero_recipes/src/recipes/openrpc.jsonandcrates/hero_recipes_server/src/recipes/openrpc.jsonare gone; thehero_recipes_admininclude_str!now points at the new path.All 125 generator tests + downstream workspace tests pass; both the
hero_rpcworkspace andexample/recipe_serverworkspace build clean (generatedosis_server_generated.rsnow usesinclude_str!("../../../../docs/openrpc.json")fromcrates/hero_recipes_server/src/recipes/).Known limitation (noted in commit message): the generator runs per-domain and overwrites the same
docs/openrpc.jsoneach call — last-domain-wins for multi-domain services. Bothrecipe_serverand thehero_servicetemplate are single-domain so it's a non-issue for the acceptance criteria, but merging multi-domain specs into one canonical file is a follow-up worth filing.Out of scope (separate PRs in their own repos):
hero_skills/hero_service_scaffold.md— needs the documented layout updated to match.hero_servicetemplate repo — needs to be regenerated by the updated scaffolder and the resultingdocs/openrpc.json+ admin include_str path committed.docs/openrpc.jsonlocation #274docs/openrpc.json+ per-domain atdocs/<domain>/openrpc.json#82