Contract ID: wasm-browser-quickstart-migration-v1
Bead: asupersync-umelq.16.2
Depends on: asupersync-umelq.16.1, asupersync-umelq.2.5
Provide a single onboarding and migration path for Browser Edition that is:
- deterministic and reproducible,
- explicit about capability and cancellation semantics,
- aligned with deferred-surface policy decisions.
This guide is intentionally command-first so users can move from "new to Browser Edition" to "verified onboarding evidence" without improvisation.
Required:
- Rust toolchain from
rust-toolchain.toml wasm32-unknown-unknowntargetrchfor offloaded cargo operations
Setup:
rustup target add wasm32-unknown-unknown
rch doctorChoose exactly one Browser profile for wasm32:
| Profile | Feature set | Intended usage |
|---|---|---|
FP-BR-MIN |
--no-default-features --features wasm-browser-minimal |
Contract-only or ABI boundary checks |
FP-BR-DEV |
--no-default-features --features wasm-browser-dev |
Local development and diagnostics |
FP-BR-PROD |
--no-default-features --features wasm-browser-prod |
Production-lean build envelope |
FP-BR-DET |
--no-default-features --features wasm-browser-deterministic |
Deterministic replay-oriented validation |
Guardrails:
- On wasm32, exactly one canonical browser profile must be enabled.
- Forbidden surfaces (
cli,io-uring,tls,sqlite,postgres,mysql,kafka) are compile-time rejected.
Reference: docs/integration.md ("wasm32 Guardrails"), src/lib.rs compile
error gates.
Browser onboarding and migration should flow through the release-channel contract before promotion beyond local/dev usage.
Canonical policy:
docs/wasm_release_channel_strategy.md
Channel model:
nightly(wasm-browser-dev) for rapid iteration,canary(wasm-browser-canary) for pre-stable validation,stable(wasm-browser-release) only after all release gates pass.
Minimum gate bundle before promotion:
python3 scripts/check_wasm_optimization_policy.py \
--policy .github/wasm_optimization_policy.json
python3 scripts/check_wasm_dependency_policy.py \
--policy .github/wasm_dependency_policy.json
python3 scripts/check_security_release_gate.py \
--policy .github/security_release_policy.json \
--check-deps \
--dep-policy .github/wasm_dependency_policy.jsonCargo-heavy profile checks remain rch-offloaded:
rch exec -- cargo check --target wasm32-unknown-unknown \
--no-default-features --features wasm-browser-dev
rch exec -- cargo check --target wasm32-unknown-unknown \
--no-default-features --features wasm-browser-prodIf any release-blocking gate fails, treat as promotion-blocking and follow the
demotion/rollback sequence in docs/wasm_release_channel_strategy.md.
Before onboarding framework adapters, verify workspace slicing closure for the browser path.
Core slicing intent:
- Keep semantic runtime invariants in the wasm-safe core path.
- Keep native-only modules behind
cfg(not(target_arch = "wasm32")). - Keep optional adapters out of default browser closure unless explicitly needed.
Validation commands:
rch exec -- cargo check --target wasm32-unknown-unknown \
--no-default-features --features wasm-browser-minimal \
| tee artifacts/onboarding/profile-minimal-check.log
rch exec -- cargo check --target wasm32-unknown-unknown \
--no-default-features --features wasm-browser-dev \
| tee artifacts/onboarding/profile-dev-check.log
rch exec -- cargo check --target wasm32-unknown-unknown \
--no-default-features --features wasm-browser-deterministic \
| tee artifacts/onboarding/profile-deterministic-check.logExpected outcomes:
- each profile compiles independently,
- no native-only module leaks into wasm32 compilation closure,
- profile guardrails reject invalid multi-profile feature combinations.
Each flow has:
- a deterministic command bundle,
- expected verification outcomes,
- artifact pointers for replay/debug.
Automated runner (preferred for CI/replay bundles):
python3 scripts/run_browser_onboarding_checks.py --scenario allScenario-scoped runs:
python3 scripts/run_browser_onboarding_checks.py --scenario vanilla
python3 scripts/run_browser_onboarding_checks.py --scenario react
python3 scripts/run_browser_onboarding_checks.py --scenario nextCanonical framework examples and deterministic replay pointers:
docs/wasm_canonical_examples.md.
Goal: verify scheduler, cancellation/quiescence, and capability boundaries.
mkdir -p artifacts/onboarding
rch exec -- cargo test -p asupersync browser_ready_handoff -- --nocapture \
| tee artifacts/onboarding/vanilla-browser-ready.log
rch exec -- cargo test --test close_quiescence_regression \
browser_nested_cancel_cascade_reaches_quiescence -- --nocapture \
| tee artifacts/onboarding/vanilla-quiescence.log
rch exec -- cargo test --test security_invariants browser_fetch_security -- --nocapture \
| tee artifacts/onboarding/vanilla-security.logExpected outcomes:
- browser handoff tests pass (no starvation regressions)
- nested cancel-cascade reaches quiescence
- browser fetch security policy tests pass with default-deny behavior
Goal: verify browser-capable seams and deterministic behavior before integrating React adapters.
rch exec -- cargo test --test native_seam_parity \
browser_clock_through_trait_starts_at_zero -- --nocapture \
| tee artifacts/onboarding/react-clock.log
rch exec -- cargo test --test native_seam_parity \
browser_clock_through_trait_advances_with_host_samples -- --nocapture \
| tee artifacts/onboarding/react-clock-advance.log
rch exec -- cargo test --test obligation_wasm_parity \
wasm_full_browser_lifecycle_simulation -- --nocapture \
| tee artifacts/onboarding/react-obligation.logExpected outcomes:
- browser clock abstraction is monotonic and deterministic
- obligation lifecycle invariants hold across browser-style lifecycle phases
Goal: verify profile closure and dependency policy before wiring App Router boundaries.
Reference template and deployment guidance:
docs/wasm_nextjs_template_cookbook.md.
python3 scripts/check_wasm_dependency_policy.py \
--policy .github/wasm_dependency_policy.json \
| tee artifacts/onboarding/next-dependency-policy.log
rch exec -- cargo check --target wasm32-unknown-unknown \
--no-default-features --features wasm-browser-dev \
| tee artifacts/onboarding/next-wasm-check.log
python3 scripts/check_wasm_optimization_policy.py \
--policy .github/wasm_optimization_policy.json \
| tee artifacts/onboarding/next-optimization-policy.logExpected outcomes:
- dependency policy script exits cleanly and produces summary artifacts
- wasm profile check confirms chosen profile closure rules
- optimization policy summary is emitted for downstream CI gates
Known failure signature and remediation:
- Signature:
getrandomcompile error requiringwasm_jssupport duringnext.wasm_profile_check. - Immediate action: treat this as a blocker for Next onboarding, capture
artifacts/onboarding/next.wasm_profile_check.log, and route fix through the wasm profile/dependency closure beads before retrying this flow.
Common legacy pattern:
Promise.race([...])returns winner, losers continue silently
Asupersync browser model:
- race winner returned,
- losers explicitly cancelled and drained,
- obligation closure is required before region close.
What to do:
- model the competing operations as scoped tasks,
- wire explicit cancellation on loser branches,
- verify with quiescence and obligation parity tests.
Verification commands:
rch exec -- cargo test --test close_quiescence_regression browser_ -- --nocapture
rch exec -- cargo test --test obligation_wasm_parity wasm_cancel_drain_ -- --nocaptureCommon legacy pattern:
- direct
fetch, timers, or storage calls without explicit authority envelope
Asupersync browser model:
- effects must flow through explicit capability contracts,
- default-deny policy for browser fetch authority.
What to do:
- define explicit origin/method/credential/header constraints,
- pass capability through call chain; avoid ambient globals,
- add policy tests before exposing API surface.
Verification command:
rch exec -- cargo test --test security_invariants browser_fetch_security -- --nocaptureCommon legacy pattern:
- detached async work that outlives UI/component lifecycle
Asupersync browser model:
- each task belongs to one region,
- region close requires quiescence,
- cancellation follows request -> drain -> finalize.
What to do:
- move detached work into explicit scope/region ownership,
- ensure close paths drive cancel+drain,
- reject lifecycle completion while obligations remain unresolved.
Verification command:
rch exec -- cargo test --test close_quiescence_regression browser_ -- --nocaptureMigration docs must not promise deferred capabilities as available. Authoritative
register: PLAN_TO_BUILD_ASUPERSYNC_IN_WASM_FOR_USE_IN_BROWSERS.md, Section
6.6 ("Deferred Surface Register").
Required mappings:
| DSR ID | Deferred surface | Browser guidance |
|---|---|---|
DSR-001 |
OS network sockets and listener stack | Use browser transport envelopes (fetch, WebSocket, browser stream bridges) through capability wrappers |
DSR-002 |
Reactor + io-uring paths | Use browser event-loop scheduling contract and timer adapters; do not reference native pollers |
DSR-003 |
Native TLS stack | Use browser trust model; no native cert-store assumptions in browser guides |
DSR-004 |
fs/process/signal/server modules |
Treat as explicit non-goals for browser-v1; route to server-side companion services |
DSR-005 |
Native DB clients (sqlite/postgres/mysql) |
Use browser-safe RPC boundaries and keep DB access out of browser runtime core |
DSR-006 |
Native-only transport protocols (kafka/quic-native/http3-native) | Use browser-compatible transport facade and declare protocol availability explicitly |
DSR-007 |
Runtime-dependent observability sinks | Use browser-safe tracing/export pathways and preserve deterministic artifact contracts |
Each onboarding run should capture:
scenario_id(vanilla-smoke,react-readiness,next-readiness)- command bundle used
- profile flags and target triple
- pass/fail outcome per step
- artifact paths
- remediation hint per step (
remediation_hint) - terminal failure excerpt (
failure_excerpt) for failing steps
Minimum artifact set:
artifacts/onboarding/*.logartifacts/onboarding/*.ndjsonartifacts/onboarding/*.summary.jsonartifacts/wasm_dependency_audit_summary.jsonartifacts/wasm_optimization_pipeline_summary.json
Use this bundle for documentation drift detection:
# Core compile/lint/format gates
rch exec -- cargo check --all-targets
rch exec -- cargo clippy --all-targets -- -D warnings
rch exec -- cargo fmt --check
# Browser policy checks referenced by this guide
python3 scripts/check_wasm_dependency_policy.py --policy .github/wasm_dependency_policy.json
python3 scripts/check_wasm_optimization_policy.py --policy .github/wasm_optimization_policy.json
python3 scripts/run_browser_onboarding_checks.py --scenario allDrift policy:
- Any command change in this guide must be accompanied by updated expected outcomes.
- Any profile/surface statement change must be validated against DSR mappings.
- Any migration guidance change must keep an explicit verification command.