auryn-kustomize 0.8.3__tar.gz

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.
@@ -0,0 +1,56 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Test/coverage artifacts
13
+ .coverage
14
+ .pytest_cache/
15
+ *.db
16
+
17
+ # Embedded-graph working dir written by `auryn quickstart` (e.g. quickstart/.auryn/)
18
+ .auryn/
19
+
20
+ # .NET build output (roslyn-extractor tool + C# test fixtures)
21
+ bin/
22
+ obj/
23
+
24
+ # Demo sample repos are generated by their setup.py / run_demo.py
25
+ demo/csharp-git/sample-repo/
26
+
27
+
28
+ # Stray FalkorDB/Redis snapshot (regenerated at runtime; never upload)
29
+ dump.rdb
30
+ *.rdb
31
+
32
+ # Deploy bundles (build artifacts)
33
+ auryn-plsql-deploy.zip
34
+ auryn-deploy.zip
35
+
36
+ # Agent-benchmark run outputs (per-run JSON logs, captured claude-config, transcripts)
37
+ benchmarks/agent/results/
38
+ benchmarks/agent/results-swe/
39
+ benchmarks/agent/results-corpus/
40
+ benchmarks/agent/results-abcd-easy/
41
+ benchmarks/agent/results-abcd-hard/
42
+ benchmarks/hook/results/
43
+ benchmarks/results/
44
+
45
+ # macOS Finder metadata
46
+ .DS_Store
47
+
48
+ # Local operator docs (client/prospect restore & VM setup) — never publish
49
+ RESTORE-*.md
50
+ INSTALL-ON-*.md
51
+
52
+ # Private, non-public hooks / work kept out of the open-source release
53
+ private/
54
+
55
+ # WIP demo not part of the public launch (kept local)
56
+ demo/auryn-tour/
@@ -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.
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.5
2
+ Name: auryn-kustomize
3
+ Version: 0.8.3
4
+ Summary: Kustomize plugin for Auryn (deployment & infrastructure tier, ADR 0007). Render-free: parses kustomization.yaml into a Resource (overlay/base) that RUNS_IMAGE the shared Image hub for each ref its images: transformer sets (newName/newTag/digest), and DEPENDS_ON the base kustomizations it layers on (resources/bases/components). A deploy-kustomize enrichment runs the shared image lifecycle. Composes with docker/compose/k8s/terraform/helm 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-kustomize
14
+
15
+ Kustomize plugin for Auryn (deployment & infrastructure tier, ADR 0007). Render-free: parses `kustomization.yaml` into a Resource (the overlay/base) that RUNS_IMAGE the shared Image hub for each ref its `images:` transformer sets (`newName`/`newTag`/`digest` → a concrete ref), and DEPENDS_ON the base kustomizations it layers on (`resources:`/`bases:`/`components:` that resolve to another in-repo kustomization). A `deploy-kustomize` enrichment runs the shared image lifecycle. Composes with auryn-docker/auryn-compose/auryn-k8s/auryn-terraform/auryn-helm onto the same hub. Depends on auryn-core and PyYAML.
16
+
17
+ v1 is static and render-free: `kustomize build` (rendering the patched base manifests) is a follow-up; v1 reads only the `kustomization.yaml` declarations.
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[kustomize]" # Auryn with only this plugin
26
+ ```
27
+
28
+ ## License
29
+
30
+ MIT. See the [LICENSE](https://github.com/FalkorDB/Auryn/blob/main/packages/kustomize/LICENSE).
@@ -0,0 +1,18 @@
1
+ # auryn-kustomize
2
+
3
+ Kustomize plugin for Auryn (deployment & infrastructure tier, ADR 0007). Render-free: parses `kustomization.yaml` into a Resource (the overlay/base) that RUNS_IMAGE the shared Image hub for each ref its `images:` transformer sets (`newName`/`newTag`/`digest` → a concrete ref), and DEPENDS_ON the base kustomizations it layers on (`resources:`/`bases:`/`components:` that resolve to another in-repo kustomization). A `deploy-kustomize` enrichment runs the shared image lifecycle. Composes with auryn-docker/auryn-compose/auryn-k8s/auryn-terraform/auryn-helm onto the same hub. Depends on auryn-core and PyYAML.
4
+
5
+ v1 is static and render-free: `kustomize build` (rendering the patched base manifests) is a follow-up; v1 reads only the `kustomization.yaml` declarations.
6
+
7
+ Part of [Auryn](https://github.com/FalkorDB/Auryn), which turns a codebase into a queryable knowledge graph for AI agents.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install falkordb-auryn # Auryn with every plugin
13
+ pip install "auryn-core[kustomize]" # Auryn with only this plugin
14
+ ```
15
+
16
+ ## License
17
+
18
+ MIT. See the [LICENSE](https://github.com/FalkorDB/Auryn/blob/main/packages/kustomize/LICENSE).
@@ -0,0 +1,28 @@
1
+ [project]
2
+ name = "auryn-kustomize"
3
+ version = "0.8.3"
4
+ description = "Kustomize plugin for Auryn (deployment & infrastructure tier, ADR 0007). Render-free: parses kustomization.yaml into a Resource (overlay/base) that RUNS_IMAGE the shared Image hub for each ref its images: transformer sets (newName/newTag/digest), and DEPENDS_ON the base kustomizations it layers on (resources/bases/components). A deploy-kustomize enrichment runs the shared image lifecycle. Composes with docker/compose/k8s/terraform/helm onto the same hub. Depends on auryn-core and PyYAML."
5
+ readme = "README.md"
6
+ authors = [{ name = "Roi Lipman", email = "roi.lipman@falkordb.com" }]
7
+ requires-python = ">=3.12"
8
+ license = { text = "MIT" }
9
+ dependencies = [
10
+ "auryn-core",
11
+ "pyyaml>=6.0",
12
+ ]
13
+
14
+ [project.entry-points."auryn.languages"]
15
+ kustomize = "auryn.ingestors.kustomize.plugin"
16
+
17
+ [project.entry-points."auryn.enrichments"]
18
+ deploy-kustomize = "auryn.ingestors.kustomize.enrichment"
19
+
20
+ [build-system]
21
+ requires = ["hatchling"]
22
+ build-backend = "hatchling.build"
23
+
24
+ [tool.hatch.build.targets.wheel]
25
+ packages = ["src/auryn"]
26
+
27
+ [tool.uv.sources]
28
+ auryn-core = { workspace = true }
@@ -0,0 +1,64 @@
1
+ """Turn parsed Kustomizations into the deployment-tier graph (ADR 0007): a `kustomization.yaml` File
2
+ owns a `Resource` (the overlay/base); the overlay RUNS_IMAGE the shared `Image` hub for each ref its
3
+ `images:` transformer sets, and DEPENDS_ON the base kustomizations it layers on (a `resources:`/`bases:`
4
+ /`components:` entry that resolves to another in-repo kustomization directory).
5
+
6
+ Emits no cross-artifact edge beyond the shared `Image` hub; the `deploy-kustomize` enrichment runs the
7
+ image lifecycle. v1 is render-free -- no `kustomize build`."""
8
+
9
+ from __future__ import annotations
10
+
11
+ import posixpath
12
+ from collections.abc import Iterator
13
+
14
+ from auryn.core.graph_model import GraphEdge, GraphNode
15
+ from auryn.core.image_ref import image_id, image_node
16
+ from auryn.ingestors.kustomize import ids
17
+ from auryn.ingestors.kustomize.model import ParsedKustomization
18
+
19
+
20
+ def _resolve_base(kustomization_dir: str, entry: str) -> str:
21
+ """Normalize a `resources:`/`bases:` path (relative to the kustomization dir) to a repo-relative
22
+ directory key, so it can be matched against the known kustomization dirs. The repo-root kustomization
23
+ is keyed by `""`, so a reference that resolves to the root (`posixpath.normpath` -> `"."`) maps to
24
+ `""`. A remote/URL entry normalizes to something that matches nothing -- and is therefore ignored."""
25
+ joined = posixpath.join(kustomization_dir, entry) if kustomization_dir else entry
26
+ norm = posixpath.normpath(joined).replace(chr(92), "/")
27
+ if norm.startswith("/"):
28
+ return norm # an absolute entry (`/base`) is not an in-repo relative dir -- keep the leading
29
+ # `/` so it matches no `by_dir` key (which are all relative), i.e. no DEPENDS_ON
30
+ return "" if norm == "." else norm.strip("/")
31
+
32
+
33
+ def build_graph(kustomizations: list[tuple[str, ParsedKustomization]], proj_id: str) -> Iterator[GraphNode | GraphEdge]:
34
+ # Index VALID kustomization dir -> its Resource id, so a base reference resolves to a real
35
+ # DEPENDS_ON (a reference to a plain manifest file or a remote base matches nothing and is skipped).
36
+ by_dir: dict[str, str] = {
37
+ pk.kustomization_dir: ids.kustomization_id(proj_id, ids.kustomization_scope(pk.kustomization_dir))
38
+ for _fp, pk in kustomizations if pk.valid
39
+ }
40
+
41
+ for file_path, pk in kustomizations:
42
+ scope = ids.kustomization_scope(pk.kustomization_dir)
43
+ kid = ids.kustomization_id(proj_id, scope)
44
+ fid = ids.file_id(proj_id, file_path)
45
+
46
+ yield GraphNode("File", {"id": fid}, {"path": file_path, "name": posixpath.basename(file_path)})
47
+ yield GraphEdge("HAS_FILE", "Project", {"id": proj_id}, "File", {"id": fid})
48
+ yield GraphNode("Resource", {"id": kid}, {
49
+ "name": pk.kustomization_dir or "_root", "kind": "kustomization",
50
+ "kustomization_dir": pk.kustomization_dir, "namespace": pk.namespace,
51
+ "name_prefix": pk.name_prefix, "name_suffix": pk.name_suffix,
52
+ "resolved": pk.valid, # an unreadable / wrong-kind kustomization.yaml isn't usable
53
+ })
54
+ yield GraphEdge("HAS_RESOURCE", "File", {"id": fid}, "Resource", {"id": kid})
55
+
56
+ for ref in pk.images:
57
+ yield image_node(ref)
58
+ yield GraphEdge("RUNS_IMAGE", "Resource", {"id": kid}, "Image", {"id": image_id(ref)})
59
+
60
+ for base in pk.bases:
61
+ target_dir = _resolve_base(pk.kustomization_dir, base)
62
+ target = by_dir.get(target_dir)
63
+ if target is not None and target != kid: # resolves to another in-repo kustomization
64
+ yield GraphEdge("DEPENDS_ON", "Resource", {"id": kid}, "Resource", {"id": target})
@@ -0,0 +1,13 @@
1
+ """The `deploy-kustomize` 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.kustomize.stitch import run as _run
8
+
9
+ # order 150 > docker/compose/k8s/terraform/helm arms, so any BUILDS_IMAGE edges already exist when
10
+ # image `resolved` is recomputed over the shared hub.
11
+ register_graph_enrichment(GraphEnrichment(name="deploy-kustomize", run=_run, order=150))
12
+
13
+ __all__ = ["_run"]
@@ -0,0 +1,132 @@
1
+ """Parse a `kustomization.yaml` (render-free) -> `ParsedKustomization`. Pure, no graph.
2
+
3
+ The two tier-relevant declarations, read WITHOUT running `kustomize build`:
4
+ * the `images:` transformer -- `{name, newName?, newTag?, digest?}` entries -> the concrete image an
5
+ overlay deploys (the hub seam);
6
+ * `resources:`/`bases:`/`components:` -- the paths this overlay layers on (the base structure).
7
+ Best-effort and never fatal: a malformed file yields an invalid `ParsedKustomization`."""
8
+
9
+ from __future__ import annotations
10
+
11
+ import yaml
12
+
13
+ from auryn.ingestors.kustomize.model import ParsedKustomization
14
+
15
+ # Kustomize recognizes a file as a kustomization by its basename regardless of `kind`, but a present
16
+ # `kind` that is NOT one of these means it's some other manifest that merely shares the name.
17
+ _KINDS = frozenset({"Kustomization", "Component", ""})
18
+
19
+
20
+ def _scalar(v) -> str:
21
+ """A YAML scalar as a stripped string (bools lowercased); "" 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).strip()
26
+ return ""
27
+
28
+
29
+ # Kustomize matches an `images:` entry's `name` as a REGEX, so a `name: ".*"` (retag everything) carries
30
+ # no concrete repository. These metacharacters can't appear in a real image ref, so a value containing
31
+ # one is a matcher, not a literal we can key the hub on.
32
+ _IMAGE_FORBIDDEN = frozenset("*?+[]{}()^$\\|<> \t")
33
+
34
+
35
+ def _plausible_image(ref: str) -> bool:
36
+ """A sane-looking, LITERAL image ref: non-empty, no whitespace or regex metacharacter (a `name:`
37
+ regex like `.*`), and -- if the last path segment carries a `:tag` -- a non-empty repository and
38
+ tag. Guards against a non-image string so `core.image_ref` can't mint a junk Image node."""
39
+ if not ref or any(c in _IMAGE_FORBIDDEN for c in ref):
40
+ return False
41
+ last = ref.split("@", 1)[0].rsplit("/", 1)[-1]
42
+ if ":" in last:
43
+ repo_tail, _, tag = last.rpartition(":")
44
+ if not repo_tail or not tag:
45
+ return False
46
+ return True
47
+
48
+
49
+ def _split_ref(ref: str) -> tuple[str, str, str]:
50
+ """`repo[:tag][@digest]` -> (repository, tag, digest). The tag is a `:` in the LAST path segment
51
+ only, so a `registry:port/...` host is never mistaken for a tag."""
52
+ body, _, digest = ref.partition("@")
53
+ cut = body.rfind("/")
54
+ seg = body[cut + 1:]
55
+ if ":" in seg:
56
+ repo_tail, _, tag = seg.rpartition(":")
57
+ return body[:cut + 1] + repo_tail, tag, digest
58
+ return body, "", digest
59
+
60
+
61
+ def _resolve_image(entry: dict) -> str | None:
62
+ """A single `images:` entry -> the concrete ref the overlay deploys, or None. Faithful to Kustomize's
63
+ `imagetag` updater (one tag-OR-digest slot): `newName` replaces the repository; the matched `name`'s
64
+ tag/digest is the starting point; `newTag` replaces the tag (clearing any digest); `digest` replaces
65
+ the digest and WINS over `newTag` (clearing the tag); `tagSuffix` appends to a tag only (a no-op on a
66
+ digest). Only an entry that yields a concrete ref is emitted -- a no-op `{name: x}`, or a `newName`
67
+ rename whose base tag is unknown render-free, is skipped (materializing `:latest` is a false hub join)."""
68
+ if not isinstance(entry, dict):
69
+ return None
70
+ name, new_name = _scalar(entry.get("name")), _scalar(entry.get("newName"))
71
+ new_tag, new_digest = _scalar(entry.get("newTag")), _scalar(entry.get("digest"))
72
+ tag_suffix = _scalar(entry.get("tagSuffix"))
73
+ if not (new_name or new_tag or new_digest or tag_suffix):
74
+ return None # a no-op entry -- just a match target, asserts nothing
75
+ name_repo, tag, digest = _split_ref(name) if name else ("", "", "")
76
+ repo = new_name or name_repo # a tagged `name` contributes only its repository here
77
+ if not repo:
78
+ return None
79
+ if new_tag:
80
+ tag, digest = new_tag, "" # newTag replaces the tag and clears any digest
81
+ if new_digest:
82
+ digest, tag = new_digest, "" # digest replaces and WINS over newTag, clearing the tag
83
+ if tag_suffix and tag:
84
+ tag += tag_suffix # tagSuffix appends to a tag (no-op on a digest)
85
+ if digest:
86
+ ref = f"{repo}@{digest}" # a digest present is the stronger identity
87
+ elif tag:
88
+ ref = f"{repo}:{tag}"
89
+ else:
90
+ return None # renamed but the base's tag is unknown statically -- don't guess `:latest`
91
+ return ref if _plausible_image(ref) else None
92
+
93
+
94
+ def _paths(doc: dict, key: str) -> list[str]:
95
+ raw = doc.get(key) # a malformed `resources: true` / scalar must not iterate (char-by-char or raise)
96
+ out = []
97
+ for p in raw if isinstance(raw, list) else []:
98
+ s = _scalar(p)
99
+ if s:
100
+ out.append(s)
101
+ return out
102
+
103
+
104
+ def parse_kustomization(kustomization_dir: str, data: str | bytes) -> ParsedKustomization:
105
+ try:
106
+ doc = yaml.safe_load(data)
107
+ except Exception:
108
+ return ParsedKustomization(kustomization_dir=kustomization_dir, valid=False)
109
+ if not isinstance(doc, dict) or _scalar(doc.get("kind")) not in _KINDS:
110
+ return ParsedKustomization(kustomization_dir=kustomization_dir, valid=False)
111
+
112
+ images: dict[str, None] = {}
113
+ raw_images = doc.get("images") # a malformed `images: 42` must not iterate
114
+ for entry in raw_images if isinstance(raw_images, list) else []:
115
+ ref = _resolve_image(entry)
116
+ if ref:
117
+ images.setdefault(ref, None)
118
+
119
+ bases: dict[str, None] = {}
120
+ for key in ("resources", "bases", "components"):
121
+ for p in _paths(doc, key):
122
+ bases.setdefault(p, None)
123
+
124
+ return ParsedKustomization(
125
+ kustomization_dir=kustomization_dir,
126
+ valid=True,
127
+ images=tuple(images),
128
+ bases=tuple(bases),
129
+ namespace=_scalar(doc.get("namespace")),
130
+ name_prefix=_scalar(doc.get("namePrefix")),
131
+ name_suffix=_scalar(doc.get("nameSuffix")),
132
+ )
@@ -0,0 +1,107 @@
1
+ """Git-tracked (and directory) Kustomize ingestion: fully recompute the project's Kustomize subgraph
2
+ at `target_sha` and diff it onto the graph (graph_sync.stream_apply). v1 is full-recompute and
3
+ render-free. Registered as the `kustomize` GitLanguage by the import-light plugin.py.
4
+
5
+ Each kustomization is anchored by its `kustomization.yaml`/`.yml`/`Kustomization` basename; nothing
6
+ else is read (the base manifests it patches need a `kustomize build` render, a follow-up). Removing
7
+ the last kustomization is handled by the `kustomize://` prior-graph cleanup in core.ingest."""
8
+
9
+ from __future__ import annotations
10
+
11
+ import itertools
12
+ import logging
13
+ import posixpath
14
+ import time
15
+ from dataclasses import dataclass
16
+
17
+ from auryn.core.graph_model import GraphNode
18
+ from auryn.core.graph_sync import stream_apply
19
+ from auryn.core.registry import LanguageIngestResult
20
+ from auryn.ingestors.kustomize.build import build_graph
21
+ from auryn.ingestors.kustomize.file_parser import parse_kustomization
22
+ from auryn.ingestors.kustomize.ids import project_id
23
+ from auryn.ingestors.kustomize.plugin import EXCLUDED_DIR_NAMES as _EXCLUDED_DIR_NAMES
24
+ from auryn.ingestors.kustomize.plugin import FILE_GLOBS as _FILE_GLOBS
25
+ from auryn.ingestors.kustomize.schema import NODE_SCHEMAS, OWNED_LABELS
26
+
27
+ logger = logging.getLogger(__name__)
28
+
29
+
30
+ @dataclass
31
+ class SyncStats:
32
+ nodes_added: int = 0
33
+ nodes_updated: int = 0
34
+ nodes_removed: int = 0
35
+ edges_added: int = 0
36
+ edges_updated: int = 0
37
+ edges_removed: int = 0
38
+ commit_sha: str = ""
39
+ elapsed_seconds: float = 0.0
40
+ files_parsed: int = 0
41
+ files_cached: int = 0
42
+
43
+
44
+ def sync_at(writer, source, target_sha: str, *, project_name: str, repo_uri: str, ref: str | None) -> SyncStats:
45
+ started = time.monotonic()
46
+ proj_id = project_id(project_name)
47
+
48
+ writer.setup_schema(NODE_SCHEMAS)
49
+ prior_sha = writer.get_property("Project", {"id": proj_id}, "commit_sha")
50
+ if prior_sha == target_sha: # tier-wide limitation: ignores source file-selection (see k8s git_sync)
51
+ return SyncStats(commit_sha=target_sha, elapsed_seconds=time.monotonic() - started)
52
+
53
+ parsed = []
54
+ for path, blob_sha in sorted(source.list_files_glob(target_sha, _FILE_GLOBS, set(_EXCLUDED_DIR_NAMES))):
55
+ cd = posixpath.dirname(path)
56
+ if cd.replace(chr(92), "/").strip("/") == "_root": # the reserved repo-root scope
57
+ logger.warning("kustomize: dir %r collides with the reserved `_root` scope -- skipped", cd)
58
+ continue
59
+ try:
60
+ blob = source.read_blob(blob_sha)
61
+ except Exception:
62
+ # KNOWN LIMITATION (tier-wide): a failed read drops it from the target, so the recompute
63
+ # REMOVES its prior nodes -- no keep-last-good.
64
+ logger.warning("failed to read kustomization %s (its nodes are removed this sync)", path, exc_info=True)
65
+ continue
66
+ parsed.append((path, parse_kustomization(posixpath.dirname(path), blob)))
67
+
68
+ # Don't stamp a phantom `kustomize://<project>` on a repo with no kustomizations. Still proceed when
69
+ # a prior subgraph exists, so removing the last one cleans it (recompute-to-empty). Gate on the
70
+ # Project NODE existing, not on `commit_sha`: an interrupted resync can clear `commit_sha` while
71
+ # leaving the nodes, and those must still be cleaned up (a bare `prior_sha is None` would skip them).
72
+ if not parsed and not writer.node_exists("Project", proj_id):
73
+ return SyncStats(commit_sha=target_sha, elapsed_seconds=time.monotonic() - started)
74
+
75
+ project_node = GraphNode(
76
+ "Project", {"id": proj_id},
77
+ {"name": project_name, "repo_uri": repo_uri, "commit_sha": target_sha, "ref": ref},
78
+ )
79
+
80
+ def make_target():
81
+ # Project node LAST, so commit_sha isn't stamped on a partial graph (see k8s git_sync). When the
82
+ # last kustomization is gone, the target is fully empty -- no Project either -- so the stale
83
+ # `kustomize://` subgraph is removed in its entirety.
84
+ tail = [project_node] if parsed else []
85
+ return itertools.chain(build_graph(parsed, proj_id), tail)
86
+
87
+ stats, _r, _p = stream_apply(writer, proj_id, OWNED_LABELS, make_target)
88
+ elapsed = time.monotonic() - started
89
+ logger.info("kustomize: %d kustomization(s), +%dn/%de in %.2fs", len(parsed), stats.nodes_added, stats.edges_added, elapsed)
90
+ return SyncStats(
91
+ nodes_added=stats.nodes_added, nodes_updated=stats.nodes_updated, nodes_removed=stats.nodes_removed,
92
+ edges_added=stats.edges_added, edges_updated=stats.edges_updated, edges_removed=stats.edges_removed,
93
+ commit_sha=target_sha, elapsed_seconds=elapsed, files_parsed=len(parsed),
94
+ )
95
+
96
+
97
+ def _git_language_sync(
98
+ writer, source, target_sha: str, *, repo_uri: str, project_name: str,
99
+ solution_name: str | None, ref: str | None, cache_root=None,
100
+ ) -> LanguageIngestResult:
101
+ s = sync_at(writer, source, target_sha, project_name=project_name, repo_uri=repo_uri, ref=ref)
102
+ return LanguageIngestResult(
103
+ nodes_added=s.nodes_added, nodes_updated=s.nodes_updated, nodes_removed=s.nodes_removed,
104
+ edges_added=s.edges_added, edges_updated=s.edges_updated, edges_removed=s.edges_removed,
105
+ files_parsed=s.files_parsed, files_cached=s.files_cached,
106
+ commit_sha=s.commit_sha, elapsed_seconds=s.elapsed_seconds,
107
+ )
@@ -0,0 +1,32 @@
1
+ """Canonical id scheme for the Kustomize graph (ADR 0007 §2). A kustomization is a `Resource` (an
2
+ overlay/base), keyed by its DIRECTORY (`kustomize://<project>/<kustomization-dir>`); the repo-root
3
+ kustomization uses the reserved `_root` segment. The shared `Image` hub keys via `core.image_ref`, so
4
+ an overlay's `images:` transformer converges with the other producers."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from auryn.core.image_ref import image_id # re-exported: the Image id lives in one place
9
+
10
+ __all__ = ["project_id", "file_id", "kustomization_scope", "kustomization_id", "image_id"]
11
+
12
+
13
+ def project_id(project_name: str) -> str:
14
+ return f"kustomize://{project_name}"
15
+
16
+
17
+ def file_id(proj_id: str, rel_path: str) -> str:
18
+ rel = rel_path.replace(chr(92), "/")
19
+ while rel.startswith("./"):
20
+ rel = rel[2:]
21
+ return f"{proj_id}/file/{rel}"
22
+
23
+
24
+ def kustomization_scope(kustomization_dir: str) -> str:
25
+ """The id segment: the kustomization's DIRECTORY (relative, slash-normalized), or the reserved
26
+ `_root` for a kustomization at the repo root -- so its `Resource` id can't collide with the
27
+ `Project` id. Keying on the directory (never a name) makes two kustomizations always distinct."""
28
+ return kustomization_dir.replace(chr(92), "/").strip("/") or "_root"
29
+
30
+
31
+ def kustomization_id(proj_id: str, scope: str) -> str:
32
+ return f"{proj_id}/{scope}"
@@ -0,0 +1,28 @@
1
+ """Parsed Kustomize model (engine-agnostic). `file_parser.parse_kustomization` produces a
2
+ `ParsedKustomization` per `kustomization.yaml`; `build.build_graph` turns them into graph nodes/edges.
3
+
4
+ v1 is STATIC and render-free: the `kustomization.yaml` is read, but `kustomize build` is NOT run, so
5
+ the base manifests it patches are not rendered. The two things that carry over the tier contract
6
+ without a render are the `images:` transformer (the concrete images an overlay deploys -> the hub) and
7
+ the `resources:`/`bases:`/`components:` references (the overlay -> base structure)."""
8
+
9
+ from __future__ import annotations
10
+
11
+ from dataclasses import dataclass
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class ParsedKustomization:
16
+ """One `kustomization.yaml`. `kustomization_dir` is its directory relative to the repo root (the
17
+ anchor) -- the scope of every id. `images` are the concrete refs its `images:` transformer sets
18
+ (the hub seam). `bases` are the raw `resources:`/`bases:`/`components:` entries (relative paths);
19
+ build resolves the ones that point at another in-repo kustomization into `DEPENDS_ON`. `valid` is
20
+ False for a file that isn't a usable Kustomization (unreadable, or missing the Kustomization kind)."""
21
+
22
+ kustomization_dir: str
23
+ valid: bool = False
24
+ images: tuple[str, ...] = ()
25
+ bases: tuple[str, ...] = ()
26
+ namespace: str = ""
27
+ name_prefix: str = ""
28
+ name_suffix: str = ""
@@ -0,0 +1,31 @@
1
+ """Import-light Kustomize language registration -- the `auryn.languages` entry-point target.
2
+
3
+ Importing this registers the kustomize GitLanguage without importing PyYAML: the lazy `sync` thunk
4
+ imports the engine only when a source actually contains a kustomization.
5
+
6
+ Detection ANCHORS on the `kustomization.yaml`/`kustomization.yml`/`Kustomization` basename (`file_globs`,
7
+ ADR 0007 §7) -- the names Kustomize itself recognizes -- so it fires only on real kustomizations, not
8
+ every `.yaml`. A `kustomization.yaml` carries `kind: Kustomization` (not a workload kind), so the k8s
9
+ ingestor parses it, finds no workload/ingress and drops it -- the two coexist on distinct `kustomize://`
10
+ / `k8s://` id prefixes."""
11
+
12
+ from __future__ import annotations
13
+
14
+ from auryn.core.registry import GitLanguage, register_git_language
15
+
16
+ LANGUAGE = "kustomize"
17
+ FILE_SUFFIXES = ()
18
+ FILE_GLOBS = ("kustomization.yaml", "kustomization.yml", "Kustomization")
19
+ EXCLUDED_DIR_NAMES = frozenset({".git", "node_modules", "vendor", "dist", ".idea", ".vscode"})
20
+
21
+
22
+ def _sync(*args, **kwargs):
23
+ from auryn.ingestors.kustomize.git_sync import _git_language_sync
24
+
25
+ return _git_language_sync(*args, **kwargs)
26
+
27
+
28
+ register_git_language(
29
+ GitLanguage(language=LANGUAGE, file_suffixes=FILE_SUFFIXES, file_globs=FILE_GLOBS,
30
+ excluded_dir_names=EXCLUDED_DIR_NAMES, sync=_sync)
31
+ )
@@ -0,0 +1,29 @@
1
+ """Graph schema the Kustomize producer writes (ADR 0007). A `kustomization.yaml` `File` owns a
2
+ `Resource` (the overlay/base); the overlay RUNS_IMAGE the shared `Image` hub for each ref its
3
+ `images:` transformer sets, and DEPENDS_ON the base kustomizations it layers on (`resources:`/`bases:`
4
+ /`components:` that resolve to another in-repo kustomization).
5
+
6
+ `Image` is the shared hub (MERGE-only; GC'd by the deploy arms). v1 is STATIC and render-free -- only
7
+ the `kustomization.yaml` is read; `kustomize build` (rendering the patched base manifests) is a
8
+ follow-up."""
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 kustomization (overlay/base)
18
+ NodeSchema(label="Image", indexed_properties=("ref",)), # the shared hub
19
+ ]
20
+
21
+ # Labels this producer OWNS under its `kustomize://<project>` prefix and diffs on resync. `Image` is shared.
22
+ OWNED_LABELS = ["Project", "File", "Resource"]
23
+
24
+ EDGE_SCHEMAS = [
25
+ EdgeSchema(rel_type="HAS_FILE"), # Project -> File
26
+ EdgeSchema(rel_type="HAS_RESOURCE"), # File (kustomization.yaml) -> Resource
27
+ EdgeSchema(rel_type="DEPENDS_ON"), # Resource (overlay) -> Resource (base kustomization)
28
+ EdgeSchema(rel_type="RUNS_IMAGE"), # Resource -> Image (an `images:` transformer entry)
29
+ ]
@@ -0,0 +1,33 @@
1
+ """The `deploy-kustomize` stitch (ADR 0007): the Kustomize producer emits its own DEPENDS_ON /
2
+ RUNS_IMAGE edges, so this arm only runs the shared image lifecycle -- recompute each `Image`'s
3
+ `resolved` (an overlay running an image that docker also builds flips internal) and GC orphan images --
4
+ so a Kustomize-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-kustomize")
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-kustomize: %d orphan image(s) GC'd", orphans)
33
+ return {"orphans_removed": orphans}