Skip to content

build: the wasm bindings are their own crate, rvt-wasm, and rvt builds as a plain rlib (C6) - #724

Merged
DrunkOnJava merged 3 commits into
mainfrom
perf/c6-rvt-wasm
Oct 5, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
perf/c6-rvt-wasm

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

From the CI audit of 2026-10-05: the core crate's crate-type was
["rlib", "cdylib"] for the wasm-pack output, and a crate type cannot be
feature-gated, so every native build, test run and cargo install linked a
shared library nobody used.

  • rvt-wasm/ (a workspace member, publish = false) holds the bindings,
    moved from src/wasm.rs, and the wasm-pack settings; the viewer builds it
    with wasm-pack build rvt-wasm --target web --out-dir ../viewer/pkg --out-name rvt, so viewer/pkg keeps rvt.js and rvt_bg.wasm.
  • rvt drops the wasm feature, its two optional dependencies and the cdylib
    crate type. The IFC header's clock, which the core read from the wasm
    module on wasm32 (SystemTime panics there), comes from js-sys on
    wasm32-unknown-unknown.
  • CI lints rvt-wasm with its own clippy step; deploy-viewer, publish.yml,
    the install script and the docs use the new command.

Verified by this pull request's CI: the deploy-viewer job builds the viewer from rvt-wasm and runs its browser tests, and clippy runs on rvt-wasm. The publish.yml viewer smoke runs only at tag time.


Note

Medium Risk
Restructures how the viewer WASM is built and linked; native consumers and release pipelines depend on the new crate layout, though the JS API and output filenames are preserved.

Overview
Splits WebAssembly bindings into a dedicated workspace crate so the core rvt package no longer builds as a cdylib on every native cargo build, test, or cargo install — the old ["rlib", "cdylib"] layout could not be feature-gated.

The new rvt-wasm member (publish = false) holds the wasm-bindgen surface (moved from src/wasm.rs), depends on rvt, and carries the wasm-pack wasm-opt = false metadata. The root crate drops the wasm feature and optional wasm-bindgen / serde-wasm-bindgen dependencies.

Build and CI now use wasm-pack build rvt-wasm --target web --out-dir ../viewer/pkg --out-name rvt everywhere (install script, deploy-viewer, publish, docs). Viewer artifacts stay rvt.js / rvt_bg.wasm. CI adds cargo clippy -p rvt-wasm.

IFC STEP header timestamps on wasm32 no longer go through the bindings crate: step_writer uses js-sys::Date::now() when targeting wasm32-unknown-unknown, with js-sys added as a target-specific dependency on the core crate.

Reviewed by Cursor Bugbot for commit 8857e2e. Configure here.

…s as a plain rlib (C6)

From the CI audit of 2026-10-05: the core crate's crate-type was
["rlib", "cdylib"] for the wasm-pack output, and a crate type cannot be
feature-gated, so every native build, test run and cargo install linked a
shared library nobody used.

- rvt-wasm/ (a workspace member, publish = false) holds the bindings,
  moved from src/wasm.rs, and the wasm-pack settings; the viewer builds it
  with `wasm-pack build rvt-wasm --target web --out-dir ../viewer/pkg
  --out-name rvt`, so viewer/pkg keeps rvt.js and rvt_bg.wasm.
- rvt drops the wasm feature, its two optional dependencies and the cdylib
  crate type. The IFC header's clock, which the core read from the wasm
  module on wasm32 (SystemTime panics there), comes from js-sys on
  wasm32-unknown-unknown.
