Repository navigation
Pin kubernetes<36 to fix runner 401s against the K8s API - #448
Merged
Merged
Conversation
The kubernetes 36.0.0 client's Configuration.auth_settings() drops the BearerToken scheme, so requests using kubeconfig/in-cluster bearer tokens go out with no Authorization header and get 401. This broke inspect_k8s_sandbox in the runner pod (every list_namespaced_pod call failed) and would break the janitor on its next image build. Upstream: kubernetes-client/python#2582 Co-Authored-By: Claude Opus 4.7 <[email protected]>
rasmusfaber
had a problem deploying
to
prd-pulumi-preview
May 21, 2026 06:57 — with
GitHub Actions
Error
Regenerated via scripts/dev/uv-lock-all.sh so every lockfile that references hawk reflects the new requires-dist constraints. Co-Authored-By: Claude Opus 4.7 <[email protected]>
🍹
|
Contributor
There was a problem hiding this comment.
Pull request overview
Pins the Python kubernetes client to <36 for runner and janitor installs to avoid the kubernetes==36.0.0 auth regression that causes in-cluster Kubernetes API calls to be sent without an Authorization header (401s), restoring stable behavior until upstream fixes the issue.
Changes:
- Add
kubernetes<36to therunneroptional dependency set. - Add
<36upper bound to the existingjanitorkubernetes requirement. - Update
uv.lockso resolution lands onkubernetes==35.0.0and reflects the new optional dependency constraints.
Reviewed changes
Copilot reviewed 1 out of 10 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
hawk/pyproject.toml |
Adds explicit <36 pin for kubernetes in runner and tightens janitor to <36. |
hawk/uv.lock |
Updates locked metadata to include the new runner/janitor constraints and resolves kubernetes==35.0.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rasmusfaber
temporarily deployed
to
prd-pulumi-preview
May 21, 2026 06:59 — with
GitHub Actions
Inactive
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
rasmusfaber
had a problem deploying
to
prd-pulumi-preview
May 21, 2026 07:17 — with
GitHub Actions
Error
rasmusfaber
marked this pull request as ready for review
May 21, 2026 07:17
rasmusfaber
requested review from
PaarthShah and
QuantumLove
and removed request for
a team
May 21, 2026 07:17
Co-Authored-By: Claude Opus 4.7 <[email protected]>
rasmusfaber
temporarily deployed
to
prd-pulumi-preview
May 21, 2026 07:18 — with
GitHub Actions
Inactive
QuantumLove
approved these changes
May 21, 2026
sghout
added a commit
to peren-gouv/hawk
that referenced
this pull request
Jun 2, 2026
* PLT-854: Add logging for all postgresql statements (#430) * HWK-3: Include all vpcs in default routes for the subnet router (#443) * Pin kubernetes<36 to fix runner 401s against the K8s API (#448) * fix(runner): pin kubernetes<36 (broken bearer auth in 36.0.0) The kubernetes 36.0.0 client's Configuration.auth_settings() drops the BearerToken scheme, so requests using kubeconfig/in-cluster bearer tokens go out with no Authorization header and get 401. This broke inspect_k8s_sandbox in the runner pod (every list_namespaced_pod call failed) and would break the janitor on its next image build. Upstream: https://github.com/kubernetes-client/python/issues/2582 Co-Authored-By: Claude Opus 4.7 <[email protected]> * chore: sync uv.lock files with kubernetes<36 pin Regenerated via scripts/dev/uv-lock-all.sh so every lockfile that references hawk reflects the new requires-dist constraints. Co-Authored-By: Claude Opus 4.7 <[email protected]> * Lower bound pin as well. Co-authored-by: Copilot Autofix powered by AI <[email protected]> * chore: sync uv.lock files after runner kubernetes lower-bound Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Stop double-prefixing the transcript with sample context (#418) * Stop double-prefixing the transcript with sample context PR #386 installed Inspect's SampleContextFilter directly on Hawk's stdout handler. The filter mutates `record.msg` in place to insert the `sample=…` prefix. Inspect's own LogHandler has the same filter and runs on the same propagated LogRecord, so the prefix was applied twice — the eval transcript now shows entries like sample=tex_python epoch=2 sample=tex_python epoch=2 Unlocked submit (reported by Tom on MirrorCode in prd). Wrap the inner filter so it operates on a shallow copy of the record and return that copy from `Filter.filter()`. Python's `Handler.handle` uses the returned record for emit but does not mutate the record passed to other handlers, so Inspect's handler still sees the original unprefixed record and applies the prefix exactly once for the transcript. Co-Authored-By: Claude Opus 4.7 <[email protected]> * test(logging): use capsys instead of monkeypatching sys.stdout Per review feedback on #418. Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]> * Support secrets stored in AWS Secrets Manager (#404) * feat: add typed secret source configs * fix: reject duplicate secret declarations * feat: add aws secret arn utilities * feat: validate aws-sourced secret references * fix: make secret validation precedence deterministic * feat: pass aws secret settings to runner jobs * feat: skip aws-sourced secrets in cli resolution * feat: resolve aws-sourced secrets in runner * feat: inject aws-sourced secrets at runner startup * feat: attach optional secrets session policy * feat: wire runner secrets manager policy * test: cover hawk stack runner secret wiring * Tighten runner secret prefix validation * docs: document aws-sourced runner secrets * fix: address aws secret source review feedback * feat: replace runner secret config with task namespace * feat: forward inspect task secret prefix to runner pods * feat: preserve AWS secret shorthand case * feat: hawk local fetches AWS-sourced secrets * Add task secrets management CLI * docs: shared task secrets and verbatim shorthand mapping README + CLAUDE.md describe the inspect-tasks/ namespace, the always-on runner grant, the verbatim shorthand mapping, and how hawk local fetches AWS-sourced secrets with local credentials. Co-Authored-By: Claude Opus 4.7 <[email protected]> * chore: update runner lock metadata * Run secret validation alongside permission checks * Use inspect task secret prefix in runner * uv.lock * docs: tighten shared task-secrets docs from review feedback - README: rephrase the runner grant as unconditional rather than conditional on "AWS-sourced secrets are enabled"; mention scan configs in the intro; add the AWS CLI pattern for researchers running `inspect eval` directly. - Pulumi.example.yaml: comment out the example so operators have to uncomment to override the default, matching the file's convention. - hawk/CLAUDE.md: consolidate the two overlapping AWS-secrets paragraphs into one section. Co-Authored-By: Claude Opus 4.7 <[email protected]> * Fix HawkStack test RDS fake * fix: use Generator instead of deprecated Iterator return type basedpyright flags `Iterator[Foo]` as a deprecated annotation for `@contextmanager` functions; use `Generator[Foo]` per the recommendation. Co-Authored-By: Claude Opus 4.7 <[email protected]> * refactor: address PR #404 style nits from QuantumLove - Drop find_duplicate_effective_arns from hawk.core.aws_secret_arns and its dedicated unit test; validate_aws_secret_arns builds the duplicate-ARN dict inline in its single-pass loop, so the helper is dead code. - Replace the four mutually-exclusive branches in validate_aws_secret_arns with a table-driven dispatch: each problem category contributes (specific title, single-case message, combined-case detail). One branch handles "exactly one problem", another handles "multiple problems"; titles, messages, and combined wording are preserved so existing tests still pass. Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(tests): pass OIDC fields to Settings(...) in secrets tests PR #364 ("Improve OIDC support", merged 2026-05-14) made several model_access_token_* fields required on Settings. The three secrets tests on this branch were authored on 2026-05-12, before that PR, and weren't updated when this branch was rebased onto main, so they failed at Settings(...) construction with field-required errors. Add the OIDC fields as placeholder values: - test_run_job_secrets.py: extend the shared _settings_for_job_secret_test helper with a module-level _TEST_AUTH_FIELDS dict that callers pick up automatically. - test_eval_set_secrets_validation.py and test_scan_secrets_validation.py: add the same fields to the one inline Settings(...) call in each file. These tests don't exercise OIDC behaviour; the values are arbitrary placeholders. 2237 unit tests pass. Co-Authored-By: Claude Opus 4.7 <[email protected]> * refactor: drop the other dead helper QuantumLove actually flagged PR #404 review pointed at line 42 of aws_secret_arns.py, which was default_prefix_is_covered (not find_duplicate_effective_arns, which 46089f27 removed). Both functions had only their unit tests as callers — default_prefix_is_covered's deploy-time use moved to infra/lib/config.py's __post_init__ during the task-secrets-namespace refactor, leaving the helper orphaned. Removing it and its test. Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]> * Download eval artifacts from the CLI (#415) * feat: add download-artifacts cli * refactor: address remaining styling nits from Claude review - drop unused SecretConfig alias; standardize on SecretSourceConfig - rename _SECRET_MANAGER_ARN_PATTERN to _AWS_SECRETS_MANAGER_ARN_PATTERN - move TConfig TypeVar to module-level declarations in runner/entrypoint - replace PS: comment style with Note: in validation docstrings - factor _elapsed_ms helper and pass duration_ms directly to _record_fetch_result so the started=now-as-duration confusion in _record_failures is gone - inline trivial _full_name and flatten _client kwargs in manage_task_secrets - rename secrets_file_names → secrets_from_files_names to reflect actual contents - combine split if-clauses in missing_required_secrets comprehension Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(cli): address review feedback on download-artifacts - retry asyncio.TimeoutError in _download_url_to_file so slow connections retry instead of dying on first timeout - continue past failing samples in download_eval_set_artifacts, summarizing per-sample failures at the end instead of aborting on the first one - tighten presigned URL test to lock the {eval_set_id}/artifacts/{sample_uuid} prefix so refactors that decouple the two segments fail CI Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]> * Survive Okta refresh-token rotation in long-running evals (#372) Okta rotates refresh tokens once at their ~90-day lifetime boundary. Three of our four /v1/token refresh-grant call sites read only access_token and discarded the rotated refresh_token, so an eval that crossed the boundary mid-run would refresh successfully once and then fail with invalid_grant for the rest of the run — losing access to the LLM API or AWS credentials. This change persists rotated refresh tokens at every call site (CLI refresh, runner inspect_ai hook, runner credential_helper subprocess), adds a CLI submission preflight that re-runs the device flow when the stored refresh token has too little lifetime left, and gives operators a recovery file the runner reads on invalid_grant to rescue an in-flight eval whose token has already been invalidated. - ClientConfig + Settings + /auth/config gain refresh_token_lifetime_days (default 90) and min_remaining_refresh_token_lifetime_days (default 30). A model_validator rejects configs where min_remaining > lifetime. - CLI store_tokens freshens a new refresh_token_issued_at keyring entry only when the stored refresh token actually changes (initial login or provider-side rotation), ignoring the common no-op echo case. - preflight_refresh_token_lifetime runs before hawk eval-set; on missing, malformed, or low-lifetime issued_at it invokes the existing device-flow login. Skips silently when there is no API URL, when /auth/config can't be fetched, or when OIDC isn't configured. - The runner credential_helper cache is extended to {access_token, expires_at, refresh_token} with atomic 0o600 writes; the cached RT takes precedence over the env-var fallback; _invalidate_token_cache preserves the persisted RT. - A new hawk.runner.refresh_token_override module hosts the override path and a defensive reader. Both the inspect_ai hook and the credential_helper consult it on permanent OAuth failure and retry with the operator-pushed token; the override RT replaces the in-memory / cached value going forward. The runner does not delete the file — operator manages its lifecycle. Cross-pod RT coordination is out of scope: multiple eval pods get the same RT injected at submission time and have no way to share rotation state. The CLI submission preflight bounds this in practice; a fully correct fix would need an external store. * fix(ci): revert pnpm/action-setup to allowlisted SHA (#447) PR #431 (dependabot) bumped pnpm/action-setup to 0e279bb959325dab635dd2c09392533439d90093, which is not on the repo's GitHub Actions allowlist. That has caused every Lint and Hawk CI run on main (and on PRs) to fail with `startup_failure` since 2026-05-20. Revert both workflows to 903f9c1a6ebcba6cf41d87230be49611ac97822e, which is on the allowlist. Same fix pattern as 98f1ad58. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> * Update subnet router config for crowdstrike (#427) * Suppress query logging for importer role when log_all_statements is enabled (#439) ALTER ROLE "inspect-importer" SET log_statement = 'none' prevents noisy importer queries from flooding the PostgreSQL logs. Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]> * Hawk Setup Evaluation — External User Experience Audit 7 (#449) * feat(VPC): adds alias-A records to public route 53 zone when hawk:albInternal is false * feat(readme): add readme info about hawk login when headless * faet(readme): add drive space requirements * fix(middleman): drop unknown fields from JSONB model_config instead of crashing (#460) * fix(middleman): drop unknown fields from JSONB model_config instead of crashing ModelInfo(**d) in _load_all_models is strict: any unknown key in the JSONB config column raises TypeError and kills model loading for every request. A single stale field (e.g. legacy `max_tokens`) in one row was enough to put dev-mish1's middleman into an intermittent crash-loop (boot succeeds only when row ordering keeps the bad row out of the first batch). Future-proof the loader: filter the dict to ModelInfo's known fields before splatting and emit a structlog warning naming the public_name + the dropped keys. Same posture as ModelConfigResponse.from_db_rows already takes for reads — explicit field mapping. Adding/removing a ModelInfo field no longer requires synchronous JSONB cleanup. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * review: hoist ModelInfo field-name set out of loader loop Copilot caught known_fields being recomputed per model dict. Compute once outside the loop and switch the diff to dict_keys - set, which also reads tighter. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * chore: fix whitespace in infra/hawk/api.py to satisfy pre-commit Auto-formatted by pre-commit. Caught by CI when this branch ran the hook on the full repo for the first time. * review: drop legacy groups key after deriving group Copilot caught that the unknown-field filter would warn (and trigger a dict rebuild) on every row still using the legacy 'groups' key. Delete it once we've converted to 'group'. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> * fix(infra): give api public route53 record a unique URN (#461) Both api private and api public route53 records were declared with the same resource name f"{name}-dns", so Pulumi blew up with 'Duplicate resource URN' on any stack with alb_internal=false (dev envs use the default False; stg/prd set true so the second record is skipped and the collision was masked). Rename the public record to {name}-public-dns. dev-mish1 has been unable to deploy since b397f140 landed because of this. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> * Route per-model Anthropic auth via Workload Identity Federation (#459) Add AnthropicCredentialBroker (middleman/src/middleman/anthropic_wif.py) that resolves an Anthropic credential per profile: either a static API key env var or a WIF lane. WIF lanes mint short-lived sk-ant-oat01-... tokens by exchanging an Okta client-credentials JWT at api.anthropic.com/v1/oauth/token. Refresh follows the WIF SDK contract (advisory exp-120s, mandatory exp-30s) with a single-flight asyncio lock per profile and a shared aiohttp session. ModelInfo gains anthropic_account; passthrough.py picks a profile via that field and swaps x-api-key for Authorization: Bearer when the credential is a bearer token. Unknown profile = fail-loud (500) so a typo doesn't silently route to the default Anthropic org. Models without anthropic_account keep the env-var API key path; no behavior change for them. Error mapping: - CredentialNotConfiguredError -> HTTP 500 (local misconfig: unknown profile name, missing Okta client_secret in SM). - CredentialExchangeError -> HTTP 502 (upstream IdP / Anthropic exchange failed). server.py loads profiles at boot (fails fast on bad config) and only invalidates the broker token cache from the periodic key refresh when SM contents actually changed (returned by provider_key_store.reload), so rotating an Okta client_secret takes effect within one cycle without forcing re-mint every 5 minutes. Pulumi wires MIDDLEMAN_ANTHROPIC_PROFILES from a new middlemanAnthropicProfiles config key (both from_pulumi_config and from_dev_env). Admin schema exposes anthropic_account on POST/PATCH /admin/models/ so the field is settable without direct DB writes. New smoke test tests/smoke/scenarios/test_middleman_anthropic_wif.py creates a temp WIF-routed model via the admin API, hits /v1/messages, asserts Anthropic answers, then cleans up. Skipped unless HAWK_SMOKE_WIF_PROFILE is set. Tests: 802 middleman tests pass (33 new broker tests, 2 new passthrough tests). End-to-end validated against a dev stack: broker logs anthropic_wif.exchange.ok, response routed via Authorization: Bearer. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> * fix(infra): pulumi up error (#465) * Add /append_info_events and /append_score_events routes (#462) * Add /append_info_events and /append_score_events routes Reuse the sample-edit JSONL -> S3 -> EventBridge -> Batch pipeline to append InfoEvent / ScoreEvent to a sample. SampleEditDetails gains two discriminated-union variants; the router's dedupe -> DB lookup -> permission check -> S3 upload orchestration is extracted into a shared _submit_sample_mutations helper so all three sibling routes share it. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Update hawk/hawk/core/types/sample_edit.py Co-authored-by: Mischa Spiegelmock <[email protected]> * Revert "Update hawk/hawk/core/types/sample_edit.py" This reverts commit b74367e23b3aadf5fb3a470d7b2f8433d2aff19e. * Use pydantic.JsonValue for InfoEvent data type Matches upstream inspect_ai.event.InfoEvent.data (JsonValue, not dict). Accepts any JSON value (dict, list, scalar, null) instead of dict-only. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> Co-authored-by: Mischa Spiegelmock <[email protected]> * Fix hawk logs tail count (#436) * feat(import): add `hawk import` for locally-produced .eval files (#356) Adds a `hawk import PATH [--name NAME]` CLI command and two backing endpoints under `/eval_sets/import/`: POST /eval_sets/import/ -> allocate eval_set_id POST /eval_sets/import/{id}/uploads -> presigned PUT URLs POST /eval_sets/import/{id}/finalize -> validate + commit The CLI hashes each .eval, gets an eval_set_id, rewrites a temp-dir copy of each file to stamp `metadata.eval_set_id`, `metadata.imported`, and `metadata.created_by` (from the JWT sub), uploads via presigned PUT, then finalizes. Source files are never modified. The server validates the stamped `eval_set_id` matches the URL (so a malicious CLI can't inject rows into another eval-set), reads each header range-style from S3 via inspect_ai/fsspec to extract model names, validates the uploader's model_groups, writes `.models.json` replace-only, and uses `CopyObject` for the staging->canonical move so bytes never flow through the API process. The existing PutObject -> job_status_updated -> EvalCompleted -> eval_log_importer chain ingests them as if they were native runs. Imported eval-sets get IDs of the form `imported-<slug>-<random>` and `metadata.imported = true`; otherwise structurally identical to native runs in the warehouse, viewer, and `hawk download`. Infrastructure: a 24h lifecycle expiration on the `evals-staging/` S3 prefix cleans up abandoned imports. Co-authored-by: Rafael <[email protected]> * chore(deps): bump the actions-minor-patch group with 3 updates (#466) * chore(deps): bump the actions-minor-patch group with 3 updates Bumps the actions-minor-patch group with 3 updates: [docker/build-push-action](https://github.com/docker/build-push-action), [docker/login-action](https://github.com/docker/login-action) and [pnpm/action-setup](https://github.com/pnpm/action-setup). Updates `docker/build-push-action` from 7.1.0 to 7.2.0 - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/bcafcacb16a39f128d818304e6c9c0c18556b85f...f9f3042f7e2789586610d6e8b85c8f03e5195baf) Updates `docker/login-action` from 4.1.0 to 4.2.0 - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/4907a6ddec9925e35a0a9e82d7399ccc52663121...650006c6eb7dba73a995cc03b0b2d7f5ca915bee) Updates `pnpm/action-setup` from 6.0.3 to 6.0.8 - [Release notes](https://github.com/pnpm/action-setup/releases) - [Commits](https://github.com/pnpm/action-setup/compare/903f9c1a6ebcba6cf41d87230be49611ac97822e...0e279bb959325dab635dd2c09392533439d90093) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-version: 7.2.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions-minor-patch - dependency-name: docker/login-action dependency-version: 4.2.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions-minor-patch - dependency-name: pnpm/action-setup dependency-version: 6.0.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: actions-minor-patch ... Signed-off-by: dependabot[bot] <[email protected]> * empty commit --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Thomas Broadley <[email protected]> * Remove production Pulumi secrets provider default (#435) Co-authored-by: Thomas Broadley <[email protected]> * Stop 500-ing viewer requests when .models.json writeback races (#450) * fix(api): stop 500-ing viewer requests when .models.json writeback races `has_permission_to_view_folder` always treated the IfMatch update of `.models.json` as required for the response. When a viewer load fans out many parallel `/view/logs/log-info/...` requests for the same folder and Middleman has returned new model_groups, all of those callers race on the IfMatch precondition. Only one wins; the rest exhaust tenacity's 3 retries and raise `RetryError`, returning 500 to the user even though `latest_model_groups` from Middleman is already the source of truth for the permission decision. Catch `RetryError` from the writeback, log it, and continue using `latest_model_groups` to decide. Cache invalidation moves to a `finally` so we still drop the stale local cache entry regardless of which writer ultimately wins in S3. * tighten comments * log race-loss at debug, drop traceback * Keep github secrets up to date (#423) * fix(api): preserve CORS headers on BaseError responses (#325) * fix(api): preserve CORS headers on BaseError responses Sub-apps registered `app.add_exception_handler(Exception, ...)`, but Starlette special-cases the `Exception` key (and 500) into `ServerErrorMiddleware` — the outermost middleware, above the user middleware stack. Responses generated there bypass `CORSMiddleware`, so `BaseError` subclasses (`ClientError`, `AppError`, `CrossLabScanError`) came back without `Access-Control-Allow-Origin`. The browser surfaced this as "Failed to fetch" rather than the 4xx/5xx Problem JSON the client could parse. Register against `BaseError` and `ExceptionGroup` instead. Those go through the inner `ExceptionMiddleware`, whose responses traverse user middleware on the way out, so CORS is applied naturally — the same path already used for `HTTPException`. Truly unhandled exceptions (`KeyError`, `RuntimeError`) now return Starlette's default `text/plain "Internal Server Error"`. Sentry's FastAPI integration auto-captures them, so reporting is unchanged; the explicit `sentry_sdk.capture_exception` call in the handler's fallback branch was redundant. Scope is limited to the 4 sub-apps that already registered the handler. The other 3 (`auth_router`, `eval_log_server`, `scan_view_server`) intentionally do not register `app_error_handler` so an XSS at a viewer origin cannot read error bodies — that posture is preserved, with a test to pin it. Co-Authored-By: Claude Opus 4.7 <[email protected]> * test(api): trim verbose docstrings from CORS tests Test names already say what they cover; the prose was rephrasing the commit message. Drop the docstrings, keep one short comment for the non-obvious why on _NO_HANDLER_SUBAPPS. Co-Authored-By: Claude Opus 4.7 <[email protected]> * refactor(api): catch errors in ProblemEnvelopeMiddleware inside CORS Switch from typed exception-handler registrations to a small ASGI middleware that catches escaping exceptions and returns Problem JSON via app_error_handler. Sits between AccessTokenMiddleware and CORSMiddleware in the user stack, so error responses traverse CORS regardless of which exception type was raised. This avoids the regression of the previous approach: with add_exception_handler(BaseError, ...), unhandled exceptions (KeyError, RuntimeError) reverted to Starlette's plain "Internal Server Error" 500. The middleware envelopes those too, so every error response the API emits is Problem JSON with CORS headers (where the sub-app has CORS configured). Sub-apps that intentionally don't envelope (auth_router, eval_log_server, scan_view_server) keep that posture — XSS at a viewer origin still can't read their error bodies. Tests pin both halves. Co-Authored-By: Claude Opus 4.7 <[email protected]> * refactor(api): drop CORS from /humans and /human_evals, use ProblemEnvelopeMiddleware These two sub-apps are CLI-only (consumed by `hawk human ...`); there's no browser caller that needs CORS. Drop CORSMiddleware and replace the legacy `add_exception_handler(Exception, app_error_handler)` with ProblemEnvelopeMiddleware to match the rest of the authenticated sub-apps. Pin both in `_ENVELOPE_SUBAPPS` so future CORS additions can't reintroduce the bypass bug fixed in this PR. --------- Co-authored-by: Claude Opus 4.7 <[email protected]> * Do not init vertex if not configured (#421) * Move tomlkit dep to top level for prepare-release script (#440) * Move tomlkit dep to top level for prepare-release script * Keep tomlkit in hawk dev deps — used by runner tests Per Copilot review: hawk/tests/runner/test_runner.py still imports tomlkit, so dropping it from hawk's dev group would break the test suite. Re-add it (also keeping it at the top level for the prepare-release script). * Refresh service uv.locks after re-adding tomlkit to hawk dev Workspace member locks reference the hawk dev deps, so adding tomlkit back to hawk required regenerating them too. * Drop now-unnecessary pyright ignores on tomlkit.dump tomlkit 0.15 ships type info, so reportUnknownMemberType no longer fires on dump() and the ignore comments fail basedpyright's reportUnnecessaryTypeIgnoreComment check. * Pin Docker to 28.5.2 to dodge msft-golang TLS panic (#472) * fix(devcontainer): pin Docker to 28.5.2 to dodge msft-golang TLS panic Docker 29.x debs are built with msft-golang, whose vendored golang-fips/openssl passes NULL to OSSL_PARAM_BLD_push_octet_string for empty Go slices. Debian backported the upstream NULL-check fix into bookworm's libssl3 3.0.20 (2026-05-05), so any devcontainer rebuild since then panics on the first TLS 1.3 handshake (e.g. `docker login` in CI). Latest 28.x (28.5.2) is built with stock Go and is unaffected. Co-Authored-By: Claude Opus 4.7 <[email protected]> * ci: run hawk jobs when devcontainer or workflows change The path filter only tripped on hawk/ changes, so PRs that touch the devcontainer or the workflows themselves slipped past CI — including the kind of fixes most likely to break or fix CI. Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]> * Tidy up example configs (#426) * Bump inspect-ai to PyPI 0.3.227 and inspect-scout to PyPI 0.4.38 (#453) Drops the METR fork from [tool.uv.sources] for both packages — every hotfix we'd cherry-picked has now landed upstream. Python deps install from PyPI directly. The npm viewer packages are still published from METR fork branches (release/0.3.227 and release/0.4.38) under the @metrevals scope, because @meridianlabs stopped publishing them: log-viewer is capped at 0.3.201 and inspect-scout-viewer at 0.4.21. The fork branches contain no cherry-picks; release/0.4.38 strips Git LFS on _view/dist so the fork installs without LFS storage. Code changes required by 0.3.227: - inspect_ai._view.server.async_connection moved to _view.common - GenerateConfig now emits a custom 'Unknown GenerateConfig field(s)' error for unknown fields instead of pydantic's standard extra_forbidden - ToolCallError.type adds 'cancelled' — added to MessageRec literal - New CheckpointEvent and InterruptEvent — added empty match cases to keep the converter's exhaustive match working * fix: replace kubeconfig with INSPECT_K8S_NAMESPACE env var (#136) Long-running evals on EKS 1.35 fail with 401 Unauthorized because the kubernetes Python library caches the service account token from the kubeconfig and never refreshes it. EKS 1.35 (KEP 740) caps token lifetime at 24 hours, down from 365 days on EKS 1.33. The kubeconfig existed solely to pass the sandbox namespace. Replace it with the INSPECT_K8S_NAMESPACE env var so k8s_sandbox falls back to in-cluster config, which has built-in token refresh (re-reads every 60s). - Remove createKubeconfig from Helm values - Replace HAWK_RUNNER_BASE_KUBECONFIG with INSPECT_K8S_NAMESPACE in job template - Delete kubeconfig ConfigMap template - Remove kubeconfig copy logic from runner entrypoint Co-authored-by: Claude Opus 4.6 <[email protected]> * [HWK-2] Fix sample looping on stale pod UID after sandbox eviction (#475) * Bump inspect-k8s-sandbox to typed-error hotfix Pulls in the rewritten k8s_sandbox pod-restart detection from inspect_k8s_sandbox PR #193 (typed `PodReplacedError` / `ContainerRestartedError`, with auto-refresh of the cached pod identity so subsequent ops target the new pod instead of looping on a stale UID), plus an updated METR-private commit that re-aligns the `INSPECT_POD_RESTART_CHECK` env-var gate to the new code structure (file ops only — exec is unconditional). Add a comment at the INSPECT_POD_RESTART_CHECK env entry so a future operator sees the read/write-only scope without spelunking the fork. Co-Authored-By: Claude Opus 4.7 <[email protected]> * Re-pin inspect-k8s-sandbox to fix observability regression Bumps the hotfix pin to pick up upstream PR #193's followup commit that removes PodReplacedError / ContainerRestartedError from the sandbox provider's `expected_exceptions` tuples. The previous tip had them listed, which silently dropped the ERROR-level log and the contextual K8sError wrap that operators (and the existing integration test) rely on. The typed exceptions still exist and still carry the auto-refresh data — callers that care about the type walk the __cause__ chain as before. Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]> * test(scan-import): deflake test_import_parquet_scanner by sorting scan_results rows (#477) * test(scan-import): sort scan_results DataFrames by transcript_id to deflake Scout runs the two test transcripts concurrently, so the row order in `scan_results.scanners[<name>]` is non-deterministic. Every test in `test_import_transcript_scan.py` that indexes results by row position (e.g. `r_count_results[0]` for transcript_001) was implicitly relying on the run order — `test_import_parquet_scanner` failed in CI today with `[4, 2] == [2, 4]` when the order flipped. Sort each scanner's DataFrame by `transcript_id` once at the fixture boundary so every downstream test sees stable, transcript_001-first order without having to opt in. `results.scanners` is a LazyScannerMapping that doesn't allow item assignment, so we materialize the sorted copies into a plain dict and reassign the field. Verified by running `test_import_parquet_scanner` 5x in a row locally (all pass) and the full `test_import_transcript_scan.py` suite (38 passed). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(scan-import): use stable sort with label tiebreaker multi_label_scanner emits multiple rows per transcript, distinguished by `label`. Sorting only by `transcript_id` left those rows in scout's non-deterministic order. Add `label` as a secondary sort key and pass kind="stable" so the tie-breaking ordering is deterministic. Caught by Copilot review. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> * perf(db): add covering index for global /samples query (#476) * perf(db): add (completed_at DESC) INCLUDE (eval_pk) covering index The global /samples endpoint with no eval_set_id filter was taking ~13s in production. EXPLAIN ANALYZE showed Postgres choosing a Seq Scan on sample (~6.3s scanning 472K rows + 95K rejected) followed by a top-N sort, because the eval_pk IN (permitted-evals) filter passes ~50% of rows — too unselective for the planner to use sample__completed_at_idx. The new covering index lets the planner walk the time-ordered index in DESC order, check eval_pk membership inline (no heap fetch), and stop at LIMIT+1 matches. Expected speedup: ~6.5s → ~50ms for the global view. Migration uses CREATE INDEX CONCURRENTLY for zero-downtime deploy. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(db): match index NULLS placement to query's DESC NULLS LAST Query orders by completed_at DESC NULLS LAST but DESC defaults to NULLS FIRST, so without explicit NULLS LAST the planner can't use the index to satisfy the ORDER BY and would fall back to a sort — undermining the intended plan change. Caught by Copilot review. Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.6 <[email protected]> * Fix/audit 8 follow ups (#451) * fix(audit-8): unblock external users on local eval, deployment docs, and scan example Addresses 20 findings from the audit-8 follow-ups issue (EquiStamp/METR_issues#430, parent audit EquiStamp/METR_issues#425), splitting cleanly into code fixes and documentation corrections. Code: - cli/local.py: error suggesting `uv pip install hawk[runner]` (which fails on zsh and outside a venv) now suggests the working `uv tool install` command (1a). - cli/cli.py: add `@click.version_option` and document hawk[runner] requirement in the `hawk local eval-set` docstring (1b, 3b). - cli/config.py: distinguish DNS failure from connection-refused when fetching /auth/config so external users get an accurate hint (3a). - core/logging.py: clear root handlers before installing ours to stop log lines printing twice when basicConfig pre-registered a handler (1e). - core/run_in_venv.py: pass `--python sys.executable` to `uv venv` so the task venv matches the Python hawk was installed with (4b). - runner/entrypoint.py: in --direct mode, install dependencies into the actual hawk interpreter via `--python=sys.executable` and correct the misleading "Installing dependencies in local venv..." log line (1c, 1d). - runner/run_eval_set.py: catch inspect_ai PrerequisiteError before the generic exception handler so missing-API-key / missing-dep errors print a clean log line instead of a 40-line traceback (1f, B.15). - scripts/dev/new-dev-env.sh: bail early with a clear error when the stg stack is missing instead of silently falling back to dummy values (5d). Docs: - hawk/README.md: split prerequisites into CLI-user vs contributor/deployer sections (B.7); add "Working directory" callout to Running Locally section and standardise example paths on the repo-root form (2a); rewrite the --direct section to reflect actual behaviour and document `--with openai` (1c, 1d); add inspect_evals/openai dependency note (1f); add missing `config`, `models`, `scan-export` rows to the CLI reference table (3c); replace METR-internal scan example with placeholders (6a, 6b); add full ScanConfig field reference table (6c). - README.md: fix `pulumi login` URL to include required ?region/profile/awssdk params (5b); remove broken `cd infra` step before `pulumi stack init` (5a). - docs/infrastructure/deployment.md: document IAM baseline for pulumi up (5c). - hawk/examples/simple.scan.yaml: replace METR-internal eval set ID, scanner package, and gpt-5 model with placeholders / cost-appropriate defaults (6a, 6b). * fix(cli/config): improve error handling for server configuration discovery Enhances the error handling in the discover_server_config function to provide a more accurate hint when a DNS failure occurs. This change distinguishes between DNS errors and other connection issues, ensuring users receive clearer guidance on troubleshooting network connectivity to the API server. * fix(audit-8): address PR review feedback - Restore real metr_scanners package in simple.scan.yaml and inline README example; previously replaced with a placeholder incorrectly labeled as METR-internal - Add --force to the hawk[runner] missing-install error message - Add two tests for the DNS vs connection-refused error hint in TestDiscoverServerConfig (test_error_hint_dns_failure, test_error_hint_connection_refused) - Remove second IAM paragraph from deployment.md (reviewer: obvious) - Tighten hawk/README.md * Update docs/infrastructure/deployment.md Co-authored-by: Rafael <[email protected]> * Update installation instructions in README and error messages in CLI - Changed the installation command in README.md to use `--reinstall-package` instead of `--force` for clarity. - Updated the error message in local.py to reflect the new installation command for the hawk[runner] package. --------- Co-authored-by: Rafael <[email protected]> Co-authored-by: Rafael <[email protected]> Co-authored-by: Mischa Spiegelmock <[email protected]> * style: fix ruff-format and basedpyright lint warnings (#482) The original lint fix on #451 didn't make it into the squash-merge due to a GitHub PR-sync bug: the branch ref had this fix on top, but PR head was frozen on an earlier SHA, so the squashed commit on main shipped the broken code. Re-applying on top of main. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> * HWK-8: disable Sentry auto-enabling Starlette integration in batch jobs (#479) * test(importer): add test that sentry_sdk.init() does not crash Covers both eval_log_importer and sample_editor. These batch jobs have starlette as a transitive dependency (via inspect-ai) but not jinja2, which causes Sentry's auto-detected StarletteIntegration to crash. Includes a test proving the crash happens without the fix, so the guard stays meaningful as dependencies change. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix(importer): exclude StarletteIntegration from Sentry in batch jobs The inspect-ai 0.3.227 bump added starlette as a transitive dependency. Sentry auto-detects starlette and tries to patch Jinja2Templates, which crashes because jinja2 is not installed. This has broken all eval log imports in production since ~09:38 UTC on 2026-05-27. Uses disabled_integrations rather than auto_enabling_integrations=False to preserve useful auto-detected integrations (e.g. SQLAlchemy). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: use explicit import for StarletteIntegration sentry_sdk.integrations.starlette is a submodule that must be explicitly imported — accessing it via attribute on the parent module fails with AttributeError. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: run sentry init tests in subprocesses sentry_sdk.init() is idempotent per process — setup_once() won't re-run after the first call. Run both the crash and no-crash tests in isolated subprocesses so they each get a fresh sentry state. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]> * feat(api): structured access logs for every HTTP request (#429) * feat(api): structured access logs for every HTTP request Emit one JSON log line per API request to CloudWatch via the `hawk.api.access` logger, capturing method, path, status, duration, client IP (from X-Forwarded-For), user email/sub, user-agent, and a request_id (honoring inbound `X-Request-ID` if present). Sets `HAWK_API_LOG_FORMAT=json` on the ECS task so the existing StructuredJSONFormatter formats both startup logs and the new access logs as JSON in the `{env}/hawk/api` CloudWatch log group. Makes "find all requests from IP X" / "find all requests by user Y" trivial via Logs Insights instead of needing Athena over ALB S3 logs. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(api): add python-json-logger to api extras The access-log middleware (previous commit) made `hawk.api.server` import `hawk.core.logging`, which requires `python-json-logger`. That dep was only declared under the `runner` extras, so the api container fails to start with `ModuleNotFoundError: pythonjsonlogger`. Caught by e2e CI (and reproduced live in dev-mish1 — ECS rolled back to the prior task def revision). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(api): take right-most X-Forwarded-For to resist client spoofing ALB appends the connecting client IP to the right of X-Forwarded-For, so anything to the left of that entry can be supplied by the caller. The previous left-most reading let a malicious request log any IP it wanted. Caught by Copilot review. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci: retrigger workflows (previous run had startup_failure) * fix(api): suppress uvicorn access log; drop query field from access log Two findings from review: * uvicorn's plaintext access logger was still on alongside the new JSON middleware, doubling ingestion in the `{env}/hawk/api` log group. Pass --no-access-log in the API Dockerfile CMD so only the structured hawk.api.access entry is emitted. * The middleware was logging request.url.query verbatim. A mounted sub-app (inspect_ai, inspect_scout) could ship a future version that accepts a ?token=... query param, which would silently land in CW alongside user_email. Drop the query field by default; if a specific query value is operationally useful, add structured logging at the endpoint that owns it. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(infra): also pass --no-access-log via ECS task command The ECS task definition's `command` field overrides the Dockerfile CMD, so the `--no-access-log` flag added to the Dockerfile was a no-op in deployed environments — uvicorn's plaintext access log continued emitting alongside the structured `hawk.api.access` middleware. Mirror the flag here so the production task actually drops it. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix: regenerate sibling uv.lock files after api extras change Each sibling project's uv.lock pins requires-dist for hawk; the api extras change (python-json-logger) needs to propagate everywhere. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(deps): pin hawk/uv.lock to main's kubernetes-asyncio==34.3.3 When I regenerated hawk/uv.lock during the rebase, uv pulled in kubernetes-asyncio 35.0.1, which made the `tail_lines` parameter of `read_namespaced_pod_log` non-optional and tripped basedpyright on hawk/core/monitoring/kubernetes.py — a file outside this PR's scope. Reseed hawk/uv.lock from origin/main and re-resolve so only the python-json-logger entry I introduced changes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> * fix(infra): ensure Lambda permission exists before ALB target group attachment (#486) TargetGroupAttachment was created before the lambda.Permission that grants the ALB permission to invoke the Lambda, causing AccessDenied on fresh deploys. Resolves on retry but should not require one. Fix: move lambda.Permission creation before TargetGroupAttachment and add depends_on so the attachment waits for the permission to exist. Confirmed by 3 auditors (Audit 10 #33, finding B.5). * fix(www): bump scout viewer to beta with bootstrap CSS bundled (#487) The scout viewer's library CSS bundle was missing the Bootstrap base rules its own components depend on (.btn, .nav, .nav-link, etc.), so the Hawk scan-viewer page rendered without any layout/typography on prd. The viewer always relied on consumers also pulling in another viewer's CSS that happened to include Bootstrap, which only worked incidentally for the eval pages (log-viewer bundles Bootstrap). Picks up the upstream fix from https://github.com/meridianlabs-ai/ts-mono/pull/259, packaged from METR/inspect_scout release/0.4.38-scout-bootstrap-fix as @metrevals/[email protected]. This is a frontend-only change — no Python deps or alembic migrations. * docs: warn that example.com is reserved in Route 53 setup docs (#337) METR_Issues #371 https://github.com/EquiStamp/METR_Issues/issues/371 Co-authored-by: Cursor <[email protected]> Co-authored-by: Mischa Spiegelmock <[email protected]> * chore(infra): remove deprecated eval log reader model-access secrets (#416) Co-authored-by: dino <[email protected]> * fix(scripts): resolveINFRA_DIR relative to script location in create-cognito-user.sh (#464) * fix(scripts): resolveINFRA_DIR relative to script location in create-cognito-user.sh * Don't swallow errors, apply changes to manage-cognito-groups.sh too --------- Co-authored-by: dino <[email protected]> Co-authored-by: Rafael <[email protected]> * Hide scans with unresolved transcript sources from /meta/scans (#396) * fix(api): hide scans with unresolved transcript sources from /meta/scans Scans run against legacy us-west-1 transcripts have scanner_results with NULL sample_pk, which made compute_scan_model_groups return {} — indistinguishable from a genuinely all-public scan. The /meta/scans filter `Scan.model_groups <@ user_perms` treated empty as public and returned ~285 private-project scans on prd to any authenticated user. This change appends a `__unresolved__` sentinel to `Scan.model_groups` when any eval-log scanner_result has NULL sample_pk. The sentinel doesn't start with `model-access-`, so no user's permitted-groups array can satisfy `contained_by` — fails closed without API changes. The migration recomputes `scan.model_groups` for every existing row after the function update. The companion one-time backfill of `scanner_result.sample_pk` (matching legacy transcripts to re-imported samples) is applied manually per environment, separate from this migration. Co-Authored-By: Claude Opus 4.7 <[email protected]> * test: give scanner_results a real sample_pk in scans-endpoint test `test_get_scans_with_scanner_result_count` created eval-log scanner_results with NULL sample_pk, which now correctly trips the `__unresolved__` sentinel and hides the scan from /meta/scans. Wire the scanner_results to a real sample so the test exercises a resolvable scan. Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]> * Add artifact and report previews to eval logs (#402) * feat: add artifact and report previews to eval logs * fix(www): sandbox SVG previews to block external beacon refs Rendering SVG via `<img src=presigned>` lets the browser dereference `<image href="https://attacker/…">`, `<use href=…>`, and `<a xlink:href=…>` sub-resource requests. Iframe sandbox="" blocks scripts but not those network requests, so the SVG bytes themselves have to be scrubbed. Adds a dedicated `SvgViewer` that mirrors `HtmlViewer`'s pipeline: DOMPurify sanitises with the SVG profile, the result is wrapped in a strict-CSP HTML host, and rendered inside a sandbox="" iframe with a Rendered/Source toggle. Policy split matches `getSafeHtmlPreviewDocument` — strict (agent artifacts) strips external href/xlink:href; report (researcher reports) keeps them, same trade-off as inline `style=` and CSS `url(...)` beacons. `.svg` is now its own FileKind so it dispatches to `SvgViewer` instead of `ImageViewer`. * fix(www): harden artifact sanitiser policy; pin TS↔Py artifact contract - sanitizeSvgDocument href hook: report policy now requires `#fragment` or `http(s)://` (was: any value, relying on DOMPurify's URI gating as a silent backstop) - Add `meta` to ALWAYS_FORBIDDEN_TAGS so `<meta http-equiv="refresh">` can't navigate the sandboxed iframe (sandbox="" blocks scripts but not meta-refresh) - Drop the SSR/regex fallback from both sanitisers — DOM is required and there's no safe string-only path - New tests/core/types/test_artifacts.py pins Pydantic field names so a Python-side rename trips CI instead of silently breaking the SPA's hand-written TS interfaces and runtime type guards - Move stale sanitiser tests out of artifactViewerUtils.test.ts; new htmlSanitization.test.ts adds cases for the meta-refresh strip, javascript:/data:text/html `<a href>` gating, and the pinned report-policy CSS url() trade-off Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix: address artifact-viewer review findings; share viewer wiring - _normalize_file_key: document that in-tree `..` is intentional (collapses to a key still under the base, which the listing endpoint already exposes); add positive `foo/../result.json` test - Add file-URL permission-denied test (was covered for listing and summary; the file-URL handler had no auth assertion) - End-to-end iframe-srcDoc tests for the strict-policy invariants the sanitiser threat model calls out: `<meta http-equiv="refresh">`, inline `style="background-image:url(...)"`, and SVG `<style>` url() beacons. Existing single mega-assertion split into one `it` per threat so a regression points at the surface that broke - Inline `useArtifactText` into `useTextPreview` (one-call shim) and lift `useTextPreview` to the Html/Svg viewer parents. Share `RenderedSourceToggle` and `SourcePreviewContent` from viewerUtils so the toggle/source pane is defined once Co-Authored-By: Claude Opus 4.7 <[email protected]> * refactor(www): collapse barrel; move artifact hooks/pages/utils to standard dirs - Delete the artifactViewerUtils.ts barrel; import directly from the source modules (artifactResource / formatters / htmlSanitization / fetchText / viewerLimits). Split its colocated test into formatters.test.ts + viewerLimits.test.ts so each module owns its test - Move useTextPreview / useSanitizedHtmlPreview / useArtifactNeighborPrefetch to src/hooks/ alongside useSampleFileUrl, useInlinedImageHtml, etc. Removes the unprincipled split where some artifact-rendering hooks lived under components/artifacts/ and the rest under hooks/ - Move resolveInlineImages to src/utils/ — pure, no React deps, and was the only hooks/ → components/ import in the tree - Move ArtifactPage / ReportPage / SampleFileFullPage to src/pages/ alongside LaunchPage, OAuthCallback, etc. (Old root-level EvalPage / SamplesPage / ... pre-date this convention; not migrating them in this branch) - Rename viewerUtils.tsx → viewerChrome.tsx since it exports React components, not utilities — the *Utils.ts suffix is otherwise used for pure helper modules (csvUtils, fileKind, formatters, viewerLimits) Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(www): cap CSV preview cost and use last_modified as inlined-image key - parseDelimitedText built each field with `+=` which is O(n²) in V8 for a single megabyte-scale field (e.g. an unclosed `"` on a 2 MB CSV would freeze the tab). Switch to a chunk buffer joined on field boundaries. - CsvViewer caps rendered rows at 5 000 with a truncation banner so a bounded-byte but row-heavy CSV cannot lock the table render. - useInlinedImageHtml keyed the react-query cache on a 32-bit FNV-1a hash of the rendered HTML, claiming "false collisions just re-run the resolver" — they don't, they hit the cached stale result. Key on the source file's last_modified from the entries listing instead; exact instead of probabilistic and no per-render hash work. Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(www): tighten strict artifact HTML URL policy * fix(www): key useTextPreview cache on object identity, not presigned URL useSampleFileUrl refetches the presigned URL every 10 min (URLs expire after 15 min on the backend). Keying useTextPreview on the URL meant that every URL refresh produced a cache miss and re-downloaded the full body — up to a 5 MB CSV / 2 MB report.html on a clock tick, every time the user lingered on a single file. Key on (scope, file key, last_modified) instead. URL is still the `enabled` gate and the fetch input, but cache identity matches the object's identity. Same pattern the previous commit applied to useInlinedImageHtml. Co-Authored-By: Claude Opus 4.7 <[email protected]> * test: cut redundant test coverage; pin contract types - Drop FileViewer.test.tsx — 10 sibling-component mocks to assert a 10-case switch dispatch was noise. Replace with artifactResource.test that targets the only meaningful assertion the old test made (the full-page URL encoding rule). - Trim HtmlViewer / SvgViewer tests to a single integration smoke per viewer (proves the sanitizer is wired + correct policy passed through). Per-threat coverage already lives in htmlSanitization.test.ts; duplicating it via a hand-rolled srcDoc-extracting regex was buying nothing. - test_artifacts.py: assert field annotations, not just names. A Python-side type change (e.g. `size_bytes: int | None → str | None`) would have passed the previous check while silently breaking the SPA. - Rename CsvViewer.test.ts → csvUtils.test.ts to match what it actually tests (parseDelimitedText, not the viewer component). - Delete test_response_models_serialize_expected_shape — Pydantic's model_dump round-trip is the library's responsibility, not ours. Net: -191 / +90 lines; same surfaces still covered, less drag on edits. Co-Authored-By: Claude Opus 4.7 <[email protected]> * refactor(www): move pure modules to utils/, types to types/, PascalCase chrome Sharpens the components/ vs utils/ vs types/ boundary that the codebase otherwise follows. Removes the last hooks→components import in the tree. - components/artifacts/ → utils/: csvUtils, fetchText, formatters, viewerLimits, htmlSanitization (each with its .test.ts). All are pure modules with no React deps. - components/artifacts/artifactResource.{ts,test.ts} → types/. It's a type contract plus two pure constructors (artifactFullPagePath, buildArtifactResource) — same shape as types/artifacts.ts which already carries `s3EntryFromKey`. - Rename viewerChrome.tsx → ViewerChrome.tsx for PascalCase parity with the other component files. - Rename UnknownFileViewer → UnknownViewer (file + symbols) to match the other viewers, named by file kind alone. Net: no behavior change. Tests + tsc unchanged (126 passing). Co-Authored-By: Claude Opus 4.7 <[email protected]> * refactor(www): collapse trivial viewer wrappers; wrap once in FileViewer Every XxxViewer.tsx exported both an XxxViewerContent and a trivial XxxViewer = (p) => <ViewerFrame><XxxViewerContent .../></ViewerFrame>. Eight of those wrappers were pure duplication. Drop the wrapper exports from Text/Markdown/Json/Csv/Image/Video/Pdf/ Unknown. FileViewer now wraps the single ViewerFrame once for the shared case and delegates Html/Svg unchanged — they keep their own wrapper because the mode toggle lives in the frame header. Net: −56 lines, same render output. Added a runtime assertUnreachable for the dispatch switch so a missing FileKind case throws explicitly instead of returning undefined. Co-Authored-By: Claude Opus 4.7 <[email protected]> * refactor(www): extract sampleContentUrls.ts; one place for /meta URL build useSampleFileUrl, useSampleFiles, useSampleSummary, and useInlinedImageHtml each hand-rolled the /meta/samples/... URL with their own encoding. Factor sampleFileUrl / sampleTreeUrl / sampleSummaryUrl into a single util so the segment-by-segment file-key encoding lives in one place and the API path is grep-able to one site. Co-Authored-By: Claude Opus 4.7 <[email protected]> * refactor(api): collapse sample-content tree handlers via a checked-tree dep 4 endpoints (list × {artifacts, reports}, file-url × {artifacts, reports}) duplicated the permission check + base-key build. Introduce a TreeBaseKeyDep that does both, and let the {tree} segment be a path parameter (Literal["artifacts", "reports"]) so two handlers cover both trees: GET /samples/{eval_set_id}/{sample_uuid}/{tree} GET /samples/{eval_set_id}/{sample_uuid}/{tree}/file/{file_key:path} Summary stays separate (different shape, queries both trees) and is registered first so the literal `summary` path doesn't get caught by the {tree} pattern. Net: −62 lines on the router. Same URLs, same tests pass unchanged. Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(www): don't prefetch on a stale selectedFileKey deep link selectNeighborPrefetchEntries silently centred on index 0 when the selection key wasn't in the entry list, so any typo'd deep link would trigger eager prefetch of the first N files. No current caller can hit this — ArtifactPanel always resolves selectedFileKey through defaultFileKey first — but the function is exported and its behaviour shouldn't depend on the caller's invariants. Distinguish the two non-matching cases: `null` means "panel still initialising" (keep the centre-on-first behaviour to warm the user's likely next clicks); a non-null key that doesn't match means the URL is stale → return []. Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(www): dedupe inline-image fetches by resolved key, not raw src resolveInlineImages dedup-keyed on (tag, rawSrc) but resolveRelativeKey strips ?query and #fragment, so refs like p.png and p.png?v=1 resolved to the same sample-tree key while triggering two presigns + two S3 fetches. Same for shared/p.png vs ../shared/p.png from a deeper dir. Pre-resolve each target's key, dedupe on (tag, resolvedKey), and apply the resulting data URL / presigned URL back to every target that maps to that key. Reshuffles resolveOne to take an already-resolved key. Existing test pinned the wasteful behaviour as desired ("two unique srcs ... we don't merge those here"). Flip it: one fetch. Co-Authored-By: Claude Opus 4.7 <[email protected]> * cleanup: remove duplicated isFullHtmlDocument tests and unused log handle - isFullHtmlDocument was tested in two places (resolveInlineImages.test duplicated the cases that already live in htmlSanitization.test, where the function is defined). Drop the duplicates + the re-export in resolveInlineImages.ts that only existed to feed them. - sample_content_router declared `log = logging.getLogger(__name__)` but never logged anything; drop it + the unused `import logging`. - Trim _checked_tree_base_key docstring from 4 lines of restating intent to one sentence; the FastAPI-feeds-the-params note is the only non-obvious bit. Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix: address Copilot PR review - fetchText: cancel reader before throwing ResponseTooLargeError so the underlying transfer stops at the cap instead of finishing the download whose bytes the UI is about to discard. - useSampleFiles: pass `tree` as the parseJsonResponse context so a malformed `reports` response says "reports", not "artifacts". - resolveInlineImages: build a Map<key, S3Entry> once per resolve pass. The previous Array.find made the inner loop O(images × entries), which matters for image-heavy reports against 10k-entry trees. - ArtifactSplitPane: thread an optional `resizeLabel` for the separator's aria-label instead of hard-coding "Resize artifact browser" — the same component now also splits the eval log viewer against the report pane. - artifacts.py: add extra="forbid" to SampleContentSummary to match the other API response models in the same file. - fileKind: document the compound-extension table (the .gz extensions already map to `unknown` — Copilot's claim that they were previewable was wrong, but the rationale was worth pinning). Co-Authored-By: Claude Opus 4.7 <[email protected]> * test: accept either SigV2 or SigV4 markers on presigned URL assertions The test pinned moto's SigV2-style query params (AWSAccessKeyId, Signature, Expires); the same call against real S3 with botocore's default SigV4 would emit X-Amz-Signature / X-Amz-Expires / X-Amz-Credential and the test would fail despite the URL being correctly signed. Keep the "signed AND has an expiry" invariant — two independent checks — but accept either signing scheme's marker for each. Drop AWSAccessKeyId (redundant with the signature check; SigV4 has no direct equivalent). Co-Authored-By: Claude Opus 4.7 <[email protected]> * Apply quick wins from PR #402 review - ReportPage: surface useSampleSummary errors through ErrorDisplay so a failed summary fetch no longer renders the misleading "No report for this sample." copy. - resolveInlineImages: throwIfAborted after mapWithConcurrency so a cancelled query lands in React Query as cancellation instead of a partially-resolved cache hit; new vitest covers the abort path. - sample_content_router: log.warning with eval_set_id/sample_uuid/tree when MAX_TREE_LIST_ENTRIES caps a listing, so the cap firing is observable in Datadog before users report it. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * chore: bump inspect-log-viewer to pick up useScrollDirection export Picks up @metrevals/[email protected] (built from METR/ts-mono@37acd5d), which re-exports useScrollDirection from the viewer's public API so EvalApp can drive its own status-bar collapse with the same hysteresis the viewer uses for its internal headers. inspect-ai itself stays on PyPI — only the npm viewer bundles the new ts-mono submodule SHA, and the Python package contents are unchanged. Upstream PR: meridianlabs-ai/ts-mono#261 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * feat(www): collapse EvalSetStatusBar on viewer scroll Mirrors the viewer's own header-collapse UX on the Hawk-controlled status bar in EvalApp. Uses `useScrollDirection` (now re-exported from @meridianlabs/log-viewer) with `stayHiddenOnUpScroll: true`, fed from a MutationObserver-resolved ref to the viewer's `.workspace` scroller, so the bar: - collapses to zero height (grid-rows transition) once the user scrolls down inside the viewer - stays collapsed during upward motion - re-expands only when the scroll container reaches the top Status bar markup uses a CSS-grid collapse (`grid-rows-[0fr|1fr]`) rather than max-height so the transition works regardless of expanded content height (e.g. the pod-status detail panel). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(www): pick the viewer's real scroller dynamically, not by class The viewer's `.workspace` div is a layout wrapper with `overflow:hidden` on the Y axis — the actual scrolling happens deeper, inside a CSS-modules-hashed element (`_scroller_<hash>`) that lives at different depths in different views (samples list / sample detail / transcript) and changes name per build. Hard-coding `.eval-app .workspace` meant `useScrollDirection` never saw any scroll events and the status bar never collapsed. Replace the selector with a scan that walks the `.eval-app` subtree and picks the descendant with the largest vertically-scrollable surface, re-running on DOM mutations. `useScrollDirection` re-resolves `ref.current` on its own MutationObserver tick. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(ci): repair main-side breakage exposed in this branch's CI After rebasing onto origin/main, three pre-existing issues from #396/#476 turn up in our pre-commit run: - `tests/core/db/test_rls.py`: five basedpyright errors where the new scan-model-groups tests use `scan.pk` / `sample.pk` directly after `await session.flush()` without an `assert ... is not None`. SQLAlchemy ORM leaves PKs typed as `UUID | None` even though they're populated post-flush; add the asserts so the narrowing happens. - `infra/hawk/eval_log_reader.py`: an unused `tags = default_tags(...)` local left over from a previous refactor (ruff F841). Drop the assignment and the now-unused import. - A duplicate alembic head: `a7b8c9d0e1f2` (#396) and `c8b3a2e1f4d5` (#476) both branched off independent parents and landed without a merge. Add the standard empty merge revision so the migration tree is linear again. These bugs are pre-existing on main and main's CI is currently failing on them too. Bundling here rather than a separate PR …
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
kubernetes36.0.0 (released today) ships a brokenConfiguration.auth_settings()that drops the BearerToken scheme entirely, so every in-cluster API call goes out with noAuthorizationheader and gets 401 from the API server. The runner installskubernetestransitively viainspect-k8s-sandboxwith no upper bound, so the next runner pod after the 36.0.0 release picked it up andinspect_k8s_sandboxstarted failing everylist_namespaced_pod(observed indev-faber2). Pinningkubernetes<36in therunnerandjanitorextras restores 35.0.0 until upstream ships a fix.Upstream issue: kubernetes-client/python#2582.