weave-sdk · node
Source declarations, signatures and documentation for node.
Source: sigil/weave/libs/weave-sdk/src/node.rs. SHA-256: d652dc23c98005b9112d183f2d4bbcd7de5d510fafcc9d0898cef257a6aa19ea.
This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.
node::WeaveNode
A Weave node — the unified entry point for all Weave operations.
Agents, CLIs, and applications interact with the Weave network through this single type. It manages identity, storage, networking, and replication.
Example
use weave_sdk::prelude::*;
#[tokio::main]
async fn main() -> weave_sdk::error::Result<()> {
let node = WeaveNode::builder()
.namespace("l1fe")
.identifier("my-agent")
.storage_dir("/tmp/weave-test")
.build()
.await?;
println!("Agent DID: {}", node.identity().did());
Ok(())
}pub struct WeaveNode {
}Source line: 38.
node::StrandPayloadCodec
Application-provided transform for one Strand's stored payloads.
Replication operates on the underlying Strand and therefore always moves
the encoded bytes. Applications such as Loom can use this hook to encrypt
private records before they reach disk or the network, while callers of
[WeaveNode::append] and [WeaveNode::read_block] continue to work with
plaintext. A codec is scoped to an exact Strand name and is never inferred
or silently inherited by another Strand.
#[derive(Clone)]
pub struct StrandPayloadCodec {
}Source line: 62.
node::StrandPayloadCodec::new
Construct an exact encode/decode pair.
pub fn new<E, D>(encode: E, decode: D) -> Self
where
E: Fn(&[u8]) -> Result<Vec<u8>> + Send + Sync + 'static,
D: Fn(&[u8]) -> Result<Vec<u8>> + Send + Sync + 'static,;Source line: 69.
node::StrandStore
Storage for append-only strands.
pub struct StrandStore {
}Source line: 169.
node::LensStore
Storage for Lens B-tree databases.
pub struct LensStore {
}Source line: 175.
node::LocusStore
Storage for Locus distributed filesystems.
pub struct LocusStore {
}Source line: 181.
node::ForumStore
Storage for Forum tuple spaces.
pub struct ForumStore {
}Source line: 187.
node::GnosisStore
Storage for Gnosis knowledge graphs.
pub struct GnosisStore {
}Source line: 193.
node::BasisStore
Storage for Basis vector stores.
pub struct BasisStore {
}Source line: 199.
node::NexusStore
Storage for Nexus multi-writer views.
pub struct NexusStore {
}Source line: 205.
node::StrandStore::create
Create a new strand.
pub async fn create(
&mut self,
name: &str,
key_pair: weave_crypto::KeyPair,
) -> Result<&strand::Strand>;Source line: 347.
node::StrandStore::create_remote
Create a read-only strand handle keyed on a remote writer's public
key. The strand has no local data yet; replication fills in blocks
over time. Used by WeaveNode::open_remote_strand to bootstrap a
fresh receiver against an existing remote strand whose writer
keypair the receiver does not (and should not) have.
pub async fn create_remote(
&mut self,
name: &str,
source_pubkey: [u8; 32],
) -> Result<&strand::Strand>;Source line: 379.
node::StrandStore::get
Get a strand by name.
pub fn get(&self, name: &str) -> Result<Option<&strand::Strand>>;Source line: 409.
node::StrandStore::get_mut
Get a mutable reference to a strand.
pub fn get_mut(&mut self, name: &str) -> Result<Option<&mut strand::Strand>>;Source line: 420.
node::StrandStore::open_for_replication
Open a fresh Strand instance backed by the same on-disk data as the
named strand. The returned Arc<RwLock<Strand>> can be safely shared
with the replication layer which needs both read and write access.
pub async fn open_for_replication(
&self,
name: &str,
) -> Result<Arc<tokio::sync::RwLock<strand::Strand>>>;Source line: 487.
node::StrandStore::list
List all strand names.
pub fn list(&self) -> Vec<&str>;Source line: 495.
node::LensStore::open
Open or create a Lens database.
pub async fn open(&mut self, name: &str) -> Result<&lens::Lens>;Source line: 581.
node::LensStore::open_remote
Create a read-only Lens database keyed on a remote source's
pubkey. The underlying Strand is opened with [strand::StrandConfig::with_public_key]
so signature verification on incoming blocks accepts only the
source's writes; replication populates the lens over time.
Errors if a database with this name already exists locally.
pub async fn open_remote(
&mut self,
name: &str,
source_pubkey: [u8; 32],
) -> Result<&lens::Lens>;Source line: 606.
node::LensStore::get
Get a Lens database by name.
pub fn get(&self, name: &str) -> Option<&lens::Lens>;Source line: 642.
node::LensStore::list
List all database names.
pub fn list(&self) -> Vec<&str>;Source line: 647.
node::LocusStore::open
Open or create a Locus drive.
pub async fn open(&mut self, name: &str) -> Result<&locus::Locus>;Source line: 692.
node::LocusStore::get_mut
Get a mutable Locus drive.
pub async fn get_mut(&mut self, name: &str) -> Option<&mut locus::Locus>;Source line: 766.
node::LocusStore::drives_get
Get an immutable Locus drive by name. Mirrors the get accessor on
other stores; useful for callers that need to read the drive's
pubkeys without mutating it (e.g. loom identity share).
pub fn drives_get(&self, name: &str) -> Option<&locus::Locus>;Source line: 773.
node::LocusStore::open_remote
Create a read-only Locus drive keyed on a remote source's three
strand pubkeys: (meta_pk, blob_meta_pk, blob_data_pk). Each
underlying strand is opened with [strand::StrandConfig::with_public_key]
so signature verification accepts only the source's writes.
Replication populates the drive over time.
pub async fn open_remote(
&mut self,
name: &str,
meta_pk: [u8; 32],
blob_meta_pk: [u8; 32],
blob_data_pk: [u8; 32],
) -> Result<&locus::Locus>;Source line: 782.
node::LocusStore::list
List all drive names.
pub fn list(&self) -> Vec<&str>;Source line: 854.
node::ForumStore::open
Open or create a Forum tuple space backed by a strand.
pub async fn open(&mut self, name: &str) -> Result<&forum::Forum>;Source line: 870.
node::ForumStore::get
Get a Forum by name.
pub fn get(&self, name: &str) -> Option<&forum::Forum>;Source line: 885.
node::ForumStore::list
List all forum names.
pub fn list(&self) -> Vec<&str>;Source line: 890.
node::GnosisStore::open
Open or create a Gnosis knowledge graph backed by a strand.
pub async fn open(&mut self, name: &str) -> Result<&gnosis::Gnosis>;Source line: 904.
node::GnosisStore::get
Get a Gnosis graph by name.
pub fn get(&self, name: &str) -> Option<&gnosis::Gnosis>;Source line: 919.
node::GnosisStore::list
List all graph names.
pub fn list(&self) -> Vec<&str>;Source line: 924.
node::BasisStore::open
Open or create a Basis vector store backed by two strands.
pub async fn open(&mut self, name: &str) -> Result<&basis::Basis>;Source line: 938.
node::BasisStore::get
Get a Basis store by name.
pub fn get(&self, name: &str) -> Option<&basis::Basis>;Source line: 962.
node::BasisStore::list
List all store names.
pub fn list(&self) -> Vec<&str>;Source line: 967.
node::NexusStore::create
Create a new Nexus view. Fail-closed if a durable view already exists.
pub async fn create(
&mut self,
name: &str,
ordering: Box<dyn nexus::OrderingStrategy>,
) -> Result<&nexus::Nexus>;Source line: 1138.
node::NexusStore::open
Open a durable Nexus view into the process map without attaching inputs.
pub async fn open(
&mut self,
name: &str,
ordering: Box<dyn nexus::OrderingStrategy>,
) -> Result<&nexus::Nexus>;Source line: 1160.
node::NexusStore::get
Get a Nexus view by name.
pub fn get(&self, name: &str) -> Option<&nexus::Nexus>;Source line: 1182.
node::NexusStore::list
List all nexus view names.
pub fn list(&self) -> Vec<&str>;Source line: 1187.
node::WeaveNode::builder
Create a builder for constructing a WeaveNode.
pub fn builder() -> WeaveNodeBuilder;Source line: 1194.
node::WeaveNode::identity
The node's identity.
pub fn identity(&self) -> &WeaveIdentity;Source line: 1199.
node::WeaveNode::config
The node's configuration.
pub fn config(&self) -> &WeaveConfig;Source line: 1204.
node::WeaveNode::strands
Access the strand store (append-only logs).
pub fn strands(&self) -> &Arc<RwLock<StrandStore>>;Source line: 1209.
node::WeaveNode::lens
Access the Lens store (B-tree databases).
pub fn lens(&self) -> &Arc<RwLock<LensStore>>;Source line: 1214.
node::WeaveNode::locus
Access the Locus store (distributed filesystems).
pub fn locus(&self) -> &Arc<RwLock<LocusStore>>;Source line: 1219.
node::WeaveNode::replication
Access the replication manager.
pub fn replication(&self) -> &Arc<ReplicationManager>;Source line: 1224.
node::WeaveNode::set_private_replication_controls
Atomically set or clear the private replication preflight and exact post-identity admission policy. Incomplete private controls are rejected so transport cannot fall back to a weaker partial profile.
pub async fn set_private_replication_controls(
&self,
proof: Option<ReplicationAccessProof>,
policy: Option<ReplicationAdmissionPolicy>,
) -> Result<()>;Source line: 1231.
node::WeaveNode::network
Access the network manager.
pub fn network(&self) -> &Arc<RwLock<NetworkManager>>;Source line: 1240.
node::WeaveNode::start_network
pub async fn start_network(&self) -> Result<()>;Source line: 1263.
node::WeaveNode::stop_network
Stop the network layer.
pub async fn stop_network(&self) -> Result<()>;Source line: 1273.
node::WeaveNode::start_auto_replication
Start auto-replication: announce all data stores and discover peers.
This announces every strand, lens, and locus this node owns on the DHT, then begins a continuous discovery-and-replicate loop.
pub async fn start_auto_replication(&self) -> Result<()>;Source line: 1284.
node::WeaveNode::announce_strand
Announce a single strand on the DHT for peer discovery.
Opens a separate Strand instance backed by the same on-disk data. Locally owned Strands retain their writer signer so a public provider lease can carry the mandatory writer delegation. Remote replicas remain read-only and cannot advertise themselves as public writers.
pub async fn announce_strand(&self, name: &str) -> Result<()>;Source line: 1315.
node::WeaveNode::replicate_locus
Replicate a locus drive with discovered peers.
Locus drives are backed by multiple strands (metadata + blob data). This announces all underlying strands on the DHT.
pub async fn replicate_locus(&self, name: &str) -> Result<()>;Source line: 1327.
node::WeaveNode::replicate_lens
Replicate a lens database with discovered peers.
Lens databases are backed by a single strand. This announces the underlying strand on the DHT.
pub async fn replicate_lens(&self, name: &str) -> Result<()>;Source line: 1372.
node::WeaveNode::replication_addr
Get the address the replication listener is bound to.
pub async fn replication_addr(&self) -> Option<std::net::SocketAddr>;Source line: 1396.
node::WeaveNode::dht_bootstrap_addr
Get the DHT bootstrap multiaddr peers can pass to LOOM_BOOTSTRAP.
pub async fn dht_bootstrap_addr(&self) -> Option<String>;Source line: 1402.
node::WeaveNode::peer_count
Get the number of connected peers.
pub async fn peer_count(&self) -> usize;Source line: 1408.
node::WeaveNode::discover_peers
Trigger an immediate discovery sweep.
pub async fn discover_peers(&self) -> Result<usize>;Source line: 1414.
node::WeaveNode::create_strand
Create a new strand and return its name.
pub async fn create_strand(&self, name: &str) -> Result<()>;Source line: 1420.
node::WeaveNode::create_strand_with_keypair
Create a Strand with an application-scoped signing key.
This is intended for unlinkable, per-resource writer identities. The
key is still held only by the local writer; readers open the resource
with [Self::open_remote_strand] and its public key.
pub async fn create_strand_with_keypair(
&self,
name: &str,
key_pair: weave_crypto::KeyPair,
) -> Result<()>;Source line: 1430.
node::WeaveNode::set_strand_payload_codec
Install or replace the payload codec for one exact Strand name.
pub async fn set_strand_payload_codec(&self, name: &str, codec: StrandPayloadCodec);Source line: 1442.
node::WeaveNode::clear_strand_payload_codec
Remove the payload codec for one exact Strand name.
pub async fn clear_strand_payload_codec(&self, name: &str);Source line: 1450.
node::WeaveNode::set_strand_history_ceiling
Apply or clear a signed higher-layer history ceiling for one exact
Strand. A ceiling of N permits only sequence numbers below N across
local reads, appends, and replication.
pub async fn set_strand_history_ceiling(&self, name: &str, ceiling: Option<u64>) -> Result<()>;Source line: 1457.
node::WeaveNode::set_strand_history_checkpoint
Apply a complete signed terminal checkpoint to one exact Strand.
pub async fn set_strand_history_checkpoint(
&self,
name: &str,
terminal_length: u64,
terminal_hash: Option<[u8; 32]>,
) -> Result<()>;Source line: 1467.
node::WeaveNode::strand_terminal_checkpoint
Verify a complete local Strand and return the terminal block count and terminal block-link hash used by signed retirement checkpoints.
pub async fn strand_terminal_checkpoint(&self, name: &str) -> Result<(u64, Option<[u8; 32]>)>;Source line: 1484.
node::WeaveNode::open_remote_strand
Open a read-only strand handle keyed on a remote writer's public key. Use this on a fresh receiver to bootstrap against an existing remote strand whose writer keypair you do not (and should not) have. Replication fills in blocks over time once the swarm is up.
Distinct from [Self::create_strand] in three ways:
- No keypair is bound — the strand is read-only.
- The strand's writer pubkey is the remote source's, so signature verification on incoming blocks accepts only the source's writes.
- The discovery key derives from the source's pubkey, so DHT lookups land on the source's announcements.
pub async fn open_remote_strand(&self, name: &str, source_pubkey: [u8; 32]) -> Result<()>;Source line: 1505.
node::WeaveNode::append
Append data to a named strand.
pub async fn append(&self, strand_name: &str, data: &[u8]) -> Result<u64>;Source line: 1612.
node::WeaveNode::read_block
Read a block from a named strand.
pub async fn read_block(&self, strand_name: &str, seq: u64) -> Result<Option<Vec<u8>>>;Source line: 1636.
node::WeaveNode::read_block_raw
Read the exact stored/replicated bytes without applying a payload codec. This is intentionally explicit and is primarily useful for custody verification and adversarial tests.
pub async fn read_block_raw(&self, strand_name: &str, seq: u64) -> Result<Option<Vec<u8>>>;Source line: 1664.
node::WeaveNode::strand_len
Return the number of blocks currently available in a named strand.
pub async fn strand_len(&self, strand_name: &str) -> Result<u64>;Source line: 1677.
node::WeaveNode::open_lens
Open a Lens database.
pub async fn open_lens(&self, name: &str) -> Result<()>;Source line: 1686.
node::WeaveNode::open_remote_lens
Open a read-only Lens keyed on a remote source's pubkey. Used on a
fresh receiver that wants to replicate an existing remote lens
(e.g. for loom clone, where the receiver pulls the source's
loom.refs and loom.index lenses without having the writer
keypair). Replication fills the lens over time.
pub async fn open_remote_lens(&self, name: &str, source_pubkey: [u8; 32]) -> Result<()>;Source line: 1698.
node::WeaveNode::lens_put
Put a key-value pair into a Lens database.
pub async fn lens_put(&self, db: &str, key: &[u8], value: &[u8]) -> Result<()>;Source line: 1710.
node::WeaveNode::lens_get
Get a value from a Lens database.
pub async fn lens_get(&self, db: &str, key: &[u8]) -> Result<Option<Vec<u8>>>;Source line: 1722.
node::WeaveNode::lens_delete
Delete a key from a Lens database.
pub async fn lens_delete(&self, db: &str, key: &[u8]) -> Result<()>;Source line: 1733.
node::WeaveNode::open_locus
Open a Locus drive (distributed filesystem).
pub async fn open_locus(&self, name: &str) -> Result<()>;Source line: 1745.
node::WeaveNode::open_remote_locus
Open a read-only Locus drive keyed on a remote source's three
strand pubkeys: (metadata, blob_meta, blob_data). Used on a
fresh receiver to bootstrap against an existing remote drive
(e.g. for loom clone's loom.blobs drive). Replication
populates each underlying strand once the swarm is up.
pub async fn open_remote_locus(
&self,
name: &str,
meta_pk: [u8; 32],
blob_meta_pk: [u8; 32],
blob_data_pk: [u8; 32],
) -> Result<()>;Source line: 1757.
node::WeaveNode::locus_write_file
Write a file to a Locus drive.
pub async fn locus_write_file(&self, drive: &str, path: &str, data: &[u8]) -> Result<()>;Source line: 1779.
node::WeaveNode::locus_read_file
Read a file from a Locus drive.
pub async fn locus_read_file(&self, drive: &str, path: &str) -> Result<Vec<u8>>;Source line: 1793.
node::WeaveNode::locus_mkdir
Create a directory in a Locus drive.
pub async fn locus_mkdir(&self, drive: &str, path: &str) -> Result<()>;Source line: 1806.
node::WeaveNode::locus_readdir
List directory contents in a Locus drive.
pub async fn locus_readdir(&self, drive: &str, path: &str) -> Result<Vec<String>>;Source line: 1820.
node::WeaveNode::locus_remove
Remove a file or directory from a Locus drive.
pub async fn locus_remove(&self, drive: &str, path: &str) -> Result<()>;Source line: 1833.
node::WeaveNode::forums
Access the Forum store (tuple spaces).
pub fn forums(&self) -> &Arc<RwLock<ForumStore>>;Source line: 1849.
node::WeaveNode::open_forum
Open a Forum tuple space.
pub async fn open_forum(&self, name: &str) -> Result<()>;Source line: 1854.
node::WeaveNode::forum_write
Write a tuple to a Forum.
pub async fn forum_write(&self, name: &str, tuple: Vec<u8>) -> Result<u64>;Source line: 1862.
node::WeaveNode::forum_read
Read a tuple from a Forum by pattern.
pub async fn forum_read(&self, name: &str, pattern: &[u8]) -> Result<Option<Vec<u8>>>;Source line: 1873.
node::WeaveNode::forum_take
Take a tuple from a Forum by pattern.
pub async fn forum_take(&self, name: &str, pattern: &[u8]) -> Result<Option<Vec<u8>>>;Source line: 1884.
node::WeaveNode::gnosis
Access the Gnosis store (knowledge graphs).
pub fn gnosis(&self) -> &Arc<RwLock<GnosisStore>>;Source line: 1897.
node::WeaveNode::open_gnosis
Open a Gnosis knowledge graph.
pub async fn open_gnosis(&self, name: &str) -> Result<()>;Source line: 1902.
node::WeaveNode::gnosis_add
Add a triple to a Gnosis graph.
pub async fn gnosis_add(
&self,
name: &str,
subject: &str,
predicate: &str,
object: &str,
) -> Result<()>;Source line: 1910.
node::WeaveNode::gnosis_query
Query a Gnosis graph.
pub async fn gnosis_query(
&self,
name: &str,
subject: Option<String>,
predicate: Option<String>,
object: Option<String>,
) -> Result<Vec<gnosis::Triple>>;Source line: 1927.
node::WeaveNode::gnosis_neighbors
Get neighbors of a node in a Gnosis graph.
pub async fn gnosis_neighbors(
&self,
name: &str,
node_id: &str,
) -> Result<Vec<(String, String)>>;Source line: 1949.
node::WeaveNode::basis
Access the Basis store (vector databases).
pub fn basis(&self) -> &Arc<RwLock<BasisStore>>;Source line: 1966.
node::WeaveNode::open_basis
Open a Basis vector store.
pub async fn open_basis(&self, name: &str) -> Result<()>;Source line: 1971.
node::WeaveNode::basis_add
Add a vector to a Basis store.
pub async fn basis_add(&self, name: &str, id: Uuid, vector: &[f32]) -> Result<()>;Source line: 1979.
node::WeaveNode::basis_search
Search for nearest neighbors in a Basis store.
pub async fn basis_search(
&self,
name: &str,
query: &[f32],
k: usize,
) -> Result<Vec<(Uuid, f32)>>;Source line: 1990.
node::WeaveNode::basis_remove
Remove a vector from a Basis store.
pub async fn basis_remove(&self, name: &str, id: Uuid) -> Result<()>;Source line: 2006.
node::WeaveNode::nexus
Access the Nexus store (multi-writer views).
pub fn nexus(&self) -> &Arc<RwLock<NexusStore>>;Source line: 2019.
node::WeaveNode::create_nexus
Create a Nexus view.
pub async fn create_nexus(&self, name: &str) -> Result<()>;Source line: 2024.
node::WeaveNode::nexus_add_input
Add an input strand to a Nexus view by loading it from disk.
pub async fn nexus_add_input(&self, nexus_name: &str, strand_name: &str) -> Result<()>;Source line: 2097.
node::WeaveNode::nexus_view
Generate and return the current Nexus view.
pub async fn nexus_view(
&self,
nexus_name: &str,
start: Option<usize>,
limit: Option<usize>,
) -> Result<Vec<nexus::ViewEntry>>;Source line: 2103.
node::WeaveNodeBuilder
Builder for constructing a WeaveNode.
#[derive(Default)]
pub struct WeaveNodeBuilder {
}Source line: 2123.
node::WeaveNodeBuilder::namespace
Set the OAS namespace (e.g., "l1fe").
pub fn namespace(mut self, ns: impl Into<String>) -> Self;Source line: 2133.
node::WeaveNodeBuilder::identifier
Set the agent identifier (e.g., "data-analyzer").
pub fn identifier(mut self, id: impl Into<String>) -> Self;Source line: 2139.
node::WeaveNodeBuilder::storage_dir
Set the storage directory.
pub fn storage_dir(mut self, dir: impl Into<PathBuf>) -> Self;Source line: 2145.
node::WeaveNodeBuilder::bootstrap
Set DHT bootstrap peers.
pub fn bootstrap(mut self, peers: &[&str]) -> Self;Source line: 2151.
node::WeaveNodeBuilder::port
Set the DHT listen port.
pub fn port(mut self, port: u16) -> Self;Source line: 2157.
node::WeaveNodeBuilder::with_identity
Provide a pre-existing identity instead of generating one.
pub fn with_identity(mut self, identity: WeaveIdentity) -> Self;Source line: 2163.
node::WeaveNodeBuilder::mdns
Enable/disable mDNS discovery.
pub fn mdns(mut self, enabled: bool) -> Self;Source line: 2169.
node::WeaveNodeBuilder::with_network
Configure the network layer (DHT port, replication port, etc.).
pub fn with_network(mut self, config: NetworkConfig) -> Self;Source line: 2175.
node::WeaveNodeBuilder::replication_port
Set the replication listener port.
pub fn replication_port(mut self, port: u16) -> Self;Source line: 2181.
node::WeaveNodeBuilder::build
Build the WeaveNode. Generates or loads identity, initializes storage.
pub async fn build(self) -> Result<WeaveNode>;Source line: 2190.