safety: STPA analysis of resource type dedup in 3-component chains#84
Merged
safety: STPA analysis of resource type dedup in 3-component chains#84
Conversation
…-11.8) Add per-component resource type keying in the P2 wrapper when handle tables are active, preventing type reuse across components that need separate handle tables. This fixes the wrapper-side issue but the root cause is in the merger's import dedup logic (new STPA sub-hazard H-11.8). The 3 resource chain tests (resource_floats, resource_with_lists, resource-import-and-export) remain fuse-only: the merger deduplicates [export] resource imports across components, so the definer and runner share one canonical resource type. The fix requires per-component resource import emission with $N suffixes in the merger. Part of #69, documents remaining work for #75. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
[export]resource imports across components, causing resource type identity mismatch at runtimeRoot Cause Analysis
In 3-component chains (definer → re-exporter → runner), the definer and runner both import
[resource-rep]floatunder[export]test:resource-floats/test. The merger deduplicates these into one import (no$Nsuffix). The P2 wrapper then creates one canonical resource type, but wasmtime needs separate per-component types. Result: "handle index 1 used with the wrong type".Fix Path
The merger needs to emit per-component
[export]resource imports with$Nsuffixes when handle tables are active, so each component gets its own canonical resource type. This is tracked as H-11.8 in the STPA analysis.Part of #69, documents remaining work for #75.
Test plan
handle_tablesis non-empty🤖 Generated with Claude Code