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

@@ -13,6 +13,7 @@ from urllib.parse import urlparse
import yaml
from .canon import edge_canon_mapping, evidence_state_for, node_canon_mapping, source_kind_from_anchor
from .connectors import ConnectorConfig, apply_connectors
from .discovery import (
attribute_stable_key,
@@ -158,12 +159,24 @@ class CandidateAccumulator:
attributes: dict[str, object] | None = None,
lifecycle: str | None = None,
domain: str | None = None,
evidence_state: str | None = None,
) -> dict[str, object]:
canon_mapping = node_canon_mapping(kind)
candidate: dict[str, object] = {
"stable_key": stable_key,
"kind": kind,
"label": label,
"repo": self.repo_slug,
"canon_category": canon_mapping.category,
"canon_anchor": canon_mapping.canon_anchor,
"mapping_fit": canon_mapping.fit,
"evidence_state": evidence_state
or evidence_state_for(
origin=origin,
source_kind=source_kind_from_anchor(source_anchor),
review_state=review_state,
confidence=confidence,
),
"origin": origin,
"review_state": review_state,
"status": status,
@@ -203,6 +216,8 @@ class CandidateAccumulator:
confidence: float = 0.8,
aliases: Iterable[str] = (),
attributes: dict[str, object] | None = None,
display_only: bool | None = None,
evidence_state: str | None = None,
) -> dict[str, object]:
stable_key = relationship_stable_key(
source_key,
@@ -210,9 +225,21 @@ class CandidateAccumulator:
target_key,
evidence_scope=replacement_scope,
)
canon_mapping = edge_canon_mapping(edge_type)
candidate: dict[str, object] = {
"stable_key": stable_key,
"edge_type": edge_type,
"canonical_type": canon_mapping.canonical_type,
"canon_anchor": canon_mapping.canon_anchor,
"mapping_fit": canon_mapping.fit,
"display_only": canon_mapping.display_only if display_only is None else display_only,
"evidence_state": evidence_state
or evidence_state_for(
origin=origin,
source_kind=source_kind_from_anchor(source_anchor),
review_state=review_state,
confidence=confidence,
),
"source_key": source_key,
"target_key": target_key,
"origin": origin,