Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Owners of everything in this repository. Add a second owner before the
# first release: one approval is required to merge into 'main'.
* @egparedes
# One approval from an owner is required to merge into 'main'; a team keeps
# that ownership with more than one person.
* @GridTools/infrastructure
39 changes: 20 additions & 19 deletions .github/workflows/agent-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ name: Agent Review (reusable)
# (agent-review/bin/authorize); decides whether the run is keyed.
# prepare downloads the pinned harness, without secrets; runs none of
# its code (no install scripts, no version check).
# review keyed harnesses: two AWF sandbox runs: a keyless one fetches
# the PR from github.com, then the agent runs with no network
# access but the API proxy. The inference key is in ONE step's
# env and reaches only AWF's API-proxy sidecar. The host never
# touches PR content and is treated as tainted once 'awf'
# returns. The only job with the caller's environment.
# review keyed harnesses, and the only job with the caller's
# environment. Two AWF sandbox runs: a keyless one fetches the
# PR from github.com, then the agent runs with no network access
# but the API proxy. The inference key is in ONE step's env and
# reaches only AWF's API-proxy sidecar. The host never touches
# PR content and is treated as tainted once 'awf' returns.
# review-keyless
# the same steps for a harness that calls no model ('stub'):
# no environment and no secret, so a test needs no key and no
Expand Down Expand Up @@ -42,9 +42,10 @@ name: Agent Review (reusable)
# accepts only the 'pull_request_target' actions it lists, and the keyed job
# has its own concurrency group.
#
# Compatibility: a new permission in any job below, a new required input, a
# raised ceiling or a new allowed endpoint breaks callers or widens what they
# agreed to; release it as a breaking change.
# Compatibility: a change that breaks callers or widens what they agreed to
# (a new permission in any job below, a new required input, a raised ceiling,
# a new allowed endpoint) is a breaking release (docs/agent-review.md,
# Releases).

on:
workflow_call:
Expand Down Expand Up @@ -321,10 +322,10 @@ jobs:
if-no-files-found: error
retention-days: 1

# The keyed review: the only job with the caller's environment, and the
# only one that can read the key. 'review-keyless' below runs the same
# steps (YAML aliases) without environment and without any 'secrets.'
# reference; tests/test-workflow-structure.py checks both properties.
# The only job with the caller's environment, so the only one that can
# read the key. 'review-keyless' runs the same steps (YAML aliases) with
# no environment and no 'secrets.' reference; the structure test checks
# both properties.
review:
needs: [authorize, prepare]
# 'authorize' decides 'keyed' from its harness allowlist, never from an
Expand Down Expand Up @@ -672,8 +673,9 @@ jobs:
| /usr/bin/tee -a "${GITHUB_STEP_SUMMARY}"

# Off by default: artifacts of public repositories are downloadable by
# any signed-in user. The Phase 0 probe found no key or auth header in
# the audit files or the proxy logs.
# any signed-in user. The AWF probe found no key or auth header in the
# audit files or the proxy logs, nor did a count-only scan of an audit
# artifact from a keyed run with these flags.
- &audit-readable
name: Make the AWF audit log readable
if: always() && steps.key.outputs.skipped != 'true' && inputs.upload_audit
Expand All @@ -698,10 +700,9 @@ jobs:
if-no-files-found: ignore
retention-days: 7

# The same steps for a harness that calls no model: no 'environment:', no
# 'secrets.' reference, so neither a key nor a deployment, and it runs on
# any ref (a caller's PR, a branch dispatch). Only the key check and the
# agent step's environment differ from 'review'.
# No 'environment:' and no 'secrets.' reference, so neither a key nor a
# deployment, and it runs on any ref (a caller's PR, a branch dispatch).
# Only the key check and the agent step's 'env:' differ from 'review'.
review-keyless:
needs: [authorize, prepare]
if: needs.authorize.outputs.allowed == 'true' && needs.authorize.outputs.keyed == 'false'
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# actionlint, shellcheck and file checks, hooks pinned by commit sha.
# The hooks of .pre-commit-config.yaml.
- name: pre-commit
run: pipx run pre-commit==4.7.0 run --all-files --show-diff-on-failure

Expand Down Expand Up @@ -82,8 +82,7 @@ jobs:
echo "::endgroup::"
done
exit "${rc}"
# The workflow's structural invariants (environment, secrets,
# permissions, expressions in scripts, the keyless twin).
# The invariants listed in agent-review/tests/workflow_structure.py.
- name: Workflow structure
run: python3 agent-review/tests/test-workflow-structure.py
# Offline; the '--' filter is checked against a copy of PR Agent's
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
Never call a branch (`@main`) or a moving tag: a change here would reach your
repository unreviewed. Check every new pin, including Dependabot's, before
merging it: a commit that exists only in a fork resolves through this
repository's name in the REST API (Actions refused it as a pin in one test (from a fork with Actions disabled), but
that may change), and a tag can resolve to another commit even between
attempts of one run.
repository's name in the REST API (in one test, from a fork with Actions
disabled, Actions refused it as a pin, but that may change), and a tag can
resolve to another commit even between attempts of one run.

