[workspace]
members = [
    ".",
    "ruchy-wasm",
]
exclude = ["fuzz"]
resolver = "2"

[workspace.lints.rust]
unsafe_code = "warn"  # Changed from "forbid" for DEFECT-001-B CallFrame Send impl
missing_docs = "allow"  # TODO: Add comprehensive documentation

[workspace.lints.clippy]
# Correctness
correctness = { level = "deny", priority = -1 }
suspicious = { level = "deny", priority = -1 }
complexity = { level = "warn", priority = -1 }
perf = { level = "warn", priority = -1 }
style = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
# Override specific perf lints that are too strict (priority 10 overrides category and clippy::all)
arc_with_non_send_sync = { level = "allow", priority = 10 }  # Value enum contains non-Send types (HtmlDocument, Expr in closures) - single-threaded code

# Specific lints to deny  
enum_glob_use = "deny"
unimplemented = "warn"
todo = "warn"
dbg_macro = "deny"

# Additional pedantic lints
cast_lossless = "warn"
cast_possible_truncation = "warn"
cast_possible_wrap = "warn"
cast_precision_loss = "allow"  # Tests can cast for demonstration
cast_sign_loss = "warn"
checked_conversions = "warn"
cloned_instead_of_copied = "warn"
cognitive_complexity = "allow"  # Test functions can be complex
default_trait_access = "allow"  # Tests can use Default::default() explicitly
doc_markdown = "warn"
empty_enum = "warn"
enum_variant_names = "warn"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
explicit_into_iter_loop = "warn"
explicit_iter_loop = "warn"
filter_map_next = "warn"
flat_map_option = "warn"
float_cmp = "allow"  # Tests can compare floats for exact values
float_cmp_const = "warn"
fn_params_excessive_bools = "warn"
from_iter_instead_of_collect = "warn"
if_not_else = "warn"
implicit_clone = "warn"
implicit_hasher = "warn"
implicit_saturating_sub = "warn"
inconsistent_struct_constructor = "warn"
inefficient_to_string = "warn"
inline_always = "warn"
invalid_upcast_comparisons = "warn"
items_after_statements = "warn"
large_digit_groups = "warn"
large_stack_arrays = "warn"
large_types_passed_by_value = "warn"
let_unit_value = "warn"
linkedlist = "warn"
macro_use_imports = "warn"
manual_assert = "warn"
manual_instant_elapsed = "warn"
manual_let_else = "warn"
manual_ok_or = "warn"
manual_string_new = "warn"
map_flatten = "warn"
map_unwrap_or = "warn"
match_bool = "warn"
match_same_arms = "allow"
match_wild_err_arm = "warn"
match_wildcard_for_single_variants = "warn"
maybe_infinite_iter = "warn"
mismatching_type_param_order = "warn"
missing_errors_doc = "warn"
missing_fields_in_debug = "warn"
missing_panics_doc = "warn"
module_name_repetitions = "warn"
must_use_candidate = "warn"
mut_mut = "warn"
naive_bytecount = "warn"
needless_bitwise_bool = "warn"
needless_continue = "warn"
needless_for_each = "warn"
needless_pass_by_value = "warn"
needless_raw_string_hashes = "warn"
negative_feature_names = "warn"
no_effect_underscore_binding = "allow"
no_mangle_with_rust_abi = "warn"
option_option = "warn"
pub_without_shorthand = "warn"
range_minus_one = "warn"
range_plus_one = "warn"
rc_buffer = "warn"
rc_mutex = "warn"
redundant_clone = "warn"
redundant_closure_for_method_calls = "warn"
redundant_else = "warn"
redundant_feature_names = "warn"
redundant_pub_crate = "warn"
ref_binding_to_reference = "warn"
ref_option_ref = "warn"
return_self_not_must_use = "warn"
same_functions_in_if_condition = "warn"
semicolon_if_nothing_returned = "warn"
should_panic_without_expect = "warn"
similar_names = "warn"
single_match_else = "warn"
stable_sort_primitive = "warn"
string_add = "allow"
string_add_assign = "warn"
struct_excessive_bools = "warn"
struct_field_names = "warn"
too_many_lines = "warn"
trait_duplication_in_bounds = "warn"
transmute_ptr_to_ptr = "warn"
trivially_copy_pass_by_ref = "warn"
type_repetition_in_bounds = "warn"
unchecked_time_subtraction = "warn"
unicode_not_nfc = "warn"
uninlined_format_args = "warn"
unnecessary_box_returns = "warn"
unnecessary_join = "warn"
unnecessary_wraps = "warn"
unnested_or_patterns = "warn"
unreadable_literal = "warn"
unused_async = "warn"
unused_self = "warn"
used_underscore_binding = "allow"
verbose_bit_mask = "warn"
verbose_file_reads = "warn"
wildcard_imports = "warn"
zero_sized_map_values = "warn"

# Cargo lints
cargo_common_metadata = "warn"

