Skip to content

feat(orch8): embeddable crate — durable execution as a Rust library#64

Merged
ovasylenko merged 2 commits into
mainfrom
feat/embeddable-crate
Jun 10, 2026
Merged

feat(orch8): embeddable crate — durable execution as a Rust library#64
ovasylenko merged 2 commits into
mainfrom
feat/embeddable-crate

Conversation

@ovasylenko

Copy link
Copy Markdown
Contributor

Summary

The primary strategic bet from docs/FEATURE_OPPORTUNITIES.md (Bet A, 34/40): cargo add orch8 — durable execution as a library, the way SQLite is a database.

let engine = orch8::Engine::builder()
    .storage(orch8::Storage::sqlite("app.db"))   // or sqlite_in_memory() / postgres(url)
    .handler("charge_card", |ctx: orch8::StepContext| async move {
        Ok(serde_json::json!({ "charged": true }))
    })
    .build().await?;
engine.start();                                   // tick loop on the HOST's tokio runtime
  • Facade crate (publish = false for now): curated re-exports + Engine/EngineBuilder/Storage/CreateInstanceOptions/Error — internals stay free to churn behind it. Zero visibility changes were needed in internal crates — the engine was already embeddable.
  • build() mirrors server startup (schema/migrations + stale-instance recovery); shutdown() cancels and drains; tick_once() supports manual-tick embedding for test harnesses.
  • upsert_sequence is create-or-get per (tenant, namespace, name, version) — versions stay immutable so running instances stay pinned.
  • Three examples, all manually verified: quickstart (sqlite + custom handler to completion), kill_resistant (run twice — the surviving instance resumes after process death), embedded_axum (HTTP service sharing the engine).

Tests

6 passing in orch8/tests + doc-test: background-loop completion, manual tick, signal-gated wait + wake, bounded graceful shutdown, CRUD/idempotency semantics. fmt/clippy/doc/check gates clean workspace-wide.

Caveats

shutdown() is terminal (documented); postgres wired but not CI-exercised (no PG harness in repo); list_instances fixed newest-first/100 (minimal pre-1.0 surface).

🤖 Generated with Claude Code

ovasylenko and others added 2 commits June 10, 2026 00:41
New workspace member `orch8`: a curated pre-1.0 facade over
orch8-engine/orch8-storage/orch8-types that embeds the durable workflow
engine in any tokio application.

- Engine::builder(): .storage(sqlite file / sqlite in-memory / postgres),
  .handler(name, async closure) on top of the server's built-in registry,
  .tick_interval(Duration), .tenant(..); build() opens storage, applies
  schema/migrations and runs crash recovery (mirrors server startup).
- engine.start()/shutdown(): background tick loop on the HOST's runtime
  with CancellationToken + graceful drain; engine.tick_once() for
  manual-tick embedding.
- Instance/sequence ops without HTTP: upsert_sequence (idempotent per
  name+version), create_instance (options struct with Default, including
  idempotency-key dedupe), get_instance, send_signal (terminal-state
  rejection + wake), list_instances.
- Examples: quickstart (sqlite file, custom handler, templated 2-step
  run), kill_resistant (run twice — instance survives process exit),
  embedded_axum (shared engine behind HTTP endpoints).
- Integration tests: background-loop completion, manual ticking,
  human-input signal wake, bounded graceful shutdown, facade CRUD
  semantics. Rustdoc with inline quickstart; doc warnings denied.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ovasylenko ovasylenko merged commit 6c6f4bc into main Jun 10, 2026
5 checks passed
@ovasylenko ovasylenko deleted the feat/embeddable-crate branch June 10, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant