[package]
name = "telltale"
version = "4.0.1"
authors = ["Zak Cutner <me@zakcutner.uk>", "Sam Hart <sam@hxrts.com>"]
edition = "2021"
rust-version = "1.75"
description = "Session types for multi-party asynchronous communication."
readme = "README.md"
repository = "https://github.com/hxrts/telltale"
license = "MIT"
keywords = ["async", "deadlock", "safety", "session", "types"]
categories = ["asynchronous", "concurrency"]

[lib]
bench = false
path = "rust/src/lib.rs"

[[test]]
name = "message_tests"
path = "rust/tests/message_tests.rs"

[[test]]
name = "role_tests"
path = "rust/tests/role_tests.rs"

[[test]]
name = "seal_tests"
path = "rust/tests/seal_tests.rs"

[[test]]
name = "session_tests"
path = "rust/tests/session_tests.rs"

[lints]
workspace = true

[dependencies]
futures = { workspace = true }
time = { workspace = true }
base64 = { workspace = true }
hex = { workspace = true }
telltale-macros = { path = "rust/macros", version = "4.0.1" }
telltale-types = { path = "rust/types", version = "4.0.1" }
telltale-theory = { path = "rust/theory", version = "4.0.1", optional = true }
thiserror = { workspace = true }
anyhow = { workspace = true }
async-trait = { workspace = true }
serde = { workspace = true, features = ["derive"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { workspace = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = { workspace = true }
wasm-bindgen-futures = { workspace = true }
wasm-timer = { workspace = true }
getrandom = { workspace = true }
serde = { workspace = true, features = ["derive"] }
uuid = { workspace = true }
tracing = { workspace = true }
bincode = { workspace = true }
# Dependencies for choreography module
proc-macro2 = { workspace = true }
quote = { workspace = true }
syn = { workspace = true }
# Optional dependencies
rand = { workspace = true, optional = true }

[dev-dependencies]
criterion = { workspace = true }
futures = { workspace = true, features = ["thread-pool"] }
num-complex = "0.4"
rand = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt", "time"] }
proptest = { workspace = true }
anyhow = { workspace = true }
tracing-subscriber = { workspace = true }
# For examples
telltale-theory = { path = "rust/theory", version = "4.0.1" }
serde_json = { workspace = true }

[features]
default = []

# Testing utilities (random generation, etc.)
test-utils = ["rand"]

# WebAssembly support
wasm = ["getrandom/js"]

# Session type theory algorithms (projection, merge, duality, etc.)
theory = ["telltale-theory"]

# Granular theory features (require theory feature)
theory-async-subtyping = ["theory", "telltale-theory/async-subtyping"]
theory-bounded = ["theory", "telltale-theory/bounded"]

# All optional features
full = [
    "theory",
    "theory-async-subtyping",
    "theory-bounded",
]

[profile.release]
debug = true

[profile.bench]
debug = true

[profile.perf-cpu]
inherits = "release"
debug = 1
lto = "thin"
codegen-units = 1
incremental = false
strip = "none"

[profile.perf-heap]
inherits = "release"
debug = 1
lto = "off"
codegen-units = 1
incremental = false
strip = "none"

[profile.perf-debug]
inherits = "dev"
opt-level = 1
debug = 2
incremental = false

[workspace]
members = ["rust/macros", "rust/choreography", "rust/types", "rust/theory", "rust/lean-bridge", "rust/vm", "rust/simulator", "rust/effect-scaffold", "rust/transport"]
exclude = ["examples/wasm-ping-pong", "external-demo", "external-demo-macros"]

# Shared dependencies across workspace members
[workspace.dependencies]
# Core async/concurrency
futures = "0.3"
tokio = { version = "1.35", features = ["full"] }
async-trait = "0.1"
async-recursion = "1.0"

# WASM support
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
wasm-timer = "0.2"
getrandom = { version = "0.2", features = ["js"] }

# Serialization
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.9"
bincode = "1.3"
time = { version = "0.3", features = ["serde"] }
base64 = "0.21"
hex = "0.4"
uuid = { version = "1.6", features = ["v4", "serde", "js"] }

# Error handling
thiserror = "1.0"
anyhow = "1.0"

# Proc macros
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "2.0", features = ["full", "extra-traits"] }

# Logging/tracing
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

# Utilities
cfg-if = "1.0"
rand = "0.8"
rand_chacha = "0.3"
regex = "1.10"
lazy_static = "1.4"
toml = "0.8"
sha2 = "0.10"
parking_lot = "0.12"
fixed = { version = "1.27", default-features = false, features = ["std"] }

# Parsing
pest = "2.7"
pest_derive = "2.7"

# Testing
criterion = { version = "0.3", features = ["html_reports"] }
proptest = "1.4"
tempfile = "3.2"
assert_matches = "1.5"

# ============================================================================
# Workspace Lints
# ============================================================================

[workspace.lints.rust]
# Safety: error handling
unused_must_use = "deny"
# unused_results = "warn"  # Enable when ready

# Clarity
missing_docs = "warn"
unreachable_pub = "warn"

[workspace.lints.clippy]
# === SAFETY: Error Handling ===
# Style guide: Never ignore a Result
let_underscore_must_use = "deny"
must_use_candidate = "warn"

# === SAFETY: Documentation ===
# Style guide: Comments explain rationale, constraints, and invariants
missing_safety_doc = "deny"
missing_errors_doc = "warn"
missing_panics_doc = "warn"

# === SAFETY: Type Correctness ===
# Style guide: Prefer explicitly-sized integers
as_conversions = "warn"
cast_possible_truncation = "warn"
cast_sign_loss = "warn"
cast_possible_wrap = "warn"

# === APIS: Usability ===
# Style guide: Avoid bool parameters, use enums
fn_params_excessive_bools = "warn"

# === PERFORMANCE: Memory ===
# Style guide: Allocate intentionally
vec_init_then_push = "warn"
large_stack_arrays = "warn"
inefficient_to_string = "warn"
needless_collect = "warn"

# === CLARITY: Function Shape ===
# Style guide: Keep functions small enough to fit on one screen
too_many_arguments = "warn"
too_many_lines = "warn"
cognitive_complexity = "warn"
needless_pass_by_value = "warn"
trivially_copy_pass_by_ref = "warn"

# === INTENTIONALLY ALLOWED ===
# These are permitted project-wide
module_name_repetitions = "allow"

# Note: unwrap_used and expect_used are controlled per-crate:
# - Library crates: should deny (use proper error handling)
# - Test/example code: may allow (convenience)
