feat: Support package-level evaluation in RVM
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
src/languages/rego/compiler/rules.rs の compile_from_policy と get_or_assign_rule_index() から始め、次にインタープリターの package-query の処理と比較してください。tests/rvm/rego/cases/default_rules.yaml のスキップされているケース、特に multiple_default_rules_different_names と default_rule_undefined_vs_default を確認してください。data.test がすべての package ルールを評価し、個々の rule-path の動作を維持したまま期待されるマージ済みオブジェクトを返せば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
The RVM (Rego Virtual Machine) currently requires individual rule paths as entry points (e.g., data.test.allow). It does not support package-level queries (e.g., data.test) that evaluate all rules in a package and return a merged object of their results.
The interpreter supports this via eval_query("data.test"), but the RVM compiler rejects package paths with "not a valid rule path" since they don't map to any entry in rule_paths.
Motivation
Package-level evaluation is useful for:
- Evaluating all rules in a package in a single call and receiving a merged result object
- Parity with the interpreter's
eval_querybehavior - Supporting patterns where rules with defaults coexist (e.g.,
default allow := false+default deny := true) and the caller wants the full package state
Current Behavior
package test
default allow := false
default deny := true
allow := true if { false }
deny := false if { false }
| Query | Interpreter | RVM |
|---|---|---|
data.test.allow |
false ✓ |
false ✓ |
data.test.deny |
true ✓ |
true ✓ |
data.test |
{"allow": false, "deny": true} ✓ |
Error: "not a valid rule path" |
Expected Behavior
data.test should return {"allow": false, "deny": true} — evaluating all rules in the test package and merging results into an object.
Technical Context
The RVM compiler resolves entry points in compile_from_policy via get_or_assign_rule_index(), which looks up the path in the rules map (keyed by full rule paths like data.test.allow). A package path like data.test has no entry there, so it fails.
The interpreter handles package queries differently — it evaluates all rules, then walks the data tree to extract the subtree at the requested path.
Why this is non-trivial in the RVM
The RVM compiles each entry point to a CALL_RULE + RETURN sequence that produces a single Value. Package-level evaluation would require:
- Discovering all rule paths under a package prefix — e.g., for
data.test, finddata.test.allowanddata.test.deny - Compiling all of them as entry points — the compiler already supports multiple entry points via
execute_entry_point_by_index - Merging results into an object — evaluating each rule and assembling
{"allow": <result>, "deny": <result>}, handlingUndefined(omit from result), nested packages, and partial objects/sets
Possible approaches
Option A — Compiler-level: synthetic package entry point
Add a new entry point type that emits CALL_RULE for each rule in the package, then OBJ_SET instructions to merge results into a single object. This keeps everything in the VM execution loop.
; Synthetic entry point for "data.test"
CALL_RULE r1 ← rule_0 (allow)
CALL_RULE r2 ← rule_1 (deny)
OBJ_NEW r0
OBJ_SET r0 "allow" r1 ; skip if r1 == Undefined
OBJ_SET r0 "deny" r2 ; skip if r2 == Undefined
RETURN r0
Pros: single VM execution, fast. Cons: more compiler complexity, needs Undefined-skip semantics in OBJ_SET.
Option B — Host-side: iterate entry points and merge
Accept a package path at the API level, resolve it to individual rule paths, compile each as an entry point, execute them via execute_entry_point_by_index, and merge in the host code (Rust or bindings).
// Pseudocode
let rule_paths = compiled_policy.get_rule_paths_for_package("data.test");
let mut result = Value::new_object();
for path in rule_paths {
let value = vm.execute_entry_point_by_name(&path)?;
if value != Value::Undefined {
let key = path.strip_prefix("data.test.").unwrap();
result.insert(key, value);
}
}
Pros: simpler, no compiler changes. Cons: multiple VM executions per package, nested packages need recursive handling.
Skipped Tests
The following test cases in tests/rvm/rego/cases/default_rules.yaml are blocked by this limitation:
multiple_default_rules_different_names— querydata.testwithdefault allow := false+default deny := truedefault_rule_undefined_vs_default— querydata.testwith mix of defaulted and undefined rules
Impact
Medium — package-level queries are a common OPA pattern.
- 主要言語
- Rust
- スター
- 375
- フォーク
- 81
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 78
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/regorus のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
RVM: errors and conflicts in rule bodies evaluate to undefined, even with strict builtin errors再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
microsoft/regorus#932 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 32/100
メンテナーはふだん 1 日以内に返信
microsoft/regorus の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
awxkee/yuvutils-rs#149 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
Ignore entry for RUSTSEC-2026-0002 no longer matches anything (`lru` is no longer in `Cargo.lock`)オープン
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
influxdata/influxdb#27767 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
shell-pool/shpool#463 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
oras-project/rust-oci-client-node#132 ·
メンテナーはふだん 2 日以内に返信