[wasm] Expose Engine.clone to bindings

Open
#721 1 comment 1 reaction 2 assignees View on GitHub

Maintainers usually reply within 1 day

@anakrish is already working on this.

Since May 13, 2026.

  • #722 by @copilot-swe-agent — open

Assessment

This issue has not been assessed yet.

Description

While the Engine in wasm binding implements the Clone trait, it's not currently exposed in wasm binding, so there doesn't seem to be way to clone from Javascript.
A small clone method on Engine could be added to allow cloning in Javascript.

I was running a benchmark on Clone where I would clone before each evaluation, I noticed that without running a dummy evaluation first before cloning, each evaluation after cloning would be very slow.

I have to basically do (psuedocode)

template := new Engine()
engine.addPolicy(...)
engine.addDataJson(..)
engine.addInputJson(dummy)
engine.evalRule(dummy rule) // Without this evaluation, each eval after clone is very expensive.

for each loop {
  e := template.clone()
  e.addInputJson(...)
  e.evalRule(....)
}

To avoid using dummy inputs, can an API be provided in Rust, so we can call engine.prepare() after addDataJson.
I was using almost 1MB rego file.

Dominant language
Rust
Stars
375
Forks
81
Avg merge
1d 11h
Merged PRs (30d)
78

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/regorus

All issues in microsoft/regorus

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.