Skip to content

research: Rhai vs Monty (pydantic/monty) for ledgrrr's execution/rule layer — evaluate later, don't decide now #115

Description

@elasticdotventures

Summary

Backlogged per operator direction 2026-07-25: keep Rhai and Monty as options, not a conclusion. Evaluate separately, later, whether to stay on Rhai or move some/all execution to Monty. Do not block other work on this decision.

Context

  • Rhai (already in use): embedded dynamic-typed scripting language, deeply wired into ledger-core's classification waterfall (rule_registry.rs, .rhai rule files) and the gateway policy layer. Chosen originally to mirror Rust's match expression plus trait-based type extension inside the rule engine — not intended as a general sandbox.
  • Monty (pydantic/monty, released Feb 2026): a minimal, sandboxed Python-subset interpreter written in Rust, purpose-built for safely executing LLM-generated code. Microsecond startup, strict sandboxing (no filesystem/network unless host-exposed), WASM builds. Supports def, closures, decorators, async/await; does not support classes; small stdlib only (sys, os, typing, asyncio, re, datetime, json, dataclasses soon).
  • Raised in the context of: if an LLM is generating executable logic for ledgrrr's process/pipeline layer, Monty's sandboxing model may be a better fit for "LLM writes it, something else must safely run it" than Rhai's tighter native-Rust-integration model.

What "evaluate later" should look at

  • Whether the execution layer even needs a general-purpose scripting language at all, vs. a narrow typed step-interpreter over a fixed operator vocabulary (see the CLIF AST issue — if CLIF cleanly lowers to a restricted operator DAG, neither Rhai nor Monty may be needed for orchestration, only for inline expressions).
  • Concrete side-by-side: what would "reconcile this account" look like authored/executed under each.
  • Migration cost/blast radius if any existing Rhai rule surface moved to Monty (currently: ledger-core classification rules, gateway_policy if it grows script-driven constraints).
  • WASM delivery requirements, if the process/diagram authoring UI needs to run untrusted LLM-generated logic in a browser.

Related

  • Roadmap: docs/superpowers/plans/2026-07-25-ledgrrr-integration-roadmap.md, subsystem 5.
  • Companion issue: CLIF (ISO/IEC 24707) AST and interpreter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureArchitectural design decisionsresearchResearch spike or investigation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions