cli

Command-line interface for Radroots
git clone https://radroots.dev/git/cli.git
Log | Files | Refs | README | LICENSE

commit 520e2820b8f629a2d2ccda229066a071279dfab9
parent 30d95fa82ca329c543d3f08b92d827bf4d6ade3b
Author: triesap <tyson@radroots.org>
Date:   Sun, 12 Jul 2026 00:50:32 +0000

crate-surface: adopt final SDK crate names

- move CLI dependencies to replica_store, replica_schema, and trade_sp1_host
- update runtime store and command code for replica_store naming
- refresh CLI tests and lockfile for the final package surface
- validate with cargo check, cargo test, and removed-name scans

Diffstat:
MCargo.lock | 127++++++++++++++++++++++++++++++++++++-------------------------------------------
MCargo.toml | 8++++----
Msrc/ops/exec/basket.rs | 33++++++++++++++++++---------------
Msrc/ops/exec/core.rs | 10+++++-----
Msrc/ops/exec/farm.rs | 2+-
Msrc/ops/exec/listing.rs | 2+-
Msrc/ops/exec/market.rs | 10+++++-----
Msrc/ops/exec/runtime.rs | 4++--
Msrc/ops/exec/trade.rs | 2+-
Msrc/out/terminal/renderers/basket.rs | 4++--
Msrc/out/terminal/renderers/market.rs | 2+-
Msrc/out/terminal/renderers/workspace.rs | 2+-
Msrc/runtime/config.rs | 4++--
Msrc/runtime/find.rs | 12++++++------
Msrc/runtime/listing.rs | 14+++++++-------
Msrc/runtime/mod.rs | 2+-
Msrc/runtime/order.rs | 22+++++++++++-----------
Msrc/runtime/provider.rs | 2+-
Msrc/runtime/sdk.rs | 10+++++-----
Msrc/runtime/store.rs | 66+++++++++++++++++++++++++++++++++---------------------------------
Msrc/runtime/sync.rs | 40++++++++++++++++++++--------------------
Msrc/runtime/validation_receipt.rs | 6+++---
Msrc/view/runtime.rs | 16++++++++--------
Mtests/support/mod.rs | 16++++++++--------
Mtests/target_cli.rs | 30+++++++++++++++---------------
25 files changed, 219 insertions(+), 227 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -3623,7 +3623,6 @@ dependencies = [ "radroots_event", "radroots_event_codec", "radroots_identity", - "radroots_runtime_store", "radroots_log", "radroots_mesh", "radroots_nostr", @@ -3632,16 +3631,17 @@ dependencies = [ "radroots_nostr_signer", "radroots_outbox", "radroots_protected_store", - "radroots_replica_db", - "radroots_replica_db_schema", + "radroots_replica_schema", + "radroots_replica_store", "radroots_replica_sync", "radroots_runtime", "radroots_runtime_paths", + "radroots_runtime_store", "radroots_sdk", "radroots_secret_vault", - "radroots_sp1_host_trade", "radroots_sql_core", "radroots_trade", + "radroots_trade_sp1_host", "radroots_transport", "radroots_transport_nostr", "serde", @@ -3666,38 +3666,38 @@ dependencies = [ ] [[package]] -name = "radroots_event_store" +name = "radroots_event" version = "0.1.0-alpha.2" dependencies = [ - "radroots_event", - "radroots_nostr", - "radroots_transport", + "hex", + "radroots_core", "serde", "serde_json", - "sqlx", - "thiserror 1.0.69", + "sha2", ] [[package]] -name = "radroots_event" +name = "radroots_event_codec" version = "0.1.0-alpha.2" dependencies = [ - "hex", + "nostr", "radroots_core", + "radroots_event", "serde", "serde_json", - "sha2", ] [[package]] -name = "radroots_event_codec" +name = "radroots_event_store" version = "0.1.0-alpha.2" dependencies = [ - "nostr", - "radroots_core", "radroots_event", + "radroots_nostr", + "radroots_transport", "serde", "serde_json", + "sqlx", + "thiserror 1.0.69", ] [[package]] @@ -3732,16 +3732,6 @@ dependencies = [ ] [[package]] -name = "radroots_runtime_store" -version = "0.1.0-alpha.2" -dependencies = [ - "radroots_sql_core", - "serde", - "serde_json", - "thiserror 1.0.69", -] - -[[package]] name = "radroots_log" version = "0.1.0-alpha.2" dependencies = [ @@ -3822,8 +3812,8 @@ name = "radroots_outbox" version = "0.1.0-alpha.2" dependencies = [ "hex", - "radroots_event_store", "radroots_event", + "radroots_event_store", "radroots_transport", "serde", "serde_json", @@ -3845,25 +3835,23 @@ dependencies = [ ] [[package]] -name = "radroots_replica_db" +name = "radroots_replica_schema" version = "0.1.0-alpha.2" dependencies = [ - "hex", - "radroots_replica_db_schema", - "radroots_sql_core", - "radroots_types", "serde", "serde_json", - "sha2", ] [[package]] -name = "radroots_replica_db_schema" +name = "radroots_replica_store" version = "0.1.0-alpha.2" dependencies = [ - "radroots_types", + "hex", + "radroots_replica_schema", + "radroots_sql_core", "serde", "serde_json", + "sha2", ] [[package]] @@ -3875,10 +3863,9 @@ dependencies = [ "radroots_core", "radroots_event", "radroots_event_codec", - "radroots_replica_db", - "radroots_replica_db_schema", + "radroots_replica_schema", + "radroots_replica_store", "radroots_sql_core", - "radroots_types", "serde", "serde_json", "sha2", @@ -3916,6 +3903,16 @@ dependencies = [ ] [[package]] +name = "radroots_runtime_store" +version = "0.1.0-alpha.2" +dependencies = [ + "radroots_sql_core", + "serde", + "serde_json", + "thiserror 1.0.69", +] + +[[package]] name = "radroots_sdk" version = "0.1.0" dependencies = [ @@ -3923,9 +3920,9 @@ dependencies = [ "hex", "nostr", "radroots_authority", - "radroots_event_store", "radroots_event", "radroots_event_codec", + "radroots_event_store", "radroots_geocoder", "radroots_identity", "radroots_nostr", @@ -3955,57 +3952,57 @@ dependencies = [ ] [[package]] -name = "radroots_sp1_guest_trade" +name = "radroots_sql_core" version = "0.1.0-alpha.2" dependencies = [ + "chrono", + "rusqlite", "serde", "serde_json", - "sha2", - "thiserror 1.0.69", + "uuid", ] [[package]] -name = "radroots_sp1_host_trade" +name = "radroots_trade" version = "0.1.0-alpha.2" dependencies = [ "base64 0.22.1", - "bincode", - "radroots_sp1_guest_trade", - "radroots_trade", + "hex", + "radroots_authority", + "radroots_core", + "radroots_event", + "radroots_event_codec", + "radroots_event_store", "serde", "serde_json", "sha2", - "sp1-build", - "sp1-sdk", + "sqlx", "thiserror 1.0.69", ] [[package]] -name = "radroots_sql_core" +name = "radroots_trade_sp1_guest" version = "0.1.0-alpha.2" dependencies = [ - "chrono", - "rusqlite", "serde", "serde_json", - "uuid", + "sha2", + "thiserror 1.0.69", ] [[package]] -name = "radroots_trade" +name = "radroots_trade_sp1_host" version = "0.1.0-alpha.2" dependencies = [ "base64 0.22.1", - "hex", - "radroots_authority", - "radroots_core", - "radroots_event_store", - "radroots_event", - "radroots_event_codec", + "bincode", + "radroots_trade", + "radroots_trade_sp1_guest", "serde", "serde_json", "sha2", - "sqlx", + "sp1-build", + "sp1-sdk", "thiserror 1.0.69", ] @@ -4023,8 +4020,8 @@ version = "0.1.0-alpha.2" dependencies = [ "futures", "nostr", - "radroots_event_store", "radroots_event", + "radroots_event_store", "radroots_nostr", "radroots_outbox", "radroots_transport", @@ -4051,14 +4048,6 @@ dependencies = [ ] [[package]] -name = "radroots_types" -version = "0.1.0-alpha.2" -dependencies = [ - "serde", - "serde_json", -] - -[[package]] name = "rand" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -19,7 +19,7 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] } [features] default = ["sp1-verify"] -sp1-verify = ["radroots_sp1_host_trade/sp1_verify"] +sp1-verify = ["radroots_trade_sp1_host/sp1_verify"] test-fixture-geonames-asset = ["radroots_sdk/test-fixture-geonames-asset"] [dependencies] @@ -40,8 +40,8 @@ radroots_nostr = { path = "../lib/crates/nostr", features = ["client", "events"] radroots_nostr_connect = { path = "../lib/crates/nostr_connect" } radroots_nostr_signer = { path = "../lib/crates/nostr_signer" } radroots_protected_store = { path = "../lib/crates/protected_store", features = ["std"] } -radroots_replica_db = { path = "../lib/crates/replica_db" } -radroots_replica_db_schema = { path = "../lib/crates/replica_db_schema" } +radroots_replica_store = { path = "../lib/crates/replica_store" } +radroots_replica_schema = { path = "../lib/crates/replica_schema" } radroots_replica_sync = { path = "../lib/crates/replica_sync" } radroots_transport = { path = "../lib/crates/transport", default-features = false } radroots_transport_nostr = { path = "../lib/crates/transport_nostr", default-features = false, features = [ @@ -52,7 +52,7 @@ radroots_runtime_paths = { path = "../lib/crates/runtime_paths" } radroots_sdk = { path = "../sdk/crates/sdk", features = ["local-runtime-radrootsd-proxy", "transport-nostr-runtime"] } radroots_secret_vault = { path = "../lib/crates/secret_vault", features = ["std", "os-keyring"] } radroots_sql_core = { path = "../lib/crates/sql_core", features = ["native"] } -radroots_sp1_host_trade = { path = "../lib/crates/sp1_host_trade" } +radroots_trade_sp1_host = { path = "../lib/crates/trade_sp1_host" } radroots_trade = { path = "../lib/crates/trade" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/src/ops/exec/basket.rs b/src/ops/exec/basket.rs @@ -4,8 +4,8 @@ use std::sync::atomic::{AtomicU64, Ordering}; use std::time::{SystemTime, UNIX_EPOCH}; use radroots_event::order::RadrootsOrderEconomics; -use radroots_replica_db::{ReplicaSql, trade_product}; -use radroots_replica_db_schema::trade_product::{ITradeProductFieldsFilter, ITradeProductFindMany}; +use radroots_replica_schema::trade_product::{ITradeProductFieldsFilter, ITradeProductFindMany}; +use radroots_replica_store::{ReplicaSql, trade_product}; use radroots_sql_core::SqliteExecutor; use serde::{Deserialize, Serialize}; use serde_json::{Value, json}; @@ -873,17 +873,17 @@ fn basket_market_issues( config: &RuntimeConfig, document: &BasketDocument, ) -> Result<Vec<BasketIssue>, OperationAdapterError> { - if !config.local.replica_db_path.exists() { + if !config.local.replica_store_path.exists() { return Ok(vec![basket_issue( "basket_market_replica_missing", - "local.replica_db", + "local.replica_store", "current local replica data is required before quote creation; run `radroots store init` and `radroots market refresh`", )]); } - let executor = SqliteExecutor::open(&config.local.replica_db_path).map_err(|error| { + let executor = SqliteExecutor::open(&config.local.replica_store_path).map_err(|error| { OperationAdapterError::Runtime(format!( "open local replica {}: {error}", - config.local.replica_db_path.display() + config.local.replica_store_path.display() )) })?; let mut issues = Vec::new(); @@ -983,12 +983,13 @@ fn basket_product_bin_state( let Some(listing_lookup) = item.listing.as_deref().and_then(non_empty_ref) else { return Ok(BasketProductResolution::Unresolved); }; - let lookup_executor = SqliteExecutor::open(&config.local.replica_db_path).map_err(|error| { - OperationAdapterError::Runtime(format!( - "open local replica {}: {error}", - config.local.replica_db_path.display() - )) - })?; + let lookup_executor = + SqliteExecutor::open(&config.local.replica_store_path).map_err(|error| { + OperationAdapterError::Runtime(format!( + "open local replica {}: {error}", + config.local.replica_store_path.display() + )) + })?; let rows = ReplicaSql::new(lookup_executor) .trade_product_lookup(listing_lookup) .map_err(|error| { @@ -1818,7 +1819,8 @@ mod tests { content: "# Market Eggs".to_owned(), sig: "f".repeat(128), }; - let executor = SqliteExecutor::open(&config.local.replica_db_path).expect("open replica"); + let executor = + SqliteExecutor::open(&config.local.replica_store_path).expect("open replica"); assert_eq!( radroots_replica_ingest_event(&executor, &event).expect("ingest listing"), RadrootsReplicaIngestOutcome::Applied @@ -1833,7 +1835,8 @@ mod tests { } fn duplicate_current_listing_row(config: &RuntimeConfig) { - let executor = SqliteExecutor::open(&config.local.replica_db_path).expect("open replica"); + let executor = + SqliteExecutor::open(&config.local.replica_store_path).expect("open replica"); let params = json!(["33333333-3333-3333-3333-333333333333", LISTING_ADDR]).to_string(); executor .exec( @@ -1908,7 +1911,7 @@ mod tests { transport: crate::runtime::config::TransportConfig::local_only(), local: LocalConfig { root: data.join("apps/cli/replica"), - replica_db_path: data.join("apps/cli/replica/replica.sqlite"), + replica_store_path: data.join("apps/cli/replica/replica.sqlite"), backups_dir: data.join("apps/cli/replica/backups"), exports_dir: data.join("apps/cli/replica/exports"), }, diff --git a/src/ops/exec/core.rs b/src/ops/exec/core.rs @@ -91,7 +91,7 @@ impl OperationService<WorkspaceGetRequest> for CoreOperationService<'_> { "shared_cache_root": self.config.paths.shared_cache_root.display().to_string(), "app_logs_root": self.config.paths.app_logs_root.display().to_string(), "local_root": self.config.local.root.display().to_string(), - "replica_db_path": self.config.local.replica_db_path.display().to_string(), + "replica_store_path": self.config.local.replica_store_path.display().to_string(), })) } } @@ -249,7 +249,7 @@ impl OperationService<ConfigGetRequest> for CoreOperationService<'_> { }, "local": { "root": self.config.local.root.display().to_string(), - "replica_db_path": self.config.local.replica_db_path.display().to_string(), + "replica_store_path": self.config.local.replica_store_path.display().to_string(), "backups_dir": self.config.local.backups_dir.display().to_string(), "exports_dir": self.config.local.exports_dir.display().to_string(), }, @@ -1263,8 +1263,8 @@ mod tests { assert_eq!(envelope.request_id, "req_workspace"); assert_eq!(envelope.result["profile"], "interactive_user"); assert_eq!( - envelope.result["replica_db_path"], - config.local.replica_db_path.display().to_string() + envelope.result["replica_store_path"], + config.local.replica_store_path.display().to_string() ); } @@ -1485,7 +1485,7 @@ mod tests { transport: crate::runtime::config::TransportConfig::local_only(), local: LocalConfig { root: data.join("apps/cli/replica"), - replica_db_path: data.join("apps/cli/replica/replica.sqlite"), + replica_store_path: data.join("apps/cli/replica/replica.sqlite"), backups_dir: data.join("apps/cli/replica/backups"), exports_dir: data.join("apps/cli/replica/exports"), }, diff --git a/src/ops/exec/farm.rs b/src/ops/exec/farm.rs @@ -883,7 +883,7 @@ mod tests { transport: crate::runtime::config::TransportConfig::local_only(), local: LocalConfig { root: data.join("apps/cli/replica"), - replica_db_path: data.join("apps/cli/replica/replica.sqlite"), + replica_store_path: data.join("apps/cli/replica/replica.sqlite"), backups_dir: data.join("apps/cli/replica/backups"), exports_dir: data.join("apps/cli/replica/exports"), }, diff --git a/src/ops/exec/listing.rs b/src/ops/exec/listing.rs @@ -608,7 +608,7 @@ mod tests { transport: crate::runtime::config::TransportConfig::local_only(), local: LocalConfig { root: data.join("apps/cli/replica"), - replica_db_path: data.join("apps/cli/replica/replica.sqlite"), + replica_store_path: data.join("apps/cli/replica/replica.sqlite"), backups_dir: data.join("apps/cli/replica/backups"), exports_dir: data.join("apps/cli/replica/exports"), }, diff --git a/src/ops/exec/market.rs b/src/ops/exec/market.rs @@ -78,7 +78,7 @@ fn market_refresh_view(mut view: SyncActionView) -> SyncActionView { "unavailable" => vec!["radroots sync status get".to_owned()], "unconfigured" => { let mut actions = Vec::new(); - if view.replica_db == "missing" { + if view.replica_store == "missing" { actions.push("radroots store init".to_owned()); } if view.configured_transport_target_count == 0 { @@ -301,7 +301,7 @@ mod tests { assert_eq!(envelope.operation_id, "market.refresh"); assert_eq!(envelope.dry_run, true); assert_eq!(envelope.result["state"], "unconfigured"); - assert_eq!(envelope.result["replica_db"], "missing"); + assert_eq!(envelope.result["replica_store"], "missing"); assert_eq!(envelope.result["direction"], "pull"); } @@ -430,7 +430,7 @@ mod tests { query: "eggs".to_owned(), count: 1, relay_count: 1, - replica_db: "ready".to_owned(), + replica_store: "ready".to_owned(), freshness: freshness(), results: vec![FindResultView { id: "listing_eggs".to_owned(), @@ -498,7 +498,7 @@ mod tests { query: "eggs".to_owned(), count: 1, relay_count: 1, - replica_db: "ready".to_owned(), + replica_store: "ready".to_owned(), freshness: freshness(), results: vec![FindResultView { id: "listing_eggs".to_owned(), @@ -672,7 +672,7 @@ mod tests { transport: crate::runtime::config::TransportConfig::local_only(), local: LocalConfig { root: data.join("apps/cli/replica"), - replica_db_path: data.join("apps/cli/replica/replica.sqlite"), + replica_store_path: data.join("apps/cli/replica/replica.sqlite"), backups_dir: data.join("apps/cli/replica/backups"), exports_dir: data.join("apps/cli/replica/exports"), }, diff --git a/src/ops/exec/runtime.rs b/src/ops/exec/runtime.rs @@ -401,7 +401,7 @@ mod tests { "SDK canonical event store and outbox" ); assert_eq!( - envelope.result["replica_db"], + envelope.result["replica_store"], "derived_projection_not_checked" ); assert_eq!(envelope.result["queue"]["pending_count"], 0); @@ -476,7 +476,7 @@ mod tests { ), local: LocalConfig { root: data.join("apps/cli/replica"), - replica_db_path: data.join("apps/cli/replica/replica.sqlite"), + replica_store_path: data.join("apps/cli/replica/replica.sqlite"), backups_dir: data.join("apps/cli/replica/backups"), exports_dir: data.join("apps/cli/replica/exports"), }, diff --git a/src/ops/exec/trade.rs b/src/ops/exec/trade.rs @@ -1831,7 +1831,7 @@ mod tests { transport: crate::runtime::config::TransportConfig::local_only(), local: LocalConfig { root: data.join("apps/cli/replica"), - replica_db_path: data.join("apps/cli/replica/replica.sqlite"), + replica_store_path: data.join("apps/cli/replica/replica.sqlite"), backups_dir: data.join("apps/cli/replica/backups"), exports_dir: data.join("apps/cli/replica/exports"), }, diff --git a/src/out/terminal/renderers/basket.rs b/src/out/terminal/renderers/basket.rs @@ -331,7 +331,7 @@ mod tests { "adjustment_count": 0, "issues": [{ "code": "basket_market_replica_missing", - "field": "local.replica_db", + "field": "local.replica_store", "message": "current local replica data is required before quote creation" }], "actions": ["radroots basket get basket_test"] @@ -343,7 +343,7 @@ mod tests { assert!(rendered.contains("Issues")); assert!(rendered.contains("basket_market_replica_missing")); - assert!(rendered.contains("local.replica_db")); + assert!(rendered.contains("local.replica_store")); } #[test] diff --git a/src/out/terminal/renderers/market.rs b/src/out/terminal/renderers/market.rs @@ -48,7 +48,7 @@ fn market_refresh_document(envelope: &OutputEnvelope, result: &Value) -> Termina common::push_count_field(&mut document, "Ingested", result, &["ingested_count"]); common::push_count_field(&mut document, "Skipped", result, &["skipped_count"]); common::push_count_field(&mut document, "Failed", result, &["failed_count"]); - common::push_path_field(&mut document, "Replica", result, &["replica_db"]); + common::push_path_field(&mut document, "Replica", result, &["replica_store"]); common::push_path_field(&mut document, "Reason", result, &["reason"]); document } diff --git a/src/out/terminal/renderers/workspace.rs b/src/out/terminal/renderers/workspace.rs @@ -31,7 +31,7 @@ impl TerminalOperationRenderer for WorkspaceRenderer { common::push_path_field(&mut document, "Profile", result, &["profile"]); common::push_verbose_path_field(&mut document, "Config", result, &["app_config_path"]); common::push_verbose_path_field(&mut document, "Data", result, &["app_data_root"]); - common::push_verbose_path_field(&mut document, "Replica", result, &["replica_db_path"]); + common::push_verbose_path_field(&mut document, "Replica", result, &["replica_store_path"]); document } } diff --git a/src/runtime/config.rs b/src/runtime/config.rs @@ -313,7 +313,7 @@ impl Default for ProxyTransportConfig { #[derive(Debug, Clone, PartialEq, Eq)] pub struct LocalConfig { pub root: PathBuf, - pub replica_db_path: PathBuf, + pub replica_store_path: PathBuf, pub backups_dir: PathBuf, pub exports_dir: PathBuf, } @@ -812,7 +812,7 @@ impl RuntimeConfig { transport, local: LocalConfig { root: paths.app_data_root.join(DEFAULT_LOCAL_STATE_DIR), - replica_db_path: paths + replica_store_path: paths .app_data_root .join(DEFAULT_LOCAL_STATE_DIR) .join(DEFAULT_LOCAL_DB_FILE), diff --git a/src/runtime/find.rs b/src/runtime/find.rs @@ -1,4 +1,4 @@ -use radroots_replica_db::ReplicaSql; +use radroots_replica_store::ReplicaSql; use radroots_sql_core::SqliteExecutor; use crate::cli::global::FindQueryArgs; @@ -45,14 +45,14 @@ impl AppliedQueryRewrite { pub fn search(config: &RuntimeConfig, args: &FindQueryArgs) -> Result<FindView, RuntimeError> { let query = args.query.join(" "); - if !config.local.replica_db_path.exists() { + if !config.local.replica_store_path.exists() { return Ok(FindView { state: "unconfigured".to_owned(), source: FIND_SOURCE.to_owned(), query, count: 0, relay_count: config.transport.nostr_relay_urls.len(), - replica_db: config.local.replica_db_path.display().to_string(), + replica_store: config.local.replica_store_path.display().to_string(), freshness: missing_freshness(), results: Vec::new(), hyf: None, @@ -62,7 +62,7 @@ pub fn search(config: &RuntimeConfig, args: &FindQueryArgs) -> Result<FindView, } refresh_market_if_needed(config)?; - let db = ReplicaSql::new(SqliteExecutor::open(&config.local.replica_db_path)?); + let db = ReplicaSql::new(SqliteExecutor::open(&config.local.replica_store_path)?); let freshness = freshness_for_scope_from_executor(config, db.executor(), RelayIngestScope::MarketRefresh)?; let applied_query_rewrite = attempt_query_rewrite(config, query.as_str(), &args.query); @@ -149,7 +149,7 @@ pub fn search(config: &RuntimeConfig, args: &FindQueryArgs) -> Result<FindView, query, count: results.len(), relay_count, - replica_db: config.local.replica_db_path.display().to_string(), + replica_store: config.local.replica_store_path.display().to_string(), freshness, results, hyf: applied_query_rewrite.map(|rewrite| rewrite.to_find_view()), @@ -162,7 +162,7 @@ fn refresh_market_if_needed(config: &RuntimeConfig) -> Result<(), RuntimeError> if config.output.dry_run || config.transport.nostr_relay_urls.is_empty() { return Ok(()); } - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; let freshness = freshness_for_scope_from_executor(config, &executor, RelayIngestScope::MarketRefresh)?; if freshness_requires_refresh(&freshness) { diff --git a/src/runtime/listing.rs b/src/runtime/listing.rs @@ -23,7 +23,7 @@ use radroots_event::listing::{ use radroots_event::trade_validation::RadrootsTradeValidationListingError; use radroots_event_codec::d_tag::is_d_tag_base64url; use radroots_event_codec::listing::encode::to_wire_parts_with_kind; -use radroots_replica_db::ReplicaSql; +use radroots_replica_store::ReplicaSql; use radroots_runtime_store::{RuntimeStoreRecord, RuntimeStoreRecordFamily, SourceRuntime}; use radroots_sdk::{ ListingEnqueuePublishRequest, ListingEnqueueReceipt, ListingPreparePublishRequest, @@ -1607,8 +1607,8 @@ pub fn get( args: &RecordLookupArgs, ) -> Result<ListingGetView, RuntimeError> { refresh_market_listing_if_needed(config)?; - let freshness = if config.local.replica_db_path.exists() { - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let freshness = if config.local.replica_store_path.exists() { + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; freshness_for_scope_from_executor(config, &executor, RelayIngestScope::MarketRefresh)? } else { missing_freshness() @@ -1619,7 +1619,7 @@ pub fn get( relay_count: config.transport.nostr_relay_urls.len(), }; - if !config.local.replica_db_path.exists() { + if !config.local.replica_store_path.exists() { return Ok(ListingGetView { state: "unconfigured".to_owned(), source: LISTING_READ_SOURCE.to_owned(), @@ -1641,7 +1641,7 @@ pub fn get( }); } - let db = ReplicaSql::new(SqliteExecutor::open(&config.local.replica_db_path)?); + let db = ReplicaSql::new(SqliteExecutor::open(&config.local.replica_store_path)?); let rows = db.trade_product_lookup(args.key.as_str())?; let Some(row) = rows.into_iter().next() else { return Ok(ListingGetView { @@ -1722,13 +1722,13 @@ pub fn get( } fn refresh_market_listing_if_needed(config: &RuntimeConfig) -> Result<(), RuntimeError> { - if !config.local.replica_db_path.exists() + if !config.local.replica_store_path.exists() || config.output.dry_run || config.transport.nostr_relay_urls.is_empty() { return Ok(()); } - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; let freshness = freshness_for_scope_from_executor(config, &executor, RelayIngestScope::MarketRefresh)?; if crate::runtime::sync::freshness_requires_refresh(&freshness) { diff --git a/src/runtime/mod.rs b/src/runtime/mod.rs @@ -31,7 +31,7 @@ pub enum RuntimeError { #[error("accounts error: {0}")] Accounts(#[from] radroots_nostr_accounts::prelude::RadrootsNostrAccountsError), #[error("replica sql error: {0}")] - Sql(#[from] radroots_replica_db::SqlError), + Sql(#[from] radroots_replica_store::SqlError), #[error("replica sync error: {0}")] ReplicaSync(#[from] radroots_replica_sync::RadrootsReplicaEventsError), #[error("runtime store error: {0}")] diff --git a/src/runtime/order.rs b/src/runtime/order.rs @@ -34,15 +34,15 @@ use radroots_nostr::prelude::{ RadrootsNostrEvent, RadrootsNostrFilter, radroots_event_from_nostr, radroots_nostr_filter_tag, radroots_nostr_kind, }; -use radroots_replica_db::{ - ReplicaSql, ReplicaTradeProductSummaryRow, nostr_event_head, trade_product, -}; -use radroots_replica_db_schema::nostr_event_head::{ +use radroots_replica_schema::nostr_event_head::{ INostrEventHeadFindOne, INostrEventHeadFindOneArgs, NostrEventHeadQueryBindValues, }; -use radroots_replica_db_schema::trade_product::{ +use radroots_replica_schema::trade_product::{ ITradeProductFieldsFilter, ITradeProductFindMany, TradeProduct, }; +use radroots_replica_store::{ + ReplicaSql, ReplicaTradeProductSummaryRow, nostr_event_head, trade_product, +}; use radroots_runtime_store::{ BUYER_ORDER_REQUEST_LOCAL_WORK_RECORD_KIND, PublishOutboxStatus, RuntimeStoreRecord, RuntimeStoreRecordFamily, RuntimeStoreRecordStatus, SourceRuntime, @@ -2789,13 +2789,13 @@ fn resolve_order_listing( return Ok(None); }; - if !config.local.replica_db_path.exists() { + if !config.local.replica_store_path.exists() { return Err(RuntimeError::Config(format!( "trade listing lookup `{listing_lookup}` requires local market data; run `radroots store init` and `radroots market refresh` before creating a trade from a listing" ))); } - let db = ReplicaSql::new(SqliteExecutor::open(&config.local.replica_db_path)?); + let db = ReplicaSql::new(SqliteExecutor::open(&config.local.replica_store_path)?); let rows = db.trade_product_lookup(listing_lookup)?; match rows.len() { 0 => Err(RuntimeError::Config(format!( @@ -2859,11 +2859,11 @@ fn resolve_trade_product_by_listing_addr( config: &RuntimeConfig, listing_addr: &str, ) -> Result<Option<ResolvedOrderEconomicsProduct>, RuntimeError> { - if !config.local.replica_db_path.exists() { + if !config.local.replica_store_path.exists() { return Ok(None); } - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; let product_rows = trade_product::find_many( &executor, &ITradeProductFindMany { @@ -2890,11 +2890,11 @@ fn resolve_active_listing_event_id( listing_addr: &str, parsed: &ParsedListingAddress, ) -> Result<Option<String>, RuntimeError> { - if !config.local.replica_db_path.exists() { + if !config.local.replica_store_path.exists() { return Ok(None); } - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; let product_rows = trade_product::find_many( &executor, &ITradeProductFindMany { diff --git a/src/runtime/provider.rs b/src/runtime/provider.rs @@ -338,7 +338,7 @@ mod tests { transport: crate::runtime::config::TransportConfig::local_only(), local: LocalConfig { root: PathBuf::from("/tmp/local"), - replica_db_path: PathBuf::from("/tmp/local/replica.sqlite"), + replica_store_path: PathBuf::from("/tmp/local/replica.sqlite"), backups_dir: PathBuf::from("/tmp/local/backups"), exports_dir: PathBuf::from("/tmp/local/exports"), }, diff --git a/src/runtime/sdk.rs b/src/runtime/sdk.rs @@ -919,14 +919,14 @@ mod tests { }, DirectRrRsDependency { section: "dependencies", - name: "radroots_replica_db", + name: "radroots_replica_store", owner: "derived-projection-and-market-reads", reason: "derived projection status, export, market reads, sync pull, basket lookup, and trade draft preflight", lifecycle: "retain until those derived projection surfaces move behind SDK APIs", }, DirectRrRsDependency { section: "dependencies", - name: "radroots_replica_db_schema", + name: "radroots_replica_schema", owner: "derived-projection-and-market-reads", reason: "typed query filters for market, basket, and order lookup projections", lifecycle: "retain until those derived projection surfaces move behind SDK APIs", @@ -968,7 +968,7 @@ mod tests { }, DirectRrRsDependency { section: "dependencies", - name: "radroots_sp1_host_trade", + name: "radroots_trade_sp1_host", owner: "validation-receipts", reason: "validation receipt SP1 proof inspection and verification", lifecycle: "retain until validation receipt verification moves behind SDK APIs", @@ -1257,7 +1257,7 @@ mod tests { "radroots_replica_pending_publish_batch", "radroots_replica_sync_status", "ReplicaSql::new", - "SqliteExecutor::open(&config.local.replica_db_path)", + "SqliteExecutor::open(&config.local.replica_store_path)", "outbox_idempotency_digest", "canonical_target_transport_endpoints", "radroots_sdk::protocol::order", @@ -2807,7 +2807,7 @@ struct FixtureConfig;\n\ ), local: LocalConfig { root: data.join("apps/cli/replica"), - replica_db_path: data.join("apps/cli/replica/replica.sqlite"), + replica_store_path: data.join("apps/cli/replica/replica.sqlite"), backups_dir: data.join("apps/cli/replica/backups"), exports_dir: data.join("apps/cli/replica/exports"), }, diff --git a/src/runtime/store.rs b/src/runtime/store.rs @@ -1,8 +1,8 @@ use std::fs; use std::path::{Path, PathBuf}; -use radroots_replica_db::export::{ReplicaDbExportManifestRs, export_manifest}; -use radroots_replica_db::migrations; +use radroots_replica_store::export::{ReplicaStoreExportManifestRs, export_manifest}; +use radroots_replica_store::migrations; use radroots_replica_sync::radroots_replica_sync_status; use radroots_sdk::{ BackupReceipt, BackupRequest, IntegrityReceipt, IntegrityRequest, RadrootsClient, @@ -34,9 +34,9 @@ const SDK_EVENT_STORE_FILE: &str = "event_store.sqlite"; const SDK_OUTBOX_FILE: &str = "outbox.sqlite"; pub fn init(config: &RuntimeConfig) -> Result<LocalInitView, RuntimeError> { - let existed = config.local.replica_db_path.exists(); + let existed = config.local.replica_store_path.exists(); ensure_local_roots(config)?; - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; migrations::run_all_up(&executor)?; ensure_sync_run_table(&executor)?; let manifest = export_manifest(&executor)?; @@ -49,26 +49,26 @@ pub fn init(config: &RuntimeConfig) -> Result<LocalInitView, RuntimeError> { }, source: DERIVED_PROJECTION_SOURCE.to_owned(), local_root: config.local.root.display().to_string(), - replica_db: "ready".to_owned(), - path: config.local.replica_db_path.display().to_string(), - replica_db_version: manifest.replica_db_version, + replica_store: "ready".to_owned(), + path: config.local.replica_store_path.display().to_string(), + replica_store_version: manifest.replica_store_version, backup_format_version: manifest.backup_format_version, }) } pub fn init_preflight(config: &RuntimeConfig) -> Result<LocalInitView, RuntimeError> { validate_local_roots(config)?; - if config.local.replica_db_path.exists() { - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + if config.local.replica_store_path.exists() { + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; ensure_sync_run_table(&executor)?; let manifest = export_manifest(&executor)?; return Ok(LocalInitView { state: "ready".to_owned(), source: DERIVED_PROJECTION_SOURCE.to_owned(), local_root: config.local.root.display().to_string(), - replica_db: "ready".to_owned(), - path: config.local.replica_db_path.display().to_string(), - replica_db_version: manifest.replica_db_version, + replica_store: "ready".to_owned(), + path: config.local.replica_store_path.display().to_string(), + replica_store_version: manifest.replica_store_version, backup_format_version: manifest.backup_format_version, }); } @@ -77,9 +77,9 @@ pub fn init_preflight(config: &RuntimeConfig) -> Result<LocalInitView, RuntimeEr state: "dry_run".to_owned(), source: DERIVED_PROJECTION_SOURCE.to_owned(), local_root: config.local.root.display().to_string(), - replica_db: "missing".to_owned(), - path: config.local.replica_db_path.display().to_string(), - replica_db_version: String::new(), + replica_store: "missing".to_owned(), + path: config.local.replica_store_path.display().to_string(), + replica_store_version: String::new(), backup_format_version: String::new(), }) } @@ -104,13 +104,13 @@ pub fn status(config: &RuntimeConfig) -> Result<LocalStatusView, CliSdkAdapterEr fn derived_projection_status( config: &RuntimeConfig, ) -> Result<LocalDerivedProjectionStatusView, RuntimeError> { - if !config.local.replica_db_path.exists() { + if !config.local.replica_store_path.exists() { return Ok(LocalDerivedProjectionStatusView { state: "unconfigured".to_owned(), source: DERIVED_PROJECTION_SOURCE.to_owned(), - replica_db: "missing".to_owned(), - path: config.local.replica_db_path.display().to_string(), - replica_db_version: String::new(), + replica_store: "missing".to_owned(), + path: config.local.replica_store_path.display().to_string(), + replica_store_version: String::new(), backup_format_version: String::new(), schema_hash: String::new(), counts: LocalReplicaCountsView { @@ -129,7 +129,7 @@ fn derived_projection_status( }); } - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; ensure_sync_run_table(&executor)?; let manifest = export_manifest(&executor)?; let sync = radroots_replica_sync_status(&executor)?; @@ -137,9 +137,9 @@ fn derived_projection_status( Ok(LocalDerivedProjectionStatusView { state: "ready".to_owned(), source: DERIVED_PROJECTION_SOURCE.to_owned(), - replica_db: "ready".to_owned(), - path: config.local.replica_db_path.display().to_string(), - replica_db_version: manifest.replica_db_version.clone(), + replica_store: "ready".to_owned(), + path: config.local.replica_store_path.display().to_string(), + replica_store_version: manifest.replica_store_version.clone(), backup_format_version: manifest.backup_format_version.clone(), schema_hash: manifest.schema_hash.clone(), counts: manifest_counts(&manifest), @@ -215,7 +215,7 @@ pub fn export( format: LocalExportFormatArg, output: &Path, ) -> Result<LocalExportView, RuntimeError> { - if !config.local.replica_db_path.exists() { + if !config.local.replica_store_path.exists() { return Ok(LocalExportView { state: "unconfigured".to_owned(), source: DERIVED_PROJECTION_SOURCE.to_owned(), @@ -232,7 +232,7 @@ pub fn export( ensure_safe_output_path(config, output)?; create_parent_dir(output)?; - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; let manifest = export_manifest(&executor)?; let sync = radroots_replica_sync_status(&executor)?; let records = match format { @@ -240,7 +240,7 @@ pub fn export( let export = json!({ "kind": "local_export_manifest_v1", "source": DERIVED_PROJECTION_SOURCE, - "replica_db_version": manifest.replica_db_version, + "replica_store_version": manifest.replica_store_version, "backup_format_version": manifest.backup_format_version, "export_version": manifest.export_version, "schema_hash": manifest.schema_hash, @@ -259,7 +259,7 @@ pub fn export( json!({ "kind": "local_export_manifest", "source": DERIVED_PROJECTION_SOURCE, - "replica_db_version": manifest.replica_db_version, + "replica_store_version": manifest.replica_store_version, "backup_format_version": manifest.backup_format_version, "export_version": manifest.export_version, "schema_hash": manifest.schema_hash, @@ -473,7 +473,7 @@ fn ensure_safe_sdk_backup_destination( let sdk_outbox_path = sdk_root.join(SDK_OUTBOX_FILE); let forbidden_paths = [ sdk_root.as_path(), - config.local.replica_db_path.as_path(), + config.local.replica_store_path.as_path(), sdk_event_store_path.as_path(), sdk_outbox_path.as_path(), ]; @@ -501,7 +501,7 @@ fn ensure_safe_sdk_restore_destination( let sdk_outbox_path = sdk_root.join(SDK_OUTBOX_FILE); let forbidden_paths = [ config.local.root.as_path(), - config.local.replica_db_path.as_path(), + config.local.replica_store_path.as_path(), sdk_event_store_path.as_path(), sdk_outbox_path.as_path(), ]; @@ -514,7 +514,7 @@ fn ensure_safe_sdk_restore_destination( destination.display() ))); } - if config.local.replica_db_path.starts_with(destination) + if config.local.replica_store_path.starts_with(destination) || config.local.backups_dir.starts_with(destination) || config.local.exports_dir.starts_with(destination) { @@ -668,7 +668,7 @@ fn create_parent_dir(path: &Path) -> Result<(), RuntimeError> { } fn ensure_safe_output_path(config: &RuntimeConfig, output: &Path) -> Result<(), RuntimeError> { - if output == config.local.replica_db_path.as_path() { + if output == config.local.replica_store_path.as_path() { return Err(RuntimeError::Config(format!( "output path {} would overwrite the local replica database", output.display() @@ -677,7 +677,7 @@ fn ensure_safe_output_path(config: &RuntimeConfig, output: &Path) -> Result<(), Ok(()) } -fn manifest_counts(manifest: &ReplicaDbExportManifestRs) -> LocalReplicaCountsView { +fn manifest_counts(manifest: &ReplicaStoreExportManifestRs) -> LocalReplicaCountsView { LocalReplicaCountsView { farms: table_row_count(manifest, "farm"), listings: table_row_count(manifest, "trade_product"), @@ -687,7 +687,7 @@ fn manifest_counts(manifest: &ReplicaDbExportManifestRs) -> LocalReplicaCountsVi } } -fn table_row_count(manifest: &ReplicaDbExportManifestRs, name: &str) -> u64 { +fn table_row_count(manifest: &ReplicaStoreExportManifestRs, name: &str) -> u64 { manifest .table_counts .iter() diff --git a/src/runtime/sync.rs b/src/runtime/sync.rs @@ -11,7 +11,7 @@ use radroots_event::kinds::{ use radroots_nostr::prelude::{ RadrootsNostrFilter, RadrootsNostrTimestamp, radroots_event_from_nostr, radroots_nostr_kind, }; -use radroots_replica_db::{ReplicaSql, migrations}; +use radroots_replica_store::{ReplicaSql, migrations}; use radroots_replica_sync::{ RadrootsReplicaEventsError, RadrootsReplicaIngestOutcome, radroots_replica_ingest_event, radroots_replica_sync_status, @@ -88,7 +88,7 @@ struct SyncSnapshot { state: String, source: String, local_root: String, - replica_db: String, + replica_store: String, configured_transport_target_count: usize, configured_transport_targets: Vec<SyncTransportTargetView>, transport_statuses: Vec<SyncTransportStatusView>, @@ -257,7 +257,7 @@ where let failed_transport_targets = relay_failures(receipt.failed_relays); let reason = relay_failure_reason(&failed_transport_targets); let failure_reason = format!("Nostr transport fetch failed: {reason}"); - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; migrations::run_all_up(&executor)?; record_sync_run( &executor, @@ -282,7 +282,7 @@ where Ok(receipt) => receipt, Err(error) => { let failure_reason = error.to_string(); - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; migrations::run_all_up(&executor)?; record_sync_run( &executor, @@ -305,7 +305,7 @@ where } }; - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; migrations::run_all_up(&executor)?; let ingest = ingest_events(&executor, &receipt, scope)?; record_sync_run( @@ -331,7 +331,7 @@ where state: "ready".to_owned(), source: INGEST_SOURCE.to_owned(), local_root: config.local.root.display().to_string(), - replica_db: "ready".to_owned(), + replica_store: "ready".to_owned(), configured_transport_target_count: snapshot.configured_transport_target_count, configured_transport_targets: snapshot.configured_transport_targets, transport_statuses: snapshot.transport_statuses, @@ -414,7 +414,7 @@ fn empty_action_from_snapshot(snapshot: SyncSnapshot, direction: &str) -> SyncAc state: snapshot.state, source: snapshot.source, local_root: snapshot.local_root, - replica_db: snapshot.replica_db, + replica_store: snapshot.replica_store, configured_transport_target_count: snapshot.configured_transport_target_count, configured_transport_targets: snapshot.configured_transport_targets, transport_statuses: snapshot.transport_statuses, @@ -449,7 +449,7 @@ fn sdk_sync_status_view(config: &RuntimeConfig, receipt: SyncStatusReceipt) -> S state: "ready".to_owned(), source: SDK_SYNC_SOURCE.to_owned(), local_root: config.local.root.display().to_string(), - replica_db: "derived_projection_not_checked".to_owned(), + replica_store: "derived_projection_not_checked".to_owned(), configured_transport_target_count, configured_transport_targets, transport_statuses, @@ -554,7 +554,7 @@ fn sdk_push_action_view( state: state.to_owned(), source: SDK_PUSH_SOURCE.to_owned(), local_root: config.local.root.display().to_string(), - replica_db: "derived_projection_not_checked".to_owned(), + replica_store: "derived_projection_not_checked".to_owned(), configured_transport_target_count, configured_transport_targets, transport_statuses, @@ -1029,12 +1029,12 @@ fn transport_implementation_label(state: RadrootsTransportImplementationState) - fn inspect_sync(config: &RuntimeConfig) -> Result<SyncSnapshot, RuntimeError> { let transport_metadata = sync_transport_metadata(config)?; - if !config.local.replica_db_path.exists() { + if !config.local.replica_store_path.exists() { return Ok(SyncSnapshot { state: "unconfigured".to_owned(), source: SYNC_SOURCE.to_owned(), local_root: config.local.root.display().to_string(), - replica_db: "missing".to_owned(), + replica_store: "missing".to_owned(), configured_transport_target_count: transport_metadata.configured_transport_target_count, configured_transport_targets: transport_metadata.configured_transport_targets, transport_statuses: transport_metadata.transport_statuses, @@ -1046,7 +1046,7 @@ fn inspect_sync(config: &RuntimeConfig) -> Result<SyncSnapshot, RuntimeError> { }); } - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; migrations::run_all_up(&executor)?; let queue = radroots_replica_sync_status(&executor)?; let freshness = @@ -1077,7 +1077,7 @@ fn inspect_sync(config: &RuntimeConfig) -> Result<SyncSnapshot, RuntimeError> { state: state.to_owned(), source: SYNC_SOURCE.to_owned(), local_root: config.local.root.display().to_string(), - replica_db: "ready".to_owned(), + replica_store: "ready".to_owned(), configured_transport_target_count: transport_metadata.configured_transport_target_count, configured_transport_targets: transport_metadata.configured_transport_targets, transport_statuses: transport_metadata.transport_statuses, @@ -1098,7 +1098,7 @@ fn inspect_sync(config: &RuntimeConfig) -> Result<SyncSnapshot, RuntimeError> { state: "ready".to_owned(), source: SYNC_SOURCE.to_owned(), local_root: config.local.root.display().to_string(), - replica_db: "ready".to_owned(), + replica_store: "ready".to_owned(), configured_transport_target_count: transport_metadata.configured_transport_target_count, configured_transport_targets: transport_metadata.configured_transport_targets, transport_statuses: transport_metadata.transport_statuses, @@ -1125,7 +1125,7 @@ pub(crate) fn freshness_for_scope( config: &RuntimeConfig, scope: RelayIngestScope, ) -> Result<SyncFreshnessView, RuntimeError> { - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; migrations::run_all_up(&executor)?; freshness_for_scope_from_executor(config, &executor, scope) } @@ -1134,10 +1134,10 @@ pub(crate) fn relay_provenance_relays_for_scope( config: &RuntimeConfig, scope: RelayIngestScope, ) -> Result<Vec<String>, RuntimeError> { - if !config.local.replica_db_path.exists() { + if !config.local.replica_store_path.exists() { return Ok(Vec::new()); } - let executor = SqliteExecutor::open(&config.local.replica_db_path)?; + let executor = SqliteExecutor::open(&config.local.replica_store_path)?; migrations::run_all_up(&executor)?; ensure_sync_run_table(&executor)?; let current_fingerprint = relay_set_fingerprint(&config.transport.nostr_relay_urls); @@ -2039,7 +2039,7 @@ mod tests { assert_eq!(view.state, "ready"); assert_eq!(view.source, "SDK canonical event store and outbox"); - assert_eq!(view.replica_db, "derived_projection_not_checked"); + assert_eq!(view.replica_store, "derived_projection_not_checked"); assert_eq!(view.configured_transport_target_count, 2); assert_eq!(view.queue.total_count, Some(0)); assert_eq!(view.queue.pending_count, 0); @@ -2196,7 +2196,7 @@ mod tests { assert_eq!(view.state, "dry_run"); assert_eq!(view.source, "SDK outbox push"); - assert_eq!(view.replica_db, "derived_projection_not_checked"); + assert_eq!(view.replica_store, "derived_projection_not_checked"); assert_eq!( view.target_transport_endpoints, vec!["wss://relay.example.com"] @@ -3177,7 +3177,7 @@ mod tests { ), local: LocalConfig { root: data.join("apps/cli/replica"), - replica_db_path: data.join("apps/cli/replica/replica.sqlite"), + replica_store_path: data.join("apps/cli/replica/replica.sqlite"), backups_dir: data.join("apps/cli/replica/backups"), exports_dir: data.join("apps/cli/replica/exports"), }, diff --git a/src/runtime/validation_receipt.rs b/src/runtime/validation_receipt.rs @@ -7,13 +7,13 @@ use radroots_sdk::{ TradeValidationReceiptWorkerEvidence, TradeValidationReceiptWorkerEvidenceSelection as SdkWorkerEvidenceSelection, }; -use radroots_sp1_host_trade::RadrootsSp1TradeHostError; -use radroots_sp1_host_trade::verify_order_acceptance_validation_receipt_inline_sp1_proof; use radroots_trade::validation_receipt::{ RadrootsTradeCommitmentConfidence, RadrootsTradeValidationAuthority, RadrootsTradeValidationReceipt, RadrootsValidationReceiptProofSystem, RadrootsValidationReceiptResult, RadrootsValidationReceiptType, }; +use radroots_trade_sp1_host::RadrootsSp1TradeHostError; +use radroots_trade_sp1_host::verify_order_acceptance_validation_receipt_inline_sp1_proof; use serde::Serialize; use serde_json::Value; @@ -1305,13 +1305,13 @@ mod tests { proof_state_from_sp1_error, proof_state_is_invalid, proof_state_is_verification_success, proof_verification_view_for_receipt, validation_receipt_invalid_reason_code, }; - use radroots_sp1_host_trade::RadrootsSp1TradeHostError; use radroots_trade::validation_receipt::{ RadrootsTradeValidationReceipt, RadrootsValidationReceiptError, RadrootsValidationReceiptProof, RadrootsValidationReceiptProofSystem, RadrootsValidationReceiptResult, RadrootsValidationReceiptStatement, RadrootsValidationReceiptType, VALIDATION_RECEIPT_DOMAIN, VALIDATION_RECEIPT_VERSION, }; + use radroots_trade_sp1_host::RadrootsSp1TradeHostError; fn sp1_proof_with_material() -> RadrootsValidationReceiptProof { RadrootsValidationReceiptProof { diff --git a/src/view/runtime.rs b/src/view/runtime.rs @@ -302,7 +302,7 @@ pub struct PublishProviderRuntimeView { #[derive(Debug, Clone, Serialize)] pub struct LocalRuntimeView { pub root: String, - pub replica_db_path: String, + pub replica_store_path: String, pub backups_dir: String, pub exports_dir: String, } @@ -565,9 +565,9 @@ pub struct LocalInitView { pub state: String, pub source: String, pub local_root: String, - pub replica_db: String, + pub replica_store: String, pub path: String, - pub replica_db_version: String, + pub replica_store_version: String, pub backup_format_version: String, } @@ -657,9 +657,9 @@ pub struct SdkIntegrityView { pub struct LocalDerivedProjectionStatusView { pub state: String, pub source: String, - pub replica_db: String, + pub replica_store: String, pub path: String, - pub replica_db_version: String, + pub replica_store_version: String, pub backup_format_version: String, pub schema_hash: String, pub counts: LocalReplicaCountsView, @@ -1122,7 +1122,7 @@ pub struct FindView { pub query: String, pub count: usize, pub relay_count: usize, - pub replica_db: String, + pub replica_store: String, pub freshness: SyncFreshnessView, pub results: Vec<FindResultView>, #[serde(skip_serializing_if = "Option::is_none")] @@ -3475,7 +3475,7 @@ pub struct SyncStatusView { pub state: String, pub source: String, pub local_root: String, - pub replica_db: String, + pub replica_store: String, pub configured_transport_target_count: usize, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub configured_transport_targets: Vec<SyncTransportTargetView>, @@ -3507,7 +3507,7 @@ pub struct SyncActionView { pub state: String, pub source: String, pub local_root: String, - pub replica_db: String, + pub replica_store: String, pub configured_transport_target_count: usize, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub configured_transport_targets: Vec<SyncTransportTargetView>, diff --git a/tests/support/mod.rs b/tests/support/mod.rs @@ -123,7 +123,7 @@ impl RadrootsCliSandbox { ) } - pub fn replica_db_path(&self) -> PathBuf { + pub fn replica_store_path(&self) -> PathBuf { self.root .path() .join("data/apps/cli/replica/replica.sqlite") @@ -173,7 +173,7 @@ const _: () = { let _ = RadrootsCliSandbox::write_workspace_config as fn(&RadrootsCliSandbox, &str) -> PathBuf; let _ = RadrootsCliSandbox::write_nostr_transport_profile as fn(&RadrootsCliSandbox, &[&str]) -> PathBuf; - let _ = RadrootsCliSandbox::replica_db_path as fn(&RadrootsCliSandbox) -> PathBuf; + let _ = RadrootsCliSandbox::replica_store_path as fn(&RadrootsCliSandbox) -> PathBuf; let _ = RadrootsCliSandbox::runtime_store_records as fn(&RadrootsCliSandbox) -> Vec<RuntimeStoreRecord>; #[cfg(unix)] @@ -334,7 +334,7 @@ pub fn seed_orderable_listing(sandbox: &RadrootsCliSandbox, listing_addr: &str) #[allow(dead_code)] pub fn seed_market_refresh_provenance(sandbox: &RadrootsCliSandbox, relay_urls: &[&str]) { - let executor = SqliteExecutor::open(sandbox.replica_db_path()).expect("open replica db"); + let executor = SqliteExecutor::open(sandbox.replica_store_path()).expect("open replica db"); executor .exec( "CREATE TABLE IF NOT EXISTS radroots_cli_sync_run ( @@ -464,7 +464,7 @@ fn seed_orderable_listing_signed_event( } pub fn remove_orderable_listing(sandbox: &RadrootsCliSandbox, listing_addr: &str) { - let executor = SqliteExecutor::open(sandbox.replica_db_path()).expect("open replica db"); + let executor = SqliteExecutor::open(sandbox.replica_store_path()).expect("open replica db"); let params = serde_json::to_string(&vec![listing_addr]).expect("delete listing params"); executor .exec( @@ -479,7 +479,7 @@ pub fn update_orderable_listing_available_amount( listing_addr: &str, available_amount: i64, ) { - let executor = SqliteExecutor::open(sandbox.replica_db_path()).expect("open replica db"); + let executor = SqliteExecutor::open(sandbox.replica_store_path()).expect("open replica db"); let params = serde_json::to_string(&serde_json::json!([available_amount, listing_addr])) .expect("update listing params"); executor @@ -495,7 +495,7 @@ pub fn update_orderable_listing_primary_bin_id( listing_addr: &str, primary_bin_id: Option<&str>, ) { - let executor = SqliteExecutor::open(sandbox.replica_db_path()).expect("open replica db"); + let executor = SqliteExecutor::open(sandbox.replica_store_path()).expect("open replica db"); let params = serde_json::to_string(&serde_json::json!([primary_bin_id, listing_addr])) .expect("update listing primary bin params"); executor @@ -507,7 +507,7 @@ pub fn update_orderable_listing_primary_bin_id( } pub fn duplicate_orderable_listing_row(sandbox: &RadrootsCliSandbox, listing_addr: &str) { - let executor = SqliteExecutor::open(sandbox.replica_db_path()).expect("open replica db"); + let executor = SqliteExecutor::open(sandbox.replica_store_path()).expect("open replica db"); let params = serde_json::to_string(&json!([ "33333333-3333-3333-3333-333333333333", listing_addr @@ -528,7 +528,7 @@ pub fn replace_latest_listing_event_id( ) { let (seller_pubkey, listing_id) = listing_addr_parts(listing_addr); let key = format!("{KIND_LISTING}:{seller_pubkey}:{listing_id}"); - let executor = SqliteExecutor::open(sandbox.replica_db_path()).expect("open replica db"); + let executor = SqliteExecutor::open(sandbox.replica_store_path()).expect("open replica db"); let params = serde_json::to_string(&vec![event_id, key.as_str()]).expect("update params"); executor .exec( diff --git a/tests/target_cli.rs b/tests/target_cli.rs @@ -34,8 +34,8 @@ use radroots_outbox::{ RadrootsOutbox, RadrootsOutboxDeliveryPlanInput, RadrootsOutboxReticulumPreviewBehavior, RadrootsOutboxSignedOperationInput, }; -use radroots_replica_db::{farm, migrations}; -use radroots_replica_db_schema::farm::IFarmFields; +use radroots_replica_schema::farm::IFarmFields; +use radroots_replica_store::{farm, migrations}; use radroots_replica_sync::radroots_replica_pending_publish_batch; use radroots_runtime_store::{ BUYER_ORDER_REQUEST_LOCAL_WORK_RECORD_KIND, PublishOutboxStatus, RuntimeStore, @@ -748,7 +748,7 @@ fn read_relay_req_subscription_id(websocket: &mut tungstenite::WebSocket<TcpStre } fn seed_derived_projection_sync_farm(sandbox: &RadrootsCliSandbox, d_tag: &str, pubkey: &str) { - let executor = SqliteExecutor::open(sandbox.replica_db_path()).expect("open replica"); + let executor = SqliteExecutor::open(sandbox.replica_store_path()).expect("open replica"); migrations::run_all_up(&executor).expect("replica migrations"); farm::create( &executor, @@ -5569,7 +5569,7 @@ fn core_account_store_dry_runs_preflight_without_mutating_local_state() { assert_eq!(workspace["operation_id"], "workspace.init"); assert_eq!(workspace["dry_run"], true); assert_eq!(workspace["result"]["state"], "dry_run"); - assert_eq!(workspace["result"]["local"]["replica_db"], "missing"); + assert_eq!(workspace["result"]["local"]["replica_store"], "missing"); assert!(!Path::new(workspace_db).exists()); let store = sandbox.json_success(&["--format", "json", "--dry-run", "store", "init"]); @@ -5577,7 +5577,7 @@ fn core_account_store_dry_runs_preflight_without_mutating_local_state() { assert_eq!(store["operation_id"], "store.init"); assert_eq!(store["dry_run"], true); assert_eq!(store["result"]["state"], "dry_run"); - assert_eq!(store["result"]["replica_db"], "missing"); + assert_eq!(store["result"]["replica_store"], "missing"); assert!(!Path::new(store_db).exists()); let account_create = @@ -7380,7 +7380,7 @@ fn sync_push_sdk_outbox_failure_reports_network_unavailable() { "SDK canonical event store and outbox" ); assert_eq!( - status["result"]["replica_db"], + status["result"]["replica_store"], "derived_projection_not_checked" ); assert_eq!(status["result"]["queue"]["pending_count"], 1); @@ -7402,7 +7402,7 @@ fn sync_push_sdk_outbox_failure_reports_network_unavailable() { assert_eq!(value["errors"][0]["detail"]["state"], "unavailable"); assert_eq!(value["errors"][0]["detail"]["source"], "SDK outbox push"); assert_eq!( - value["errors"][0]["detail"]["replica_db"], + value["errors"][0]["detail"]["replica_store"], "derived_projection_not_checked" ); assert_eq!( @@ -7442,7 +7442,7 @@ fn sync_push_ignores_derived_projection_pending_queue_for_sdk_canonical_push() { DERIVED_PROJECTION_SYNC_PUSH_FARM_D_TAG, selected_pubkey, ); - let executor = SqliteExecutor::open(sandbox.replica_db_path()).expect("open replica"); + let executor = SqliteExecutor::open(sandbox.replica_store_path()).expect("open replica"); let derived_projection_batch = radroots_replica_pending_publish_batch(&executor) .expect("derived projection pending batch"); assert!(derived_projection_batch.pending_count > 0); @@ -7460,7 +7460,7 @@ fn sync_push_ignores_derived_projection_pending_queue_for_sdk_canonical_push() { assert_eq!(value["result"]["state"], "ready"); assert_eq!(value["result"]["source"], "SDK outbox push"); assert_eq!( - value["result"]["replica_db"], + value["result"]["replica_store"], "derived_projection_not_checked" ); assert_eq!(value["result"]["queue"]["pending_count"], 0); @@ -7485,7 +7485,7 @@ fn buyer_market_sync_basket_dry_runs_preflight_without_mutating_local_state() { assert_eq!(market["operation_id"], "market.refresh"); assert_eq!(market["dry_run"], true); assert_eq!(market["result"]["state"], "unconfigured"); - assert_eq!(market["result"]["replica_db"], "missing"); + assert_eq!(market["result"]["replica_store"], "missing"); let (sync_pull_output, sync_pull) = sandbox.json_output(&["--format", "json", "--dry-run", "sync", "pull"]); @@ -7494,7 +7494,7 @@ fn buyer_market_sync_basket_dry_runs_preflight_without_mutating_local_state() { assert_eq!(sync_pull["dry_run"], true); assert_eq!(sync_pull["errors"][0]["code"], "operation_unavailable"); assert_eq!(sync_pull["errors"][0]["detail"]["state"], "unconfigured"); - assert_eq!(sync_pull["errors"][0]["detail"]["replica_db"], "missing"); + assert_eq!(sync_pull["errors"][0]["detail"]["replica_store"], "missing"); let sync_push = sandbox.json_success(&["--format", "json", "--dry-run", "sync", "push"]); assert_eq!(sync_push["operation_id"], "sync.push"); @@ -7502,7 +7502,7 @@ fn buyer_market_sync_basket_dry_runs_preflight_without_mutating_local_state() { assert_eq!(sync_push["result"]["state"], "ready"); assert_eq!(sync_push["result"]["source"], "SDK outbox push"); assert_eq!( - sync_push["result"]["replica_db"], + sync_push["result"]["replica_store"], "derived_projection_not_checked" ); assert_eq!(sync_push["result"]["queue"]["pending_count"], 0); @@ -7530,7 +7530,7 @@ fn buyer_market_sync_basket_dry_runs_preflight_without_mutating_local_state() { assert_eq!(sync_push_ready["result"]["state"], "ready"); assert_eq!(sync_push_ready["result"]["source"], "SDK outbox push"); assert_eq!( - sync_push_ready["result"]["replica_db"], + sync_push_ready["result"]["replica_store"], "derived_projection_not_checked" ); assert_eq!( @@ -8937,7 +8937,7 @@ fn buyer_side_order_writes_reject_conflicting_account_override_for_local_draft() fn order_submit_non_dry_run_uses_sdk_relay_validation_without_replica_freshness_gate() { let sandbox = RadrootsCliSandbox::new(); let order_id = create_ready_order(&sandbox, "freshness_missing_db"); - fs::remove_file(sandbox.replica_db_path()).expect("remove replica db"); + fs::remove_file(sandbox.replica_store_path()).expect("remove replica db"); configure_nostr_transport(&sandbox, "ws://127.0.0.1:9"); let (output, value) = sandbox.json_output(&[ @@ -8962,7 +8962,7 @@ fn order_submit_non_dry_run_uses_sdk_relay_validation_without_replica_freshness_ fn order_submit_dry_run_does_not_require_local_replica_freshness() { let sandbox = RadrootsCliSandbox::new(); let order_id = create_ready_order(&sandbox, "dry_freshness_missing_db"); - fs::remove_file(sandbox.replica_db_path()).expect("remove replica db"); + fs::remove_file(sandbox.replica_store_path()).expect("remove replica db"); let value = sandbox.json_success(&[ "--format",