feat: Ensure RVM caches deterministic builtins

Mirror interpreter implementation:
- use builtins::must_cache to determine whether builtin must be cached.
- reuse cached value when applicable
- clear the VM’s builtin cache whenever execution state resets to avoid leaking values across runs
- add a YAML regression for rand.intn set comprehensions and re-enable the rand cases in the OPA test suite

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2025-12-03 10:45:29 -06:00
parent 1d627f3798
commit e3d23766ae
5 changed files with 53 additions and 3 deletions
-1
View File
@@ -36,7 +36,6 @@ const OPA_TODO_FOLDERS: &[&str] = &[
"partialdocconstants",
"partialobjectdoc",
"planner-ir",
"rand",
"refheads",
"replacen",
"semverisvalid",
+15
View File
@@ -0,0 +1,15 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
cases:
- note: builtin_rand_intn_cache_consistency
data: {}
modules:
- |
package test
rands := { rand.intn("seed", 100) | numbers.range(1, 100)[_] }
np := count(rands)
query: data.test.np
want_result: 1