Skip to content

feat(sdk): canonical builtin_object_type metadata builder and typed topic registration - #166

Merged
facontidavide merged 3 commits into
mainfrom
feat/object-topic-metadata
Aug 6, 2026
Merged

feat(sdk): canonical builtin_object_type metadata builder and typed topic registration#166
facontidavide merged 3 commits into
mainfrom
feat/object-topic-metadata

Conversation

@facontidavide

Copy link
Copy Markdown
Contributor

Companion G2 of the dialog-tree / SDK-compatibility plan (SDK 0.21.0 train). Independent of #164; trivial CHANGELOG conflict expected with sibling PRs.

What

Three incompatible renderer-selection keys circulate today: docs recommended {"object_type": ...}, MediaMetadataBuilder emits media_class, but the application discovers renderers ONLY via builtin_object_type (canonical PJ::sdk::name() values, e.g. "kImage"). Emitting the wrong key leaves an object topic silently invisible. This PR makes builtin_object_type the one canonical key at the SDK level.

  • ObjectTopicMetadataBuilder: accepts BuiltinObjectType only (never free-form strings); validates via parse(name(type)) round-trip (rejects kNone, reserved values, unknown casts); deterministic key order (canonical key first, then lexicographic); correct JSON escaping via a shared detail escaper (MediaMetadataBuilder now reuses it — byte-for-byte output-equivalent to its old private helper).
  • Non-elidable validation: invalid input puts the builder into a persistent error state (clearing any earlier valid type) and build() returns Expected<std::string> — behavior does not degrade under NDEBUG. Typed registration on invalid metadata returns the error and never touches the vtable.
  • Typed registration sugar on SourceObjectWriteHostView / toolbox views (registerTopic / registerObjectTopic / registerObjectTopicOnDataset overloads taking BuiltinObjectType), constrained so existing registerTopic("x", {}) calls keep binding the raw string overload (covered by a compile-time test). No C-ABI changes.
  • Doc corrections across the toolbox guide, builtin-type docs, header comments, and the plugin-authoring skill reference: media_class does not select a renderer.

Verification

54/54 ctest, warnings-as-errors, pre-commit clean; independent adversarial review passed after fixes (release-mode validation, {} overload compatibility, missed authoring doc); release-mode invalid-input tests included.

🤖 Generated with Claude Code

facontidavide and others added 3 commits August 6, 2026 12:26
ObjectTopicMetadataBuilder emits the canonical builtin_object_type
discovery key via PJ::sdk::name(), with deterministic ordering, JSON
escaping, and enum-only validation. Typed registerTopic /
registerObjectTopic / registerObjectTopicOnDataset overloads forward to
the existing raw metadata_json slots; no C-ABI change.

Implemented by Codex session 019fd0fe-beb1-7d93-85c1-244943244efb.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Correct every doc that recommended object_type or implied media_class
selects a renderer; document the canonical key at each registration
surface; add the 0.21.0 changelog entry.

Implemented by Codex session 019fd0fe-beb1-7d93-85c1-244943244efb.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@facontidavide
facontidavide force-pushed the feat/object-topic-metadata branch from 2122435 to 3b4eddb Compare August 6, 2026 10:29
@facontidavide
facontidavide merged commit 8f67765 into main Aug 6, 2026
4 checks passed
@facontidavide
facontidavide deleted the feat/object-topic-metadata branch August 6, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant