pub fn evaluate_table(
lib: &JSONEval,
eval_key: &str,
scope_data: &EvalData,
) -> Result<Vec<Value>, String>Expand description
Sandboxed table evaluation for safe parallel execution
All heavy operations (dependency analysis, forward reference checks) are done at parse time. This function creates an isolated scope to prevent interference between parallel table evaluations.
§Parallel Safety
This function is designed for safe parallel execution:
- Takes
scope_dataas an immutable reference (read-only parent scope) - Creates an isolated sandbox (clone) for all table-specific mutations
- All temporary variables (
$iteration,$threshold, column vars) exist only in the sandbox - The parent
scope_dataremains unchanged, preventing race conditions - Multiple tables can be evaluated concurrently without interference
§Mutation Safety
ALL data mutations go through EvalData methods:
sandbox.set()- sets field values with version trackingsandbox.push_to_array()- appends to arrays with version trackingsandbox.get_table_row_mut()- gets mutable row references (followed by mark_modified)sandbox.mark_modified()- explicitly marks paths as modified
This ensures proper version tracking and mutation safety throughout evaluation.
§Sandboxing Strategy
- Clone
scope_datato create an isolated sandbox at the start - All evaluations and mutations happen within the sandbox via EvalData methods
- Extract the final table array from the sandbox
- Sandbox is dropped, discarding all temporary state
- Parent scope remains pristine and can be safely shared across threads