Sieve playground: the server's interpreter in the browser #181

Merged
jcoffey-dev merged 1 commits from sieve-playground into main 2026-10-09 08:33:56 +00:00
Owner

inbuxa Admin's Debug button on a Sieve script sent the script to an outside playground. Its interpreter only knows upstream's extension names, so any script that requires vnd.inbuxa.expressions or vnd.inbuxa.while failed to compile there. This adds our own playground, built from this repository's interpreter, for the console to ship. The admin side is in a companion inbuxa-admin PR.

What it is: tools/sieve-playground, ported from the playground in the upstream sieve-rs repository's web/ directory (commit 549a2d57f7, written for sieve-rs 1.x) to the vendored 0.7.3 the server runs.

  • Same interpreter: vendor/sieve-rs by path, with the vnd.inbuxa.* names. run.rs/handler.rs drive 0.7's event loop the way delivery does: the script carries on after a runtime error, and llm_prompt compiles and answers false, as a server without a model does.
  • Same functions: the server's own crates/common/src/scripts/functions modules are included by path. Tests fail if the function list, ApplyString or the six functions copied from misc.rs/unicode.rs (the rest of those files needs server-only crates) stop matching.
  • WASI, not wasm-bindgen: sieve-rs 0.7 and mail-builder call SystemTime::now(), which panics on wasm32-unknown-unknown. On wasm32-wasip1 they ask the host instead; the page's worker answers the six WASI calls and gives the clock the playground's current-time setting, so currentdate and a vacation reply's Date follow it. shim/gethostname stands in for a crate with no WASI build. Nothing in vendor/ or crates/ changes.
  • No upstream names on the page or in the samples; storage keys are renamed too. 0.7 has no instruction counter or memory limit, so the page shows neither.

Checked

  • cargo test in the crate: 14 pass, including every sample and the parity tests.
  • Every sample run through the wasm in Node with a fixed clock (the Date headers follow it), and the built console opened in Chrome: no console errors.
  • Fork checks pass (name, notice, context, privacy, expr-schema, unit tests). The root workspace does not see the crate (it has its own [workspace]), so CI is unchanged.

build.sh --admin <dir> stages the build into an inbuxa-admin checkout. When vendor/sieve-rs or the function modules change, rebuild and commit it there.

inbuxa Admin's **Debug** button on a Sieve script sent the script to an outside playground. Its interpreter only knows upstream's extension names, so any script that requires `vnd.inbuxa.expressions` or `vnd.inbuxa.while` failed to compile there. This adds our own playground, built from this repository's interpreter, for the console to ship. The admin side is in a companion inbuxa-admin PR. **What it is:** `tools/sieve-playground`, ported from the playground in the upstream sieve-rs repository's `web/` directory (commit `549a2d57f7`, written for sieve-rs 1.x) to the vendored **0.7.3** the server runs. - **Same interpreter:** `vendor/sieve-rs` by path, with the `vnd.inbuxa.*` names. `run.rs`/`handler.rs` drive 0.7's event loop the way delivery does: the script carries on after a runtime error, and `llm_prompt` compiles and answers `false`, as a server without a model does. - **Same functions:** the server's own `crates/common/src/scripts/functions` modules are included by path. Tests fail if the function list, `ApplyString` or the six functions copied from `misc.rs`/`unicode.rs` (the rest of those files needs server-only crates) stop matching. - **WASI, not wasm-bindgen:** sieve-rs 0.7 and mail-builder call `SystemTime::now()`, which panics on `wasm32-unknown-unknown`. On `wasm32-wasip1` they ask the host instead; the page's worker answers the six WASI calls and gives the clock the playground's current-time setting, so `currentdate` and a vacation reply's `Date` follow it. `shim/gethostname` stands in for a crate with no WASI build. **Nothing in `vendor/` or `crates/` changes.** - **No upstream names** on the page or in the samples; storage keys are renamed too. 0.7 has no instruction counter or memory limit, so the page shows neither. **Checked** - `cargo test` in the crate: 14 pass, including every sample and the parity tests. - Every sample run through the wasm in Node with a fixed clock (the `Date` headers follow it), and the built console opened in Chrome: no console errors. - Fork checks pass (name, notice, context, privacy, expr-schema, unit tests). The root workspace does not see the crate (it has its own `[workspace]`), so CI is unchanged. `build.sh --admin <dir>` stages the build into an inbuxa-admin checkout. When `vendor/sieve-rs` or the function modules change, rebuild and commit it there.
jcoffey-dev added 1 commit 2026-10-09 08:14:58 +00:00
Sieve playground: the server's interpreter in the browser
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 7m45s
136fc2540b
tools/sieve-playground builds the vendored sieve-rs 0.7.3 (vnd.inbuxa.*
names included) to WebAssembly, with a static page around it, for inbuxa
Admin's Debug button on a Sieve script: until now that button sent the
script to an outside site whose interpreter knows only upstream's
extension names, so any script that requires vnd.inbuxa.* failed to
compile there.

Ported from the playground in the upstream sieve-rs repository's web/
directory (commit 549a2d57f7), which targets sieve-rs 1.x:

- run.rs and handler.rs drive 0.7's event loop the way the server's
  delivery does, carrying on after a runtime error; llm_prompt compiles
  and answers false, as on a server without a model.
- The expression functions are the server's own modules, included by
  path; tests fail if the list, ApplyString or the few functions copied
  from misc.rs/unicode.rs stop matching crates/common.
- Built for wasm32-wasip1 rather than with wasm-bindgen: sieve-rs and
  mail-builder read the clock, which panics on wasm32-unknown-unknown.
  The page's worker answers the six WASI calls, giving the module the
  playground's current-time setting. shim/gethostname stands in for a
  crate with no WASI build. Nothing in vendor/ or crates/ changes.
- The page carries no upstream names or links; storage keys and the
  samples are renamed to match.

build.sh --admin <dir> stages the result into an inbuxa-admin checkout.
jcoffey-dev merged commit 9419e160f6 into main 2026-10-09 08:33:56 +00:00
jcoffey-dev deleted branch sieve-playground 2026-10-09 08:33:56 +00:00
Sign in to join this conversation.