fix(server): recompute combined OpenRPC spec on every rpc.discover #40
No reviewers
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!40
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/rpc-discover-stale-cache"
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?
Summary
Closes lhumina_code/hero_rpc#32.
UnifiedState.combined_openrpc: Arc<Value>was a single snapshot of the merged OpenRPC spec, built once atserve()time and cloned out of the Arc on everyrpc.discover//openrpc.jsonrequest.Today that snapshot can't actually drift mid-process —
entriesare read once atserve()and the builder is consumed — but the structure is the kind that breaks the moment runtime domain registration is added, and the issue's "Expected" section explicitly asks for "no caching layer between what the code says and what the discover endpoint returns." This PR removes that layer.What changed
combined_openrpc: Arc<Value>withdomain_specs: Arc<Vec<Value>>— still a snapshot of each domain's spec atserve()time, but small.compute_combined_openrpc(state)and a purebuild_combined_openrpc(title, version, description, domain_specs)helper. Bothrpc.discoverand/openrpc.jsonnow call through this helper on every request.Valueclones plus appending the management-method list. Microseconds.rpc.discoveris called rarely (router scanner cycle), so the perf delta is irrelevant.build_combined_openrpc: every domain's methods appear; second call reflects subsequent input changes; empty input still emits management methods.What this does NOT fix
The
Observedsection of #32 mentions a hero_logic binary built Apr 20 that omitsLogicService.play_startfromrpc.discoverdespite the methods being in the.oschema. That's a build-time concern, not a runtime cache concern.include_str!captures whatever was inopenrpc.jsonat compile time. If the spec is regenerated from.oschemaafter the binary was last built, the running binary still serves the old embedded content. No change torpc.discovercan fix that — only rebuilding the binary will.A separate follow-up could be a
build.rsin each service that runs thehero_rpc_generatoragainst the.oschemasoopenrpc.jsonis always rebuilt as part ofcargo build. That's out of scope here. Filing a tracking issue if you want.Test plan
cargo build -p hero_rpc_servercargo test -p hero_rpc_server --lib compute_combined_openrpc— 3/3 passcargo test --workspace --lib— full suite green🤖 Generated with Claude Code
timur referenced this pull request2026-05-05 11:25:56 +00:00
Filed #41 for the proper root-cause fix (build.rs regenerates openrpc.json from .oschema, so
include_str!is always current). Once #41 lands across consumer service crates, the per-request recompute in this PR becomes unnecessary and can be reverted to a startup snapshot — that revert is the last step of #41.Keeping this PR as the tactical fix in the meantime.