Refactor provenance handling in EdgeDTO and graph utilities

- Updated provenance priorities and introduced a mapping from internal provenance values to EdgeDTO-compliant literals.
- Added a new function `normalize_provenance` to standardize internal provenance strings.
- Enhanced the `_edge` function to include an `is_internal` flag and provenance normalization.
- Modified the `EdgeDTO` model to include a new `source_hint` field for detailed provenance information and an `is_internal` flag for intra-note edges.
- Reduced the provenance options in `EdgeDTO` to valid literals, improving data integrity.
This commit is contained in:
Lars committed 2026-01-25 16:27:09 +01:00
1 parent 0d61a9e191
commit cc258008dc
9 files changed
+2337 -52

No files matched your search

+11 -9
View File
@@ -46,16 +46,18 @@ class EdgeDTO(BaseModel):
target: str
weight: float
direction: Literal["out", "in", "undirected"] = "out"
# WP-24c v4.5.3: Erweiterte Provenance-Werte für Chunk-Aware Edges
# Unterstützt alle tatsächlich verwendeten Provenance-Typen im System
provenance: Optional[Literal[
"explicit", "rule", "smart", "structure",
"explicit:callout", "explicit:wikilink", "explicit:note_zone", "explicit:note_scope",
"inline:rel", "callout:edge", "semantic_ai", "structure:belongs_to", "structure:order",
"derived:backlink", "edge_defaults", "global_pool"
]] = "explicit"
# WP-26 v1.0: Provenance auf valide Literale reduziert (EdgeDTO-Constraint)
# Detail-Informationen werden über source_hint transportiert
provenance: Optional[Literal["explicit", "rule", "smart", "structure"]] = "explicit"
# WP-26 v1.0: Neues Feld für Detail-Informationen zur Herkunft
source_hint: Optional[Literal[
"callout", "wikilink", "inline_rel", "schema_default", "note_scope",
"note_zone", "belongs_to", "order", "backlink", "edge_defaults", "global_pool"
]] = None
confidence: float = 1.0
target_section: Optional[str] = None
target_section: Optional[str] = None
# WP-26 v1.0: Flag für Intra-Note-Edges
is_internal: Optional[bool] = None
# --- Request Models ---