Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/ai_hash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ai_hash"
version = "0.4.1"
version = "0.4.2"
authors = ["Apilium Technologies <hello@apilium.com>"]
keywords = [ "aingle", "ai", "hash", "blake", "blake2b" ]
categories = [ "cryptography" ]
Expand Down
2 changes: 1 addition & 1 deletion crates/aingle/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aingle"
version = "0.4.1"
version = "0.4.2"
description = "AIngle, a framework for distributed applications"
license = "Apache-2.0 OR LicenseRef-Commercial"
homepage = "https://apilium.com"
Expand Down
2 changes: 1 addition & 1 deletion crates/aingle_ai/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aingle_ai"
version = "0.4.1"
version = "0.4.2"
description = "AI integration layer for AIngle - Ineru, Nested Learning, Kaneru"
license = "Apache-2.0 OR LicenseRef-Commercial"
repository = "https://github.com/ApiliumCode/aingle"
Expand Down
2 changes: 1 addition & 1 deletion crates/aingle_contracts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aingle_contracts"
version = "0.4.1"
version = "0.4.2"
description = "Smart Contracts DSL and WASM Runtime for AIngle"
license = "Apache-2.0 OR LicenseRef-Commercial"
repository = "https://github.com/ApiliumCode/aingle"
Expand Down
2 changes: 1 addition & 1 deletion crates/aingle_cortex/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aingle_cortex"
version = "0.4.1"
version = "0.4.2"
description = "Córtex API - REST/GraphQL/SPARQL interface for AIngle semantic graphs"
license = "Apache-2.0 OR LicenseRef-Commercial"
repository = "https://github.com/ApiliumCode/aingle"
Expand Down
102 changes: 102 additions & 0 deletions crates/aingle_cortex/src/rest/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,104 @@ pub async fn restore_checkpoint(
Ok(StatusCode::OK)
}

// ============================================================================
// Vector Search (Motomeru)
// ============================================================================

#[derive(Debug, Deserialize)]
pub struct VectorSearchRequest {
pub embedding: Vec<f32>,
pub k: usize,
#[serde(default = "default_min_similarity")]
pub min_similarity: f32,
pub entry_type: Option<String>,
pub tags: Option<Vec<String>>,
}

fn default_min_similarity() -> f32 {
0.0
}

#[derive(Debug, Serialize)]
pub struct VectorIndexStatsDto {
pub point_count: usize,
pub deleted_count: usize,
pub dimensions: usize,
pub memory_bytes: usize,
}

/// Vector search over memory entries using HNSW index.
pub async fn vector_search(
State(state): State<AppState>,
Json(req): Json<VectorSearchRequest>,
) -> Result<Json<Vec<MemoryResultDto>>> {
let memory = state.memory.read().await;
let results = memory.ltm.vector_search_memories(&req.embedding, req.k, req.min_similarity);

let mut dtos: Vec<MemoryResultDto> = results
.into_iter()
.map(|(entry, similarity)| MemoryResultDto {
id: entry.id.to_hex(),
entry_type: entry.entry_type.clone(),
data: entry.data.clone(),
tags: entry.tags.iter().map(|t| t.0.clone()).collect(),
importance: entry.metadata.importance,
relevance: similarity,
source: "LongTerm".to_string(),
created_at: entry.metadata.created_at.0.to_string(),
last_accessed: entry.metadata.last_accessed.0.to_string(),
access_count: entry.metadata.access_count,
})
.collect();

// Apply optional filters
if let Some(ref entry_type) = req.entry_type {
dtos.retain(|d| &d.entry_type == entry_type);
}
if let Some(ref tags) = req.tags {
if !tags.is_empty() {
dtos.retain(|d| tags.iter().any(|t| d.tags.contains(t)));
}
}

Ok(Json(dtos))
}

