name: checker check

# Builds and lints the Rust implementation crates under crates/ (the rule-based
# checker that "stands in Lean's position" at product runtime).
#
# Like spec-check, this is an INTERNAL gate on the implementation's own health
# (does it build, pass its tests, satisfy clippy + rustfmt?). It is NOT a
# spec-to-implementation conformance gate — implementations align to the Lean
# contract by human review, not by CI. See the repo README.

on:
  push:
  pull_request:
  workflow_dispatch:

jobs:
  checker-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      # Keep local rustup, rustfmt output, clippy, and CI on one reproducible
      # compiler release. Update this together with rust-toolchain.toml.
      - name: Install Rust toolchain (1.92.0 + clippy + rustfmt)
        uses: dtolnay/rust-toolchain@1.92.0
        with:
          components: clippy, rustfmt

      - name: Cache cargo registry + build
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: cargo-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            cargo-${{ runner.os }}-

      - name: Install cargo-audit 0.22.2
        run: cargo install cargo-audit --version 0.22.2 --locked

      - name: Audit Rust vulnerabilities and unsoundness
        run: cargo audit --deny unsound

      # Fonts for typst compilation (WU-4 onward): the engineering files are
      # CJK-heavy, so the compile-check / build tests need a CJK font present.
      # Harmless before those crates exist.
      - name: Install CJK fonts
        run: |
          sudo apt-get update
          sudo apt-get install -y fonts-noto-cjk

      - name: Format check
        run: cargo fmt --all --check

      - name: Clippy (deny warnings)
        run: cargo clippy --all-targets --all-features -- -D warnings

      - name: Test
        run: cargo test --all-features --workspace
