Refine LLM validation zone handling in graph_derive_edges.py
Enhance the extraction logic to store the zone status before header updates, ensuring accurate context during callout processing. Initialize the all_chunk_callout_keys set prior to its usage to prevent potential UnboundLocalError. These improvements contribute to more reliable edge construction and better handling of LLM validation zones.
This commit is contained in:
parent
ea0fd951f2
commit
f2a2f4d2df
|
|
@ -321,13 +321,17 @@ def extract_callouts_from_markdown(
|
|||
|
||||
if header_match:
|
||||
header_text = header_match.group(1).strip()
|
||||
# WP-24c v4.5.7: Speichere Zonen-Status VOR der Aktualisierung
|
||||
# (für Callout-Blöcke, die vor diesem Header enden)
|
||||
zone_before_header = current_zone_is_llm_validation
|
||||
|
||||
# Prüfe, ob dieser Header eine LLM-Validierungs-Zone startet
|
||||
# WP-24c v4.5.6: Header-Status-Maschine - korrekte Zonen-Erkennung
|
||||
current_zone_is_llm_validation = any(
|
||||
header_text.lower() == llm_header.lower()
|
||||
for llm_header in llm_validation_headers
|
||||
)
|
||||
logger.debug(f"DEBUG-TRACER [Zone-Change]: Header '{header_text}' (Level {llm_validation_level}) -> LLM-Validierung: {current_zone_is_llm_validation}")
|
||||
logger.debug(f"DEBUG-TRACER [Zone-Change]: Header '{header_text}' (Level {llm_validation_level}) -> LLM-Validierung: {current_zone_is_llm_validation} (vorher: {zone_before_header})")
|
||||
# Beende aktuellen Callout-Block bei Header-Wechsel
|
||||
if in_callout_block:
|
||||
# Verarbeite gesammelten Callout-Block VOR dem Zonen-Wechsel
|
||||
|
|
@ -337,7 +341,6 @@ def extract_callouts_from_markdown(
|
|||
|
||||
# Verarbeite jeden Callout mit Zonen-Kontext
|
||||
# WICHTIG: Verwende den Zonen-Status VOR dem Header-Wechsel
|
||||
zone_before_header = current_zone_is_llm_validation
|
||||
|
||||
for k, raw_t in block_call_pairs:
|
||||
t, sec = parse_link_target(raw_t, note_id)
|
||||
|
|
@ -525,6 +528,10 @@ def build_edges_for_note(
|
|||
# note_type für die Ermittlung der edge_defaults (types.yaml)
|
||||
note_type = _get(chunks[0], "type") if chunks else "concept"
|
||||
|
||||
# WP-24c v4.5.7: Initialisiere all_chunk_callout_keys VOR jeder Verwendung
|
||||
# Dies verhindert UnboundLocalError, wenn LLM-Validierungs-Zonen vor Phase 1 verarbeitet werden
|
||||
all_chunk_callout_keys: Set[Tuple[str, str, Optional[str]]] = set()
|
||||
|
||||
# WP-24c v4.2.0: Note-Scope Zonen Extraktion (VOR Chunk-Verarbeitung)
|
||||
# WP-24c v4.5.6: Separate Behandlung von LLM-Validierungs-Zonen
|
||||
note_scope_edges: List[dict] = []
|
||||
|
|
@ -644,9 +651,8 @@ def build_edges_for_note(
|
|||
defaults = get_edge_defaults_for(note_type, reg)
|
||||
refs_all: List[str] = []
|
||||
|
||||
# WP-24c v4.2.9 Fix B: Zwei-Phasen-Synchronisation für Chunk-Autorität
|
||||
# WICHTIG: Diese Menge muss VOR dem globalen Scan vollständig sein
|
||||
all_chunk_callout_keys: Set[Tuple[str, str, Optional[str]]] = set()
|
||||
# WP-24c v4.5.7: all_chunk_callout_keys wurde bereits oben initialisiert
|
||||
# (Zeile 530) - keine erneute Initialisierung nötig
|
||||
|
||||
# PHASE 1 (Sicherung der Chunk-Autorität): Sammle alle Callout-Keys aus candidate_pool
|
||||
# BEVOR der globale Markdown-Scan oder der Loop über die Chunks beginnt
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user