Commit b6a6439
fix(resource-graph,merger): match full (iface, rn) tuple in 4 sites (LS-A-17/18/19) (#156)
Four sites in meld-core either dropped the interface dimension of the
(component, interface, resource_name) tuple or used substring/suffix
matching where exact match was required. All led to silent cross-
resource confusion or wrong-handle-table routing with no host trap.
LS-A-17a — resource_graph.rs definer purge (lines 279-308). The
cleanup filter ignored the iface when removing defines_cache entries.
A component importing `[resource-rep]X` from interface I_x AND defining
its own `[resource-rep]X` in unrelated interface I_y lost the
(comp, I_y, X) definer entry.
LS-A-17b — resource_graph.rs terminal-exporter pass (lines 242-264).
`to_also_imports_resource` checked any iface, mis-classifying a
definer as a re-exporter when the consumer imported any unrelated
resource interface (e.g. wasi:io/poll).
LS-A-18 — resource_graph.rs first pass (~lines 124-172) only stripped
`[resource-rep]` and `[resource-new]` prefixes. A re-exporter that
imports `[resource-drop]Y` for a foreign resource Y never registered
Y in the graph; the drop call then routed to the first matching
handle-table fallback (LS-A-15 family), invoking a foreign dtor on a
foreign rep.
LS-A-19 — merger.rs::add_unresolved_imports dedup-skip path used
`imp.name.ends_with(rn)`. Two distinct resources sharing a suffix
(`float` / `bigfloat`) collided into the same tracking entry.
Fixes:
- definer purge: filter by (idx == from_comp && iface == ri && r == rn)
- terminal exporter: scope to_also_imports check to the iface under
attribution (and [export]-prefixed variants)
- first-pass: extracted ResourcePrefixKind enum; handle Drop arm as
ImportsFrom edge (matches second pass)
- merger dedup: exact-match against format!("[resource-{rep,new}]{rn}")
Tests (3 new):
- ls_a_17_definer_survives_unrelated_import_with_same_resource_name
- ls_a_17_terminal_definer_with_unrelated_resource_import
- ls_a_18_drop_on_foreign_resource_registers_node_for_reexporter
LS-A-17/18/19 added to safety/stpa/loss-scenarios.yaml. Discovered by
the post-v0.8.0 Mythos delta-pass sweep on resource_graph.rs and
merger.rs.
Refs: LS-A-17, LS-A-18 (UCA-F-2, H-1, H-3), LS-A-19 (UCA-M-9, H-1, H-10)
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent ff6c317 commit b6a6439
4 files changed
Lines changed: 411 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
9 | 31 | | |
10 | 32 | | |
11 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2144 | 2144 | | |
2145 | 2145 | | |
2146 | 2146 | | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
2147 | 2155 | | |
| 2156 | + | |
2148 | 2157 | | |
2149 | 2158 | | |
2150 | | - | |
2151 | | - | |
2152 | | - | |
2153 | | - | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
2154 | 2163 | | |
2155 | 2164 | | |
2156 | 2165 | | |
2157 | 2166 | | |
2158 | 2167 | | |
2159 | 2168 | | |
2160 | 2169 | | |
| 2170 | + | |
2161 | 2171 | | |
2162 | 2172 | | |
2163 | | - | |
2164 | | - | |
2165 | | - | |
2166 | | - | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
2167 | 2177 | | |
2168 | 2178 | | |
2169 | 2179 | | |
| |||
0 commit comments