Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
2054584
chore(deps): pull cowprotocol, alloy, redb, reqwest, tracing
brunota20 Jun 1, 2026
f85d3d3
runtime: implement cow-api, chain, local-store host backends
brunota20 Jun 1, 2026
6f669c6
runtime: multi-module supervisor + block/log event loop
brunota20 Jun 1, 2026
8af08bd
docs(adr): add 0001-0007 capturing engine and CoW architecture decisions
brunota20 Jun 2, 2026
3f1dbf8
docs(adr): unwrap hard-wrapped paragraphs to single line each
brunota20 Jun 2, 2026
7e05190
docs(adr): revise CoW design and reorder ADRs (0001-0008)
brunota20 Jun 3, 2026
67a0be7
fix(docs): reviewed ADRs by bleu
brunota20 Jun 3, 2026
e5579a3
fix(docs): revised ADRs and diagrams
brunota20 Jun 8, 2026
ed48319
feat(supervisor): apply ADR-0001/0003/0005/0016 and trap-based module…
brunota20 Jun 9, 2026
1570036
feat(supervisor): add fuel + memory limits per module store (BLEU-818)
brunota20 Jun 9, 2026
32a2198
docs: rename nexum.toml -> module.toml in example, justfile, and READ…
brunota20 Jun 10, 2026
38ac8e3
test: fill host backend test gaps — manifest parsing, cow-api, provid…
brunota20 Jun 10, 2026
fdd64e4
test: E2E supervisor tests + fix wit_import_to_cap to skip type-only …
brunota20 Jun 10, 2026
7131282
style: apply rust-idiomatic rules (em-dashes, #[from] Orderbook, unus…
brunota20 Jun 10, 2026
0679580
review: apply lgahdl feedback on PR #9 (+ rebase PR #8 fixes)
brunota20 Jun 12, 2026
9a97ba9
refactor(manifest): split into types/load/capabilities/error submodules
brunota20 Jun 13, 2026
5ae6368
refactor(main): extract host impls + CLI + event loop + limits
brunota20 Jun 13, 2026
794091a
refactor: move large #[cfg(test)] modules to sibling files
brunota20 Jun 13, 2026
81ee734
chore(deps): patch cowprotocol to bleu/cow-rs main (post-alpha.3)
brunota20 Jun 1, 2026
7161382
Merge PR #15 (feat/cowprotocol-bleu-main-v3) into dev/m2-base
brunota20 Jun 15, 2026
1eca322
Merge PR #12 (docs/adr-bundle) into dev/m2-base
brunota20 Jun 15, 2026
5a42878
chore(deps): bump cowprotocol patch to bleu/cow-rs main (BLEU-822 + B…
brunota20 Jun 15, 2026
7da5636
feat(modules): module.toml for twap-monitor + ethflow-watcher (BLEU-834)
brunota20 Jun 15, 2026
d35f1a0
review: address jeffersonBastos feedback on PR #54 (BLEU-834 manifests)
brunota20 Jun 22, 2026
2b11f91
chore(rust-idiomatic): M2 compliance pass (filtered from M4/M5 compli…
brunota20 Jun 23, 2026
1ee58f5
feat(twap-monitor): workspace + skeleton (BLEU-825)
brunota20 Jun 15, 2026
a5295a6
feat(twap-monitor): index ConditionalOrderCreated → local-store (BLEU…
brunota20 Jun 15, 2026
e89dbef
feat(twap-monitor): eth_call poll path + PollOutcome decoder (BLEU-827)
brunota20 Jun 15, 2026
4d29a22
feat(twap-monitor): build OrderCreation and submit via cow-api (BLEU-…
brunota20 Jun 15, 2026
6df7fde
feat(twap-monitor): wire OrderPostError retry_hint on submit (BLEU-829)
brunota20 Jun 15, 2026
4e08b73
feat(twap-monitor): PollOutcome lifecycle dispatch (BLEU-830)
brunota20 Jun 15, 2026
bdbbcb7
feat(ethflow-watcher): workspace + skeleton (BLEU-831)
brunota20 Jun 15, 2026
f3e6ea7
feat(ethflow-watcher): decode CoWSwapEthFlow OrderPlacement (BLEU-832)
brunota20 Jun 15, 2026
9113e60
feat(ethflow-watcher): build OrderCreation, submit, apply retry_hint …
brunota20 Jun 15, 2026
a49d285
fix(ethflow-watcher): idempotency guard on re-delivered placements
brunota20 Jun 15, 2026
18b861a
feat(shepherd-sdk): workspace + skeleton (BLEU-835)
brunota20 Jun 17, 2026
8428927
feat(shepherd-sdk): extract shared helpers from M2 modules (BLEU-840)
brunota20 Jun 17, 2026
246a712
refactor(modules): consume shepherd-sdk helpers (BLEU-843)
brunota20 Jun 17, 2026
b47897a
feat(shepherd-sdk-test): in-memory host mocks for module tests (BLEU-…
brunota20 Jun 17, 2026
2f2c3a9
docs(shepherd-sdk): rustdoc polish + README + docs/sdk.md (BLEU-844)
brunota20 Jun 17, 2026
41b557f
feat(examples): price-alert Chainlink oracle reader (BLEU-846)
brunota20 Jun 17, 2026
c93dc50
feat(examples): balance-tracker example module (BLEU-847)
brunota20 Jun 17, 2026
dd3bc71
docs(tutorial): first-module walkthrough (BLEU-848)
brunota20 Jun 17, 2026
a97e6d8
chore: rust-idiomatic compliance pass across M3 + M2 modules
brunota20 Jun 17, 2026
7ba857e
refactor(price-alert): port to Host trait + MockHost tests (BLEU-851)
brunota20 Jun 17, 2026
c823bdc
feat(examples): stop-loss module + tutorial as guided tour (BLEU-852)
brunota20 Jun 17, 2026
859ddc5
refactor(twap-monitor): port to Host trait + MockHost tests (BLEU-854)
brunota20 Jun 17, 2026
04e97b0
refactor(ethflow-watcher): port to Host trait + MockHost tests (BLEU-…
brunota20 Jun 17, 2026
95beeb0
chore(qa): workspace cargo fmt sweep + em-dash cleanup (COW-1063)
brunota20 Jun 17, 2026
1a6f6aa
docs(qa): COW-1063 sign-off matrix + architectural findings
brunota20 Jun 17, 2026
f047051
docs: resolve QA findings - ADR-0009 + doc 05 status callouts
brunota20 Jun 17, 2026
08c486e
ci: build all production module .wasm targets via matrix (COW-1066)
brunota20 Jun 17, 2026
a11068d
ci: gate cargo doc warnings (-D warnings) + fix 3 broken intra-doc li…
brunota20 Jun 17, 2026
9bd9d37
docs(shepherd-sdk): add 6 doctests covering Host trait + helper API (…
brunota20 Jun 17, 2026
3734e03
test(nexum-engine): supervisor integration tests for 5 production mod…
brunota20 Jun 17, 2026
76fbb15
docs(m2): testnet runbook + engine.m2.toml + `just run-m2` (validated…
brunota20 Jun 17, 2026
56e25a7
fix(event_loop): do not bail boot when block / log stream Vec is empty
brunota20 Jun 18, 2026
a77ff32
docs(m3): testnet runbook + engine.m3.toml + `just run-m3` (validated…
brunota20 Jun 18, 2026
8a823dc
docs(m3): testnet edge-case validation report - 5 scenarios run, all …
brunota20 Jun 18, 2026
b7e4f4d
fix(supervisor): mark module alive=false when init returns Err (COW-1…
brunota20 Jun 18, 2026
89cb145
review: address jeffersonBastos M3 epic feedback (PR #55)
brunota20 Jun 22, 2026
70db5db
chore(rust-idiomatic): M3 compliance pass (filtered from M4/M5 compli…
brunota20 Jun 23, 2026
cf81d36
docs(deployment): operator runbook (BLEU-836) (#17)
brunota20 Jun 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,46 @@ jobs:
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- run: cargo test --workspace --all-features --no-fail-fast

docs:
name: rustdoc
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: "-D warnings"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master 2026-03-27
with:
toolchain: nightly
targets: wasm32-wasip2
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- run: cargo doc --workspace --no-deps

build-module:
name: build example module
name: build ${{ matrix.module }} (wasm32-wasip2)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
module:
- example
- twap-monitor
- ethflow-watcher
- price-alert
- balance-tracker
- stop-loss
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master 2026-03-27
with:
toolchain: nightly
targets: wasm32-wasip2
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- run: cargo build -p example --target wasm32-wasip2 --release
- run: cargo build -p ${{ matrix.module }} --target wasm32-wasip2 --release
- name: report wasm size
run: |
artifact_name=$(echo "${{ matrix.module }}" | tr '-' '_')
wasm_path="target/wasm32-wasip2/release/${artifact_name}.wasm"
if [ -f "$wasm_path" ]; then
size=$(wc -c < "$wasm_path")
echo "${{ matrix.module }} .wasm size: ${size} bytes"
fi
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ Thumbs.db
# Environment
.env
.env.*

# Agent skills / AI tooling — installed locally, never committed.
.agents/
.claude/
skills-lock.json

# Engine runtime state (default state_dir from engine.toml).
data/
21 changes: 21 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[workspace]
members = [
"crates/nexum-engine",
"crates/shepherd-sdk",
"crates/shepherd-sdk-test",
"modules/ethflow-watcher",
"modules/example",
"modules/examples/balance-tracker",
"modules/examples/price-alert",
"modules/examples/stop-loss",
"modules/twap-monitor",
]
resolver = "2"

Expand All @@ -10,6 +17,20 @@ edition = "2024"
license = "AGPL-3.0"
repository = "https://github.com/nullisLabs/shepherd"

# `cowprotocol` v1.0.0-alpha.3 (the crates.io release the engine
# depends on) was cut from `cowdao-grants/cow-rs` PR #5 at commit
# `1742ffa`. `bleu/cow-rs` main has diverged since with: the
# `composable::Proof` width fix (relevant to the TWAP poll path),
# `OrderCreation` zero-from-address fast-fail, the `order_book` /
# `composable` submodule splits, `OrderPostErrorKind` + `retry_hint()`
# (BLEU-822, the protocol-level retry contract M2 modules dispatch
# on), and `OrderBookApi::with_base_url(chain, base_url)` for barn /
# staging routing (BLEU-823). Patching to that commit picks the lot
# up without waiting for an alpha.4 publish. Drop once
# `cowprotocol >= 1.0.0-alpha.4` ships.
[patch.crates-io]
cowprotocol = { git = "https://github.com/bleu/cow-rs", rev = "57f5f553ab28c9fff54089daf2d39b4282f3e4dd" }

[profile.dev]
panic = "abort"

Expand Down
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,71 @@ just build

# Run the runtime against the example module
just run

# Run unit tests
just test
```

Without Nix, you need: Rust (edition 2024, see `rust-toolchain.toml` if present), the `wasm32-wasip2` target, and `wasm-tools`.

## Running

### Single-module (development)

```sh
nexum-engine <path-to-component.wasm> [<module.toml>]
```

The `module.toml` is optional; without it the engine prints a deprecation warning and loads the module with empty capabilities and config (0.1 fallback).

### Multi-module (production)

```sh
nexum-engine --engine-config engine.toml
```

`engine.toml` declares RPC endpoints, the state directory, and a `[[modules]]` list:

```toml
[engine]
state_dir = "/var/lib/shepherd"
log_level = "info"

[chains.1]
rpc_url = "wss://mainnet.infura.io/ws/v3/..."

[[modules]]
path = "modules/twap-monitor/twap-monitor.wasm"
manifest = "modules/twap-monitor/module.toml"

[[modules]]
path = "modules/ethflow-watcher/ethflow-watcher.wasm"
```

### Module manifest (`module.toml`)

```toml
[module]
name = "twap-monitor"
version = "0.1.0"

[capabilities]
required = ["chain", "local-store", "cow-api"]
optional = ["http"]

[capabilities.http]
allow = ["api.cow.fi"]

[[subscription]]
kind = "log"
chain_id = 1
address = "0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74" # ComposableCoW (canonical CREATE2 address, same on every supported chain)

[[subscription]]
kind = "block"
chain_id = 1
```

## Documentation

The `docs/` directory contains the design corpus:
Expand Down
48 changes: 47 additions & 1 deletion crates/nexum-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,56 @@ license.workspace = true
repository.workspace = true

[dependencies]
# WASM Component Model runtime.
wasmtime = { version = "45", features = ["component-model"] }
wasmtime-wasi = "45"

# Async + error plumbing.
anyhow = "1"
thiserror = "2"
tokio = { version = "1", features = ["full"] }
getrandom = "0.4"

# Manifest parsing.
serde = { version = "1", features = ["derive"] }
toml = "1"
serde_json = "1"

# Observability. `tracing` replaces the prior `eprintln!` debug log
# so the engine can drop into a structured log pipeline in production.
tracing = "0.1"
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "env-filter", "ansi"] }

# `cow-api` backend. cowprotocol pulls `OrderBookApi`, `OrderCreation`,
# `OrderUid`, the orderbook base URL table per `Chain`, and the typed
# error surface the host re-projects into `HostError`. Pinned to the
# crates.io release Shepherd is shipping against.
cowprotocol = "1.0.0-alpha"
# REST passthrough for `cow_api::request`. cowprotocol pulls reqwest
# transitively for its own client; we depend on it directly so the
# import is explicit and survives any future cowprotocol feature
# rearrangement.
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }

# `chain` backend. Each configured chain owns a `DynProvider` built
# from a `WsConnect`/`Http` transport so the host's `request` /
# `request-batch` impls can hand a raw `(method, params)` pair to
# alloy's JSON-RPC layer without reimplementing the codec.
alloy-provider = { version = "1.5", default-features = false, features = ["ws", "ipc", "pubsub", "reqwest"] }
alloy-rpc-client = { version = "1.5", default-features = false }
alloy-rpc-types-eth = { version = "1.5", default-features = false, features = ["std"] }
alloy-transport = { version = "1.5", default-features = false }
alloy-transport-ws = { version = "1.5", default-features = false }
alloy-primitives = { version = "1.5", default-features = false, features = ["std", "serde"] }
futures = "0.3"

# `local-store` backend. Per-module namespacing is enforced
# host-side via a `[len:u8][module_name][raw_key]` prefix.
redb = "2"

# Misc.
getrandom = "0.4"
url = "2"

[dev-dependencies]
tempfile = "3"
wiremock = "0.6"
16 changes: 16 additions & 0 deletions crates/nexum-engine/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! WIT bindings generated by `wasmtime::component::bindgen!`.
//!
//! Both `wit/nexum-host` and `wit/shepherd-cow` packages are listed
//! explicitly so wit-parser can resolve the cross-package reference
//! natively - no vendored `deps/` tree needed. The world name is fully
//! qualified.
//!
//! Every `Host` trait impl in `crate::host::impls` consumes types
//! generated here.

wasmtime::component::bindgen!({
path: ["../../wit/nexum-host", "../../wit/shepherd-cow"],
world: "shepherd:cow/shepherd",
imports: { default: async },
exports: { default: async },
});
46 changes: 46 additions & 0 deletions crates/nexum-engine/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//! Manual CLI parser. Kept hand-rolled (instead of pulling clap) because
//! the surface is small and unlikely to grow in 0.2.

use std::path::PathBuf;

/// Parsed CLI surface.
///
/// `nexum-engine [<wasm-path> [<manifest-path>]] [--engine-config <path>]`
///
/// Positional `<wasm-path>` is a backwards-compat shortcut that
/// synthesises a one-module engine config. Production deployments pass
/// `--engine-config` and declare modules in TOML.
#[derive(Debug, Default)]
pub struct Cli {
pub wasm: Option<PathBuf>,
pub manifest: Option<PathBuf>,
pub engine_config: Option<PathBuf>,
}

impl Cli {
pub fn parse() -> Self {
let mut args = std::env::args().skip(1);
let mut cli = Self::default();
let mut positional = Vec::new();
while let Some(arg) = args.next() {
match arg.as_str() {
"--engine-config" => cli.engine_config = args.next().map(PathBuf::from),
"-h" | "--help" => {
eprintln!(
"usage: nexum-engine [<wasm-path> [<manifest-path>]] \
[--engine-config <path>]"
);
std::process::exit(0);
}
_ => positional.push(arg),
}
}
if let Some(p) = positional.first() {
cli.wasm = Some(PathBuf::from(p));
}
if let Some(p) = positional.get(1) {
cli.manifest = Some(PathBuf::from(p));
}
cli
}
}
Loading