Repository navigation
feat(extract): add Kubernetes/ArgoCD/Helm-values YAML extractor - #2043
stevenpollack wants to merge 1 commit into
Conversation
graphify had no YAML extractor, so k8s manifests, ArgoCD GitOps config and Helm values all fell to the LLM document path — expensive, and it produced inferred prose links rather than a real deployment graph. On a Helm+ArgoCD monorepo that meant the entire deploy topology was effectively unqueryable. extract_k8s() parses the YAML that is actually valid YAML and emits: contains / in_namespace / references / deploys_to / deploys_chart / generates_from / produces Objects are addressed <kind>.<name> GLOBALLY rather than per-file or per- directory, mirroring how Kubernetes resolves a reference: an ApplicationSet's 'project: platform' means the AppProject named platform wherever it is declared. That scoping is what lets cross-file edges survive the per-file merge. References are matched by key NAME during a recursive walk rather than by fixed spec paths, so an ApplicationSet's nested spec.template.spec picks up the same refs as a bare Application with no ApplicationSet-specific code. Detection is by CONTENT (apiVersion + kind), never by extension: .yaml stays a DOC extension so ordinary YAML keeps going to the LLM path. The sniff runs after _is_sensitive() in detect(), so a secrets.yaml is dropped first. Mirrors the existing is_package_manifest_path() precedent (Graphify-Labs#1377). Helm templates are out of scope — Go template directives make them invalid YAML; they degrade to an empty result with an error rather than raising. pyyaml ships as the optional [k8s] extra, matching sql/terraform/pascal. Validated on a production Helm+ArgoCD monorepo: 31 manifests, 0 parse errors, 94-node graph. The generates_from edges alone show which registry each environment fans out over — i.e. which services can reach prod at all. Co-Authored-By: Claude <[email protected]>
|
Offering a second real-world corpus for this, if it is useful for validation. I run graphify on a private NixOS + k3s infrastructure monorepo (AST-only refresh,
So ~45% of the repo's source files are invisible to the graph, and the missing half is precisely the deployment topology this PR targets. The failure matches your description exactly: the files are classified as documents, land in Corpus shape, in case it is useful as a test target — 464 YAML files under
Two things about this corpus that may exercise paths a Helm-centric repo would not:
The practical consequence on our side is that "which Application owns this workload, and what does it reach" is currently unanswerable from the graph, which is the same question you hit. Happy to run a build against this corpus and report node/edge counts or failures if that would help move the PR — just say what output would be useful. No pressure intended on timing; mainly recording that the gap has more than one reporter and that there is a non-Helm GitOps corpus available to test against. |
|
Following up on the corpus offer above — the branch is now Two things I can do, if either is useful:
Since I posted, I confirmed the gap is unchanged on Your decision 3 — keep No pressure on timing; mainly that it would be a shame for the branch to rot if it is only a rebase away. |
|
Hey Scott,
I ended up abandoning graphify for a more strategic use of LSPs. You may want to actually run a comparison using your corpus: this branch of graphify vs. Helm-ls + schema-annotated yaml.
…On Tue, 4 Aug 2026, at 6:43 AM, Scott Wright wrote:
*wrightbuilt* left a comment (Graphify-Labs/graphify#2043)
<#2043 (comment)>
Following up on the corpus offer above — the branch is now
`CONFLICTING` against main and has not been rebased since 2026-07-19,
so I wanted to check whether it is still live before spending time on
it.
Two things I can do, if either is useful:
1. *Rebase onto current main and report the result* — happy to hand
back a patch rather than push anywhere.
2. *Run the extractor against the 464-file ArgoCD/Kustomize corpus*
described above and report node/edge counts, parse failures, and
specifically whether the recursive name-keyed walk picks up the
CRD-heavy files (IngressRoute, ExternalSecret, PrometheusRule,
ServiceMonitor — roughly 190 files between them).
Since I posted, I confirmed the gap is unchanged on `0.9.32`:
`.yaml`/`.yml` sit in `DOC_EXTENSIONS` (`detect.py:32`) and
`_get_extractor()` returns `None` for both, so a deterministic AST-only
run indexes none of them — 0 nodes from 515 files in our case.
Your decision 3 — keep `.yaml` in `DOC_EXTENSIONS` and reroute by
content sniff on `apiVersion:` + `kind:` — is what makes this adoptable
for us without changing the cost profile of the rest of the corpus.
Worth saying explicitly, since it is the design choice a reviewer is
most likely to push back on.
No pressure on timing; mainly that it would be a shame for the branch
to rot if it is only a rebase away.
—
Reply to this email directly, view it on GitHub
<#2043?email_source=notifications&email_token=AAT4RA2NGKZHDQBGZJ367HL5ID2PNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJXGE2DSNZUGIZ2M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-5171497423>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAT4RA2EMW3ROHZOYSGBXIT5ID2PNAVCNFSNUABGKJSXA33TNF2G64TZHMYTEMBQGU4TOMRWGM5US43TOVSTWNBZGIZDQNJVHA2TBILWAI>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
Thanks for the straight answer — that is genuinely more useful than a rebase would have been. We may well run that comparison. Our corpus is a reasonable test for it: 464 YAML files, ArgoCD app-of-apps with almost no Helm, so it leans on cross-file Leaving the branch alone for now rather than carrying it. Appreciate you writing it up as carefully as you did — the module docstring on what it deliberately does not resolve is what made it possible to evaluate without running it. |
|
Please do report back, I'd love to see what the results are.
…On Tue, 4 Aug 2026, at 7:02 AM, Scott Wright wrote:
*wrightbuilt* left a comment (Graphify-Labs/graphify#2043)
<#2043 (comment)>
Thanks for the straight answer — that is genuinely more useful than a
rebase would have been.
We may well run that comparison. Our corpus is a reasonable test for
it: 464 YAML files, ArgoCD app-of-apps with almost no Helm, so it leans
on cross-file `Application` → workload resolution rather than chart
values — which is roughly the case where a schema-aware LSP and a graph
should diverge most. If we do run it, I will post the results here,
since anyone else landing on this PR is asking the same question you
were.
Leaving the branch alone for now rather than carrying it. Appreciate
you writing it up as carefully as you did — the module docstring on
what it deliberately does *not* resolve is what made it possible to
evaluate without running it.
—
Reply to this email directly, view it on GitHub
<#2043?email_source=notifications&email_token=AAT4RAYEHKGC724ZDLE62735ID4VHA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJXGE3DOMRVGA4KM4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-5171672508>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAT4RA4VXFLLRHIMJ27XYOD5ID4VHAVCNFSNUABGKJSXA33TNF2G64TZHMYTEMBQGU4TOMRWGM5US43TOVSTWNBZGIZDQNJVHA2TBILWAI>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Problem
graphify has no YAML extractor. Kubernetes manifests, ArgoCD GitOps config and Helm values all fall through to the LLM document path — expensive, and what comes back is inferred prose relationships rather than a real deployment graph.
On a Helm + ArgoCD monorepo the practical effect is that the deployment topology is unqueryable. I hit this trying to answer "how does this service reach prod?" — every file holding the answer was invisible to the graph.
What this adds
extract_k8s()parses the YAML that genuinely is YAML and emits:contains·in_namespace·references·deploys_to·deploys_chart·generates_from·producesThree decisions worth reviewing:
1. Global
<kind>.<name>addressing.extract_terraformscopes IDs by directory because Terraform resources are module-scoped. Kubernetes isn't: an ApplicationSet'sproject: platformmeans the AppProject namedplatformwherever it is declared. Global scoping is what lets those cross-file edges survive the per-file extraction merge. Pinned bytest_cross_file_reference_resolves_by_global_address.2. References matched by key NAME, not fixed spec paths. An ApplicationSet nests an entire Application spec under
spec.template.spec. A depth-agnostic recursive walk keyed on field names picks those up with zero ApplicationSet-specific code — that's most of why this is ~290 lines and not 600.3. Detection by CONTENT, not extension.
.yamlstays inDOC_EXTENSIONS; only files carrying bothapiVersion:andkind:are rerouted to the AST path. Ordinary YAML (CI configs, docs data, front-matter) keeps going to the LLM path exactly as before. This mirrors the existingis_package_manifest_path()precedent (#1377).Security note: the sniff runs after
_is_sensitive()indetect(), so asecrets.yamlis dropped before it can reach the AST path. I verified that ordering rather than assuming it.Deliberately out of scope
Helm templates (
charts/*/templates/*.yaml). Go template directives make them invalid YAML — measured on a real chart, 0 of 46 template files parse, while 100% of the manifests and values files do. They degrade to an empty result plus an error string rather than raising.Documented in the module docstring, so the graph doesn't overstate what it knows:
generates_fromto the glob it scans, not the files that glob matches. Resolving it would mean globbing the filesystem from inside a single-file extractor, breaking per-file caching and determinism.apiVersionnorkind(an ArgoCD fleet entry is often justapp: <name>) is indistinguishable from arbitrary config, so it stays a document.Validation
Real Helm + ArgoCD monorepo, 31 manifests: 0 parse errors, 94-node graph end-to-end through
detect→extract→build_from_json.The
generates_fromedges alone answer "which services can reach prod at all":Two ApplicationSets read different registries — which is exactly why one service deploys to dev but never to prod. That was previously invisible.
Dependency
pyyamlas the optional[k8s]extra, matching thesql/terraform/pascalpattern. Without it, affected files hit the standard missing-extra warning (_EXTRA_FOR_EXTENSION) instead of failing the run.Tests
14 new tests in
tests/test_k8s.py(+ a registry-identity test following thetest_<lang>_migratedconvention), covering each relation, ApplicationSet nesting, multi-document files, real line numbers, graceful Helm-template failure, and both directions of the detection sniff. Guarded bypytest.importorskip("yaml").Full suite: 3424 passed. Four failures in
test_ollama_retry_cap.py(ModuleNotFoundError: No module named 'openai') reproduce identically onv8without this change — pre-existing and unrelated.