/// Get HNSW vector index statistics.
pub async fn vector_index_stats(
State(state): State<AppState>,
) -> Result<Json<VectorIndexStatsDto>> {
let memory = state.memory.read().await;
let stats = memory.ltm.hnsw_index()
.map(|idx| idx.stats())
.unwrap_or(ineru::hnsw::HnswStats {
point_count: 0,
deleted_count: 0,
dimensions: 0,
max_layer: 0,
memory_bytes: 0,
});

Ok(Json(VectorIndexStatsDto {
point_count: stats.point_count,
deleted_count: stats.deleted_count,
dimensions: stats.dimensions,
memory_bytes: stats.memory_bytes,
}))
}

/// Force rebuild of the HNSW vector index.
pub async fn rebuild_vector_index(
State(state): State<AppState>,
) -> Result<StatusCode> {
let mut memory = state.memory.write().await;
if let Some(hnsw) = memory.ltm.hnsw_index_mut() {
hnsw.rebuild();
tracing::info!("HNSW index rebuilt, {} active points", hnsw.len());
}
Ok(StatusCode::OK)
}

// ============================================================================
// Helpers
// ============================================================================
Expand Down Expand Up @@ -376,4 +474,8 @@ pub fn memory_router() -> axum::Router<AppState> {
.route("/api/v1/memory/checkpoint", post(checkpoint))
.route("/api/v1/memory/checkpoints", get(list_checkpoints))
.route("/api/v1/memory/restore/{id}", post(restore_checkpoint))
// Motomeru: HNSW vector search endpoints
.route("/api/v1/memory/search", post(vector_search))
.route("/api/v1/memory/index/stats", get(vector_index_stats))
.route("/api/v1/memory/index/rebuild", post(rebuild_vector_index))
}
2 changes: 1 addition & 1 deletion crates/aingle_graph/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aingle_graph"
version = "0.4.1"
version = "0.4.2"
description = "Native GraphDB for AIngle - Semantic triple store with SPO indexes"
license = "Apache-2.0 OR LicenseRef-Commercial"
repository = "https://github.com/ApiliumCode/aingle"
Expand Down
2 changes: 1 addition & 1 deletion crates/aingle_logic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aingle_logic"
version = "0.4.1"
version = "0.4.2"
description = "Proof-of-Logic validation engine for AIngle semantic graphs"
license = "Apache-2.0 OR LicenseRef-Commercial"
repository = "https://github.com/ApiliumCode/aingle"
Expand Down
2 changes: 1 addition & 1 deletion crates/aingle_minimal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aingle_minimal"
version = "0.4.1"
version = "0.4.2"
description = "Ultra-light AIngle node for IoT devices (<1MB RAM)"
license = "Apache-2.0 OR LicenseRef-Commercial"
repository = "https://github.com/ApiliumCode/aingle"
Expand Down
2 changes: 1 addition & 1 deletion crates/aingle_viz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aingle_viz"
version = "0.4.1"
version = "0.4.2"
description = "DAG Visualization for AIngle - Web-based graph explorer"
license = "Apache-2.0 OR LicenseRef-Commercial"
repository = "https://github.com/ApiliumCode/aingle"
Expand Down
2 changes: 1 addition & 1 deletion crates/aingle_zk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aingle_zk"
version = "0.4.1"
version = "0.4.2"
description = "Zero-Knowledge Proofs for AIngle - privacy-preserving cryptographic primitives"
license = "Apache-2.0 OR LicenseRef-Commercial"
repository = "https://github.com/ApiliumCode/aingle"
Expand Down
2 changes: 1 addition & 1 deletion crates/aingle_zome_types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aingle_zome_types"
version = "0.4.1"
version = "0.4.2"
description = "AIngle zome types"
license = "Apache-2.0 OR LicenseRef-Commercial"
homepage = "https://apilium.com"
Expand Down
2 changes: 1 addition & 1 deletion crates/ineru/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ineru"
version = "0.4.1"
version = "0.4.2"
description = "Ineru: Neural-inspired memory system for AIngle AI agents"
license = "Apache-2.0 OR LicenseRef-Commercial"
repository = "https://github.com/ApiliumCode/aingle"
Expand Down
Loading
Loading