Skip to content

feat(core): add scope to IPolicyValidationContext#38006

Open
kaizencc wants to merge 2 commits into
mainfrom
feat/core-validation-context-scope
Open

feat(core): add scope to IPolicyValidationContext#38006
kaizencc wants to merge 2 commits into
mainfrom
feat/core-validation-context-scope

Conversation

@kaizencc
Copy link
Copy Markdown
Contributor

@kaizencc kaizencc commented May 26, 2026

Summary

  • Adds an optional scope property to IPolicyValidationContext (and the deprecated IPolicyValidationContextBeta1) exposing the root construct of the app being validated.
  • Plugins can now walk the construct tree for typed L1 property access and token resolution via Stack.of(node).resolve(), rather than re-parsing synthesized JSON templates.
  • The field is optional — existing plugins continue to work unchanged.

Test plan

  • New unit test: validate context includes scope as the root construct — verifies plugin receives the App as scope
  • Updated existing multi-stage tests to use expect.objectContaining (they were exact-matching the context shape)
  • Full validation test suite passes (49/49)

Adds an optional `scope` property to `IPolicyValidationContext` (and the
deprecated `IPolicyValidationContextBeta1`) that exposes the root
construct of the app being validated. This allows plugins to walk the
construct tree for typed L1 property access and token resolution via
`Stack.of(node).resolve()` instead of re-parsing JSON templates.

The field is optional to preserve backwards compatibility — existing
plugins continue to work unchanged.
@kaizencc kaizencc requested a review from a team as a code owner May 26, 2026 17:41
@github-actions github-actions Bot added the p2 label May 26, 2026
@mergify mergify Bot added the contribution/core This is a PR that came from AWS. label May 26, 2026
@mergify mergify Bot temporarily deployed to automation May 26, 2026 17:42 Inactive
@mergify mergify Bot temporarily deployed to automation May 26, 2026 17:42 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

⚠️ This pull request description does not follow the correct template structure.

PRs without a linked issue will receive lower priority for review and merging. Please update the description to follow the PR template and include a line like Closes #123 in the Issue section. If no existing issue matches your change, create one first.

Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@kaizencc kaizencc added pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels May 26, 2026
@aws-cdk-automation aws-cdk-automation dismissed their stale review May 26, 2026 17:51

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label May 26, 2026
@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label May 27, 2026
Copy link
Copy Markdown
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditional approval, I do want you to change the contract slightly.

*
* @default - not provided
*/
readonly scope?: IConstruct;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
readonly scope?: IConstruct;
readonly appConstruct: IConstruct;

Two changes:

  • Always present. It's something that we always guarantee to plugin writers that exists. So it's a stronger guarantee than optional, which is fine. If this causes a jsii-diff problem, you can silence it.
  • If you call it scope, it makes me think that we get called multiple times at different points in the tree, but that's not what it is. So name it more strongly to what it represent.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label May 27, 2026
Address review feedback:
- Rename `scope` to `appConstruct` to better convey that this is the
  app root, not a per-invocation scope
- Make the property required since we always guarantee it to plugin
  writers
@kaizencc kaizencc force-pushed the feat/core-validation-context-scope branch from 8b3f4ff to 4bbccdb Compare May 27, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. p2 pr/do-not-merge This PR should not be merged at this time. pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-readme The PR linter will not require README changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants