.PHONY: install build test test-full verify-counts lint fmt clean generate

VENV := .venv
PYTHON := $(VENV)/bin/python

$(VENV):
	python3 -m venv $(VENV)
	$(PYTHON) -m pip install --upgrade pip
	$(PYTHON) -m pip install -e ".[dev]"

install: $(VENV)

build:
	uv build
	@echo "build: OK — dist/ now contains the wheel (and sdist)"

# H3-GAP-087 — this repo polices its own count prose: canonical counts
# (scripts/test-count.txt) → live pytest collection parity → battery parity
# against the sibling shim checkout → stale-literal sweep with explicit
# historical exemptions. Exit 0 pass / 1 drift / 2 guard misconfigured.
verify-counts:
	sh scripts/check-test-count.sh

test:
	uv run pytest -x --tb=short -q

test-full:
	uv run pytest -x -v

lint:
	uv run ruff check src/ tests/

fmt:
	uv run ruff format src/ tests/

clean:
	rm -rf $(VENV) __pycache__ src/h3_harness/__pycache__
	find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
	find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true

all: verify-counts install lint build test

generate:
	uv run python scripts/generate-protocol.py
	uv run ruff check --fix src/h3_harness/protocol.py
	uv run ruff format src/h3_harness/protocol.py
