OschemaBuildConfig: add contexts_default(...) setter so single-bin codegen can override the ServerCli root-only default #36
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#36
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
Downstream services that consume the OSIS code generator (
OschemaBuilder::new(config).single_bin(...).generate()) get an auto-generated entrypoint atbin/<name>.rsthat callsServerCli::parse().ServerCli::contextsdefaults to"root"(crates/server/src/server/cli.rs:31). When the binary is launched without--contextsand withoutHERO_CONTEXTSenv (which is the production path viahero_proc), onlyrootgets registered. Any client request withX-Hero-Contextset to a name not in that list (e.g.default,geomind) silently falls back torootat the dispatcher layer (unified_server.rs:597-608) — every space ends up reading the same store.Downstream services have no clean way to override that default today. Editing the generated
bin/<name>.rsis futile (it's markedDO NOT EDITand gets clobbered on schema or build.rs changes); there is no setter onOschemaBuildConfigfor it; environment variables only paper over the problem at deployment time.Concrete blocker: hero_osis #40 (lhumina_code/hero_osis#40). The hero_os UI shell defaults its
active_contextto"default". Out of the box, every hero_osis install has the cross-context data leak symptom because the generator picksrootanddefaultis never registered.Proposed API
Add a
contexts_default(impl Into<String>)builder method onOschemaBuildConfig(likely incrates/server/src/server/config.rsor whereverOschemaBuildConfiglives — a quick grep should locate it). When set, the generator emits abin/<name>.rsthat uses the supplied value as the contexts default in place of the upstreamServerCli"root"default. Behaviour priority preserved:When
contexts_default(...)is NOT called, behaviour is unchanged (back-compat).Consumer-side usage in hero_osis would look like:
The emitted
bin/hero_osis.rswould then ship with that contexts list as its default, register all of them at startup, and the cross-context isolation already present inOServer::register+unified_server::dispatch_rpcwould Just Work for those names.Implementation sketch
contexts_default: Option<String>field toOschemaBuildConfigwith builder setter.OschemaBuilderto whichever generator function emits thesingle_binmain file (likelycrates/generator/src/...— search forsingle_binconsumer).let contexts: Vec<String> = cli.contexts.split(',')...block in the bin, conditionally substitute the default.contexts_default("a,b")produces a bin with"a,b"as the resolved default and that an explicit--contexts cstill overrides it.Out of scope (worth filing separately)
The deeper bug —
unified_server::dispatch_rpcsilently falls back to"root"for any unregistered context name — should be fixed independently (return-32602 Invalid paramsstrict, OR auto-register on first request permissive, OR at minimumtracing::warn!on fallback). This issue (#NN above) is just the build-time API to plug the most common gap; the deeper dispatcher behaviour is its own ticket.Found via
QA session 2026-04-29; documented in detail at hero_osis #40 (lhumina_code/hero_osis#40). The hero_osis fix attempt for #40 surfaced this missing API as the actual blocker.