[hyperlight_component_util] Expose the fallibility of calls to the host API - #1724
Merged
Conversation
syntactically
requested review from
andreiltd,
danbugs,
dblnz,
devigned,
jprendes,
jsturtevant,
ludfjig,
simongdavies and
squillace
as code owners
August 12, 2026 10:30
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the host-side WIT bindings generation so that calls from the host into the guest become explicitly fallible, avoiding panics when a malicious or crashing guest causes call failures. It does this by introducing a polarity-aware CallResult<T> wrapper that becomes anyhow::Result<T> for host-to-guest calls, and then threading that through generated signatures and call sites.
Changes:
- Add
Positivity::CallResult<T>and use it to wrap host-to-guest call return types (includinginstantiate). - Update host bindgen codegen to propagate errors (
?) instead of panicking on bad guest returns / lock poisoning. - Extend the test WIT world + guest implementation with a deliberate trap and add a host test validating the call returns an error.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/tests/rust_guests/witguest/src/main.rs | Adds a guest export (failable.will_trap) that deliberately panics to simulate a trapping guest. |
| src/tests/rust_guests/witguest/guest.wit | Extends the test world with a new exported failable interface used to exercise fallible host calls. |
| src/hyperlight_host/tests/wit_test.rs | Updates existing host tests for Result-wrapped guest calls and adds a trap/error assertion test. |
| src/hyperlight_component_util/src/rtypes.rs | Emits function and instantiate return types as <P as Positivity>::CallResult<T> for polarity-aware fallibility. |
| src/hyperlight_component_util/src/host.rs | Updates generated host-side bindings to return CallResult and to propagate errors instead of panicking. |
| src/hyperlight_common/src/component.rs | Introduces Positivity::CallResult<T> and defines it as anyhow::Result<T> for Positive (host calling guest). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
syntactically
force-pushed
the
lm/component-fallibility
branch
from
August 12, 2026 16:32
e8d7fcd to
c9e2e59
Compare
jsturtevant
previously approved these changes
Aug 12, 2026
syntactically
force-pushed
the
lm/component-fallibility
branch
3 times, most recently
from
August 12, 2026 19:48
707fbcc to
fadee35
Compare
syntactically
force-pushed
the
lm/component-fallibility
branch
from
August 13, 2026 08:58
fadee35 to
63fe3e5
Compare
…st API Previously, the generated bindings code for the host side of a component interface would panic in a number of situations if something went wrong while trying to call into the guest. This is undesirable when building hosts that should be reliable in the face of malicious guests that manage to crash the guest partition. This commit changes the host-side bindgen to wrap the return types of guest calls in a `Result` wrapper, making it easier to deal with these errors gracefully. Co-authored-by: James Sturtevant <jsturtevant@gmail.com> Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
syntactically
force-pushed
the
lm/component-fallibility
branch
from
August 13, 2026 10:47
63fe3e5 to
1f65826
Compare
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, the generated bindings code for the host side of a component interface would panic in a number of situations if something went wrong while trying to call into the guest. This is undesirable when building hosts that should be reliable in the face of malicious guests that manage to crash the guest partition.
This commit changes the host-side bindgen to wrap the return types of guest calls in a
Resultwrapper, making it easier to deal with these errors gracefully.