Skip to main content

Module eval

Module eval 

Source
Expand description

Best-effort HCL expression evaluator.

Given a parsed Component and an EvalContext, the evaluator reduces every Expression it can statically — variables bound from *.tfvars, locals via a worklist fixpoint, stdlib + Terraform-only functions, and sandboxed file functions — leaving references that depend on apply-time data (Expression::Unresolved, data.*, resource attributes, module outputs) intact.

The evaluator is best-effort by contract, per 99-key-decisions.md D4: an unresolved leaf is not a parse error — it is the correct outcome when the source-only parser does not have apply-time information. The Phase 4 contract is pinned in 13-evaluator.md.

§Architecture

eval is a pure walk over our Expression tree (reduce.rs). The spec (13-evaluator.md § 4) describes “feeding our context into the hcl-rs::eval evaluator and reading the result back into our IR”; in practice that pattern is partially unreachable because hcl::eval::FuncDef accepts a fn-pointer, not a closure, so stateful functions (file(), get_env(), the Terragrunt helpers) cannot carry sandbox / workspace-root context through it. See 93-improvements-review.md S-010 / S-011 for the recorded spec defects.

The walker keeps the contract the spec actually cares about: every public IR shape that flows through is ours. The value_to_hcl / hcl_to_value adapters convert at the boundary so future delegations (Phase 6 Terragrunt funcs) can lean on hcl::Value without changing this module.

Structs§

CallCx
Per-call context handed to each HclFunc::call.
CycleParticipant
A single participant in a cycle diagnostic.
EvalContext
Read-only inputs to a single crate::eval::Evaluator::evaluate call.
EvalLimits
Per-call resource limits enforced by the evaluator and its registered functions.
EvaluatedComponent
Post-evaluation view of a Component.
FuncRegistry
Read-only function registry shared by the evaluator across components.
FuncRegistryBuilder
Mutable builder for a FuncRegistry.
HclEvaluator
Default evaluator implementation.

Enums§

EnvVarMode
How get_env calls treat the process environment.
EvalError
Recoverable evaluator failure.
FuncError
Error returned by an HclFunc::call.

Traits§

Evaluator
The contract every evaluator implements. Phase 4 ships exactly one implementation: HclEvaluator.
HclFunc
A single function dispatchable by the evaluator.

Functions§

hcl_to_value
Convert an hcl::Value back into our Value.
value_to_hcl
Convert our Value into the hcl::Value shape hcl::eval consumes.