# Allow some things that are too strict
module_inception = "allow"
# Allow test-related patterns as specified in CLAUDE.md
unwrap_used = "allow"  # Tests can use unwrap for clarity
expect_used = "allow"  # Tests can use expect for clarity
panic = "allow"        # Tests can panic
print_stdout = "allow" # Examples and tests can print
print_stderr = "allow" # Examples and tests can print
empty_line_after_doc_comments = "allow"  # Documentation formatting flexibility
format_push_string = "allow"  # Tests can use format! for clarity
absurd_extreme_comparisons = "allow"  # Tests can check edge cases
approx_constant = "allow"  # Tests can use literal values
unnecessary_to_owned = "allow"  # Tests can be explicit
assertions_on_constants = "allow"  # Tests assert expected constants
overly_complex_bool_expr = "allow"  # Tests can have complex conditions

[workspace.package]
version = "3.163.0"
edition = "2021"
authors = ["Noah Gift"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/paiml/ruchy"
homepage = "https://github.com/paiml/ruchy"
documentation = "https://docs.rs/ruchy"
rust-version = "1.75"

[workspace.dependencies]
anyhow = "1.0"
thiserror = "2.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tracing = "0.1"
tracing-subscriber = "0.3"

# Parsing
logos = "0.15"
pest = "2.8"
pest_derive = "2.8"

# Code generation
syn = { version = "2.0", features = ["full", "extra-traits", "visit-mut"] }
quote = "1.0"
proc-macro2 = "1.0"
prettyplease = "0.2"

# REPL
rustyline = "17.0"
rustyline-derive = "0.11"

# Testing
proptest = "1.7"
criterion = "0.7"
insta = { version = "1.43", features = ["yaml"] }
quickcheck = "1.0"
quickcheck_macros = "1.1"

[package]
name = "ruchy"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
description = "A systems scripting language that transpiles to idiomatic Rust with extreme quality engineering"
readme = "README.md"
keywords = ["language", "compiler", "transpiler", "rust", "scripting"]
categories = ["compilers", "development-tools", "parser-implementations"]
exclude = ["src/bin/ruchy-coverage.rs", "src/bin/ruchy-lsp.rs", "coverage/", "node_modules/", "docs/specifications/", "tests/tdd_*", "scripts/"]

[[bin]]
name = "ruchy"
path = "src/bin/ruchy.rs"


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

[package.metadata.wasm-pack.profile.release]
wasm-opt = false

[lints]
workspace = true

[features]
default = ["batteries-included"]
batteries-included = ["notebook", "wasm-compile", "http-client", "markdown", "repl", "watch-mode"]
minimal = []  # Users can use --no-default-features --features minimal for core only
dataframe = ["polars", "arrow", "arrow-array", "arrow-buffer", "arrow-schema"]
testing = ["proptest"]
stub_tests = []  # Enable stub tests for incomplete features (development only)
notebook = ["tokio", "tokio-util", "axum", "tower", "tower-http", "wasmparser", "wasmtime"]
mcp = ["tokio", "tokio-util", "pmcp", "async-trait", "tower-lsp"]
wasm-compile = []  # WASM compilation is always available via wasm-encoder
# Optional features for minimal builds (DEPENDENCY-CLEANUP Sprint v3.109.0)
http-client = ["dep:reqwest"]
markdown = ["dep:pulldown-cmark"]
repl = ["dep:rustyline"]
watch-mode = ["dep:notify"]

[dependencies]
rand = "0.8"
ruchyruchy = { path = "../ruchyruchy", version = "1.8.0" }  # DEBUGGER-014 Phase 1.2: Execution tracing support (Issue #84)
wasm-encoder = "0.207.0"
glob = "0.3"
walkdir = "2.5"  # STDLIB-005: Directory traversal
rayon = "1.11"  # STDLIB-005: Parallel directory walking
md5 = "0.7"  # STDLIB-005: File hashing for duplicate detection
anyhow = { workspace = true }
thiserror = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tracing = { workspace = true }
logos = { workspace = true }
pest = { workspace = true }
pest_derive = { workspace = true }
syn = { workspace = true }
quote = { workspace = true }
im = "15.1"
quickcheck = "1.0"
smallvec = "1.15"
proc-macro2 = { workspace = true }
prettyplease = { workspace = true }
clap = { version = "4.5", features = ["derive"] }
regex = "1.11"
log = "0.4"
env_logger = "0.11"
# DataFrame support
polars = { version = "0.50", features = ["lazy"], optional = true }
arrow = { version = "54.0", optional = true }
arrow-array = { version = "54.0", optional = true }
arrow-buffer = { version = "54.0", optional = true }
arrow-schema = { version = "54.0", optional = true }
# WebAssembly support
uuid = { version = "1.18", features = ["v4", "js"] }
wasm-bindgen = "0.2"
serde-wasm-bindgen = "0.6"
js-sys = "0.3"
web-sys = { version = "0.3", features = ["console"] }
console_error_panic_hook = "0.1"
# Hardware detection
num_cpus = "1.17"
# MCP Integration (optional for WASM compatibility)
pmcp = { version = "1.3.0", features = ["full"], optional = true }
tokio = { version = "1.47", features = ["full"], optional = true }
tokio-util = { version = "0.7", features = ["rt"], optional = true }
async-trait = { version = "0.1", optional = true }
# Snapshot testing
sha2 = "0.10"
toml = "0.9"
chrono = { version = "0.4", features = ["serde"] }
# LSP support (optional for WASM compatibility)
tower-lsp = { version = "0.20", optional = true }
# Notebook support (optional)
axum = { version = "0.8", features = ["macros"], optional = true }
tower = { version = "0.4", features = ["util"], optional = true }
tower-http = { version = "0.5", features = ["cors", "fs", "set-header"], optional = true }
once_cell = "1.21"
lazy_static = "1.5"
# Compilation support
tempfile = "3.21"
proptest = { version = "1.7", optional = true }
# HTTP client support (STD-002) - optional for minimal builds
reqwest = { version = "0.12", features = ["blocking"], optional = true }
# HTTP server support (HTTP-001)
mime_guess = "2.0"
# HTML parsing support (HTTP-002-C) - native implementation
html5ever = "0.27"
markup5ever = "0.13"
markup5ever_rcdom = "0.3"
# Notebook support
wasmparser = { version = "0.239.0", optional = true }
wasmtime = { version = "38.0.2", optional = true }
# Markdown parsing - optional for minimal builds
pulldown-cmark = { version = "0.9", optional = true }

# Platform-specific dependencies for non-WASM targets
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
rustyline = { workspace = true, optional = true }
colored = "3.0"
walkdir = "2.5"
notify = { version = "8.2", optional = true }
local-ip-address = "0.6"  # Network IP detection for serve command

# Unix-specific dependencies for process management
[target.'cfg(unix)'.dependencies]
nix = { version = "0.29", features = ["signal", "process"] }
signal-hook = "0.3"  # Graceful shutdown handling

# WASM-specific dependencies
[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }
js-sys = "0.3"
wasm-bindgen-futures = "0.4"
console_error_panic_hook = "0.1"
web-sys = "0.3"
# WASM-compatible tokio without networking
tokio = { version = "1.47", features = ["macros", "rt", "time"], optional = true }

[dev-dependencies]
proptest = { workspace = true }
criterion = { workspace = true }
insta = { workspace = true }
tracing-subscriber = { workspace = true }
quickcheck = { workspace = true }
reqwest = { version = "0.12", features = ["json"] }
serde_json = "1.0"
assert_cmd = "2.0"
predicates = "3.1"
rexpect = "0.5"
tempfile = "3.21"
quickcheck_macros = { workspace = true }
walkdir = "2.5"
httpmock = "0.8"
nix = { version = "0.29", features = ["signal", "process"] }
# TDD Web testing dependencies
axum = { version = "0.8", features = ["macros"] }
tower = { version = "0.4", features = ["util"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

# WASM QA Framework dependencies (following spec)
wasm-bindgen-test = "0.3"
arbitrary = { version = "1.3", features = ["derive"] }
serde-wasm-bindgen = "0.6"

[[bench]]
name = "parser"
harness = false

[[bench]]
name = "transpiler"
harness = false

[[bench]]
name = "parser_benchmarks"
harness = false

[[bench]]
name = "interpreter_benchmarks"
harness = false

[[bench]]
name = "transpiler_benchmarks"
harness = false

[[bench]]
name = "performance_v3_13"
harness = false

[[bench]]
name = "wasm_performance"
harness = false

[[bench]]
name = "bytecode_vm_performance"
harness = false

[[bench]]
name = "matrix_data_science_benchmarks"
harness = false

# Commented out due to compilation errors
# [[bench]]
# name = "shared_session_performance"
# harness = false

[profile.dev]
opt-level = 0

[profile.release]
opt-level = "z"        # Optimize for size (not speed)
lto = "fat"           # Full link-time optimization (slower compile, smaller binary)
codegen-units = 1     # Single codegen unit for better optimization
strip = true          # Remove debug symbols
panic = "abort"       # Smaller panic handler (no unwinding)

# WASM QA Framework profiles (following spec)
[profile.coverage]
inherits = "test"
opt-level = 0
debug = 2
debug-assertions = true
overflow-checks = true
lto = false
panic = 'abort'
incremental = false
codegen-units = 1  # Deterministic coverage

# Separate profile for WASM testing
[profile.wasm-test]
inherits = "test"
opt-level = "s"  # Size optimization for faster browser loading
lto = true           # Enable Link Time Optimization
codegen-units = 1    # Single codegen unit for better optimization
strip = true         # Strip symbols for smaller size

[profile.release-dist]
inherits = "release"
strip = true           # Remove debug symbols
lto = "fat"           # Maximum link-time optimization
codegen-units = 1     # Single codegen unit for better optimization
panic = "abort"       # Smaller panic handler
opt-level = "z"       # Optimize for binary size
