Skip to content

dx: development-friction debt — shared core crate, generated jco flags, guest wrappers, harness cleanups #35

Description

@lann

Every algorithm addition currently costs three implementations, two giant package.json flag lines, manifest entries, and vector suites. Reduce the recurring tax before the surface grows:

  • Shared RustCrypto core crate. wasmtime-impl/src/host.rs and guest-impl/src/provider.rs duplicate ~500 lines near-verbatim — the Sha2 and AeadCipher enums, new_aes_gcm_key/new_chacha_key validation, nonce budgets, algorithm-name constants, even error-message strings (compare host.rs:148-224 with provider.rs:117-192). Extract the algorithm cores and minting validation into one crate consumed by both, leaving only bindings/resource-table plumbing per side. Today the conformance suite is the only thing keeping the two in sync, and its coverage has holes exactly where drift would hide (see the coverage-gaps issue).
  • Generate the jco transpile flags from the WIT. Renaming an interface touches ~13 sites; the worst are the ~2,900-character --async-imports/--map one-liners duplicated with different contents in examples/jco-demo/package.json:9 and conformance/adapters/jco/package.json:8,11 — unreviewable in diffs, and a typo in an --async-imports string produces a silently-synchronous import and a runtime JSPI failure, not a build error.
  • Guest-side convenience libraries. Every consumer re-implements the feed-a-stream-and-await pattern (futures::join! plumbing) to MAC 20 bytes; feed/read_all helpers are already copy-pasted across crypto-demo, timing-lab, and the conformance guests (e.g. examples/crypto-demo/src/lib.rs:554-582 vs timing-lab/src/lib.rs:179-189). Publish thin guest wrappers (Rust crate, JS package) with sign_bytes(&[u8])-style helpers so the correct pattern is written once. (Migrated from TODO.md.)
  • Demo-harness and build-plumbing cleanups:
    • The expected-summary gate is self-referential — count and list derive from the same Vec (examples/crypto-demo/src/lib.rs:127-131), asserted identically in two drivers (examples/wasmtime-demo/tests/demo.rs:64-76, examples/jco-demo/src/run.mjs:26-36) and absent from the composed driver (examples/demo-driver/src/lib.rs:29-41). Deleting half the demo's checks passes every gate on every target. Pin an expected check list somewhere, or stop describing it as a gate (AGENTS.md cites it as the exemplar of "a gate asserts it").
    • Dead bindgen with: blocks — examples/wasmtime-demo/src/lib.rs:26-30 maps 3 of 6 resource types, conformance/adapters/wasmtime/src/main.rs:54-57 maps 2; both are dead configuration (imports come from add_to_linker) that misleads readers. Delete or make consistent.
    • The component-build recipe exists twice (examples/wasmtime-demo/tests/demo.rs:26-53 shells out to cargo + wasm-tools; examples/jco-demo/package.json build:component) with no gate against drift — and just build-component routes the pure-Rust build through npm, so just demo-wasmtime requires Node.
    • GNU timeout in recipes makes the justfile silently Linux-only; the 7-crate --exclude lists are hand-duplicated in two recipes (justfile:17, 37) with nothing checking they match members.

From the 2026-07 whole-repo review (convenience libraries migrated from TODO.md).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions