auryn-helm 0.8.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,128 @@
1
+ """Turn parsed Helm charts into the deployment-tier graph (ADR 0007). STATIC, render-free:
2
+
3
+ Project -HAS_FILE-> File (Chart.yaml, values.yaml)
4
+ File (Chart.yaml) -HAS_RESOURCE-> Resource (the chart/release, kind="release")
5
+ Resource -DEPENDS_ON-> Resource (a chart dependency; in-repo chart else placeholder)
6
+ Resource -RUNS_IMAGE-> Image (each container image declared in values.yaml -> the hub)
7
+ Resource -MOUNTS-> ConfigValue (each notable static config value from values.yaml)
8
+
9
+ Emits no cross-artifact edge beyond the shared `Image` hub (`resolved:false` placeholders); the
10
+ `deploy-helm` enrichment runs the shared image lifecycle. No `Service`/`DEPLOYS`: a chart's workloads
11
+ live in the Go-templated `templates/*.yaml`, which v1 does NOT render (ADR 0007 line 225) -- so the
12
+ chart's images attach to the release `Resource` via `RUNS_IMAGE` (ADR §3 allows a `Resource` source).
13
+
14
+ A dependency naming an in-repo chart resolves to that chart's real `Resource`; an external dependency
15
+ (not in the repo) falls back to a project-scoped `resolved:false` placeholder (the ADR 0004 pattern)."""
16
+
17
+ from __future__ import annotations
18
+
19
+ import posixpath
20
+ import re
21
+ from collections.abc import Iterator
22
+
23
+ from auryn.core.graph_model import GraphEdge, GraphNode
24
+ from auryn.core.image_ref import image_id, image_node
25
+ from auryn.ingestors.helm import ids
26
+ from auryn.ingestors.helm.model import ParsedChart
27
+
28
+ # A config KEY whose name signals a sensitive value (ADR 0007: a sensitive entry is redacted, never
29
+ # stored). Matched on the dotted name, so `database.password` / `auth.apiKey` are caught at any depth.
30
+ # The final branch catches a bare `key`/`keys` SEGMENT (`tls.key`, `api.key`, `signing_key` -> a private
31
+ # key) while not firing on `monkey`/`keyboard`/`publicKey` (a public key isn't a secret).
32
+ _SENSITIVE = re.compile(
33
+ r"(?i)(password|passwd|passphrase|pwd|secret|token|credential|api[_-]?key|access[_-]?key"
34
+ r"|private[_-]?key|(?:^|[._-])keys?(?:[._-]|$))"
35
+ )
36
+
37
+ # Credentials embedded in a connection-URL VALUE (`postgres://user:pass@host`) -- the password segment
38
+ # is redacted even when the KEY (`database.url`) doesn't look sensitive, so no credential is stored. The
39
+ # `user:pass@` is userinfo only inside the AUTHORITY, so the user/pass spans exclude `/?#` (an `@` after
40
+ # a `?` is in the query, e.g. `https://host?contact=a:b@x`, and must not be mistaken for a credential).
41
+ _URL_CRED = re.compile(r"(?i)([a-z][a-z0-9+.\-]*://[^\s:/@?#]*:)([^\s@/?#]+)(@)")
42
+
43
+
44
+ def _is_sensitive(name: str) -> bool:
45
+ return bool(_SENSITIVE.search(name))
46
+
47
+
48
+ def _redact_value(value: str) -> str:
49
+ return _URL_CRED.sub(r"\1[redacted]\3", value)
50
+
51
+
52
+ def _scope(pc: ParsedChart) -> str:
53
+ return ids.chart_scope(pc.chart_dir)
54
+
55
+
56
+ def _chart_file(chart_dir: str) -> str:
57
+ return posixpath.join(chart_dir, "Chart.yaml") if chart_dir else "Chart.yaml"
58
+
59
+
60
+ def _values_file(chart_dir: str) -> str:
61
+ return posixpath.join(chart_dir, "values.yaml") if chart_dir else "values.yaml"
62
+
63
+
64
+ def build_graph(charts: list[ParsedChart], proj_id: str) -> Iterator[GraphNode | GraphEdge]:
65
+ # Index chart NAME -> its Resource id, so a `dependencies:` entry naming an in-repo chart resolves
66
+ # to a real DEPENDS_ON (an external dependency falls back to a project-scoped placeholder). Only an
67
+ # UNAMBIGUOUS name (exactly one in-repo chart) resolves: a name shared by several charts (vendored
68
+ # subcharts, multiple versions) stays a placeholder rather than resolving arbitrarily to one.
69
+ name_ids: dict[str, list[str]] = {}
70
+ for pc in charts:
71
+ if pc.chart:
72
+ name_ids.setdefault(pc.chart.name, []).append(ids.chart_id(proj_id, _scope(pc)))
73
+ by_name: dict[str, str] = {n: v[0] for n, v in name_ids.items() if len(v) == 1}
74
+
75
+ for pc in charts:
76
+ scope = _scope(pc)
77
+ cid = ids.chart_id(proj_id, scope)
78
+ chart_rel = _chart_file(pc.chart_dir)
79
+ fid = ids.file_id(proj_id, chart_rel)
80
+ name = pc.chart.name if pc.chart else scope
81
+
82
+ yield GraphNode("File", {"id": fid}, {"path": chart_rel, "name": "Chart.yaml"})
83
+ yield GraphEdge("HAS_FILE", "Project", {"id": proj_id}, "File", {"id": fid})
84
+ yield GraphNode("Resource", {"id": cid}, {
85
+ "name": name, "kind": "release", "chart_dir": pc.chart_dir,
86
+ "version": pc.chart.version if pc.chart else "",
87
+ "app_version": pc.chart.app_version if pc.chart else "",
88
+ "chart_type": pc.chart.chart_type if pc.chart else "",
89
+ "resolved": pc.chart is not None, # a nameless/unreadable Chart.yaml isn't a valid chart
90
+ })
91
+ yield GraphEdge("HAS_RESOURCE", "File", {"id": fid}, "Resource", {"id": cid})
92
+
93
+ if pc.has_values:
94
+ values_rel = _values_file(pc.chart_dir)
95
+ vfid = ids.file_id(proj_id, values_rel)
96
+ yield GraphNode("File", {"id": vfid}, {"path": values_rel, "name": "values.yaml"})
97
+ yield GraphEdge("HAS_FILE", "Project", {"id": proj_id}, "File", {"id": vfid})
98
+
99
+ for dep in (pc.chart.dependencies if pc.chart else ()):
100
+ target = by_name.get(dep.name)
101
+ if target is None: # external dependency -> a project-scoped placeholder chart (unresolved)
102
+ target = ids.dep_id(proj_id, dep.name)
103
+ yield GraphNode("Resource", {"id": target}, {
104
+ "name": dep.name, "kind": "chart", "resolved": False,
105
+ "version": dep.version, "repository": dep.repository,
106
+ })
107
+ if target != cid:
108
+ yield GraphEdge("DEPENDS_ON", "Resource", {"id": cid}, "Resource", {"id": target})
109
+
110
+ for ref in pc.images:
111
+ yield image_node(ref)
112
+ yield GraphEdge("RUNS_IMAGE", "Resource", {"id": cid}, "Image", {"id": image_id(ref)})
113
+
114
+ for cv_name, cv_value in pc.config_values:
115
+ vid = ids.config_value_id(cid, cv_name)
116
+ # Redact credentials (the graph, viewer and MCP reads surface ConfigValue.value): a whole
117
+ # value under a sensitive KEY (`*password*`/`*token*`/...), or just the password embedded in
118
+ # a connection-URL VALUE under an ordinary key (`database.url`).
119
+ key_sensitive = _is_sensitive(cv_name)
120
+ value = "[redacted]" if key_sensitive else _redact_value(cv_value)
121
+ yield GraphNode("ConfigValue", {"id": vid}, {
122
+ "name": cv_name, "value": value,
123
+ "sensitive": key_sensitive or value != cv_value, "chart_dir": pc.chart_dir,
124
+ })
125
+ # MOUNTS is the tier's config-wiring edge (ADR 0007 line 107); v1 helm has no Service, so the
126
+ # release Resource is the owner -- mirroring how ADR §3 generalized RUNS_IMAGE/DEPENDS_ON to
127
+ # a Resource source. Reuses the contract edge rather than inventing one.
128
+ yield GraphEdge("MOUNTS", "Resource", {"id": cid}, "ConfigValue", {"id": vid})
@@ -0,0 +1,13 @@
1
+ """The `deploy-helm` stitch registration -- the `auryn.enrichments` entry-point target (ADR 0007).
2
+ Import-light: `stitch` pulls in only core graph helpers (no PyYAML)."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from auryn.core.registry import GraphEnrichment, register_graph_enrichment
7
+ from auryn.ingestors.helm.stitch import run as _run
8
+
9
+ # order 140 > docker/compose/k8s/terraform arms, so any BUILDS_IMAGE edges already exist when image
10
+ # `resolved` is recomputed over the shared hub.
11
+ register_graph_enrichment(GraphEnrichment(name="deploy-helm", run=_run, order=140))
12
+
13
+ __all__ = ["_run"]
@@ -0,0 +1,68 @@
1
+ """Parse a Helm chart's STATIC, YAML-valid files -> `ParsedChart`. Pure, no graph.
2
+
3
+ v1 reads only `Chart.yaml` (chart name/version/type + `dependencies:`) and `values.yaml` (container
4
+ image refs + notable config values). The Go-templated `templates/*.yaml` are deliberately NOT parsed:
5
+ they are not valid YAML, and the workloads they declare can't be resolved without a `helm template`
6
+ render (the future k8s arm, ADR 0007 line 225). Best-effort and never fatal: a malformed file yields
7
+ an empty/None component rather than raising."""
8
+
9
+ from __future__ import annotations
10
+
11
+ import yaml
12
+
13
+ from auryn.ingestors.helm.model import Chart, Dependency, ParsedChart
14
+ from auryn.ingestors.helm.values import extract_config_values, extract_images
15
+
16
+
17
+ def _safe_yaml(data: str | bytes) -> dict:
18
+ """A concrete YAML document (Chart.yaml / values.yaml) as a dict; {} on anything unexpected."""
19
+ try:
20
+ doc = yaml.safe_load(data)
21
+ except Exception:
22
+ return {}
23
+ return doc if isinstance(doc, dict) else {}
24
+
25
+
26
+ def parse_chart_yaml(data: str | bytes) -> Chart | None:
27
+ """`Chart.yaml` -> `Chart`, or None when it has no `name` (not a usable chart definition)."""
28
+ doc = _safe_yaml(data)
29
+ name = doc.get("name")
30
+ if not isinstance(name, str) or not name:
31
+ return None
32
+ deps: list[Dependency] = []
33
+ seen: set[str] = set()
34
+ deps_raw = doc.get("dependencies") # a malformed `dependencies: 42` must not raise (-> chart dropped)
35
+ for d in deps_raw if isinstance(deps_raw, list) else []:
36
+ if isinstance(d, dict) and isinstance(d.get("name"), str) and d["name"] not in seen:
37
+ seen.add(d["name"])
38
+ deps.append(Dependency(
39
+ name=d["name"],
40
+ version=str(d.get("version", "")),
41
+ repository=str(d.get("repository", "")),
42
+ ))
43
+ return Chart(
44
+ name=name,
45
+ version=str(doc.get("version", "")),
46
+ app_version=str(doc.get("appVersion", "")),
47
+ chart_type=str(doc.get("type", "")),
48
+ dependencies=tuple(deps),
49
+ )
50
+
51
+
52
+ def load_values(data: str | bytes) -> dict:
53
+ return _safe_yaml(data)
54
+
55
+
56
+ def parse_chart(chart_dir: str, chart_yaml, values_yaml) -> ParsedChart:
57
+ """Assemble a `ParsedChart` from a chart's raw `Chart.yaml`/`values.yaml` bytes (either may be
58
+ None). The chart's images and config values are read from `values.yaml`."""
59
+ chart = parse_chart_yaml(chart_yaml) if chart_yaml else None
60
+ has_values = values_yaml is not None
61
+ values = load_values(values_yaml) if values_yaml else {}
62
+ return ParsedChart(
63
+ chart_dir=chart_dir,
64
+ chart=chart,
65
+ images=extract_images(values),
66
+ config_values=extract_config_values(values),
67
+ has_values=has_values,
68
+ )
@@ -0,0 +1,138 @@
1
+ """Git-tracked (and directory) Helm ingestion: fully recompute the project's Helm subgraph at
2
+ `target_sha` and diff it onto the graph (graph_sync.stream_apply). v1 is full-recompute and
3
+ render-free. Registered as the `helm` GitLanguage by the import-light plugin.py.
4
+
5
+ A chart is anchored by its `Chart.yaml`; each chart pulls its sibling `values.yaml` and NOTHING else
6
+ -- the Go-templated `templates/*.yaml` are not read (ADR 0007 line 225). The GitLanguage suffix match
7
+ is broad (`*.yaml`/`*.yml`, like k8s) -- the `Chart.yaml` basename is what actually identifies a chart
8
+ here, and non-chart YAML yields nothing, so a repo with no charts never gets a phantom `helm://`
9
+ project. (A tighter filename-aware detector is the `GitLanguage.filename_matches` follow-up, ADR §7.)
10
+
11
+ The k8s producer naturally skips these same files, so there is no double-ingest: `Chart.yaml`/
12
+ `values.yaml` lack `apiVersion`+`kind` (k8s's byte pre-check drops them), and a chart's templates fail
13
+ k8s's YAML parse (the `{{ }}` makes them invalid YAML). The two producers coexist on distinct
14
+ `helm://`/`k8s://` id prefixes."""
15
+
16
+ from __future__ import annotations
17
+
18
+ import itertools
19
+ import logging
20
+ import posixpath
21
+ import time
22
+ from dataclasses import dataclass
23
+
24
+ from auryn.core.graph_model import GraphNode
25
+ from auryn.core.graph_sync import stream_apply
26
+ from auryn.core.registry import LanguageIngestResult
27
+ from auryn.ingestors.helm.build import build_graph
28
+ from auryn.ingestors.helm.file_parser import parse_chart
29
+ from auryn.ingestors.helm.ids import project_id
30
+ from auryn.ingestors.helm.plugin import EXCLUDED_DIR_NAMES as _EXCLUDED_DIR_NAMES
31
+ from auryn.ingestors.helm.plugin import CHART_GLOBS as _CHART_GLOBS
32
+ from auryn.ingestors.helm.schema import NODE_SCHEMAS, OWNED_LABELS
33
+
34
+ logger = logging.getLogger(__name__)
35
+
36
+
37
+ @dataclass
38
+ class SyncStats:
39
+ nodes_added: int = 0
40
+ nodes_updated: int = 0
41
+ nodes_removed: int = 0
42
+ edges_added: int = 0
43
+ edges_updated: int = 0
44
+ edges_removed: int = 0
45
+ commit_sha: str = ""
46
+ elapsed_seconds: float = 0.0
47
+ files_parsed: int = 0
48
+ files_cached: int = 0
49
+
50
+
51
+ def _collect_charts(source, target_sha: str) -> dict[str, tuple]:
52
+ """Group the repo's YAML into charts: `{chart_dir: (chart_blob, values_blob)}` keyed off each
53
+ `Chart.yaml`. Only the chart's own `Chart.yaml` + sibling `values.yaml` are kept -- v1 reads no
54
+ templates. A repo YAML file that isn't a `Chart.yaml` (and isn't a chart's `values.yaml`) is
55
+ dropped, so a plain k8s manifest or a compose file never anchors a helm chart."""
56
+ yaml_files: dict[str, str] = {} # only Chart.yaml + values.yaml, not every repo YAML
57
+ for path, blob_sha in source.list_files_glob(target_sha, _CHART_GLOBS, set(_EXCLUDED_DIR_NAMES)):
58
+ yaml_files.setdefault(path, blob_sha)
59
+
60
+ chart_dirs: dict[str, str] = {}
61
+ for p in yaml_files:
62
+ if posixpath.basename(p) != "Chart.yaml":
63
+ continue
64
+ cd = posixpath.dirname(p)
65
+ norm = cd.replace(chr(92), "/").strip("/") # a non-root chart literally at `_root`/`_dep/...`
66
+ if norm == "_root" or norm == "_dep" or norm.startswith("_dep/"):
67
+ logger.warning("helm: chart dir %r collides with a reserved id namespace (_root/_dep) -- skipped", cd)
68
+ continue
69
+ chart_dirs[cd] = yaml_files[p]
70
+ charts: dict[str, tuple] = {}
71
+ for cd, chart_blob in sorted(chart_dirs.items()):
72
+ values_blob = yaml_files.get(posixpath.join(cd, "values.yaml") if cd else "values.yaml")
73
+ charts[cd] = (chart_blob, values_blob)
74
+ return charts
75
+
76
+
77
+ def sync_at(writer, source, target_sha: str, *, project_name: str, repo_uri: str, ref: str | None) -> SyncStats:
78
+ started = time.monotonic()
79
+ proj_id = project_id(project_name)
80
+
81
+ writer.setup_schema(NODE_SCHEMAS)
82
+ prior_sha = writer.get_property("Project", {"id": proj_id}, "commit_sha")
83
+ if prior_sha == target_sha: # tier-wide limitation: ignores source file-selection (see k8s git_sync)
84
+ return SyncStats(commit_sha=target_sha, elapsed_seconds=time.monotonic() - started)
85
+
86
+ def _read(blob_sha):
87
+ return source.read_blob(blob_sha) if blob_sha else None
88
+
89
+ parsed_charts = []
90
+ for cd, (chart_blob, values_blob) in _collect_charts(source, target_sha).items():
91
+ try:
92
+ parsed_charts.append(parse_chart(cd, _read(chart_blob), _read(values_blob)))
93
+ except Exception:
94
+ # KNOWN LIMITATION (tier-wide): a failed read drops the chart from the target, so the
95
+ # recompute REMOVES its prior nodes -- no keep-last-good like the tree-sitter ingestors.
96
+ logger.warning("failed to read chart at %s (its nodes are removed this sync)", cd or "<root>", exc_info=True)
97
+ continue
98
+
99
+ # Don't stamp a phantom `helm://<project>` on a repo that has no charts at all. Still proceed when a
100
+ # prior helm subgraph exists, so removing the last chart cleans it (recompute-to-empty) -- its
101
+ # Project node, not its stamp: a sync that died mid-apply leaves the node without one.
102
+ if not parsed_charts and prior_sha is None and not writer.node_exists("Project", proj_id):
103
+ return SyncStats(commit_sha=target_sha, elapsed_seconds=time.monotonic() - started)
104
+
105
+ project_node = GraphNode(
106
+ "Project", {"id": proj_id},
107
+ {"name": project_name, "repo_uri": repo_uri, "commit_sha": target_sha, "ref": ref},
108
+ )
109
+
110
+ def make_target():
111
+ # Project node LAST, so commit_sha isn't stamped on a partial graph (see k8s git_sync). When the
112
+ # LAST chart was removed (no charts, but a prior graph exists) the target is fully empty -- no
113
+ # Project either -- so the stale `helm://` subgraph is removed in its entirety, not left as a
114
+ # bare Project node.
115
+ tail = [project_node] if parsed_charts else []
116
+ return itertools.chain(build_graph(parsed_charts, proj_id), tail)
117
+
118
+ stats, _r, _p = stream_apply(writer, proj_id, OWNED_LABELS, make_target)
119
+ elapsed = time.monotonic() - started
120
+ logger.info("helm: %d chart(s), +%dn/%de in %.2fs", len(parsed_charts), stats.nodes_added, stats.edges_added, elapsed)
121
+ return SyncStats(
122
+ nodes_added=stats.nodes_added, nodes_updated=stats.nodes_updated, nodes_removed=stats.nodes_removed,
123
+ edges_added=stats.edges_added, edges_updated=stats.edges_updated, edges_removed=stats.edges_removed,
124
+ commit_sha=target_sha, elapsed_seconds=elapsed, files_parsed=len(parsed_charts),
125
+ )
126
+
127
+
128
+ def _git_language_sync(
129
+ writer, source, target_sha: str, *, repo_uri: str, project_name: str,
130
+ solution_name: str | None, ref: str | None, cache_root=None,
131
+ ) -> LanguageIngestResult:
132
+ s = sync_at(writer, source, target_sha, project_name=project_name, repo_uri=repo_uri, ref=ref)
133
+ return LanguageIngestResult(
134
+ nodes_added=s.nodes_added, nodes_updated=s.nodes_updated, nodes_removed=s.nodes_removed,
135
+ edges_added=s.edges_added, edges_updated=s.edges_updated, edges_removed=s.edges_removed,
136
+ files_parsed=s.files_parsed, files_cached=s.files_cached,
137
+ commit_sha=s.commit_sha, elapsed_seconds=s.elapsed_seconds,
138
+ )
@@ -0,0 +1,51 @@
1
+ """Canonical id scheme for the Helm graph (ADR 0007 §2). A chart is a `Resource` (the release), keyed
2
+ by its chart DIRECTORY (`helm://<project>/<chart-dir>`); its notable config values are `ConfigValue`
3
+ nodes keyed owner-scoped (`<resource-id>/env/<NAME>`, the tier-wide ConfigValue scheme, ADR line 72).
4
+ The shared `Image` hub keys via `core.image_ref`, so a chart's image converges with the other
5
+ producers. v1 emits no `Service` (a chart's workloads need a render -- the future k8s arm)."""
6
+
7
+ from __future__ import annotations
8
+
9
+ from auryn.core.image_ref import image_id # re-exported: the Image id lives in one place
10
+
11
+ __all__ = ["project_id", "file_id", "chart_scope", "chart_id", "dep_id", "config_value_id", "image_id"]
12
+
13
+
14
+ def project_id(project_name: str) -> str:
15
+ return f"helm://{project_name}"
16
+
17
+
18
+ def file_id(proj_id: str, rel_path: str) -> str:
19
+ rel = rel_path.replace(chr(92), "/")
20
+ while rel.startswith("./"):
21
+ rel = rel[2:]
22
+ return f"{proj_id}/file/{rel}"
23
+
24
+
25
+ def chart_scope(chart_dir: str) -> str:
26
+ """The chart's id segment: its DIRECTORY (relative, slash-normalized). Keying on the directory --
27
+ never the Chart.yaml `name` -- is what stops a root chart whose name equals a sibling subdir from
28
+ merging with that subchart (two charts in two dirs always get two scopes). The repo-ROOT chart
29
+ (empty dir) uses the reserved `_root` segment. `_root` and the `_dep/` dependency namespace are
30
+ reserved: `git_sync._collect_charts` skips a real chart that would land on either, so a path can
31
+ never collide with them (see `dep_id`)."""
32
+ return chart_dir.replace(chr(92), "/").strip("/") or "_root"
33
+
34
+
35
+ def chart_id(proj_id: str, scope: str) -> str:
36
+ return f"{proj_id}/{scope}"
37
+
38
+
39
+ def dep_id(proj_id: str, dep_name: str) -> str:
40
+ # A dependency that resolves to an in-repo chart uses that chart's id; an EXTERNAL dependency (not
41
+ # in the repo) gets a project-scoped placeholder keyed by name, so two charts depending on the same
42
+ # external chart converge on one node. The `_dep/` namespace is RESERVED -- chart discovery
43
+ # (git_sync._collect_charts) skips any real chart whose directory is `_dep`/`_dep/...`, so a
44
+ # placeholder can never collide with a chart `Resource`.
45
+ return f"{proj_id}/_dep/{dep_name}"
46
+
47
+
48
+ def config_value_id(owner_id: str, name: str) -> str:
49
+ # The tier-wide ConfigValue scheme is `<owner-id>/env/<NAME>` (ADR 0007 line 72); the owner is the
50
+ # chart's `Resource`, so the value is scoped to -- and GC'd with -- its chart.
51
+ return f"{owner_id}/env/{name}"
@@ -0,0 +1,49 @@
1
+ """Parsed Helm model (engine-agnostic). `file_parser.parse_chart` produces a `ParsedChart` per chart
2
+ directory; `build.build_graph` turns them into graph nodes/edges.
3
+
4
+ v1 is STATIC and render-free: only a chart's YAML-valid files (`Chart.yaml` + `values.yaml`) are read.
5
+ The Go-templated `templates/*.yaml` are NOT parsed -- they are not valid YAML, and resolving the
6
+ workloads they declare needs a `helm template` render (the future k8s arm, ADR 0007 line 225)."""
7
+
8
+ from __future__ import annotations
9
+
10
+ from dataclasses import dataclass
11
+
12
+
13
+ @dataclass(frozen=True)
14
+ class Dependency:
15
+ """One entry of a chart's `dependencies:` (Chart.yaml / the legacy requirements.yaml). `version`
16
+ and `repository` are kept for the placeholder `Resource` a not-in-repo dependency becomes."""
17
+
18
+ name: str
19
+ version: str = ""
20
+ repository: str = ""
21
+
22
+
23
+ @dataclass(frozen=True)
24
+ class Chart:
25
+ """A Helm chart, from its `Chart.yaml`. `chart_type` is Chart.yaml's `type:` (`application` /
26
+ `library`). `dependencies` become DEPENDS_ON edges -- resolved to an in-repo chart when one matches
27
+ by name, else a `resolved:false` placeholder `Resource` (the ADR 0004 reference pattern)."""
28
+
29
+ name: str
30
+ version: str = ""
31
+ app_version: str = ""
32
+ chart_type: str = ""
33
+ dependencies: tuple[Dependency, ...] = ()
34
+
35
+
36
+ @dataclass(frozen=True)
37
+ class ParsedChart:
38
+ """One Helm chart: its `Chart.yaml` metadata (or None if unreadable), the container image refs its
39
+ `values.yaml` declares (the hub seam), and its notable static config values. `chart_dir` is the
40
+ chart's directory relative to the repo root (the `Chart.yaml` anchor) -- the scope of every id this
41
+ chart contributes. `has_values` records whether a `values.yaml` was present (so its File node is
42
+ emitted only when it exists). v1 emits NO `Service`: a chart's workloads live in the Go-templated
43
+ `templates/*.yaml`, which can't be resolved statically without a render (ADR 0007 line 225)."""
44
+
45
+ chart_dir: str
46
+ chart: Chart | None = None
47
+ images: tuple[str, ...] = ()
48
+ config_values: tuple[tuple[str, str], ...] = () # (dotted-name, value) scalar leaves (bounded depth)
49
+ has_values: bool = False
@@ -0,0 +1,39 @@
1
+ """Import-light Helm language registration -- the `auryn.languages` entry-point target.
2
+
3
+ Importing this registers the helm GitLanguage without importing PyYAML: the lazy `sync` thunk imports
4
+ the engine only when a source actually contains `.yaml`/`.yml` files.
5
+
6
+ Detection matches the chart FILES by basename (`file_globs`, ADR 0007 §7) -- `Chart.yaml`/`Chart.yml`
7
+ and the sibling `values.yaml`/`values.yml` -- instead of the old broad `*.yaml` (which, like k8s,
8
+ woke helm on every YAML in the repo and dropped the non-charts). helm now fires only on chart-related
9
+ files; a plain k8s manifest / compose file / arbitrary `config.yaml` no longer wakes it. Including
10
+ `values.yaml` also makes the save-watcher resync on a values edit (where a chart's images/config live)
11
+ and lets a resync that still sees `values.yaml` after `Chart.yaml` is deleted clean the chart up; the
12
+ whole-chart-removed case (no files at all) is handled by the `helm://` prior-graph cleanup in
13
+ core.ingest. A chart's Go-templated templates are invalid YAML, so the k8s parse drops them -- the two
14
+ producers coexist on distinct `helm://` / `k8s://` id prefixes."""
15
+
16
+ from __future__ import annotations
17
+
18
+ from auryn.core.registry import GitLanguage, register_git_language
19
+
20
+ LANGUAGE = "helm"
21
+ FILE_SUFFIXES = ()
22
+ # Chart-related basenames only (NOT a broad `*.yaml`): the chart manifest + its values. A chart always
23
+ # has a Chart.yaml, so detection still fires only on real charts; git_sync anchors each chart on its
24
+ # Chart.yaml and reads the sibling values.yaml.
25
+ FILE_GLOBS = ("Chart.yaml", "Chart.yml", "values.yaml", "values.yml")
26
+ CHART_GLOBS = FILE_GLOBS
27
+ EXCLUDED_DIR_NAMES = frozenset({".git", "node_modules", "vendor", "dist", ".idea", ".vscode"})
28
+
29
+
30
+ def _sync(*args, **kwargs):
31
+ from auryn.ingestors.helm.git_sync import _git_language_sync
32
+
33
+ return _git_language_sync(*args, **kwargs)
34
+
35
+
36
+ register_git_language(
37
+ GitLanguage(language=LANGUAGE, file_suffixes=FILE_SUFFIXES, file_globs=FILE_GLOBS,
38
+ excluded_dir_names=EXCLUDED_DIR_NAMES, sync=_sync)
39
+ )
@@ -0,0 +1,34 @@
1
+ """Graph schema the Helm producer writes (ADR 0007). A chart `File` (its `Chart.yaml`) owns the chart
2
+ `Resource` (the release); the chart DEPENDS_ON the charts it depends on, RUNS_IMAGE the shared `Image`
3
+ hub (each container image declared in `values.yaml`), and MOUNTS the notable `ConfigValue`s from
4
+ `values.yaml`.
5
+
6
+ `Image` is the shared hub (MERGE-only; GC'd by the deploy arms). v1 is STATIC and render-free -- only
7
+ the YAML-valid `Chart.yaml`/`values.yaml`; a chart's workloads (`Service`/`DEPLOYS`) need a
8
+ `helm template` render, the follow-up k8s arm."""
9
+
10
+ from __future__ import annotations
11
+
12
+ from auryn.core.graph_model import EdgeSchema, NodeSchema
13
+
14
+ NODE_SCHEMAS = [
15
+ NodeSchema(label="Project", indexed_properties=("name",)),
16
+ NodeSchema(label="File", indexed_properties=("path",)),
17
+ NodeSchema(label="Resource", indexed_properties=("name",)), # the chart / release
18
+ NodeSchema(label="ConfigValue", indexed_properties=("name",)), # a notable value from values.yaml
19
+ NodeSchema(label="Image", indexed_properties=("ref",)), # the shared hub
20
+ ]
21
+
22
+ # Labels this producer OWNS under its `helm://<project>` prefix and diffs on resync. `Image` is shared.
23
+ # `Service` is NOT emitted by the static v1, but stays in the reconcilation inventory so a resync of a
24
+ # graph first built by the pre-static (#784) template design -- which DID emit helm `Service` workloads
25
+ # -- purges those now-orphaned nodes (and their DEPLOYS edges) instead of leaving them behind.
26
+ OWNED_LABELS = ["Project", "File", "Resource", "ConfigValue", "Service"]
27
+
28
+ EDGE_SCHEMAS = [
29
+ EdgeSchema(rel_type="HAS_FILE"), # Project -> File
30
+ EdgeSchema(rel_type="HAS_RESOURCE"), # File (Chart.yaml) -> Resource (chart)
31
+ EdgeSchema(rel_type="DEPENDS_ON"), # Resource (chart) -> Resource (dependency chart)
32
+ EdgeSchema(rel_type="RUNS_IMAGE"), # Resource (chart) -> Image (a values.yaml image)
33
+ EdgeSchema(rel_type="MOUNTS"), # Resource (chart) -> ConfigValue (a values.yaml config value)
34
+ ]
@@ -0,0 +1,33 @@
1
+ """The `deploy-helm` stitch (ADR 0007): the Helm producer emits its own DEPENDS_ON / RUNS_IMAGE /
2
+ MOUNTS edges, so this arm only runs the shared image lifecycle -- recompute each `Image`'s `resolved`
3
+ (a chart running an image that docker also builds flips internal) and GC orphan images -- so a
4
+ Helm-only repo still gets correct image state."""
5
+
6
+ from __future__ import annotations
7
+
8
+ import logging
9
+
10
+ from auryn.core import deploy
11
+ from auryn.core.graph_client import GraphWriter
12
+
13
+ logger = logging.getLogger("auryn.deploy-helm")
14
+
15
+
16
+ def run(writer: GraphWriter, repo, target_sha: str) -> dict | None:
17
+ return stitch(writer)
18
+
19
+
20
+ def stitch(writer: GraphWriter) -> dict | None:
21
+ try:
22
+ if not writer.ro_query("MATCH (i:Image) RETURN i.id LIMIT 1").result_set:
23
+ return None
24
+ except Exception as e:
25
+ if "empty key" in str(e).lower():
26
+ return None
27
+ raise
28
+ deploy.recompute_image_resolved(writer)
29
+ orphans = deploy.gc_orphan_images(writer)
30
+ if not orphans:
31
+ return None
32
+ logger.info("deploy-helm: %d orphan image(s) GC'd", orphans)
33
+ return {"orphans_removed": orphans}
@@ -0,0 +1,105 @@
1
+ """Extract the container images and notable config values a chart's `values.yaml` declares -- the
2
+ STATIC, render-free seam (ADR 0007). Pure, no graph.
3
+
4
+ Images follow the common Helm conventions: an `image:` MAPPING with `repository` (+ optional
5
+ `registry`/`tag`), or a bare `image: "repo:tag"` STRING, at the top level or nested under any
6
+ sub-chart/component key (`primary.image.repository`, ...). The concrete ref is handed to
7
+ `core.image_ref`, so a chart's image converges on the same `Image` hub node docker/compose/k8s/tf key.
8
+
9
+ Config values are the scalar leaves down to a bounded depth -- the chart's notable static config, NOT
10
+ every leaf (deep maps and lists are skipped, keeping the node count sensible)."""
11
+
12
+ from __future__ import annotations
13
+
14
+ # Top-level + one nested level: captures `replicaCount`, `service.port`, `image.repository`/`image.tag`
15
+ # (the "top-level config keys and image-related keys"), while deeper trees (`resources.limits.cpu`,
16
+ # `ingress.annotations.*`) stay out -- a sensible config slice, not an exhaustive flatten.
17
+ _MAX_CONFIG_DEPTH = 2
18
+
19
+
20
+ def _scalar(v) -> str | None:
21
+ """A YAML scalar as a string (bools lowercased `true`/`false`), or None for a map/list/null."""
22
+ if isinstance(v, bool):
23
+ return "true" if v else "false"
24
+ if isinstance(v, (str, int, float)):
25
+ return str(v)
26
+ return None
27
+
28
+
29
+ def _assemble_image(img: dict) -> str | None:
30
+ """`{repository, tag?, registry?}` -> a concrete ref (`ghcr.io/acme/api:1.2`), or None without a
31
+ `repository`. Tag/registry are optional; `core.image_ref` applies the registry/`latest` defaults."""
32
+ repository = _scalar(img.get("repository"))
33
+ if not repository:
34
+ return None
35
+ registry = _scalar(img.get("registry"))
36
+ tag = _scalar(img.get("tag"))
37
+ ref = f"{registry.rstrip('/')}/{repository}" if registry else repository
38
+ return f"{ref}:{tag}" if tag else ref
39
+
40
+
41
+ def _plausible_image(ref: str) -> bool:
42
+ """A sane-looking image ref: non-empty, no whitespace, no unrendered `{{...}}` template, and -- if
43
+ the last path segment carries a `:tag` -- a non-empty repository and tag. Filters a prose value or a
44
+ templated tag that happens to sit on an `image:` key (`image: "see the docs"`, `shop/api:`,
45
+ `repository: shop/api, tag: "{{ .Chart.AppVersion }}"`); `core.image_ref` would otherwise mint a
46
+ junk Image node from them."""
47
+ if not ref or "{{" in ref or any(c.isspace() for c in ref):
48
+ return False
49
+ last = ref.split("@", 1)[0].rsplit("/", 1)[-1] # last path segment, digest stripped
50
+ if ":" in last:
51
+ repo_tail, _, tag = last.rpartition(":")
52
+ if not repo_tail or not tag:
53
+ return False
54
+ return True
55
+
56
+
57
+ def extract_images(values: dict) -> tuple[str, ...]:
58
+ """Every container image ref declared under `values`, de-duplicated in first-seen order. Walks the
59
+ whole tree: wherever a mapping has an `image` key (a `repository` sub-map, or a bare `repo:tag`
60
+ string) a ref is collected -- if it looks like a real image ref (`_plausible_image`)."""
61
+ out: dict[str, None] = {}
62
+
63
+ def _add(ref: str | None) -> None:
64
+ if ref and _plausible_image(ref):
65
+ out.setdefault(ref, None)
66
+
67
+ def walk(node) -> None:
68
+ if isinstance(node, dict):
69
+ img = node.get("image")
70
+ if isinstance(img, str):
71
+ _add(img.strip())
72
+ elif isinstance(img, dict):
73
+ _add(_assemble_image(img))
74
+ for k, v in node.items():
75
+ if k != "image": # the `image` block itself holds only scalars -- no images nested within
76
+ walk(v)
77
+ elif isinstance(node, list):
78
+ for v in node:
79
+ walk(v)
80
+
81
+ walk(values)
82
+ return tuple(out)
83
+
84
+
85
+ def extract_config_values(values: dict) -> tuple[tuple[str, str], ...]:
86
+ """`(dotted-name, value)` for the scalar leaves of `values` down to `_MAX_CONFIG_DEPTH` levels --
87
+ the chart's notable static config (`replicaCount`, `service.port`, `image.tag`, ...). Lists and
88
+ deeper maps are skipped so the node count stays sensible, not every leaf (ADR 0007)."""
89
+ out: list[tuple[str, str]] = []
90
+
91
+ def walk(node: dict, prefix: str, depth: int) -> None:
92
+ if depth > _MAX_CONFIG_DEPTH:
93
+ return
94
+ for k, v in node.items():
95
+ name = f"{prefix}.{k}" if prefix else str(k)
96
+ s = _scalar(v)
97
+ if s is not None:
98
+ out.append((name, s))
99
+ elif isinstance(v, dict):
100
+ walk(v, name, depth + 1)
101
+ # lists / nulls: skipped
102
+
103
+ if isinstance(values, dict):
104
+ walk(values, "", 1)
105
+ return tuple(out)
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.5
2
+ Name: auryn-helm
3
+ Version: 0.8.3
4
+ Summary: Helm-chart plugin for Auryn (deployment & infrastructure tier, ADR 0007). Render-free static parse: Chart.yaml + values.yaml become a Resource (the chart/release) that DEPENDS_ON its chart dependencies (in-repo chart else a placeholder), RUNS_IMAGE the shared Image hub for each values.yaml image, and MOUNTS the chart's notable ConfigValues. A deploy-helm enrichment runs the shared image lifecycle. Composes with docker/compose/k8s/terraform onto the same hub. Depends on auryn-core and PyYAML.
5
+ Author-email: Roi Lipman <roi.lipman@falkordb.com>
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.12
9
+ Requires-Dist: auryn-core
10
+ Requires-Dist: pyyaml>=6.0
11
+ Description-Content-Type: text/markdown
12
+
13
+ # auryn-helm
14
+
15
+ Helm-chart plugin for Auryn (deployment & infrastructure tier, ADR 0007). Render-free static parse: a chart's `Chart.yaml` + `values.yaml` become a Resource (the chart/release) that DEPENDS_ON its chart dependencies (resolved to an in-repo chart by name, else a placeholder), RUNS_IMAGE the shared Image hub for each image declared in `values.yaml`, and MOUNTS the chart's notable `ConfigValue`s. A `deploy-helm` enrichment runs the shared image lifecycle. Composes with auryn-docker/auryn-compose/auryn-k8s/auryn-terraform onto the same hub. Depends on auryn-core and PyYAML.
16
+
17
+ v1 is static and render-free: a chart's `templates/*.yaml` are Go-templated (not valid YAML) and are not parsed — resolving the workloads they declare needs a `helm template` render, a future k8s-producing arm.
18
+
19
+ Part of [Auryn](https://github.com/FalkorDB/Auryn), which turns a codebase into a queryable knowledge graph for AI agents.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ pip install falkordb-auryn # Auryn with every plugin
25
+ pip install "auryn-core[helm]" # Auryn with only this plugin
26
+ ```
27
+
28
+ ## License
29
+
30
+ MIT. See the [LICENSE](https://github.com/FalkorDB/Auryn/blob/main/packages/helm/LICENSE).
@@ -0,0 +1,16 @@
1
+ auryn/ingestors/helm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ auryn/ingestors/helm/build.py,sha256=B-E5TDo5xv8KQwPJ5GeSLQZqpk9WcMGrJJU7i_aYpcY,6974
3
+ auryn/ingestors/helm/enrichment.py,sha256=aDrfU8gkD1Q_5DZo4jGuTttlcKlcV-k7H5BoiBZAr3k,588
4
+ auryn/ingestors/helm/file_parser.py,sha256=VTiwCsJH7INNIBOct2-FRLt28QOGInpCom3W3E9Dwv4,2747
5
+ auryn/ingestors/helm/git_sync.py,sha256=eyng5NYNbxWof5bpw_9BnM7FjO1SOcUcVYnJOmsFiPo,7090
6
+ auryn/ingestors/helm/ids.py,sha256=OpQiTk9KAsl9sScmax0wo10acoQgrFXY4JGW4AKH6FY,2556
7
+ auryn/ingestors/helm/model.py,sha256=dON7KHjeQGBvT1x-3F3quckjBWc4FUtypx28KpyeL10,2188
8
+ auryn/ingestors/helm/plugin.py,sha256=n35TSL7BhT57xsbcp-IElJYPaVjci8r90WWmhyfP72U,2041
9
+ auryn/ingestors/helm/schema.py,sha256=_XxG6MhY31UEcvyqw6gsJW_fJxzOddERdSJk9Q87A5M,2012
10
+ auryn/ingestors/helm/stitch.py,sha256=L2k5UbG5eX21DgJwSxdUFfkUWQl5KjV5Ax6TyDxvGEw,1128
11
+ auryn/ingestors/helm/values.py,sha256=T-LRHgXq8eJ3bOGT5_ntFF06PQLdHzfpIu1nR2ikpxo,4656
12
+ auryn_helm-0.8.3.dist-info/METADATA,sha256=DJpWzCt1n31UoJKj2YNxv2r5H-LK7hbymjSEATdIkeA,1966
13
+ auryn_helm-0.8.3.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
14
+ auryn_helm-0.8.3.dist-info/entry_points.txt,sha256=5W-qP1qUuW5C1MAzRSJ6jJTl-c_EF4-6R7NVtfx3a_Y,120
15
+ auryn_helm-0.8.3.dist-info/licenses/LICENSE,sha256=MuKfC8-ZgDZVoySTMklxyndvd1_og68pI2gS94re3RI,1065
16
+ auryn_helm-0.8.3.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,5 @@
1
+ [auryn.enrichments]
2
+ deploy-helm = auryn.ingestors.helm.enrichment
3
+
4
+ [auryn.languages]
5
+ helm = auryn.ingestors.helm.plugin
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 FalkorDB
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.