Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(build): WIT-driven IPC topic schemas - #644

Merged
joshuajbouw merged 4 commits into
mainfrom
feat/wit-driven-ipc-types
Mar 26, 2026
Merged

joshuajbouw merged 4 commits into
mainfrom
feat/wit-driven-ipc-types

Conversation

@joshuajbouw

@joshuajbouw joshuajbouw commented Mar 26, 2026

Copy link
Copy Markdown
Member

Linked Issue

Closes #643

Summary

Add WIT-driven IPC topic schema extraction. Capsule authors declare wit_type on [[topic]] entries to reference a WIT record. At install time, the record's fields and /// doc comments are converted to JSON Schema and baked into meta.json. At runtime, WasmEngine populates the SchemaCatalog for A2UI consumption.

Changes

  • Add wit-parser = "0.227" workspace dependency
  • New astrid-build::wit_schema module — WIT record → JSON Schema converter (primitives, option, list, tuple, enum, flags, variant, result, nested records, type aliases)
  • Add wit_type: Option<String> field to TopicDef in Capsule.toml
  • Extend bake_topics() to resolve wit_type from capsule wit/ directory
  • Extract read_schema_file() helper from bake_topics()
  • Update SchemaCatalog::register_topics() to accept baked schemas map
  • Wire schema catalog population into WasmEngine::load() via meta.json
  • Use Resolve::push_dir() for proper multi-file WIT package handling
  • Add MAX_TYPE_DEPTH (32) guard against recursive type aliases
  • Register topics unconditionally (not gated on capsule_registry presence)

Test Plan

Automated

  • cargo test --workspace passes
  • No new clippy warnings
  • 4 new wit_schema tests: simple record, empty dir, nonexistent dir, unknown type error
  • Schema catalog tests updated with baked schema parameter + new test for populated schema

Checklist

  • Linked to an issue
  • CHANGELOG.md updated under [Unreleased]

Add wit-parser to extract JSON Schemas from capsule WIT record
definitions at install time. Capsule authors declare wit_type on
[[topic]] entries in Capsule.toml to reference a WIT record by name.
The build system parses the record's fields and /// doc comments into
a JSON Schema that is baked into meta.json. At runtime, WasmEngine
reads baked schemas and populates the SchemaCatalog for A2UI
consumption.

- Add wit-parser 0.227 workspace dependency
- New astrid-build::wit_schema module: WIT record -> JSON Schema
  converter with support for primitives, option, list, tuple, enum,
  flags, variant, result, nested records, and type aliases
- Add wit_type: Option<String> field to TopicDef (Capsule.toml)
- Extend bake_topics() to resolve wit_type from capsule wit/ dir
- Extract read_schema_file() helper from bake_topics()
- Update SchemaCatalog::register_topics() to accept baked schemas
- Wire schema catalog population into WasmEngine::load() via
  meta.json

Closes #643
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to how Inter-Process Communication (IPC) topic schemas are managed within the system. It enables the use of WebAssembly Interface Type (WIT) records as a source for defining these schemas, allowing for a more integrated and automated approach to schema generation. The change streamlines the process of providing structured data definitions for topics, ensuring that these definitions are consistently available at runtime for various system components, including AI-to-UI interactions.

Highlights

  • WIT-driven IPC Topic Schemas: Capsule authors can now define IPC topic schemas using WebAssembly Interface Type (WIT) records by specifying a wit_type in their Capsule.toml.
  • Automated JSON Schema Generation: The build system now parses WIT record definitions and their /// doc comments, converting them into JSON Schema which is then baked into meta.json.
  • Runtime Schema Integration: The WasmEngine reads these pre-baked schemas from meta.json at runtime, populating the SchemaCatalog for use by A2UI and other tooling.
  • New Dependency: The wit-parser crate has been added as a workspace dependency to enable WIT file processing.
  • Schema Resolution Priority: When both a schema file path and a wit_type are specified for a topic, the wit_type definition takes precedence.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


From WIT's clear form, a schema springs, For IPC, new order brings. With types defined, and docs so neat, Our data flows, a structured feat.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a WIT record to JSON Schema converter to support IPC topic schemas defined in WIT. It adds a new wit_schema module in astrid-build, updates the capsule manifest to include a wit_type field, and modifies the installation process to bake these schemas into meta.json. Feedback focuses on ensuring WIT result unit types are explicitly mapped to null in the generated schema for accuracy and replacing a potential panic in file size conversion with proper error handling during the installation process.

Comment thread crates/astrid-build/src/wit_schema.rs
Comment thread crates/astrid-cli/src/commands/capsule/install.rs Outdated
- Use Resolve::push_dir() instead of per-file push_str() to handle
  multi-file WIT packages correctly (single package split across
  multiple .wit files in a directory)
- Add MAX_TYPE_DEPTH (32) guard to prevent stack overflow on deeply
  nested type aliases or circular references in type_to_json_schema
- Move schema catalog registration outside the capsule_registry
  guard so topics are registered unconditionally (schema_catalog is
  always present, even when registry is None in tests)
- Guard push_dir against empty directories (no .wit files)
- Use {"type": "null"} for WIT result unit types (was {} or
  {"type": "string"}) per review feedback
- Replace .expect() with .with_context()? for file size conversion
  in read_schema_file()
@joshuajbouw
joshuajbouw merged commit 024f900 into main Mar 26, 2026
13 checks passed
@joshuajbouw
joshuajbouw deleted the feat/wit-driven-ipc-types branch March 26, 2026 19:24
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.

WIT-driven IPC topic schemas for A2UI

1 participant