How metr/hawk works
Purpose and entry points
Inspect-Hawk is an AWS-hosted platform for running Inspect AI evaluation grids and transcript scans at scale. Users submit YAML through the Python CLI; the API schedules isolated Kubernetes jobs, results are imported into PostgreSQL, and a React SPA exposes browsing/search/export. Main entry points: hawk/hawk/__main__.py, hawk/hawk/cli/cli.py, hawk/hawk/api/server.py, hawk/hawk/runner/entrypoint.py, and Pulumi infra/__main__.py.
Submission, API, and authorization
The CLI authenticates, validates/submits eval-set or scan configurations, monitors jobs, and supports local execution. The FastAPI-style API owns request validation, job creation, Helm/Kubernetes launch, status/log/result endpoints, human workflows, and presigned artifact access. Authorization is a cross-cutting boundary: JWT/access-token checks and model-group permissions protect submission, logs, warehouse data, and files.
Paths: hawk/hawk/cli/eval_set.py, hawk/hawk/api/run.py, hawk/hawk/api/auth/permission_checker.py.
Evaluation execution plane
API-created Kubernetes jobs run the runner image. The runner establishes credentials, observability, resource/stop monitors, creates a per-job environment, and invokes Inspect evaluation or scan execution. Evaluation sandboxes are separate pods and are governed by network policies; lifecycle/checkpoint/approval logic supports interruption and human-gated work.
Paths: hawk/hawk/runner/run_eval_set.py, hawk/hawk/runner/run_scan.py, hawk/hawk/api/helm_chart/templates/job.yaml.
LLM mediation services
Runner pods call Middleman rather than providers directly. Middleman authenticates callers, selects permitted model/provider configuration, manages provider keys and token/cost/rate-limit behavior, proxies OpenAI-compatible and provider-specific requests, and emits telemetry. It integrates with OpenAI, Anthropic, OpenRouter, and Google/Vertex-related implementations.
Paths: middleman/src/middleman/server.py, middleman/src/middleman/lab_apis/, middleman/src/middleman/provider_key_store.py.
Log ingestion and warehouse
Inspect writes eval logs/artifacts to S3. Event-driven services read/import logs and job status into Aurora PostgreSQL, converting eval and scan records via PostgreSQL-specific writers. The warehouse is the durable query boundary, with Alembic migrations, row-level security infrastructure, indexed full-text/trigram search, and model-group access enforcement.
Paths: hawk/hawk/core/importer/eval/importer.py, hawk/hawk/core/importer/scan/importer.py, hawk/hawk/core/db/models.py.
Query, viewer, and artifacts
API routes serve eval sets, samples, timelines, searches, scans, usage, and artifacts from the warehouse/S3. The Vite/React viewer calls these APIs, supports OAuth/session handling, result exploration, transcript search, timelines, jobs, scans, and artifact rendering. Static viewer deployment is separate from the API runtime.
Paths: hawk/hawk/api/transcript_search_router.py, hawk/www/src/AppRouter.tsx, hawk/www/src/components/SampleExplorer.tsx.
Cloud runtime and operations
Pulumi defines the AWS system: VPC/ALB/DNS, ECS Fargate API/Middleman/viewer services, EKS with Karpenter capacity, Aurora PostgreSQL Serverless, S3, EventBridge/Lambda processing, Cognito, and supporting Valkey/monitoring integrations. Datadog, CloudWatch, OpenTelemetry/X-Ray-related code provide metrics, logs, traces, dashboards, alarms, and dead-letter monitoring.
Paths: infra/hawk/api.py, infra/hawk/runner.py, infra/hawk/eventbridge.py.
Key control flow
hawk eval-set → API auth/config validation → Helm job on EKS → runner/sandbox execution and Middleman LLM calls → S3 logs → EventBridge/Lambda import → Aurora results → API → browser viewer. Scan submission follows the same control plane but reads historical transcripts and persists structured scan results.
Main entry points: api/server.py Hawk API · run_eval_set.py Evaluation runner · middleman/server.py Middleman · models.py Aurora PostgreSQL
Components 19
Clients
- Python CLI · Authenticates, validates YAML, submits work, and monitors jobs.
hawk/hawk/cli/eval_set.py - React viewer · Browses evaluations, scans, timelines, search, and artifacts.
hawk/www/src/AppRouter.tsx
Control plane
- Hawk API · Validates requests, creates jobs, and serves results and artifacts.
hawk/hawk/api/server.py - Authorization · Protects submission, logs, warehouse data, and files.
hawk/hawk/api/auth/permission_checker.py - Kubernetes job launcher · Creates isolated runner jobs on EKS.
hawk/hawk/api/helm_chart/templates/job.yaml
Execution plane
- Evaluation runner · Establishes job environment and runs evaluations or scans.
hawk/hawk/runner/run_eval_set.py - Scan execution · Runs transcript scans and produces structured scan records.
hawk/hawk/runner/run_scan.py - Evaluation sandboxes · Network-governed pods for Inspect evaluation sandboxes.
- Middleman · Authenticates callers and selects permitted provider/model configuration.
middleman/src/middleman/server.py - Provider key store · Manages provider keys, costs, tokens, and rate limits.
middleman/src/middleman/provider_key_store.py - LLM providers · OpenAI, Anthropic, OpenRouter, and Google/Vertex providers.
Data and query
- S3 logs and artifacts · Durable Inspect logs and generated artifacts.
- Event import pipeline · Imports emitted logs and job status into the warehouse.
infra/hawk/eventbridge.py - Evaluation importer · Converts evaluation logs into PostgreSQL records.
hawk/hawk/core/importer/eval/importer.py - Scan importer · Converts scan output into structured warehouse records.
hawk/hawk/core/importer/scan/importer.py - Aurora PostgreSQL · Durable query boundary with search and model-group enforcement.
hawk/hawk/core/db/models.py - Transcript search routes · Serves transcript search from the warehouse.
hawk/hawk/api/transcript_search_router.py
Cloud operations
- AWS runtime · Hosts API, Middleman, viewer, and runner capacity.
infra/hawk/api.py - Runner infrastructure · Defines EKS runner deployment and capacity integration.
infra/hawk/runner.py
Connections 26
- Python CLI → Hawk API: submit eval-set or scan
- React viewer → Hawk API: query and render results
- Hawk API → Authorization: authorize requests
- Hawk API → Kubernetes job launcher: create job
- Kubernetes job launcher → Evaluation runner: launch eval job
- Kubernetes job launcher → Scan execution: launch scan job
- Evaluation runner → Evaluation sandboxes: run Inspect sandboxes
- Evaluation runner → Middleman: LLM requests
- Scan execution → Middleman: LLM requests
- Middleman → Provider key store: resolve credentials and limits
- Middleman → LLM providers: proxy provider calls
- Evaluation runner → S3 logs and artifacts: write eval logs and artifacts
- Scan execution → S3 logs and artifacts: write scan results
- S3 logs and artifacts → Event import pipeline: object events
- Event import pipeline → Evaluation importer: evaluation logs
- Event import pipeline → Scan importer: scan logs
- Evaluation importer → Aurora PostgreSQL: persist evaluation records
- Scan importer → Aurora PostgreSQL: persist scan records
- Hawk API → Aurora PostgreSQL: results, jobs, and usage queries
- Hawk API → S3 logs and artifacts: presigned artifact access
- Hawk API → Transcript search routes: mount search endpoint
- Transcript search routes → Aurora PostgreSQL: full-text transcript search
- AWS runtime → Hawk API: hosts
- AWS runtime → Middleman: hosts
- AWS runtime → React viewer: deploys static viewer
- Runner infrastructure → Evaluation runner: provides EKS capacity