Skip to content

Commit 12d0ad3

Browse files
joe4devclaude
andauthored
test: live agentic evaluation of the IAM actions (#141)
* test: agentic evaluation of the IAM actions with Claude Code evals/agentic runs Claude Code headless against an isolated LocalStack on a random port, on small CloudFormation projects that fail on IAM, and grades the deployed state after a clean redeploy (no LLM judge). Every arm gets the AWS CLI and LocalStack's log; --without-mcp drops the server for a fair baseline. - 06-08: the deciding policy is in another account the agent can't read (event bus source, KMS encryption context, bucket prefix by principal tag). They show what the server adds. - 01-05: no-harm checks where the agent can read every policy: a missing permission, an explicit deny and a permissions boundary (guardrails the agent must not weaken), a Lambda resource policy, and a failure that isn't IAM. - Whether the agent called localstack-app-inspector or localstack-iam-policy-analyzer is reported, not graded. - agentic-eval.yml runs on demand (every scenario unless one is given) and weekly (02, 05, 06-08) through OpenRouter. Secrets stay out of the agent's scripts and the uploaded results; Claude Code and the AWS CLI are pinned where Dependabot updates them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(agentic-eval): job summary, weekly history issue, 30-day results - lib/summary.mjs renders a results.json as a markdown table (pass rate, tools used, turns, time, cost, failed checks, versions); no agent text - the workflow writes it to the job summary - weekly runs comment it on the issue "Agentic eval history" (created on the first run), from a separate job that holds no secret and may only write issues - the results artifact is kept for 30 days instead of 14 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7ca58c6 commit 12d0ad3

58 files changed

Lines changed: 4578 additions & 10 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/dependabot.yml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ updates:
2525
# when it no longer applies. Bump it by hand and redo or drop the patch.
2626
- dependency-name: "@gleanwork/mcp-server-tester"
2727

28-
# CLIs inside the Docker image (aws-cdk, lstk) and the CDK sample app that CI deploys with them.
28+
# CLIs inside the Docker image (aws-cdk, lstk), the CDK sample app that CI deploys with them, and the
29+
# coding agent the agentic eval runs (Claude Code).
2930
- package-ecosystem: npm
3031
directories:
3132
- /docker/tools/npm
3233
- /data/sample-cdk
34+
- /evals/agentic/tools
3335
schedule:
3436
interval: weekly
3537
cooldown:
@@ -61,7 +63,11 @@ updates:
6163

6264
# FROM lines in the Dockerfile: node and hashicorp/terraform.
6365
- package-ecosystem: docker
64-
directory: /
66+
directories:
67+
- /
68+
# TODO: remove with evals/agentic/tools/Dockerfile once
69+
# https://github.com/localstack/localstack-mcp-server/pull/137 lands
70+
- /evals/agentic/tools
6571
schedule:
6672
interval: weekly
6773
cooldown:

‎.github/workflows/agentic-eval.yml‎

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: Agentic eval
2+
3+
# A coding agent (Claude Code headless, through OpenRouter) fixes common IAM failures with this MCP server, the AWS
4+
# CLI and LocalStack's log.
5+
# On demand (every scenario unless one is given) and weekly (02, 05 and 06-08): each run costs model tokens and takes
6+
# a few minutes per scenario.
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
scenario:
11+
description: "Scenario prefix to run (e.g. 01); empty runs all"
12+
required: false
13+
default: ""
14+
repeat:
15+
description: "Runs per scenario"
16+
required: false
17+
default: "1"
18+
model:
19+
description: "OpenRouter model slug (defaults to the repository variable EVAL_OPENROUTER_MODEL)"
20+
required: false
21+
default: ""
22+
schedule:
23+
- cron: "0 5 * * 1"
24+
25+
permissions:
26+
contents: read
27+
28+
jobs:
29+
agentic-eval:
30+
runs-on: ubuntu-26.04
31+
timeout-minutes: 120
32+
outputs:
33+
summary: ${{ steps.summary.outputs.summary }}
34+
steps:
35+
# Fail loudly instead of looking tested: a scheduled run on a fork, or a missing secret or model.
36+
- name: Require the secrets and the model
37+
env:
38+
HAS_LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN != '' }}
39+
HAS_OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY != '' }}
40+
OPENROUTER_MODEL: ${{ inputs.model || vars.EVAL_OPENROUTER_MODEL }}
41+
run: |
42+
missing=()
43+
[ "$HAS_LOCALSTACK_AUTH_TOKEN" = "true" ] || missing+=("secret LOCALSTACK_AUTH_TOKEN")
44+
[ "$HAS_OPENROUTER_API_KEY" = "true" ] || missing+=("secret OPENROUTER_API_KEY")
45+
[ -n "$OPENROUTER_MODEL" ] || missing+=("the model input or repository variable EVAL_OPENROUTER_MODEL")
46+
if [ ${#missing[@]} -gt 0 ]; then
47+
echo "::error::Missing: ${missing[*]}"
48+
exit 1
49+
fi
50+
51+
- name: Checkout code
52+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
53+
with:
54+
# later steps run third-party code and the agent: no GitHub token in .git/config
55+
persist-credentials: false
56+
57+
- name: Use Node.js 22
58+
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
59+
with:
60+
node-version: 22.x
61+
62+
- name: Install dependencies
63+
run: yarn install --frozen-lockfile
64+
65+
# The agent under test, at the version in evals/agentic/tools/package-lock.json (Dependabot).
66+
- name: Install Claude Code
67+
run: |
68+
npm ci --prefix evals/agentic/tools --omit=dev --no-audit --no-fund
69+
echo "$GITHUB_WORKSPACE/evals/agentic/tools/node_modules/.bin" >> "$GITHUB_PATH"
70+
71+
# The nightly image, the runner's default: the scenarios need the IAM event details on LocalStack's main branch,
72+
# which a release has only later.
73+
- name: Pull the LocalStack image
74+
run: docker pull localstack/localstack-pro:dev
75+
76+
# The AWS CLI the scenarios' deploy and trigger scripts run, at the version pinned in
77+
# evals/agentic/tools/Dockerfile, ahead of the runner image's own on the PATH.
78+
# TODO: use the host-tools action's AWS CLI once https://github.com/localstack/localstack-mcp-server/pull/137 lands.
79+
- name: Install the AWS CLI
80+
run: |
81+
docker build --output "type=local,dest=$RUNNER_TEMP/awscli" evals/agentic/tools
82+
echo "$RUNNER_TEMP/awscli/aws-cli/bin" >> "$GITHUB_PATH"
83+
"$RUNNER_TEMP/awscli/aws-cli/bin/aws" --version
84+
85+
# Without secrets: the build runs code from node_modules.
86+
- name: Build the MCP server
87+
run: yarn build
88+
89+
# Secrets only for this step. The LocalStack token reaches only the container and the MCP server; the OpenRouter
90+
# key is Claude Code's credential, so the processes Claude Code starts inherit it (evals/agentic/README.md).
91+
- name: Run the agentic evaluation
92+
env:
93+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
94+
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
95+
OPENROUTER_MODEL: ${{ inputs.model || vars.EVAL_OPENROUTER_MODEL }}
96+
MCP_ANALYTICS_DISABLED: "1"
97+
# Weekly: the no-harm checks that matter most (02 guardrail, 05 not IAM) and the cross-account scenarios.
98+
SCENARIO: ${{ github.event_name == 'schedule' && '02,05,06,07,08' || inputs.scenario }}
99+
REPEAT: ${{ inputs.repeat || '1' }}
100+
run: |
101+
args=(--repeat "$REPEAT")
102+
if [ -n "$SCENARIO" ]; then args+=(--scenario "$SCENARIO"); fi
103+
node evals/agentic/run.mjs "${args[@]}"
104+
105+
# The runner redacts secrets before it writes a result; this checks it did, since GitHub does not mask artifacts.
106+
- name: Check the results hold no secret
107+
id: secret-check
108+
if: always()
109+
env:
110+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
111+
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
112+
run: |
113+
[ -d evals/agentic/results ] || exit 0
114+
for value in "$LOCALSTACK_AUTH_TOKEN" "$OPENROUTER_API_KEY"; do
115+
if [ -n "$value" ] && grep -rqF -- "$value" evals/agentic/results; then
116+
echo "::error::A secret is in the results. They are not uploaded; rotate the secret."
117+
exit 1
118+
fi
119+
done
120+
121+
# A table per run (pass rate, tools used, turns, time, cost, failed checks, versions) on the run page, and for
122+
# the history issue. Only numbers and names: no transcript or agent text.
123+
- name: Summarize the results
124+
id: summary
125+
if: always() && steps.secret-check.outcome == 'success'
126+
run: |
127+
shopt -s nullglob
128+
files=(evals/agentic/results/*/results.json)
129+
if [ ${#files[@]} -eq 0 ]; then
130+
summary="### Agentic eval: no results (the run failed before the evaluation finished)"
131+
else
132+
summary=$(node evals/agentic/lib/summary.mjs "${files[@]}")
133+
fi
134+
echo "$summary" >> "$GITHUB_STEP_SUMMARY"
135+
{
136+
echo "summary<<EVAL_SUMMARY_EOF"
137+
echo "$summary"
138+
echo "EVAL_SUMMARY_EOF"
139+
} >> "$GITHUB_OUTPUT"
140+
141+
- name: Keep the results
142+
if: always() && steps.secret-check.outcome == 'success'
143+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
144+
with:
145+
name: agentic-eval-results
146+
path: evals/agentic/results
147+
retention-days: 30
148+
if-no-files-found: ignore
149+
150+
# The weekly history: one comment per scheduled run on the issue "Agentic eval history", created on the first run.
151+
# A job of its own, so the token that may write issues never shares a job with the secrets or the agent.
152+
history:
153+
needs: agentic-eval
154+
if: always() && github.event_name == 'schedule'
155+
runs-on: ubuntu-26.04
156+
timeout-minutes: 5
157+
permissions:
158+
issues: write
159+
steps:
160+
- name: Comment the summary on the history issue
161+
env:
162+
GH_TOKEN: ${{ github.token }}
163+
GH_REPO: ${{ github.repository }}
164+
SUMMARY: ${{ needs.agentic-eval.outputs.summary }}
165+
RESULT: ${{ needs.agentic-eval.result }}
166+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
167+
run: |
168+
title="Agentic eval history"
169+
issue=$(gh issue list --state open --search "in:title \"$title\"" --json number,title \
170+
--jq "map(select(.title == \"$title\")) | .[0].number // empty")
171+
if [ -z "$issue" ]; then
172+
issue=$(gh issue create --title "$title" \
173+
--body "One comment per weekly run of the agentic evaluation (.github/workflows/agentic-eval.yml): pass rate, tools used, turns, time, cost and versions per scenario. The full results are kept as the run's artifact for 30 days." \
174+
| grep -oE '[0-9]+$')
175+
fi
176+
body="${SUMMARY:-### Agentic eval: no summary}"
177+
printf '%s\n\nRun: %s (%s)\n' "$body" "$RUN_URL" "$RESULT" > "$RUNNER_TEMP/comment.md"
178+
gh issue comment "$issue" --body-file "$RUNNER_TEMP/comment.md"

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
- name: Unit tests
3333
run: yarn test
3434

35+
- name: Unit tests of the agentic eval runner
36+
run: yarn test:evals
37+
3538
- name: Build the project
3639
run: yarn build
3740

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ terraform.tfstate*
1111
.terraform/
1212
.terraform.lock.hcl
1313
.mcp-test-results/
14+
evals/agentic/results/
1415
.DS_Store
1516
cdk.out/

‎AGENTS.md‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ yarn test # Jest unit tests: *.test.ts next to the code, handler t
2121
yarn test:mcp:direct # Playwright: calls the built server's tools directly, plus the Azure offline suite (needs Docker + LOCALSTACK_AUTH_TOKEN)
2222
yarn test:mcp:tools # Playwright: each tool against a real LocalStack, no model (needs Docker + LOCALSTACK_AUTH_TOKEN)
2323
yarn test:mcp:evals # Playwright: LLM evals through OpenRouter (needs OPENROUTER_API_KEY, LOCALSTACK_AUTH_TOKEN, and terraform, lstk and snow on PATH; EVAL_MODEL swaps the model)
24+
yarn test:evals # node --test: unit tests of the agentic eval runner (evals/agentic/lib)
25+
yarn eval:agentic # Claude Code fixes IAM failures with this server and the AWS CLI (needs Docker, the AWS CLI, Claude Code, LOCALSTACK_AUTH_TOKEN; see evals/agentic/README.md)
2426
yarn format # Prettier
2527
```
2628

@@ -38,6 +40,7 @@ yarn format # Prettier
3840
| `src/tools-tests/` | Handler tests, one file per tool. They live outside `src/tools/` because xmcp registers every file there as a tool. |
3941
| `tests/mcp/` | Playwright tests against the built server. |
4042
| `tests/docker/` | Validation of the Docker image. |
43+
| `evals/agentic/` | The agentic evaluation of the IAM actions: scenarios, runner, and the pinned tools it runs. |
4144
| `docs/` | Topic docs. |
4245

4346
## Writing a tool
@@ -67,6 +70,8 @@ the failing test first when fixing a bug in `src/`.
6770
| Tools | `tests/mcp/tools.spec.mjs` | every PR, with the auth token | Each tool over MCP stdio against a real emulator, without a model. |
6871
| Server | `tests/mcp/direct.spec.mjs` | every PR, with the auth token | The built server: tool list, prompts, setup wizard. |
6972
| Image | `tests/docker/validate-image.mjs` | `docker.yml`, with the auth token | Real calls through the Docker image. |
73+
| Evals | `data/evals/comprehensive.json` (`tests/mcp/evals.spec.mjs`) | after merges to `main`, weekly, on demand | Whether a model picks the right tool and action for a request. |
74+
| Agentic | `evals/agentic/` (`agentic-eval.yml`) | weekly, on demand | Whether a coding agent fixes a whole project with the tools, graded by its final state. |
7075

7176
Rules for tool tests:
7277

@@ -330,7 +335,12 @@ Inspector and enabling it again deletes what it recorded, unless persistence is
330335
Render every payload string escaped (REVIEW §7): an ARN, a resource name or an error message must not be able to
331336
close a code fence, break a table, or leave its fence or cell.
332337

333-
An agentic evaluation of these actions is a follow-up (see [Follow-ups](#follow-ups)).
338+
`evals/agentic/` checks the actions end to end: Claude Code, given this server's IAM tools, the AWS CLI and
339+
LocalStack's log, fixes small CloudFormation projects and is graded by the deployed state after a clean redeploy (see its README). Under REVIEW
340+
§0 it keeps the auth token in a private MCP config deleted after the run, runs its own scripts and git without
341+
secrets and outside the agent's reach, redacts the results and checks them before upload, and pins the tools it
342+
runs where Dependabot updates them. The model key is Claude Code's credential, so the processes Claude Code
343+
starts inherit it.
334344

335345
## Gaps in LocalStack
336346

@@ -421,12 +431,6 @@ Decisions not settled yet. Ask the user before acting on one, and move the answe
421431

422432
Planned work that is not on `main` yet. Ask the user before starting one.
423433

424-
- **Agentic evaluation of the IAM actions.** A coding agent (Claude Code headless) fixes common IAM failures in small
425-
projects using only this server, graded by deterministic checks, on demand and weekly. Before it lands it must
426-
meet REVIEW §0 and "Dependencies": the agent and the scripts it runs get no secrets, the MCP config holding the
427-
auth token is private and deleted after the run, the agent can read and edit only its project and cannot change
428-
the scripts it may run, results are redacted and checked before upload, workflow inputs go through `env:`, and
429-
Claude Code is pinned in a lockfile Dependabot updates.
430434
- **`lstk mcp`'s `failed-requests` action (lstk, unreleased).** It groups App Inspector's failed spans
431435
(`status_code=2`) by service, operation, HTTP status and AWS error code, with counts, first and last time and the
432436
latest example. That computation is an approved exception to rule 5: approved by the

0 commit comments

Comments
 (0)