Skip to content

The platform for continuously improving AI agents.

4.3 KB
Raw Blame
.PHONY: test test-serial test-journeys test-load lint-format lint-backend lint-frontend install-hooks psql worker research-agent workshop-agent research-image sandbox check-migrations collector collector-migrate collector-test up

install-hooks:
	uv run pre-commit install

# Local celery worker (macOS). --pool=solo because forking after the httpx Modal
# warmup copies locked mDNS/getaddrinfo state into the child and SIGSEGVs. Solo
# is concurrency 1, so a long landing or script run blocks everything else locally.
# -Q lists every queue: this one process stands in for the whole compose fleet.
# Data Workshop scripts need `make sandbox` running and SANDBOX_URL=http://127.0.0.1:8080
# with the same SANDBOX_TOKEN in .env.
worker:
	OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES \
		uv run celery -A overbae worker -l info --pool=solo -n local@%h \
		-Q control,io,assistant,io_traces,batch,landing,interactive

# Temporal workers for research and Workshop agents; they need a Temporal server
# (`temporal server start-dev`, or compose's `temporal` service).
research-agent:
	uv run python manage.py research_agent_worker

workshop-agent:
	uv run python manage.py workshop_agent_worker

# The image a local research executor runs (RESEARCH_EXECUTOR=docker).
research-image:
	docker build -f docker/research/Dockerfile -t overmind-research:local .

# Runs scripts as your own user: no isolation, local development only.
sandbox:
	SANDBOX_ALLOW_SHARED_UID=1 uv run --env-file .env python -m sandbox --host 127.0.0.1

lint-format:
	$(MAKE) --no-print-directory -j2 lint-backend lint-frontend

lint-backend:
	uv run ruff check --fix
	uv run ruff format

lint-frontend:
	bun run --cwd frontend biome check --fix
	bun run --cwd frontend typecheck

psql:
	docker compose exec postgres psql -U overbae -d overbae

# Collector on the host, 0.0.0.0:4318. Compose Postgres must already be up.
collector:
	DATABASE_URL=$${DATABASE_URL:-postgresql://overbae:[email protected]:5432/overbae} \
	DJANGO_SECRET_KEY=$${DJANGO_SECRET_KEY:-change-me-in-production} \
	OTEL_LISTEN_ADDR=$${OTEL_LISTEN_ADDR:-0.0.0.0:4318} \
	cargo run -p server

# Migrate existing Postgres spans and signal data into per-project DuckDB files.
collector-migrate:
	DATABASE_URL=$${DATABASE_URL:-postgresql://overbae:[email protected]:5432/overbae} \
	DATA_DIR=$${DATA_DIR:-.} \
	cargo run -p server -- migrate-from-postgres $(ARGS)

collector-test:
	cargo test --workspace

# API, Console, workers, sandbox, Grafana, and the collector.
up:
	docker compose up -d --build

# CI passes MIGRATIONS_BASE=HEAD^1 (the merge commit's base); locally, origin/main.
MIGRATIONS_BASE ?= origin/main

check-migrations:
	DJANGO_SETTINGS_MODULE=tests.settings uv run python manage.py makemigrations --check --dry-run
	uv run python scripts/check_migrations.py $(MIGRATIONS_BASE)

clean:
	docker compose down -v

schema:
	DJANGO_DEBUG=True uv run python manage.py spectacular --file openapi.yaml --validate

generate_api_client: schema
	rm -rf frontend/src/openapi/docs frontend/src/openapi/models frontend/src/openapi/apis
	docker run --rm --user $$(id -u):$$(id -g) -e HOME=/tmp -v $(PWD):/workspace \
		openapitools/openapi-generator-cli:v7.19.0 generate \
		-i /workspace/openapi.yaml \
		-g typescript-fetch \
		-o /workspace/frontend/src/openapi \
		--additional-properties=typescriptThreePlus=true,supportsES6=true,enumPropertyNaming=original
	python3 -c "import pathlib; [p.write_text('\n'.join(l.rstrip(' \t') for l in p.read_text().split('\n')).rstrip('\n') + '\n') for p in pathlib.Path('frontend/src/openapi').rglob('*.ts')]"
	rm openapi.yaml

# Number of parallel workers (auto = number of CPUs)
WORKERS ?= auto
test_args ?=

test: ## Run all tests in parallel (default)
	uv run pytest tests/ -m 'not load' -n $(WORKERS) --dist worksteal -q $(test_args)

test-serial: ## Run all tests serially (for debugging)
	uv run pytest tests/ -v $(test_args)

test-journeys: ## Run end-to-end journeys on the live stack (needs compose Postgres and Redis)
	TEST_REDIS_URL=redis://localhost:6379/15 OVERMIND_JOURNEY_XDIST=1 \
		uv run pytest tests/journeys -m 'not load' -n $(WORKERS) --maxprocesses 6 --dist loadfile -v -o console_output_style=count --durations=10 $(test_args)

test-load: ## Run the capacity checks with wall-clock bounds (needs compose Postgres and Redis)
	TEST_REDIS_URL=redis://localhost:6379/15 uv run pytest tests/journeys tests/test_dataset_scale.py -m load -v $(test_args)