Skip to content

spike(w012): harden in-process WASM analyzer M1 - #556

Open
1932819331hy-debug wants to merge 32 commits into
limitlessprojects:mainfrom
1932819331hy-debug:spike/w012-m1-hardened
Open

1932819331hy-debug wants to merge 32 commits into
limitlessprojects:mainfrom
1932819331hy-debug:spike/w012-m1-hardened

Conversation

@1932819331hy-debug

@1932819331hy-debug 1932819331hy-debug commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

W-012 Milestone 1 — In-process WASM checker feasibility

This PR contributes a testable, AI-assisted feasibility spike for Issue #268 / wildcard W-012, accepted into the 2026-11-01 M1 review window. It embeds the existing Rust checker as wasm32-unknown-unknown in Go with Wazero, provides a real golang.org/x/tools/go/analysis.Analyzer, and publishes correctness, failure-boundary, and performance evidence. It does not claim a production replacement for hyb, stock gopls integration, or M2 completion.

Implemented and reviewed

  • Build the existing Rust checker for WASM and call it from Go without a per-request external Rust process.
  • Map on-disk sibling .hy diagnostics to Go source positions for go vet -vettool.
  • Preserve accepted managed-safety warnings and distinguish user-code rejection from infrastructure failures; malformed envelopes, WASM traps, cancellations, and invalid memory bounds fail closed.
  • Bound the public Engine.Check call, add cancellable CheckContext, and isolate concurrent analyzer context snapshots.
  • Fail closed if a declared .hy input is unreadable; canonicalize file paths to avoid duplicated diagnostics, and report source files in deterministic order.
  • Exercise parity, regressions, race safety, diagnostic positions, and infrastructure-failure cases in a repeatable hosted CI workflow.

Latest hosted verification

Negative results and open limitations

  • The measured public Engine.Check path was 2.143 ms p50 versus 1.204 ms p50 for native subprocess + JSON validation on the measured cloud host (one representative fixture, 100 samples). A reusable-instance experimental boundary measured 1.097 ms p50, but it is not the implemented public path. This does not validate the original 18.7× speedup or sub-millisecond IDE-latency claim. The later cancellation/path-hardening changes have not been rebenchmarked.
  • Stock gopls cannot dynamically load arbitrary external analyzers or treat unsaved .hy buffers as first-class Go documents. The demonstrated go/analysis driver works with on-disk .hy files; a separate LSP/editor integration remains unimplemented.
  • Go analysis.Diagnostic has no warning severity level, so go vet -vettool may exit nonzero for managed-warning-only files even though the native Hybrid checker accepts them.
  • No 25-file/100-edit editor latency benchmark, long-duration memory soak, or final cross-platform packaging claim is made.

Reproduction

From the same checkout with Rust 1.99.0, Go 1.26.9, Node 24.19.0, and the wasm32-unknown-unknown target:

(cd compiler && cargo build --locked --release -p hyb)
(cd compiler && cargo build --locked --release -p hy-wasm --target wasm32-unknown-unknown)
export HYBRID_WASM_PATH="$PWD/compiler/target/wasm32-unknown-unknown/release/hy_wasm.wasm"
export HYBRID_NATIVE_PATH="$PWD/compiler/target/release/hyb"
node test_wasm_parity.js
(cd spikes/w012-analyzer && go test -race -count=1 ./... && go vet ./...)

Scope and disclosure: The proposal, implementation, and tests were developed with AI assistance. Hosted CI results above reflect actual completed runs; no unperformed personal manual verification is claimed. M1/M2 acceptance and compensation remain entirely at the maintainer's discretion.

…ostics semantics

Use anonymous disposable module instances, preserve nonfatal managed warnings outside go vet, map Unicode positions to byte offsets, and avoid initializing WASM on Go-only packages. Add regressions for concurrency, source positions, warnings and Go-only packages.
Strict go/analysis drivers only permit declared Go/Other/Ignored files through Pass.ReadFile. Avoid calling it for .hy siblings discovered by disk scan; preserve on-disk reading with snapshot verification and add a strict-driver regression.
…idence

Give maintainers a decision matrix for Rust-to-WASM parity, fail-closed semantics, realistic gopls/TypesInfo boundaries and observed public-wrapper performance, with pinned 113/113 CI links.
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