Skip to content

fix(test): stop Windows toolchain-vanishing flake in acceptance tests - #2834

Merged
Andriy Knysh (aknysh) merged 11 commits into
mainfrom
osterman/toolchain-cache-fix-own-pr
Jul 30, 2026
Merged

Andriy Knysh (aknysh) merged 11 commits into
mainfrom
osterman/toolchain-cache-fix-own-pr

Conversation

@osterman

Copy link
Copy Markdown
Member

what

  • Stops TestPrintTelemetryDisclosureOnlyOnce (and its three sibling telemetry disclosure
    tests) from deleting the shared <cache>/atmos root; they now isolate via a per-test
    ATMOS_XDG_CACHE_HOME/XDG_CACHE_HOME redirect instead.
  • Closes a TOCTOU race in internal/exec terraform/tofu version tests: RequireTerraformPath/
    RequireTofuPath now resolve the binary path once and hand it back directly, instead of a
    second independent exec.LookPath call at each call site.
  • Makes requireExecutablePath fail loudly (t.Fatalf) instead of silently returning an empty
    path when ATMOS_TEST_SKIP_PRECONDITION_CHECKS=true and the binary isn't found.
  • Isolates several pkg/toolchain install/uninstall/list tests from the real shared XDG
    toolchain cache directory (Toolchain.InstallPath now points at each test's own t.TempDir()).
  • Widens requireExecutablePath's retry window (2s → 15s) as a defensive backstop, and adds
    permanent forensic instrumentation (executableLookupForensics) that dumps per-PATH-entry
    toolchain directory state on a lookup failure.
  • Adds a docs/fixes/ entry recording the root cause and investigation.

why

  • The Windows "Acceptance Tests" CI job had been flaky for weeks with a recurring
    executable file not found in %PATH% failure for tofu/terraform, always on a different
    victim test in internal/exec each run.
  • Root cause (confirmed via the forensic instrumentation added here): TestPrintTelemetryDisclosureOnlyOnce
    was calling os.RemoveAll on the shared <cache>/atmos root — the same root the toolchain
    install path lives under since feat(ci): GitHub Actions build cache (atmos ci cache) #2579 — twice per run (setup + defer), deleting every
    CI-provisioned tool (terraform, opentofu, helm, helmfile) out from under the other
    concurrently-running go test package binaries.
  • The other fixes in this PR are the real-but-secondary hazards found and closed during the same
    investigation, kept together because each one was ruled in/out as a contributing cause before
    the actual root cause was found.
  • Extracted out of Support explicit CI git checkout and bundle Docker CLI #2812 (which bundles an unrelated CI git-clone-bootstrap feature) so this
    CI-reliability fix can ship and be reviewed independently.

references

TestExecuteTerraform_Version and TestYamlFuncTerraformOutput each resolved
the tofu/terraform binary via RequireTofu/RequireTerraform, then made a
second, independent exec.LookPath call before isolating the binary. On the
Windows acceptance job's concurrent packages, another test can mutate the
shared toolchain cache directory between those two lookups, turning a
binary that just existed into a spurious "not found" failure.

RequireTerraformPath/RequireTofuPath now resolve the path once and hand it
back directly, removing the redundant lookup at each call site.
…miss

requireExecutablePath (backing RequireTerraformPath/RequireTofuPath) silently
returned "" when ATMOS_TEST_SKIP_PRECONDITION_CHECKS=true (set for every CI
acceptance job) and the binary wasn't found, instead of surfacing the miss.
Callers that need the resolved path then crashed on the empty string with a
confusing "open : file not found" error rather than a clear diagnostic.

RequireExecutable is decoupled back to its original full-bypass behavior
(a true no-op when checks are disabled) since its callers only need a
boolean gate, not a path -- only the path-returning variants now hard-fail
on a genuine lookup miss.
Several pkg/toolchain tests (TestRunInstall_WithLatestKeyword,
TestRunInstall_WithCanonicalFormat, TestRunInstall_WithValidToolSpec,
TestRunInstall_WithSetAsDefault, TestRunInstallWithNoArgs,
TestRunInstall_Reinstall, TestRunUninstall, TestRunUninstall_InvalidToolSpecFormat,
TestUninstallAllVersionsOfTool) called SetAtmosConfig() without setting
Toolchain.InstallPath. NewInstaller()'s GetInstallPath() falls back to the
real, shared XDG toolchain cache directory whenever InstallPath is empty --
the exact directory CI's "atmos toolchain install --default" step populates
and that the whole acceptance suite depends on for hashicorp/terraform and
opentofu/opentofu binaries for the rest of the run.

TestRunInstall_WithLatestKeyword and TestRunInstall_WithCanonicalFormat in
particular perform real network installs of real "terraform" binaries into
that shared path, racing with every other concurrently-running package's
test process reading tofu/terraform off PATH -- almost certainly the root
cause of the intermittent "'tofu' not found in PATH" hard failures seen on
the Windows acceptance job (round 3 of this investigation had already ruled
out a stale-PATH-visibility theory for this specific failure instance).

Fixed by pointing Toolchain.InstallPath at each test's own t.TempDir(),
matching the isolation pattern already used by the rest of the toolchain
test suite.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
TestBuildToolRow/TestBuildToolRow_NotInstalled resolved NewInstaller()'s
binDir to the real shared toolchain cache dir (no InstallPath override),
same class of issue fixed in fdbb83f -- read-only here, but still worth
isolating for hygiene and to rule them out as a contributor.

The Windows tofu-not-found flake recurred in CI even after that fix, so
widen requireExecutablePath's retry window from 2s to 15s as a defensive
backstop: some residual contention under the acceptance job's concurrent
package load isn't yet fully identified, and a longer bounded poll is safer
than risking another silent failure while that's tracked down.
The Windows acceptance job has a recurring failure where an installed
toolchain binary (tofu/terraform) vanishes from PATH mid-suite for the
full retry window. Root-cause candidates are all writer-side windows in
the shared toolchain cache (uninstall RemoveAll, onedir rename-aside,
in-place flat-install extraction) but four rounds of static analysis
couldn't pin which one fires in CI.

requireExecutablePath now dumps per-PATH-entry forensics on failure:
whether each toolchain dir exists, its contents, target presence, and
whether the installer's ".lock" sibling is held. The next CI failure
becomes direct evidence of the mechanism (dir deleted vs tree renamed
aside vs writer mid-flight vs PATH corruption) instead of another guess.
Root cause of the recurring Windows acceptance flake, confirmed by the
lookup forensics added in a68e195: the failure dump showed EVERY
toolchain directory (terraform, opentofu, helm, helmfile) gone at once
-- the whole <cache>/atmos tree had been deleted mid-run.

TestPrintTelemetryDisclosureOnlyOnce "cleaned up" by os.RemoveAll on
filepath.Dir(cfg.GetCacheFilePath()) -- the real shared <cache>/atmos
root -- twice (setup + defer). Ever since the toolchain install root
moved underneath that same root (<cache>/atmos/toolchain, #2579), this
deleted every CI-provisioned tool out from under the concurrently
running package test binaries. Whichever terraform/tofu-dependent test
happened to run during the window failed with "executable file not
found in %PATH%"; the tests package healed itself via TestMain
re-provisioning, which is why only internal/exec kept failing.

All four disclosure tests now isolate the cache via a per-test
ATMOS_XDG_CACHE_HOME/XDG_CACHE_HOME redirect instead of deleting
anything shared. This also fixes the sibling tests that "cleaned"
./.atmos -- a directory the disclosure code never used -- while
actually polluting the real user-level cache.yaml.
Update the commit/branch reference now that this self-contained
investigation ships as its own PR instead of riding along with #2812's
unrelated CI git-clone-bootstrap feature.
@atmos-pro

atmos-pro Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@osterman Erik Osterman (Cloud Posse) (osterman) added the no-release Do not create a new release (wait for additional code changes) label Jul 30, 2026
@github-actions github-actions Bot added the size/m Medium size PR label Jul 30, 2026
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@codecov

codecov Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.05556% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.88%. Comparing base (bb785f4) to head (86b30be).

Files with missing lines Patch % Lines
tests/preconditions.go 93.05% 3 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2834      +/-   ##
==========================================
- Coverage   81.90%   81.88%   -0.02%     
==========================================
  Files        1796     1796              
  Lines      173648   173711      +63     
==========================================
+ Hits       142222   142248      +26     
- Misses      23645    23682      +37     
  Partials     7781     7781              
Flag Coverage Δ
unittests 81.88% <93.05%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
tests/preconditions.go 70.31% <93.05%> (+4.26%) ⬆️

... and 17 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…ablePath

Codecov flagged tests/preconditions.go at 60.93% patch coverage: the new
requireExecutablePath retry loop, executableLookupForensics,
describeToolchainPathEntry, RequireTerraformPath, and RequireTofuPath had no
direct tests. Add real assertion-based coverage for the resolve-on-first-try,
retry-until-resolved, and exhausted-retries-skip paths, plus table-driven
tests for the forensics string-building logic (target present/absent,
directory contents, writer-lock sibling, unreadable dir).

Convert executablePathRetryTimeout/Interval from const to var so tests can
shrink the retry window instead of waiting out the real 15s.
@aknysh
Andriy Knysh (aknysh) merged commit 8c46159 into main Jul 30, 2026
84 checks passed
@aknysh
Andriy Knysh (aknysh) deleted the osterman/toolchain-cache-fix-own-pr branch July 30, 2026 20:03
@atmos-pro

atmos-pro Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

Erik Osterman (Cloud Posse) (osterman) added a commit that referenced this pull request Jul 30, 2026
* fix: skip provenance during component rendering

* test: harden provenance rendering coverage

* fix: don't process Go templates in Terraform source code (#2145) (#2830)

Atmos parses the Terraform/OpenTofu source of a component with
`terraform-config-inspect` and stores the result in
`component_info.terraform_config`. That section is part of the component
section Atmos renders as a `Go` template, so a Terraform `description`
containing double curly braces — e.g. the GCP resource name format
`projects/{{project}}/locations/{{location}}/services/{{name}}` — aborted
every command with `function "project" not defined`.

Atmos templating belongs to the abstraction above Terraform modules, so
`component_info` is now excluded from template rendering in both the
`ProcessStacks` and `describe stacks` pipelines. It remains in the template
context, so `{{ .component_info.component_path }}` and friends keep working
in stack manifests.


Claude-Session: https://claude.ai/code/session_01E9zBYFTZLeu2gBjPjpRN8v

Co-authored-by: Claude <[email protected]>
Co-authored-by: Erik Osterman (Cloud Posse) <[email protected]>

* fix: preserve provenance output order

* test: update provenance describe snapshots

* perf(terraform-state): cache missing state reads

* test: cover raw provenance and missing state cache

* fix(test): stop Windows toolchain-vanishing flake in acceptance tests (#2834)

* fix(test): resolve CI toolchain cache binaries

* fix(tests): close TOCTOU race in Terraform/OpenTofu binary resolution

TestExecuteTerraform_Version and TestYamlFuncTerraformOutput each resolved
the tofu/terraform binary via RequireTofu/RequireTerraform, then made a
second, independent exec.LookPath call before isolating the binary. On the
Windows acceptance job's concurrent packages, another test can mutate the
shared toolchain cache directory between those two lookups, turning a
binary that just existed into a spurious "not found" failure.

RequireTerraformPath/RequireTofuPath now resolve the path once and hand it
back directly, removing the redundant lookup at each call site.

* fix(tests): fail loudly instead of returning an empty path on lookup miss

requireExecutablePath (backing RequireTerraformPath/RequireTofuPath) silently
returned "" when ATMOS_TEST_SKIP_PRECONDITION_CHECKS=true (set for every CI
acceptance job) and the binary wasn't found, instead of surfacing the miss.
Callers that need the resolved path then crashed on the empty string with a
confusing "open : file not found" error rather than a clear diagnostic.

RequireExecutable is decoupled back to its original full-bypass behavior
(a true no-op when checks are disabled) since its callers only need a
boolean gate, not a path -- only the path-returning variants now hard-fail
on a genuine lookup miss.

* fix(test): isolate toolchain install-path from the real shared cache dir

Several pkg/toolchain tests (TestRunInstall_WithLatestKeyword,
TestRunInstall_WithCanonicalFormat, TestRunInstall_WithValidToolSpec,
TestRunInstall_WithSetAsDefault, TestRunInstallWithNoArgs,
TestRunInstall_Reinstall, TestRunUninstall, TestRunUninstall_InvalidToolSpecFormat,
TestUninstallAllVersionsOfTool) called SetAtmosConfig() without setting
Toolchain.InstallPath. NewInstaller()'s GetInstallPath() falls back to the
real, shared XDG toolchain cache directory whenever InstallPath is empty --
the exact directory CI's "atmos toolchain install --default" step populates
and that the whole acceptance suite depends on for hashicorp/terraform and
opentofu/opentofu binaries for the rest of the run.

TestRunInstall_WithLatestKeyword and TestRunInstall_WithCanonicalFormat in
particular perform real network installs of real "terraform" binaries into
that shared path, racing with every other concurrently-running package's
test process reading tofu/terraform off PATH -- almost certainly the root
cause of the intermittent "'tofu' not found in PATH" hard failures seen on
the Windows acceptance job (round 3 of this investigation had already ruled
out a stale-PATH-visibility theory for this specific failure instance).

Fixed by pointing Toolchain.InstallPath at each test's own t.TempDir(),
matching the isolation pattern already used by the rest of the toolchain
test suite.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(test): isolate remaining toolchain-path leak, widen resolution retry

TestBuildToolRow/TestBuildToolRow_NotInstalled resolved NewInstaller()'s
binDir to the real shared toolchain cache dir (no InstallPath override),
same class of issue fixed in fdbb83f -- read-only here, but still worth
isolating for hygiene and to rule them out as a contributor.

The Windows tofu-not-found flake recurred in CI even after that fix, so
widen requireExecutablePath's retry window from 2s to 15s as a defensive
backstop: some residual contention under the acceptance job's concurrent
package load isn't yet fully identified, and a longer bounded poll is safer
than risking another silent failure while that's tracked down.

* test(ci): add lookup forensics for the Windows toolchain-vanishing flake

The Windows acceptance job has a recurring failure where an installed
toolchain binary (tofu/terraform) vanishes from PATH mid-suite for the
full retry window. Root-cause candidates are all writer-side windows in
the shared toolchain cache (uninstall RemoveAll, onedir rename-aside,
in-place flat-install extraction) but four rounds of static analysis
couldn't pin which one fires in CI.

requireExecutablePath now dumps per-PATH-entry forensics on failure:
whether each toolchain dir exists, its contents, target presence, and
whether the installer's ".lock" sibling is held. The next CI failure
becomes direct evidence of the mechanism (dir deleted vs tree renamed
aside vs writer mid-flight vs PATH corruption) instead of another guess.

* fix(test): stop telemetry test deleting the shared Atmos cache root

Root cause of the recurring Windows acceptance flake, confirmed by the
lookup forensics added in a68e195: the failure dump showed EVERY
toolchain directory (terraform, opentofu, helm, helmfile) gone at once
-- the whole <cache>/atmos tree had been deleted mid-run.

TestPrintTelemetryDisclosureOnlyOnce "cleaned up" by os.RemoveAll on
filepath.Dir(cfg.GetCacheFilePath()) -- the real shared <cache>/atmos
root -- twice (setup + defer). Ever since the toolchain install root
moved underneath that same root (<cache>/atmos/toolchain, #2579), this
deleted every CI-provisioned tool out from under the concurrently
running package test binaries. Whichever terraform/tofu-dependent test
happened to run during the window failed with "executable file not
found in %PATH%"; the tests package healed itself via TestMain
re-provisioning, which is why only internal/exec kept failing.

All four disclosure tests now isolate the cache via a per-test
ATMOS_XDG_CACHE_HOME/XDG_CACHE_HOME redirect instead of deleting
anything shared. This also fixes the sibling tests that "cleaned"
./.atmos -- a directory the disclosure code never used -- while
actually polluting the real user-level cache.yaml.

* docs(fixes): record telemetry-test shared-cache-root fix

* docs(fixes): note extraction onto osterman/toolchain-cache-fix-own-pr

Update the commit/branch reference now that this self-contained
investigation ships as its own PR instead of riding along with #2812's
unrelated CI git-clone-bootstrap feature.

* test(tests): cover forensics and retry-path branches in requireExecutablePath

Codecov flagged tests/preconditions.go at 60.93% patch coverage: the new
requireExecutablePath retry loop, executableLookupForensics,
describeToolchainPathEntry, RequireTerraformPath, and RequireTofuPath had no
direct tests. Add real assertion-based coverage for the resolve-on-first-try,
retry-until-resolved, and exhausted-retries-skip paths, plus table-driven
tests for the forensics string-building logic (target present/absent,
directory contents, writer-lock sibling, unreadable dir).

Convert executablePathRetryTimeout/Interval from const to var so tests can
shrink the retry window instead of waiting out the real 15s.

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
Co-authored-by: Andriy Knysh <[email protected]>

---------

Co-authored-by: thejrose1984 <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Erik Osterman (Cloud Posse) <[email protected]>
Co-authored-by: Andriy Knysh <[email protected]>
@github-actions

Copy link
Copy Markdown

These changes were released in v1.225.0-rc.3.

Andriy Knysh (aknysh) added a commit that referenced this pull request Aug 1, 2026
…dependents) + scope --labels/--tags evaluation before filtering (#2807)

* fix: scope --labels/--tags and list dependencies evaluation before filtering

On a monorepo spanning multiple AWS accounts, atmos terraform ... --all
--labels/--tags and atmos list dependencies --stack <stack> fully evaluated
(templates, YAML functions, auth) every stack in the repo before consulting
the requested selector, failing on an unrelated/inaccessible stack before the
command ever got to the user's actual target.

Generalizes the existing -s/--stack early-skip (see
docs/fixes/2026-06-22-describe-stacks-scope-and-cache-per-component-auth.md)
to --labels/--tags, and reworks `list dependencies` to compute a reachable
dependency closure and only fully evaluate the stacks that closure touches.

* fix(docs): use 2-space list continuation indent for editorconfig

atmos validate --affected's editorconfig check requires markdown
indentation in multiples of 2 (.editorconfig sets indent_size=2 for
*.md). The Symptom section's two numbered-list items used 3-space
continuation indent, failing CI.

* fix(schema): regenerate atmos.yaml JSON schema for eager_evaluation

The Acceptance Tests suite (linux/macos/windows) failed
TestEmbeddedSchemaIsCurrent: adding describe.settings.eager_evaluation
to schema.DescribeSettings in 62a35aa left the embedded JSON schema
stale. Regenerated via `go generate ./pkg/config/schema`.

* feat(list): add --tags/--labels filtering across list subcommands, accept ':' in --labels

`atmos list stacks` had no way to filter by metadata.tags/metadata.labels even
though `list components` already did. Extends the same --tags/--labels
filtering to list stacks, instances, metadata, sources, and dependencies, and
--tags only to list vendor (manifest-declared tags, not stack metadata; no
labels concept in that schema). Also accepts ':' as an alternative to '=' in
--labels pairs (e.g. --labels=team:platform) everywhere the shared parser is
used (terraform --all, container/kubernetes/helm verbs, list components).

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: address CodeRabbit review findings on PR #2807

- pkg/list/dependencies/closure.go: StackNames now actually sorts (doc
  claimed "sorted" but graph.Nodes iteration is a non-deterministic map).
- Correct the eager-evaluation config path everywhere it's documented/
  commented: describe.settings.eager_evaluation, not
  settings.describe.settings.eager_evaluation (matches
  schema.DescribeSettings.EagerEvaluation's actual yaml/mapstructure tag).
- tests/fixtures/scenarios/dependencies-scoped-evaluation/atmos.yaml:
  components.terraform.base_path now points at the fixture's own local
  mock component instead of resolving outside the fixture to a shared,
  unrelated one.
- cmd/list/dependencies.go: list dependencies now parses --labels via
  LabelsRaw on DependenciesOptions (populated in parseDependenciesOptions,
  parsed in RunE) instead of reading viper directly, matching every other
  list subcommand's pattern and making the flag wiring unit-testable.
- Strengthen tags/labels filter tests (cmd/list/sources_test.go,
  cmd/list/vendor_test.go, pkg/list/list_instances_test.go,
  pkg/list/list_metadata_test.go) to assert exact returned rows and cover
  multi-tag any-match / multi-label all-match distinctly, so a reversed
  selector semantics bug would be caught.

cmd/list/sources.go's `return nil, err` after ParseLabelsFlag was flagged
as bypassing the error-wrapping convention, but left as-is: the error is
already wrapped with errUtils.ErrInvalidFlag at its origin in
pkg/tags/flags.go, and the same passthrough pattern is the established
convention in cmd/list/components.go and cmd/list/dependencies.go (8+
call sites) — wrapping only here would diverge from those siblings
without a correctness gain.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* test: regenerate --labels help-text golden snapshots

The colon-separator fix updated the --labels flag description everywhere
it's registered ("key=value or key:value pairs" instead of just
"key=value"), which reflows the wrapped --help text captured in these
golden snapshots. Regenerated with -regenerate-snapshots per this repo's
rule against hand-editing golden files; diff is exactly the reflowed
--labels line in each.

Fixes the Acceptance Tests (linux/windows/macos) CI failure — same 7
TestCLICommands subtests failed identically on all three OS matrix jobs
(tf_plan/terraform_provision/terraform/atmos_terraform help snapshots,
config_alias_tr): platform-independent captured CLI text, one fix covers
all three.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: treat unresolved YAML functions as undecidable selectors; reject --tags/--labels with --upload

Code-review fixes for the --tags/--labels scope-before-evaluate work:

- Extract the duplicated templated-selector guard into a shared
  tags.SelectorUnresolved helper that also detects unprocessed Atmos YAML
  functions (stored as plain "!env FOO"-style strings until function
  processing runs), so a component with e.g. metadata.tags: [!env TIER] is
  conservatively routed through full evaluation instead of being silently
  skipped by the early gate or the lightweight closure roots.
- Reject --tags/--labels combined with --upload in list instances: the
  Atmos Pro inventory upload is always unfiltered, so a filtered table next
  to a full upload would mislead. Matches the existing matrix/tree guards.

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat: dependency-closure selection (--include-dependencies/--include-dependents) for bulk terraform and list commands

Every multi-component terraform selection (--all, --components, --query,
-s, --tags, --labels, --affected) now accepts two depth-carrying closure
flags that expand the selection with its dependency-graph closure,
executed in dependency order (reverse for destroy) with cross-stack
edges followed:

- --include-dependencies[=N]: also run everything the selection depends
  on (its prerequisites), N levels deep (bare = unlimited).
- --include-dependents[=N]: same in the reverse direction. Previously a
  bool wired only into --affected; now works with every selection and
  accepts a depth (true/false stay accepted for compatibility).

Selectors choose the seed; closure flags expand it - closure members run
even when they do not match the selectors that seeded them. The same
flags on list components/stacks/instances preview the exact execution
set.

Implementation:

- pkg/dependency: Filter gains per-direction depth bounds
  (DependencyDepth/DependentDepth, 0 = unlimited) with a best-depth BFS
  replacing the unbounded DFS walk.
- pkg/scheduler/adapters: FilterTerraformGraph restructured to
  seed-then-expand - tags/labels/query narrow the seed (previously a
  post-filter), then one graph.Filter applies the closure from
  info/selection (merged, most-permissive depth). The per-node query
  skip is suppressed when the query already gated the seed, so
  closure-added prerequisites are not silently dropped.
- pkg/list/dependencies: the three-phase scoped evaluation from the
  list-dependencies work is generalized into ResolveScopedClosure and
  shared with the terraform bulk paths, so a closure run fully evaluates
  only the stacks the closure touches. Root selection is unified behind
  a Selector (components/stack-glob/tags/labels) used by list previews.
- Selector purity (by design): metadata.tags/metadata.labels drive
  scoping before evaluation, so values requiring auth or execution
  (!terraform.state, !store, !secret, !aws.*, !exec, atmos.Component,
  datasources, ...) are rejected with a hard error on any command that
  processes the manifest; plain strings, simple templates, and local
  functions (!env, !git.*, !include) remain allowed. Validation parses
  templates with the configured delimiters (no regex heuristics), and
  SelectorUnresolved is delimiter-aware as well.
- list stacks/components/instances also gain the tags/labels early-skip
  (scoped describe) so selector filtering no longer evaluates
  out-of-scope components.

Docs: flag docs for terraform plan/apply/deploy/destroy/init + usage and
the three list commands, selector-purity section in stack metadata docs,
changelog blog post, roadmap entry, and regenerated help-text golden
snapshots.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix: evaluate only the closure's own components, and resolve templated selectors in the lightweight phase

Field testing of the closure flags surfaced two ways evaluation still
escaped the selection scope:

1. Stack granularity: Phase C fully evaluated every component in each
   stack the closure touched, so a component that merely shared a stack
   file with an in-closure prerequisite had its templates and YAML
   functions (e.g. a cross-account !terraform.state) evaluated - and
   could fail auth - despite never being selected. The scoped closure
   engine now narrows each resolved describe pass to the closure's own
   components within that stack, and the list closure previews
   (components/stacks/instances) go through the same engine instead of
   a full describe followed by row filtering.

2. Templated selectors: metadata.tags/metadata.labels values containing
   Go templates were undecidable in the lightweight structural pass, so
   every such component conservatively became a closure seed - inflating
   the closure toward the whole repo. Since the selector purity contract
   guarantees selectors are at most simple templates over the stack
   context, the lightweight matcher now best-effort renders them (sprig
   functions, configured delimiters, missing keys treated as unresolved)
   and matches exactly; only genuinely unresolvable values still widen
   scope conservatively, never wrongly excluding a component.

Includes a regression test proving a poison component sharing a stack
with closure members is never evaluated, and resolution tests covering
templates, custom delimiters, missing keys, and nested values.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix: complete scoped dependency closure evaluation (#2816)

* fix: complete scoped dependency closure evaluation

* fix: scope label template resolution to requested keys

* fix: scope dependency label resolution to requested keys

* fix: clarify dependency levels output

* test: verify dependency levels output

* fix: address CodeRabbit review — closure rows, shared describe helper, purity bypass, error wrap, labels test

- list stacks closure preview: build rows with extract.Stacks over the
  resolved closure stacks instead of hand-rolled {"stack": name} rows,
  so var-derived columns stay populated exactly like the non-closure
  path.
- Extract the duplicated ExecuteDescribeStacksScoped wrapper in the list
  stacks/components closure paths into one newScopedDescribeFunc
  constructor.
- Selector purity: close the with/range/variable-alias bypass — field
  and variable accesses naming a forbidden atmos method (.Component,
  .Store, .GomplateDatasource) are now rejected regardless of what the
  dot or variable is bound to, since the binding cannot be proven
  statically and such names have no legitimate selector use. Covers
  `with atmos`, `$x := atmos`, parenthesized chains, and range bodies,
  with tests for each.
- Wrap the dependency-graph build error in the instances closure filter
  with the ErrBuildDepGraph sentinel.
- Add a labels-filter case to the scoped-dispatch instances test,
  asserting the labels reach the scoped describe variant.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix: address code-review follow-ups on closure selection and selector purity

- Add a completeness test guarding the selector purity deny-list: every
  YAML function registered in utils.AtmosYamlTags must be explicitly
  classified as forbidden or selector-safe, so a future function cannot
  silently bypass the contract; stale deny-list entries also fail.
- Unify the list instances closure preview with the lightweight closure
  the other list commands consume: processInstancesScopedClosure now
  returns the membership of result.Closure and the row filter is a plain
  membership lookup, removing the divergent resolved-graph rebuild
  (BuildGraph + Roots + ReachableClosure) and guaranteeing identical
  membership across list components/instances/dependencies by
  construction. Add an agreement test covering templated selectors.
- Deduplicate requestedSelectorLabels into tags.RequestedLabels (was
  copied verbatim in internal/exec and pkg/list/dependencies).
- Slash-normalize the closure seed stack glob (stackMatches) to match
  the non-closure instances path on Windows.
- Remove the unreachable query-at-seed branch in the terraform scheduler
  adapter: the only producer of TerraformSelection is the --affected
  path, and checkTerraformFlags rejects --affected with --query.
- Split renderLevels into levelDistances/sortedLevelNodes helpers to
  satisfy the cyclomatic-complexity gate.
- Changelog: state explicitly that the metadata.tags/metadata.labels
  purity contract is enforced for every component whenever stacks are
  enumerated, even without selector flags.

Co-Authored-By: Claude Fable 5 <[email protected]>

* test: reject stale selector-safe entries in the purity completeness test

Mirror the deny-list staleness check for the selector-safe allow-list, so
a renamed or removed YAML function cannot leave a dangling classification
in either direction. Addresses CodeRabbit review on PR #2807.

Co-Authored-By: Claude Fable 5 <[email protected]>

* chore: allow gh api graphql mutations in Claude Code settings

The blanket deny rule on `gh api graphql*mutation*` blocked legitimate
PR-review-thread replies/resolutions alongside anything else routed
through gh's GraphQL API, overriding the narrower `gh api graphql:*`
allow entry above it. Remove it now that this workflow needs mutations
(e.g. addPullRequestReviewThreadReply, resolveReviewThread) to work.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix: skip provenance during component rendering (#2829)

* fix: skip provenance during component rendering

* test: harden provenance rendering coverage

* fix: don't process Go templates in Terraform source code (#2145) (#2830)

Atmos parses the Terraform/OpenTofu source of a component with
`terraform-config-inspect` and stores the result in
`component_info.terraform_config`. That section is part of the component
section Atmos renders as a `Go` template, so a Terraform `description`
containing double curly braces — e.g. the GCP resource name format
`projects/{{project}}/locations/{{location}}/services/{{name}}` — aborted
every command with `function "project" not defined`.

Atmos templating belongs to the abstraction above Terraform modules, so
`component_info` is now excluded from template rendering in both the
`ProcessStacks` and `describe stacks` pipelines. It remains in the template
context, so `{{ .component_info.component_path }}` and friends keep working
in stack manifests.


Claude-Session: https://claude.ai/code/session_01E9zBYFTZLeu2gBjPjpRN8v

Co-authored-by: Claude <[email protected]>
Co-authored-by: Erik Osterman (Cloud Posse) <[email protected]>

* fix: preserve provenance output order

* test: update provenance describe snapshots

* perf(terraform-state): cache missing state reads

* test: cover raw provenance and missing state cache

* fix(test): stop Windows toolchain-vanishing flake in acceptance tests (#2834)

* fix(test): resolve CI toolchain cache binaries

* fix(tests): close TOCTOU race in Terraform/OpenTofu binary resolution

TestExecuteTerraform_Version and TestYamlFuncTerraformOutput each resolved
the tofu/terraform binary via RequireTofu/RequireTerraform, then made a
second, independent exec.LookPath call before isolating the binary. On the
Windows acceptance job's concurrent packages, another test can mutate the
shared toolchain cache directory between those two lookups, turning a
binary that just existed into a spurious "not found" failure.

RequireTerraformPath/RequireTofuPath now resolve the path once and hand it
back directly, removing the redundant lookup at each call site.

* fix(tests): fail loudly instead of returning an empty path on lookup miss

requireExecutablePath (backing RequireTerraformPath/RequireTofuPath) silently
returned "" when ATMOS_TEST_SKIP_PRECONDITION_CHECKS=true (set for every CI
acceptance job) and the binary wasn't found, instead of surfacing the miss.
Callers that need the resolved path then crashed on the empty string with a
confusing "open : file not found" error rather than a clear diagnostic.

RequireExecutable is decoupled back to its original full-bypass behavior
(a true no-op when checks are disabled) since its callers only need a
boolean gate, not a path -- only the path-returning variants now hard-fail
on a genuine lookup miss.

* fix(test): isolate toolchain install-path from the real shared cache dir

Several pkg/toolchain tests (TestRunInstall_WithLatestKeyword,
TestRunInstall_WithCanonicalFormat, TestRunInstall_WithValidToolSpec,
TestRunInstall_WithSetAsDefault, TestRunInstallWithNoArgs,
TestRunInstall_Reinstall, TestRunUninstall, TestRunUninstall_InvalidToolSpecFormat,
TestUninstallAllVersionsOfTool) called SetAtmosConfig() without setting
Toolchain.InstallPath. NewInstaller()'s GetInstallPath() falls back to the
real, shared XDG toolchain cache directory whenever InstallPath is empty --
the exact directory CI's "atmos toolchain install --default" step populates
and that the whole acceptance suite depends on for hashicorp/terraform and
opentofu/opentofu binaries for the rest of the run.

TestRunInstall_WithLatestKeyword and TestRunInstall_WithCanonicalFormat in
particular perform real network installs of real "terraform" binaries into
that shared path, racing with every other concurrently-running package's
test process reading tofu/terraform off PATH -- almost certainly the root
cause of the intermittent "'tofu' not found in PATH" hard failures seen on
the Windows acceptance job (round 3 of this investigation had already ruled
out a stale-PATH-visibility theory for this specific failure instance).

Fixed by pointing Toolchain.InstallPath at each test's own t.TempDir(),
matching the isolation pattern already used by the rest of the toolchain
test suite.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(test): isolate remaining toolchain-path leak, widen resolution retry

TestBuildToolRow/TestBuildToolRow_NotInstalled resolved NewInstaller()'s
binDir to the real shared toolchain cache dir (no InstallPath override),
same class of issue fixed in fdbb83f -- read-only here, but still worth
isolating for hygiene and to rule them out as a contributor.

The Windows tofu-not-found flake recurred in CI even after that fix, so
widen requireExecutablePath's retry window from 2s to 15s as a defensive
backstop: some residual contention under the acceptance job's concurrent
package load isn't yet fully identified, and a longer bounded poll is safer
than risking another silent failure while that's tracked down.

* test(ci): add lookup forensics for the Windows toolchain-vanishing flake

The Windows acceptance job has a recurring failure where an installed
toolchain binary (tofu/terraform) vanishes from PATH mid-suite for the
full retry window. Root-cause candidates are all writer-side windows in
the shared toolchain cache (uninstall RemoveAll, onedir rename-aside,
in-place flat-install extraction) but four rounds of static analysis
couldn't pin which one fires in CI.

requireExecutablePath now dumps per-PATH-entry forensics on failure:
whether each toolchain dir exists, its contents, target presence, and
whether the installer's ".lock" sibling is held. The next CI failure
becomes direct evidence of the mechanism (dir deleted vs tree renamed
aside vs writer mid-flight vs PATH corruption) instead of another guess.

* fix(test): stop telemetry test deleting the shared Atmos cache root

Root cause of the recurring Windows acceptance flake, confirmed by the
lookup forensics added in a68e195: the failure dump showed EVERY
toolchain directory (terraform, opentofu, helm, helmfile) gone at once
-- the whole <cache>/atmos tree had been deleted mid-run.

TestPrintTelemetryDisclosureOnlyOnce "cleaned up" by os.RemoveAll on
filepath.Dir(cfg.GetCacheFilePath()) -- the real shared <cache>/atmos
root -- twice (setup + defer). Ever since the toolchain install root
moved underneath that same root (<cache>/atmos/toolchain, #2579), this
deleted every CI-provisioned tool out from under the concurrently
running package test binaries. Whichever terraform/tofu-dependent test
happened to run during the window failed with "executable file not
found in %PATH%"; the tests package healed itself via TestMain
re-provisioning, which is why only internal/exec kept failing.

All four disclosure tests now isolate the cache via a per-test
ATMOS_XDG_CACHE_HOME/XDG_CACHE_HOME redirect instead of deleting
anything shared. This also fixes the sibling tests that "cleaned"
./.atmos -- a directory the disclosure code never used -- while
actually polluting the real user-level cache.yaml.

* docs(fixes): record telemetry-test shared-cache-root fix

* docs(fixes): note extraction onto osterman/toolchain-cache-fix-own-pr

Update the commit/branch reference now that this self-contained
investigation ships as its own PR instead of riding along with #2812's
unrelated CI git-clone-bootstrap feature.

* test(tests): cover forensics and retry-path branches in requireExecutablePath

Codecov flagged tests/preconditions.go at 60.93% patch coverage: the new
requireExecutablePath retry loop, executableLookupForensics,
describeToolchainPathEntry, RequireTerraformPath, and RequireTofuPath had no
direct tests. Add real assertion-based coverage for the resolve-on-first-try,
retry-until-resolved, and exhausted-retries-skip paths, plus table-driven
tests for the forensics string-building logic (target present/absent,
directory contents, writer-lock sibling, unreadable dir).

Convert executablePathRetryTimeout/Interval from const to var so tests can
shrink the retry window instead of waiting out the real 15s.

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
Co-authored-by: Andriy Knysh <[email protected]>

---------

Co-authored-by: thejrose1984 <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Erik Osterman (Cloud Posse) <[email protected]>
Co-authored-by: Andriy Knysh <[email protected]>

* test: close patch-scoped coverage gaps on cross-stack-dag-closure

Add behavior-asserting tests for previously-uncovered lines this patch
introduced: ghost-dependency tolerance in the dependency filter, direct
coverage of closure.go's exported helpers, Phase-C describe-error
propagation and merge fallback branches in scope.go, levels rendering
edge cases (reverse/both direction, diamond convergence, tie-breaking,
unresolvable node IDs), templated-tag/unresolvable-label resolution in
render.go, selector-purity edge cases (bare template reference, else-
branch forbidden call, if-without-else), the tags-filter exclusion
branch in the scheduler adapter's selection seeding, and PredicateFilter/
extract-metadata helpers that previously had zero direct coverage.

Genuinely unreachable branches (BuildGraph/selectedTerraformNodeIDs
error guards with no current failing path, and a few defensive nil/
empty-slice guards in the selector template-parse walk) are left
uncovered with the reasoning left in the corresponding review thread
rather than padded with tautological tests.

Co-Authored-By: Claude Fable 5 <[email protected]>

* test: close coverage gaps in cross-stack dependency closure code paths

Adds real behavior tests for the closure-preview flows added by this PR
(--include-dependencies/--include-dependents on terraform bulk commands and
list components/stacks/instances) that had no unit coverage: the closure-
requested branches of describeTerraformStacksForExecution, the scoped-closure
extraction helpers in cmd/list (components/stacks/instances), the tags/labels
early-skip template-resolution layer in describe_stacks_component_processor.go,
DefaultStacksProcessor.ExecuteDescribeStacksScoped, ExecuteDescribeStacksWithAuthDisabledAndMocks,
includeDependentsFlagValue's dual bool/string flag shapes, and several RunE-level
closure-flag error paths across cmd/list.

Adds a small dedicated fixture (list-components-closure-tags) with a tagged
forward dependency chain plus an unrelated component and an always-failing
component, used to assert closure membership is exact (never pulls in
unrelated siblings) and that evaluation errors from the closure's own seed
propagate instead of being swallowed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* test: close remaining patch-scoped coverage gaps in cmd/list, pkg/list

Cover RunE/ParseLabelsFlag/closure-preview error-propagation branches
introduced by this patch's --tags/--labels and dependency-closure
selection work: components/dependencies/stacks command error paths in
cmd/list, and the labels-parse error branch in
pkg/list.ExecuteListInstancesCmd's non-tree/non-matrix path.

Remaining zero-coverage lines (BuildGraph/selectedTerraformNodeIDs error
guards with no failing path, defensive nil/empty-slice guards in the
selector template-parse walk, and two nil-map guards on describe results
that are always non-nil on the success path) are confirmed genuinely
unreachable, consistent with prior cycles' documented reasoning.

Co-Authored-By: Claude Fable 5 <[email protected]>

* refactor(exec): extract Spacelift/Atlantis and sources-exclusion helpers from ProcessStacks

Addresses CodeRabbit feedback that ProcessStacks was growing past the
function-size/complexity guidelines. Extracts the Spacelift/Atlantis name
computation into computeSpaceliftAndAtlantisNames and the sources
capture/delete/restore pair into excludeSourcesFromEvaluation, keeping the
orchestrator closer to a linear pipeline.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: address CodeRabbit feedback on PR #2807

- Document the selector purity contract (validateSelectorMetadata runs
  always, independent of active tags/labels filters or eager_evaluation)
  in the scope-before-evaluate fix doc, so the always-on rejection of
  forbidden selector functions isn't a surprise.
- Reorder imports in terraform_state_output_coverage_test.go into a
  single Atmos-package group.
- Widen the provisioned_by_user sanitization regex to also preserve
  double-quoted (not just single-quoted) unresolved provenance
  templates, with a regression test.
- Fix list-vendor.mdx: only vendor manifests lack a labels concept;
  component manifests already support metadata.labels elsewhere.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* [autocommit] formatting fixes

* fix(ci): add deterministic URL overrides for flaky gopkg.in NOTICE entries

Review Dependency Licenses was failing because 5 gopkg.in vanity-import
dependencies (ini.v1, evanphx/json-patch.v4, inf.v0, op/go-logging.v1,
warnings.v0) resolve their license URL via go-licenses' network/source
metadata lookup, which is flaky: it sometimes emits "URL: Unknown"
instead of the real GitHub blob URL, producing a NOTICE diff regardless
of which value happened to be committed last (an earlier autocommit on
this branch had in fact regenerated NOTICE mid-flake, reverting these
five URLs back to "Unknown").

Add these five modules to generate-notice.sh's existing REPO_OVERRIDES
mechanism (already used for dario.cat/mergo, inet.af/netaddr, and the
cloud.google.com/go split modules for the same reason), so their URLs
are rebuilt deterministically from the pinned go.mod version instead of
depending on network resolution. Verified byte-identical NOTICE output
across three consecutive regenerations.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(ci): convert generate-notice.sh to tab indentation per .editorconfig

Run pre-commit hooks and Validation (affected) were both failing with
"Wrong indentation type(spaces instead of tabs)" across dozens of lines
in scripts/generate-notice.sh: .editorconfig requires indent_style=tab
for *.sh, but this file has always used spaces. This was latent — the
editorconfig check validates whichever files appear in a commit's diff,
and nothing had touched this file until the REPO_OVERRIDES change in
183fb78, which put its pre-existing (unrelated) violation in scope.

Convert all shell-code indentation (4/8/12 spaces -> 1/2/3 tabs) to
tabs. The one heredoc with genuine indented body content (the footer's
"  go-licenses report ./..." and "  https://github.com/cloudposse/atmos"
lines, which become literal NOTICE text, not shell structure) is
rewritten as a sequence of top-level `echo` statements instead, so the
indentation lives inside a quoted string rather than as leading-line
whitespace -- satisfying the tab rule without changing NOTICE's output.
Verified byte-identical NOTICE content before/after, and `atmos
validate --affected --exclude 'tests/fixtures/**' --exclude '**/*.go'
--format rich` (the exact pre-commit hook command) now reports
"editorconfig: passed".

Co-Authored-By: Claude Fable 5 <[email protected]>

* [autocommit] formatting fixes

* fix(ci): add gopkg.in/yaml.v2 and v3 to NOTICE URL overrides

A second flaky autocommit (10061ca) reverted these two modules' URLs
to "Unknown" the same way the five modules fixed in 183fb78 did.
Rather than keep patching individual gopkg.in modules as they happen to
flake, enumerated every gopkg.in/* module actually present in NOTICE
(go list -m all | grep gopkg.in, cross-checked against the generated
file) — all 7 are now covered. Verified deterministic output across
repeated regenerations.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(test): cross-platform USER env var and Windows backslash-quote sanitization

Two independent Windows-only Acceptance Tests failures:

1. TestSanitizeOutput_WithCustomReplacements/Preserve_double-quoted_
   provenance_template: sanitizeOutput's filepath.ToSlash(protectedOutput)
   call converts every backslash to a forward slash on Windows (a no-op on
   Unix), which corrupted literal `\"` sequences in quoted provenance
   templates (e.g. `env \"USER\"`) into `/"`. Protect `\"` behind a
   placeholder before ToSlash and restore it after, mirroring the existing
   JSON-unicode-escape protection immediately above it in the same
   function.

2. TestCLICommands/describe_component_with_{current_directory,relative_path,
   component_name_(backward_compatibility)}: the "complete" fixture's
   provisioned_by_user used `{{ env "USER" }}`. Windows doesn't set USER
   (it sets USERNAME), so the template rendered to an empty string, which
   serializes as a quoted `""` -- and the sanitizer's provisionedByUserRegex
   deliberately excludes quote-leading values (added in b315ec2, to
   preserve unresolved quoted templates), so it never got normalized to the
   expected `user` placeholder. Add the same fallback to the identical
   pattern in the quick-start-advanced example. Golden snapshots
   regenerated via -regenerate-snapshots to reflect the new template
   source text (the rendered/sanitized line is unchanged).

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(list): scope `list sources` --tags/--labels before evaluation; nitpick cleanup

`atmos list sources` filtered by --tags/--labels only after describe-stacks
had already evaluated auth/templates/YAML-functions for every stack. Switch
to ExecuteDescribeStacksScoped so out-of-scope components are skipped before
evaluation, matching the scope-before-evaluate pattern already used by the
other list commands.

Also addresses a few CodeRabbit nitpicks: replace a hand-rolled
containsString with slices.Contains in pkg/list/dependencies/scope.go,
compute componentTypes once per call instead of once per stack in
pkg/list/extract/stacks.go, convert the tags/labels row-filtering subtests
in list_instances_test.go and list_metadata_test.go to table-driven tests,
and drop the dead filterSpec field/case from TestBuildMetadataFilters.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* test: cover escaped-quote and JSON-unicode-escape preservation together

TestSanitizeOutput had no case exercising the two Windows-only
filepath.ToSlash protections (escaped \" and >-style unicode
escapes) together, or the > protection at all. Add a regression
case with both in one input, per CodeRabbit review on 22a94a4. Only
meaningfully exercises the platform-specific path on Windows (ToSlash
is a no-op elsewhere), matching how the original bug was only caught
by Windows CI.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(closure): review fixes — affected depth bound, selector purity hardening, wrongful-exclusion edges

High severity:

- --affected --include-dependents=N no longer silently expands unlimited:
  the selection producer bridged the depth-carrying flag through a bool and
  left DependentDepth zero (= unlimited in filter encoding), so the
  most-permissive closure merge erased the user's bound. The new
  affectedTerraformSelection helper carries the parsed depth from info via
  the exported FlagDepthToFilterDepth conversion.
- Selector purity blast radius: the error now names the offending component
  and stack manifest; describe.settings.eager_evaluation (the advertised
  rollback switch) also bypasses purity validation — with full evaluation
  forced there is no pre-evaluation scoping to protect; docs corrected to
  state the true enforcement surface (stack-enumerating commands).
- Purity gate laundering holes closed: atmos.Resolve (launders any YAML
  function through a template call), gomplate datasource access beyond
  ds/datasource (include, datasourceExists, datasourceReachable,
  defineDatasource), the gomplate aws/gcp/net/random namespaces, and sprig
  network/nondeterministic functions (getHostByName, uuidv4, randAlpha*,
  randBytes, now) are now rejected in selectors; map KEYS are validated too.
- Wrongful-exclusion edge fixed: RequestedLabels is shape-aware — a non-map
  labels value (templated scalar) or a templated map key cannot be safely
  narrowed, so the selector is undecidable and falls through to full
  evaluation instead of collapsing to a decidable non-match.
  SelectorUnresolved now also considers map keys.
- Reverse-closure blind spot fixed: a dependent whose dependency declaration
  is templated produces no lightweight-graph edge and was never evaluated,
  so --include-dependents silently omitted it. Reverse/both directions now
  conservatively evaluate UnresolvedDependencySources so their edges
  materialize; membership is still decided by the recomputed closure.

Medium severity:

- Preview/execution alignment: the final closure re-tests the seed roots
  against the RESOLVED graph (refineRoots), so a root whose templated
  selector resolves to a non-matching value is dropped — list previews now
  match the execution set instead of being a conservative superset.
- describe.settings.eager_evaluation documented on the website
  (cli/configuration/describe) and referenced from the blog post as the
  migration escape hatch for the purity contract; blog also documents the
  --affected --include-dependents --tags scope-semantics change and the
  bare-flag depth syntax sharp edge.

Low severity:

- list vendor --tags binds ATMOS_VENDOR_TAGS instead of reusing
  ATMOS_COMPONENT_TAGS for a semantically different filter (vendor manifest
  tags, not component metadata.tags).
- list metadata docs no longer advertise the not-yet-implemented --filter
  expression; examples use jq over --format json instead.

Tests added:

- --affected selection depth table (bare/bounded/forced/nil-info) and a
  closure-spec merge case pinning that same-flag inputs keep the bound.
- Purity: ~20 deny-list cases including allowed-direction guards
  (.vars.aws/.vars.now stay legal), map-key rejection, and the documented
  .vars.Component conservatism; eager_evaluation bypass; error identity.
- Wrongful exclusion: templated-scalar labels and templated label keys fall
  through to full evaluation at the processor level.
- Reverse closure: templated same-stack and cross-stack dependents are
  discovered; evaluated non-dependents stay out of the closure; forward
  direction skips the conservative evaluation entirely.
- Preview drift: resolved-to-non-matching root is dropped from the closure.
- Cross-stack execution ordering through ExecuteTerraform (vpc-core before
  app-dev; reversed for destroy) and destroy --include-dependencies ordering
  (seed first, prerequisites last).
- Destroy --include-dependencies warning presence/absence via the UI-stream
  capture seam; not-provisioned state-cache invalidation including
  mismatched-key negative guards.

Co-Authored-By: Claude Fable 5 <[email protected]>

* refactor(closure): build the seed selector in one place

Extract the Selector construction shared by the lightweight seed pass
(ResolveScopedClosure) and the resolved-graph root refinement (refineRoots)
into a ScopeRequest.selector() method. The refinement must apply exactly the
same filters as the seed pass; constructing them in one place keeps the two
passes identical by construction when a selector field is added.

Addresses a CodeRabbit review comment on PR #2807.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(lint): extract resolveLabelSelector to reduce nestif complexity

internal/exec/describe_stacks_component_processor.go:853 was flagged by
nestif (complexity: 4). Extracts the label-narrowing/resolution block from
inScopeByTagsAndLabelsWithContext into a named helper, resolveLabelSelector,
preserving behavior exactly.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(list): restrict stacks closure preview to final closure; address review comments

CodeRabbit review fixes on PR #2807:

list stacks closure correctness:

- `list stacks --include-*` output is now restricted to the FINAL closure's
  stacks before extraction. result.Stacks can hold conservatively evaluated
  stacks that are not closure members (the reverse direction evaluates
  unresolved dependency sources so their edges materialize, and refineRoots
  can drop an initially conservative root once its selector resolves) —
  list components/instances already filtered by closure membership; stacks
  now does too, so the preview matches the execution set. Regression-tested
  with a new qa fixture stack whose templated dependency resolves outside
  the closure (test fails with the filter removed).
- With --component, closure-extracted stack rows now carry the component
  under "component" for stacks that actually contain it, matching
  extract.StacksForComponent's row shape so `{{ .component }}` columns
  render identically with and without closure flags. Prerequisite stacks
  without the component keep no component key rather than claiming one.

Help text and docs:

- The --include-dependencies/--include-dependents descriptions now state
  the order is reversed for destroy; 7 terraform help golden snapshots
  regenerated via -regenerate-snapshots.
- list dependencies levels doc: the positional component argument is now
  listed among the level-0 seeds alongside --stack/--tags/--labels.

Test hardening:

- USER and USERNAME pinned to "user" in all three component-path-resolution
  test cases that snapshot provisioned_by_user: the sanitizer regex cannot
  cover a username containing spaces or both vars being unset, so the
  snapshots were portable only by accident. Snapshots regenerated
  (byte-identical — the pinning makes the sanitized value genuine).
- Invalid --labels tests (cmd/list sources, pkg/list instances) now assert
  errUtils.ErrInvalidFlag and the offending value, not just any error.
- Added the fail-open scoped-dispatch test: tags/labels filters with a
  processor lacking the optional scoped interface fall back cleanly.
- The instances closure-preview test now captures the data stream and
  asserts the exact rendered component set instead of only NoError.
- GetTagsFromMetadata/GetLabelsFromMetadata tests converted to table-driven
  with mixed-type cases; render levels selector cases named as subtests
  with the fixture built inline; ResolveSelectorValue test's name-string
  branch replaced with a per-case data field.
- Removed a //nolint:dupl directive made unused by the strengthened test.

Deferred with follow-up issues to be opened: functional-options migration
for the ExecuteDescribeStacks* family (heavy refactor, wrong to do
mid-review) and honoring --filter in list metadata (feature gap, docs
already corrected).

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(test): normalize ANSI and wrapping in destroy-warning assertion

TestCheckTerraformFlagsDestroyDependenciesWarning asserted plain text on the
captured UI stream. Locally (non-TTY) the warning renders unstyled and the
test passed; on CI (all three OSes) the formatter renders the stream with
ANSI colors and width-dependent style segmentation — the sentence is split
across styled segments (`...the selected\x1b[0m\x1b[97m components`) — so
the Contains assertion failed.

Strip ANSI escape sequences and collapse all whitespace (including
wrap-inserted newlines) before asserting, in both the positive and negative
directions. Verified against the exact CI-captured byte sequence and under
ATMOS_FORCE_COLOR=true ATMOS_FORCE_TTY=true COLUMNS=80.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
Co-authored-by: Andriy Knysh <[email protected]>
Co-authored-by: zack-is-cool <[email protected]>
Co-authored-by: thejrose1984 <[email protected]>
Co-authored-by: atmos-pro[bot] <173522224+atmos-pro[bot]@users.noreply.github.com>
Co-authored-by: aknysh <[email protected]>

This branch was previously deployed

1 inactive deployment
screengrabs — 86b30bee Deployed Jul 30, 2026 by osterman via build #840
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-release Do not create a new release (wait for additional code changes) size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants