ironflowx 0.3.0

Ironflow foundation crates in one dependency.
Documentation

foundation

crates.io docs.rs CI MSRV License: MIT

An experimental MIT-licensed rewrite of the Ironflow engine. Not the shipping product; Ironflow 1.x is under the Ironflow License.

Foundation crates are 0.x with no semver-stability promise.

Purpose

Every part of the engine writes through one commit path. Foundation is that path, proven on its own: the crates any Ironflow X product links to commit one environment's events durably, in order, and read them back.

Foundation's layers: a host calls the engine with a key; the engine checks the key against the control plane, then runs event calls on the ledger, which commits events durably and reads them back; an embedder without keys calls the ledger directly; beneath them are the pure credentials, event rules and core types

What 0.3 is

Run ironflowx serve to open an engine in a data directory and serve it over Connect, gRPC and gRPC-Web. Use the same binary to call the engine. The CLI prints JSON and can describe each operation's inputs, outputs and a runnable example.

  • The first open bootstraps the engine. serve writes the admin key to admin.key, or takes the key you supply.
  • Create keys scoped read, write or admin, read-only unless asked otherwise, with an optional expiry; list them, and revoke one.
  • Emit an event, or a batch of up to 100, with data, metadata, a version and an idempotency key; each records the key that emitted it.
  • Repeat an emit with its idempotency key and get the original event's ID back, with nothing new stored.
  • Read an event by ID, or list events newest first, as soon as any emit returns.
  • Reopen after a crash with nothing acknowledged lost, and recover an admin key from the data directory when the last one is lost.

An app that needs no keys opens a ledger directly.

Architecture

The engine is a library: a host opens it on a data directory, and every call to it carries a key. An embedder that needs no keys opens a ledger in a directory instead. ironflowx serve is the first host we ship. Event rules, credentials and core are pure; only the ledger, the control plane, the engine and the host touch disk, the clock and randomness.

A write is acknowledged once its record is fsynced, and a read sees every write acknowledged before it arrived, whoever made it:

Emit, then read your write

More diagrams (crates, modules and seams, crash recovery) and the details are in docs/architecture.md; the decisions behind them are in docs/decisions.md.

Crate Contents
ironflowx-core IDs, the environment reference, attribution, scopes, addresses, secrets, stored and event-clock time, the clock trait, error kinds
ironflowx-events event rules: what an event is and when an emit is refused
ironflowx-proto the Operations interface and its request and answer types; behind features, the proto, its wire messages and the proto client
ironflowx-cell the ledger: one environment's durable commit log and read store
ironflowx-authz credentials: the key format, and whether a key is valid and may make a call
ironflowx-store the control plane: which tenants, projects, environments and keys exist
ironflowx-operations the engine: admits every call, then runs it on the ledger or the keys
ironflowx every foundation crate, re-exported
ironflowx-doors the HTTP door, unpublished
ironflowx-cli the CLI, unpublished
ironflowx-codegen the generator: the CLI's commands, from the proto, unpublished
ironflowx-bin the ironflowx binary and its host, unpublished

Use it

Run the binary

Choose the archive and its .sha256 file for your platform from the GitHub releases. The Linux archives use static musl for x86-64 and AArch64. The macOS archive is for Apple silicon. Run shasum -a 256 -c <archive>.sha256 beside the archive, then extract it with tar -xzf <archive>.

Start the host in one terminal.

./ironflowx serve

Once it is ready, use the bootstrap key in another terminal.

./ironflowx whoami --url http://127.0.0.1:9310 --key-file .ironflowx/admin.key
./ironflowx describe events emit

Embed the engine

Depend on the facade, with tokio for the runtime the engine and the ledger run on:

[dependencies]
ironflowx = "0.3"
tokio = { version = "1", default-features = false, features = ["rt"] }

examples/embed bootstraps an engine, emits an event, reads it back with a read-only key and sees that key's emit refused. The engine refuses 0.1 ledger directories (D39, changelog).

Call a served engine

Add the client feature to your ironflowx dependency to use ironflowx::proto::Client over HTTP. Use client-tls for HTTPS, with roots from the system's trust store. Both features are off by default, so an embedder can build without the HTTP stack. Engine and Client both implement Operations.

From this checkout, start the host on loopback with a fresh data directory.

cargo run --locked -p ironflowx-bin -- serve --listen 127.0.0.1:8080 --data-dir ./whoami-demo

Once the host is ready, run the example in another terminal.

cargo run --locked -p ironflowx --features client --example whoami -- http://127.0.0.1:8080 ./whoami-demo/admin.key

The example asks whoami and prints the calling key's ID and scopes.