Skip to content

feat(pvm): expose standalone runtime through host bridge - #540

Open
replghost wants to merge 50 commits into
mainfrom
feat/pvm-app-runtime
Open

feat(pvm): expose standalone runtime through host bridge#540
replghost wants to merge 50 commits into
mainfrom
feat/pvm-app-runtime

Conversation

@replghost

@replghost replghost commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • keep truapi-pvm-host as the thin reviewed integration boundary for the standalone PolkaVM runtime
  • pin pvm-host-runtime v0.1.8 at 530885a9d6dbf5a2742d4f2ff9f5c71b05f2a762
  • export matching browser assets, native runtime, native GPU renderer, motion metadata, UI semantics, and canonical advanced input APIs
  • generate Swift and Kotlin bindings for atomic UTF-8 text/IME input and validated eight-byte input records
  • retain pointer capture as Host policy; the product-requested capture contract remains a design draft rather than a manifest feature

Runtime boundary

The runtime implementation, browser workers, deterministic assets, ABI documentation, and conformance tests live in paritytech/pvm-host-runtime. This PR retains only the bridge, immutable pin, UniFFI/server wiring, and browser asset exporter.

Verification

  • runtime workspace tests and browser asset reproduction pass at the pinned v0.1.8 source
  • bridge tests and generated Swift/Kotlin bindings pass
  • Dotli and Epoca reproduce the same browser runtime worker digests

Consumers

@replghost
replghost requested a review from a team August 28, 2026 07:13
@replghost
replghost force-pushed the feat/pvm-app-runtime branch from 7f73849 to f6457f1 Compare August 28, 2026 07:15
@replghost
replghost enabled auto-merge August 28, 2026 07:15
@replghost

Copy link
Copy Markdown
Contributor Author

@pgherveou @eugypalu all required checks are green, including Rust/Clippy, Android, iOS, browser artifacts, and license policy. Could one of you provide the required host-sdk-team approval so the merge queue can admit this dependency?

@pgherveou pgherveou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove the generated files in the new js packages. Can't these be built from the src files ?

for the new bindings we can also added then to .gitattributes with linguist-generated=true, so that at least they show up as generated artifacts in the code review

@replghost

Copy link
Copy Markdown
Contributor Author

Addressed in b0e178e: removed the committed browser dist/ tree, ignored it, and kept build/test/release generation source-driven. npm test now proves a clean package checkout builds the WASM and split workers before checksum verification; npm pack --dry-run --json still contains all ten release files. Added linguist-generated=true for the new Swift and FFI binding outputs in .gitattributes.

@replghost
replghost requested a review from pgherveou August 28, 2026 09:18
@replghost

Copy link
Copy Markdown
Contributor Author

Cleanup CI is fully green; ready for rereview and merge queue admission.

@pgherveou

Copy link
Copy Markdown
Collaborator

DQ: why do all these things need to live in host-rust-core, they don't seem to have dependency on the rust-core stuff, and could be shipped independently ?

@replghost
replghost requested a review from Imod7 August 28, 2026 09:29
@replghost
replghost force-pushed the feat/pvm-app-runtime branch from b0e178e to e0f05c4 Compare August 28, 2026 09:32
@replghost

Copy link
Copy Markdown
Contributor Author

They share the Rust core directly rather than only co-locating artifacts:

  • @parity/pvm-browser-runtime compiles rust/crates/pvm-runtime to wasm32-unknown-unknown; its JS workers are the adapter around that Wasm ABI.
  • The same pvm-runtime crate is linked into truapi-server, so the existing UniFFI cdylib/XCFramework/AAR exports the native Swift/Kotlin runtime. A separate repository would require a second native library and package lifecycle in every host.
  • pvm-gpu-wire is shared by the native and browser implementations, keeping bounds and binary GPU records identical.
  • The existing host-rust-core CI/release jobs already regenerate UniFFI and publish the browser/native artifacts from one reviewed commit.

