Contributing¶
Developer Setup¶
There are two ways to run Hawk locally. Choose the workflow that matches the change you're making:
- Full Dev Stack for API and viewer development with live reload. Use this for most application and frontend work.
- Local Minikube Setup for the complete local platform, including MinIO, PostgreSQL, the API, and eval runners on Minikube. Use this when the change affects how evals actually execute.
Commit signing¶
All commits to this repo must be signed. Set up SSH commit signing once (global config applies to every clone and worktree):
git config --global commit.gpgsign true
git config --global gpg.format ssh
# point at your SSH public key (this is the common default path)
git config --global user.signingkey ~/.ssh/id_ed25519.pub
Then add that same public key to GitHub as a Signing Key (Settings → SSH and GPG keys → New SSH key → key type "Signing Key"). A key added only as an Authentication key still signs locally but won't show as Verified on GitHub.
Confirm a commit is signed with git cat-file -p <sha> (look for a gpgsig
header) or git log --show-signature; on GitHub it shows a "Verified" badge.
Full Dev Stack: API, Viewer, Live Reload¶
For developing with hot reload across the full stack:
Terminal 1: Viewer Dev Server¶
Terminal 2: API Server¶
Run from the repo root:
# Point an env file at a deployed stack (DB, S3, OIDC, etc.):
uv run python scripts/dev/generate-env.py <stack> --api > hawk/.env
# ...or, for fully local development: cp hawk/.env.example hawk/.env
scripts/dev/api # serves http://localhost:8080 with live reload
scripts/dev/api loads hawk/.env (override with HAWK_ENV_FILE) and runs the
server in the app's project env. Extra args pass through to fastapi dev, e.g.
scripts/dev/api --port 9000.
Optional: Embedded Viewer Library Watch Mode¶
Hawk consumes packaged Inspect AI and Inspect Scout viewers, so ordinary Hawk
frontend development does not require either repository. If a change is inside
one of those embedded viewer libraries, follow the
cross-repository setup.
It covers cloning the relevant repository at the revision pinned by Hawk,
initializing its ts-mono submodule, and temporarily linking the local viewer
package into hawk/www.
Code Quality¶
Linting and type checking are defined by the repo's pre-commit hooks (.pre-commit-config.yaml). CI's Lint job runs the same hooks, so run them locally rather than invoking the tools by hand.
Install pre-commit:
uv tool install pre-commit --with pre-commit-uv
pnpm --dir hawk/www install # once, so the eslint/prettier/tsc hooks can run
Run linting + type checks (requires all python and js toolchains to be installed locally):
Unit tests are not part of the hooks — run pytest in the package you're changing (see Testing).
The Ruff hooks run uv run --locked ruff from the repository root, so local
hooks and CI use the version in the root uv.lock. Each directory still uses
its own lint configuration. To upgrade Ruff, run uv lock --upgrade-package ruff
from the root, then run the hooks above.
Previewing Documentation¶
From the repository root, start the documentation site with live reload and open it in your browser:
The preview is served at http://localhost:8000/ and automatically rebuilds
when files under docs/ or properdocs.yml change.
Frontend API types¶
The viewer's API types (hawk/www/src/api.gen.d.ts) are generated from the
backend's OpenAPI schema, not hand-maintained. After a backend change that
touches the API surface, regenerate and commit:
The www-api-types pre-commit hook (run locally and by CI's Lint job) fails
when the committed file is stale.
Testing Runner Changes¶
Most runner changes can be tested against the local Minikube stack without
Pulumi or AWS. With Minikube running (see
Local Minikube Setup), rebuild the runner under a new
tag and submit an eval to the local API. Run these commands from hawk/:
IMAGE_TAG=my-tag
RUNNER_IMAGE_NAME=localhost:5000/runner \
PYTHON_BASE_IMAGE=python:3.13-slim-trixie@sha256:cf50a4f6ac4f026458b08d5222023d700ac806410dff5e9ca8728fa44f2b850f \
../scripts/dev/build-and-push-runner-image.sh "$IMAGE_TAG"
HAWK_API_URL=http://localhost:8080 \
hawk eval-set examples/simple.eval-set.yaml --image-tag "$IMAGE_TAG"
The real runner uses the model configured in the eval set, so configure its
provider key in hawk/.env before starting the local stack.
To test against a deployed dev stack instead, push the image to that stack's ECR and submit the eval to the same stack:
# From the repository root, after `pulumi login` to the deployment's S3
# backend and authenticating AWS and Docker to the stack's ECR:
export AWS_PROFILE="<profile-for-the-target-account>"
export PULUMI_FALLBACK_TO_STATE_SECRETS_MANAGER=true
export STACK="dev-<name>"
IMAGE_TAG=my-tag
ENVIRONMENT="$(pulumi stack output env -s "$STACK")"
AWS_REGION="$(pulumi stack output region -s "$STACK")"
(
cd hawk
PULUMI_STACK="$STACK" \
ENVIRONMENT="$ENVIRONMENT" AWS_REGION="$AWS_REGION" \
../scripts/dev/build-and-push-runner-image.sh "$IMAGE_TAG"
)
# Pin the CLI's API, Middleman, and viewer URLs to the same stack.
uv run python scripts/dev/generate-env.py "$STACK" > .env
hawk login # use --no-browser in a headless environment
hawk eval-set hawk/examples/simple.eval-set.yaml --image-tag "$IMAGE_TAG"
Local Minikube Setup¶
This runs Hawk entirely locally. It uses MinIO for S3, local PostgreSQL, a local Docker registry, and Minikube for Kubernetes. This is the same setup used by E2E tests in CI.
Prerequisites¶
You must be inside the devcontainer, which includes minikube, Docker-in-Docker, cilium, kubectl, helm, and gvisor.
Quick Start¶
These commands are run from the hawk/ directory:
The script will:
- Start Minikube with gvisor, containerd, and an insecure local registry
- Create Kubernetes resources and install Cilium
- Launch services (API server, Middleman, MinIO, PostgreSQL, Docker registry)
- Verify cluster access to the registry and configure MinIO
- Build and push dummy and real runner images
- Log in through the bundled Dex provider and run a simple eval set
Middleman reads its models from the local PostgreSQL, like a deployed stack.
After migrations, the middleman-seed service registers mockllm/model,
gpt-4o-mini, gpt-4o, claude-3-5-sonnet-20241022 and the dead dead-model in the
model-access-public group from hawk/docker/middleman-seed.sql. It only adds
missing rows, so local edits survive restarts. To add a model, append it to that
file and run docker compose run --rm middleman-seed && docker compose restart middleman.
Running Evals Locally¶
Run k9s to monitor the Inspect pod.
For rebuilding and selecting a real runner image after code changes, see Testing Runner Changes.
Updating Dependencies (Inspect AI / Inspect Scout)¶
Use the prepare-release.py script:
# Update to a specific PyPI version
scripts/ops/prepare-release.py --inspect-ai 0.3.50
# Update to a specific git commit SHA
scripts/ops/prepare-release.py --inspect-ai abc123def456
# Update Scout
scripts/ops/prepare-release.py --inspect-scout 0.2.10
The script updates pyproject.toml files and runs uv lock. Unless you pass --no-commit, it creates a local release branch and commits the bumps. It pushes a release branch to the upstream fork only when the pin is a git SHA, so that commit can be fetched. A PyPI version does not get that pushed branch. It publishes npm packages when a viewer package needs a build.
For a git SHA it also builds the fork's wheel, attaches it to a release on the METR fork, and pins that wheel's URL rather than the git commit, so installs download one wheel instead of cloning the fork. That needs gh logged in with push access to the fork. Afterwards, run scripts/dev/uv-lock-all.sh to update every lock file. To move a commit that is already pinned as a git source to its wheel, pass --wheel-only, which skips the viewer build and leaves package.json alone. CI rebuilds each pinned wheel from its commit and fails if the files differ. To change what the METR forks carry, see Inspect AI and Scout Forks.
Bumping inspect-ai also moves what runner jobs get. The runner builds a fresh
venv per job, and that venv is pinned to the same inspect-ai hawk itself is
running — read from package metadata, which in a deployed runner is the
uv sync --locked result baked into the image. Until you bump, jobs stay on the
pinned version even if a newer one ships upstream.
That pin is a hard constraint, not a preference: a task or scanner package that
requires a newer inspect-ai makes the venv unresolvable, and the job fails at
install rather than silently upgrading. So the staleness of this pin is
user-visible — if people start hitting no version of inspect-ai==<pinned>,
that is the signal to bump. Users can opt out per-config via packages: (see
Overriding inspect-ai or inspect-scout).
Cutting a maintenance release¶
release-please cuts every release from main. A patch for an older line (say
3.7.4 while main is on 4.x) is cut by hand from that line's release/X.Y.x
branch, then tagged by the release-maintenance workflow. Only the release
GitHub App may create tags in this repository, so you can't push the tag or
run gh release create yourself.
Warning
Once approved, a run publishes at once: it publishes the hawk package to
PyPI and pushes the viewer plug-in base image, and posts to the
announcements Slack channel if the branch's release-announce.yml lacks
the guard from step 5. A tag can't be deleted or moved afterwards.
A release/* branch takes pushes without a pull request, so the approval is
the release commit's only review. Once the run's checks pass, it waits in the
release-maintenance environment for a member of hawk-reviewers other
than the person who dispatched it. The workflow's checks show the commit is well-formed, not
that its changes are right: the approver reads the commits since the
previous release before approving.
- Land the fixes on
release/X.Y.x(create it from the line's last tag if it doesn't exist). Give each afix:subject, as onmain. - Add a release commit on top, with the subject
chore: release X.Y.Z, that makes the changes a release-please release PR makes on that line:- the version in
.release-please-manifest.json; - the version in every file under
extra-filesin the branch's ownrelease-please-config.json:hawk/pyproject.tomland thehawkentry in everyuv.lock, plus, on lines that list them, the Middleman, relay and viewer versions; - a
## [X.Y.Z]entry at the top ofhawk/CHANGELOG.md, in the format of the entries below it. It becomes the release notes.
- the version in
- Push the branch. The release commit must be signed and show as Verified on GitHub.
- Compare the
environmentthatpublish-pypi.ymlnames on the branch with the one it names onmain. If they differ, ask a PyPI project owner whether the trusted publisher still accepts the branch's, or the PyPI publish fails. - The release runs the workflow files at the release commit. Check these two
there, and backport a missing guard first, so that the release commit
includes it:
viewer-plugin-base.ymladds the image'slatestand major tags only to the newest release (it asksreleases/latestand lists the major's tags). Otherwise the patch takes those tags from a newer release.release-announce.ymlskips a release whose version is lower than the onereleases/latestnames. Otherwise the patch is announced in Slack like a new release.
-
Run the checks yourself. This only reads:
-
Run the workflow from
mainwith the same tag and SHA, ask a reviewer to approve the run, and watch it:
The workflow refuses the release unless:
- the tag is a patch (
Zabove 0) lower than the latest release, and doesn't exist yet; - the commit is Verified, is on
release/X.Y.xand builds on the previous releasevX.Y.(Z-1); - the manifest and
hawk/pyproject.tomlcarry the version, and the changelog has its entry.
It then creates the tag and a GitHub Release that is not marked latest. If it fails after creating the tag, run it again with the same inputs: it reuses a tag that points at the same commit and has no release yet.
If the approved job stops at "Check the release App key is set", the
HAWK_RELEASE_APP_PRIVATE_KEY secret on the release-maintenance environment
is empty. A repository admin sets it by hand, once and again after each
rotation of the release App's key (METR's private infra-shared repository
says where the key is kept), piping the key to:
Nothing was tagged or published: re-run the failed job once the secret is set, and have it approved again.
Publishing the release starts three workflows, all run from the workflow files
at the tag, not the ones on main:
release-announce.ymlposts nothing to the announcements Slack channel, given the guard from step 5: its run says in a notice that a higher version is the latest release.publish-pypi.ymlpublishes thehawkpackage to PyPI. If it fails, the tag and the GitHub Release still stand. Its only trigger is the release, so once the cause is fixed, re-run the failed run from the Actions tab.viewer-plugin-base.ymlpusheshawk-viewer-plugin-baseasX.Y.Z, and asXwhen it is the newest release of that major.
Database Migrations¶
See Database for migration instructions.
Pull Requests¶
Unless you're on a METR team with access to this repository or on the qualified contributor list, a PR needs an accepted issue first: see the contribution policy.
When creating PRs, use the template at .github/pull_request_template.md. The template includes:
- Overview and linked issue
- Approach and alternatives considered
- Testing & validation checklist
- Agent review: AI tools used and what their review found
- Code quality checklist
- Before-merging checklist: signed/Verified commits and a Conventional-Commit title