Skip to content

[hyperlight_component_util] Expose the fallibility of calls to the host API - #1724

Merged
syntactically merged 1 commit into
mainfrom
lm/component-fallibility
Aug 13, 2026
Merged

[hyperlight_component_util] Expose the fallibility of calls to the host API#1724
syntactically merged 1 commit into
mainfrom
lm/component-fallibility

Conversation

@syntactically

Copy link
Copy Markdown
Member

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.

Copilot AI lite review requested due to automatic review settings August 12, 2026 10:30
@syntactically syntactically added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Aug 12, 2026

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 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 (including instantiate).
  • 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.

Comment thread src/hyperlight_host/tests/wit_test.rs
@syntactically
syntactically force-pushed the lm/component-fallibility branch from e8d7fcd to c9e2e59 Compare August 12, 2026 16:32
jsturtevant
jsturtevant previously approved these changes Aug 12, 2026
…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
syntactically force-pushed the lm/component-fallibility branch from 63fe3e5 to 1f65826 Compare August 13, 2026 10:47
@syntactically syntactically added the ready-for-review PR is ready for (re-)review label Aug 13, 2026
Base automatically changed from lm/component-positivity to main August 13, 2026 21:30
@syntactically
syntactically merged commit 1f65826 into main Aug 13, 2026
59 of 64 checks passed
@syntactically
syntactically deleted the lm/component-fallibility branch August 13, 2026 23:07
@github-actions github-actions Bot removed the ready-for-review PR is ready for (re-)review label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants