fireweed-dsl 0.37.0

Fireweed's data-plane DSL (API-008): schema and program documents, and the checker that resolves a program against a schema.
Documentation

Fireweed

Fireweed is the data plane for Snorri and Cayce: queues and tables for short-lived, scale-out workflow data, changed through a small typed DSL and run as plain SQL.

A consumer describes its data in a schema document: queues, tables, typed fields, indexes and named reads. It changes that data with programs: lists of typed statements (insert, claim, settle, renew, update, delete, assert, select, read, pause, resume) that run as one transaction. Both are YAML or JSON.

An executor creates real tables and indexes from the schema and runs each statement as one SQL statement over them. The database chooses rows by index, orders writers with row locks and decides with its clock when work is due. The executor keeps nothing in the process between calls.

  • ADR-027: the decision and the owner's rulings.
  • API-008: the DSL reference and the PostgreSQL executor's rules.

Crates

Crate What it is
fireweed-dsl Schema and program documents, the checker that resolves a program against a schema, and the Executor trait every backend implements.
fireweed-dsl-postgres The PostgreSQL 18 executor: PgExecutor implements Executor over a pool of connections; the same operations are functions over one connection.
fireweed-umf Space schemas as UMF core 0.10 documents with the fireweed.space extension (API-009).
fireweed-dsl-local The Turso executor: one database per space on local disk, with the log optionally shipped to S3 (feature s3); Local implements Executor.

All four are on crates.io:

[dependencies]
fireweed-dsl = "0.37"
fireweed-dsl-postgres = "0.37"
fireweed-umf = "0.37"   # only for UMF schema documents
fireweed-dsl-local = "0.37"   # only for the in-process Turso executor

Application code depends on fireweed-dsl alone and takes an Arc<dyn fireweed_dsl::Executor>; only the binary that starts it names a backend:

use std::sync::Arc;
use fireweed_dsl::Executor;

let exec: Arc<dyn Executor> = match backend {
    "postgres" => Arc::new(fireweed_dsl_postgres::PgExecutor::new(url.parse()?)),
    _ => Arc::new(fireweed_dsl_local::Local::open(local_config)?),
};

Releases are cut by pushing a tag vX.Y.Z from main; see CHANGELOG.md and .github/workflows/release.yml.

Example

A schema:

version: 1
queues:
  work:
    max_attempts: 5
    fields:
      campaign: {type: text, index: true}

A program that enqueues two items, and one that claims them:

request_id: enqueue-1
issued_at: 2026-11-16T09:30:00Z
statements:
  - insert: {into: work, rows: [{key: a, campaign: c1}, {key: b, campaign: c1}]}
request_id: claim-1
issued_at: 2026-11-16T09:30:05Z
statements:
  - claim: {from: work, where: {eq: [campaign, c1]}, limit: 10, lease: 30s, worker: w1}

The claim returns each item's id and lease token. A later program settles them:

request_id: settle-1
issued_at: 2026-11-16T09:30:09Z
statements:
  - settle: {queue: work, outcome: complete, items: [{id: 1, token: "<token>"}]}

From Rust:

use fireweed_dsl::Executor;

let engine = fireweed_dsl_postgres::PgExecutor::new(url.parse()?);
let schema: fireweed_dsl::Schema = fireweed_dsl::from_yaml(SCHEMA)?;
engine.apply_schema("tenant", "space", &schema, None).await?;
let program: fireweed_dsl::Program = fireweed_dsl::from_yaml(ENQUEUE)?;
let response = engine.execute("tenant", "space", &program).await?;

Development

Prerequisites: rustup (the repository selects Rust 1.99.0) and PostgreSQL 18. docker compose up -d postgres starts one on port 55432.

cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings
FIREWEED_PG_TEST_URL=postgres://fireweed:fireweed@127.0.0.1:55432/fireweed cargo test --workspace
cargo deny check

Without FIREWEED_PG_TEST_URL the executor's tests skip.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option. Contributions are issues only; see CONTRIBUTING.md.