Skip to content

fix: preserve typed scalar rule paths and Program JSON round trips - #833

Open
Maksym (maksym-mishchenko) wants to merge 3 commits into
microsoft:mainfrom
maksym-mishchenko:maksym-mishchenko-anand-scalar-path-follow-up
Open

Maksym (maksym-mishchenko) wants to merge 3 commits into
microsoft:mainfrom
maksym-mishchenko:maksym-mishchenko-anand-scalar-path-follow-up

Conversation

@maksym-mishchenko

Copy link
Copy Markdown
Contributor

Follow-up to merged #827, addressing the deferred scalar-path review findings.

Changes

  • Preserve Boolean, null and numeric rule-prefix keys separately from same-text strings across interpreter and RVM registration, lookup, defaults and entrypoints. Canonicalize numeric paths using the existing parsed Number model.
  • Fix numeric 1 versus string "1" WITH suppression in the interpreter and compiled-policy path, including nested rollback and reuse. RVM WITH remains unsupported.
  • Preserve typed keys, Undefined and sets in Program-owned literals and rule_tree JSON, with strict errors for malformed marked payloads.
  • Cover typed conflicts, registered combined-depth boundaries, legacy/marked round trips, error handling and Engine/VM reuse.

Compatibility

value_encoding: "typed-keys-v1" is emitted only when these Program fields need it. Marker-absent legacy JSON retains its existing behavior; marked payloads require the updated reader. Package grammar, the global Value serializer, Number model, binary format, public ABI, dependencies and feature definitions are unchanged.

Validation

On main 042af3a with Rust 1.95.0: cargo xtask ci-debug, cargo xtask fmt --check, cargo xtask clippy, cargo xtask test-no-std, FFI namespace tests (4 passed), and Azure-policy integration (325 passed). Strict Clippy includes all-target/all-feature, no-default and FFI/Java/Python/WASM stages. The no_std gate builds the existing thumbv7m-none-eabi harness; this is not an all-nine shipped-native or embedded-RVM runtime certification.

No changes to #827 review threads; no global numeric semantics or new RVM WITH support.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e136eee-6922-4fa1-af3e-f294cac94ddf

Copilot AI left a comment

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.

🟡 Changes recommended

Repeated unary scalar indices can be canonicalized and registered as valid typed paths.

1 open finding
What changed in this PR

Preserves typed scalar rule paths across interpreter/RVM execution and Program JSON round trips.

Changes:

  • Adds typed path parsing, registration, lookup, and WITH handling.
  • Adds marked JSON encoding for typed keys, sets, and Undefined.
  • Expands regression coverage and documentation.
File Description
src/​compiled_policy.rs Stores typed path components.
src/​interpreter.rs Handles typed rules and WITH overrides.
src/​interpreter/​target/​resolve.rs Uses typed target paths.
src/​languages/​rego/​compiler/​references.rs Matches typed RVM references.
src/​languages/​rego/​compiler/​rules.rs Registers typed rule-tree paths.
src/​parser.rs Parses static scalar components.
src/​rvm/​program/​rule_tree.rs Stores and checks typed keys.
src/​rvm/​program/​serialization/​json.rs Adds typed Program JSON encoding.
src/​utils.rs Adds typed path utilities.
src/​value/​mod.rs Adds typed nested-object construction.
tests/​engine/​mod.rs Tests interpreter and compiled behavior.
tests/​rvm/​compiler.rs Tests typed conflict handling.
tests/​rvm/​rego/​mod.rs Tests serialization and VM reuse.
tests/​rvm/​rego/​cases/​scalar_path_identity.yaml Adds scalar-path fixtures.
docs/​grammar.md Documents typed rule paths.
docs/​rvm/​architecture.md Documents Program JSON encoding.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/utils.rs Resolved
Maksym Mishchenko and others added 2 commits October 13, 2026 22:32
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e136eee-6922-4fa1-af3e-f294cac94ddf
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e136eee-6922-4fa1-af3e-f294cac94ddf

Copilot AI left a comment

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.

🟡 Changes recommended

Exact numeric interpreter lookups can still evaluate and fail on a conflicting same-text string rule.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread tests/engine/mod.rs
Comment on lines +745 to +749
for (path, expected) in [
("data.policy.items[1].blocked", Value::Bool(true)),
("data.policy.items[1.0].blocked", Value::Bool(true)),
("data.policy.items[\"1\"].blocked", Value::Bool(false)),
] {
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