Skip to content

Disable Build Harness - #993

Merged
Erik Osterman (Cloud Posse) (osterman) merged 1 commit into
mainfrom
disable-build-harness
Jan 31, 2025
Merged

Erik Osterman (Cloud Posse) (osterman) merged 1 commit into
mainfrom
disable-build-harness

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Jan 31, 2025 •

Copy link
Copy Markdown
Member

what

  • Remove build-harness injection
  • Add a placeholder for readme target

why

  • README generation is really the only use-case we have for the build-harness in this repo
  • We're ripping that out and going to start doing native README generation with atmos
  • Build Harness initialization started getting flakey

references

Summary by CodeRabbit

  • Chores
    • Temporarily disabled README generation
    • Removed linting process from build workflow
    • Simplified Makefile configuration

@mergify

mergify Bot commented Jan 31, 2025

Copy link
Copy Markdown
Contributor

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

@mergify mergify Bot added triage Needs triage needs-cloudposse Needs Cloud Posse assistance labels Jan 31, 2025
@osterman
Erik Osterman (Cloud Posse) (osterman) force-pushed the disable-build-harness branch 2 times, most recently from cae5b50 to ec51c5d Compare January 31, 2025 01:55
@osterman
Erik Osterman (Cloud Posse) (osterman) marked this pull request as ready for review January 31, 2025 02:18
@osterman Erik Osterman (Cloud Posse) (osterman) added no-release Do not create a new release (wait for additional code changes) and removed triage Needs triage labels Jan 31, 2025
@coderabbitai

coderabbitai Bot commented Jan 31, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The pull request introduces modifications to the Makefile, specifically removing the README_DEPS export and the entire lint target. The readme target has been updated to display a message about README generation being temporarily disabled and exit successfully. These changes appear to be adjusting the build and documentation workflow, with a focus on simplifying or pausing certain build-related processes.

Changes

File Change Summary
Makefile - Removed README_DEPS export line
- Modified readme target to output a temporary disable message
- Completely removed lint target

Possibly related PRs

Suggested labels

no-release


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75d6c46 and cfc8536.

