Skip to content

flavio/ferricel

Repository files navigation

Docs

Ferricel compiles CEL (Common Expression Language) expressions into WebAssembly modules.

The produced .wasm files can then be executed in any Wasm runtime.

![NOTE] Development Transparency: Ferricel has been developed with the aid of a code assistant (Claude Sonnet/Opus 4.6).

The code assistant was used for implementation, testing, and documentation. All development has been conducted under direct human supervision, with code review and validation performed throughout.

Components

Ferricel provides the following components:

  • ferricel: a CLI tool for compiling CEL expressions to WebAssembly or running compiled .wasm modules
  • ferricel-core: a pure Rust library that powers ferricel. You can use it to embed a compiler or runtime in your Rust program

Features

Ferricel targets full compliance with the CEL specification and the cel-go extension libraries. Conformance is validated against the official CEL conformance test suite.

Ferricel also supports the Kubernetes CEL validation libraries.

For more details about Ferricel compliance, please refer to the docs.

Ferricel also supports extending CEL programs with custom functions implemented by the WebAssembly host. See Host Extensions for details.

Usage (CLI)

Let's take this small CEL program:

account.balance >= transaction.withdrawal
    || (account.overdraftProtection
    && account.overdraftLimit >= transaction.withdrawal  - account.balance)

We'll compile it to a WebAssembly module using the ferricel CLI:

ferricel build --expression-file validate-balance.cel -o validate-balance.wasm

Now we can run it with the ferricel run command. We need to provide the data to be evaluated, which we call "bindings".

Let's create a bindings file named validate-balance.bindings.json with the following contents:

{
  "account": {
    "balance": 500,
    "overdraftProtection": true,
    "overdraftLimit": 1000
  },
  "transaction": {
    "withdrawal": 700
  }
}

We can now run the compiled Wasm module with the bindings:

ferricel run \
    --bindings-file validate-balance.bindings.json \
    validate-balance.wasm

The evaluation produces the following output:

true

Alternatively, we can pass bindings as an inline JSON string:

ferricel run \
    --bindings-json '{"account":{"balance":500,"overdraftProtection":true,"overdraftLimit":0},"transaction":{"withdrawal":700}}' \
    validate-balance.wasm

In this case, the program runs with overdraftLimit set to 0, which causes the validation to return a different result:

false

Usage (Rust)

You can use ferricel-core to compile CEL expressions and execute them from Rust.

See the ferricel-core documentation for examples and API details.

Installation

Download pre-built binaries from GitHub Releases.

Or install from source using Cargo:

cargo install ferricel

Name

The name "Ferricel" is a pun combining "ferrous" (relating to iron and Rust, the programming language) and "CEL" (Common Expression Language).

About

A CEL to WebAssembly compiler

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors