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. - Cycle
Participant - A single participant in a cycle diagnostic.
- Eval
Context - Read-only inputs to a single
crate::eval::Evaluator::evaluatecall. - Eval
Limits - Per-call resource limits enforced by the evaluator and its registered functions.
- Evaluated
Component - Post-evaluation view of a
Component. - Func
Registry - Read-only function registry shared by the evaluator across components.
- Func
Registry Builder - Mutable builder for a
FuncRegistry. - HclEvaluator
- Default evaluator implementation.
Enums§
- EnvVar
Mode - How
get_envcalls treat the process environment. - Eval
Error - Recoverable evaluator failure.
- Func
Error - 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::Valueback into ourValue. - value_
to_ hcl - Convert our
Valueinto thehcl::Valueshapehcl::evalconsumes.