feat: evaluate only the parameter/preset/tag closure, with an opt-out - #226
Merged
Merged
Conversation
Preview now passes OptionWithResourceClosure to the parser by default so root resources nothing in the parameter, preset, or tag closure references are skipped. Preview takes variadic options; OptionFullEvaluation restores evaluating every resource, so a caller can turn the optimization off without a new preview release if a template misbehaves. Test_Extract runs every vector in both modes against the same expectations. Test_OptionFullEvaluation observes the difference through Output.ModuleOutput, which is the one output the closure changes.
Emyrk
marked this pull request as ready for review
September 11, 2026 20:42
geokat
approved these changes
Sep 11, 2026
geokat
left a comment
Contributor
There was a problem hiding this comment.
lgtm, other than the possible race (see comment).
Both mode subtests wrote tc.unknownTags and tc.expTags on the shared tc, which the race detector flags.
This was referenced Sep 15, 2026
Emyrk
added a commit
to coder/coder
that referenced
this pull request
Sep 17, 2026
Bumps `github.com/coder/preview` to pick up resource closure evaluation (coder/preview#226) and its `OptionFullEvaluation` opt-out. The `coder/trivy` replace moves to the commit that provides `OptionWithResourceClosure` (coder/trivy#74), matching what preview pins. Behavior is unchanged in this PR: `preview.Preview` now prunes root resources outside the parameter/preset/tag closure by default, and coderd already only reads parameters, presets, and tags from it. The next PR in the stack adds a deployment-level escape hatch. Prepared with Coder Agents assistance.
Emyrk
added a commit
to coder/coder
that referenced
this pull request
Sep 17, 2026
…ion (#29356) **What changed** Dynamic parameter rendering now evaluates only the coder parameter blocks and what they reference. Other root-module resources are skipped. Parameter, preset, and tag values are unchanged; optimizing rendering on large templates. **How to revert** Set `CODER_DYNAMIC_PARAMETERS_FULL_EVALUATION=true` (or `--dynamic-parameters-full-evaluation`) on `coder server` to restore full evaluation. The flag is hidden and needs no restart of workspaces. If you need it, please [open an issue](https://github.com/coder/coder/issues/new) with the template so we can fix the root cause. **Troubleshooting** Symptoms would be a parameter default, option list, preset value, or workspace tag that shows as unknown or empty after upgrading, when it was populated before. Confirm by setting the flag above; if the value comes back, report it. Templates written in `.tf.json` are not affected (they always use full evaluation). **Why** Rendering re-ran the entire template graph on every parameter change in the workspace form, which dominated latency on large templates. Resources a workspace would create cannot feed a parameter, so evaluating them is wasted work. The optimization lives in coder/preview#226 (coder/trivy#74); this PR adds the deployment-level escape hatch. --- - `CODER_DYNAMIC_PARAMETERS_FULL_EVALUATION` / `--dynamic-parameters-full-evaluation` (hidden, default `false`) on `DeploymentValues`. - `dynamicparameters.PreviewOptions(dv)` maps it to `preview.OptionFullEvaluation()`; `dynamicparameters.WithPreviewOptions` threads it through the loader to `preview.Preview`. - Wired at the three render paths that hold deployment values: the template version tags extractor, the dynamic parameters websocket, and `wsbuilder` builds created from `coderd` (which call `.DeploymentValues(...)`). Not covered: the autobuild lifecycle executor and the enterprise prebuilds reconciler construct `wsbuilder` without deployment values, so builds started from those paths use preview's default regardless of the flag. Those only re-render for builds, not the keystroke websocket path the optimization targets. Prepared with Coder Agents assistance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Evaluates only the
coder_parameter/coder_workspace_preset/coder_workspace_tagsclosure when rendering, with an opt-out. Supersedes #221 (thanks @PushTheLimit); the trivy side is coder/trivy#74.OptionWithResourceClosure, and passes it by default so root resources nothing in the closure references are skipped. On the motivating templateEvaluateAlldrops from ~2s to ~0.16s.Previewtakesopts ...Option.OptionFullEvaluation()evaluates every resource, so coderd can turn the optimization off behind a setting without a new preview release if a template misbehaves.Test_Extractruns every vector in both modes against the same expectations, pinning that parameters, presets, tags, and variables are identical either way.Test_OptionFullEvaluationobserves the difference throughOutput.ModuleOutput.Behavior notes:
Output.ModuleOutputmay contain unknown values for root outputs that read pruned resources. Nothing in coderd consumes it..tf.jsonfiles skip pruning entirely (trivy's JSON reference extraction is not reliable enough to prune on).Test coverage for the reference shapes the pruner must see through landed separately in #223 and #224.
Prepared with Coder Agents assistance.