They could be split, but that would duplicate the Rust source/pins and create independent browser, XCFramework, and AAR versioning with an ABI-drift boundary. Keeping the runtime here makes the host-neutral Rust implementation the single source for all three targets; Epoca/Dotli/Brevity/Desktop remain independent consumers.

@replghost

Copy link
Copy Markdown
Contributor Author

Does that shared Rust/UniFFI dependency path resolve the repository-placement concern, or do you want the runtime split into a separate repository before merge?

@replghost

Copy link
Copy Markdown
Contributor Author

Additional review completed. Fixed three concrete boundary issues:

  • Native constructors now enforce the same program, gas, asset-count, per-file, aggregate-byte, and safe-path limits as the browser ABI before guest compilation.
  • The browser compiler backend now enforces the manifest graphics profile, one Tri2D submission per update, CoreVM framebuffer-only behavior, and GPU state/sequence errors consistently with the interpreter.
  • Browser worker termination now closes its timer and MessageChannel ports; invalid launches no longer leak host-thread channels.

Added behavioral browser tests for malformed launch inputs and cross-profile framebuffer submission. Full workspace result: 1,205 tests passed, Clippy -D warnings passed, package tests 4/4 passed, and committed iOS bindings remain current.

Vendored commit 56c67a306fc276129829f94db85a622061e17882 into both consumers and exercised it end to end: Epoca App v2 10/10 plus seven-app browser matrix 45/45; Dotli Doom, Quake, Duke3D, NES, egui, GPU Cube, and Scene Lab all passed on the compiler backend.

@replghost

Copy link
Copy Markdown
Contributor Author

PolkaVM dependency update:

  • Rebased epoca/aarch64-jit-0.37 onto current paritytech/polkavm@master; branch head is e06cce9, 6 commits ahead / 0 behind.
  • Ported the AArch64 JIT across the current code-blob, 32-bit address, dynamic-paging, memset, and 16 KiB page semantics.
  • PolkaVM verification: 4,090 passed, 2 ignored; AArch64 assembler clippy passes with warnings denied.
  • This PR now pins e06cce9 in commit 23f50c64.
  • Host CI is green, including Rust workspace, native build, iOS bindings/package, browser provider, codegen, and dependency licenses.

@replghost

Copy link
Copy Markdown
Contributor Author

The repository-placement concern is now resolved by the extraction:

  • the runtime implementation, GPU wire contract, browser workers/Wasm, tests, ABI documentation, and releases live in paritytech/pvm-host-runtime;
  • the current immutable release is v0.1.4 at 235d1d407f3340fb73cb7a698fe973a9dad5251f;
  • this PR now retains only the thin truapi-pvm-host integration boundary, truapi-server/UniFFI wiring, and the reviewed runtime/asset pin.

Generated browser output remains source-built and verified in the standalone repository; committed Swift/FFI bindings are marked generated. The full bridge matrix is green.

@replghost
replghost force-pushed the feat/pvm-app-runtime branch from de7560d to 8daab08 Compare August 31, 2026 19:46
@replghost
replghost force-pushed the feat/pvm-app-runtime branch from 8daab08 to 5e04221 Compare August 31, 2026 20:37
@replghost
replghost requested a review from a team September 3, 2026 17:25
default = ["wasm-signing-host"]
wasm-signing-host = []
ws-bridge = ["dep:tokio", "dep:tokio-tungstenite", "dep:rand", "dep:base64"]
native-pvm-gpu = ["truapi-pvm-host/native-gpu"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feel like the wrong place to put these dep.
I would rather see one crate that we expose, that depends on truapi-server and native-pvm-gpu

@replghost

Copy link
Copy Markdown
Contributor Author

Final consumer rollout is aligned on v0.1.8: Dotli #185 and Epoca #409 pin 85effb1; Brevity #1164 is merged; App Kit #20 is merged. All bridge checks are green and merge queue/auto-merge is already enabled. @eugypalu @Imod7 @valentinfernandez1 ready for the required approval.

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.

2 participants