refactor(value): migrate Value::Set to Set storage abstraction - #778
Draft
Anand Krishnamoorthi (anakrish) wants to merge 1 commit into
Draft
refactor(value): migrate Value::Set to Set storage abstraction#778Anand Krishnamoorthi (anakrish) wants to merge 1 commit into
Anand Krishnamoorthi (anakrish) wants to merge 1 commit into
Conversation
Copilot started reviewing on behalf of
Anand Krishnamoorthi (anakrish)
August 4, 2026 17:24
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR completes the Value::Set storage migration by switching the enum payload from Rc<BTreeSet<Value>> to Rc<value::Set>, wiring in the Set abstraction introduced earlier and updating call sites across RVM, builtins, serialization, language compilers, and tests. This follows the same “opaque storage wrapper” pattern as the prior Value::Object → Object migration, reducing direct dependence on the concrete collection type.
Changes:
- Replace
Value::Set(Rc<BTreeSet<Value>>)withValue::Set(Rc<Set>), updateFrom<BTreeSet<Value>> for Value, and adjustas_set/as_set_mutto return&Set/&mut Set. - Update RVM set iteration to mirror object iteration by using an opaque resumable
SetCursorover a sharedRc<Set>(removing the priorcurrent_item/first_iterationsnapshot scheme). - Migrate set construction and set algebra call sites (union/intersection/difference) to use the
SetAPI andValue::from(...)conversions.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/rvm/compiler.rs | Updates expected literal set construction to use Value::from(BTreeSet<_>) instead of manually constructing Value::Set(Rc<...>). |
| src/value/set/mod.rs | Adjusts Set::iter to return the stable wrapper iterator type and updates Set::into_value to produce Rc<Set>-backed Value::Set. |
| src/value/mod.rs | Switches Value::Set payload type to Rc<Set> and updates conversions/accessors accordingly. |
| src/rvm/vm/loops.rs | Refactors set loop iteration to use SetCursor and Set::next, removing manual resume snapshotting. |
| src/rvm/vm/dispatch.rs | Updates set literal construction to use Value::from(BTreeSet) conversion. |
| src/rvm/vm/context.rs | Updates IterationState::Set to store Rc<Set> and SetCursor, aligning semantics with object iteration. |
| src/rvm/vm/comprehension.rs | Updates comprehension-driven set iteration to use SetCursor and removes now-unneeded snapshot/resume logic. |
| src/rvm/vm/arithmetic.rs | Switches set subtraction to use Set::difference returning a Set, then Value::from(Set). |
| src/rvm/program/serialization/value.rs | Switches binary set serialization to accept &Set and iterates via iter_sorted() for canonical ordering. |
| src/rvm/program/metadata.rs | Updates metadata set construction to use Value::from_set(...) helper (now producing Rc<Set> internally). |
| src/languages/rego/compiler/expressions/collection_literals.rs | Updates constant set evaluation/hoisting to construct sets via Value::from_set(...). |
| src/languages/azure_rbac/builtins/lists.rs | Updates helper signature to accept &Set and uses Set::contains. |
| src/languages/azure_policy/compiler/metadata.rs | Updates set-valued annotations to use Value::from_set(...). |
| src/builtins/utils.rs | Updates ensure_set to return Rc<Set> instead of Rc<BTreeSet<Value>>. |
| src/builtins/sets.rs | Migrates set builtins to Set operations (union/intersection/difference) returning Set and wrapping via Value::from(Set). |
Anand Krishnamoorthi (anakrish)
force-pushed
the
set-abstraction-migration
branch
2 times, most recently
from
August 4, 2026 20:51
0fc87fb to
ef809a8
Compare
Anand Krishnamoorthi (anakrish)
force-pushed
the
set-abstraction-migration
branch
from
August 12, 2026 21:34
ef809a8 to
459fdc9
Compare
Switch Value::Set from Rc<BTreeSet<Value>> to Rc<Set>, wiring the previously-merged Set wrapper struct (microsoft#740) into the enum and updating all call sites across interpreter, RVM, builtins, serialization, and languages. Mirrors the merged Object migration (microsoft#736). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fc92437e-8820-49a4-ba5f-ec82a79f1221
Anand Krishnamoorthi (anakrish)
force-pushed
the
set-abstraction-migration
branch
from
August 13, 2026 03:09
459fdc9 to
565e357
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switch Value::Set from Rc<BTreeSet> to Rc, wiring the previously-merged Set wrapper struct (#740) into the enum and updating all call sites across interpreter, RVM, builtins, serialization, and languages. Mirrors the merged Object migration (#736).