feat(lib): AtomicNode runtime boundary (slice 1) - #1324
Merged
Conversation
Adds `atomic_lib::runtime::AtomicNode`, the thin node surface proposed in
planning/runtime-boundary-decision.md. It wraps `Db` and delegates every
method to code that already existed, so there is no behaviour change:
- `open(NodeConfig)` -> `Db::init_memory/init_redb/init_redb_file/init_redb_opfs`
- `get` -> `get_resource_extended`, `query` -> `Storelike::query`
- `apply_commit(json, IngestPolicy)`:
Hub/Peer -> `sync::engine::ingest_commit` (extracted from
`ingest_commit_json`, which now wraps it and serialises the response),
Replica -> `sync::ws_apply::apply_commit_json` (now returns
`CommitResponse`), LocalCache -> the WASM `applyCommit` path.
- `mutate(ResourceEdit)` -> `Resource::save_locally` / `save_as_genesis`
- `subscribe()` -> `Db::subscribe_events`
- `sync_with_peer` (iroh) -> `sync::peer::sync_drive_with_peer_outcome`
`IngestPolicy::{Hub, Peer, Replica, LocalCache}` mirrors the
`CommitIngestOpts::{hub, peer, replica}` presets of #1274 plus the WASM
no-validation path, so that PR can map onto it 1:1 once merged.
The WASM `ClientDb` is the first consumer: it now holds an `AtomicNode`
and routes `applyCommit` and `query` through it.
Tests: two nodes in one process, `mutate` on one, `apply_commit(Peer)`
on the other, query and `DbEvent` reflect it; LocalCache accepts a
tampered signature while Peer rejects it; mutate without agent errors.
Claude-Session: https://claude.ai/code/session_019asLKBrBWY5ovyeCgtmdSd
joepio
force-pushed
the
feat/atomic-node-slice
branch
from
September 1, 2026 20:07
deb7165 to
2a6bab4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
First slice of the node runtime boundary accepted in
planning/runtime-boundary-decision.md:atomic_lib::runtime::AtomicNode, a thin struct wrappingDbthat gives adapters one surface instead of each wrappingDbthemselves.No behaviour change. Every method delegates to a function that already existed:
AtomicNodeopen(NodeConfig)Db::init_memory/init_redb/init_redb_file/init_redb_opfsget(subject, for_agent)Storelike::get_resource_extendedquery(&Query)Storelike::queryapply_commit(json, IngestPolicy::Hub{..} | Peer)sync::engine::ingest_commit(body extracted fromingest_commit_json, which now wraps it)apply_commit(json, IngestPolicy::Replica)sync::ws_apply::apply_commit_json(now returnsCommitResponse; its one caller ignored the value)apply_commit(json, IngestPolicy::LocalCache)applyCommitbody (parse_json_ad_resource+ no-validationCommitOpts)mutate(ResourceEdit::Update | Genesis)Resource::save_locally/save_as_genesissubscribe()Db::subscribe_events(existingDbEventbroadcast; no new bus)sync_with_peer(irohfeature)sync::peer::sync_drive_with_peer_outcomeIngestPolicy::{Hub, Peer, Replica, LocalCache}is named to match theCommitIngestOpts::{hub, peer, replica}presets in #1274 plus the WASM "fourth policy", so that PR can map onto it 1:1 once merged. Until then the enum carries literalCommitIngestOptsmatching the server handler andapply_peer_commit.First consumer:
wasm/src/lib.rsClientDbnow holds anAtomicNodeand routesapplyCommitandquerythrough it (getResourcedeliberately stays on the rawDb::get_resourcesince it has nofor_agent).Tests
lib/src/runtime/node.rs(--features db-redb):AtomicNodes in one process:mutate(Genesis)on Alice,apply_commit(Peer)of the wire commit on Bob,get+query(parent)reflect it, and Bob'sDbEvent::Changedstream includes the subjectLocalCacheaccepts a commit with a tampered signature,Peerrejects itmutatewithout a default agent errorsVerified:
cargo test -p atomic_lib --features db-redb --lib(429 passed),cargo clippy -p atomic_lib --features db-redb,iroh --lib --tests(no new warnings),cargo check -p atomic-wasm --target wasm32-unknown-unknown,cargo check -p atomic-server,cargo check --manifest-path flutter/rust/Cargo.toml.Not in this slice (documented in
planning/atomic-lib-runtime.md)mutateusessave_locally, not the Hub ingest path.sync_with_peerrequires the global Iroh endpoint (peer::start), same as today.NodeEvent, blob, outbox or transport abstraction; nothing stubbed.Consumers
CommitIngestOpts) —IngestPolicymaps onto itatomic_libFlutter SDK (precompiled binaries + CI) #1241 — server / adapter work that should bindAtomicNodeinstead ofDbhttps://claude.ai/code/session_019asLKBrBWY5ovyeCgtmdSd