Repository navigation
Tags
Tags
subduction_core: add a conformance suite for MinimizedTreeStore (#401) The store contract describes behaviour over time and across nodes, which the compiler cannot check. A store that breaks it compiles and mostly works, then hides commits that are in storage. Teams writing their own networked store need a way to check theirs. `minimized_tree_store::conformance`, behind a new `conformance` feature, mirrors `storage::conformance`: - Checks every store must pass, through one handle. - Checks of rules 1 to 3 through two handles to one backing store, which accept only a `SharedMinimizedTreeStore`. - `check_ops`, which runs generated operation sequences (`Op` implements `Arbitrary`) against both handles and compares every result with a model of storage: a hit always equals storage, a removed tree never hits, and a populate is kept only if no write happened since its miss. Trees include fragments and parent edges, so a store that loses them in serialization fails. The feature pulls in no executor, so the suite builds on a store's own target, including Wasm. `tests/minimized_tree_store_conformance.rs` runs it against every stock store, including a bounded shared store small enough that most sequences sweep. The shared store's unit tests that the suite now covers are removed; its reclamation tests stay, since the suite cannot force a store to forget a marker.
Extract out a minimized tree store (#397) * subduction_core: benchmark minimized-tree hot paths The next commits move the node's minimized-tree LRU behind a trait. Its reads are the per-commit hot path, so the change has to stay as fast as the concrete map. Land the benchmark first so it can be run on both sides of that change. It uses only the builder's default store and node methods that exist before and after: - `hot_heads` / `hot_commits`: reads of a resident tree. - `write_resident`: one write into a resident tree of fixed size. - `cold_heads`: a read that hydrates from storage. - `contended_heads`: concurrent reads of one tree from many tasks. * collections: owned checkouts for BoundedShardedMap A minimized tree store needs to hand out a resident tree that the node can read and minimize in place. Its trait method returns a future, so the handle cannot borrow the map: a borrowed guard tied to `&self` cannot be `Send` for every lifetime the future form requires. Hold each shard in an `Arc` so it can be locked with an owned guard, and add: - `checkout`, which returns a `Checkout` holding the shard lock and derefs to the value, recording an access like the other readers. - `insert_if_absent`, which keeps a resident value rather than replacing it. `ShardedMap::shard_at` stops being `const`, since it now indexes an `Arc` array. The existing closure-based helpers stay until their callers move over. * subduction_core: add the MinimizedTreeStore trait Serving sync needs each tree's minimized form, which takes a full storage read and a minimization pass to build. The node keeps built trees in a process-local LRU. That is right for one node, but a deployment where several nodes share storage (for example on Cloudflare) needs the trees in a store those nodes share, or each node goes stale on the others' writes. Define where built trees live as a trait, so a deployment can choose: - `get` checks out a resident tree or reports a miss with the tree's current generation. - `populate` keeps a tree rebuilt after a miss, unless the generation moved since: a compare-and-set that stops a slow reader from hiding a concurrent write. - `merge` and `remove` keep a resident tree in step with storage, and always change the generation. `Generation` is not required to be `Clone`, so the node can carry each one only from its miss to the matching `populate`. A store used by one node can make it `()`. Two stores ship here: `MemoryMinimizedTreeStore`, the existing bounded LRU behind the trait, and `NoopMinimizedTreeStore`, which keeps nothing. The module docs state the contract, including the rules a store shared between nodes must enforce itself. Nothing uses the trait yet; the next commit makes it a node effect. * subduction_core: make the minimized tree store a node effect The node kept built trees in a concrete `BoundedShardedMap`, fixed by a `SHARDS` const generic on `Subduction`, `SyncHandler`, `StorageTasks` and the builder. Make the store the node's sixth effect instead, so a deployment can keep trees per process, in a store shared between nodes, or not at all. Effects and construction: - `HasMinimizedTreeStore` names the store; `Effects` requires it, and `SendableEffects` requires its error and generation to be `Send`. - `Config` gains a sixth slot, defaulting to `MemoryMinimizedTreeStore`. - The builder's `.minimized_tree_store(store)` replaces `.sedimentrees()` and `.max_resident_trees()`; bound the default with `MemoryMinimizedTreeStore::with_capacity`. - `SHARDS` moves to `MemoryMinimizedTreeStore<SHARDS>` and leaves every node type. - `Subduction::minimized_tree_store()` returns the store, replacing `resident_sedimentree_count()`. Coordination (`storage/state`, `cache.rs`, `ingest.rs`, `handler/sync.rs`): - Each tree has a store lock. Populating after a miss (revalidate, then `populate`) and maintenance after a write (`merge` or `remove`, then settle) both hold it, so they never interleave. Hits take no lock. - A miss carries the store's generation to `populate`. If the store reports `Stale`, another node wrote since the miss: the read is served but not stored, since retrying could rescan storage without bound under remote writes. - A populate that overlaps a local write retries instead of adopting the resident tree. - A store error never fails a node operation. A failed `get` reads storage, a failed `populate` is ignored, and a failed `merge` or `remove` marks the tree bypassed: reads skip the store for it until a later `remove` succeeds. - The sync handler looks the tree up on each attempt and serves either the resident tree or a fresh scan. Behaviour changes: `sedimentree_ids` returns an empty list on a storage error instead of falling back to the resident set, which may not cover storage. Every call site moves over (CLI, Wasm, tokio, websocket, ingest), and `store_failures.rs` covers the error paths with a store whose gene 10BC8 rations and failures tests can control. * Remove automatic poisoned cache handling * Fix regression * Update docs
Split out effect config (#381) * subduction_core: hand-write Debug for IoError and ListenError `#[derive(Debug)]` bounds every type parameter, so both errors demanded `Debug` on `Async`, `Store`, `Conn`, and `WireMsg`, though they only hold those types' error values, which are already `Debug`. That leaked a spurious `Store: Debug` bound into `SyncHandler`'s `Handler` impl and everything generic over it. The manual impls need no bounds and print the same output. * subduction_core: bundle node effects into one effects type `Subduction` took a type parameter per side effect (storage, policy, signer, timer, spawner), and `SyncHandler` repeated most of them. Every node and handler type was long, the two could drift apart, and each new effect would have added a parameter everywhere. Replace them with one effects type `E`, named through a capability trait per effect in the new `effects` module: - `HasStorage`, `HasStoragePolicy`, `HasConnectionPolicy`, `HasSigner`, `HasSpawner`, and `HasTimer` name each component as an associated type. Storage and policy errors are associated types too, so callers write `E::StorageError` instead of a projection. - `Effects<Async>` is all of them (blanket-implemented). `SendableEffects` and `LocalEffects` add the per-form thread-safety bounds, so generic code states one bound instead of one per slot. - `effects::config::Config<Store, Policy, Sign, Timer, Sp>` is the stock phantom implementation. `Subduction::new` and the builder infer it; `Subduction::with_effects` takes a custom effects type. Each consumer bounds `E` only by what it uses: `SyncHandler` needs storage, storage policy, and spawner, and no longer takes a signer or timer. Along the way: - Split `StorageTasks` out of `NodeTasks`, so building a powerbox needs only storage and policy. - Drop `ListenerFuture`'s phantom component parameters. - Drop the `Send + Sync` timer requirement on `Local`. - Require `ConnectionDisallowed: Send` on `Sendable` nodes, so spawned `add_connection` calls are `Send`. - Migrate all workspace call sites to local `Config` aliases (`CliEffects`, `WasmEffects`, `Cfg`), and describe the design in `HACKING.md`. Breaking: `Subduction`, `SyncHandler`, `ListenerFuture`, and `NodeTasks` change their generic parameters, `SyncHandler`'s `Metric` has no default, and `NodeTasks::storage_powerbox` moves to `StorageTasks`.
Bump hickory, rustix, tokio and quinn-udp for RustSec advisories (#396) `cargo audit` fails on the current lockfile. Each bump is a patch release within the existing semver range, so no manifest changes: - hickory-net, hickory-proto, hickory-resolver 0.26.1 -> 0.26.3 - quinn-udp 0.5.15 -> 0.5.16 (RUSTSEC-2026-0538) - rustix 1.1.4 -> 1.1.6 - tokio 1.53.1 -> 1.53.3
subduction_core: don't forward requests to peers who are denied access Problem: in Subduction::load_and_watch when we request sync for a document we don't take account of whether the peer we are requesting the document from has access to the document. This has the effect of announcing document IDs we care about to peers who are denied access. Solution: use `StoragePolicy::authorize_fetch` to check whether a peer has access to a document before requesting it from them.
subduction_tokio: expose load-and-watch streams on node handles Add the admission-checked load_and_watch adapter and reuse the core stream, coordination, and task registry. Local replay and writes work offline; ongoing loading follows current/future connections and reconnects even for cached data. There is no storage-only method or boolean mode in the erased core adapter. Document recovery, cancellation, and lifecycle admission. Exercise local replay, independent stream cancellation, shutdown termination, and closed admission.
PreviousNext