Skip to content

BE-829: Port over initial durable-kernel crate - #9703

Open
thehabbos007 wants to merge 5 commits into
mainfrom
asa/durable-execution
Open

thehabbos007 wants to merge 5 commits into
mainfrom
asa/durable-execution

Conversation

@thehabbos007

Copy link
Copy Markdown
Contributor

🌟 What is the purpose of this PR?

This PR contains the initial durable execution crate used by the integration framework we want for the HASH Graph. The integrations framework needs resiliency, durability and simple operations, and this should tick off those three requirements.

Most of this code has been reviewed by me over several passes, but obviously most of it is LLM generated. The general flow of the code generation progress has been through rigorous testing under a certain set of properties we wish for the system. The src/properties.rs module contains a list of properties we expect the system to pass on at every step of running (at checkpoints in the execution flow). These properties could also form the foundation for a more formal proof using systems a la TLA+.

At a high level, the library is used to orchestrate business logic in an event stream in a durable, resilient fashion. Think of Temporal/Restate/etc. without needing to operate a separate orchestration cluster. Instead this library embeds within programs that need durability, while expecting certain shapes of how the work is laid out.

The README goes over the details more in depth. For the public API, one supplies trait implementations of DomainEvent, Fold, SimpleDomain, and Executor as well as configuring KernelConfig. Two example programs are provided in the directory, see the customer_sync.rs example for a nice introduction.

Apologies for the huge PR, any suggestion for how we can split it up/make it more palatable would be appreciated

🔗 Related links

🚫 Blocked by

🔍 What does this change?

  • Top-level cargo workspace
  • New @local crate durable-kernel under AGPL-3

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • should be documented more in depth, which is not done in this PR, but also not blocking a merge. A lot of documentation has been added, though.

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

🐾 Next steps

🛡 What tests cover this?

  • Unit tests
  • Deterministic simulation testing harness
  • Properties to be used with above
  • A (non-committed/published) TLA+ spec, which I do not have enough confidence in to add to the repo.

Coverage:

Library source DST only All local tests
Total, excluding src/sim 44.1% (1111/2520) 76.8% (1936/2520)
src/domain.rs 68.9% (350/508) 84.3% (428/508)
src/ids.rs 85.1% (40/47) 85.1% (40/47)
src/keyspace.rs 0.0% (0/78) 92.3% (72/78)
src/port.rs 100.0% (2/2) 100.0% (2/2)
src/properties.rs 100.0% (11/11) 100.0% (11/11)
src/registry.rs 57.1% (40/70) 74.3% (52/70)
src/routing.rs 71.4% (10/14) 78.6% (11/14)
src/runtime.rs 0.0% (0/342) 83.9% (287/342)
src/shard_log/command_loop.rs 58.3% (500/858) 66.0% (566/858)
src/shard_log/mod.rs 26.8% (158/590) 79.2% (467/590)
Simulation source DST only All local tests
src/sim/harness.rs 94.2% (518/550) 94.4% (519/550)
src/sim/mod.rs 100.0% (168/168) 100.0% (168/168)

❓ How to test this?

  1. Checkout the branch / view the deployment
  2. Try the example programs
  3. Confirm that they work as documented
  4. Ensure cargo tests pass, as well as the dst harness (cargo test -p durable-kernel --all-features sim::)

📹 Demo

