Skip to content

feat(acceptance): treat a release-referenced values file as read-only context#245

Merged
sunib merged 2 commits into
mainfrom
feat/values-file-referenced-context
Jul 16, 2026
Merged

feat(acceptance): treat a release-referenced values file as read-only context#245
sunib merged 2 commits into
mainfrom
feat/values-file-referenced-context

Conversation

@sunib

@sunib sunib commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What

A Helm values.yaml named by a release — an Argo CD Application's helm.valueFiles or a Flux HelmRelease's spec.chart.spec.valuesFiles — has no apiVersion/kind, so the acceptance gate refused it as non-krm-yaml. Because acceptance is all-or-nothing, that one file took the whole folder down with it: the co-located release and a perfectly valid ClusterIssuer.

This reads the path-valued field from the release document the store already parses and treats the file it names as read-only context — understood, never written, and never a refusal for its folder. It implements Move 1 of values-file-projection.md §2 (and acceptance-precision.md §1c). Move 2 (projecting the file as an editable object) remains design.

How

  • New valuefiles.go: helmValueFileRefs decodes both release kinds through one releaseDoc type (dispatched by group+kind) and resolves the named path through one ordered candidate set — Argo's repo-root $values/… form, a whole-repo scan, and co-located subtree resolution — to a non-KRM file only.
  • The set is carried on ManifestStore.ValueFileRefs; acceptance.go suppresses the non-krm-yaml refusal for it and scan_repo.go stops counting it as non-KRM noise.
  • The file never enters FilesByPath, so it can never be written or swept. Mirrors the existing kustomize-patch "read-only build context" retention.

platform/cert-manager flips refused → accepted (2/2/1 → 2/2/0) in support-today.md, rescuing its ClusterIssuer.

Testing

Both the Argo and Flux spellings are covered at every layer:

  • Unit — reference resolution (co-located, repo-root whole-repo + subtree, KRM-target-is-not-context) and the acceptance gate.
  • Goldenscan-repo fixtures supported/argocd-external-helm-values and supported/flux-helmrelease-values.
  • Contractpkg/manifestanalyzer folder scan.
  • e2e — two isolated specs proving the live operator adopts the folder (mirrors a live ConfigMap into it — a refused folder writes nothing) and leaves the values file + co-located manifests byte-for-byte untouched.

Validation: task lint, task test (coverage held at 76.5%), and task test-e2e (58/58 passed) all green.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Referenced Helm values.yaml files are now treated as read-only context for Argo CD Applications and Flux HelmReleases.
    • Folders containing those referenced values files are now adopted and mirrored without refusing or deleting the values files.
    • Unreferenced non-Kubernetes YAML still gets refused.
  • Bug Fixes
    • The acceptance gate no longer reports non-KRM issues for referenced values-file paths.
  • Documentation
    • Updated support-boundary design records to reflect the shipped behavior.
  • Tests
    • Added acceptance and scan coverage plus end-to-end fixtures for Argo/Flux values-file scenarios.

… context

An Argo CD Application's helm.valueFiles or a Flux HelmRelease's
spec.chart.spec.valuesFiles names a values.yaml by path. That file has no
apiVersion/kind, so the acceptance gate refused it as non-krm-yaml and, because
acceptance is all-or-nothing, took the whole folder down with it — including the
co-located release and a valid ClusterIssuer.

Read the path-valued field from the release document the store already parses and
treat the file it names as read-only context: understood, never written, never a
refusal for its folder. helmValueFileRefs resolves the reference (Argo $values/…
repo-root form, whole-repo, and co-located subtree) to a non-KRM file, carried on
ManifestStore.ValueFileRefs; acceptance.go suppresses the non-krm-yaml refusal and
scan_repo.go stops counting it as noise. The file never enters FilesByPath, so it
can never be written or swept.

Implements docs/design/support-boundary/values-file-projection.md §2 Move 1 (and
acceptance-precision.md §1c). platform/cert-manager flips refused→accepted in
support-today.md. Move 2 (editable projection) remains design.

Covered by unit, acceptance-gate, scan-repo golden, pkg-contract, and live e2e
tests for both the Argo and Flux spellings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b29052f3-341d-4aaf-8486-d7783bfd5b40

📥 Commits

Reviewing files that changed from the base of the PR and between 8d3b0fd and f33965c.

📒 Files selected for processing (8)
  • docs/design/support-boundary/README.md
  • docs/design/support-boundary/values-content-architecture.md
  • docs/design/support-boundary/values-file-projection.md
  • internal/manifestanalyzer/acceptance.go
  • internal/manifestanalyzer/acceptance_test.go
  • internal/manifestanalyzer/store.go
  • internal/manifestanalyzer/valuefiles.go
  • internal/manifestanalyzer/valuefiles_test.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • internal/manifestanalyzer/acceptance.go
  • internal/manifestanalyzer/store.go
  • internal/manifestanalyzer/valuefiles.go
  • internal/manifestanalyzer/acceptance_test.go
  • internal/manifestanalyzer/valuefiles_test.go

