Project repo-family relations from local declarations
This commit is contained in:
parent
1d8f59f1de
commit
9af9ee3e72
13 changed files with 671 additions and 28 deletions
|
|
@ -56,6 +56,9 @@ def test_legacy_fabric_terms_map_without_becoming_display_edges() -> None:
|
|||
assert edge_canon_mapping("exposes").canonical_type == "exposes"
|
||||
assert edge_canon_mapping("provides").canonical_type == "implements"
|
||||
assert edge_canon_mapping("binds:exact").canonical_type == "depends_on"
|
||||
assert edge_canon_mapping("supports_rail").canonical_type == "depends_on"
|
||||
assert edge_canon_mapping("hosts_rail").canonical_type == "deploys"
|
||||
assert edge_canon_mapping("binds_rapp").canonical_type == "deploys"
|
||||
assert edge_canon_mapping("resolves_to").canonical_type == "flows_to"
|
||||
assert edge_canon_mapping("declares").display_only is True
|
||||
|
||||
|
|
|
|||
|
|
@ -159,6 +159,59 @@ def test_graph_explorer_collapses_discovered_repository_nodes() -> None:
|
|||
assert declares_package["data"]["displayOnly"] is False
|
||||
|
||||
|
||||
def test_graph_explorer_surfaces_repository_source_references() -> None:
|
||||
graph = {
|
||||
"apiVersion": "railiance.fabric/v1alpha1",
|
||||
"kind": "FabricGraphExport",
|
||||
"generated_at": "2026-07-26T00:00:00Z",
|
||||
"source": {"repo": "fixture-repo", "commit": "abc123"},
|
||||
"nodes": [
|
||||
{
|
||||
"id": "repo:fixture-repo",
|
||||
"kind": "Repository",
|
||||
"name": "Fixture Repo",
|
||||
"repo": "fixture-repo",
|
||||
"domain": "testing",
|
||||
"lifecycle": "active",
|
||||
"attributes": {
|
||||
"source_path": "/tmp/fixture-repo/declarations/rapp.yaml",
|
||||
"source_links": [
|
||||
{
|
||||
"label": "Rapp declaration",
|
||||
"path": "/tmp/fixture-repo/declarations/rapp.yaml",
|
||||
}
|
||||
],
|
||||
},
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
}
|
||||
|
||||
payload = fabric_graph_explorer_payload(
|
||||
graph,
|
||||
[{"slug": "fixture-repo", "name": "Fixture Repo", "repo_family": "rapp"}],
|
||||
{"fixture-repo"},
|
||||
)
|
||||
|
||||
repository_node = next(
|
||||
element
|
||||
for element in payload["elements"]
|
||||
if element["data"].get("id") == "repo:fixture-repo"
|
||||
and "source" not in element["data"]
|
||||
)
|
||||
|
||||
assert repository_node["data"]["sourceReferences"] == [
|
||||
{
|
||||
"label": "Declaration",
|
||||
"path": "/tmp/fixture-repo/declarations/rapp.yaml",
|
||||
},
|
||||
{
|
||||
"label": "Rapp declaration",
|
||||
"path": "/tmp/fixture-repo/declarations/rapp.yaml",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def test_graph_explorer_presents_legacy_server_nodes_as_runtime_entities() -> None:
|
||||
graph = {
|
||||
"apiVersion": "railiance.fabric/v1alpha1",
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue