fix(generator): drop redundant sid-field requirement on root objects (#85) #88

Closed
timur wants to merge 1 commit from issue-85-rootobj-sid-validation into development
Owner

Closes #85.

Summary

  • crates/generator/src/generator.rs::validate_root_object no longer rejects [rootobject] types that don't declare a sid field.
  • The Rust struct emitter already auto-injects pub sid: SmartId, pub created_at: u64, pub updated_at: u64 for every root object and silently skips any schema-declared duplicates — the validator was the odd one out.
  • The wrong-behavior test test_rootobject_requires_sid is replaced by test_rootobject_without_sid_is_accepted, which pins the new correct behavior.
  • 125 generator tests pass.

Why

The validator was the upstream source of the bad guidance in hero_skills#275 (oschema skill telling authors to declare sid: str even though the emitter ignores it). With this fix, hero_service#1 can collapse its catalog schema to the intended minimal ServiceDefinition shape — which is also the cleaner fix for hero_rpc#72.

Test plan

  • cargo test -p hero_rpc_generator --lib — 125 passed.
  • Manual: hero_service builds against this branch with ServiceDefinition = { name, description, interfaces: [Interface] } (no sid: str).
Closes #85. ## Summary - `crates/generator/src/generator.rs::validate_root_object` no longer rejects `[rootobject]` types that don't declare a `sid` field. - The Rust struct emitter already auto-injects `pub sid: SmartId`, `pub created_at: u64`, `pub updated_at: u64` for every root object and silently skips any schema-declared duplicates — the validator was the odd one out. - The wrong-behavior test `test_rootobject_requires_sid` is replaced by `test_rootobject_without_sid_is_accepted`, which pins the new correct behavior. - 125 generator tests pass. ## Why The validator was the upstream source of the bad guidance in [hero_skills#275](https://forge.ourworld.tf/lhumina_code/hero_skills/issues/275) (`oschema` skill telling authors to declare `sid: str` even though the emitter ignores it). With this fix, [hero_service#1](https://forge.ourworld.tf/lhumina_code/hero_service/issues/1) can collapse its catalog schema to the intended minimal `ServiceDefinition` shape — which is also the cleaner fix for [hero_rpc#72](https://forge.ourworld.tf/lhumina_code/hero_rpc/issues/72). ## Test plan - [x] `cargo test -p hero_rpc_generator --lib` — 125 passed. - [x] Manual: `hero_service` builds against this branch with `ServiceDefinition = { name, description, interfaces: [Interface] }` (no `sid: str`).
fix(generator): drop redundant sid-field requirement on root objects (#85)
Some checks failed
Test / test (push) Failing after 2m24s
Test / test (pull_request) Failing after 2m12s
25758a452d
The Rust struct emitter auto-injects `pub sid: SmartId`, `pub created_at: u64`,
and `pub updated_at: u64` for every root object, and silently skips any
schema-declared fields with those names. Requiring authors to also write
`sid: str` in the schema produced a misleading declaration that the emitter
then ignored — and propagated bad guidance into the `oschema` skill
(hero_skills#275).

Root-object-ness is determined by the `[rootobject]` comment marker. Drop the
validator's `must have a 'sid' field` check; keep the
`must have at least one user-defined field` check.

Test `test_rootobject_requires_sid` (which pinned the wrong behavior) is
replaced by `test_rootobject_without_sid_is_accepted`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
timur closed this pull request 2026-05-20 08:40:34 +00:00
Author
Owner

Closing as superseded — equivalent fix already merged via #87 (commit 4196165). Issue #85 is resolved on development.

Closing as superseded — equivalent fix already merged via #87 (commit 4196165). Issue #85 is resolved on development.
Some checks failed
Test / test (push) Failing after 2m24s
Test / test (pull_request) Failing after 2m12s

Pull request closed

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!88
No description provided.