[workspace]
members = [
    ".",
    "crates/entrenar-common",
    "crates/entrenar-distill",
    "crates/entrenar-shell",
    "crates/entrenar-lora",
    "crates/entrenar-inspect",
    "crates/entrenar-bench",
]

[workspace.lints.rust]
unsafe_code = "deny"
unreachable_pub = "warn"
missing_debug_implementations = "allow"
rust_2018_idioms = { level = "warn", priority = -1 }
trivial_casts = "warn"
trivial_numeric_casts = "warn"
unused_import_braces = "warn"
unused_lifetimes = "warn"
unused_qualifications = "warn"

[workspace.lints.clippy]
all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
checked_conversions = "warn"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
inefficient_to_string = "warn"
explicit_iter_loop = "warn"
manual_ok_or = "warn"
explicit_deref_methods = "warn"
implicit_clone = "warn"
inconsistent_struct_constructor = "warn"
redundant_closure_for_method_calls = "warn"
unnested_or_patterns = "warn"
many_single_char_names = "allow"
cast_precision_loss = "allow"
cast_possible_truncation = "allow"
cast_possible_wrap = "allow"
cast_sign_loss = "allow"
similar_names = "allow"
doc_markdown = "allow"
missing_const_for_fn = "allow"
module_name_repetitions = "allow"
must_use_candidate = "allow"
return_self_not_must_use = "allow"
float_cmp = "allow"
unreadable_literal = "allow"
items_after_statements = "allow"
large_stack_arrays = "allow"
struct_excessive_bools = "allow"
needless_pass_by_value = "allow"
unused_self = "allow"
trivially_copy_pass_by_ref = "allow"
assigning_clones = "allow"
match_same_arms = "allow"
case_sensitive_file_extension_comparisons = "allow"
used_underscore_binding = "allow"
comparison_chain = "allow"
format_push_string = "allow"
too_many_lines = "allow"
match_wildcard_for_single_variants = "allow"
struct_field_names = "allow"
manual_let_else = "allow"
unnecessary_wraps = "allow"

[package]
name = "entrenar"
version = "0.5.0"
edition = "2021"
authors = ["PAIML <hello@paiml.com>"]
description = "Training & Optimization library with autograd, LoRA, quantization, and model merging"
repository = "https://github.com/paiml/entrenar"
license = "MIT"
keywords = ["machine-learning", "neural-networks", "autograd", "lora", "quantization"]
categories = ["science", "mathematics"]

[lib]
crate-type = ["cdylib", "rlib"]

[lints]
workspace = true

[features]
default = []
gguf = []  # Placeholder for future GGUF support via Realizar
monitor = ["trueno-db"]  # Training monitoring with persistence
wasm = ["wasm-bindgen", "getrandom", "js-sys"]  # WASM bindings for browser dashboard
citl = ["trueno-rag", "tokio", "uuid"]  # Compiler-in-the-Loop training with RAG-based fix suggestions
server = ["axum", "tower", "tower-http", "tokio"]  # REST/HTTP API server
tracing = ["renacer"]  # Renacer distributed tracing integration
ruchy-sessions = []  # Ruchy session bridge for preserving training history
gpu = ["trueno/gpu", "tokio"]  # GPU-accelerated training via wgpu
cuda = ["trueno/cuda-monitor", "tokio"]  # NVIDIA CUDA monitoring via trueno-gpu

