GitHub - SMC17/workflow-event-log-zig: Ordered workflow event stream with strict-monotonic gap-free sequence numbers and deterministic replay. Isolation across concurrent workflow IDs. 11 tests. · GitHub
Skip to content

SMC17/workflow-event-log-zig

Repository files navigation

workflow-event-log-zig

License: AGPL-3.0-or-later Zig

Append-only per-workflow event-log substrate in Zig 0.16. Ports Temporal L381 workflow event log + scd-zig backfill duality semantics into a single library.

Status

v0.0.1 — 11/11 tests pass on Zig 0.16. Each WorkflowId owns an ordered stream; appends enforce strict-monotonic gap-free sequence numbers; replays walk the stream in order from a given start point. Two workflows can share the same seq space without collision.

What ships

  • WorkflowId / EventSeq / Timestampu64 / u64 / i64.
  • EventKind enum: workflow_started, activity_scheduled, activity_completed, activity_failed, timer_fired, signal_received, workflow_completed, workflow_failed, custom.
  • WorkflowEvent{ seq, timestamp, kind, bytes }.
  • WorkflowLog with init / deinit / append / read(from, to) / replay(from, state, apply_fn) / eventAt(seq) / streamLen / nextSeq.
  • Idempotency: re-appending the LAST event with the same seq is silently accepted (at-least-once safety; matches Temporal's worker retry contract).

Build

zig build test                  # 11 unit tests

What ships does NOT do (yet)

  • No persistence. Memory-only at v0.0.1. v0.0.2 wires the on-disk layer via shipped tableformat-zig manifest.
  • No replay engine (P178). v0.0.1 ships the iteration primitive; the deterministic-replay engine (wf-rand seed + side-effect dedup + activity-result memoisation) lands in v0.0.2 as a separate module.
  • No snapshot pruning. v0.0.3 ships continuation-events + retention.
  • No multi-writer coordination. Single-writer per stream at v0.0.1; commit-or-retry transaction support comes via integration with shipped cow-branch-zig in v0.0.2.
  • No event-time queries. v0.0.1 reads + replays by seq only; v0.0.2 adds timestamp-bounded reads.

Composes with shipped substrate

  • scd-zig backfill duality. Workflow event log IS the source-of-truth log for backfill ↔ incremental rebuilds; the duality property is enforceable at the log layer.
  • tableformat-zig (v0.0.2 persistence) — manifest-of-events for on-disk durability.
  • cow-branch-zig — workflow branches at LSN boundaries enable history-preserving experimentation.
  • thompson-bandit-zig — Temporal's adaptive retry pattern composes with the Beta posterior for activity retries.

Honest non-claims

  • Pre-1.0 substrate. v0.0.1 stores everything in memory.
  • eventAt does a linear scan within the stream; v0.0.2 swaps to direct indexed access (events are stored in seq order).
  • No single-writer coordination; caller serialises appends.
  • The replay callback is a fn pointer; v0.0.2 wires a more ergonomic visitor pattern.

Credit

Concepts adapted from Temporal workflow event log (castle L381) + scd-zig backfill duality (B2 in the castle inventory). Frontier port by Sean Collins (sean@sunlitmoon.online).

License

AGPL-3.0-or-later. See LICENSE.

About

Ordered workflow event stream with strict-monotonic gap-free sequence numbers and deterministic replay. Isolation across concurrent workflow IDs. 11 tests.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

Contributors