```bash
gh api repos/GridTools/ci-workflows/compare/main...<sha> --jq .status # 'identical' or 'behind'
Expand Down
20 changes: 10 additions & 10 deletions agent-review/awf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# --container-workdir) and image digests (--image-tag) are passed as
# command-line flags.
#
# Verified by a probe on AWF v0.29.12 (runs on a fork, listed in the pull
# request that added this file): the dummy key is unreadable in the sandbox in every mode; the
# CSCS path mapping; the model pattern format; 'maxTurns' and
# 'rateLimiting' answer 429; 'agentTimeout' ends the agent with exit 124.
# Verified by a probe on AWF v0.29.12: a dummy key is unreadable in the
# sandbox in every mode; the CSCS path mapping; the model pattern format;
# 'maxTurns' and 'rateLimiting' answer 429; 'agentTimeout' ends the agent
# with exit 124.
# The bounds the agent can actually hit are in the 'Spend' notes below.

network:
Expand Down Expand Up @@ -47,10 +47,10 @@ apiProxy:
# sidecar otherwise makes ~7 GETs per run to api.github.com (the
# github/gh-aw-firewall 'catalogue-data' branch) to refresh its pricing
# snapshot. Those carry no data about the run (GET only, no Authorization),
# but we do not use AWF's AI-credit accounting (see 'Spend' below), so the
# egress and the up-to-5 s first-request wait are
# pointless. Pricing then falls back to the bundled tables.
# (AWF v0.29.12: containers/api-proxy/catalogue-loader.js:91,237.)
# but AWF's AI-credit accounting is not used (see 'Spend' below), so the
# egress and the up-to-5 s first-request wait are pointless. Pricing then
# falls back to the bundled tables (AWF v0.29.12,
# containers/api-proxy/catalogue-loader.js).
modelCatalogue:
enabled: false
# Spend. The only hard cap is the dedicated CSCS key's own token budget;
Expand Down Expand Up @@ -86,8 +86,8 @@ container:
# one triggers first and the result is still collected.
agentTimeout: 25
memoryLimit: 6g
# TODO(phase0): pin images by digest with 'container.images' if passing
# the setup action's 'image-tag' output (with digests) is not enough.
# No 'container.images': the images are pinned by digest through the
# setup action's 'image-tag' output, passed as '--image-tag'.

filesystem:
# Placeholder; the 'review' job sets it to the review workspace, the only
Expand Down
23 changes: 12 additions & 11 deletions agent-review/harnesses/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Harness adapters

Each subdirectory adapts one coding-agent harness to the agent review
pipeline (see `docs/agent-review.md`). All files here are
read from the reusable workflow's own commit (`job.workflow_sha`), never from
the pull request or the calling repository.
pipeline (see `docs/agent-review.md`). All files here are read from the
reusable workflow's own commit (`job.workflow_sha`), never from the pull
request or the calling repository.

| File | Contract |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `install.sh` | `install.sh <prefix>`. Runs in the secretless `prepare` job. Installs an **exact** version with integrity checks (npm: `npm ci` against a committed `package-lock.json`; binaries: release URL plus SHA-256) into `<prefix>`, and writes the version to `<prefix>/VERSION`. It must not execute any harness code (no install scripts, no `--version`): `prepare` runs on the host with sudo and a cache-capable token; `run.sh` checks the version inside the sandbox with `check_version` from `common.sh`. The prefix is unpacked to `/opt/agent-review/harness/<name>` (read-only) and must run from there without network access. |
| `run.sh` | Runs inside the sandbox from the PR checkout, under `timeout`. Environment: `PROMPT_FILE`, `REPO_DIR`, `OUT_DIR`, `CONTEXT_DIR`, `MODEL`, `HARNESS_PREFIX`, `PR_NUMBER`, and AWF's `AWF_API_PROXY_OPENAI_URL`. Keeps its configuration in a scratch home under `$TMPDIR` (a directory in the workspace), built from environment variables only; disables auto-update, telemetry, sharing and remote model catalogues; sets the harness's request timeouts so that a request that stalls ends and is retried, without shortening how long the run waits for a silent service (`../tests/test-harness-stall.sh`); runs headless and writes `$OUT_DIR/review.md`. Exit codes: 0 review written, 2 ran but no review, anything else a failure. **Return 2, not 0, when the harness exits 0 without a real answer** (a step cap, a stall detector or a tool-call-only last turn can all do that): `run-review` posts whatever `review.md` holds after exit 0. Harness output goes to files in `$OUT_DIR`, which are not collected; print diagnostics only through `diag` in `common.sh`, which prefixes every line so that the harness's output cannot be read as a workflow command. |
| `run.sh` | Runs inside the sandbox from the PR checkout, under `timeout`. Environment: `PROMPT_FILE`, `REPO_DIR`, `OUT_DIR`, `CONTEXT_DIR`, `MODEL`, `HARNESS_PREFIX`, `PR_NUMBER`, `STUB_PADDING_KIB` (stub only: KiB of padding added to the fixed review, to test the size caps), and AWF's `AWF_API_PROXY_OPENAI_URL`, on top of the inherited environment; `run-review` also sets `HOME` and `TMPDIR` to directories in the workspace and forces the `GIT_*` settings of `sandbox_git.py`, so the harness's own git calls get them too. Keeps its configuration in a scratch home under `$TMPDIR` (a directory in the workspace), built from environment variables only; disables auto-update, telemetry, sharing and remote model catalogues; sets the harness's request timeouts so that a request that stalls ends and is retried, without shortening how long the run waits for a silent service (`../tests/test-harness-stall.sh`); runs headless and writes `$OUT_DIR/review.md`. Exit codes: 0 review written, 2 ran but no review, anything else a failure. **Return 2, not 0, when the harness exits 0 without a real answer** (a step cap, a stall detector or a tool-call-only last turn can all do that): `run-review` posts whatever `review.md` holds after exit 0. Harness output goes to files in `$OUT_DIR`, which are not collected; print diagnostics only through `diag` in `common.sh`, which prefixes every line so that the harness's output cannot be read as a workflow command. |
| `wire` | One line: `openai-chat` or `none`. `openai-chat` passes the key to AWF as `OPENAI_API_KEY`; every harness uses AWF's OpenAI listener, `$AWF_API_PROXY_OPENAI_URL` (an origin): clients that append only `/chat/completions` (opencode, Pi) need `$AWF_API_PROXY_OPENAI_URL/v1`. There is no `anthropic-messages` wire: with `ANTHROPIC_API_KEY`, AWF v0.29.12 opens an Anthropic listener whose `POST /messages` is not counted by `maxTurns`, and its entrypoint fails under `filesystem.allowWrite`. An Anthropic-API client can use the OpenAI listener, which forwards `/v1/messages` with a Bearer token (CSCS accepts it). |
| `README.md` | Pinned version, how to upgrade it, the paths it reads as instructions or configuration (add them to `../instruction-files.txt`), and any outbound calls it tries to make. |
| `README.md` | How the version is pinned and upgraded, the paths it reads as instructions or configuration (add them to `../instruction-files.txt`), and any outbound calls it tries to make. |

The harness name must also be added to the harness allowlist in
`agent-review/lib/agent_review/authorize.py` (`KEYED_HARNESSES` or
Expand All @@ -19,14 +19,15 @@ The harness name must also be added to the harness allowlist in
`none`: the `review-keyless` job); both jobs check that the `wire` agrees.
Callers that offer it add it to their `workflow_dispatch` choice.

Recommended: `opencode` with `zai-org/GLM-5.3-Flash`, `pi` as the alternative.

`common.sh` holds the helpers the adapters share: the scratch `HOME`, `NO_PROXY` for loopback and the listeners, and bounded diagnostics.

| Harness | Version | Wire | Ignores the repository's configuration with | Own turn cap |
| --------------------- | ------- | ------------- | ------------------------------------------- | ------------ |
| [opencode](opencode/) | 2.2.7 | `openai-chat` | `OPENCODE_DISABLE_PROJECT_CONFIG=1` | 35 steps |
| [pi](pi/) | 1.5.2 | `openai-chat` | `--no-approve --no-context-files` | none |
| Harness | Wire | Ignores the repository's configuration with | Own turn cap |
| --------------------- | ------------- | ------------------------------------------- | ------------------------ |
| [opencode](opencode/) | `openai-chat` | `OPENCODE_DISABLE_PROJECT_CONFIG=1` | `MAX_STEPS` in `run.sh` |
| [pi](pi/) | `openai-chat` | `--no-approve --no-context-files` | none |

Each harness's version is pinned in its `package.json`; which harness and
model to use is in `docs/agent-review.md` (Configuration notes).

`stub` makes no model call and writes a fixed review with hostile content
(@mentions of a handle that is not a valid login, HTML comments imitating
Expand Down
Loading
Loading