Hard to showcase, not very flashy :(

@thehabbos007
thehabbos007 requested a review from a team as a code owner September 14, 2026 12:17
Copilot AI balanced review requested due to automatic review settings September 14, 2026 12:17
@vercel

vercel Bot commented Sep 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hash Ready Ready Preview Sep 14, 2026 1:06pm UTC
3 Skipped Deployments
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Sep 14, 2026 1:06pm UTC
petrinaut Skipped Skipped Sep 14, 2026 1:06pm UTC
petrinaut-docs Skipped Skipped Sep 14, 2026 1:06pm UTC

Request Review

@cursor

cursor Bot commented Sep 14, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Introduces a new persistence and orchestration layer (SlateDB/opendata) that will underpin integration durability; correctness and recovery behavior matter, though it is not yet wired into production graph paths in this diff.

Overview
Adds a new workspace crate durable-kernel (libs/@local/durable-kernel) for embedded durable execution: applications define events, state folding, and external effects via DomainEvent / Fold / Executor, and the kernel journals per-shard event streams, snapshots, recovery, retries, and effect completion.

The workspace registers the crate and pulls in slatedb, opendata-common, and opendata-log (with a large Cargo.lock refresh). Runtime storage is configured through Kernel / KernelConfig (e.g. file:// paths in the examples).

Ships documentation (README), AGPL-3 license, customer_sync and webhook_relay examples (reset/defer/crash recovery demos), and an internal @rust/durable-kernel package script hook. The library also includes shard journaling, property checks, and a simulation/test harness (not fully shown in the diff excerpt).

Reviewed by Cursor Bugbot for commit 24042a1. Bugbot is set up for automated code reviews on this repo. Configure here.

@thehabbos007
thehabbos007 requested a review from a team September 14, 2026 12:17
@github-actions github-actions Bot added area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/tests New or updated tests type/legal Owned by the @legal team labels Sep 14, 2026
Comment thread libs/@local/durable-kernel/examples/customer_sync.rs Outdated
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.91106% with 738 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.35%. Comparing base (407734a) to head (24042a1).
⚠️ Report is 54 commits behind head on main.

Files with missing lines Patch % Lines
...local/durable-kernel/src/shard_log/command_loop.rs 65.17% 284 Missing and 20 partials ⚠️
libs/@local/durable-kernel/src/shard_log/mod.rs 82.11% 143 Missing and 9 partials ⚠️
libs/@local/durable-kernel/src/domain.rs 90.84% 90 Missing and 11 partials ⚠️
libs/@local/durable-kernel/src/runtime.rs 89.96% 78 Missing and 10 partials ⚠️
libs/@local/durable-kernel/src/sim/harness.rs 91.43% 50 Missing and 6 partials ⚠️
libs/@local/durable-kernel/src/registry.rs 79.80% 18 Missing and 3 partials ⚠️
libs/@local/durable-kernel/src/ids.rs 85.10% 7 Missing ⚠️
libs/@local/durable-kernel/src/keyspace.rs 95.58% 6 Missing ⚠️
libs/@local/durable-kernel/src/routing.rs 89.65% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9703      +/-   ##
==========================================
+ Coverage   65.89%   66.35%   +0.45%     
==========================================
  Files        1887     1899      +12     
  Lines      198443   203334    +4891     
  Branches     8248     8396     +148     
==========================================
+ Hits       130773   134927    +4154     
- Misses      66140    66818     +678     
- Partials     1530     1589      +59     
Flag Coverage Δ
rust.durable-kernel 84.91% <84.91%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread libs/@local/durable-kernel/examples/customer_sync.rs Fixed

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread libs/@local/durable-kernel/src/runtime.rs
@github-advanced-security

Copy link
Copy Markdown
Contributor

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unbounded effect and snapshot behavior, unenforced codec identity, and an unbounded storage flush affect correctness and operability.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds the initial durable-kernel Rust crate for embedded durable execution, including event journaling, recovery, snapshots, effect orchestration, and deterministic simulation testing.

Changes:

  • Implements the public domain, runtime, storage, routing, and compatibility APIs.
  • Adds fault-injection, property-based, recovery, and record-size tests.
  • Adds examples, documentation, licensing, and workspace integration.
File summaries
File Description
Cargo.toml Registers the crate in the workspace.
libs/@local/durable-kernel/.gitignore Excludes local specifications.
libs/@local/durable-kernel/Cargo.toml Defines crate dependencies and features.
libs/@local/durable-kernel/LICENSE.md Adds the AGPL-3 license.
libs/@local/durable-kernel/README.md Documents architecture, usage, and recovery.
libs/@local/durable-kernel/package.json Adds Turborepo package metadata.
libs/@local/durable-kernel/examples/customer_sync.rs Demonstrates durable CRM synchronization.
libs/@local/durable-kernel/examples/webhook_relay.rs Demonstrates durable webhook delivery.
libs/@local/durable-kernel/src/lib.rs Exposes the crate modules.
libs/@local/durable-kernel/src/domain.rs Defines events, folds, executors, and snapshots.
libs/@local/durable-kernel/src/ids.rs Implements content-derived identifiers.
libs/@local/durable-kernel/src/keyspace.rs Defines validated storage paths.
libs/@local/durable-kernel/src/port.rs Defines the low-level domain interface.
libs/@local/durable-kernel/src/properties.rs Catalogs simulation safety properties.
libs/@local/durable-kernel/src/registry.rs Registers durable record declarations.
libs/@local/durable-kernel/src/routing.rs Implements fixed shard routing identifiers.
libs/@local/durable-kernel/src/runtime.rs Runs shards and external effects.
libs/@local/durable-kernel/src/shard_log/mod.rs Implements journal storage and recovery.
libs/@local/durable-kernel/src/shard_log/command_loop.rs Serializes shard commands and state updates.
libs/@local/durable-kernel/src/sim/mod.rs Provides an in-memory fault-injection journal.
libs/@local/durable-kernel/src/sim/harness.rs Generates and verifies deterministic schedules.
libs/@local/durable-kernel/tests/event_size.rs Tests record-size boundaries and recovery.
Review details
  • Files reviewed: 22/23 changed files
  • Comments generated: 6
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread libs/@local/durable-kernel/src/registry.rs
Comment thread libs/@local/durable-kernel/src/shard_log/mod.rs Outdated
Comment thread libs/@local/durable-kernel/src/ids.rs Outdated
Comment thread libs/@local/durable-kernel/src/runtime.rs
Comment thread libs/@local/durable-kernel/src/runtime.rs
Comment thread libs/@local/durable-kernel/Cargo.toml Outdated
@codspeed

codspeed Bot commented Sep 14, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 6 benchmarks measured no execution time

Nothing ran under measurement, usually because the compiler removed the code under test. These results are not comparable, so they count as unchanged.

Preventing compiler optimizations

✅ 98 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚠️ as_constant < 1 ns < 1 ns N/A
⚠️ constant_equal < 1 ns < 1 ns N/A
⚠️ constant_not_equal < 1 ns < 1 ns N/A
⚠️ access < 1 ns < 1 ns N/A
⚠️ runtime_equal < 1 ns < 1 ns N/A
⚠️ runtime_not_equal < 1 ns < 1 ns N/A

Comparing asa/durable-execution (24042a1) with main (67f60d5)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (20547b3) during the generation of this report, so 67f60d5 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit afca874. Configure here.

Comment thread libs/@local/durable-kernel/src/shard_log/command_loop.rs
@vercel
vercel Bot temporarily deployed to Preview – petrinaut-docs September 14, 2026 12:58 Inactive
@vercel
vercel Bot temporarily deployed to Preview – petrinaut September 14, 2026 12:58 Inactive
@vercel
vercel Bot temporarily deployed to Preview – petrinaut September 14, 2026 13:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – petrinaut-docs September 14, 2026 13:05 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team type/legal Owned by the @legal team

Development

Successfully merging this pull request may close these issues.

3 participants