Repository navigation
Add wasm-friendly seams to ed-agent - #57
Conversation
There was a problem hiding this comment.
This PR makes ed-agent compilable for wasm32 without changing native behavior. The core is a new public maybe module: MaybeSend/MaybeSync are plain Send/Sync supertrait markers on native targets and blanket-implemented for every ?Sized type on wasm32, following wgpu's WasmNotSend pattern. The four host-facing seams (ToolExecutor, ApprovalHandler, EventSink, SessionStore) switch their bounds to these aliases, and the three async_trait traits (plus their in-crate impls) use #[async_trait(?Send)] on wasm so returned futures don't need Send. Timing moves from std::time::Instant to web_time::Instant (a std re-export on native), since Instant::now() panics on wasm32-unknown-unknown. The crate doc now documents that onde's stub engine only matches real signatures in newer releases, so wasm builds wait on an onde release plus a version bump — consistent with the author's note that wasm CI is deliberately deferred. Native cargo check/test/clippy pass unchanged. One soundness concern about the cfg gate is raised below; otherwise the seams look correct and the native desugaring is identical to before.
Automated review by siGit Code Review · commit 337fee0 · see the review dashboard
There was a problem hiding this comment.
The wasm gating now keys on wasm32-unknown-unknown, so wasip1-threads and Emscripten pthreads keep the real Send/Sync bounds; the async_trait(?Send) attributes and docs were updated consistently. The earlier thread-safety concern is addressed, and I see no remaining issues in this diff.
Automated review by siGit Code Review · commit a4f69a1 · changes since 337fee0 · see the review dashboard
Introduce MaybeSend and MaybeSync marker traits that are Send/Sync on native targets and blanket-implemented on wasm32, switch the async_trait attributes to ?Send on wasm, and use web_time::Instant so timing works in the browser. Native behavior and public signatures are unchanged. The Platforms section of the crate docs no longer claims the onde stub has different signatures; that was fixed on the onde side. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
target_arch = "wasm32" also matches wasm32-wasip1-threads and Emscripten with pthreads, where the single JS thread premise does not hold and the blanket MaybeSend/MaybeSync impls would let a !Send host type cross threads. Gate the relaxation, and the matching async_trait(?Send) attributes, on wasm32 with target_os = "unknown", the browser target the docs justify. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.6 <noreply@sigit.si>
onde 1.4.0 has a wasm32 stub engine whose signatures match the real engine, so ed-agent builds for wasm32-unknown-unknown against the published crate. Bump the workspace dependency to it and refresh the lockfile (uniffi stays at =0.31.0). Add a check-wasm32 job that runs cargo check and clippy -D warnings for ed-agent on that target, and make the CI status job wait on it. Update the Platforms crate doc to say wasm32-unknown-unknown builds against onde's web target. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si> Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>
a4f69a1 to
3439e9a
Compare
There was a problem hiding this comment.
This PR makes ed-agent build on wasm32-unknown-unknown. The core is the new maybe module: MaybeSend/MaybeSync are plain Send/Sync supertraits on native and blanket-implemented for every ?Sized type on wasm32-unknown-unknown, gated on target_os = "unknown" per the earlier review thread (now resolved). The host seams (ToolExecutor, ApprovalHandler, EventSink, SessionStore) switch their bounds to these aliases, and their async_trait attributes become ?Send on that target. Timing moves to web_time::Instant since std::time::Instant::now() panics on wasm. The workspace bumps onde to 1.4.0 (whose wasm stub matches the real engine's signatures), and a new check-wasm32 CI job runs cargo check and clippy for ed-agent on the target, with CI status gating on it. Native signatures and behavior are unchanged. One small gap in the new CI job noted below; otherwise the diff looks clean.
Automated review by siGit Code Review · commit 3439e9a · see the review dashboard
Addresses review feedback on #57. The check-wasm32 job ran without --all-targets, so the test module never compiled on wasm32 and the ?Send switches inside it went unchecked. Adding --all-targets exposed that two test impls, CountingExecutor (ToolExecutor) and FixedApproval (ApprovalHandler), still carried a plain async_trait and so kept the Send bound their traits drop on wasm32-unknown-unknown. Give both the same wasm32 cfg_attr switch the production impls use, and run the wasm32 check and clippy with --all-targets so this path stays covered. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si> Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>
There was a problem hiding this comment.
Re-review of the wasm-seams follow-up. Both earlier threads are addressed: the wasm relaxation is now gated on target_os = "unknown" (keeping real Send/Sync bounds on wasip1-threads and Emscripten), and the wasm32 CI job now runs check/clippy with --all-targets, so the test modules are actually compiled on that target. The new cfg_attr switches on the CountingExecutor and FixedApproval test impls in ed.rs match the ?Send trait definitions, which is what makes those --all-targets runs pass. Nothing new to flag.
Automated review by siGit Code Review · commit e6d25f3 · changes since 3439e9a · see the review dashboard
Adds
MaybeSendandMaybeSync, which areSend/Syncon native targets and blanket-implemented on wasm32. Theasync_traitattributes switch to?Sendon wasm, and timing usesweb_time::Instant. Native behavior and public signatures are unchanged.The workspace now requires
onde1.4.0, whose wasm32 stub matches the real engine's signatures, soed-agentbuilds forwasm32-unknown-unknownagainst the published crate. A newcheck-wasm32CI job runscargo checkandcargo clippy -D warningsfored-agenton that target, andCI statuswaits on it. The Platforms crate doc now says wasm32 builds against onde's web target.Checked locally: the wasm32 check and clippy, plus fmt, clippy and tests for the whole workspace.