feat(hoist): pre-compute loop hoisting metadata at compilation time (#483)

Introduce a compiler pass that analyzes and pre-computes loop hoisting information
during policy compilation. This hoisted metadata is stored in lookup tables and made
available to downstream consumers:

- interpreter: use HoistedLoop entries during evaluation (replaces runtime scanning)
- type inference: can leverage pre-computed loop structure for type propagation
- RVM compiler: will consume hoisting metadata for optimized bytecode generation

Changes:
- populate loop hoisting tables during engine preparation and query snippet execution
- refactor eval_stmts_in_loop and eval_output_expr_in_loop to consume HoistedLoop directly
- add helper methods for accessing loop expressions, collections, and indices from HoistedLoop
- extend Lookup with get_checked and into_slots for safe query context access and merging

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2025-10-08 11:11:30 -05:00
committed by GitHub
parent 9604fe86f1
commit 5d8387f4d9
14 changed files with 1365 additions and 267 deletions
+1 -2
View File
@@ -268,8 +268,7 @@ fn test_target_deserialization_with_registry_schemas() {
// We expect this to fail with a "not found in registry" error since we haven't
// populated the registries with test data
if result.is_err() {
let error = result.unwrap_err();
if let Err(error) = result {
assert!(matches!(
error,
TargetError::JsonParseError(_) | TargetError::DeserializationError(_)