oschema: tighten root-object detection to require [rootobject] marker #108

Merged
timur merged 1 commit from strict-rootobject-marker into development 2026-05-21 11:30:17 +00:00
Owner

Summary

The parser previously marked an object as a root object if it carried either the [rootobject] comment marker or a sid: str field. Three of four codegen targets (Rust SDK trait, OpenRPC spec, UI scaffolds) honoured the OR; the OSIS server-side dispatcher emitter only honoured the marker. Result: a schema with sid: str and no marker would land in the SDK + OpenRPC + UI surfaces but silently skip the server dispatcher — every CRUD call would resolve to "Unknown method" at runtime.

Tightens to a single signal — the explicit [rootobject] marker — at the one place that matters (crates/oschema/src/parser.rs), then drops the now-redundant has_sid || obj.is_root_object checks in every downstream collector. One rule, one detection site, no silent divergence.

Affected places

  • crates/oschema/src/parser.rs — sole detection site, marker-only.
  • crates/generator/src/build/emit/rust_rpc2.rs — drops the OR.
  • crates/generator/src/build/ui_emit.rs — drops the OR.
  • crates/generator/src/schemas/openrpc.rs — drops the OR.
  • crates/generator/src/rust/rust_rpc.rs — drops the OR (two sites).
  • crates/generator/src/generate/examples.rs — drops the OR.
  • crates/generator/src/generate/e2e.rs — drops the OR.
  • crates/generator/src/schemas/oschema.rs::is_root_object — drops the sid-fallback.

Fixture updates

Inline test schemas that relied on sid-auto-detection gain explicit # <TypeName> [rootobject] headers (rust_rpc2.rs, ui_emit.rs, openrpc.rs, rhai_struct.rs). Every real .oschema shipped in the repo already carried the marker — no on-disk schemas needed editing. The walkthrough's demo schema doc-comment was tightened to drop the "must carry a sid: str field" misdirection (sid / created_at / updated_at are server-managed, the codegen injects them).

Test plan

  • 138/138 generator lib tests pass.
  • 79/79 oschema lib tests pass.
  • 66/66 OSIS lib tests pass.
  • Full cargo test --workspace --lib passes.
  • examples/recipe_server/ end-to-end cargo build still passes.
  • cargo run --manifest-path examples/recipe_server/Cargo.toml --example 01_walkthrough still produces the expected output (7 CRUD methods + service method in step 4, full dispatch arm in step 5).
## Summary The parser previously marked an object as a root object if it carried *either* the `[rootobject]` comment marker *or* a `sid: str` field. Three of four codegen targets (Rust SDK trait, OpenRPC spec, UI scaffolds) honoured the OR; the OSIS server-side dispatcher emitter only honoured the marker. Result: a schema with `sid: str` and no marker would land in the SDK + OpenRPC + UI surfaces but silently skip the server dispatcher — every CRUD call would resolve to "Unknown method" at runtime. Tightens to a single signal — the explicit `[rootobject]` marker — at the one place that matters (`crates/oschema/src/parser.rs`), then drops the now-redundant `has_sid || obj.is_root_object` checks in every downstream collector. One rule, one detection site, no silent divergence. ## Affected places - `crates/oschema/src/parser.rs` — sole detection site, marker-only. - `crates/generator/src/build/emit/rust_rpc2.rs` — drops the OR. - `crates/generator/src/build/ui_emit.rs` — drops the OR. - `crates/generator/src/schemas/openrpc.rs` — drops the OR. - `crates/generator/src/rust/rust_rpc.rs` — drops the OR (two sites). - `crates/generator/src/generate/examples.rs` — drops the OR. - `crates/generator/src/generate/e2e.rs` — drops the OR. - `crates/generator/src/schemas/oschema.rs::is_root_object` — drops the sid-fallback. ## Fixture updates Inline test schemas that relied on sid-auto-detection gain explicit `# <TypeName> [rootobject]` headers (`rust_rpc2.rs`, `ui_emit.rs`, `openrpc.rs`, `rhai_struct.rs`). **Every real `.oschema` shipped in the repo already carried the marker** — no on-disk schemas needed editing. The walkthrough's demo schema doc-comment was tightened to drop the "must carry a sid: str field" misdirection (sid / created_at / updated_at are server-managed, the codegen injects them). ## Test plan - [x] 138/138 generator lib tests pass. - [x] 79/79 oschema lib tests pass. - [x] 66/66 OSIS lib tests pass. - [x] Full `cargo test --workspace --lib` passes. - [x] `examples/recipe_server/` end-to-end `cargo build` still passes. - [x] `cargo run --manifest-path examples/recipe_server/Cargo.toml --example 01_walkthrough` still produces the expected output (7 CRUD methods + service method in step 4, full dispatch arm in step 5).
oschema: tighten root-object detection to require [rootobject] marker
Some checks failed
Test / test (push) Failing after 1m32s
Test / test (pull_request) Failing after 3m2s
d9779a3582
The parser previously marked an object as a root object if it carried
*either* the `[rootobject]` comment marker *or* a `sid: str` field. Three
out of four codegen targets (Rust SDK trait, OpenRPC spec, UI scaffolds)
honoured the OR. The fourth — the OSIS server-side dispatcher emitter —
only honoured the marker. The result: a schema with `sid: str` and no
marker would land in the SDK + OpenRPC + UI surfaces but silently skip
the server dispatcher, so every CRUD call would resolve to "Unknown
method" at runtime.

Tighten the rule to a single signal — the explicit `[rootobject]` marker —
in the one place that matters (`oschema::parser`), then drop the now-
redundant `has_sid || obj.is_root_object` checks in every downstream
collector. Effect: one rule, one detection site, no silent divergence.

Affected places:

- `crates/oschema/src/parser.rs` — sole detection site, marker-only.
- `crates/generator/src/build/emit/rust_rpc2.rs` — drops the OR.
- `crates/generator/src/build/ui_emit.rs` — drops the OR.
- `crates/generator/src/schemas/openrpc.rs` — drops the OR.
- `crates/generator/src/rust/rust_rpc.rs` — drops the OR (two sites).
- `crates/generator/src/generate/examples.rs` — drops the OR.
- `crates/generator/src/generate/e2e.rs` — drops the OR.
- `crates/generator/src/schemas/oschema.rs::is_root_object` — drops the
  sid-fallback (the OSchema regenerator now writes the marker if and
  only if the source schema had one).

Test fixtures: inline test schemas that relied on sid-auto-detection
gain explicit `# <TypeName> [rootobject]` headers (rust_rpc2, ui_emit,
openrpc, rhai_struct). Every real `.oschema` shipped in the repo
already carried the marker — no schema files needed editing. The
walkthrough's demo schema doc-comment was tightened to drop the
"must carry a sid: str field" misdirection (sid/created_at/updated_at
are server-managed, the codegen injects them).

Verified:
- 138/138 generator lib tests pass.
- 79/79 oschema lib tests pass.
- 66/66 OSIS lib tests pass.
- `examples/recipe_server/` end-to-end `cargo build` still passes.
- `cargo run --example 01_walkthrough` still produces the expected
  output (7 CRUD methods + service method in step 4, full dispatch
  arm in step 5).
timur merged commit eeae847a0d into development 2026-05-21 11:30:17 +00:00
timur deleted branch strict-rootobject-marker 2026-05-21 11:30:18 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_rpc!108
No description provided.