[package]
name = "brainwires-storage"
description = "Backend-agnostic storage, tiered memory, and document management for the Brainwires Agent Framework"
version.workspace = true
edition.workspace = true
license.workspace = true
rust-version.workspace = true
repository.workspace = true
homepage.workspace = true
authors.workspace = true
readme = "README.md"
documentation = "https://docs.rs/brainwires-storage"
keywords = ["vector-database", "lancedb", "semantic-search", "embeddings", "tiered-memory"]
categories = ["database"]

[dependencies]
# Internal crates
brainwires-core.workspace = true
# Vector database & columnar storage (native only)
lancedb = { workspace = true, optional = true }
arrow-array = { workspace = true, optional = true }
arrow-schema = { workspace = true, optional = true }

# Async runtime
tokio = { version = "1.43", features = ["sync", "time"] }
futures = { workspace = true, optional = true }

# Serialization
serde = { workspace = true }
serde_json = { workspace = true }

# Error handling
anyhow.workspace = true

# Identifiers & time
uuid.workspace = true
chrono.workspace = true

# Embeddings (FastEmbed ONNX model)
fastembed = { workspace = true, optional = true }

# Caching (embedding memoization)
lru = { workspace = true, optional = true }

# Hashing (file content hashing)
sha2 = { workspace = true, optional = true }

# SQLite (for lock store, native only)
rusqlite = { workspace = true, optional = true }

# Regex (for template matching)
regex.workspace = true

# File format processing (native only)
base64 = { version = "0.22", optional = true }

# System info (for lock store, native only)
gethostname = { version = "1", optional = true }
dirs = { version = "6", optional = true }
libc = { version = "0.2", optional = true }

# Async traits (required for StorageBackend/VectorDatabase traits + LockPersistence)
async-trait.workspace = true

# Vector DB deps (from brainwires-rag)
tantivy = { version = "0.22", optional = true }
globset = { version = "0.4", optional = true }
qdrant-client = { version = "1.15", optional = true }

# NornicDB deps
reqwest = { workspace = true, optional = true }
neo4rs = { version = "0.9.0-rc.9", optional = true }

# Postgres + pgvector (tokio-postgres avoids sqlx's libsqlite3-sys conflict)
tokio-postgres = { version = "0.7", optional = true }
deadpool-postgres = { version = "0.14", optional = true }
pgvector = { version = "0.4.1", features = ["postgres"], optional = true }

# MySQL (async client with built-in pool)
mysql_async = { version = "0.34", optional = true }

# SurrealDB (official SDK)
surrealdb = { version = "2", optional = true, features = ["protocol-ws", "kv-mem"] }

# Logging
tracing.workspace = true

[features]
default = ["native"]
native = [
    "lance-backend",
    "dep:fastembed", "dep:lru", "dep:rusqlite",
    "dep:base64", "dep:gethostname", "dep:dirs", "dep:libc",
    "tokio/rt", "tokio/macros",
    "brainwires-core/native",
]
full = ["native"]

# Unified database backends
lance-backend = [
    "dep:lancedb", "dep:arrow-array", "dep:arrow-schema",
    "dep:futures", "dep:sha2",
    "dep:tantivy", "dep:globset",
]
postgres-backend = ["lance-backend", "dep:tokio-postgres", "dep:deadpool-postgres", "dep:pgvector"]
mysql-backend = ["lance-backend", "dep:mysql_async"]
surrealdb-backend = ["lance-backend", "dep:surrealdb"]
qdrant-backend = ["lance-backend", "dep:qdrant-client"]
pinecone-backend = ["lance-backend", "dep:reqwest"]
weaviate-backend = ["lance-backend", "dep:reqwest"]
milvus-backend = ["lance-backend", "dep:reqwest"]
# NornicDB: base REST transport
nornicdb-backend = ["lance-backend", "dep:reqwest"]
# NornicDB: Bolt transport (Neo4j binary protocol)
nornicdb-bolt = ["nornicdb-backend", "dep:neo4rs"]
# NornicDB: gRPC transport (Qdrant-compatible)
nornicdb-grpc = ["nornicdb-backend", "dep:qdrant-client"]
# NornicDB: all transports
nornicdb-full = ["nornicdb-bolt", "nornicdb-grpc"]

# Backward-compat alias
vector-db = ["lance-backend"]

alt-folder-name = []
wasm = ["brainwires-core/wasm"]

[dev-dependencies]
tokio = { workspace = true, features = ["full", "test-util"] }
tempfile.workspace = true

[[example]]
name = "message_store"
required-features = ["native"]

[[example]]
name = "tiered_memory"
required-features = ["native"]

[[example]]
name = "plan_templates"
required-features = ["native"]

[[example]]
name = "lock_coordination"
required-features = ["native"]
