Grain's storage-agnostic workflow engine — a pure advance() reducer and a RunStore port.
Project description
grain-core
Grain's storage-agnostic workflow engine: a pure advance() reducer and a RunStore port, with a
conformance kit that any store can prove itself against.
Zero dependencies beyond grain-contracts (the
vocabulary), so a service can drive Grain workflows without installing Grain's CLI. The reducer is
pure — no clock, no filesystem, no store — and every side effect comes back as data for the driver
to apply. That is how one engine serves grain-kit's filesystem runs and Diwa's Postgres missions.
from grain_contracts.workflow import Run
from grain_core import advance, RunStore
from grain_core.kernel import StepStarted
transition = advance(run, StepStarted(step_id=run.cursor), now="2026-07-14T00:00:00Z")
store.save(transition.run, expected_version=version) # driver applies the result
for effect in transition.effects: # ...and any effects, as data
...
Implementing a store
RunStore is a Protocol with four methods — load, save(run, *, expected_version),
discard_artifact, list_runs. Prove your implementation against the shared kit:
from grain_core.conformance import run_conformance
def test_my_store_conforms():
run_conformance(lambda: MyRunStore(...)) # a fresh, empty store per call
The kit pins the version contract the port leaves to implementers: version tokens are opaque;
save(expected_version=None) creates (and conflicts if the run already exists);
save(expected_version=token) updates iff the token is current, else raises
ConcurrentModification; list_runs is newest-first by created.
Source and issues · MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grain_core-0.1.0.tar.gz.
File metadata
- Download URL: grain_core-0.1.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2aa610aea43ca89014a6933d760a4b098ad32f881b1726aab72044ff95a0d8f3
|
|
| MD5 |
4d7d12dad18af486e0061aadd5d26942
|
|
| BLAKE2b-256 |
20776905834afd6b7994d6a0b451a0460ebd5cd7c000b112d5803caebf7fbaeb
|
File details
Details for the file grain_core-0.1.0-py3-none-any.whl.
File metadata
- Download URL: grain_core-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bf0a79717c370c4a71b203fdc2410f4490f24de80435ad8a40e6dcba1e5e190
|
|
| MD5 |
1f8eb92f1570a615bb5f4b4aaa8fb137
|
|
| BLAKE2b-256 |
d7810bc91ce0bd1c9f1b110a254ad563963160660cf10c88bff9e4c49246b5a9
|