neue hash-wert berechnung
This commit is contained in:
1 parent
6011b96fc1
commit
156c2c2fd5
4 files changed
+61
-32
No files matched your search
+16
-7
@@ -1,11 +1,10 @@
|
||||
"""
|
||||
FILE: app/core/ingestion.py
|
||||
DESCRIPTION: Haupt-Ingestion-Logik. Liest Markdown, prüft Hashes (Change Detection), zerlegt in Chunks und schreibt in Qdrant.
|
||||
VERSION: 2.5.2
|
||||
VERSION: 2.5.3 (Fix: Hash-Mode Full for Metadata Detection)
|
||||
STATUS: Active
|
||||
DEPENDENCIES: app.core.parser, app.core.note_payload, app.core.chunker, app.core.derive_edges, app.core.qdrant*, app.services.embeddings_client
|
||||
EXTERNAL_CONFIG: config/types.yaml
|
||||
LAST_ANALYSIS: 2025-12-15
|
||||
"""
|
||||
import os
|
||||
import logging
|
||||
@@ -94,7 +93,8 @@ class IngestionService:
|
||||
apply: bool = False,
|
||||
purge_before: bool = False,
|
||||
note_scope_refs: bool = False,
|
||||
hash_mode: str = "body",
|
||||
# FIX: Default auf "full", damit Metadata-Änderungen erkannt werden
|
||||
hash_mode: str = "full",
|
||||
hash_source: str = "parsed",
|
||||
hash_normalize: str = "canonical"
|
||||
) -> Dict[str, Any]:
|
||||
@@ -150,17 +150,27 @@ class IngestionService:
|
||||
logger.error(f"Payload build failed: {e}")
|
||||
return {**result, "error": f"Payload build failed: {str(e)}"}
|
||||
|
||||
# 4. Change Detection (Das fehlende Stück!)
|
||||
# 4. Change Detection (Updated Logic)
|
||||
old_payload = None
|
||||
if not force_replace:
|
||||
old_payload = self._fetch_note_payload(note_id)
|
||||
|
||||
has_old = old_payload is not None
|
||||
key_current = f"{hash_mode}:{hash_source}:{hash_normalize}"
|
||||
old_hash = (old_payload or {}).get("hashes", {}).get(key_current)
|
||||
|
||||
# Robustere Abfrage: Falls 'hashes' im Payload fehlt, None zurückgeben
|
||||
old_hashes = (old_payload or {}).get("hashes")
|
||||
if isinstance(old_hashes, dict):
|
||||
old_hash = old_hashes.get(key_current)
|
||||
else:
|
||||
# Fallback für Legacy Payloads ohne Hash-Dict
|
||||
old_hash = None
|
||||
|
||||
new_hash = note_pl.get("hashes", {}).get(key_current)
|
||||
|
||||
# Wenn wir keinen alten Hash haben (z.B. neues Hash-Schema "full"), erzwingen wir Update
|
||||
hash_changed = (old_hash != new_hash)
|
||||
|
||||
chunks_missing, edges_missing = self._artifacts_missing(note_id)
|
||||
|
||||
should_write = force_replace or (not has_old) or hash_changed or chunks_missing or edges_missing
|
||||
@@ -177,7 +187,6 @@ class IngestionService:
|
||||
|
||||
# --- Config Loading (Clean) ---
|
||||
chunk_config = get_chunk_config(note_type)
|
||||
# Hier greift die Logik aus types.yaml (smart=True/False)
|
||||
|
||||
chunks = await assemble_chunks(fm["id"], body_text, fm["type"], config=chunk_config)
|
||||
chunk_pls = make_chunk_payloads(fm, note_pl["path"], chunks, note_text=body_text)
|
||||
@@ -240,7 +249,7 @@ class IngestionService:
|
||||
logger.error(f"Upsert failed: {e}", exc_info=True)
|
||||
return {**result, "error": f"DB Upsert failed: {e}"}
|
||||
|
||||
# --- Qdrant Helper (Restored) ---
|
||||
# --- Qdrant Helper ---
|
||||
|
||||
def _fetch_note_payload(self, note_id: str) -> Optional[dict]:
|
||||
from qdrant_client.http import models as rest
|
||||
|
||||
Reference in new issue
Block a user