feat: add deployment zone overlays

This commit is contained in:
2026-05-24 15:55:05 +02:00
parent 62236f6453
commit ff1c4ce05b
28 changed files with 1282 additions and 26 deletions

View File

@@ -11,6 +11,7 @@ from datetime import datetime, timezone
from pathlib import Path
from typing import Any
from .deployment_overlay import normalize_deployment_overlay
from .discovery import normalize_identity_part, short_fingerprint
from .loader import load_yaml, repo_root
from .schema_validation import draft202012_validator
@@ -619,7 +620,7 @@ def _identity_from_evidence(root: dict[str, Any], item: dict[str, Any]) -> dict[
or declared_slug
or Path(str(source.get("path") or "")).name
)
return {
candidate = {
"identity_type": "Repository",
"label": identity_slug,
"graph_id": identity_slug,
@@ -635,6 +636,10 @@ def _identity_from_evidence(root: dict[str, Any], item: dict[str, Any]) -> dict[
},
"confidence": 0.9 if evidence_type == "repository_checkout" else 0.85,
}
overlay = normalize_deployment_overlay(source, attributes)
if overlay:
candidate["deployment_overlay"] = overlay
return candidate
if evidence_type in {"deployment_automation", "infrastructure_manifest"}:
path = str(source.get("path") or "")
return {
@@ -665,7 +670,7 @@ def _identity_from_evidence(root: dict[str, Any], item: dict[str, Any]) -> dict[
}
if evidence_type == "endpoint_contract":
path = str(source.get("path") or "")
return {
candidate = {
"identity_type": "Endpoint",
"label": Path(path).name or "endpoint-contract",
"graph_id": path,
@@ -677,6 +682,10 @@ def _identity_from_evidence(root: dict[str, Any], item: dict[str, Any]) -> dict[
"attributes": {**attributes, "source_evidence_type": evidence_type},
"confidence": 0.75,
}
overlay = normalize_deployment_overlay(source, attributes)
if overlay:
candidate["deployment_overlay"] = overlay
return candidate
if evidence_type == "host_path_match":
path = str(source.get("path") or "")
return {
@@ -901,6 +910,7 @@ def _add_identity_candidate(
evidence_ids: list[str],
aliases: list[str],
attributes: dict[str, Any],
deployment_overlay: dict[str, Any] | None = None,
confidence: float,
) -> None:
normalized_type = normalize_identity_part(identity_type)
@@ -924,6 +934,9 @@ def _add_identity_candidate(
incoming["subfabric_id"] = subfabric_id
if owner_actor_id:
incoming["owner_actor_id"] = owner_actor_id
overlay = normalize_deployment_overlay(deployment_overlay or {}, attributes)
if overlay:
incoming["deployment_overlay"] = overlay
existing = candidates.get(stable_key)
if existing is None:
@@ -933,6 +946,11 @@ def _add_identity_candidate(
existing["aliases"] = _unique_strings([*existing.get("aliases", []), *incoming["aliases"]])
existing["evidence_ids"] = _unique_strings([*existing.get("evidence_ids", []), *incoming["evidence_ids"]])
existing["attributes"] = {**existing.get("attributes", {}), **incoming["attributes"]}
if incoming.get("deployment_overlay"):
existing["deployment_overlay"] = normalize_deployment_overlay(
existing.get("deployment_overlay") if isinstance(existing.get("deployment_overlay"), dict) else {},
incoming["deployment_overlay"],
)
if incoming.get("owner_actor_id") and existing.get("owner_actor_id") and incoming["owner_actor_id"] != existing["owner_actor_id"]:
existing["attributes"]["ambiguous_owner_actor_ids"] = _unique_strings(
[existing["owner_actor_id"], incoming["owner_actor_id"], *existing["attributes"].get("ambiguous_owner_actor_ids", [])]
@@ -973,6 +991,7 @@ def _candidate_graph(candidates: list[dict[str, Any]], manifest: dict[str, Any])
"fabric_id": candidate.get("fabric_id", ""),
"subfabric_id": candidate.get("subfabric_id", ""),
"owner_actor_id": candidate.get("owner_actor_id", ""),
"deployment_overlay": candidate.get("deployment_overlay", {}),
}
for candidate in sorted(candidates, key=lambda item: item["stable_key"])
]