Skip to content

Commit 287cde6

Browse files
committed
build(workspace): scaffold 6-crate workspace + cid/core2 patches
Establishes the Phase 1 Cargo workspace for the Benten Engine: benten-core, benten-graph, benten-ivm, benten-caps, benten-eval, benten-engine, plus bindings/napi. This commit lands the workspace manifest, lockfile, clippy configuration, and the three stub crates (benten-ivm / benten-caps / benten-eval) whose real implementations come online in subsequent phases. benten-core / benten-graph / benten-engine / bindings-napi follow in their own slices. Workspace dependencies are pinned to the 2026-04-14 validated versions (ENGINE-SPEC §14.5): blake3 1.8, serde_ipld_dagcbor 0.6, multihash 0.19, redb 4, napi 3, wasmtime 35, criterion 0.8, proptest 1.11, papaya 0.2, mimalloc 0.1, thiserror 2, tracing 0.1. Includes two [patch.crates-io] entries resolving the core2 yank (bbqsrc/core2 archived 2026-04-14): - cid -> BentenAlignmentInc/rust-cid @ e11cf45 (our fork; upstream PR multiformats/rust-cid#185, tracking #184) - core2 -> technocreatives/core2 @ 545e84b (transitional; removed when multiformats/rust-multihash#407 merges and releases) Clippy config adopts workspace-wide warn-on-all + pedantic + nursery defaults with a Benten-specific doc-valid-idents allowlist (CIDv1, MVCC, IVM, UCAN, DID, etc.) so Benten terms don't need backticks in every doc line.
1 parent 366e6d8 commit 287cde6

9 files changed

Lines changed: 1598 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 1340 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
[workspace]
2+
resolver = "3"
3+
4+
members = [
5+
"crates/benten-core", # Node, Edge, Value, content hashing, version chains
6+
"crates/benten-graph", # Storage (KVBackend trait + redb impl), indexes, MVCC
7+
"crates/benten-ivm", # IVM (Algorithm B) — subscribes to graph changes (STUB)
8+
"crates/benten-caps", # Capability types + pre-write hook + NoAuthBackend default (STUB)
9+
"crates/benten-eval", # 12 primitives, evaluator, transaction primitive, SANDBOX host (STUB)
10+
"crates/benten-engine", # Orchestrator: public API
11+
"bindings/napi", # napi-rs v3 bindings (native + WASM)
12+
]
13+
14+
[workspace.package]
15+
version = "0.1.0"
16+
edition = "2024"
17+
rust-version = "1.85"
18+
license = "MIT OR Apache-2.0"
19+
authors = ["BentenAI"]
20+
repository = "https://github.com/BentenAI/benten-engine"
21+
22+
[workspace.lints.rust]
23+
unsafe_op_in_unsafe_fn = "deny"
24+
unused_must_use = "warn"
25+
26+
[workspace.lints.clippy]
27+
# Start strict and relax only where justified.
28+
all = { level = "warn", priority = -1 }
29+
pedantic = { level = "warn", priority = -1 }
30+
todo = "warn"
31+
dbg_macro = "warn"
32+
print_stdout = "warn"
33+
print_stderr = "warn"
34+
unwrap_used = "warn"
35+
expect_used = "warn"
36+
37+
# Relaxed defaults:
38+
module_name_repetitions = "allow"
39+
must_use_candidate = "allow"
40+
missing_errors_doc = "allow"
41+
42+
[workspace.dependencies]
43+
# Core engine
44+
blake3 = { version = "1.8", default-features = false }
45+
serde = { version = "1", default-features = false, features = ["derive", "alloc"] }
46+
serde_bytes = { version = "0.11", default-features = false, features = ["alloc"] }
47+
serde_json = "1"
48+
serde_ipld_dagcbor = "0.6.4"
49+
multihash = "0.19"
50+
redb = "4"
51+
52+
# Concurrency & allocator
53+
papaya = "0.2"
54+
mimalloc = { version = "0.1", default-features = false }
55+
56+
# Error handling & observability
57+
thiserror = "2"
58+
tracing = "0.1"
59+
60+
# WASM sandbox (SANDBOX primitive)
61+
wasmtime = "35"
62+
63+
# Dev
64+
criterion = { version = "0.8", features = ["html_reports"] }
65+
proptest = "1.11"
66+
tempfile = "3"
67+
68+
# Bindings (napi-rs v3 handles native + WASM)
69+
napi = { version = "3", default-features = false }
70+
napi-derive = "3"
71+
72+
# Phase 3 (sync/identity) — reserved versions for future use:
73+
# iroh = "0.97"
74+
# loro = "1"
75+
# ed25519-dalek = "2"
76+
# uhlc = "0.2"
77+
78+
# Dependency workaround: the `core2` 0.4.0 crate was archived upstream on
79+
# 2026-04-14 ("No longer supported. Use core directly.") and yanked from
80+
# crates.io. It is pulled in transitively via two chains:
81+
# 1. cid -> ipld-core -> serde_ipld_dagcbor (direct in our hash path)
82+
# 2. multihash + multihash-derive (via cid's feature wiring)
83+
#
84+
# We resolve chain 1 by patching `cid` to our fork, which replaces the core2
85+
# dependency with `no_std_io2` (same approach as multiformats/rust-multihash#407,
86+
# pending upstream review in multiformats/rust-cid).
87+
#
88+
# We resolve chain 2 temporarily by patching `core2` to the technocreatives
89+
# community fork at a pinned commit. This entry can be removed once
90+
# multiformats/rust-multihash#407 merges and a release is cut, which will
91+
# propagate a core2-free multihash through to the ipld-core / serde_ipld_dagcbor
92+
# chain as well.
93+
#
94+
# See SPIKE-phase-1-stack-RESULTS.md "Surprises" #1 and "Next Actions" #1.
95+
[patch.crates-io]
96+
cid = { git = "https://github.com/BentenAlignmentInc/rust-cid", rev = "e11cf45399c951597725a9bc3ed49c805f7aa640" }
97+
core2 = { git = "https://github.com/technocreatives/core2", rev = "545e84bcb0f235b12e21351e0c69767958efe2a7" }
98+
99+
[profile.release]
100+
lto = "thin"
101+
codegen-units = 1
102+
opt-level = 3
103+
strip = "symbols"
104+
105+
[profile.bench]
106+
lto = "thin"
107+
codegen-units = 1
108+
109+
[profile.dev]
110+
opt-level = 0
111+
debug = 2

clippy.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Clippy configuration for Benten Engine.
2+
# See https://rust-lang.github.io/rust-clippy/master/ for lint list.
3+
4+
avoid-breaking-exported-api = true
5+
cognitive-complexity-threshold = 30
6+
type-complexity-threshold = 250
7+
too-many-arguments-threshold = 7
8+
9+
# Benten-specific terms that must not trigger the `doc_markdown` lint. These are
10+
# concrete standards/identifiers, not generic jargon — wrapping them in backticks
11+
# everywhere they appear in docs is noise.
12+
doc-valid-idents = [
13+
"CIDv1", "CID", "IPLD", "DAG-CBOR", "BLAKE3", "UCAN", "DID", "MVCC",
14+
"HLC", "IVM", "WASM", "P2P", "ADDL", "OAuth", "PostgreSQL", "AGE",
15+
"WebSocket", "SSE", "TypeScript", "JavaScript", "Node.js",
16+
# Standard clippy defaults (see clippy docs) — re-listed because specifying
17+
# this key replaces the default list entirely.
18+
"KiB", "MiB", "GiB", "TiB", "PiB", "EiB",
19+
"DirectX", "ECMAScript", "GPLv2", "GPLv3",
20+
"GitHub", "GitLab", "IPv4", "IPv6", "ClojureScript", "CoffeeScript",
21+
"JavaScript", "PureScript", "TypeScript",
22+
"NaN", "NaNs",
23+
"OAuth", "GraphQL",
24+
"OCaml",
25+
"OpenDNS", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap",
26+
"OpenTelemetry", "WebGL", "WebGL2", "WebGPU",
27+
"TensorFlow",
28+
"TrueType",
29+
"iOS", "macOS", "FreeBSD",
30+
"TeX", "LaTeX", "BibTeX", "BibLaTeX",
31+
"MinGW",
32+
"CamelCase",
33+
]

crates/benten-caps/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "benten-caps"
3+
version.workspace = true
4+
edition.workspace = true
5+
rust-version.workspace = true
6+
license.workspace = true
7+
authors.workspace = true
8+
repository.workspace = true
9+
description = "Capability policy hook + NoAuthBackend for the Benten graph engine (Phase 1 stub)."
10+
11+
[lints]
12+
workspace = true
13+
14+
[dependencies]
15+
benten-core = { path = "../benten-core" }

crates/benten-caps/src/lib.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! # benten-caps — Capability policy (STUB)
2+
//!
3+
//! Phase 1 stub. Full implementation lands in Phase 1 proper.
4+
//!
5+
//! Responsibilities (Phase 1 proper):
6+
//!
7+
//! - Define the `CapabilityPolicy` pre-write hook trait.
8+
//! - Provide the `NoAuthBackend` default (allows all writes — embedded/local-only
9+
//! users pay zero cost for capability enforcement).
10+
//! - Expose capability types (grants, scopes, attenuation) as plain data that
11+
//! `benten-engine` wires into the write path.
12+
//! - UCAN backend stub (full implementation deferred to `benten-id` in Phase 3).
13+
//!
14+
//! See [`docs/ENGINE-SPEC.md`](../../../docs/ENGINE-SPEC.md) Section 9.
15+
//!
16+
//! The spike uses this crate only to validate that the 6-crate workspace
17+
//! compiles cleanly and that `benten-engine` can depend on it.
18+
19+
#![forbid(unsafe_code)]
20+
21+
/// Marker for the current stub phase. Removed when real capability policy lands.
22+
pub const STUB_MARKER: &str = "benten-caps::stub";

crates/benten-eval/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "benten-eval"
3+
version.workspace = true
4+
edition.workspace = true
5+
rust-version.workspace = true
6+
license.workspace = true
7+
authors.workspace = true
8+
repository.workspace = true
9+
description = "Operation primitives and evaluator for the Benten graph engine (Phase 1 stub)."
10+
11+
[lints]
12+
workspace = true
13+
14+
[dependencies]
15+
benten-core = { path = "../benten-core" }

crates/benten-eval/src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! # benten-eval — Operation primitives + evaluator (STUB)
2+
//!
3+
//! Phase 1 stub. Full implementation lands in Phase 1 proper.
4+
//!
5+
//! Responsibilities (Phase 1 proper):
6+
//!
7+
//! - The 12 operation primitives (READ, WRITE, TRANSFORM, BRANCH, ITERATE,
8+
//! WAIT, CALL, RESPOND, EMIT, SANDBOX, SUBSCRIBE, STREAM).
9+
//! - Iterative evaluator with an explicit execution stack (no recursion).
10+
//! - Registration-time structural validation (14 invariants).
11+
//! - Transaction primitive (begin/commit/rollback).
12+
//! - TRANSFORM expression evaluator (arithmetic, built-ins, object construction).
13+
//! - `wasmtime`-based SANDBOX host with fuel metering.
14+
//!
15+
//! See [`docs/ENGINE-SPEC.md`](../../../docs/ENGINE-SPEC.md) Sections 3–5 and 10.
16+
//!
17+
//! The spike uses this crate only to validate that the 6-crate workspace
18+
//! compiles cleanly and that `benten-engine` can depend on it.
19+
20+
#![forbid(unsafe_code)]
21+
22+
/// Marker for the current stub phase. Removed when the evaluator lands.
23+
pub const STUB_MARKER: &str = "benten-eval::stub";

crates/benten-ivm/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "benten-ivm"
3+
version.workspace = true
4+
edition.workspace = true
5+
rust-version.workspace = true
6+
license.workspace = true
7+
authors.workspace = true
8+
repository.workspace = true
9+
description = "Incremental View Maintenance for the Benten graph engine (Phase 1 stub)."
10+
11+
[lints]
12+
workspace = true
13+
14+
[dependencies]
15+
benten-core = { path = "../benten-core" }

crates/benten-ivm/src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//! # benten-ivm — Incremental View Maintenance (STUB)
2+
//!
3+
//! Phase 1 stub. Full implementation lands in Phase 1 proper.
4+
//!
5+
//! Responsibilities (Phase 1 proper):
6+
//!
7+
//! - Subscribe to the graph change notification stream exposed by `benten-graph`
8+
//! via the SUBSCRIBE primitive.
9+
//! - Per-view strategy selection (Algorithm B is the default; Algorithm A
10+
//! is used as a fallback for simple views).
11+
//! - Pre-compute materialized views (capability grants, event handler dispatch,
12+
//! content listings) so reads are O(1).
13+
//!
14+
//! The evaluator is deliberately ignorant of IVM: IVM is a composable subscriber
15+
//! to graph events, not an engine-internal feature. See
16+
//! [`docs/ENGINE-SPEC.md`](../../../docs/ENGINE-SPEC.md) Section 8.
17+
//!
18+
//! The spike uses this crate only to validate that the 6-crate workspace
19+
//! compiles cleanly and that `benten-engine` can depend on it.
20+
21+
#![forbid(unsafe_code)]
22+
23+
/// Marker for the current stub phase. Removed when real IVM lands.
24+
pub const STUB_MARKER: &str = "benten-ivm::stub";

0 commit comments

Comments
 (0)