Skip to content

feat(azure_policy): test runner, compiler fixes, and example program#700

Merged
anakrish merged 1 commit intomicrosoft:mainfrom
anakrish:azure-policy-compiler-pr-5c
Apr 30, 2026
Merged

feat(azure_policy): test runner, compiler fixes, and example program#700
anakrish merged 1 commit intomicrosoft:mainfrom
anakrish:azure-policy-compiler-pr-5c

Conversation

@anakrish
Copy link
Copy Markdown
Collaborator

@anakrish anakrish commented Apr 27, 2026

Adds the YAML test runner that exercises the test data from #698 and #699, plus several compiler fixes surfaced during testing:

  • Removed parameter register caching that produced wrong results inside short-circuiting allOf/anyOf blocks; added literal-index caching for parameter defaults to avoid repeated O(n) literal-table scans
  • Simplified cross-resource effect details to only emit roleDefinitionIds and type (deployment templates are not evaluated for compliance)
  • Replaced guid/uniqueString builtins with clear "unsupported" errors
  • Normalized datetime output to ISO 8601 with Z suffix
  • Added azure_policy parser MAX_COL constant (8192) for long template expressions, keeping the global DEFAULT_MAX_COL at 1024
  • Added rvm to azure_policy feature dependencies since the compiler targets RVM bytecode

Also restructures the example binary into examples/regorus/ with new azure-policy-eval and azure-policy-aliases subcommands, adds C# alias normalization tests, and documents Azure Policy support in the README.

Part 3 of 3 — split from #695 to enable Copilot review. #698 and #699 are merged.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a YAML-driven Azure Policy test runner and refines Azure Policy compiler/runtime behavior, along with an example CLI workflow and documentation to demonstrate end-to-end policy evaluation.

Changes:

  • Introduces/expands the Rust YAML test harness for Azure Policy parsing/compilation/evaluation (including host-await responses) and updates related parser/builtin test inputs.
  • Applies several Azure Policy compiler/builtin fixes (template function support errors, template-expression handling, cross-resource effect details shaping, parameter default handling) and adjusts lexer length limits.
  • Adds an azure-policy-eval / azure-policy-aliases example flow, C# AliasRegistry tests, and README documentation for Azure Policy usage.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/lexer/mod.rs Updates max-column test to reflect increased default/override limits.
tests/azure_policy_builtins/cases/date_time_add.yaml Aligns datetime builtin expectations with normalized ISO-8601 + timezone output.
tests/azure_policy/parser_tests/mod.rs Minor refactor/cleanup in YAML parser test runner variable naming/flow.
tests/azure_policy/parser_tests/cases/policy_rule.yaml Removes old standalone YAML parser-rule suite cases (now covered elsewhere).
tests/azure_policy/parser_tests/cases/policy_definition.yaml Removes old standalone YAML policy-definition parser suite cases.
tests/azure_policy/normalization/mod.rs Removes the prior YAML-driven normalization test runner.
tests/azure_policy/normalization/cases/round_trip.yaml Removes prior normalization round-trip cases.
tests/azure_policy/normalization/cases/registry_api.yaml Removes prior registry API normalization cases.
tests/azure_policy/normalization/cases/normalize_sub_resources.yaml Removes prior sub-resource normalization cases.
tests/azure_policy/normalization/cases/normalize_envelope.yaml Removes prior envelope normalization cases.
tests/azure_policy/normalization/cases/normalize_basic.yaml Removes prior basic normalization cases.
tests/azure_policy/normalization/cases/malformed_input.yaml Removes prior malformed-input normalization/denormalization behavior pinning.
tests/azure_policy/normalization/cases/envelope_pipeline.yaml Removes prior envelope pipeline normalization test cases.
tests/azure_policy/normalization/cases/edge_cases.yaml Removes prior edge-case normalization behavior pinning.
tests/azure_policy/normalization/cases/denormalize_basic.yaml Removes prior basic denormalization cases.
tests/azure_policy/normalization/cases/denormalize_aliases.yaml Removes prior alias-driven denormalization cases.
tests/azure_policy/normalization/cases/data_plane_manifest.yaml Removes prior data-plane manifest normalization cases.
tests/azure_policy/normalization/cases/data_plane_breadth.yaml Removes prior broad data-plane normalization cases.
tests/azure_policy/normalization/cases/data_plane_advanced.yaml Removes prior advanced data-plane normalization cases.
tests/azure_policy/mod.rs Adds the main YAML test runner that compiles and evaluates Azure Policy programs (including host-await wiring).
src/utils/limits/length.rs Raises DEFAULT_MAX_COL to accommodate long Azure Policy template expressions.
src/languages/azure_policy/mod.rs Exposes the Azure Policy compiler module publicly (under rvm).
src/languages/azure_policy/compiler/template_dispatch.rs Returns clear “unsupported” errors for guid/uniqueString template functions.
src/languages/azure_policy/compiler/expressions.rs Adjusts JSON/template-expression compilation to avoid re-parsing already-resolved top-level literals; removes defaults register caching.
src/languages/azure_policy/compiler/effects_modify_append.rs Alters Modify/Append details handling and preserves Modify condition as literal runtime JSON.
src/languages/azure_policy/compiler/effects.rs Narrows cross-resource structured effect details emission to roleDefinitionIds and type.
src/languages/azure_policy/compiler/core.rs Removes cached parameter-defaults register tracking from register cleanup logic.
src/builtins/azure_policy/template_functions_misc.rs Updates notes around guid/uniqueString being unimplemented and template-only.
src/builtins/azure_policy/template_functions_datetime.rs Normalizes datetime parsing/formatting to always emit ISO-8601 with explicit timezone (Z for UTC).
examples/regorus/main.rs Adds azure-policy-eval and azure-policy-aliases subcommands (feature-gated).
examples/regorus/azure_policy_data/require_https_storage.json Adds a sample Azure Policy definition used by the example CLI.
examples/regorus/azure_policy_data/non_compliant_storage.json Adds a non-compliant sample resource for the example CLI.
examples/regorus/azure_policy_data/compliant_storage.json Adds a compliant sample resource for the example CLI.
examples/regorus/azure_policy.rs Implements the Azure Policy example subcommands: compile + normalize + evaluate pipeline, plus alias listing.
bindings/csharp/Regorus.Tests/AzurePolicyTests.cs Adds C# AliasRegistry normalization/denormalization tests via bindings.
README.md Documents Azure Policy preview support and provides quick-start commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/languages/azure_policy/compiler/effects_modify_append.rs Outdated
Comment thread tests/azure_policy/mod.rs Outdated
Comment thread tests/azure_policy/mod.rs Outdated
Comment thread tests/azure_policy/mod.rs Outdated
Comment thread src/languages/azure_policy/compiler/effects_modify_append.rs
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/azure_policy/mod.rs
Comment thread tests/azure_policy/mod.rs
@anakrish anakrish force-pushed the azure-policy-compiler-pr-5c branch from 658c039 to 71b0bfb Compare April 27, 2026 21:19
@anakrish anakrish requested a review from Copilot April 27, 2026 21:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 45 out of 45 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/azure_policy/mod.rs
Comment thread tests/azure_policy/cases/e2e_storage_ip_allowlist.yaml Outdated
Comment thread tests/azure_policy/mod.rs Outdated
Comment thread tests/azure_policy/mod.rs
Comment thread tests/azure_policy/mod.rs Outdated
Comment thread tests/azure_policy/mod.rs Outdated
@anakrish anakrish force-pushed the azure-policy-compiler-pr-5c branch 3 times, most recently from 78a14e6 to a2d00ee Compare April 28, 2026 03:07
@anakrish anakrish requested a review from Copilot April 28, 2026 03:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 41 out of 41 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/azure_policy/parser_tests/mod.rs Outdated
Comment thread tests/azure_policy/mod.rs
Comment thread src/languages/azure_policy/compiler/effects.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 41 out of 41 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (2)

examples/regorus/main.rs:7

  • mod azure_policy is gated only on feature = "azure_policy", but the module (and the AzurePolicyEval subcommand) uses regorus::rvm and the Azure Policy compiler module, which are behind feature = "rvm". Building with --no-default-features --features azure_policy will fail to compile. Consider gating the module/subcommand on all(feature = "azure_policy", feature = "rvm"), or splitting the module so non-RVM pieces (like alias listing) can still compile without rvm.
    examples/regorus/main.rs:308
  • Both AzurePolicyEval and AzurePolicyAliases variants are gated only on feature = "azure_policy", but AzurePolicyEval requires rvm (RegoVM + compiler). If you want azure-policy-aliases to be usable without rvm, gate only the eval variant on all(feature = "azure_policy", feature = "rvm") and keep the aliases variant on feature = "azure_policy" (and adjust the azure_policy module accordingly).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/limits/length.rs Outdated
Comment thread src/builtins/azure_policy/template_functions_datetime.rs
Comment thread examples/regorus/azure_policy.rs
@anakrish anakrish force-pushed the azure-policy-compiler-pr-5c branch 2 times, most recently from 9a1dd30 to ebf05fb Compare April 28, 2026 14:38
@anakrish anakrish requested a review from Copilot April 28, 2026 14:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 41 out of 41 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/languages/azure_policy/compiler/expressions.rs
Comment thread bindings/csharp/Regorus.Tests/AzurePolicyTests.cs
@anakrish anakrish force-pushed the azure-policy-compiler-pr-5c branch 4 times, most recently from d0e35bb to a5f7566 Compare April 28, 2026 20:37
@anakrish anakrish requested a review from Copilot April 28, 2026 20:37
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/languages/azure_policy/compiler/effects.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/azure_policy_builtins/cases/date_time_add.yaml Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/azure_policy/mod.rs
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@anakrish anakrish force-pushed the azure-policy-compiler-pr-5c branch from ea596ed to cd71ce7 Compare April 30, 2026 01:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/languages/azure_policy/parser/mod.rs Outdated
Comment thread src/languages/azure_policy/parser/mod.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/azure_policy_builtins/cases/date_time_add.yaml Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/languages/azure_policy/compiler/effects.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/languages/azure_policy/compiler/effects_modify_append.rs
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/languages/azure_policy/compiler/effects_modify_append.rs Outdated
Adds the YAML test runner that exercises the companion test data PRs, plus
several compiler fixes surfaced during testing:

- Removed parameter register caching that produced wrong results inside
  short-circuiting allOf/anyOf blocks; added literal-index caching for
  parameter defaults to avoid repeated O(n) literal-table scans
- Simplified cross-resource effect details to only emit roleDefinitionIds
  and type (deployment templates are not evaluated for compliance)
- Replaced guid/uniqueString builtins with clear "unsupported" errors
- Normalized datetime output to ISO 8601 with Z suffix
- Added azure_policy parser MAX_COL constant (8192) for long template
  expressions, keeping the global DEFAULT_MAX_COL at 1024
- Added rvm to azure_policy feature dependencies since the compiler
  targets RVM bytecode

Also restructures the example binary into examples/regorus/ with new
azure-policy-eval and azure-policy-aliases subcommands, adds C# alias
normalization tests, and documents Azure Policy support in the README.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/azure_policy/mod.rs
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants