diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs index 1c16be88..54762868 100644 --- a/apps/desktop/src-tauri/src/lib.rs +++ b/apps/desktop/src-tauri/src/lib.rs @@ -29,6 +29,7 @@ use synapse_core::ports::{LlmPort, BufferPort, EmbeddingPort, HolographicPort}; use std::sync::Arc; use tokio::sync::Mutex; use synapse_core::ports::SovereigntyPort; +use rand::Rng; #[derive(serde::Serialize)] struct NodeInfo { @@ -735,12 +736,11 @@ struct TrainingMetrics { async fn get_training_metrics(_state: tauri::State<'_, SynapseState>) -> Result { // Mock metrics for the UI heartbeat // In real impl, this would read from a shared Arc> - use rand::Rng; // We need rand for the heartbeat effect - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); Ok(TrainingMetrics { - loss: rng.gen_range(0.1..0.5), - maternal_gradient_norm: rng.gen_range(0.01..0.1), + loss: rng.random_range(0.1..0.5), + maternal_gradient_norm: rng.random_range(0.01..0.1), epoch: 1, }) } diff --git a/bin/issue-syncer-linux b/bin/issue-syncer-linux deleted file mode 100644 index fac730fc..00000000 --- a/bin/issue-syncer-linux +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# issue-syncer-linux stub -# This is a placeholder. Replace with Rust binary or implemented script. -echo "⚠️ issue-syncer-linux stub - using fallback scripts" -exit 1 diff --git a/crates/synapse-core/Cargo.toml b/crates/synapse-core/Cargo.toml index 57408f39..9e9da105 100644 --- a/crates/synapse-core/Cargo.toml +++ b/crates/synapse-core/Cargo.toml @@ -35,6 +35,13 @@ anyhow = { workspace = true } lazy_static = "1.5.0" +[features] +infra = ["surrealdb"] + [dev-dependencies] tokio = { workspace = true } synapse-infra = { path = "../synapse-infra" } + +[dependencies.surrealdb] +workspace = true +optional = true diff --git a/crates/synapse-core/src/tokenomics/structs.rs b/crates/synapse-core/src/tokenomics/structs.rs index c0b4ee52..302b8d6f 100644 --- a/crates/synapse-core/src/tokenomics/structs.rs +++ b/crates/synapse-core/src/tokenomics/structs.rs @@ -6,6 +6,7 @@ use uuid::Uuid; /// The `soulbound_id` is the permanent anchor for reputation, /// while `wallet_address` is for financial transactions. #[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(feature = "infra", derive(surrealdb::SurrealValue))] pub struct UserProfile { /// The public address for receiving token rewards. pub wallet_address: String, @@ -72,6 +73,7 @@ pub struct Contribution { /// Receipt for a reward calculation, detailing mint vs burn. #[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(feature = "infra", derive(surrealdb::SurrealValue))] pub struct RewardReceipt { /// Total tokens minted for this reward. pub amount_minted: u64, diff --git a/crates/synapse-immune/src/quantum_wallet.rs b/crates/synapse-immune/src/quantum_wallet.rs index c2a6289b..208a98ed 100644 --- a/crates/synapse-immune/src/quantum_wallet.rs +++ b/crates/synapse-immune/src/quantum_wallet.rs @@ -50,7 +50,7 @@ impl synapse_core::ports::signer_port::Signer for QuantumWallet { } } -use rand::RngCore; +use rand::Rng; pub fn encrypt_hologram( data: &[u8], @@ -62,7 +62,7 @@ pub fn encrypt_hologram( let cipher = Aes256Gcm::new(key); let mut nonce_bytes = [0u8; 12]; - OsRng.fill_bytes(&mut nonce_bytes); + rand::rng().fill(&mut nonce_bytes); let nonce = Nonce::from_slice(&nonce_bytes); let encrypted_payload = cipher.encrypt(nonce, data.as_ref()).expect("encryption failed"); diff --git a/crates/synapse-infra/Cargo.toml b/crates/synapse-infra/Cargo.toml index a2f1d1c6..1423dc94 100644 --- a/crates/synapse-infra/Cargo.toml +++ b/crates/synapse-infra/Cargo.toml @@ -7,7 +7,7 @@ description = "Infrastructure adapters for Synapse Protocol" [dependencies] # Core domain -synapse-core = { path = "../synapse-core" } +synapse-core = { path = "../synapse-core", features = ["infra"] } # Async tokio = { workspace = true } diff --git a/crates/synapse-infra/src/adapters/surrealdb_adapter.rs b/crates/synapse-infra/src/adapters/surrealdb_adapter.rs index 72753ecb..6451e572 100644 --- a/crates/synapse-infra/src/adapters/surrealdb_adapter.rs +++ b/crates/synapse-infra/src/adapters/surrealdb_adapter.rs @@ -13,7 +13,7 @@ use std::sync::Arc; use tokio::sync::OnceCell; /// Record type for SurrealDB serialization. -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, surrealdb::SurrealValue)] struct MemoryRecord { content: String, layer: u8, @@ -55,7 +55,7 @@ pub struct SurrealDbAdapter { impl SurrealDbAdapter { /// Create a new SurrealDB adapter with file-based persistent storage. /// - /// # Arguments + /// #[derive(Debug, Deserialize, surrealdb::SurrealValue)]Arguments /// * `path` - Path to the database directory (uses SurrealKV backend) /// /// This uses the SurrealKV embedded storage engine for persistence. @@ -221,6 +221,23 @@ impl MemoryPort for SurrealDbAdapter { .await .map_err(|e| Error::System(format!("Search failed: {}", e)))?; + #[derive(Debug, Deserialize, surrealdb::SurrealValue)] + struct VectorSearchResult { + id: Thing, + content: String, + layer: u8, + node_type: String, + created_at: i64, + updated_at: i64, + embedding: Vec, + metadata: String, + namespace: String, + source: String, + holographic_data: Option>, + loop_level: u8, + distance: f32, + } + let results: Vec = response .take(0) .map_err(|e| Error::System(format!("Failed to parse results: {}", e)))?; @@ -282,6 +299,23 @@ impl MemoryPort for SurrealDbAdapter { .await .map_err(|e| Error::System(format!("Search layer failed: {}", e)))?; + #[derive(Debug, Deserialize, surrealdb::SurrealValue)] + struct VectorSearchResult { + id: Thing, + content: String, + layer: u8, + node_type: String, + created_at: i64, + updated_at: i64, + embedding: Vec, + metadata: String, + namespace: String, + source: String, + holographic_data: Option>, + loop_level: u8, + distance: f32, + } + let results: Vec = response .take(0) .map_err(|e| Error::System(format!("Failed to parse results: {}", e)))?; @@ -341,6 +375,23 @@ impl MemoryPort for SurrealDbAdapter { .await .map_err(|e| Error::System(format!("Search namespace failed: {}", e)))?; + #[derive(Debug, Deserialize, surrealdb::SurrealValue)] + struct VectorSearchResult { + id: Thing, + content: String, + layer: u8, + node_type: String, + created_at: i64, + updated_at: i64, + embedding: Vec, + metadata: String, + namespace: String, + source: String, + holographic_data: Option>, + loop_level: u8, + distance: f32, + } + let results: Vec = response .take(0) .map_err(|e| Error::System(format!("Failed to parse results: {}", e)))?; @@ -392,7 +443,7 @@ impl MemoryPort for SurrealDbAdapter { .await .map_err(|e| Error::System(format!("Get by layer failed: {}", e)))?; - #[derive(Deserialize)] + #[derive(Deserialize, surrealdb::SurrealValue)] struct LayerResult { id: Thing, content: String, @@ -524,6 +575,21 @@ impl MemoryPort for SurrealDbAdapter { .await .map_err(|e| Error::System(format!("Search all failed: {}", e)))?; + #[derive(Debug, Serialize, Deserialize, surrealdb::SurrealValue)] + struct MemoryRecord { + content: String, + layer: u8, + node_type: String, + created_at: i64, + updated_at: i64, + embedding: Vec, + metadata: String, // JSON serialized + namespace: String, + source: String, + holographic_data: Option>, + loop_level: u8, + } + let results: Vec = response .take(0) .map_err(|e| Error::System(format!("Failed to parse search results: {}", e)))?; @@ -542,7 +608,7 @@ impl MemoryPort for SurrealDbAdapter { .await .map_err(|e| Error::System(e.to_string()))?; - #[derive(Deserialize)] + #[derive(Deserialize, surrealdb::SurrealValue)] struct RecordWithId { id: Thing, content: String, @@ -587,7 +653,7 @@ impl MemoryPort for SurrealDbAdapter { let sql = "SELECT * FROM memory_node ORDER BY created_at DESC LIMIT 1"; let mut response = self.db.query(sql).await.map_err(|e| Error::System(e.to_string()))?; - #[derive(Deserialize)] + #[derive(Deserialize, surrealdb::SurrealValue)] struct RecordWithId { id: Thing, content: String,