Skip to content

fix(policy): scope target guardrails to gateway tools - #2423

Open
rksharma-owg wants to merge 1 commit into
aws:mainfrom
rksharma-owg:fix/policy-target-cedar-2395
Open

rksharma-owg wants to merge 1 commit into
aws:mainfrom
rksharma-owg:fix/policy-target-cedar-2395

Conversation

@rksharma-owg

Copy link
Copy Markdown

Description

Fixes tool-scoped guardrail policies generated by agentcore add policy --target. The generated Cedar statement now uses the target's single known tool name (for example, websearch___WebSearch) and resolves the containing deployed gateway when --gateway is omitted, producing the required ARN-scoped resource constraint. Ambiguous target-to-gateway mappings are rejected instead of guessed.

Root cause

The form-mode policy command passed only the target name to Cedar synthesis, which hard-coded POST:/invocations and omitted the gateway ARN unless --gateway was explicitly supplied. AgentCore policy validation requires the target tool action identifier and a concrete gateway resource for tool-scoped policies.

Testing

  • npx vitest run src/cli/tui/screens/policy/__tests__/synthesize-cedar.test.ts src/cli/primitives/__tests__/PolicyPrimitive.test.ts
  • npm run build
  • npm run format:check
  • npm run lint (existing warnings only)
  • Fork preflight: run 36379287231

Local repository-wide npm run typecheck is blocked by pre-existing fetch/stream typing errors, but the same check passed in the fork preflight above.

Related Issue

Closes #2395

@rksharma-owg
rksharma-owg requested a review from a team September 28, 2026 04:53
@github-actions github-actions Bot added the size/m PR size: M label Sep 28, 2026

This branch has not been deployed

No deployments
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.

bug(policy): add policy --target generates an undeployable Cedar statement (wrong action id suffix, resource scope not narrowed)

1 participant