- CI lints rvt-wasm with its own clippy step; deploy-viewer, publish.yml,
  the install script and the docs use the new command.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Viewer deploy skips wasm crate
    • Added rvt-wasm/** to the deploy-viewer push and pull_request path filters and updated the workflow comment so bindings-only changes trigger a rebuild and Pages deploy.

Create PR

Or push these changes by commenting:

@cursor push b0c8afcc75
Preview (b0c8afcc75)
diff --git a/.github/workflows/deploy-viewer.yml b/.github/workflows/deploy-viewer.yml
--- a/.github/workflows/deploy-viewer.yml
+++ b/.github/workflows/deploy-viewer.yml
@@ -3,8 +3,8 @@
 # VW1-18 — build the WASM + the Vite site and publish to
 # https://drunkonjava.github.io/rvt-rs/ via GitHub Pages (Pages root;
 # the old `/viewer/` sub-path 404s).
-# Runs on every push to main that touches viewer/ or src/ (so the
-# WASM stays fresh), plus manual runs.
+# Runs on every push to main that touches viewer/, rvt-wasm/, or src/
+# (so the WASM stays fresh), plus manual runs.
 #
 # C3: the viewer is published only from a commit whose CI passed. The deploy
 # job waits for CI's `CI passed` check on the pushed commit; a commit CI's
@@ -16,6 +16,7 @@
     branches: [main]
     paths:
       - 'src/**'
+      - 'rvt-wasm/**'
       - 'viewer/**'
       - 'docs/viewer-demos.json'
       - 'Cargo.toml'
@@ -25,6 +26,7 @@
     branches: [main]
     paths:
       - 'src/**'
+      - 'rvt-wasm/**'
       - 'viewer/**'
       - 'docs/viewer-demos.json'
       - 'Cargo.toml'

You can send follow-ups to the cloud agent here.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8857e2e. Configure here.

Comment thread .github/workflows/deploy-viewer.yml Resolved
The bindings moved from src/ to rvt-wasm/, so the viewer deploy's path
filters now watch rvt-wasm/** too; without it a bindings-only change would
leave Pages serving the previous rvt.js and rvt_bg.wasm (Bugbot on #724).
@DrunkOnJava
DrunkOnJava merged commit ad477c5 into main Oct 5, 2026
27 checks passed
@DrunkOnJava
DrunkOnJava deleted the perf/c6-rvt-wasm branch October 5, 2026 18:56
DrunkOnJava added a commit that referenced this pull request Oct 20, 2026
…and rvt-wasm crate (#849)

## Summary

Two contributor-facing docs described a layout that C6 (2026-10-05: #724 split the bindings into `rvt-wasm`, #732 merged every test file into one binary) replaced. `docs/extending-layer-5b.md`'s Step 5 told a contributor to add a check that would never run, and the viewer docs named a bindings file that no longer exists.

## Motivation

A scan of the docs for cited source paths that do not exist found these. The other misses it reported are dated notes about other repositories, historical reports, an ADR and a launch draft that says it was written for 0.1.2.

- **`docs/extending-layer-5b.md`, Step 5.** It said to add a `#[test]` gated on a `corpus` feature to `tests/elements.rs`, opening `_corpus/examples/Autodesk/...` by a hard-coded path. There is no `corpus` feature and no `tests/elements.rs`. Since #732 every `tests/*.rs` file is a module of the one `integration` binary, and CI runs only the files `tools/ci/test-targets.txt` classes. A test written to the guide is neither compiled nor run, and the repository's rule is to resolve the corpus through `tests/common`, never a path.
- **`docs/viewer-build-pipeline.md` and `AGENTS.md`.** Both named `src/wasm.rs` behind a `wasm` feature. #724 moved the bindings to their own crate, `rvt-wasm`, and `rvt` builds as a plain `rlib`. The build commands both docs give were already the `rvt-wasm` ones.

## Changes

- `docs/extending-layer-5b.md`:
  - **Step 3** registers the decoder and lists its class in `elements::MVP_TYPED_CLASSES` before the corpus check, since production uses a typed decoder only for those classes (skipping an instance it rejects). The same change adds the class's arm to `typed_json::mvp_typed_view`, or the CLI and Python give it `typed: null`, and to the list `tests/python/test_decoded_api.py` pins and the class list in `docs/schemas/decoded-elements.schema.json`. It drops the `decoder_class_names_are_unique` tripwire, which no longer exists (`decoder_for_class` takes the first match).
  - **Step 5** says how a real-file check is added now: `tests/<name>.rs`, a line in `tests/integration/main.rs`, and the class `real` in the manifest, which fails CI for a file it does not class. The check uses the files whose oracle holds the class (the family corpus through `tests/common`, or project files through `RVT_PROJECT_CORPUS_DIR`), requires an instance only where the oracle has one, and fails on a missing file when `RVT_REQUIRE_CORPUS` is set, as `tests/elem_table_corpus.rs` does. Its example decodes through the production path (`walker::iter_elements`), keeps the schema rows (`record_kind` `schema_instance`, which typed and generic decodes share and partition records do not), asserts `provenance.decoder == "MyClassDecoder"` on each, and marks where each field is compared with the oracle by ElementId.
  - **The file list, Step 6 and Step 7** no longer put tests in the decoder file or say "unit-tested with synthesized bytes", and the commit scope is `elements`.
- `docs/viewer-build-pipeline.md`: its note on what the snippets predate gains the `rvt-wasm` move (C6, #724) and says #260's per-ref concurrency group happened (it said "is proposed", though #260 merged on 2026-09-19).
- `AGENTS.md`: the WASM package is rebuilt when `rvt-wasm/src/lib.rs` or the library code it reaches changes.

## Testing

N/A: docs only. The example uses `RevitFile::schema`, `SchemaTable::classes`, `ClassEntry::{name, fields}` and `tests/common`'s `ALL_YEARS` and `sample_for_year`, as `tests/samples.rs` does.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR
- [x] Commit messages describe what changed and why
- [x] No emojis in code, docs, or commit messages
- [x] No private paths, personal email addresses, or internal jargon in committed files

## Legal and contribution hygiene

- [x] I agree this work is licensable under Apache-2.0 (see `CONTRIBUTING.md`)
- [x] This PR contains no Autodesk proprietary source, decompiled internals, or NDA'd SDK content (see `CLEANROOM.md`)

## Breaking changes

None.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Documentation-only updates with no runtime or CI behavior changes.
> 
> **Overview**
> Updates contributor docs so they match **C6**: WASM bindings live in **`rvt-wasm`**, and corpus checks plug into the single **`integration`** test binary plus **`tools/ci/test-targets.txt`**.
> 
> **`docs/extending-layer-5b.md`** expands the “three-file” checklist to include **`typed_json`**, Python/schema class lists, and the corpus/CI wiring. Step 2’s example now **fails closed** in `decode` (not just `decode_instance`). Step 3 documents **`MVP_TYPED_CLASSES`**, production scoring/provenance, and where to register typed output. Step 5 **replaces** the obsolete `tests/elements.rs` / `corpus`-feature pattern with **`tests/<name>_corpus.rs`**, a module line in **`tests/integration/main.rs`**, and classing the file **`real`** in the CI manifest, including an oracle-driven `iter_elements` example.
> 
> **`AGENTS.md`** and **`docs/viewer-build-pipeline.md`** point rebuild notes at **`rvt-wasm/src/lib.rs`** and record the bindings split and merged **per-ref** deploy concurrency as shipped.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 3873423. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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