Skip to content

chore(wasm): rayon cfg-gate, event_rx doc, wasm-check CI (deferred from #1007) #1010

Description

@clouatre

Status update (2026-08-28)

  • Item 1 (rayon cfg-gate): re-checked call sites -- par_iter() now appears at 3 sites (analyze.rs:297, cache.rs:97, cache.rs:168), not 5. The underlying blocker (tree-sitter's C build scripts can't cross-compile to wasm32-unknown-unknown) is unchanged and still real.
  • Item 2 (event_rx doc comment): stale, drop this item. CodeAnalyzer no longer has an event_rx field, and LogEvent/NeverSessionManager-as-drain-source no longer exist in CodeAnalyzer at all (NeverSessionManager now only appears in main.rs as an unrelated rmcp HTTP session-manager type). Whatever this field was appears to have been refactored away since feat(http): bearer token auth middleware for HTTP MCP transport #1007. Nothing to document here.
  • Item 3 (wasm-check CI feature): unaffected by the above; still a real deferred item once tree-sitter WASM support exists. Note the --no-default-features flag in the proposed CI command now only disables the schemars feature (the only remaining feature flag), since the lang-* feature-gate system was removed repo-wide -- languages will still compile in regardless of that flag.

Background

During the implementation of bearer token auth for the HTTP MCP transport (#1007), three
additional changes were drafted and then removed as YAGNI:

  1. Rayon cfg-gate in aptu-coder-core (analyze.rs, cache.rs)
  2. event_rx doc comment in CodeAnalyzer
  3. wasm-check CI feature and job

They are tracked here for when WASM portability becomes a concrete goal.

Items

1. Rayon wasm cfg-gate

analyze.rs and cache.rs use rayon::par_iter() at 5 call sites. Under
#[cfg(target_family = "wasm")] these must fall back to sequential iter(), since rayon
requires OS threads which do not exist in any WASM target.

The implementation is straightforward:

  • Gate use rayon::prelude::* with #[cfg(not(target_family = "wasm"))]
  • At each par_iter() site, emit sequential iter() under #[cfg(target_family = "wasm")]

Blocker: tree-sitter is an unconditional direct dependency of aptu-coder-core and
includes C build scripts that cannot cross-compile to wasm32-unknown-unknown. The cfg-gate
alone does not make the crate WASM-compilable. Address alongside or after tree-sitter WASM
support.

2. event_rx doc comment

Add a doc comment to the event_rx: Arc<TokioMutex<Option<mpsc::UnboundedReceiver<LogEvent>>>>
field in CodeAnalyzer explaining the drain-once invariant under NeverSessionManager.

Small, self-contained. Can ship independently of item 1.

3. wasm-check CI feature and job

Because cargo check --target wasm32-unknown-unknown is not viable (tree-sitter C build
scripts, Rust 1.96 explicit_builtin_cfgs_in_flags blocks RUSTFLAGS='--cfg target_family="wasm"'),
a wasm-check Cargo feature was designed to activate the wasm cfg branches on a native host:

# aptu-coder-core/Cargo.toml
wasm-check = []
# ci.yml
- run: cargo check --locked -p aptu-coder-core --no-default-features --features wasm-check

This requires updating all cfg gates to any(target_family = "wasm", feature = "wasm-check"),
adding permanent indirection at every site. Ship together with item 1.

Prerequisites

  • tree-sitter WASM support in the Rust ecosystem (upstream, no timeline)
  • Concrete WASM deployment target chosen (wasm32-wasip2 + wasmtime/Spin recommended over
    wasm32-unknown-unknown + Cloudflare Workers; see prior analysis)

Metadata

Metadata

Assignees

No one assigned

    Labels

    choreMaintenance tasks

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions