Skip to content

Commit 5993747

Browse files
joe4devclaude
andcommitted
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>
1 parent 82ebd77 commit 5993747

56 files changed

Lines changed: 4395 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: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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+
steps:
33+
# Fail loudly instead of looking tested: a scheduled run on a fork, or a missing secret or model.
34+
- name: Require the secrets and the model
35+
env:
36+
HAS_LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN != '' }}
37+
HAS_OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY != '' }}
38+
OPENROUTER_MODEL: ${{ inputs.model || vars.EVAL_OPENROUTER_MODEL }}
39+
run: |
40+
missing=()
41+
[ "$HAS_LOCALSTACK_AUTH_TOKEN" = "true" ] || missing+=("secret LOCALSTACK_AUTH_TOKEN")
42+
[ "$HAS_OPENROUTER_API_KEY" = "true" ] || missing+=("secret OPENROUTER_API_KEY")
43+
[ -n "$OPENROUTER_MODEL" ] || missing+=("the model input or repository variable EVAL_OPENROUTER_MODEL")
44+
if [ ${#missing[@]} -gt 0 ]; then
45+
echo "::error::Missing: ${missing[*]}"
46+
exit 1
47+
fi
48+
49+
- name: Checkout code
50+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
51+
with:
52+
# later steps run third-party code and the agent: no GitHub token in .git/config
53+
persist-credentials: false
54+
55+
- name: Use Node.js 22
56+
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
57+
with:
58+
node-version: 22.x
59+
60+
- name: Install dependencies
61+
run: yarn install --frozen-lockfile
62+
63+
# The agent under test, at the version in evals/agentic/tools/package-lock.json (Dependabot).
64+
- name: Install Claude Code
65+
run: |
66+
npm ci --prefix evals/agentic/tools --omit=dev --no-audit --no-fund
67+
echo "$GITHUB_WORKSPACE/evals/agentic/tools/node_modules/.bin" >> "$GITHUB_PATH"
68+
69+
# The nightly image, the runner's default: the scenarios need the IAM event details on LocalStack's main branch,
70+
# which a release has only later.
71+
- name: Pull the LocalStack image
72+
run: docker pull localstack/localstack-pro:dev
73+
74+
# The AWS CLI the scenarios' deploy and trigger scripts run, at the version pinned in
75+
# evals/agentic/tools/Dockerfile, ahead of the runner image's own on the PATH.
76+
# TODO: use the host-tools action's AWS CLI once https://github.com/localstack/localstack-mcp-server/pull/137 lands.
77+
- name: Install the AWS CLI
78+
run: |
79+
docker build --output "type=local,dest=$RUNNER_TEMP/awscli" evals/agentic/tools
80+
echo "$RUNNER_TEMP/awscli/aws-cli/bin" >> "$GITHUB_PATH"
81+
"$RUNNER_TEMP/awscli/aws-cli/bin/aws" --version
82+
83+
# Without secrets: the build runs code from node_modules.
84+
- name: Build the MCP server
85+
run: yarn build
86+
87+
# Secrets only for this step. The LocalStack token reaches only the container and the MCP server; the OpenRouter
88+
# key is Claude Code's credential, so the processes Claude Code starts inherit it (evals/agentic/README.md).
89+
- name: Run the agentic evaluation
90+
env:
91+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
92+
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
93+
OPENROUTER_MODEL: ${{ inputs.model || vars.EVAL_OPENROUTER_MODEL }}
94+
MCP_ANALYTICS_DISABLED: "1"
95+
# Weekly: the no-harm checks that matter most (02 guardrail, 05 not IAM) and the cross-account scenarios.
96+
SCENARIO: ${{ github.event_name == 'schedule' && '02,05,06,07,08' || inputs.scenario }}
97+
REPEAT: ${{ inputs.repeat || '1' }}
98+
run: |
99+
args=(--repeat "$REPEAT")
100+
if [ -n "$SCENARIO" ]; then args+=(--scenario "$SCENARIO"); fi
101+
node evals/agentic/run.mjs "${args[@]}"
102+
103+
# The runner redacts secrets before it writes a result; this checks it did, since GitHub does not mask artifacts.
104+
- name: Check the results hold no secret
105+
id: secret-check
106+
if: always()
107+
env:
108+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
109+
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
110+
run: |
111+
[ -d evals/agentic/results ] || exit 0
112+
for value in "$LOCALSTACK_AUTH_TOKEN" "$OPENROUTER_API_KEY"; do
113+
if [ -n "$value" ] && grep -rqF -- "$value" evals/agentic/results; then
114+
echo "::error::A secret is in the results. They are not uploaded; rotate the secret."
115+
exit 1
116+
fi
117+
done
118+
119+
- name: Keep the results
120+
if: always() && steps.secret-check.outcome == 'success'
121+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
122+
with:
123+
name: agentic-eval-results
124+
path: evals/agentic/results
125+
retention-days: 14
126+
if-no-files-found: ignore

‎.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)