Skip to content

Add Component host functions and resources - #291

Draft
JDLondon7 wants to merge 6 commits into
bytecodealliance:mainfrom
JDLondon7:tradepit/upstream/w010-host-linking-resources
Draft

Add Component host functions and resources#291
JDLondon7 wants to merge 6 commits into
bytecodealliance:mainfrom
JDLondon7:tradepit/upstream/w010-host-linking-resources

Conversation

@JDLondon7

@JDLondon7 JDLondon7 commented Aug 1, 2026

Copy link
Copy Markdown

Failing test

upstream/main cannot define component host functions or host resources through ComponentLinker. The added tests exercise callback success/error/panic propagation, exclusive linker namespace borrowing, resource value conversion, host data recovery, and deterministic drop behavior.

General correction

  • Expose the component linker root and nested linker instances while enforcing the C API's exclusive parent-borrow rule.
  • Bind synchronous host functions with explicit callback state and panic-to-error conversion.
  • Bind host resource types and owned resource values, including explicit take/drop operations.
  • Reject nil callbacks and destructors and prevent closing a linker while its root is borrowed.

This is a stacked draft on top of the component call/runtime-value draft because host callbacks consume and produce the same ComponentVal representation. The host/resource-specific review surface is the final two commits. It tracks #280 and deliberately leaves ComponentValType wrappers to the existing type series, including #283.

Validation

With the v47.0.0 release artifacts restored as ignored build inputs:

go vet ./...
go test ./...
go test -tags wasmtime_component_model ./...
golangci-lint run --build-tags wasmtime_component_model --new-from-rev tradepit/upstream/w010-component-call-values --whole-files

All commands pass on Windows amd64; lint reports 0 issues for the stacked slice. The untagged commands specifically guard the build-tag boundary between the always-built linker lifecycle and the host-only API.

Compatibility and security impact

The API is additive and synchronous. Callback state stays behind cgo handles, panics are converted into Wasmtime errors, linker borrowing is enforced in Go, and host resource ownership has explicit consume/drop paths.

Documentation

Public types and methods include Go documentation. Tests cover lifecycle and failure paths.

Downstream removal condition

Downstream users can remove equivalent local bindings after an upstream release contains these APIs and their callback, linker lifecycle, and resource ownership fixtures pass unchanged.

This change contains no TradePit product concepts or private data.

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.

1 participant