📒 Files selected for processing (1)
  • Makefile (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (2)
Makefile (2)

13-15: HOLD! Document the temporary state, warrior!

While the placeholder maintains build pipeline stability, we should document the timeline and plan for the new README generation system using atmos.

Consider adding a comment above the target explaining:

  • Why README generation is disabled
  • When it will be re-enabled
  • Where to find current documentation in the meantime
+# TODO: README generation temporarily disabled while transitioning to native atmos-based generation
+# See PR #993 for context and timeline
 readme:
	@echo "README.md generation temporarily disabled."
	@exit 0
✅ Verification successful

HEED THE CALL, WARRIOR! Your documentation suggestion stands true!

The git history reveals this is part of a larger transition away from build-harness, removing the previous README generation that depended on docs/targets.md. Documentation is indeed needed to provide context for fellow warriors.

The suggested comment should specifically mention:

  • Removal of build-harness integration
  • Previous dependency on docs/targets.md
  • Plan for native atmos-based generation
+# TODO: README generation temporarily disabled during transition from build-harness to native atmos-based generation
+# Previous implementation required build-harness and docs/targets.md
+# Track progress in the atmos migration epic
 readme:
	@echo "README.md generation temporarily disabled."
	@exit 0
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for README-related comments and implementations
echo "=== Searching for README-related comments ==="
rg -i "readme.*generation|generate.*readme" --type make

echo -e "\n=== Checking for TODO comments about README ==="
rg -i "todo.*readme|readme.*todo" --type make

echo -e "\n=== Looking for PR #993 references ==="
rg "#993" --type make

echo -e "\n=== Examining current README generation implementation ==="
ast-grep --pattern 'readme:
  $$$'

Length of output: 665


Script:

#!/bin/bash
# Check recent git history for README-related changes
echo "=== Checking git history for README changes ==="
git log -n 5 --oneline -- Makefile

echo -e "\n=== Examining the previous README generation implementation ==="
git diff HEAD~1 HEAD -- Makefile

Length of output: 908


Line range hint 1-71: Verify the code quality safeguards, warrior!

The removal of the lint target raises concerns about code quality checks. Let's verify if linting is handled elsewhere in the CI/CD pipeline.

✅ Verification successful

Linting is well-covered through dedicated tools and commands, warrior!

The removal of the Makefile lint target is not a concern as the codebase has robust linting through:

  • EditorConfig validation via atmos validate editorconfig command
  • golangci-lint integration through Go tooling
  • Comprehensive EditorConfig settings in atmos.yaml
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for alternative linting mechanisms in CI/CD configuration

echo "Checking for CI/CD linting configurations..."
# Look for common CI config files
fd -t f "^\.github/workflows/.*\.(ya?ml|json)$|^\.gitlab-ci\.ya?ml$|^\.circleci/.*\.ya?ml$"

# Search for linting-related commands in CI configs and scripts
echo -e "\nSearching for linting commands in CI configurations..."
rg -i "lint|golangci|staticcheck|vet" -g "!vendor/"

Length of output: 66314


Script:

#!/bin/bash
# Search for linting configurations and references

# Look for golangci-lint config files
echo "Checking for golangci-lint config files..."
fd -t f "^\.golangci\.ya?ml$|^\.golangci\.toml$|^\.golangci\.json$"

# Search for references to common Go linting tools
echo -e "\nSearching for linting tool references..."
rg -i "golangci-lint|staticcheck|go\s+vet|go\s+lint|revive|golint" -g "!vendor/"

# Look for GitHub Actions workflow files that might contain linting
echo -e "\nChecking GitHub Actions workflows..."
fd -t f "^\.github/workflows/.*\.(ya?ml|json)$"

Length of output: 691


Script:

#!/bin/bash
# Search for linting and code quality checks including hidden files

# Look for CI config files and linting configs
echo "Checking CI and linting configurations..."
fd -H -t f "^\.golangci\.ya?ml$|^\.travis\.ya?ml$|^\.gitlab-ci\.ya?ml$|^\.github/workflows/.*\.ya?ml$"

# Broader search for code quality related terms
echo -e "\nSearching for code quality check references..."
rg -i "lint|vet|quality|check|analyze|inspect|review" -g "!vendor/" -g "!*.md" -g "!*.html" -g "!website/*"

# Check package.json or go.mod for linting dependencies
echo -e "\nChecking dependency files..."
fd -H -t f "^go\.mod$|^package\.json$" -x cat {}

Length of output: 68837


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@osterman
Erik Osterman (Cloud Posse) (osterman) deleted the disable-build-harness branch January 31, 2025 03:01
@mergify mergify Bot removed the needs-cloudposse Needs Cloud Posse assistance label Jan 31, 2025
@github-actions

github-actions Bot commented Feb 3, 2025

Copy link
Copy Markdown

These changes were released in v1.158.0.

Erik Osterman (Cloud Posse) (osterman) added a commit that referenced this pull request Oct 6, 2025
Upgraded to Chroma v2.20.0 which includes the fix for YAML multiline
whitespace issues (fixed in v2.15.0 via PR #993).

Changes:
- Updated all Chroma imports from v0 to v2
- Updated go.mod dependencies
- Removed old v0.10.0 dependency

The v2.15.0 release includes "Don't output extra whitespace in YAML
multiline" fix by @Gusted which should resolve the folded scalar
indentation duplication issue.

Kept the fixHighlightedIndentation() workaround as a safety net in case
the upstream fix doesn't cover all edge cases.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Erik Osterman (Cloud Posse) (osterman) added a commit that referenced this pull request Oct 6, 2025
Removed the fixHighlightedIndentation() workaround and helper functions
since the Chroma v2.20.0 upgrade fixed the YAML multiline indentation
issue.

The upstream fix in Chroma v2.15.0 (PR #993) properly handles YAML
folded scalars without adding duplicate whitespace, making our
post-processing workaround unnecessary.

Kept the stderr terminal detection enhancement as it's still needed
to ensure syntax highlighting works when provenance output goes to
stderr instead of stdout.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Andriy Knysh (aknysh) added a commit that referenced this pull request Oct 7, 2025
* feat: add --show-provenance flag to describe component and describe stacks

Add provenance tracking display that shows the source file and line number
for each configuration value in component and stack descriptions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* docs: revert broken provenance implementation, add comprehensive PRD

## what
- Reverted incomplete provenance implementation from pkg/ui/provenance/
- Removed --show-provenance flags from describe component and describe stacks commands
- Created comprehensive PRD for proper line-level provenance system at docs/prd/line-level-provenance.md

## why
The initial provenance implementation had fundamental limitations:
- Only tracked top-level section keys (vars.*, settings.*), not nested values
- Two-column rendering was broken and couldn't align with complex YAML structures
- No line number tracking, only file paths
- Not reusable across different Atmos config types (stacks, atmos.yaml, vendor, workflows)
- Output polluted with 750+ lines of raw sources data
- Tests didn't catch critical bugs

## references
- PRD: docs/prd/line-level-provenance.md
- Extends existing MergeContext system (pkg/merge/merge_context.go)
- Uses gopkg.in/yaml.v3 Node API for line tracking
- Estimated 3-4 weeks for proper implementation
- Backward compatible deprecation of current sources system

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* docs: rename PRD from line-level-provenance to import-provenance

Renamed PRD to better reflect that we're tracking import/inheritance chains
rather than just line-level granularity. 'Import provenance' more accurately
describes tracking where values come from through the import system.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* feat: complete provenance tracking implementation for nested imports

- Implement MergeWithProvenance function to track provenance during YAML merging
- Add provenance storage and entry management with thread-safe operations
- Create tree renderer for inline provenance visualization with depth indicators
- Add YAML position extraction utilities for accurate line/column tracking
- Fix nested import provenance tracking in stack processor
- Record provenance metadata using merge context's current file
- Handle []any type for imports array in describe component output
- Add comprehensive test suite for provenance tracking functionality
- Support JSONPath addressing for nested configuration values
- Add benchmarks for provenance operations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* feat: improve provenance display with line wrapping and updated legend

- Update provenance legend: change "Defined at this level" to "Defined in parent stack"
- Add LongString type that encodes as YAML folded scalars (>-) for long strings
- Add WrapLongStrings function to automatically wrap long strings in YAML output
- Integrate line wrapping in provenance renderer to prevent horizontal scrolling
- Long values like atmos_component_description now wrap properly with provenance comments aligned

This improves readability of provenance output by ensuring long string values are wrapped
using proper YAML folded scalar syntax, keeping provenance comments aligned at the comment
column and preventing the need for horizontal scrolling.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* fix: address CodeRabbit review feedback for provenance tracking

- Fix file output with --provenance flag by writing raw YAML to file
- Add perf.Track instrumentation to merge context helper functions
- Replace manual depth calculations with GetImportDepth() method
- Fix goroutine data race by using per-goroutine MergeContext
- Fix linting issues (godot comment capitalization, gosec file permissions)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* feat: add ProvenanceTracker interface and describe stacks provenance

- Create generic ProvenanceTracker interface for extensibility
- Add --provenance flag to describe stacks command
- Update MergeContext to document ProvenanceTracker implementation
- Add comprehensive unit tests for interface with mock implementation
- Update PRD to reflect actual implementation status and design decisions
- Document display format rationale (valid YAML output)
- Document symbol and color scheme with Unicode codes
- Document backward compatibility with sources system

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* fix: resolve yaml package type conflicts and address code review

- Add explicit yaml alias to gopkg.in/yaml.v3 imports to prevent type conflicts with go.yaml.in/yaml/v3 used by yqlib dependency
- Add missing perf.Track instrumentation to public functions in describe_component.go per coding guidelines
- Stabilize provenance value hashing by using json.Marshal for deterministic serialization instead of fmt.Sprintf

Fixes the CI build failure caused by YAML package type mismatch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* refactor: reduce cognitive complexity in provenance code

* fix: resolve all golangci-lint errors and warnings

- Extract constants for magic numbers and string literals
- Refactor all functions with >5 params to use config structs
- Fix getSymbolColor() to return different colors per symbol
- Split tree_renderer.go into multiple files (under 500 lines)
- Pass heavy params by pointer to avoid memory copying
- Extract helper functions to reduce cyclomatic complexity
- Fix all comment formatting (godot linter)
- Fix nilerr issues
- Fix nestif complexity in test by inverting conditions

All golangci-lint issues resolved for PR #1584

* fix: resolve provenance tracking bug and linting issues

## what
- Fixed bug where __import__: and __import_meta__: provenance entries weren't being recorded for direct imports
- Resolved race condition in parallel stack processing that caused wrong merge contexts to be stored
- Added per-stack merge context storage to replace single global variable
- Fixed comment formatting to end with periods (godot linter)
- Resolved code duplication in describe_affected_test.go
- Added "imports" to allowed fields in test

## why
- Provenance tracking is critical for showing users where configuration values come from
- The bug prevented proper tracking of imports defined directly in stack files
- Race conditions in parallel processing caused provenance to be attributed to wrong stack files
- Pre-commit hooks enforce code quality standards

## how
1. Added merge context initialization in ProcessYAMLConfigFileWithContext when nil
2. Created mergeContexts map to store contexts per stack file instead of single global
3. Added SetMergeContextForStack() and GetMergeContextForStack() functions
4. Updated ProcessYAMLConfigFiles to store each stack's context separately
5. Modified ExecuteDescribeComponentWithContext to retrieve stack-specific context
6. Maintained backward compatibility by keeping deprecated functions
7. Fixed all godot linter warnings in cmd files

## testing
- TestDescribeComponent_DirectImportProvenance passes
- TestDescribeComponent_NestedImportProvenance passes
- TestDescribeComponentWithProvenance passes
- All describe component tests pass
- All linting checks pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: address CodeRabbit review comments

## Critical Fixes
- **pkg/provenance/data_transform.go**: Fix nil context handling to preserve sections when provenance tracking is disabled
  - Initialize `hasProvenance := ctx == nil` to keep all keys when no provenance tracking
  - Prevents data loss when provenance is disabled

## Major Fixes
- **internal/exec/describe_component.go**: Fix TTY detection
  - Check `os.Stderr.Fd()` instead of `os.Stdout.Fd()` (correct stream)
  - Require both empty file and TTY to prevent spam to pipes/redirects

- **internal/exec/describe_component.go**: Add safe type assertion for imports
  - Use safe `if impStr, ok := imp.(string)` instead of panic-prone `imp.(string)`
  - Skip non-string values gracefully

- **pkg/provenance/text_utils.go**: Fix rune-safe text wrapping
  - Convert to `[]rune` before slicing to preserve multi-byte UTF-8 characters
  - Prevents corruption of ANSI sequences and Unicode text

- **pkg/provenance/tree_renderer.go**: Handle highlight failures gracefully
  - Fall back to plain YAML on highlight error instead of propagating error
  - Ensures users always see YAML output

## Minor Fixes
- **docs/prd/import-provenance.md**: Add language identifiers to fenced code blocks
  - Change ` ``` ` to ` ```text ` for legend and architecture diagram
  - Fixes markdownlint warnings

All fixes verified with:
- Build: ✅ Passes
- Linting: ✅ 0 issues
- Tests: ✅ All pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* refactor: remove incomplete RenderInline() and consolidate to production implementation

## What Changed
- **Removed `RenderInline()` function** - Incomplete placeholder that only returned plain YAML
- **Updated tests** to use `RenderInlineProvenanceWithStackFile()` production implementation
- **Renamed files** for clarity:
  - `inline.go` → `provenance_helpers.go` (now only contains helper utilities)
  - `inline_test.go` → `provenance_helpers_test.go`
- **Kept `FormatProvenanceComment()`** - Useful helper for formatting provenance entries

## Why
CodeRabbit correctly identified that `RenderInline()` was incomplete (just returned YAML without provenance comments).

The PR already has a complete implementation in `RenderInlineProvenanceWithStackFile()` that:
- Adds provenance legend
- Parses YAML structure and builds path mapping
- Looks up provenance for each key
- Adds inline comments with file:line:column
- Used in production code (describe_component.go:135)

`RenderInline()` was only used in 2 unit tests and created confusion. Consolidating to a single implementation eliminates duplication and makes the codebase clearer.

## Verification
- ✅ Build passes
- ✅ All tests pass (updated to use production function)
- ✅ Linting passes (0 issues)
- ✅ Single source of truth for inline provenance rendering

Addresses CodeRabbit review: #1584 (comment)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* perf: add performance tracking to FormatProvenanceComment

## What Changed
- Added `perf` import to `pkg/provenance/provenance_helpers.go`
- Added `defer perf.Track(nil, "provenance.FormatProvenanceComment")()` to track performance

## Why
All exported functions should have performance tracking for observability and profiling. This was missing from `FormatProvenanceComment()`.

## Verification
- ✅ Build passes
- ✅ Tests pass
- ✅ Linting passes (0 issues)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: remove unnecessary perf tracking from unused test helper

## What Changed
- Removed `perf.Track()` call from `FormatProvenanceComment()`
- Removed unused `perf` import

## Why
`FormatProvenanceComment()` is only used in test code, not in production. Adding performance tracking to a test-only helper function provides no value and was causing CI failures on macOS and Windows platforms.

## Issue
- Commit `2374f64de` added perf tracking and caused CI failures
- Linux: ✅ PASS
- macOS: ❌ FAIL
- Windows: ❌ FAIL

## Root Cause
The function is unused in production code - only called in its own test. Performance tracking on an unused helper is unnecessary and introduced platform-specific failures.

## Verification
- ✅ Build passes
- ✅ Tests pass locally
- ✅ Linting passes (0 issues)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* refactor: move formatProvenanceComment to test file

## What Changed
- Moved `FormatProvenanceComment()` from `provenance_helpers.go` (production code) to `provenance_helpers_test.go` (test code)
- Made function unexported (`formatProvenanceComment`) since it's test-only
- Deleted `provenance_helpers.go` as it's now empty

## Why
The function was only used in tests, not in production code. Having an exported function in production files that's only used in tests is misleading and was the reason CodeRabbit flagged it as an incomplete implementation.

**Original Context:**
- `FormatProvenanceComment()` was originally part of the incomplete `RenderInline()` implementation
- When we removed `RenderInline()` (commit 99f4bb9), we kept this helper thinking it might be useful
- But it's never actually used in production - only in its own test

**Proper Organization:**
- Test-only helpers belong in `_test.go` files
- Should be unexported (lowercase) to indicate internal test usage
- Keeps production code clean and focused

## Verification
- ✅ Build passes
- ✅ All tests pass
- ✅ Linting passes (0 issues)
- ✅ No production code affected

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: ensure deterministic provenance tracking by sorting map keys

Provenance tracking was non-deterministic due to Go's random map iteration order.
This caused test failures on macOS CI where `TestDescribeComponentWithProvenance`
expected to find specific paths like `vars.enabled` or `vars.name`, but map iteration
could skip them depending on iteration order.

Changes:
- Sort map keys before iterating in `recordMapProvenance()`
- Ensures consistent provenance path recording across all platforms
- Fixes flaky test failures on macOS CI

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: address CodeRabbit review comments on provenance tracking

CodeRabbit identified three issues with provenance implementation and tests:

1. **ValueHash not populated**: ProvenanceEntry.ValueHash field was empty
   - Added `value` parameter to provenanceEntryParams
   - Updated recordProvenanceEntry to compute and set ValueHash using hashValue()
   - Pass actual values through all recordProvenanceEntry calls
   - Changed params to pointer to satisfy gocritic hugeParam linter

2. **Missing negative assertions**: Test didn't verify provenance absence
   - Added assertions to ensure no provenance comments when ctx is nil
   - Test now checks for absence of "# from:" and "# Provenance Legend:"

3. **Weak provenance format assertions**: Test only checked for presence
   - Added exact format checks for provenance comments ("# ● [0] config.yaml:10")
   - Added legend symbol verification (●, ○, ∴)
   - Fixed bug where legend was always shown even when ctx is nil

These changes ensure provenance entries have complete metadata for change
detection and that tests properly verify both positive and negative cases.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: improve provenance display with parent stack header and depth 1 symbol

Changes the provenance rendering to be more intuitive:

1. **Added parent stack header**: Shows which stack file is being described
   - Displays "# Stack: {filename}" before the YAML output
   - Helps users understand the context

2. **Fixed symbol logic**: Changed from depth 0 to depth 1 for parent stack
   - ● [1] now shows values defined in the parent stack
   - ○ [2+] shows values inherited from imports
   - Depth 0 never occurred in practice (parent stack is always depth 1)

3. **Updated legend text**: Reflects new depth numbering
   - "● [1] Defined in parent stack"
   - "○ [N] Inherited/imported (N=2+ levels deep)"

4. **Adjusted color coding**: Makes depths 1-2 green
   - Depth 1-2: green (parent + first import)
   - Depth 3: yellow (getting far)
   - Depth 4+: red (very far)

5. **Updated all tests**: Changed test expectations from depth 0 to depth 1

6. **Refactored legend rendering**: Extracted into helper function to reduce cyclomatic complexity

This makes provenance output more intuitive and useful for understanding
where configuration values come from.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* test: add comprehensive provenance output validation tests

Add tests to validate complete provenance rendering output:
- TestProvenanceOutputFormat: validates legend, stack header, symbols, and depth formatting for all depth levels
- TestProvenanceComputedType: validates computed values show ∴ symbol regardless of depth

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: respect indent configuration when rendering YAML with provenance

When rendering YAML with provenance comments, now respects the indent
configuration from atmosConfig.Settings.Terminal.TabWidth instead of
always using the default indent of 2. This ensures folded YAML scalars
(like atmos_component_description with >-) are indented correctly
according to the user's configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* test: add tests to validate YAML indent configuration for folded scalars

Add comprehensive tests to verify that YAML folded scalar indentation
respects the tab_width configuration:
- TestYAMLIndentRespected: Validates indent=2 (default) produces 6 spaces
- TestYAMLIndentWithIndent4: Validates indent=4 produces 12 spaces

These tests ensure that the fix in tree_renderer.go correctly respects
the TabWidth configuration when rendering YAML with provenance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: disable syntax highlighting for provenance to fix folded scalar indentation

The Chroma syntax highlighter was adding extra indentation (6 spaces) to
YAML folded scalar continuation lines, causing them to display with 12
spaces instead of the correct 6 spaces.

Root cause: When highlighting YAML with folded scalars (>-), the Chroma
lexer/formatter adds duplicate indentation to continuation lines:
- Original: "      Vpc-Flow-Logs-Bucket..."  (6 spaces)
- After highlighting: "      \x1b[0m      Vpc-Flow..." (6 + 6 = 12 spaces)

Solution: Disable syntax highlighting for provenance output. The YAML
structure is already clear with provenance comments, and this avoids
the indentation duplication issue.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: preserve syntax highlighting while fixing folded scalar indentation

The Chroma syntax highlighter was duplicating indentation for YAML folded
scalar continuation lines by inserting ANSI color codes within whitespace.
This resulted in visual duplication (e.g., 6 spaces + color codes + 6 more spaces).

Added post-processing that:
- Compares original and highlighted YAML line-by-line
- Counts leading spaces in both (handling ANSI codes in highlighted version)
- Strips duplicate spaces when highlighted has >2x original indentation
- Preserves all ANSI color codes for syntax highlighting

Extracted helper functions to maintain code quality:
- countLeadingSpaces() - counts spaces in plain strings
- countLeadingSpacesWithANSI() - counts spaces while skipping ANSI codes
- stripLeadingSpaces() - removes N spaces while preserving ANSI codes

Also fixed unrelated linting issues:
- Added static error ErrCommandNil for templater.go
- Removed unused processHelp function and help.go file
- Removed unused workflowMarkdown variable

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* chore: upgrade Chroma from v0.10.0 to v2.20.0

Upgraded to Chroma v2.20.0 which includes the fix for YAML multiline
whitespace issues (fixed in v2.15.0 via PR #993).

Changes:
- Updated all Chroma imports from v0 to v2
- Updated go.mod dependencies
- Removed old v0.10.0 dependency

The v2.15.0 release includes "Don't output extra whitespace in YAML
multiline" fix by @Gusted which should resolve the folded scalar
indentation duplication issue.

Kept the fixHighlightedIndentation() workaround as a safety net in case
the upstream fix doesn't cover all edge cases.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* cleanup: remove workaround for Chroma YAML indentation bug

Removed the fixHighlightedIndentation() workaround and helper functions
since the Chroma v2.20.0 upgrade fixed the YAML multiline indentation
issue.

The upstream fix in Chroma v2.15.0 (PR #993) properly handles YAML
folded scalars without adding duplicate whitespace, making our
post-processing workaround unnecessary.

Kept the stderr terminal detection enhancement as it's still needed
to ensure syntax highlighting works when provenance output goes to
stderr instead of stdout.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: send provenance output to stdout for piping

Changed provenance output from stderr to stdout to enable piping:
  atmos describe component vpc --stack dev --provenance | grep pattern

Changes:
- Provenance output now goes to stdout (fmt.Print)
- Simplified output logic: write to file if specified, else stdout
- Removed unused golang.org/x/term import
- Refactored to reduce complexity (extracted renderProvenance method)
- Added type assertion with static error for provenance rendering

This aligns with Unix philosophy and Atmos design: data goes to stdout,
UI messages go to stderr.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* Address CodeRabbit review comments for provenance feature

## what
- Fix comment punctuation in tree_renderer.go (add missing period)
- Add performance tracking to buildFileTree function
- Fix null value handling in merge provenance recording
- Add comprehensive error condition tests
- Enhance test assertions for provenance rendering

## why
- Ensures compliance with golangci-lint godot rules (all comments must end with periods)
- Adds performance tracking to critical functions per coding guidelines
- Fixes bug where nil values were not tracked in provenance (now treats nil as a scalar)
- Improves test coverage with error conditions: nil atmosConfig, malformed entries, null values, nested structures, and different provenance types
- Makes test assertions more specific and thorough, verifying exact comment formats and legend text

## references
- Addresses 6 unresolved CodeRabbit review comments on PR #1584
- Follows project guidelines in CLAUDE.md for comments, perf tracking, and test quality

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* Fix data race in ProcessYAMLConfigFiles goroutines

## what
- Add mutex protection for errorResult variable accessed by multiple goroutines

## why
- CodeRabbit identified potential data race where multiple goroutines write to errorResult without synchronization
- Lines 173, 205, and 222 all write to errorResult from different goroutines
- Without synchronization, this could lead to race conditions and undefined behavior

## how
- Add errorLock sync.Mutex to protect errorResult writes
- Wrap all errorResult assignments with errorLock.Lock()/Unlock()
- Maintains existing processYAMLConfigFilesLock for map/slice access

## references
- Addresses CodeRabbit review comment on PR #1584

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* Fix godot linter issue in merge_with_provenance.go parameter comments

## what
- Add periods to parameter comment lines that were ending with colons

## why
- golangci-lint godot rule requires all comments to end with periods
- Parameter descriptions like "atmosConfig: ..." should end with "flag." not "flag"

## references
- Addresses linting issue identified in PR #1584 review

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* updates

* updates

* updates

* updates

* updates

* updates

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: aknysh <[email protected]>
Erik Osterman (Cloud Posse) (osterman) added a commit that referenced this pull request Oct 7, 2025
* feat: add --show-provenance flag to describe component and describe stacks

Add provenance tracking display that shows the source file and line number
for each configuration value in component and stack descriptions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* docs: revert broken provenance implementation, add comprehensive PRD

- Reverted incomplete provenance implementation from pkg/ui/provenance/
- Removed --show-provenance flags from describe component and describe stacks commands
- Created comprehensive PRD for proper line-level provenance system at docs/prd/line-level-provenance.md

The initial provenance implementation had fundamental limitations:
- Only tracked top-level section keys (vars.*, settings.*), not nested values
- Two-column rendering was broken and couldn't align with complex YAML structures
- No line number tracking, only file paths
- Not reusable across different Atmos config types (stacks, atmos.yaml, vendor, workflows)
- Output polluted with 750+ lines of raw sources data
- Tests didn't catch critical bugs

- PRD: docs/prd/line-level-provenance.md
- Extends existing MergeContext system (pkg/merge/merge_context.go)
- Uses gopkg.in/yaml.v3 Node API for line tracking
- Estimated 3-4 weeks for proper implementation
- Backward compatible deprecation of current sources system

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* docs: rename PRD from line-level-provenance to import-provenance

Renamed PRD to better reflect that we're tracking import/inheritance chains
rather than just line-level granularity. 'Import provenance' more accurately
describes tracking where values come from through the import system.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* feat: complete provenance tracking implementation for nested imports

- Implement MergeWithProvenance function to track provenance during YAML merging
- Add provenance storage and entry management with thread-safe operations
- Create tree renderer for inline provenance visualization with depth indicators
- Add YAML position extraction utilities for accurate line/column tracking
- Fix nested import provenance tracking in stack processor
- Record provenance metadata using merge context's current file
- Handle []any type for imports array in describe component output
- Add comprehensive test suite for provenance tracking functionality
- Support JSONPath addressing for nested configuration values
- Add benchmarks for provenance operations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* feat: improve provenance display with line wrapping and updated legend

- Update provenance legend: change "Defined at this level" to "Defined in parent stack"
- Add LongString type that encodes as YAML folded scalars (>-) for long strings
- Add WrapLongStrings function to automatically wrap long strings in YAML output
- Integrate line wrapping in provenance renderer to prevent horizontal scrolling
- Long values like atmos_component_description now wrap properly with provenance comments aligned

This improves readability of provenance output by ensuring long string values are wrapped
using proper YAML folded scalar syntax, keeping provenance comments aligned at the comment
column and preventing the need for horizontal scrolling.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* fix: address CodeRabbit review feedback for provenance tracking

- Fix file output with --provenance flag by writing raw YAML to file
- Add perf.Track instrumentation to merge context helper functions
- Replace manual depth calculations with GetImportDepth() method
- Fix goroutine data race by using per-goroutine MergeContext
- Fix linting issues (godot comment capitalization, gosec file permissions)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* feat: add ProvenanceTracker interface and describe stacks provenance

- Create generic ProvenanceTracker interface for extensibility
- Add --provenance flag to describe stacks command
- Update MergeContext to document ProvenanceTracker implementation
- Add comprehensive unit tests for interface with mock implementation
- Update PRD to reflect actual implementation status and design decisions
- Document display format rationale (valid YAML output)
- Document symbol and color scheme with Unicode codes
- Document backward compatibility with sources system

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* fix: resolve yaml package type conflicts and address code review

- Add explicit yaml alias to gopkg.in/yaml.v3 imports to prevent type conflicts with go.yaml.in/yaml/v3 used by yqlib dependency
- Add missing perf.Track instrumentation to public functions in describe_component.go per coding guidelines
- Stabilize provenance value hashing by using json.Marshal for deterministic serialization instead of fmt.Sprintf

Fixes the CI build failure caused by YAML package type mismatch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* refactor: reduce cognitive complexity in provenance code

* fix: resolve all golangci-lint errors and warnings

- Extract constants for magic numbers and string literals
- Refactor all functions with >5 params to use config structs
- Fix getSymbolColor() to return different colors per symbol
- Split tree_renderer.go into multiple files (under 500 lines)
- Pass heavy params by pointer to avoid memory copying
- Extract helper functions to reduce cyclomatic complexity
- Fix all comment formatting (godot linter)
- Fix nilerr issues
- Fix nestif complexity in test by inverting conditions

All golangci-lint issues resolved for PR #1584

* fix: resolve provenance tracking bug and linting issues

- Fixed bug where __import__: and __import_meta__: provenance entries weren't being recorded for direct imports
- Resolved race condition in parallel stack processing that caused wrong merge contexts to be stored
- Added per-stack merge context storage to replace single global variable
- Fixed comment formatting to end with periods (godot linter)
- Resolved code duplication in describe_affected_test.go
- Added "imports" to allowed fields in test

- Provenance tracking is critical for showing users where configuration values come from
- The bug prevented proper tracking of imports defined directly in stack files
- Race conditions in parallel processing caused provenance to be attributed to wrong stack files
- Pre-commit hooks enforce code quality standards

1. Added merge context initialization in ProcessYAMLConfigFileWithContext when nil
2. Created mergeContexts map to store contexts per stack file instead of single global
3. Added SetMergeContextForStack() and GetMergeContextForStack() functions
4. Updated ProcessYAMLConfigFiles to store each stack's context separately
5. Modified ExecuteDescribeComponentWithContext to retrieve stack-specific context
6. Maintained backward compatibility by keeping deprecated functions
7. Fixed all godot linter warnings in cmd files

- TestDescribeComponent_DirectImportProvenance passes
- TestDescribeComponent_NestedImportProvenance passes
- TestDescribeComponentWithProvenance passes
- All describe component tests pass
- All linting checks pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: address CodeRabbit review comments

- **pkg/provenance/data_transform.go**: Fix nil context handling to preserve sections when provenance tracking is disabled
  - Initialize `hasProvenance := ctx == nil` to keep all keys when no provenance tracking
  - Prevents data loss when provenance is disabled

- **internal/exec/describe_component.go**: Fix TTY detection
  - Check `os.Stderr.Fd()` instead of `os.Stdout.Fd()` (correct stream)
  - Require both empty file and TTY to prevent spam to pipes/redirects

- **internal/exec/describe_component.go**: Add safe type assertion for imports
  - Use safe `if impStr, ok := imp.(string)` instead of panic-prone `imp.(string)`
  - Skip non-string values gracefully

- **pkg/provenance/text_utils.go**: Fix rune-safe text wrapping
  - Convert to `[]rune` before slicing to preserve multi-byte UTF-8 characters
  - Prevents corruption of ANSI sequences and Unicode text

- **pkg/provenance/tree_renderer.go**: Handle highlight failures gracefully
  - Fall back to plain YAML on highlight error instead of propagating error
  - Ensures users always see YAML output

- **docs/prd/import-provenance.md**: Add language identifiers to fenced code blocks
  - Change ` ``` ` to ` ```text ` for legend and architecture diagram
  - Fixes markdownlint warnings

All fixes verified with:
- Build: ✅ Passes
- Linting: ✅ 0 issues
- Tests: ✅ All pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* refactor: remove incomplete RenderInline() and consolidate to production implementation

- **Removed `RenderInline()` function** - Incomplete placeholder that only returned plain YAML
- **Updated tests** to use `RenderInlineProvenanceWithStackFile()` production implementation
- **Renamed files** for clarity:
  - `inline.go` → `provenance_helpers.go` (now only contains helper utilities)
  - `inline_test.go` → `provenance_helpers_test.go`
- **Kept `FormatProvenanceComment()`** - Useful helper for formatting provenance entries

CodeRabbit correctly identified that `RenderInline()` was incomplete (just returned YAML without provenance comments).

The PR already has a complete implementation in `RenderInlineProvenanceWithStackFile()` that:
- Adds provenance legend
- Parses YAML structure and builds path mapping
- Looks up provenance for each key
- Adds inline comments with file:line:column
- Used in production code (describe_component.go:135)

`RenderInline()` was only used in 2 unit tests and created confusion. Consolidating to a single implementation eliminates duplication and makes the codebase clearer.

- ✅ Build passes
- ✅ All tests pass (updated to use production function)
- ✅ Linting passes (0 issues)
- ✅ Single source of truth for inline provenance rendering

Addresses CodeRabbit review: #1584 (comment)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* perf: add performance tracking to FormatProvenanceComment

- Added `perf` import to `pkg/provenance/provenance_helpers.go`
- Added `defer perf.Track(nil, "provenance.FormatProvenanceComment")()` to track performance

All exported functions should have performance tracking for observability and profiling. This was missing from `FormatProvenanceComment()`.

- ✅ Build passes
- ✅ Tests pass
- ✅ Linting passes (0 issues)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: remove unnecessary perf tracking from unused test helper

- Removed `perf.Track()` call from `FormatProvenanceComment()`
- Removed unused `perf` import

`FormatProvenanceComment()` is only used in test code, not in production. Adding performance tracking to a test-only helper function provides no value and was causing CI failures on macOS and Windows platforms.

- Commit `2374f64de` added perf tracking and caused CI failures
- Linux: ✅ PASS
- macOS: ❌ FAIL
- Windows: ❌ FAIL

The function is unused in production code - only called in its own test. Performance tracking on an unused helper is unnecessary and introduced platform-specific failures.

- ✅ Build passes
- ✅ Tests pass locally
- ✅ Linting passes (0 issues)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* refactor: move formatProvenanceComment to test file

- Moved `FormatProvenanceComment()` from `provenance_helpers.go` (production code) to `provenance_helpers_test.go` (test code)
- Made function unexported (`formatProvenanceComment`) since it's test-only
- Deleted `provenance_helpers.go` as it's now empty

The function was only used in tests, not in production code. Having an exported function in production files that's only used in tests is misleading and was the reason CodeRabbit flagged it as an incomplete implementation.

**Original Context:**
- `FormatProvenanceComment()` was originally part of the incomplete `RenderInline()` implementation
- When we removed `RenderInline()` (commit 99f4bb9), we kept this helper thinking it might be useful
- But it's never actually used in production - only in its own test

**Proper Organization:**
- Test-only helpers belong in `_test.go` files
- Should be unexported (lowercase) to indicate internal test usage
- Keeps production code clean and focused

- ✅ Build passes
- ✅ All tests pass
- ✅ Linting passes (0 issues)
- ✅ No production code affected

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: ensure deterministic provenance tracking by sorting map keys

Provenance tracking was non-deterministic due to Go's random map iteration order.
This caused test failures on macOS CI where `TestDescribeComponentWithProvenance`
expected to find specific paths like `vars.enabled` or `vars.name`, but map iteration
could skip them depending on iteration order.

Changes:
- Sort map keys before iterating in `recordMapProvenance()`
- Ensures consistent provenance path recording across all platforms
- Fixes flaky test failures on macOS CI

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: address CodeRabbit review comments on provenance tracking

CodeRabbit identified three issues with provenance implementation and tests:

1. **ValueHash not populated**: ProvenanceEntry.ValueHash field was empty
   - Added `value` parameter to provenanceEntryParams
   - Updated recordProvenanceEntry to compute and set ValueHash using hashValue()
   - Pass actual values through all recordProvenanceEntry calls
   - Changed params to pointer to satisfy gocritic hugeParam linter

2. **Missing negative assertions**: Test didn't verify provenance absence
   - Added assertions to ensure no provenance comments when ctx is nil
   - Test now checks for absence of "# from:" and "# Provenance Legend:"

3. **Weak provenance format assertions**: Test only checked for presence
   - Added exact format checks for provenance comments ("# ● [0] config.yaml:10")
   - Added legend symbol verification (●, ○, ∴)
   - Fixed bug where legend was always shown even when ctx is nil

These changes ensure provenance entries have complete metadata for change
detection and that tests properly verify both positive and negative cases.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: improve provenance display with parent stack header and depth 1 symbol

Changes the provenance rendering to be more intuitive:

1. **Added parent stack header**: Shows which stack file is being described
   - Displays "# Stack: {filename}" before the YAML output
   - Helps users understand the context

2. **Fixed symbol logic**: Changed from depth 0 to depth 1 for parent stack
   - ● [1] now shows values defined in the parent stack
   - ○ [2+] shows values inherited from imports
   - Depth 0 never occurred in practice (parent stack is always depth 1)

3. **Updated legend text**: Reflects new depth numbering
   - "● [1] Defined in parent stack"
   - "○ [N] Inherited/imported (N=2+ levels deep)"

4. **Adjusted color coding**: Makes depths 1-2 green
   - Depth 1-2: green (parent + first import)
   - Depth 3: yellow (getting far)
   - Depth 4+: red (very far)

5. **Updated all tests**: Changed test expectations from depth 0 to depth 1

6. **Refactored legend rendering**: Extracted into helper function to reduce cyclomatic complexity

This makes provenance output more intuitive and useful for understanding
where configuration values come from.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* test: add comprehensive provenance output validation tests

Add tests to validate complete provenance rendering output:
- TestProvenanceOutputFormat: validates legend, stack header, symbols, and depth formatting for all depth levels
- TestProvenanceComputedType: validates computed values show ∴ symbol regardless of depth

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: respect indent configuration when rendering YAML with provenance

When rendering YAML with provenance comments, now respects the indent
configuration from atmosConfig.Settings.Terminal.TabWidth instead of
always using the default indent of 2. This ensures folded YAML scalars
(like atmos_component_description with >-) are indented correctly
according to the user's configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* test: add tests to validate YAML indent configuration for folded scalars

Add comprehensive tests to verify that YAML folded scalar indentation
respects the tab_width configuration:
- TestYAMLIndentRespected: Validates indent=2 (default) produces 6 spaces
- TestYAMLIndentWithIndent4: Validates indent=4 produces 12 spaces

These tests ensure that the fix in tree_renderer.go correctly respects
the TabWidth configuration when rendering YAML with provenance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: disable syntax highlighting for provenance to fix folded scalar indentation

The Chroma syntax highlighter was adding extra indentation (6 spaces) to
YAML folded scalar continuation lines, causing them to display with 12
spaces instead of the correct 6 spaces.

Root cause: When highlighting YAML with folded scalars (>-), the Chroma
lexer/formatter adds duplicate indentation to continuation lines:
- Original: "      Vpc-Flow-Logs-Bucket..."  (6 spaces)
- After highlighting: "      \x1b[0m      Vpc-Flow..." (6 + 6 = 12 spaces)

Solution: Disable syntax highlighting for provenance output. The YAML
structure is already clear with provenance comments, and this avoids
the indentation duplication issue.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: preserve syntax highlighting while fixing folded scalar indentation

The Chroma syntax highlighter was duplicating indentation for YAML folded
scalar continuation lines by inserting ANSI color codes within whitespace.
This resulted in visual duplication (e.g., 6 spaces + color codes + 6 more spaces).

Added post-processing that:
- Compares original and highlighted YAML line-by-line
- Counts leading spaces in both (handling ANSI codes in highlighted version)
- Strips duplicate spaces when highlighted has >2x original indentation
- Preserves all ANSI color codes for syntax highlighting

Extracted helper functions to maintain code quality:
- countLeadingSpaces() - counts spaces in plain strings
- countLeadingSpacesWithANSI() - counts spaces while skipping ANSI codes
- stripLeadingSpaces() - removes N spaces while preserving ANSI codes

Also fixed unrelated linting issues:
- Added static error ErrCommandNil for templater.go
- Removed unused processHelp function and help.go file
- Removed unused workflowMarkdown variable

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* chore: upgrade Chroma from v0.10.0 to v2.20.0

Upgraded to Chroma v2.20.0 which includes the fix for YAML multiline
whitespace issues (fixed in v2.15.0 via PR #993).

Changes:
- Updated all Chroma imports from v0 to v2
- Updated go.mod dependencies
- Removed old v0.10.0 dependency

The v2.15.0 release includes "Don't output extra whitespace in YAML
multiline" fix by @Gusted which should resolve the folded scalar
indentation duplication issue.

Kept the fixHighlightedIndentation() workaround as a safety net in case
the upstream fix doesn't cover all edge cases.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* cleanup: remove workaround for Chroma YAML indentation bug

Removed the fixHighlightedIndentation() workaround and helper functions
since the Chroma v2.20.0 upgrade fixed the YAML multiline indentation
issue.

The upstream fix in Chroma v2.15.0 (PR #993) properly handles YAML
folded scalars without adding duplicate whitespace, making our
post-processing workaround unnecessary.

Kept the stderr terminal detection enhancement as it's still needed
to ensure syntax highlighting works when provenance output goes to
stderr instead of stdout.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: send provenance output to stdout for piping

Changed provenance output from stderr to stdout to enable piping:
  atmos describe component vpc --stack dev --provenance | grep pattern

Changes:
- Provenance output now goes to stdout (fmt.Print)
- Simplified output logic: write to file if specified, else stdout
- Removed unused golang.org/x/term import
- Refactored to reduce complexity (extracted renderProvenance method)
- Added type assertion with static error for provenance rendering

This aligns with Unix philosophy and Atmos design: data goes to stdout,
UI messages go to stderr.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* Address CodeRabbit review comments for provenance feature

- Fix comment punctuation in tree_renderer.go (add missing period)
- Add performance tracking to buildFileTree function
- Fix null value handling in merge provenance recording
- Add comprehensive error condition tests
- Enhance test assertions for provenance rendering

- Ensures compliance with golangci-lint godot rules (all comments must end with periods)
- Adds performance tracking to critical functions per coding guidelines
- Fixes bug where nil values were not tracked in provenance (now treats nil as a scalar)
- Improves test coverage with error conditions: nil atmosConfig, malformed entries, null values, nested structures, and different provenance types
- Makes test assertions more specific and thorough, verifying exact comment formats and legend text

- Addresses 6 unresolved CodeRabbit review comments on PR #1584
- Follows project guidelines in CLAUDE.md for comments, perf tracking, and test quality

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* Fix data race in ProcessYAMLConfigFiles goroutines

- Add mutex protection for errorResult variable accessed by multiple goroutines

- CodeRabbit identified potential data race where multiple goroutines write to errorResult without synchronization
- Lines 173, 205, and 222 all write to errorResult from different goroutines
- Without synchronization, this could lead to race conditions and undefined behavior

- Add errorLock sync.Mutex to protect errorResult writes
- Wrap all errorResult assignments with errorLock.Lock()/Unlock()
- Maintains existing processYAMLConfigFilesLock for map/slice access

- Addresses CodeRabbit review comment on PR #1584

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* Fix godot linter issue in merge_with_provenance.go parameter comments

- Add periods to parameter comment lines that were ending with colons

- golangci-lint godot rule requires all comments to end with periods
- Parameter descriptions like "atmosConfig: ..." should end with "flag." not "flag"

- Addresses linting issue identified in PR #1584 review

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* updates

* updates

* updates

* updates

* updates

* updates

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: aknysh <[email protected]>
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants