# One command surface (InnerLoop §agentic-efficiency #3). Deterministic,
# greppable output; precursor of the `cb` CLI.

CARGO := cargo

.PHONY: check test sim bench bench-test coverage dep-weight loc all

## fmt + clippy (deny warnings) + HashMap deny-lint
check:
	$(CARGO) fmt --all --check
	$(CARGO) clippy --workspace --all-targets -- -D warnings

## unit + scenario-format tests
test:
	$(CARGO) test --workspace

## run all GROUND scenarios through cb-sim
dep-weight:
	python3 tools/dep-weight.py

coverage:
	python3 tools/rule-coverage.py

sim:
	$(CARGO) run -q -p cb-sim -- scenarios/ground/*.yaml

## Criterion benches (AM-6/AM-7)
bench:
	$(CARGO) bench -p games-ground

## InnerLoop positive control: run every bench once, no measurement.
## Fails if a workload stalls or produces the wrong event count.
bench-test:
	$(CARGO) bench -p games-ground --bench synthetic -- --test


## AM-2/AM-3 input: source LOC per crate (excludes tests would need tokei)
loc:
	@for d in crates/cb-kernel crates/cb-events crates/cb-game-runtime games/ground tools/cb-sim; do \
		printf '%-28s %s\n' $$d "$$(find $$d/src -name '*.rs' | xargs cat | grep -vcE '^\s*(//|$$)')"; \
	done

all: check test sim coverage dep-weight bench-test