📝 Walkthrough

Walkthrough

Referenced Helm values files are detected for Argo CD Applications and Flux HelmReleases, tracked as read-only context, excluded from non-KRM refusals and counts, and covered by analyzer, folder, end-to-end, fixture, and documentation updates.

Changes

Referenced values-file acceptance

Layer / File(s) Summary
Values-file detection and resolution
internal/manifestanalyzer/valuefiles.go, internal/manifestanalyzer/valuefiles_test.go
Extracts Argo CD and Flux values-file references, resolves scanned paths, excludes remote, missing, and KRM targets, and records non-KRM references.
Acceptance and scan integration
internal/manifestanalyzer/store.go, internal/manifestanalyzer/acceptance.go, internal/manifestanalyzer/scan_repo.go, internal/manifestanalyzer/*_test.go, pkg/manifestanalyzer/folder_test.go
Stores referenced paths and prevents referenced values files from producing IssueNonKRM refusals or non-KRM counts while unreferenced files remain refused.
Repository, folder, and end-to-end validation
internal/manifestanalyzer/testdata/scan-repo/supported/*, test/e2e/fixtures/values-file-folder*, test/e2e/values_file_acceptance_e2e_test.go, test/fixtures/gitops-layouts/support-today.md
Adds Argo and Flux fixtures and verifies adoption, resource counts, mirroring, preservation of seeded files, and updated scan results.
Design and support records
docs/design/support-boundary/*.md
Marks read-only referenced-values context as shipped and defines the planned source-aware editing architecture and boundaries.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ScannedFiles
  participant ManifestAnalyzer
  participant AcceptanceGate
  participant GitTarget
  ScannedFiles->>ManifestAnalyzer: parse Argo Application or Flux HelmRelease
  ManifestAnalyzer->>ManifestAnalyzer: resolve existing non-KRM values.yaml
  ManifestAnalyzer->>AcceptanceGate: provide referenced values-file context
  AcceptanceGate-->>GitTarget: accept folder without IssueNonKRM
  GitTarget->>ScannedFiles: preserve referenced values.yaml during mirroring
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: treating referenced release values files as read-only acceptance context.
Description check ✅ Passed The description clearly explains the change, rationale, implementation, and testing, though it omits some optional template sections like type and checklist.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/values-file-referenced-context

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
internal/manifestanalyzer/store.go (1)

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Update comments to reflect Flux HelmRelease support.

The documentation for ValueFileRefs and its associated methods only mentions Argo CD Applications and helm.valueFiles, but the implementation (and PR objective) also supports Flux HelmReleases via spec.chart.spec.valuesFiles. Update these comments to accurately reflect the supported releases, preventing future confusion about the scope of this context.

  • internal/manifestanalyzer/store.go#L96-103: Update the field documentation to mention both Argo CD and Flux HelmReleases.
  • internal/manifestanalyzer/store.go#L415-418: Update the inline comment to mention both Argo CD and Flux.
  • internal/manifestanalyzer/store.go#L511-522: Update the method godoc to mention both Argo CD and Flux.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/manifestanalyzer/store.go` at line 1, Update the documentation for
ValueFileRefs and its associated methods in store.go to describe support for
both Argo CD Applications using helm.valueFiles and Flux HelmReleases using
spec.chart.spec.valuesFiles. Revise the field comment, the inline comment near
the related processing, and the method godoc without changing implementation
behavior.
internal/manifestanalyzer/scan_repo_test.go (1)

237-255: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider asserting resource counts for consistency.

TestScanRepo_ReferencedValuesFileAccepted asserts that the Rendered and Editable resources are correctly counted. Consider adding a similar assertion here to ensure that the HelmRelease is tracked correctly (rendered=1, editable=1), matching the expectations in flux-helmrelease-values.golden.json. As per coding guidelines, follow the existing codebase’s testing patterns when adding new Go code.

♻️ Proposed refactor
 	if got.Resources.NonKRM != 0 {
 		t.Errorf("the referenced values file is context, not noise: nonKrm = %d, want 0", got.Resources.NonKRM)
 	}
+	if got.Resources.Rendered != 1 || got.Resources.Editable != 1 {
+		t.Errorf("HelmRelease should be managed: rendered=%d editable=%d, want 1/1",
+			got.Resources.Rendered, got.Resources.Editable)
+	}
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/manifestanalyzer/scan_repo_test.go` around lines 237 - 255, Extend
TestScanRepo_FluxHelmReleaseValuesFileAccepted with assertions for
got.Resources.Rendered == 1 and got.Resources.Editable == 1, matching the
existing resource-count checks in TestScanRepo_ReferencedValuesFileAccepted and
the fixture golden expectations.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/design/support-boundary/acceptance-precision.md`:
- Around line 90-94: Update the acceptance statement in the referenced
values-file section to describe any existing referenced non-KRM values file,
rather than limiting the contract to files named values.yaml. Preserve the
documented Argo CD Application and Flux HelmRelease field references and
acceptance behavior.

In `@internal/manifestanalyzer/valuefiles.go`:
- Around line 130-141: Update decodeReleases to decode each YAML document into a
yaml.Node first, then decode that node into releaseDoc so *yaml.TypeError only
skips the current document and processing continues. Preserve the existing
termination behavior for true decoder or syntax errors, ensuring the loop cannot
retry the same invalid input indefinitely.

---

Nitpick comments:
In `@internal/manifestanalyzer/scan_repo_test.go`:
- Around line 237-255: Extend TestScanRepo_FluxHelmReleaseValuesFileAccepted
with assertions for got.Resources.Rendered == 1 and got.Resources.Editable == 1,
matching the existing resource-count checks in
TestScanRepo_ReferencedValuesFileAccepted and the fixture golden expectations.

In `@internal/manifestanalyzer/store.go`:
- Line 1: Update the documentation for ValueFileRefs and its associated methods
in store.go to describe support for both Argo CD Applications using
helm.valueFiles and Flux HelmReleases using spec.chart.spec.valuesFiles. Revise
the field comment, the inline comment near the related processing, and the
method godoc without changing implementation behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bda5127e-93a6-4b87-887a-3d1309609278

📥 Commits

Reviewing files that changed from the base of the PR and between 38590d1 and 8d3b0fd.

📒 Files selected for processing (24)
  • docs/design/support-boundary/acceptance-precision.md
  • docs/design/support-boundary/values-file-projection.md
  • internal/manifestanalyzer/acceptance.go
  • internal/manifestanalyzer/acceptance_test.go
  • internal/manifestanalyzer/scan_repo.go
  • internal/manifestanalyzer/scan_repo_test.go
  • internal/manifestanalyzer/store.go
  • internal/manifestanalyzer/testdata/scan-repo/supported/argocd-external-helm-values.golden.json
  • internal/manifestanalyzer/testdata/scan-repo/supported/argocd-external-helm-values/app/application.yaml
  • internal/manifestanalyzer/testdata/scan-repo/supported/argocd-external-helm-values/app/clusterissuer.yaml
  • internal/manifestanalyzer/testdata/scan-repo/supported/argocd-external-helm-values/app/values.yaml
  • internal/manifestanalyzer/testdata/scan-repo/supported/flux-helmrelease-values.golden.json
  • internal/manifestanalyzer/testdata/scan-repo/supported/flux-helmrelease-values/app/helmrelease.yaml
  • internal/manifestanalyzer/testdata/scan-repo/supported/flux-helmrelease-values/app/values.yaml
  • internal/manifestanalyzer/valuefiles.go
  • internal/manifestanalyzer/valuefiles_test.go
  • pkg/manifestanalyzer/folder_test.go
  • test/e2e/fixtures/values-file-folder-flux/helmrelease.yaml
  • test/e2e/fixtures/values-file-folder-flux/values.yaml
  • test/e2e/fixtures/values-file-folder/application.yaml
  • test/e2e/fixtures/values-file-folder/clusterissuer.yaml
  • test/e2e/fixtures/values-file-folder/values.yaml
  • test/e2e/values_file_acceptance_e2e_test.go
  • test/fixtures/gitops-layouts/support-today.md

Comment thread docs/design/support-boundary/acceptance-precision.md
Comment thread internal/manifestanalyzer/valuefiles.go
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.05882% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/manifestanalyzer/valuefiles.go 88.0% 5 Missing and 4 partials ⚠️
internal/manifestanalyzer/store.go 66.6% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

…lti-doc decode

Move 1 (a release-referenced values file is read-only context) is an
acceptance-only classification, not a source-resolution or editing feature.
Make the code say what it actually proves, and fix one robustness edge — per the
merge requirements recorded in values-content-architecture.md.

- Comments/tests now say "named read-only context" (a scan-local path match),
  never "the file the release consumes". Drop the overclaim that a $values ref
  or a Flux sourceRef proves the source is this repo; both spellings are matched
  by name without source-identity proof. Record the intentional policy: an Argo
  bare path on an external chart, or a Flux HelmRepository source, resolves
  inside the fetched chart, so a co-located file is a benign named passenger and
  is never presented as an editable deployment input.
- decodeReleases: split documents as generic yaml.Node values, then convert each
  independently, so an incompatible earlier document (e.g. an unrelated kind with
  a type-mismatched spec) can no longer abort the stream and hide a later
  Application/HelmRelease. Adds a regression test.
- Design docs: values-content-architecture.md (new) records the Git-authoring
  boundary, the Argo/Flux resolution table, and the staged delivery sequence;
  values-file-projection.md and README.md updated to the corrected framing.

No change to acceptance classification; unit coverage held at 76.5%.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sunib
sunib merged commit d25c013 into main Jul 16, 2026
18 checks passed
@sunib
sunib deleted the feat/values-file-referenced-context branch July 16, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant