Skip to content

feat(describe affected): add --tags/--labels selectors and --flatten - #3297

Merged
Andriy Knysh (aknysh) merged 13 commits into
mainfrom
osterman/jnd72
Oct 8, 2026
Merged

Andriy Knysh (aknysh) merged 13 commits into
mainfrom
osterman/jnd72

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

what

  • Add --tags (match any) and --labels (match all) selectors to atmos describe affected and atmos list affected, with the same semantics as atmos terraform --tags/--labels. They filter every output format, including --format=matrix.

  • Replace the positional excludeLocked parameter threaded through the affected code with an AffectedFilter struct.

  • Apply the selectors to components deleted in HEAD (matched against their metadata in the base ref, including whole deleted stacks) and to nested --include-dependents lists. With --include-dependents, selectors are applied after dependents are resolved: a non-matching dependent is removed and its matching dependents move up, and a non-matching top-level affected component is removed with its matching dependents promoted to top-level entries reported as affected: dependent. So a change to a privileged (ci: manual) component still surfaces the automated components that depend on it.

  • Add --flatten (ATMOS_DESCRIBE_AFFECTED_FLATTEN) to describe affected, which lifts every remaining dependent into the top-level list for every format. Without it, --format=matrix only ever contained top-level entries, so dependents never reached the CI matrix. Requires --include-dependents; rejected with --upload.

  • list affected --include-dependents now resolves dependents and emits affected: dependent rows through the same code path.

  • atmos terraform --affected|--all --include-dependents --tags/--labels now prunes closure-added dependents that do not match the selectors (prerequisites still run regardless), with dropped intermediates contracted so execution and destroy order survive. This is a behavior change for --include-dependents with selectors and is called out in the terraform docs and the changelog.

  • Apply --exclude-locked to deleted components using their base-ref metadata, and to dependents that promotion or --flatten would lift into the top-level list, so a locked component never reaches the matrix through either path. Nested dependents of kept components are unchanged.

  • Reject --tags/--labels combined with --upload with hints when passed on the command line; selectors that arrive through ATMOS_TAGS/ATMOS_LABELS are ignored with a warning instead, so a job-level export does not break the unfiltered upload step.

  • Stop ATMOS_TAGS/ATMOS_LABELS leaking into other commands. The global Viper's automatic env lookup resolved the bare tags/labels keys before any explicitly bound env var, so a job-level export silently narrowed list components, list stacks, list affected, vendor update/diff/verify, and changed which identity auth login picked. A new per-flag flags.WithViperKey option moves those flags to namespaced keys (list.*, list.vendor.tags, vendor.*, auth.*) with their documented env vars (ATMOS_COMPONENT_*, ATMOS_VENDOR_*, ATMOS_AUTH_TAGS), so no two commands share a key. terraform keeps ATMOS_TAGS/ATMOS_LABELS but ignores env-only selectors when a component argument is given, and normalizes ATMOS_TAGS=a,b into two tags.

  • --labels parse errors now name the flag and env var and carry a hint.

  • Document the pattern: a default ci: auto label on every component, a ci: manual override on privileged components, --labels=ci=auto where CI builds its matrix, and an OPA policy as a backstop. Updates the describe affected and list affected references (including the previously undocumented --output-file), the native CI guide, the legacy-actions migration guide, the GitHub Actions matrix examples (guard on the count output, since an empty matrix is {"include":[]}), component metadata docs, and the atmos-ci agent skill. Adds a changelog post and a roadmap entry.

  • Add a real-stack regression fixture (tests/fixtures/scenarios/atmos-describe-affected-with-selectors) and test covering promotion, flatten, deleted and locked components, label flips, templated labels, and terraform parity. Fix records: docs/fixes/2026-10-07-affected-selectors-deleted-and-dependents.md and docs/fixes/2026-10-07-affected-selectors-field-test-fixes.md.

  • Fix a pre-existing panic (assignment to entry in nil map) when ATMOS_SCHEMAS_* environment variables or --schemas-* flags are used with an atmos.yaml that has no schemas: section, by using nil-safe setters at all eight write sites. Regenerate the describe affected and list affected help screengrabs.

  • Bump six website dependencies through pnpm.overrides to patched versions within their current major (shell-quote, source-map-js, proxy-addr, joi, compression, postcss-selector-parser), closing the matching Dependabot alerts.

why

  • Native CI has no equivalent of the legacy settings.github.actions_enabled, so foundation components (aws-teams, iam, tfstate-backend) always landed in the plan/apply matrix, and --format=matrix ignores --query.
  • Tags and labels already exist on components and are already used for bulk terraform runs. Reusing them keeps the opt-out in the stack configuration instead of in a jq filter in workflow YAML.
  • Labels match positively only, hence the default-plus-override pattern. The OPA policy fails the job rather than skipping it, so it is documented as a safety net and not as the opt-out.
  • A hands-on field test of the first iteration found that the selectors hid automated dependents of privileged changes, that terraform still ran privileged dependents the matrix excluded, and that the documented job-level env vars leaked into unrelated commands. Those are fixed here rather than deferred, because the documented CI pattern depends on all three behaving.

references

  • Adds --tags/--labels/--flatten to the surface described in website/docs/stacks/components/component-metadata.
  • Changelog post: website/blog/2026-10-07-ci-component-selectors.mdx.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Filter affected components and Terraform selections by tags and labels. Tags match any requested value; labels require all specified pairs to match.
    • Apply selectors to dependents while preserving matching descendants; optionally flatten dependents in describe affected.
    • Configure selector filters through command-specific environment variables.
    • CI workflow examples now use affected-component counts to skip deployment when no components match.
  • Bug Fixes
    • Corrected empty-result handling in CI workflows and clarified selector behavior for deleted and locked components.

Native CI had no per-instance opt-out and the affected matrix could not be
filtered, so privileged components (iam, aws-teams, tfstate-backend) always
reached the plan/apply matrix.

`atmos describe affected` and `atmos list affected` now accept `--tags`
(match any) and `--labels` (match all) with the same semantics as
`atmos terraform --tags/--labels`, applied to every output format including
`--format=matrix`. Combining them with `--upload` is rejected because the
upload is always unfiltered. The positional `excludeLocked` parameter is
replaced by an `AffectedFilter` struct.

Docs cover the default-label-plus-override pattern and an OPA backstop, with
a changelog post, roadmap entry, migration-guide note and atmos-ci skill update.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@atmos-pro

atmos-pro Bot commented Oct 7, 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 minor New features that do not break anything label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

  • website/pnpm-lock.yaml

Bump the patched versions through pnpm.overrides in website/ (all within the
current major, so the dependabot.yml ignore policy is respected):