[dependencies]
# Core PAIML stack
ndarray = "0.16"
trueno = "0.11.0"  # SIMD-accelerated compute
aprender = "0.21.0"  # ML interpret module for explainability + .apr model format + pruning
alimentar = "0.2.2"  # Dataset loading with MNIST
trueno-viz = { version = "0.1.5", features = ["terminal"] }  # Terminal visualization
trueno-db = { version = "0.3.9", optional = true }  # Time-series storage
chrono = { version = "0.4", features = ["serde"] }  # Timestamps for metric storage
renacer = { version = "0.7.0", optional = true }  # Distributed tracing
wasm-bindgen = { version = "0.2", optional = true }  # WASM bindings
getrandom = { version = "0.3", features = ["wasm_js"], optional = true }  # WASM random
js-sys = { version = "0.3", optional = true }  # JavaScript types for WASM
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.9"
serde_json = "1.0"
toml = "0.8"
thiserror = "2.0"
rand = "0.9"
clap = { version = "4.5", features = ["derive"] }
clap_complete = "4.5"  # Shell completion generation
dirs = "5.0"  # Cache directory resolution for HF pipeline
trueno-rag = { version = "0.1.5", optional = true }  # RAG pipeline for CITL
tokio = { version = "1.41", features = ["rt", "rt-multi-thread", "macros", "net"], optional = true }  # Async runtime
uuid = { version = "1.11", features = ["v4", "serde"], optional = true }  # UUIDs for CITL patterns
axum = { version = "0.8", optional = true }  # HTTP server for REST API
tower = { version = "0.5", optional = true }  # Tower service utilities
tower-http = { version = "0.6", features = ["trace", "cors"], optional = true }  # HTTP middleware
safetensors = "0.7"  # SafeTensors format parsing
sha2 = "0.10"  # SHA256 hashing for artifact CAS
hex = "0.4"  # Hex encoding for hashes
regex = "1.10"  # ORCID/ROR validation
ed25519-dalek = "2.1"  # Ed25519 signing for pre-registration
zip = "2.2"  # RO-Crate ZIP export
memmap2 = "0.9"  # Memory-mapped file access for large models
bytemuck = { version = "1.19", features = ["derive"] }  # Safe byte casting for tensor data
hf-hub = "0.4"  # HuggingFace Hub API for model downloads

[dev-dependencies]
proptest = "1.4"
approx = "0.5"
tempfile = "3.8"
criterion = "0.5"
arrow = { version = "54", default-features = false }  # For MNIST example array access
insta = { version = "1.42", features = ["json", "yaml"] }  # Snapshot testing for PMAT QA

[[bench]]
name = "monitor_bench"
harness = false
required-features = ["monitor"]

[profile.release]
opt-level = 3
lto = true
codegen-units = 1

[profile.dev]
opt-level = 0

[[bin]]
name = "entrenar"
path = "src/main.rs"
required-features = []

[[example]]
name = "llama2-train"
path = "examples/llama2/train.rs"
required-features = []

[[example]]
name = "llama2-finetune-lora"
path = "examples/llama2/finetune_lora.rs"
required-features = []

[[example]]
name = "llama2-finetune-qlora"
path = "examples/llama2/finetune_qlora.rs"
required-features = []

[[example]]
name = "llama2-memory-benchmarks"
path = "examples/llama2/memory_benchmarks.rs"
required-features = []

[[example]]
name = "merge_models"
path = "examples/merge_models.rs"
required-features = []

[[example]]
name = "train_from_yaml"
path = "examples/train_from_yaml.rs"
required-features = []

[[example]]
name = "distillation"
path = "examples/distillation.rs"
required-features = []

[[example]]
name = "training_loop"
path = "examples/training_loop.rs"
required-features = []

[[example]]
name = "model_io"
path = "examples/model_io.rs"
required-features = []

[[example]]
name = "train_from_yaml_example"
path = "examples/train_from_yaml_example.rs"
required-features = []

[[example]]
name = "explainability"
path = "examples/explainability.rs"
required-features = []

[[example]]
name = "monitoring"
path = "examples/monitoring.rs"
required-features = []

[[example]]
name = "hf_distillation"
path = "examples/hf_distillation.rs"
required-features = []

[[example]]
name = "citl"
path = "examples/citl.rs"
required-features = ["citl"]

[[example]]
name = "mnist_train"
path = "examples/mnist_train.rs"
required-features = []

[[example]]
name = "mnist_train_gpu"
path = "examples/mnist_train_gpu.rs"
required-features = ["gpu"]

[[example]]
name = "cli_bench"
path = "examples/cli_bench.rs"
required-features = []

[[example]]
name = "cli_inspect"
path = "examples/cli_inspect.rs"
required-features = []

[[example]]
name = "cli_audit"
path = "examples/cli_audit.rs"
required-features = []

[[example]]
name = "cli_monitor"
path = "examples/cli_monitor.rs"
required-features = []

[[example]]
name = "cuda_backend"
path = "examples/cuda_backend.rs"
required-features = []
