Repository navigation
feat(helm): template-action-aware pinnability classifier (#1234) - #1887
Merged
Merged
Conversation
…d conditional deps A top-level-only CRD fixture passes even when subchart CRD routing is broken (epic #1228 finding 10). This chart carries crds/ in the parent AND in a subchart, includes the same subchart twice (plain + alias, so the render emits duplicate CRD documents — finding 11), and a conditional dependency disabled by default (finding 12). A comment in the parent template deliberately mentions lookup as prose so a text-matching classifier trips over it (finding 9).
loki 6.21.0 fails with default values (nil pointer on loki.storage.bucketNames.chunks). A chart silently excluded from the corpus reads as coverage it does not have, so charts that need values ship them beside the corpus manifest and a chart that cannot render is a harness failure, not an omission.
Phase 0 of epic #1228. A committed corpus of 13 real charts, pinned by exact version in charts.txt, pulled at run time with an isolated helm repo config and never vendored. Per chart the harness scans template actions, renders twice with closed inputs (pinned kube version, values file when the chart needs one), and classifies: deterministic-as-is, pinnable-with-closed-inputs, or unpinnable — recording why. Verdicts are asserted against expected.txt, not printed: any drift in verdict, CRD routing, lookup counts, or render stability fails the suite. The two prototype classifier bugs are fixed and regression- pinned: lookup detection parses template actions rather than text (finding 9 — cert-manager's 52 comment-prose hits classify as 0), and CRD routing matches a crds/ path segment rather than prefix (finding 10 — subchart CRDs arrive as charts/<child>/crds/). The upstream survey is network-gated on CHANT_HELM_SURVEY (run it with 'just helm-survey'; CI runs it path-scoped plus weekly via helm-survey.yml). The fixture surveys — the umbrella chart plus a control-flow-lookup and an open-generated-input fixture — need only a helm binary and run offline in the normal suite. The subchart-aware scan also surfaces a finding the prototype's top-level-only grep missed: kube-prometheus-stack bundles grafana, so its control-flow lookup (templates/pvc.yaml:28) refuses the umbrella too under a purely static gate.
Promote the survey harness's prototype classifier into the lexicon proper as src/pinnability — the production gate the pinned-render pipeline (#1235-#1240) calls before anything is pinned. What the promotion adds over the prototype: - Template actions are parsed with control-flow structure (if/else-if/else, with, range, define), not just extracted — so the classifier knows which gates enclose each construct. Lookup detection stays action-based (finding 9: cert-manager's 52 textual hits classify as 0) and matches only the function call, never a value named lookup* (grafana's persistence.lookupVolumeName). - Subchart-recursive with per-instance effective values: Chart.yaml dependencies are walked with helm-style coalescing (child defaults < parent subtree < supplied values, globals propagated), aliased dependencies get their own value scope over the shared directory, and condition:-disabled dependencies gate everything inside them. - Values-aware reachability, the epic's core insight applied: a control-flow lookup whose enclosing gates (or short-circuited same-action conjuncts) definitively evaluate false under the supplied values is a recorded conditional hazard (chart, path, gating value) instead of a refusal — flipping the value re-classifies the (chart, values) pair. A reachable or unprovable one refuses with the file and line. Unknown always degrades toward refusal, never toward pinning. - Open generated inputs (randAlphaNum, genCA, and friends) are detected statically and named, with the suppliable .Values path when the action carries one; the double-render localizer (#1236) confirms them dynamically. - .Capabilities.* references are listed per occurrence as a requires-profile input — the normal case (11 of 13 corpus charts), not an error. The verdict is a typed report: { verdict: deterministic | pinnable | unpinnable, requiresProfile, closedInputs, hazards, reasons } with raw lookup findings and scan warnings alongside. The survey harness now consumes the promoted classifier; the prototype (test/survey/classify.ts) is deleted. Two corpus verdicts legitimately change, both by the reachability the promotion adds: - kube-prometheus-stack: unpinnable -> pinnable-with-closed-inputs. The bundled grafana's control-flow lookup sits behind grafana.persistence.enabled, which the chart's defaults leave false; the hazard records the gate. - grafana: unpinnable -> pinnable-with-closed-inputs. Same construct, standalone: persistence.enabled defaults to false, so a default-values render never consults the cluster. Every other row keeps its verdict and counts; expected.txt rows gain a hazards= column so gating drift fails the suite. A new gated-lookup-fixture commits the kube-prometheus-stack shape offline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1 of epic #1228: promote the survey harness's prototype classifier into the lexicon proper as
lexicons/helm/src/pinnability/— the production gate the pinned-render pipeline (#1235–#1240) calls before anything is pinned. Exported from the package entry and as the./pinnabilitysubpath; imports no generated artifacts, so the survey CI job still runs without a generation step.What the promotion adds over the prototype
Template actions with structure, not just extraction. Actions are parsed with their enclosing control flow (
if/else if/else,withincluding dot rebinding,range,define), so the classifier knows which gates enclose each construct. Lookup detection stays action-based — cert-manager's 52 textual hits classify as 0 (finding 9) — and matches only the function call, never a value namedlookup*(grafana'spersistence.lookupVolumeName, survey finding 2).Subchart-recursive with per-instance effective values.
Chart.yamldependencies are walked with helm-style coalescing (child defaults < parent<alias-or-name>subtree < supplied values; globals propagate;nulldeletes). Aliased dependencies get their own value scope over the shared directory;condition:-disabled dependencies gate everything inside them; an unvendored dependency is a recorded warning, never a silent pass.Values-aware reachability — the epic's core insight applied. Pinnability is a property of
(chart, values):lookupwhose enclosing gates (or short-circuited same-actionand/orconjuncts) definitively evaluate false under the supplied values is a recorded conditional hazard(chart, path in root coordinates, gating value)— not a refusal. Flipping the value re-classifies the pair.not provably gated off) — unknown always degrades toward refusal, never toward pinning. The tri-state condition evaluator coversand/or/not/eq/ne/empty/default, parens, pipelines, literals, and.Valuespaths; everything else is UNKNOWN.lookupstays a declared-input requirement (5 of 13 corpus charts; the reuse-existing-secret pattern), recorded inclosedInputs.Open generated inputs (
randAlphaNum,genCA,genSignedCert, ...) are detected statically and named, with the suppliable.Valuespath when the action carries one (harbor'score.secret/jobservice.secret/registry.secretcascade all resolve). Entries without a statically visible supply path are handed to the double-render localizer (#1236) by name. A generator behind a closed gate, or one whose value is already supplied, is dead and not an open input.Capability reads (
.Capabilities.KubeVersion/.APIVersions) are listed per occurrence inrequiresProfile— the normal case (11 of 13 charts), not an error.Verdict shape
The survey keeps its previous labels (
deterministic-as-is,pinnable-with-closed-inputs) via a mapping soexpected.txtdiffs show only real reclassification.Survey rewiring and expected.txt changes
The harness now consumes the promoted classifier; the prototype (
test/survey/classify.ts) is deleted, with the routing/diff helpers promoted tosrc/pinnability/render-stream.ts(seeds for #1239/#1236). Full 13-chart survey re-run against helm v4.1.1. Two verdicts legitimately change, both by the reachability the promotion adds — the exact recovery the survey comment flagged as the open design question:unpinnable->pinnable-with-closed-inputs,hazards=1. The bundled grafana's control-flowlookup(charts/grafana/templates/pvc.yaml:28) sits behindgrafana.persistence.enabled, which the defaults leave false. The hazard records the gate.unpinnable->pinnable-with-closed-inputs,hazards=1. Same construct standalone:persistence.enableddefaults to false, so a default-values render never consults the cluster. (Its 4 unstable lines — the randAlphaNum admin password cascade — keep it pinnable-with-closed-inputs, now with the open input named.)Every other row keeps its verdict and every count (caps, lookup-control/value, crds, unstable-lines) is unchanged; rows gain a
hazards=column so gating drift fails the suite.Tests
src/pinnability/pinnability.test.ts): findings 9/10 regressions, condition evaluation and short-circuit reachability, coalescing/alias/condition/global handling, values-gated reachability (hazard vs refusal on a values flip, subchart gates in root coordinates, disabled deps, aliased instance left open refuses), generated-input detection and closure, capability listing.gated-lookup-fixturecommits the kube-prometheus-stack shape offline (helm-only, no network): hazard under defaults, refusal whenkid.persistence.enabled=true.npx vitest run lexicons/helm: 572 passed, 15 skipped (network-gated).CHANT_HELM_SURVEY=1survey: 22/22, all 13 charts assert.npm run build -w @intentius/chant-lexicon-helm,just build,just lint,npx tsx scripts/check-lexicons.ts: clean.Closes #1234