# Pre-commit hooks configuration for NexQuant
# See https://pre-commit.com for more information

repos:
  # ── Test Coverage Check: new modules must have tests ──────────────
  - repo: local
    hooks:
      - id: check-test-coverage
        name: Check new rdagent modules have tests
        entry: python scripts/check_test_coverage.py
        language: system
        pass_filenames: false
        always_run: true

  # ── MyPy Ratchet: no new type errors allowed ────────────────────
  - repo: local
    hooks:
      - id: mypy-ratchet
        name: MyPy ratchet (no new type errors)
        entry: python scripts/check_mypy_ratchet.py
        language: system
        pass_filenames: false
        always_run: true

  # ── Qlib Unit Tests (MANDATORY) ──────────────────────────────────
  - repo: local
    hooks:
      - id: qlib-unit-tests
        name: Qlib Unit Tests (~490 tests)
        entry: pytest
        language: system
        args:
          - test/qlib/
          - test/backtesting/
          - -v
          - --tb=short
          - --cov=rdagent
          - --cov-fail-under=33
          - --cov-report=term
          - --ignore=test/backtesting/test_ftmo_oos.py
          - --ignore=test/backtesting/test_kronos_adapter.py
          - --ignore=test/qlib/test_fin_quant_integration.py
        pass_filenames: false
        always_run: true

  # ── Security Scanning (MANDATORY) ─────────────────────────────────
  - repo: local
    hooks:
      - id: bandit-security-scan
        name: Bandit Security Scan
        entry: bandit
        language: system
        args:
          - -r
          - rdagent/
          - -c
          - .bandit.yml
          - --severity-level=medium
          - --confidence-level=medium
          - --format=txt
        pass_filenames: false
        always_run: true
