[hyperlight_component_util] Properly track positivity/negativity - #1723
Merged
Conversation
syntactically
requested review from
andreiltd,
danbugs,
dblnz,
devigned,
jprendes,
jsturtevant,
ludfjig,
simongdavies and
squillace
as code owners
August 12, 2026 10:29
syntactically
force-pushed
the
lm/component-positivity
branch
from
August 12, 2026 16:32
7bb80fb to
c1f8d53
Compare
jsturtevant
reviewed
Aug 12, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Hyperlight’s component bindgen to track positive vs negative positions via an explicit type parameter (instead of relying on compile-time State::is_export), allowing the same generated interface definitions to be used correctly as both imports and exports.
Changes:
- Introduces
hyperlight_common::component::{Positivity, Positive, Negative}and usesPositivity::Borrowto encode borrowed-handle representation by position. - Updates bindgen emission to thread positivity through generated traits/types and fixes resource/type referencing to use the positivity parameter.
- Updates host/guest tests and the Rust WIT guest to use the new positivity-parameterized generated APIs.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/rust_guests/witguest/src/main.rs | Updates guest-side generated trait impl usage to pass explicit Positive/Negative parameters. |
| src/hyperlight_host/tests/wit_test.rs | Updates host-side tests to implement/consume positivity-parameterized bindings and adds a regression case for same-interface import+export with resources. |
| src/hyperlight_component_util/src/rtypes.rs | Threads positivity through trait/type references and replaces State::is_export logic with Positivity::Borrow. |
| src/hyperlight_component_util/src/host.rs | Adjusts host bindgen output to use positivity-parameterized imports/exports traits. |
| src/hyperlight_component_util/src/guest.rs | Adjusts guest bindgen output for positivity-parameterized traits and impl emission. |
| src/hyperlight_component_util/src/emit.rs | Adds positivity parameter to emitted trait generics and refactors impl tracking to carry impl generic args. |
| src/hyperlight_common/src/lib.rs | Exposes the new component module from hyperlight_common. |
| src/hyperlight_common/src/component.rs | Adds Positivity trait and Positive/Negative marker types defining borrow-handle representation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
jsturtevant
previously approved these changes
Aug 12, 2026
syntactically
force-pushed
the
lm/component-positivity
branch
from
August 12, 2026 19:46
c1f8d53 to
ec745d3
Compare
syntactically
force-pushed
the
lm/component-positivity
branch
from
August 12, 2026 19:48
ec745d3 to
3cfcb74
Compare
syntactically
force-pushed
the
lm/component-positivity
branch
from
August 13, 2026 08:58
3cfcb74 to
928a40d
Compare
Previously, bindgen code relied upon state that it tracked at compile time to determine whether a particular definition was in a positive or negative position (see `State::is_export`). Unfortunately, since type definitions presently are maintained based on wit-style names, and the same wit interface can be both imported and exported from the main component, this did not work very well. This commit changes the generated types to include a type parameter that tracks whether they are being used in a positive or negative manner. It also changes the one current user of `State::is_export` to instead use that type parameter, ensuring that the single generated definition can be used both as an import and as an export. Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
syntactically
force-pushed
the
lm/component-positivity
branch
from
August 13, 2026 10:47
928a40d to
03ef756
Compare
jsturtevant
reviewed
Aug 13, 2026
jsturtevant
approved these changes
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, bindgen code relied upon state that it tracked at compile time to determine whether a particular definition was in a positive or negative position (see
State::is_export). Unfortunately, since type definitions presently are maintained based on wit-style names, and the same wit interface can be both imported and exported from the main component, this did not work very well.This commit changes the generated types to include a type parameter that tracks whether they are being used in a positive or negative manner. It also changes the one current user of
State::is_exportto instead use that type parameter, ensuring that the single generated definition can be used both as an import and as an export.