Skip to content

safety: STPA analysis of resource type dedup in 3-component chains#84

Merged
avrabe merged 1 commit intomainfrom
fix/per-component-resource-type-keys
Apr 2, 2026
Merged

safety: STPA analysis of resource type dedup in 3-component chains#84
avrabe merged 1 commit intomainfrom
fix/per-component-resource-type-keys

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 2, 2026

Summary

  • Add per-component resource type keying in P2 wrapper when handle tables are active
  • Document new STPA sub-hazard H-11.8: merger deduplicates [export] resource imports across components, causing resource type identity mismatch at runtime
  • 3 resource chain tests remain fuse-only — the root cause is in the merger's import dedup logic, not the wrapper

Root Cause Analysis

In 3-component chains (definer → re-exporter → runner), the definer and runner both import [resource-rep]float under [export]test:resource-floats/test. The merger deduplicates these into one import (no $N suffix). 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 $N suffixes 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

  • 276 tests pass, 0 failures
  • No regressions — per-component keying only activates when handle_tables is non-empty
  • 2-component resource tests unaffected (no handle tables)

🤖 Generated with Claude Code

…-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>
@avrabe avrabe merged commit 1074db5 into main Apr 2, 2026
4 checks passed
@avrabe avrabe deleted the fix/per-component-resource-type-keys branch April 2, 2026 02:27
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