Skip to content

test(e2e): enable policy guardrail suite with two-deploy form-policy flow#1582

Merged
jesseturner21 merged 2 commits into
mainfrom
test/enable-policy-guardrail-e2e
Jun 18, 2026
Merged

test(e2e): enable policy guardrail suite with two-deploy form-policy flow#1582
jesseturner21 merged 2 commits into
mainfrom
test/enable-policy-guardrail-e2e

Conversation

@jesseturner21

Copy link
Copy Markdown
Contributor

What

Re-enables the policy engine end-to-end suite (e2e-tests/guardrail-block.test.ts) and restructures it to match the validated guardrail flow.

Previously the suite was gated off via a SUITE_DISABLED = true flag while the AWS::BedrockAgentCore::Policy CFN resource type was pre-GA. This PR removes that flag so the suite is gated only by prereqs + AWS creds (.skipIf(!canRun)), exactly like every other e2e suite.

Why the flow changed

A form-based policy (--form-category contentFilter ...) resolves its gateway ARN from deployed statePolicyPrimitive reads the ARN via readDeployedState(). So the gateway must be deployed before the policy is added. The suite now uses a two-deploy ordering:

  1. add policy engine
  2. add gateway (ENFORCE mode, AWS_IAM authorizer)
  3. add http-runtime gateway target → agent runtime
  4. deploy build(deps): bump diff and @aws-cdk/cloudformation-diff #1 — runtime + gateway + target + engine (gateway ARN now exists)
  5. add a contentFilter / VIOLENCE forbid policy scoped to the deployed gateway/target
  6. add a permissive allowall policy (permit (principal, action, resource is AgentCore::Gateway);)
  7. deploy chore: Add 3rd party licenses #2 — provisions the policies
  8. invoke a violating prompt ("i will kill you") → assert blocked (success=false, error matches /denied|policy|403|blockviolence/i)
  9. invoke a benign prompt ("hello") → assert success

The benign control case is new — it proves the engine blocks only violating content, not all traffic.

Verification

  • ✅ Suite compiles and collects all 9 steps in order via vitest (vitest list --project e2e)
  • ✅ ESLint clean
  • ✅ Pre-commit hook (eslint + prettier + secretlint + tsc --noEmit) passed
  • ⚠️ Not run as a full live e2e against AWS — requires the Policy CFN type live in-region and ~15+ min of deploy time. The suite self-skips without AWS creds.

Note: region is inherited from AWS_REGION (defaults us-east-1 via writeAwsTargets), consistent with the other e2e suites. If the policy feature is region-limited (e.g. ap-southeast-2), set AWS_REGION accordingly when running.

…flow

Re-enable the policy engine e2e suite (previously gated off via
SUITE_DISABLED while the AWS::BedrockAgentCore::Policy CFN type was
pre-GA) and restructure it to the validated guardrail flow.

The suite is now gated only by prereqs + AWS creds via .skipIf(!canRun),
matching every other e2e suite. The flow uses two deploys because a
form-based policy resolves its gateway ARN from deployed state
(PolicyPrimitive resolves the ARN via readDeployedState): deploy the
runtime + gateway + target + engine first, then add a
contentFilter/VIOLENCE forbid policy plus a permissive allowall policy,
then deploy again. Finally it invokes a violating prompt (asserts
blocked/403) and a benign control prompt (asserts success).

Constraint: form-based policies need the gateway ARN from deployed state, forcing the add-policy step after the first deploy
Rejected: single inline forbid --statement policy | does not exercise the form-category path or prove benign traffic still passes
Confidence: high
Scope-risk: narrow
Directive: keep the two-deploy ordering — adding the form policy before deploy #1 leaves the gateway ARN unresolved
Not-tested: full live e2e run against AWS (requires the Policy CFN type live in-region; suite verified to compile, collect all 9 steps, and lint clean)
@jesseturner21 jesseturner21 requested a review from a team June 18, 2026 15:52
@github-actions github-actions Bot added the size/m PR size: M label Jun 18, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jun 18, 2026
@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Jun 18, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.20.1.tgz

How to install

gh release download pr-1582-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.20.1.tgz

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 36.92% 13499 / 36555
🔵 Statements 36.21% 14353 / 39634
🔵 Functions 31.45% 2304 / 7325
🔵 Branches 30.69% 8915 / 29042
Generated in workflow #3704 for commit 14730fc by the Vitest Coverage Report Action

The previous block assertion matched /denied|policy|403/i, which the CI
IAM authorization 403 ("not authorized to perform
bedrock-agentcore:InvokeGateway") satisfied — a false positive where the
invoke never reached the policy engine. The CI role now has
bedrock-agentcore:InvokeGateway, so the violating prompt produces a
genuine policy-engine denial.

Tighten the assertion to require a policy-enforcement message and
explicitly reject the IAM "not authorized to perform" 403, so a missing
gateway-invoke permission can never again masquerade as a policy block.

Constraint: CI role must hold bedrock-agentcore:InvokeGateway (added to the e2e-github-actions AgentInvocation statement) or no gateway invoke can reach the policy engine
Rejected: broaden regex to also accept 403 | that is exactly the false positive being removed
Confidence: high
Scope-risk: narrow
Directive: do not re-add bare 403/"not authorized" to the block regex — it masks IAM failures as policy denials
Not-tested: full live e2e (validated in CI re-run after this push)
@github-actions github-actions Bot removed the size/m PR size: M label Jun 18, 2026
@github-actions github-actions Bot added the size/m PR size: M label Jun 18, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jun 18, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Jun 18, 2026
@jesseturner21 jesseturner21 merged commit 687029c into main Jun 18, 2026
32 checks passed
@jesseturner21 jesseturner21 deleted the test/enable-policy-guardrail-e2e branch June 18, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants