Skip to content

Add wasm-friendly seams to ed-agent - #57

Merged
setoelkahfi merged 4 commits into
mainfrom
feature/ed-agent-wasm-seams
Nov 18, 2026
Merged

setoelkahfi merged 4 commits into
mainfrom
feature/ed-agent-wasm-seams

Conversation

@setoelkahfi

@setoelkahfi setoelkahfi commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Adds MaybeSend and MaybeSync, which are Send/Sync on native targets and blanket-implemented on wasm32. The async_trait attributes switch to ?Send on wasm, and timing uses web_time::Instant. Native behavior and public signatures are unchanged.

The workspace now requires onde 1.4.0, whose wasm32 stub matches the real engine's signatures, so ed-agent builds for wasm32-unknown-unknown against the published crate. A new check-wasm32 CI job runs cargo check and cargo clippy -D warnings for ed-agent on that target, and CI status waits 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.

@setoelkahfi setoelkahfi self-assigned this Nov 10, 2026
@setoelkahfi
setoelkahfi requested a review from paydii November 10, 2026 12:51

@sigit-code-review sigit-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread crates/ed-agent/src/maybe.rs Resolved

@sigit-code-review sigit-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@keypair34 keypair34 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

setoelkahfi and others added 3 commits November 16, 2026 11:25
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>
@setoelkahfi
setoelkahfi force-pushed the feature/ed-agent-wasm-seams branch from a4f69a1 to 3439e9a Compare November 16, 2026 10:59

@sigit-code-review sigit-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread .github/workflows/ci.yml Resolved
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>

@sigit-code-review sigit-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@setoelkahfi
setoelkahfi merged commit 3471bd6 into main Nov 18, 2026
5 checks passed
@setoelkahfi
setoelkahfi deleted the feature/ed-agent-wasm-seams branch November 18, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants