Skip to content

Normalizer#635

Draft
anakrish wants to merge 5 commits intomicrosoft:mainfrom
anakrish:normalizer
Draft

Normalizer#635
anakrish wants to merge 5 commits intomicrosoft:mainfrom
anakrish:normalizer

Conversation

@anakrish
Copy link
Copy Markdown
Collaborator

No description provided.

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 Azure Policy “alias” support to Regorus by introducing an alias registry plus normalization/denormalization logic (control-plane and data-plane), along with extensive YAML-driven test coverage, documentation, benchmarks, and FFI/C# bindings to expose the registry to consumers.

Changes:

  • Introduce languages::azure_policy::aliases (types, registry, normalizer, denormalizer) and expose it behind the azure_policy feature.
  • Add YAML-driven normalization/denormalization/round-trip tests and supporting alias catalogs/manifests.
  • Add FFI + C# wrapper API for AliasRegistry, plus a Criterion benchmark and dependency updates (incl. lockfiles).

Reviewed changes

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

Show a summary per file
File Description
tests/mod.rs Conditionally enables Azure Policy test module under azure_policy feature.
tests/azure_policy/mod.rs Azure Policy test root module.
tests/azure_policy/normalization/mod.rs YAML-driven normalization/denormalization/envelope test runner.
tests/azure_policy/normalization/cases/round_trip.yaml Round-trip normalization/denormalization scenarios (incl. versioned remap regression).
tests/azure_policy/normalization/cases/registry_api.yaml Exercises public AliasRegistry APIs (normalize/denormalize/normalize_and_wrap).
tests/azure_policy/normalization/cases/normalize_sub_resources.yaml Sub-resource array flattening test cases.
tests/azure_policy/normalization/cases/normalize_envelope.yaml Envelope construction expectations.
tests/azure_policy/normalization/cases/normalize_basic.yaml Basic normalization behaviors (flatten properties, root precedence, etc.).
tests/azure_policy/normalization/cases/malformed_input.yaml Pins behavior for malformed/unexpected inputs.
tests/azure_policy/normalization/cases/envelope_pipeline.yaml End-to-end normalize+wrap pipeline case.
tests/azure_policy/normalization/cases/edge_cases.yaml Edge-case behavior pinning for ambiguous/malformed inputs.
tests/azure_policy/normalization/cases/denormalize_basic.yaml Basic denormalization behaviors.
tests/azure_policy/normalization/cases/denormalize_aliases.yaml Denormalization with alias-based casing restoration + arrays.
tests/azure_policy/normalization/cases/data_plane_manifest.yaml Data-plane manifest loading + normalization coverage.
tests/azure_policy/normalization/cases/data_plane_breadth.yaml Broader data-plane shape coverage across namespaces.
tests/azure_policy/normalization/cases/data_plane_advanced.yaml Advanced data-plane shapes (top-level aliases, schemaVersions, arrays).
tests/azure_policy/aliases/versioned_aliases.json Versioned alias catalog fixture for tests.
src/lib.rs Exposes languages::azure_policy behind feature flag.
src/languages/mod.rs Adds azure_policy to languages module file (currently unused by crate wiring).
src/languages/azure_policy/mod.rs Defines Azure Policy language module + clippy allowances; exports aliases.
src/languages/azure_policy/aliases/types.rs Alias/manifest schema types + resolved/precomputed structures.
src/languages/azure_policy/aliases/obj_map.rs Internal hash map utilities + nested set helpers + ROOT_FIELDS.
src/languages/azure_policy/aliases/normalizer/mod.rs Normalizer entry points + envelope builder.
src/languages/azure_policy/aliases/normalizer/flatten.rs Recursive normalization helpers + sub-resource flattening.
src/languages/azure_policy/aliases/normalizer/element_remap.rs Array element-level remap logic used for versioned wildcard aliases.
src/languages/azure_policy/aliases/normalizer/alias_resolution.rs Applies alias resolution + precomputed aggregates to normalized output.
src/languages/azure_policy/aliases/denormalizer/mod.rs Denormalization pipeline back to ARM JSON + aggregates application.
src/languages/azure_policy/aliases/denormalizer/helpers.rs CI key lookup + element field removal utilities.
src/languages/azure_policy/aliases/denormalizer/sub_resource.rs Rewraps sub-resource array elements back under properties.
src/languages/azure_policy/aliases/denormalizer/casing.rs Restores key casing using alias metadata-derived map.
src/languages/azure_policy/aliases/denormalizer/tests.rs Inline unit tests for denormalizer helpers/casing.
docs/azure-policy/aliases.md Design discussion and rationale for alias approach.
docs/azure-policy/alias-normalization.md Detailed normalization spec and end-to-end flow documentation.
check_aliases.py Helper script to validate presence of needed aliases in fixtures.
benches/normalization_benchmark.rs Criterion benchmark suite for normalization/denormalization performance.
Cargo.toml Adds hashbrown dependency and new normalization_benchmark bench target.
Cargo.lock Lockfile updates from new dependency graph.
bindings/ffi/src/lib.rs Wires in new FFI module.
bindings/ffi/src/common.rs Derives Debug/PartialEq for RegorusStatus (used in tests/interop).
bindings/ffi/src/alias_registry.rs Adds FFI surface for AliasRegistry load/query/normalize/denormalize.
bindings/ffi/Cargo.lock Lockfile updates from new dependency graph.
bindings/csharp/Regorus/SafeHandles.cs Adds SafeHandle for alias registry native handle.
bindings/csharp/Regorus/NativeMethods.cs Adds P/Invoke declarations for alias registry functions + struct.
bindings/csharp/Regorus/AliasRegistry.cs Adds managed AliasRegistry wrapper API.
bindings/csharp/Regorus.Tests/AliasRegistryTests.cs Adds managed tests covering alias registry API behavior.
bindings/java/Cargo.lock Lockfile updates (hashbrown/foldhash).
bindings/python/Cargo.lock Lockfile updates (hashbrown/foldhash).
bindings/wasm/Cargo.lock Lockfile updates (hashbrown/foldhash).

💡 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 44 out of 50 changed files in this pull request and generated 3 comments.


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

@anakrish anakrish force-pushed the normalizer branch 2 times, most recently from 788f861 to 2efd79d Compare March 27, 2026 16:33
@anakrish anakrish requested a review from Copilot March 27, 2026 16:33
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 45 changed files in this pull request and generated 4 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 41 out of 45 changed files in this pull request and generated 1 comment.


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

Add self-contained alias normalization system for Azure Policy:

- AliasRegistry: loads alias catalogs (control-plane JSON and data-plane
  manifests), resolves alias paths, detects sub-resource arrays
- Normalizer: transforms ARM JSON resources into normalized form using
  alias-driven path mappings, root-field extraction, and sub-resource
  array flattening
- Denormalizer: reverses normalization back to ARM JSON format
- Types: deserialization types for production alias catalogs with
  versioned path support

Includes:
- 58 inline unit tests across all modules
- FFI bindings (C-compatible API)
- C# managed wrapper (AliasRegistry.cs, NativeMethods, SafeHandle)
- Test data: alias catalog and versioned alias fixtures
- Documentation: design rationale and normalization specification
- Validation script (check_aliases.py)
- Eliminate BTreeMap↔ObjMap conversion churn with fast-path lookups
- Precompute alias aggregates for all versioned paths at registry load time
- Use full value equality for versioned aggregate caching
- Precompute versioned scalar path segments for zero-allocation lookups
- Add versioned-path benchmarks
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 40 out of 44 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 on lines +6 to +18
#![allow(
clippy::as_conversions,
clippy::arithmetic_side_effects,
clippy::for_kv_map,
clippy::if_then_some_else_none,
clippy::indexing_slicing,
clippy::missing_const_for_fn,
clippy::option_if_let_else,
clippy::pattern_type_mismatch,
clippy::redundant_pub_crate,
clippy::shadow_unrelated,
clippy::unused_trait_names
)]
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The module-level #![allow(...)] disables several lints that are denied at the crate level (e.g., clippy::indexing_slicing, clippy::arithmetic_side_effects, clippy::as_conversions) for the entire Azure Policy language implementation. This makes it easy for new unchecked indexing/as casts to slip in unnoticed across this whole module. Consider narrowing these to item-level #[allow] on the specific functions/types that need them (or adding brief comments explaining why each lint must be relaxed here).

Copilot uses AI. Check for mistakes.
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.

2 participants