refactoring for canon conformity

This commit is contained in:
2026-05-23 14:00:59 +02:00
parent 0193c97094
commit 653411ffb8
16 changed files with 819 additions and 29 deletions

View File

@@ -30,7 +30,10 @@ def test_scan_repo_emits_schema_valid_deterministic_snapshot(tmp_path: Path) ->
candidates = snapshot["candidates"]
nodes_by_label = {(node["kind"], node["label"]): node for node in candidates["nodes"]}
assert nodes_by_label[("Repository", "Fixture Repo")]["review_state"] == "candidate"
assert nodes_by_label[("Repository", "Fixture Repo")]["canon_category"] == "source-repository"
assert nodes_by_label[("Repository", "Fixture Repo")]["evidence_state"] == "declared"
assert nodes_by_label[("ServiceDeclaration", "Fixture API")]["review_state"] == "accepted"
assert nodes_by_label[("ServiceDeclaration", "Fixture API")]["canon_category"] == "service"
assert nodes_by_label[("Library", "fixture-service")]["attributes"]["language"] == "python"
assert nodes_by_label[("ExternalLibrary", "PyYAML")]["attributes"]["ecosystem"] == "python"
assert nodes_by_label[("DeploymentService", "api")]["attributes"]["orchestrator"] == "docker-compose"
@@ -45,10 +48,15 @@ def test_scan_repo_emits_schema_valid_deterministic_snapshot(tmp_path: Path) ->
nodes_by_label[("RuntimeService", "fixture-api.testing.svc.cluster.local")]["attributes"]["runtime_target_type"]
== "kubernetes-service-dns"
)
assert (
nodes_by_label[("RuntimeService", "fixture-api.testing.svc.cluster.local")]["canon_category"]
== "runtime-resource"
)
assert (
nodes_by_label[("ApplicationEndpoint", "declared.fixture.test")]["attributes"]["runtime_target_type"]
== "declared-endpoint"
)
assert nodes_by_label[("ApplicationEndpoint", "declared.fixture.test")]["canon_category"] == "endpoint"
assert nodes_by_label[("NetworkPort", "127.0.0.1:8080/tcp")]["attributes"]["target_port"] == 8080
assert nodes_by_label[("NetworkPort", "fixture-api.testing.svc.cluster.local:8080/tcp")]["attributes"]["service_port"] == 8080
assert nodes_by_label[("NetworkPort", "declared.fixture.test:9443/tcp")]["attributes"]["scheme"] == "https"
@@ -76,6 +84,14 @@ def test_scan_repo_emits_schema_valid_deterministic_snapshot(tmp_path: Path) ->
"routes_to_service",
"resolves_to",
}
edges_by_type = {edge["edge_type"]: edge for edge in candidates["edges"]}
assert edges_by_type["exposes"]["canonical_type"] == "exposes"
assert edges_by_type["provides"]["canonical_type"] == "implements"
assert edges_by_type["provides"]["mapping_fit"] == "partial"
assert edges_by_type["opens_port"]["canonical_type"] == "exposes"
assert edges_by_type["resolves_to"]["canonical_type"] == "flows_to"
assert all(edge["display_only"] is False for edge in candidates["edges"])
assert all(edge["evidence_state"] in {"declared", "observed", "inferred", "proposed", "gap"} for edge in candidates["edges"])
assert {attribute["name"] for attribute in candidates["attributes"]} >= {
"readme_title",
"intent_present",