Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grain_core-0.1.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grain_core-0.1.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

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

Hashes for grain_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2aa610aea43ca89014a6933d760a4b098ad32f881b1726aab72044ff95a0d8f3
MD5 4d7d12dad18af486e0061aadd5d26942
BLAKE2b-256 20776905834afd6b7994d6a0b451a0460ebd5cd7c000b112d5803caebf7fbaeb

See more details on using hashes here.

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

Hashes for grain_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bf0a79717c370c4a71b203fdc2410f4490f24de80435ad8a40e6dcba1e5e190
MD5 1f8eb92f1570a615bb5f4b4aaa8fb137
BLAKE2b-256 d7810bc91ce0bd1c9f1b110a254ad563963160660cf10c88bff9e4c49246b5a9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page