- shell-quote 1.10.0 -> 1.11.0 (#321)
- source-map-js 1.2.1 -> 1.2.2 (#318)
- proxy-addr 2.0.7 -> 2.0.8 (#317)
- joi 17.13.7 -> 17.13.8 (#316)
- compression 1.8.1 -> 1.8.2 (#315)
- postcss-selector-parser 7.1.5 -> 7.1.6 (#314)

The remaining open alerts are not auto-fixable (no patch, major bump blocked
by policy, or an unfamiliar CodeQL/Semgrep rule).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: cloudposse/atmos/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 337c8fa8-1d9d-4b8c-b973-e7be13ac243b
📥 Commits

Reviewing files that changed from the base of the PR and between 997d2df and 472255f.

📒 Files selected for processing (12)
  • website/blog/2026-10-07-ci-component-selectors.mdx
  • website/docs/ci/ci.mdx
  • website/docs/ci/migrate-legacy-actions.mdx
  • website/docs/cli/commands/auth/logout.mdx
  • website/docs/cli/commands/describe/describe-affected.mdx
  • website/docs/cli/commands/list/list-affected.mdx
  • website/docs/cli/commands/terraform/terraform-apply.mdx
  • website/docs/cli/commands/terraform/terraform-deploy.mdx
  • website/docs/cli/commands/terraform/terraform-plan.mdx
  • website/docs/cli/commands/terraform/usage.mdx
  • website/docs/integrations/github-actions/deploy-affected.mdx
  • website/docs/stacks/components/metadata.mdx
🚧 Files skipped from review as they are similar to previous changes (4)
  • website/docs/cli/commands/terraform/terraform-plan.mdx
  • website/docs/cli/commands/auth/logout.mdx
  • website/docs/cli/commands/terraform/terraform-apply.mdx
  • website/docs/cli/commands/describe/describe-affected.mdx

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Adds tag and label selectors to affected-component commands and Terraform graph selection. Selectors filter live and deleted components and can prune or promote dependents. The change also adds namespaced environment handling, count-based CI matrix guards, and CI guidance.

Changes

Affected Component Selectors

Layer / File(s) Summary
Selector inputs and command integration
cmd/describe_affected*.go, cmd/list/*, cmd/terraform/*, cmd/auth/*, cmd/vendor/*, pkg/flags/*
Adds selector flags, Viper key overrides, environment-source tracking, parsing, and command-specific environment bindings.
Affected filtering and dependent resolution
internal/exec/describe_affected*.go, pkg/list/list_affected.go, pkg/schema/schema.go, pkg/tags/flags.go
Applies tag-any and label-all matching to affected components, filters deleted components using base metadata, and prunes or promotes dependents. Adds flattening and source-aware label errors.
Dependency selection and Terraform execution
pkg/dependency/*, pkg/list/dependencies/*, pkg/scheduler/adapters/terraform.go
Adds selector-aware dependency closures and contracts removed-node paths to preserve execution ordering.
Regression coverage and CI guidance
tests/*, internal/exec/*_test.go, pkg/*/*_test.go, agent-skills/*, website/docs/*, website/blog/*, docs/fixes/*
Adds selector tests and fixtures, documents filtering and environment behavior, and updates CI examples to guard on matrix counts.
Schema configuration and supporting updates
pkg/config/*, website/package.json, website/src/data/roadmap.js, website/static/casts/*
Adds nil-safe schema resource-path updates and tests, a package override, roadmap entry, and refreshed command help output.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI as describe affected CLI
  participant Resolver as Affected component resolver
  participant Dependents as Dependent finalizer
  participant Output as Matrix output
  CLI->>Resolver: parse selectors and find affected components
  Resolver->>Dependents: resolve dependents with metadata
  Dependents->>Dependents: prune unmatched entries and promote matching descendants
  Dependents->>Output: return filtered affected entries
Loading

Merge Risk: ⚪ Minimal · up to 47225

This change updates documentation for the new affected-component selectors. No merge-blocking risk is apparent from the supplied material.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: adding tag and label selectors and flattening support to describe affected. It is concise and directly related to the main changeset.
Docstring Coverage ✅ Passed Docstring coverage is 97.34% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 301 functions across 70 files. (12 skipped:…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

CI timing summary

Latest completed GitHub Actions runs for 472255fa941d.

  • PR wall-clock time: 27m 55s
  • Aggregate runner time: 10h 13m 05s
  • Included: 19 workflows, 127 jobs (including matrix jobs)

Wall-clock time spans the earliest included workflow creation through the latest completion. Aggregate runner time adds each job's execution time, so concurrent jobs are counted separately.

Workflow Elapsed Runner time Jobs
✅ Tests 27m 55s 8h 48m 47s 98
✅ Screengrabs 24m 08s 24m 00s 2
✅ Planfile Verify E2E 13m 58s 20m 10s 3
✅ Website Preview Build 9m 52s 9m 47s 1
✅ CodeQL 7m 49s 15m 59s 6
✅ atmos.ci 3m 57s 3m 52s 1
✅ Dependency Review 3m 48s 3m 42s 1
✅ Pre-commit 3m 16s 2m 35s 1
✅ Release Documentation Check 1m 06s 26s 1
✅ TruffleHog secret scan 46s 40s 1
✅ Link Check 42s 38s 1
✅ Algolia 38s 34s 2
✅ Validate Codeowners 33s 27s 1
✅ Validate Agent Skills 26s 21s 1
✅ PR Size Labeler 23s 18s 1
✅ vhs 23s 19s 3
✅ Verify Repository Symlinks 21s 18s 1
✅ autofix.ci 16s 12s 1
⏭️ Feature release 1s 0s 1
Longest jobs (top 10)
Job Workflow Duration Conclusion
build Screengrabs 23m 39s ✅ success
[race] non-acceptance test suite (shard 4/4) Tests 20m 04s ✅ success
[floci] go e2e Tests 16m 08s ✅ success
[race] non-acceptance test suite (shard 1/4) Tests 15m 19s ✅ success
Acceptance Tests (windows, shard 3/10) Tests 14m 55s ✅ success
Acceptance Tests (macos, shard 3/10) Tests 14m 35s ✅ success
Acceptance Tests (windows, shard 2/10) Tests 14m 24s ✅ success
[race] non-acceptance test suite (shard 3/4) Tests 13m 49s ✅ success
Acceptance Tests (windows, shard 5/10) Tests 13m 17s ✅ success
Acceptance Tests (macos, shard 2/10) Tests 13m 08s ✅ success

Updated automatically when a PR workflow finishes.

TestGetAffectedComponents patches the public ExecuteDescribeAffectedWithTarget*
wrappers, which keep their `excludeLocked bool` parameter (only the *WithOptions
variants take an AffectedFilter). The doubles had been switched to
`filter AffectedFilter`, so gomonkey's ApplyFunc type check panicked on Linux and
Windows ("target type ... and double type ... are different") and aborted the
whole internal/exec package. The test is skipped on darwin/arm64, so it was not
caught locally.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 7, 2026
@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.77278% with 80 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.74%. Comparing base (d81d8ea) to head (472255f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/describe_affected_selector_flags.go 77.77% 7 Missing and 7 partials ⚠️
pkg/list/list_affected.go 63.15% 14 Missing ⚠️
pkg/dependency/filter.go 88.98% 7 Missing and 6 partials ⚠️
pkg/scheduler/adapters/terraform.go 81.81% 4 Missing and 4 partials ⚠️
internal/exec/describe_affected_components.go 77.77% 3 Missing and 3 partials ⚠️
internal/exec/describe_affected_utils_2.go 97.38% 2 Missing and 3 partials ⚠️
cmd/describe_affected.go 33.33% 2 Missing and 2 partials ⚠️
cmd/list/affected.go 33.33% 4 Missing ⚠️
cmd/terraform/utils.go 89.28% 2 Missing and 1 partial ⚠️
internal/exec/describe_affected_utils_parallel.go 66.66% 2 Missing ⚠️
... and 5 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3297      +/-   ##
==========================================
+ Coverage   84.73%   84.74%   +0.01%     
==========================================
  Files        2122     2124       +2     
  Lines      207244   207934     +690     
==========================================
+ Hits       175602   176211     +609     
- Misses      23375    23428      +53     
- Partials     8267     8295      +28     
Flag Coverage Δ
unittests 84.74% <90.77%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
cmd/auth/login.go 63.12% <100.00%> (+0.41%) ⬆️
cmd/auth/logout.go 74.18% <100.00%> (+0.11%) ⬆️
cmd/list/components.go 84.76% <100.00%> (ø)
cmd/list/dependencies.go 89.55% <100.00%> (ø)
cmd/list/flag_wrappers.go 100.00% <100.00%> (ø)
cmd/list/instances.go 70.64% <100.00%> (ø)
cmd/list/metadata.go 64.93% <100.00%> (ø)
cmd/list/sources.go 83.75% <100.00%> (ø)
cmd/list/stacks.go 83.54% <100.00%> (ø)
cmd/list/vendor.go 49.27% <100.00%> (ø)
... and 30 more

... and 20 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.

…nd dependents

A field test of the new selectors found two paths that bypassed them. A
component deleted in HEAD, including every component of a deleted stack, was
always reported, so a privileged `ci: manual` component still reached the
`--labels=ci=auto` matrix. With --include-dependents, non-matching components
were still nested under their parents.

Deleted components are now matched against their metadata from the base ref.
Nested dependents are pruned recursively, promoting matching descendants of a
removed dependent to the nearest remaining ancestor. `terraform --affected` is
unchanged. `atmos list affected` picks up the deleted-component fix.

Docs, the changelog post and the atmos-ci skill now cover the
schemas.opa.base_path prerequisite for the OPA backstop, the empty-value
behavior, deleted and dependents handling, and the list affected flags. A fix
record is added under docs/fixes.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… no schemas

Setting ATMOS_SCHEMAS_OPA_BASE_PATH (or the jsonschema, cue and atmos-manifest
variants, or the matching --schemas-* flags) panicked with "assignment to entry
in nil map" when the loaded atmos.yaml had no `schemas:` section, because the
Schemas map is left nil in that case.

AtmosConfiguration already had a nil-safe SetSchemaRegistry, but eight write
sites in pkg/config/utils.go still assigned into the map directly. Add the
matching SetResourcePath setter and use the nil-safe setters at all eight
sites. Regression tests cover the environment variable path, the flag path and
the setter, and they fail with the original panic without the change.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Regenerate only the describe affected and list affected --help casts so they
show the new --tags and --labels flags, using the casts generator's --filter
option. Update the fix record: both pass-through follow-ups were resolved in
this pull request.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mergify

mergify Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

@mergify mergify Bot added the conflict This PR has conflicts label Oct 7, 2026
… are set

The nested-dependents pruning attached each dependent's metadata inside
addDependentsToAffected unconditionally. That added a populated field to every
dependent, so the whole-struct comparisons in TestDescribeAffectedWithDependents,
...WithoutTemplates and ...FilteredByStack failed on Linux, macOS and Windows CI.
Those tests skip inside a git worktree (go-git rejects the worktreeconfig
extension), which is why they were not caught locally.

addDependentsToAffected keeps its signature and original behavior and now
delegates to addDependentsToAffectedWithFilter. Execute uses the filtered variant
only when --tags or --labels is set, and the transient metadata is cleared after
pruning. The shared settings move into a dependentsOptions struct, which also
brings the touched functions within the argument and length limits.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 8, 2026
@osterman Erik Osterman (Cloud Posse) (osterman) changed the title feat(describe affected): add --tags and --labels selectors feat(describe affected): add --tags/--labels selectors and --flatten Oct 8, 2026
@osterman

Copy link
Copy Markdown
Member Author

CodeRabbit (@coderabbitai) review

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@aknysh
Andriy Knysh (aknysh) added this pull request to the merge queue Oct 8, 2026
@atmos-pro

atmos-pro Bot commented Oct 8, 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.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 8, 2026
@aknysh
Andriy Knysh (aknysh) added this pull request to the merge queue Oct 8, 2026
@atmos-pro

atmos-pro Bot commented Oct 8, 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.

Merged via the queue into main with commit 1c8f21b Oct 8, 2026
138 checks passed
@aknysh
Andriy Knysh (aknysh) deleted the osterman/jnd72 branch October 8, 2026 17:23
@atmos-pro

atmos-pro Bot commented Oct 8, 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.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

These changes were released in v1.231.0.

This branch was successfully deployed

1 active and 1 inactive deployments
preview — 472255fa Deployed Oct 8, 2026 by github-actions[bot]
screengrabs — 472255fa Deployed Oct 8, 2026 by osterman via build #2578
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything size/xl Extra large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants