Skip to content

fix: handle empty namespace paths in component codegen#1331

Merged
jsturtevant merged 2 commits into
hyperlight-dev:mainfrom
jsturtevant:component-util-fixes
Jun 19, 2026
Merged

fix: handle empty namespace paths in component codegen#1331
jsturtevant merged 2 commits into
hyperlight-dev:mainfrom
jsturtevant:component-util-fixes

Conversation

@jsturtevant

@jsturtevant jsturtevant commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #1329.

This updates component code generation so WIT interfaces without a namespace emit local Rust paths instead of paths with an invalid leading separator.

It also adds the shared bindgen-test-cases WIT fixture and CI artifact plumbing so stacked bindgen-focused PRs can extend the same fixture instead of adding one-off wasm artifacts. This is an simple with test case but it gets tricky to add all of the examples there so split this out to catch all the edge cases.

@jsturtevant jsturtevant changed the title Component util fixes fix: name collisions and empty namespaces Mar 20, 2026
@jsturtevant jsturtevant added the kind/bugfix For PRs that fix bugs label Mar 20, 2026

@dblnz dblnz 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.

Great to see this change!
It's been bugging me for some time when working on component debugging .

I am still new to this part of the codebase, maybe someone with more insight can have a look.

@jsturtevant jsturtevant force-pushed the component-util-fixes branch from f12a24f to d9ee203 Compare April 3, 2026 18:54
@jsturtevant jsturtevant added this to the v0.16 milestone Jun 17, 2026
When a WIT interface has no namespace path (e.g. no package prefix),
the generated Rust code would produce invalid double-colon (::) paths.
Add guards to emit correct paths when the namespace is empty.

Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
@jsturtevant jsturtevant force-pushed the component-util-fixes branch from d9ee203 to fb96c87 Compare June 17, 2026 23:21
@jsturtevant jsturtevant changed the title fix: name collisions and empty namespaces fix: handle empty namespace paths in component codegen Jun 18, 2026
@jsturtevant jsturtevant force-pushed the component-util-fixes branch from d426239 to 20d73d5 Compare June 18, 2026 23:23
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
@jsturtevant jsturtevant marked this pull request as ready for review June 18, 2026 23:37
Copilot AI review requested due to automatic review settings June 18, 2026 23:37

Copilot AI 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.

Pull request overview

This PR fixes a Rust path generation bug in Hyperlight’s component bindings when a WIT interface has an empty namespace path (previously producing invalid leading :: segments), and adds a shared bindgen-focused WIT fixture plus CI artifact plumbing to support future bindgen test expansion.

Changes:

  • Adjusted Rust token emission to avoid generating ::... paths when namespace_path() is empty (e.g., emit Trait instead of ::Trait).
  • Added a new shared WIT fixture (bindgen-test-cases) and a host-side compile-time test that exercises the plain-export interface codegen path.
  • Updated guest-build and build-test CI workflows to upload/download the new bindgen-test-cases.wasm artifact, and updated the Justfile to produce it.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tests/rust_guests/witguest/bindgen-test-cases/world.wit Adds a reusable WIT fixture with an unqualified exported interface to reproduce/guard the empty-namespace path case.
src/hyperlight_host/tests/wit_test.rs Adds a compile-time test that references generated types from the new fixture, ensuring codegen produces valid Rust paths.
src/hyperlight_component_util/src/rtypes.rs Fixes several codegen sites to avoid inserting :: when namespace_path() is empty.
src/hyperlight_component_util/src/host.rs Fixes host export-instance impl emission to use a local trait path when the namespace is empty.
Justfile Generates bindgen-test-cases.wasm alongside existing WIT-derived wasm fixtures.
.github/workflows/dep_build_test.yml Downloads the new fixture wasm artifact for build/test jobs.
.github/workflows/dep_build_guests.yml Uploads the new fixture wasm artifact (debug build) for downstream jobs.

@jsturtevant jsturtevant merged commit 9386633 into hyperlight-dev:main Jun 19, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bugfix For PRs that fix bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wit: empty namespaces

5 participants