Skip to content

Commit 3a33e51

Browse files
hyperpolymathclaude
andcommitted
test(seam): cross-verifier conformance for the access-sites carrier (#251 follow-up)
Runs typed-wasm's OWN verify_access_sites_from_module pass (and both section parsers) over a real ephapax-emitted module: zero errors — the ADR-0002/ADR-0003 sections ephapax emits are byte-compatible with the independent consumer and every recorded offset resolves to a real typed memory op. - bump typed-wasm-verify pin a1935c1 -> 5d67603 (current HEAD; the old rev predates the access-sites verifier) + enable its additive unstable-l2 feature (exposes the regions/access-sites parsers + pass). - all 6 seam tests + all 19 ephapax-cli test binaries green on the new pin. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent fc32791 commit 3a33e51

3 files changed

Lines changed: 69 additions & 5 deletions

File tree

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ephapax-vram-cache = { path = "src/ephapax-vram-cache" }
6262
# `affinescript.ownership` → `typedwasm.ownership`). This is the
6363
# canonical C7 pin (cf. CHANGELOG.md "Added" / "C7 (#72)"). Re-bump
6464
# only if a newer `typed-wasm-verify` API change is needed.
65-
typed-wasm-verify = { git = "https://github.com/hyperpolymath/typed-wasm", rev = "a1935c16176567e0470de2feedf9c37a87dc0158" }
65+
typed-wasm-verify = { git = "https://github.com/hyperpolymath/typed-wasm", rev = "5d67603852098561d5f4e967f6d0bdf3d3e10a16", features = ["unstable-l2"] }
6666

6767
# External dependencies
6868
serde = { version = "1.0", features = ["derive"] }

src/ephapax-cli/tests/typed_wasm_seam_conformance.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,67 @@ fn extract_ownership_section(wasm: &[u8]) -> Option<Vec<u8>> {
193193
}
194194
None
195195
}
196+
197+
/// Cross-verifier conformance for the ADR-0002/ADR-0003 carriers
198+
/// (#251): compile a string-using program with the REAL CLI, then run
199+
/// typed-wasm's OWN `verify_access_sites_from_module` pass over the
200+
/// emitted bytes. Zero `AccessSiteError`s means the regions +
201+
/// access-sites sections ephapax emits are byte-compatible with the
202+
/// independent consumer AND every recorded offset resolves to a real
203+
/// typed memory op of the declared field's type.
204+
#[test]
205+
fn typed_wasm_verifies_ephapax_access_sites() {
206+
let dir = tempfile::tempdir().expect("tempdir");
207+
let src_path = dir.path().join("seam_access.eph");
208+
std::fs::write(&src_path, "fn echo(s: String): String = s\n").expect("write source");
209+
let out = dir.path().join("seam_access.wasm");
210+
211+
let status = std::process::Command::new(env!("CARGO_BIN_EXE_ephapax"))
212+
.args(["compile"])
213+
.arg(&src_path)
214+
.arg("-o")
215+
.arg(&out)
216+
.output()
217+
.expect("spawn ephapax");
218+
assert!(
219+
status.status.success(),
220+
"compile failed:\nstdout: {}\nstderr: {}",
221+
String::from_utf8_lossy(&status.stdout),
222+
String::from_utf8_lossy(&status.stderr)
223+
);
224+
let wasm = std::fs::read(&out).expect("read emitted wasm");
225+
226+
// Their parsers must accept our payloads...
227+
let regions_payload = extract_custom_section(&wasm, "typedwasm.regions")
228+
.expect("typedwasm.regions section present");
229+
let regions = tw::section::parse_regions_section_payload(&regions_payload)
230+
.expect("typed-wasm rejected ephapax's regions payload");
231+
assert_eq!(regions.len(), 1, "expected the single ephapax.string region");
232+
233+
let access_payload = extract_custom_section(&wasm, "typedwasm.access-sites")
234+
.expect("typedwasm.access-sites section present");
235+
let sites = tw::section::parse_access_sites_section_payload(&access_payload)
236+
.expect("typed-wasm rejected ephapax's access-sites payload");
237+
assert!(!sites.is_empty(), "no access sites decoded");
238+
239+
// ...and their full verification pass must report zero errors.
240+
let errors = tw::verify::verify_access_sites_from_module(&wasm)
241+
.expect("verifier failed to parse the module");
242+
assert!(
243+
errors.is_empty(),
244+
"typed-wasm's access-site verifier rejected ephapax's module: {errors:?}"
245+
);
246+
}
247+
248+
/// Find an arbitrary named custom section in a wasm module.
249+
fn extract_custom_section(wasm: &[u8], name: &str) -> Option<Vec<u8>> {
250+
use wasmparser::{Parser, Payload};
251+
for payload in Parser::new(0).parse_all(wasm) {
252+
if let Payload::CustomSection(reader) = payload.ok()? {
253+
if reader.name() == name {
254+
return Some(reader.data().to_vec());
255+
}
256+
}
257+
}
258+
None
259+
}

0 commit comments

Comments
 (0)