name: Lint — undefined names

# High-signal static gate for the bug class behind PR #249 (case-rename 500):
# a name referenced but never imported/defined. Invisible to tests when it sits
# in a rarely-hit branch or a fire-and-forget background task — it only
# NameErrors at runtime. pyflakes catches it before merge. Gates ONLY on
# undefined names (not unused imports / f-strings — those are noise). Uses a
# throwaway venv so it is immune to PEP-668 externally-managed environments.

on:
  pull_request:
    branches: [main]
  push:
    branches: [main]

jobs:
  undefined-names:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Run undefined-name guard
        run: |
          python3 -m venv /tmp/lintvenv
          /tmp/lintvenv/bin/pip install --quiet pyflakes==3.4.0
          /tmp/lintvenv/bin/python scripts/check_undefined_names.py
