This repository was archived by the owner on Oct 20, 2026. It is now read-only.
Repository navigation
modules: load the engines through the host's module door (canary.14) - #3
Merged
Merged
Conversation
…y.14
The data engine and DuckDB ask the host where it serves their declared
wasm (plugin-sdk ADR 326, `host.modules`) before falling back to bin/.
The probe is inline and feature-detected (`supports("modules@1")` + the
member), so the bundle runs unchanged on today's SDK and editor.
- data engine: the wasm-bindgen glue is handed the host's copy, fetched
with its Subresource Integrity; any failure → the copy next to the glue.
- DuckDB: the engine wasm URL comes from the host, pre-fetched once with
its integrity (a 404 or a mismatch falls back to bin/ — DuckDB's worker
hangs rather than rejects on a missing module; a good pre-fetch warms
the cache the worker reads). The worker script and JS API stay in bin/,
same-origin (D-05, comment rewritten to say what it does and does not
forbid). A failed hosted instantiate retries once from bin/.
- publish.yml: stamps sha384 into the PUBLISHED manifest (after
PACKAGE_HASH, before the build that inlines it) and uploads the wasm to
modules.paged.media after `npm publish`, via plugin-cli 0.1.6; skips
cleanly without CLOUDFLARE_API_TOKEN.
Tests: module-door unit tests (probe, glue init, DuckDB pre-fetch); the
browser lane gains a cross-origin brotli module host and boots DuckDB and
the engine from it, plus the 404 fallback.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…text pass) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What
Adopts the plugin-SDK module door (plugin-sdk ADR 326, paged-media/plugin-sdk#11) for both engine wasm files, feature-detected so it runs unchanged on the currently published SDK (0.2.45+ peer) and today's editor.
src/module-door.ts: inline probehostedWasm(host, name)—supports("modules@1")+host.modules.resolve; every failure →null(loadbin/). Not imported from plugin-sdk becauseresolveWasmexists only from 0.2.51 and would be a missing export on older editors.bootEngine→initEngineGlue): wasm-bindgeninit({ module_or_path: fetch(url, { integrity }) })with the host's copy; any failure →init()on the glue's ownbin/data_js_bg.wasm.bootDuckDB({ resolveWasm, onFallback })): the engine wasm URL comes from the host. It is pre-fetched once with its integrity (preflightHostedWasm) — a 404 / CORS refusal / digest mismatch falls back tobin/(DuckDB's worker hangs on a missing module rather than rejecting; found by the browser lane), and a good pre-fetch warms the HTTP cache the worker's own fetch reads (module host serves immutable). A failed hosted instantiate retries once frombin/with a fresh worker. The worker script and JS API stay inbin/, same-origin — the D-05 comment is rewritten honestly: no cross-origin Worker, no CDN/third-party; the first-party module host is allowed for the wasm fetch; SRI cannot reach DuckDB's own fetch (the pre-fetch verifies the same immutable URL). Extensions still load frombin/duckdb-ext/.session.tspasseswasmResolver(host)and logs fallbacks viahost.log.warn.paged-plugin integritystamps sha384 into the published manifest (afterpackage-hash --stamp, before the build that inlines manifest.json — never committed), andpaged-plugin modules-uploadhosts the wasm atmodules.paged.media/@paged-media/data/<version>/bin/…afternpm publish(skips cleanly withoutCLOUDFLARE_API_TOKEN). Both vianpx @paged-media/plugin-cli@0.1.6→ needs plugin-sdk#11 merged + published first.Tests
src/__tests__/module-door.test.ts(10): probe on old/unwired/refusing/throwing hosts, glue init with integrity / URL-only / fallback / no door, DuckDB pre-fetch pass + 404 + integrity failure.test/duckdb-browser.spec.ts, real Chromium): a second cross-origin server stands in for the module host (brotliContent-Encoding,application/wasm, CORS *; CSP connect-src lists it as the editor's does). DuckDB instantiates from it while the worker comes frombin/; a missing host module falls back tobin/; the data engine loads from it with its sha384 and a wrong digest is refused.REQUIRE_REAL_ENGINE=1 REQUIRE_REAL_DUCKDB=1 REQUIRE_REAL_CORE=1 REQUIRE_REAL_BROWSER=1 vitest run: 58 files / 387 passed, 2 skipped.pnpm typecheck && pnpm testgreen; contract-import lint clean;package-hash --checkok (new version).validateok;integritystamps 4/4 and validates;modules-upload --dry-runnames the 4 keys.Release order
plugin-sdk#11 (plugin-cli 0.1.6 must be on npm before this publish runs) → this → editor pins.
🤖 Generated with Claude Code