# Chanora — local task runner.
#
# Conforms to docs/governance/repository-bootstrap-plan.md v0.1.0 §3,
# which requires a `justfile` with stubs for format / lint / test /
# verify-docs / security-scan.
#
# Install just: https://github.com/casey/just

default:
    @just --list

# ---------------------------------------------------------------------------
# Docs validation
# ---------------------------------------------------------------------------

# Run the documentation/traceability validator.
verify-docs:
    python3 tools/validate_docs.py

# ---------------------------------------------------------------------------
# Formatting
# ---------------------------------------------------------------------------

# Format every codebase in the repo that has a formatter wired up.
format:
    @echo "[format] Rust workspace"
    cargo fmt --package chanora_audio --package chanora_bridge --package chanora_core --package chanora_diagnostics --package chanora_protocol --package chanora_state --package chanora_storage
    @echo "[format] Flutter app"
    cd apps/chanora_flutter && dart format lib test

# ---------------------------------------------------------------------------
# Lint
# ---------------------------------------------------------------------------

# Run linters on every codebase that has them wired up.
lint:
    @echo "[lint] Rust workspace"
    cargo clippy --workspace --all-targets --all-features -- -W clippy::all
    @echo "[lint] Flutter app"
    cd apps/chanora_flutter && flutter analyze

# ---------------------------------------------------------------------------
# Test
# ---------------------------------------------------------------------------

# Run local test suites. Live/network tests remain explicitly ignored.
test:
    @echo "[test] Rust workspace"
    cargo test --workspace --all-targets --all-features
    @echo "[test] Flutter app"
    cd apps/chanora_flutter && flutter test

# ---------------------------------------------------------------------------
# Security scan
# ---------------------------------------------------------------------------

# Run the local dependency audit when cargo-audit is installed.
security-scan:
    @if command -v cargo-audit >/dev/null 2>&1; then \
        cargo audit; \
    else \
        echo "[security-scan] cargo-audit not installed; run: cargo install cargo-audit"; \
    fi
