Skip to content

feat(value): introduce Object storage abstraction - #735

Merged
anakrish merged 1 commit into
microsoft:mainfrom
anakrish:storage-abstraction-object-foundation
Jun 4, 2026
Merged

feat(value): introduce Object storage abstraction#735
anakrish merged 1 commit into
microsoft:mainfrom
anakrish:storage-abstraction-object-foundation

Conversation

@anakrish

@anakrish anakrish commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

First in a small series that introduces opaque storage types for Value variants so future backends can swap in without rippling through call sites. The design also lets multiple backends coexist at runtime — different Object instances in the same process can use different implementations (e.g. a lazy DB-backed object for input, inline small-map objects for SARIF location records, regular sorted maps elsewhere) and interoperate through the same opaque type.

The design and rationale are written up in docs/value/object.md. It covers the encapsulation choice, the explicit iter vs iter_sorted split, the cursor for resumable traversal, why Ord is defined against sorted iteration, and the concrete workloads driving the abstraction (SARIF small-object pressure, Kubernetes admission, Azure Policy aliases and case-insensitive compare, external/lazy data sources, eval-time arenas, host-language FFI). Precedents: serde_json::Map, toml::Table, simdjson DOM.

Layout: the new type lives at src/value/object/{mod,iter,serde}.rs; src/value.rs becomes src/value/mod.rs to make room. Re-exported as regorus::Object.

Nothing in the engine consumes Object yet — this PR is additive. Unit tests (34 covering iteration, cursor mutation-safety, ordering invariants, serde determinism with non-string keys, iterator-trait surface, etc.) stand on their own.

Follow-ups (separate PRs):

  • Object migration (payload swap + call sites)
  • Set foundation + migration
  • Array, String, and Bindings abstractions

@anakrish anakrish changed the title feat(value): introduce Object storage abstraction (foundation) feat(value): introduce Object storage abstraction Jun 1, 2026
@anakrish
anakrish requested review from dekomissMSFT and dpokluda June 1, 2026 20:38
Add an opaque Object type for the key→value storage backing
Value::Object. It exposes a small set of methods (get, insert, remove,
iter, iter_sorted, cursor, serde) and keeps the backing store private,
so future representations -- inline small-map, hash-backed, lazy,
arena, FFI-callback -- can plug in without touching the call sites
that name this type.

Nothing in the engine uses Object yet. Value::Object still wraps
Rc<BTreeMap<Value, Value>>; the payload swap and call-site migration
come in the next PR. Object stands on its own unit tests in the
meantime.

docs/value/object.md walks through the design, the precedents it
follows (serde_json::Map, toml::Table, simdjson DOM), and the
concrete workloads the abstraction is meant to unlock.

A matching Set abstraction follows in a separate PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@anakrish
anakrish force-pushed the storage-abstraction-object-foundation branch from 595029d to d9892d9 Compare June 2, 2026 17:44
@anakrish
anakrish merged commit 11940dd into microsoft:main Jun 4, 2026
59 checks passed
@anakrish
anakrish deleted the storage-abstraction-object-foundation branch June 4, 2026 17:31
anakrish added a commit that referenced this pull request Jul 21, 2026
Release the core `regorus` crate as v0.11.0 (up from v0.10.1) and align
every language binding to the same version.

This release carries an API-breaking change (flagged by
cargo-semver-checks), so it takes a minor bump under the 0.x SemVer
convention.

Highlights since v0.10.1:

- fix(rvm): assert every-quantifier results so failing cases don't pass
  (#765)
- fix: deep-merge nested data documents in Engine::add_data (#760)
- feat(compiler): support registered host-await builtins for natural
  function call syntax (#667)
- feat(value): introduce Set/Object storage abstractions (#740, #735,
  #736)
- security: reject data nested beyond 128 levels to avoid stack overflow

Version updates:

- Core crate (Cargo.toml/Cargo.lock) 0.10.1 -> 0.11.0
- Bindings aligned via `cargo xtask bindings`: ffi, java, python, wasm,
  ruby, csharp (manifests, lockfiles, pom.xml, Directory.Packages.props,
  version.rb)
- CHANGELOG.md updated with the 0.11.0 section
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