[package]
name = "logicaffeine-system"
version = "0.9.3"
edition.workspace = true
authors.workspace = true
repository.workspace = true
homepage.workspace = true
keywords.workspace = true
categories.workspace = true
rust-version.workspace = true
license = "BUSL-1.1"
description = "Platform IO and system services for LOGOS"
readme = "README.md"

[features]
default = []  # LEAN by default - no network, no persistence, no parallelism

# Individual capabilities (opt-in)
networking = ["dep:libp2p", "dep:futures"]
persistence = ["dep:memmap2", "dep:sha2"]
concurrency = ["dep:rayon", "dep:bumpalo"]
io-uring = ["dep:io-uring", "dep:crossbeam-channel", "persistence"]

# Convenience bundles
full = ["networking", "persistence", "concurrency"]
distributed = ["networking", "persistence"]  # For Distributed<T>

[dependencies]
# Always included (lightweight core)
logicaffeine-base = { version = "0.9.3", path = "../logicaffeine_base" }
logicaffeine-data = { version = "0.9.3", path = "../logicaffeine_data" }
serde = { version = "1.0", features = ["derive"] }
bincode = "1.3"
async-trait = "0.1"
once_cell = "1.19"
async-lock = "3.4"
crc32fast = "1.3"

# Feature-gated heavy dependencies
libp2p = { version = "0.54", optional = true, features = [
    "tcp", "quic", "noise", "yamux", "mdns",
    "request-response", "gossipsub", "macros", "tokio"
] }
memmap2 = { version = "0.9", optional = true }
sha2 = { version = "0.10", optional = true }
rayon = { version = "1.10", optional = true }
bumpalo = { version = "3.19", optional = true }
futures = { version = "0.3", optional = true }

# Native-only (always available on native, not WASM)
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync", "time", "fs", "io-util"] }
rand = "0.8"
getrandom = "0.2"
uuid = { version = "1.0", features = ["v4"] }

# Linux-only: io_uring for kernel-async file I/O
[target.'cfg(target_os = "linux")'.dependencies]
io-uring = { version = "0.7", optional = true }
crossbeam-channel = { version = "0.5", optional = true }

# WASM dependencies
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
js-sys = "0.3"
getrandom = { version = "0.2", features = ["js"] }
web-sys = { version = "0.3", features = [
    "Window", "Navigator", "StorageManager",
    "FileSystemDirectoryHandle", "FileSystemFileHandle",
    "FileSystemWritableFileStream", "FileSystemGetFileOptions",
    "FileSystemGetDirectoryOptions", "FileSystemCreateWritableOptions",
    "File", "Blob", "DomException",
    "Worker", "WorkerOptions", "WorkerType", "MessageEvent", "ErrorEvent",
    # IndexedDB features for fallback VFS
    "IdbFactory", "IdbDatabase", "IdbObjectStore", "IdbRequest", "IdbTransaction",
    "IdbTransactionMode", "IdbOpenDbRequest", "IdbVersionChangeEvent",
    "IdbObjectStoreParameters", "Event", "EventTarget", "DomStringList"
]}

[dev-dependencies]
tempfile = "3.10"

[package.metadata.docs.rs]
# Document with all features for comprehensive API coverage
features = ["full"]
