Project repo-family relations from local declarations
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s

This commit is contained in:
codex 2026-07-26 08:51:29 +02:00
parent 1d8f59f1de
commit 9af9ee3e72
13 changed files with 671 additions and 28 deletions

View file

@ -102,6 +102,135 @@ def test_registry_accepts_snapshot_and_queries_graph(tmp_path: Path) -> None:
assert "libraries" in library_xregistry_projection(store.list_libraries())["groups"]
def test_registry_projects_repo_family_relations_from_repo_local_declarations(tmp_path: Path) -> None:
store = RegistryStore(tmp_path / "registry.sqlite3")
store.init_schema()
store.upsert_repository({"slug": "railiance-cluster", "name": "Railiance Cluster"})
store.upsert_repository({"slug": "railiance-infra", "name": "Railiance Infra"})
store.upsert_repository({"slug": "railiance-platform", "name": "Railiance Platform"})
rail_repo = tmp_path / "rail-kubernetes"
(rail_repo / "declarations").mkdir(parents=True)
(rail_repo / "declarations" / "rail.yaml").write_text(
"""
kind: execution-rail
rail_id: rail-kubernetes
repo: rail-kubernetes
ownership_repo: railiance-cluster
""".lstrip(),
encoding="utf-8",
)
rapp_repo = tmp_path / "rapp-openbao"
(rapp_repo / "declarations").mkdir(parents=True)
(rapp_repo / "declarations" / "rapp.yaml").write_text(
"""
kind: managed-workload-package
rapp_id: rapp-openbao
repo: rapp-openbao
ownership_repo: railiance-platform
primary_rail: rail-kubernetes
supported_rails:
- rail-kubernetes
""".lstrip(),
encoding="utf-8",
)
reef_repo = tmp_path / "reef-railiance"
(reef_repo / "declarations").mkdir(parents=True)
(reef_repo / "bindings").mkdir(parents=True)
(reef_repo / "declarations" / "reef.yaml").write_text(
"""
kind: substrate-reef
reef_id: reef-railiance
repo: reef-railiance
ownership_repo: railiance-infra
primary_rail: rail-kubernetes
""".lstrip(),
encoding="utf-8",
)
(reef_repo / "bindings" / "rails.yaml").write_text(
"""
reef_id: reef-railiance
hosted_rails:
- rail_id: rail-kubernetes
role: primary
""".lstrip(),
encoding="utf-8",
)
(reef_repo / "bindings" / "rapps.yaml").write_text(
"""
reef_id: reef-railiance
bound_rapps:
- rapp_id: rapp-openbao
status: approved
""".lstrip(),
encoding="utf-8",
)
store.upsert_repository(
{
"slug": "rail-kubernetes",
"name": "rail-kubernetes",
"path": str(rail_repo),
"repo_family": "rail",
"ownership_repo": "railiance-cluster",
"declaration_paths": [str(rail_repo / "declarations" / "rail.yaml")],
}
)
store.upsert_repository(
{
"slug": "rapp-openbao",
"name": "rapp-openbao",
"path": str(rapp_repo),
"repo_family": "rapp",
"ownership_repo": "railiance-platform",
"primary_rail": "rail-kubernetes",
"supported_rails": ["rail-kubernetes"],
"declaration_paths": [str(rapp_repo / "declarations" / "rapp.yaml")],
}
)
store.upsert_repository(
{
"slug": "reef-railiance",
"name": "reef-railiance",
"path": str(reef_repo),
"repo_family": "reef",
"ownership_repo": "railiance-infra",
"primary_rail": "rail-kubernetes",
"declaration_paths": [str(reef_repo / "declarations" / "reef.yaml")],
}
)
combined = store.combined_graph()
nodes = {node["id"]: node for node in combined["nodes"] if node["kind"] == "Repository"}
edges = {
(edge["from"], edge["type"], edge["to"]): edge
for edge in combined["edges"]
}
reef_record = store.get_repository("reef-railiance")
assert reef_record["path"] == str(reef_repo.resolve())
assert reef_record["declaration_paths"] == [str((reef_repo / "declarations" / "reef.yaml").resolve())]
assert nodes["repo:reef-railiance"]["attributes"]["source_path"].endswith("declarations/reef.yaml")
assert (
edges[("repo:rail-kubernetes", "governed_by", "repo:railiance-cluster")]["canonical_type"]
== "governed_by"
)
assert (
edges[("repo:rapp-openbao", "supports_rail", "repo:rail-kubernetes")]["canonical_type"]
== "depends_on"
)
assert (
edges[("repo:reef-railiance", "hosts_rail", "repo:rail-kubernetes")]["canonical_type"]
== "deploys"
)
reef_binding = edges[("repo:reef-railiance", "binds_rapp", "repo:rapp-openbao")]
assert reef_binding["canonical_type"] == "deploys"
assert any(
str(link.get("path") or "").endswith("bindings/rapps.yaml")
for link in reef_binding["attributes"]["source_links"]
)
def test_registry_http_service_serves_queries(tmp_path: Path) -> None:
store = RegistryStore(tmp_path / "registry.sqlite3")
store.init_schema()