Skip to content

feat(SR-25): fix resource handle translation in cross-component adapters#28

Merged
avrabe merged 1 commit intomainfrom
fix/sr-25-resource-handle-translation
Mar 15, 2026
Merged

feat(SR-25): fix resource handle translation in cross-component adapters#28
avrabe merged 1 commit intomainfrom
fix/sr-25-resource-handle-translation

Conversation

@avrabe
Copy link
Contributor

@avrabe avrabe commented Mar 15, 2026

Summary

  • Adapters now call [resource-rep] to convert borrow<T> handles to raw representations before forwarding to callee core functions, per the canonical ABI's lower_borrow semantics
  • own<T> params are correctly left as handles — the callee calls from_handle/resource.rep internally
  • Fixed critical bug where the "no copying needed" early-return path in generate_memory_copy_adapter skipped Phase 0, producing simple passthroughs for functions with only resource params

Test plan

  • Resources fixture runtime test passes (promoted from graceful degradation to hard assertion)
  • Full test suite passes (42 tests, 0 failures)
  • No clippy warnings
  • Pre-commit hooks pass (fmt, clippy, test)

🤖 Generated with Claude Code

Adapters now call [resource-rep] to convert borrow<T> handles to their
raw representation before forwarding to callee core functions. Per the
canonical ABI, lower_borrow returns the representation (not the handle)
when T is defined by the callee instance. own<T> params are left as
handles since the callee calls from_handle/resource.rep internally.

Key changes:
- adapter/mod.rs: add resource_rep_calls field (borrow params only)
- adapter/fact.rs: Phase 0 resource.rep conversion in all four generator
  functions; guard early-return "no copying needed" path to not skip
  Phase 0; build_resource_import_map for [resource-rep] lookup
- parser.rs: resource_param_positions(), resource_result_positions()
- resolver.rs: ResolvedResourceOp, build_resource_type_to_import(),
  resolve_resource_positions() with borrow/own distinction

Resources fixture promoted from graceful degradation to hard assertion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@avrabe avrabe merged commit fd629fe into main Mar 15, 2026
3 checks passed
@avrabe avrabe deleted the fix/sr-25-resource-handle-translation branch March 15, 2026 11:51
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