.PHONY: test forecast variance control-cycle exchange-forecast exchange-usage optimization portfolio-report settlement capability consumption-mode thresholds

test:
	python3 -m unittest discover -s tests -p 'test_*.py'
	python3 tools/validate.py

forecast:
	python3 tools/cost_model.py data/demand/platform-audit-storage.json data/providers/object-storage.json

variance:
	@test -n "$(ACTUAL)" || { echo 'ACTUAL=data/actuals/YYYY-MM.json is required' >&2; exit 2; }
	python3 tools/variance.py data/forecasts/platform-audit-storage-scaleway-base-2026-08.json $(ACTUAL)

control-cycle:
	@test -n "$(FORECAST)" -a -n "$(ACTUAL)" || { echo 'FORECAST=... ACTUAL=... are required' >&2; exit 2; }
	python3 tools/control_cycle.py $(FORECAST) $(ACTUAL)

exchange-forecast:
	python3 tools/financial_exchange.py forecast data/forecasts/platform-audit-storage-scaleway-base-2026-08.json

exchange-usage:
	@test -n "$(ACTUAL)" || { echo 'ACTUAL=data/actuals/YYYY-MM.json is required' >&2; exit 2; }
	python3 tools/financial_exchange.py usage $(ACTUAL) resource:platform:audit-storage

thresholds:
	@test -n "$(PERIOD)" || { echo 'PERIOD=YYYY-MM is required' >&2; exit 2; }
	python3 tools/thresholds.py data/thresholds/platform-audit-storage.json \
	  data/actuals/$(PERIOD).json $(PERIOD) \
	  data/forecasts/platform-audit-storage-scaleway-base-2026-08.json

optimization:
	python3 tools/optimization.py $(CASE)

portfolio-report:
	python3 tools/portfolio_report.py .

capability:
	python3 tools/capability.py

consumption-mode:
	@test -n "$(PERIOD)" || { echo 'PERIOD=YYYY-MM is required' >&2; exit 2; }
	python3 tools/settlement.py consumption-mode --period $(PERIOD) \
	  > data/consumption-mode/current.json
	@echo "wrote data/consumption-mode/current.json for $(PERIOD)"

settlement:
	@test -n "$(PERIOD)" || { echo 'PERIOD=YYYY-MM is required' >&2; exit 2; }
	python3 tools/settlement.py close --period $(PERIOD)
