fix(ruvector-cli): bundle ONNX runtime assets in dist/ + extend verify-dist gate#405
Open
ronmikailov wants to merge 1 commit intoruvnet:mainfrom
Open
fix(ruvector-cli): bundle ONNX runtime assets in dist/ + extend verify-dist gate#405ronmikailov wants to merge 1 commit intoruvnet:mainfrom
ronmikailov wants to merge 1 commit intoruvnet:mainfrom
Conversation
…-dist gate Issue: 0.2.23 → 0.2.25 ship `dist/core/onnx/pkg/` containing only `package.json`, with no `loader.js`, no wasm-bindgen JS bridge, and no `.wasm` binary. The embedder reads those at startup via `path.join(__dirname, 'onnx', ...)`, so on a clean install: ``` $ npx ruvector embed text "hello" Embedding failed: Failed to initialize ONNX embedder: ONNX WASM files not bundled. The onnx/ directory is missing. ``` The previous build script copied exactly one file: ``` "build": "tsc && cp src/core/onnx/pkg/package.json dist/core/onnx/pkg/" ``` Root cause: tsc only emits .js for .ts inputs, so the JS loader, the wasm-bindgen bridge, and the .wasm itself were silently skipped. The verify-dist gate added in ruvnet#403 didn't catch this because it only scanned bin/cli.js for `require('../dist/...js')` calls — these assets are read via path.join + fs.readFileSync + dynamicImport, not require(). Changes: 1. `scripts/copy-onnx-assets.js` (new) — explicit, cross-platform Node script that copies all 8 runtime assets from src/core/onnx/ to dist/core/onnx/. Listed explicitly (not a recursive cp) so adding a new asset is a deliberate choice, not an accident. Fails the build if any source asset is missing. 2. `package.json` — `build` now runs `node scripts/copy-onnx-assets.js` instead of the single-file `cp`. 3. `scripts/verify-dist.js` — adds a second pass that asserts the four runtime asset paths read by `dist/core/onnx-embedder.js` actually exist. This catches the same class of regression (build copies the wrong files) at publish time, not at user-install time. Verification: ``` $ rm -rf dist && npm run build copy-onnx-assets: 8 asset(s) copied to dist/core/onnx/. $ npm run verify-dist verify-dist: 13 dist require path(s) + 4 runtime asset(s) present. $ ls dist/core/onnx/pkg/ LICENSE package.json ruvector_onnx_embeddings_wasm.d.ts ruvector_onnx_embeddings_wasm.js ruvector_onnx_embeddings_wasm_bg.js ruvector_onnx_embeddings_wasm_bg.wasm ruvector_onnx_embeddings_wasm_bg.wasm.d.ts ``` Out of scope: with all assets present, Node still fails to dynamic-import the wasm-bindgen bundler-target entry (`import * as wasm from "./xxx.wasm"` isn't supported by Node ESM without `--experimental-wasm-modules`). That needs a `--target nodejs` (or `web` with deferred init) rebuild of ruvector-onnx-embeddings-wasm. Tracking separately. This PR makes the build/publish actually ship what it claims to ship — necessary precondition for any of the followup wasm-target work. Co-Authored-By: claude-flow <ruv@ruv.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
0.2.23→0.2.25shipdist/core/onnx/pkg/containing onlypackage.json. Noloader.js, no wasm-bindgen JS bridge, no.wasmbinary. The embedder reads those at startup viapath.join(__dirname, 'onnx', ...), so on a clean install of any of those versions:This PR makes the build/publish actually ship what it claims to ship.
Root cause
Old build script:
tsconly emits.jsfor.tsinputs. The JS loader, the wasm-bindgen bridge, and the.wasmbinary itself are all non-TS, so all three were silently skipped. Only the single-filecpran.The
verify-distgate added in #403 caught the originaldist/regression but didn't catch this one because it only scansbin/cli.jsforrequire('../dist/...js'). These assets are read viapath.join+fs.readFileSync+dynamicImport, notrequire(), so the original gate is structurally blind to them.Changes
1.
scripts/copy-onnx-assets.js(new)Explicit, cross-platform Node script that copies the 8 runtime assets the embedder needs. Listed explicitly (not a recursive
cp) so adding a new asset is a deliberate choice, not an accident. Fails the build with a non-zero exit if any source asset is missing.2.
package.json3.
scripts/verify-dist.jsAdds a second pass that asserts the four runtime asset paths read by
dist/core/onnx-embedder.jsactually exist. Same publish-gate semantics as the existingbin/cli.jsscan, just covering the path-join'd asset reads as well.Verification
The "ONNX WASM files not bundled" error no longer fires — the
existsSynccheck atdist/core/onnx-embedder.js:184passes because the files exist.Out of scope (followup needed)
With all assets present, Node still fails the next step:
The shipped
ruvector_onnx_embeddings_wasm.jsis the wasm-bindgen bundler target (import * as wasm from "./xxx.wasm"). Node ESM rejects bare.wasmimports without--experimental-wasm-modules. The embedder code expects the web/no-modules target (withwasmModule.default(wasmBytes)for deferred init), but it never gets that branch because the bundler-target import fails before the embedder's branch logic runs.The clean fix is to rebuild
ruvector-onnx-embeddings-wasmwith--target nodejs(orwebwith deferred init) so the entry exposes adefault(bytes)initializer and doesn't try toimportthe.wasmdirectly. That's a Rust/wasm-bindgen build-config change, not a JS one — out of scope for this PR.This PR is the necessary precondition for that work: the assets actually need to ship before any wasm-target fix can possibly run end-to-end.
Related
ruvector doctorfalsely reports 'Native binding failed to load' #399 —dist/missing entirely on 0.2.23. Fixed in fix(ruvector-cli): release-hygiene fixes for v0.2.24 (#399, #401) #403.dist/paths (onnx-embedder.js,rvf-wrapper.js) missing. Fixed in fix(ruvector-cli): release-hygiene fixes for v0.2.24 (#399, #401) #403..jsassets thatdist/core/onnx-embedder.jsreads at runtime were never copied by the build, even after fix(ruvector-cli): release-hygiene fixes for v0.2.24 (#399, #401) #403'sdist/rescue. Same release-hygiene class.🤖 Generated with claude-flow