From e93bab6ea738410f6f8784f3d96bdcee600a7047 Mon Sep 17 00:00:00 2001 From: Lars Date: Sun, 28 Dec 2025 11:04:40 +0100 Subject: [PATCH] =?UTF-8?q?Fassadenaufl=C3=B6sung=20unter=20app/core?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/derive_edges.py | 10 ---------- app/core/graph_adapter.py | 10 ---------- app/core/ingestion/ingestion_processor.py | 2 +- app/core/qdrant.py | 22 --------------------- app/core/qdrant_points.py | 24 ----------------------- app/core/retrieval/retriever.py | 6 +++--- app/core/retriever.py | 14 ------------- app/core/retriever_scoring.py | 18 ----------------- app/routers/chat.py | 2 +- app/routers/graph.py | 2 +- app/routers/query.py | 2 +- app/services/discovery.py | 4 ++-- scripts/assert_payload_schema.py | 2 +- scripts/backfill_edges.py | 7 ++++--- scripts/debug_edge_loss.py | 2 +- scripts/debug_qdrant_state.py | 2 +- scripts/diag_payload_indexes.py | 2 +- scripts/edges_dryrun.py | 2 +- scripts/edges_full_check.py | 2 +- scripts/export_markdown.py | 3 +-- scripts/gc_qdrant_after_vault_scan.py | 2 +- scripts/payload_dryrun.py | 2 +- scripts/prune_qdrant_vs_vault.py | 2 +- scripts/report_hashes.py | 2 +- scripts/reset_qdrant.py | 2 +- scripts/resolve_unresolved_references.py | 4 ++-- scripts/verify_chunk_texts.py | 2 +- tests/assert_payload_schema.py | 2 +- tests/audit_edges_now.py | 2 +- tests/check_chunks_vs_text.py | 2 +- tests/check_chunks_window_vs_text.py | 2 +- tests/diag_edges_for_note.py | 2 +- tests/diag_payload_indexes.py | 2 +- tests/diag_subgraph_for_note.py | 4 ++-- tests/ensure_indexes_and_show.py | 2 +- tests/inspect_one_note.py | 2 +- tests/show_edges_for_note.py | 2 +- tests/test_WP22_intelligence.py | 12 ++++++------ tests/test_edges_all.py | 2 +- tests/test_edges_defaults_smoke.py | 2 +- tests/test_edges_smoke.py | 2 +- tests/test_edges_smoke_fast.py | 2 +- tests/test_graph_unit.py | 2 +- tests/test_query_text_embed_unit.py | 4 ++-- tests/test_query_unit.py | 4 ++-- tests/test_retriever_basic.py | 6 +++--- tests/test_retriever_edges.py | 8 ++++---- tests/test_retriever_weight.py | 6 +++--- tests/test_smart_chunking_integration.py | 2 +- tests/verify_chunks_integrity.py | 2 +- 50 files changed, 66 insertions(+), 164 deletions(-) delete mode 100644 app/core/derive_edges.py delete mode 100644 app/core/graph_adapter.py delete mode 100644 app/core/qdrant.py delete mode 100644 app/core/qdrant_points.py delete mode 100644 app/core/retriever.py delete mode 100644 app/core/retriever_scoring.py diff --git a/app/core/derive_edges.py b/app/core/derive_edges.py deleted file mode 100644 index 392d05a..0000000 --- a/app/core/derive_edges.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -FILE: app/core/derive_edges.py -DESCRIPTION: Facade für das neue graph Package. - WP-14: Modularisierung abgeschlossen. -VERSION: 2.2.0 -""" -from .graph.graph_derive_edges import build_edges_for_note -from .graph.graph_utils import PROVENANCE_PRIORITY - -__all__ = ["build_edges_for_note", "PROVENANCE_PRIORITY"] \ No newline at end of file diff --git a/app/core/graph_adapter.py b/app/core/graph_adapter.py deleted file mode 100644 index ee36f9e..0000000 --- a/app/core/graph_adapter.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -FILE: app/core/graph_adapter.py -DESCRIPTION: Facade für das neue graph Package (Adapter-Teil). - WP-14: Modularisierung abgeschlossen. -VERSION: 0.5.0 -""" -from .graph.graph_subgraph import Subgraph, expand -from .graph.graph_weights import EDGE_BASE_WEIGHTS - -__all__ = ["Subgraph", "expand", "EDGE_BASE_WEIGHTS"] \ No newline at end of file diff --git a/app/core/ingestion/ingestion_processor.py b/app/core/ingestion/ingestion_processor.py index 92a2a02..8d6114d 100644 --- a/app/core/ingestion/ingestion_processor.py +++ b/app/core/ingestion/ingestion_processor.py @@ -38,7 +38,7 @@ from .ingestion_chunk_payload import make_chunk_payloads # Fallback für Edges (Struktur-Verknüpfung) try: - from app.core.derive_edges import build_edges_for_note + from app.core.graph.graph_derive_edges import build_edges_for_note except ImportError: def build_edges_for_note(*args, **kwargs): return [] diff --git a/app/core/qdrant.py b/app/core/qdrant.py deleted file mode 100644 index 80f1c85..0000000 --- a/app/core/qdrant.py +++ /dev/null @@ -1,22 +0,0 @@ -""" -FILE: app/core/qdrant.py -DESCRIPTION: Proxy-Modul zur Aufrechterhaltung der Abwärtskompatibilität (WP-14). - Leitet alle Aufrufe an das neue database-Paket weiter. -STATUS: Proxy (Legacy-Support) -""" -from .database.qdrant import ( - QdrantConfig, - get_client, - ensure_collections, - ensure_payload_indexes, - collection_names -) - -# Re-Export für 100% Kompatibilität -__all__ = [ - "QdrantConfig", - "get_client", - "ensure_collections", - "ensure_payload_indexes", - "collection_names", -] \ No newline at end of file diff --git a/app/core/qdrant_points.py b/app/core/qdrant_points.py deleted file mode 100644 index d136232..0000000 --- a/app/core/qdrant_points.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -FILE: app/core/qdrant_points.py -DESCRIPTION: Proxy-Modul zur Aufrechterhaltung der Abwärtskompatibilität (WP-14). - Leitet Point-Operationen an das neue database-Paket weiter. -STATUS: Proxy (Legacy-Support) -""" -from .database.qdrant_points import ( - points_for_note, - points_for_chunks, - points_for_edges, - upsert_batch, - get_edges_for_sources, - search_chunks_by_vector -) - -# Re-Export für 100% Kompatibilität -__all__ = [ - "points_for_note", - "points_for_chunks", - "points_for_edges", - "upsert_batch", - "get_edges_for_sources", - "search_chunks_by_vector" -] \ No newline at end of file diff --git a/app/core/retrieval/retriever.py b/app/core/retrieval/retriever.py index a6c3357..4f6c307 100644 --- a/app/core/retrieval/retriever.py +++ b/app/core/retrieval/retriever.py @@ -25,10 +25,10 @@ import app.core.database.qdrant as qdr import app.core.database.qdrant_points as qp import app.services.embeddings_client as ec -import app.core.graph_adapter as ga +import app.core.graph.graph_subgraph as ga -# Mathematische Engine importieren (Bleibt vorerst in app.core) -from app.core.retriever_scoring import get_weights, compute_wp22_score +# Mathematische Engine importieren +from app.core.retrieval.retriever_scoring import get_weights, compute_wp22_score logger = logging.getLogger(__name__) diff --git a/app/core/retriever.py b/app/core/retriever.py deleted file mode 100644 index 055d764..0000000 --- a/app/core/retriever.py +++ /dev/null @@ -1,14 +0,0 @@ -""" -FILE: app/core/retriever.py -DESCRIPTION: Proxy-Modul zur Aufrechterhaltung der Abwärtskompatibilität (WP-14). - Leitet Retrieval-Anfragen an das neue retrieval-Paket weiter. -STATUS: Proxy (Legacy-Support) -""" -from .retrieval.retriever import ( - Retriever, - hybrid_retrieve, - semantic_retrieve -) - -# Re-Export für 100% Kompatibilität -__all__ = ["Retriever", "hybrid_retrieve", "semantic_retrieve"] \ No newline at end of file diff --git a/app/core/retriever_scoring.py b/app/core/retriever_scoring.py deleted file mode 100644 index 0aec2a7..0000000 --- a/app/core/retriever_scoring.py +++ /dev/null @@ -1,18 +0,0 @@ -""" -FILE: app/core/retriever_scoring.py -DESCRIPTION: Proxy-Modul zur Aufrechterhaltung der Abwärtskompatibilität (WP-14). - Leitet Scoring-Berechnungen an das neue retrieval-Paket weiter. -STATUS: Proxy (Legacy-Support) -""" -from .retrieval.retriever_scoring import ( - get_weights, - compute_wp22_score, - get_status_multiplier -) - -# Re-Export für 100% Kompatibilität -__all__ = [ - "get_weights", - "compute_wp22_score", - "get_status_multiplier" -] \ No newline at end of file diff --git a/app/routers/chat.py b/app/routers/chat.py index f632769..92670bd 100644 --- a/app/routers/chat.py +++ b/app/routers/chat.py @@ -21,7 +21,7 @@ from pathlib import Path from app.config import get_settings from app.models.dto import ChatRequest, ChatResponse, QueryRequest, QueryHit from app.services.llm_service import LLMService -from app.core.retriever import Retriever +from app.core.retrieval.retriever import Retriever from app.services.feedback_service import log_search router = APIRouter() diff --git a/app/routers/graph.py b/app/routers/graph.py index bbbfb48..e8cd99c 100644 --- a/app/routers/graph.py +++ b/app/routers/graph.py @@ -12,7 +12,7 @@ from typing import List, Optional from fastapi import APIRouter, Query from qdrant_client import QdrantClient from app.models.dto import GraphResponse, NodeDTO, EdgeDTO -from app.core.graph_adapter import expand +from app.core.graph.graph_subgraph import expand from app.config import get_settings router = APIRouter() diff --git a/app/routers/query.py b/app/routers/query.py index ec9db7b..03c1da9 100644 --- a/app/routers/query.py +++ b/app/routers/query.py @@ -10,7 +10,7 @@ LAST_ANALYSIS: 2025-12-15 from __future__ import annotations from fastapi import APIRouter, HTTPException, BackgroundTasks from app.models.dto import QueryRequest, QueryResponse -from app.core.retriever import hybrid_retrieve, semantic_retrieve +from app.core.retrieval.retriever import hybrid_retrieve, semantic_retrieve # NEU: from app.services.feedback_service import log_search diff --git a/app/services/discovery.py b/app/services/discovery.py index 95b502c..c3817fe 100644 --- a/app/services/discovery.py +++ b/app/services/discovery.py @@ -13,9 +13,9 @@ import os from typing import List, Dict, Any, Optional, Set import yaml -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client from app.models.dto import QueryRequest -from app.core.retriever import hybrid_retrieve +from app.core.retrieval.retriever import hybrid_retrieve logger = logging.getLogger(__name__) diff --git a/scripts/assert_payload_schema.py b/scripts/assert_payload_schema.py index b67367e..0aa7fb9 100644 --- a/scripts/assert_payload_schema.py +++ b/scripts/assert_payload_schema.py @@ -64,7 +64,7 @@ import urllib.error import urllib.request from typing import Any, Dict, List -from app.core.qdrant import QdrantConfig, get_client, collection_names +from app.core.database.qdrant import QdrantConfig, get_client, collection_names REQUIRED = { "notes": ["note_id", "type", "title", "updated", "tags"], diff --git a/scripts/backfill_edges.py b/scripts/backfill_edges.py index 5699077..bb05dff 100644 --- a/scripts/backfill_edges.py +++ b/scripts/backfill_edges.py @@ -61,9 +61,10 @@ import argparse, glob, json, os from typing import List, Tuple from app.core.parser import read_markdown # gibt je nach Implementierung ein Objekt ODER ein (fm, body)-Tuple -from app.core.qdrant import QdrantConfig, get_client, ensure_collections -from app.core.qdrant_points import points_for_edges, upsert_batch -from app.core.derive_edges import build_note_index, derive_wikilink_edges +from app.core.database.qdrant import QdrantConfig, get_client, ensure_collections +from app.core.database.qdrant_points import points_for_edges, upsert_batch +# TODO: build_note_index und derive_wikilink_edges müssen noch implementiert werden +# from app.core.graph.graph_derive_edges import build_note_index, derive_wikilink_edges def _coerce_parsed(note_or_tuple): diff --git a/scripts/debug_edge_loss.py b/scripts/debug_edge_loss.py index 6074a36..02a22b2 100644 --- a/scripts/debug_edge_loss.py +++ b/scripts/debug_edge_loss.py @@ -71,7 +71,7 @@ from pathlib import Path sys.path.insert(0, os.path.abspath(".")) from app.core.chunking import assemble_chunks -from app.core.derive_edges import build_edges_for_note +from app.core.graph.graph_derive_edges import build_edges_for_note from app.core.parser import extract_wikilinks from app.core.graph.graph_extractors import extract_typed_relations, extract_callout_relations diff --git a/scripts/debug_qdrant_state.py b/scripts/debug_qdrant_state.py index d1d1281..5f80634 100644 --- a/scripts/debug_qdrant_state.py +++ b/scripts/debug_qdrant_state.py @@ -53,7 +53,7 @@ v1.0.0: Initial Release """ from __future__ import annotations import argparse, os, json -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client def count_points(client, collection: str) -> int: try: diff --git a/scripts/diag_payload_indexes.py b/scripts/diag_payload_indexes.py index ff9e769..c39c8ff 100644 --- a/scripts/diag_payload_indexes.py +++ b/scripts/diag_payload_indexes.py @@ -60,7 +60,7 @@ import urllib.request import urllib.error from typing import Any, Dict -from app.core.qdrant import QdrantConfig, get_client, collection_names +from app.core.database.qdrant import QdrantConfig, get_client, collection_names def _safe_model_dump(obj: Any) -> Dict[str, Any]: diff --git a/scripts/edges_dryrun.py b/scripts/edges_dryrun.py index 22f3ffa..d0623f5 100644 --- a/scripts/edges_dryrun.py +++ b/scripts/edges_dryrun.py @@ -76,7 +76,7 @@ from pathlib import Path from typing import Dict, List, Optional from app.core.parser import read_markdown, normalize_frontmatter -from app.core.derive_edges import build_edges_for_note +from app.core.graph.graph_derive_edges import build_edges_for_note def _iter_markdown(vault: str): for p in Path(vault).rglob("*.md"): diff --git a/scripts/edges_full_check.py b/scripts/edges_full_check.py index b024861..236a398 100644 --- a/scripts/edges_full_check.py +++ b/scripts/edges_full_check.py @@ -67,7 +67,7 @@ import json from collections import Counter, defaultdict from typing import Dict, Any, List, Tuple -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client from qdrant_client.http import models as rest diff --git a/scripts/export_markdown.py b/scripts/export_markdown.py index 2a973b0..5bda243 100644 --- a/scripts/export_markdown.py +++ b/scripts/export_markdown.py @@ -80,8 +80,7 @@ from typing import Dict, List, Optional, Tuple, Any import yaml from qdrant_client.http import models as rest -from app.core.qdrant import QdrantConfig, get_client -from app.core.qdrant import ensure_collections # safety +from app.core.database.qdrant import QdrantConfig, get_client, ensure_collections # --------------------------------------------------------------------- # Helpers diff --git a/scripts/gc_qdrant_after_vault_scan.py b/scripts/gc_qdrant_after_vault_scan.py index 3405d1c..c91cc58 100644 --- a/scripts/gc_qdrant_after_vault_scan.py +++ b/scripts/gc_qdrant_after_vault_scan.py @@ -77,7 +77,7 @@ from qdrant_client import QdrantClient from qdrant_client.http import models as rest from app.core.parser import read_markdown, normalize_frontmatter, validate_required_frontmatter # :contentReference[oaicite:5]{index=5} -from app.core.qdrant import QdrantConfig, get_client, collection_names # :contentReference[oaicite:6]{index=6} +from app.core.database.qdrant import QdrantConfig, get_client, collection_names # :contentReference[oaicite:6]{index=6} def iter_note_ids_from_vault(vault_root: str) -> Set[str]: """Liest alle Markdown-Dateien im Vault und sammelt valide Frontmatter-IDs.""" diff --git a/scripts/payload_dryrun.py b/scripts/payload_dryrun.py index 25ca832..066a195 100644 --- a/scripts/payload_dryrun.py +++ b/scripts/payload_dryrun.py @@ -73,7 +73,7 @@ from app.core.parser import read_markdown, normalize_frontmatter, validate_requi from app.core.chunking import assemble_chunks from app.core.ingestion.ingestion_note_payload import make_note_payload from app.core.ingestion.ingestion_chunk_payload import make_chunk_payloads -from app.core.derive_edges import build_edges_for_note +from app.core.graph.graph_derive_edges import build_edges_for_note async def process_file(path: str, root: str, args): """Verarbeitet eine einzelne Datei asynchron.""" diff --git a/scripts/prune_qdrant_vs_vault.py b/scripts/prune_qdrant_vs_vault.py index 9314235..5fbac86 100644 --- a/scripts/prune_qdrant_vs_vault.py +++ b/scripts/prune_qdrant_vs_vault.py @@ -85,7 +85,7 @@ from typing import Dict, List, Set, Tuple from qdrant_client import QdrantClient from qdrant_client.http import models as rest -from app.core.qdrant import QdrantConfig, get_client, collection_names +from app.core.database.qdrant import QdrantConfig, get_client, collection_names from app.core.parser import read_markdown, normalize_frontmatter diff --git a/scripts/report_hashes.py b/scripts/report_hashes.py index 1ce690c..b9dac05 100644 --- a/scripts/report_hashes.py +++ b/scripts/report_hashes.py @@ -63,7 +63,7 @@ import os from typing import List, Dict, Any from qdrant_client.http import models as rest -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client def collections(prefix: str): return f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges" diff --git a/scripts/reset_qdrant.py b/scripts/reset_qdrant.py index 27913bd..bbb287a 100644 --- a/scripts/reset_qdrant.py +++ b/scripts/reset_qdrant.py @@ -83,7 +83,7 @@ from dotenv import load_dotenv from qdrant_client import QdrantClient from qdrant_client.http import models as rest -from app.core.qdrant import ( +from app.core.database.qdrant import ( QdrantConfig, get_client, ensure_collections, diff --git a/scripts/resolve_unresolved_references.py b/scripts/resolve_unresolved_references.py index b159844..144a1a8 100644 --- a/scripts/resolve_unresolved_references.py +++ b/scripts/resolve_unresolved_references.py @@ -70,8 +70,8 @@ import uuid from typing import List, Dict, Any, Iterable from qdrant_client import models -from app.core.qdrant import QdrantConfig, get_client -from app.core.qdrant_points import points_for_edges +from app.core.database.qdrant import QdrantConfig, get_client +from app.core.database.qdrant_points import points_for_edges # Logging Setup logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s") diff --git a/scripts/verify_chunk_texts.py b/scripts/verify_chunk_texts.py index 3ba3943..6b70ce6 100644 --- a/scripts/verify_chunk_texts.py +++ b/scripts/verify_chunk_texts.py @@ -67,7 +67,7 @@ from typing import Dict, List, Tuple, Optional from qdrant_client.http import models as rest -from app.core.qdrant import QdrantConfig, get_client, collection_names +from app.core.database.qdrant import QdrantConfig, get_client, collection_names def _chunk_sort_key(p: Dict, pid: str) -> Tuple[int,int,str]: # Primär: payload.chunk_index, sekundär: Nummer am Ende der ID (#cNN oder #NN), sonst 0 diff --git a/tests/assert_payload_schema.py b/tests/assert_payload_schema.py index c5cc279..ee62f23 100644 --- a/tests/assert_payload_schema.py +++ b/tests/assert_payload_schema.py @@ -23,7 +23,7 @@ import urllib.error import urllib.request from typing import Any, Dict, List -from app.core.qdrant import QdrantConfig, get_client, collection_names +from app.core.database.qdrant import QdrantConfig, get_client, collection_names REQUIRED = { "notes": ["note_id", "type", "title", "updated", "tags"], diff --git a/tests/audit_edges_now.py b/tests/audit_edges_now.py index 67f0014..6c8de77 100644 --- a/tests/audit_edges_now.py +++ b/tests/audit_edges_now.py @@ -9,7 +9,7 @@ if PROJECT_ROOT not in sys.path: sys.path.insert(0, PROJECT_ROOT) from qdrant_client.http import models as rest -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client def scroll_all(c, col, flt=None): out, nextp = [], None diff --git a/tests/check_chunks_vs_text.py b/tests/check_chunks_vs_text.py index 11959a5..00893d7 100644 --- a/tests/check_chunks_vs_text.py +++ b/tests/check_chunks_vs_text.py @@ -18,7 +18,7 @@ PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) if PROJECT_ROOT not in sys.path: sys.path.insert(0, PROJECT_ROOT) -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client from qdrant_client.http import models as rest def collections(prefix: str) -> Tuple[str, str, str]: diff --git a/tests/check_chunks_window_vs_text.py b/tests/check_chunks_window_vs_text.py index 11959a5..00893d7 100644 --- a/tests/check_chunks_window_vs_text.py +++ b/tests/check_chunks_window_vs_text.py @@ -18,7 +18,7 @@ PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) if PROJECT_ROOT not in sys.path: sys.path.insert(0, PROJECT_ROOT) -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client from qdrant_client.http import models as rest def collections(prefix: str) -> Tuple[str, str, str]: diff --git a/tests/diag_edges_for_note.py b/tests/diag_edges_for_note.py index 65d0143..7c91c74 100644 --- a/tests/diag_edges_for_note.py +++ b/tests/diag_edges_for_note.py @@ -37,7 +37,7 @@ if PROJECT_ROOT not in sys.path: from qdrant_client.http import models as rest # type: ignore -from app.core.qdrant import QdrantConfig, get_client, collection_names +from app.core.database.qdrant import QdrantConfig, get_client, collection_names def fetch_edges_for_note(note_id: str, prefix: str | None, limit: int = 512) -> List[dict]: diff --git a/tests/diag_payload_indexes.py b/tests/diag_payload_indexes.py index 1418e62..ddea543 100644 --- a/tests/diag_payload_indexes.py +++ b/tests/diag_payload_indexes.py @@ -10,7 +10,7 @@ WICHTIG: Einige Qdrant-Versionen liefern payload_schema nur, wenn from __future__ import annotations import argparse, json from qdrant_client.http import models as rest -from app.core.qdrant import QdrantConfig, get_client, collection_names +from app.core.database.qdrant import QdrantConfig, get_client, collection_names def compact_schema(ps: dict | None) -> dict: if not isinstance(ps, dict): diff --git a/tests/diag_subgraph_for_note.py b/tests/diag_subgraph_for_note.py index a502000..edd04c3 100644 --- a/tests/diag_subgraph_for_note.py +++ b/tests/diag_subgraph_for_note.py @@ -33,8 +33,8 @@ PROJECT_ROOT = os.path.dirname(THIS_DIR) if PROJECT_ROOT not in sys.path: sys.path.insert(0, PROJECT_ROOT) -from app.core.qdrant import QdrantConfig, get_client # type: ignore -import app.core.graph_adapter as ga # type: ignore +from app.core.database.qdrant import QdrantConfig, get_client # type: ignore +import app.core.graph.graph_subgraph as ga # type: ignore def build_subgraph_for_note( diff --git a/tests/ensure_indexes_and_show.py b/tests/ensure_indexes_and_show.py index 805ecf7..2ee0d31 100644 --- a/tests/ensure_indexes_and_show.py +++ b/tests/ensure_indexes_and_show.py @@ -14,7 +14,7 @@ import urllib.request import urllib.error from typing import Any, Dict -from app.core.qdrant import QdrantConfig, get_client, ensure_payload_indexes, collection_names +from app.core.database.qdrant import QdrantConfig, get_client, ensure_payload_indexes, collection_names def _safe_model_dump(obj: Any) -> Dict[str, Any]: diff --git a/tests/inspect_one_note.py b/tests/inspect_one_note.py index e68aeb4..ce61bdc 100644 --- a/tests/inspect_one_note.py +++ b/tests/inspect_one_note.py @@ -17,7 +17,7 @@ from app.core.parser import read_markdown, normalize_frontmatter, validate_requi from app.core.chunker import assemble_chunks from app.core.chunk_payload import make_chunk_payloads try: - from app.core.derive_edges import build_edges_for_note + from app.core.graph.graph_derive_edges import build_edges_for_note except Exception: from app.core.edges import build_edges_for_note # type: ignore diff --git a/tests/show_edges_for_note.py b/tests/show_edges_for_note.py index 908c37e..dccf755 100644 --- a/tests/show_edges_for_note.py +++ b/tests/show_edges_for_note.py @@ -14,7 +14,7 @@ import argparse, json, os, sys from typing import Dict, Any, List, Tuple from qdrant_client.http import models as rest -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client def collections(prefix: str) -> Tuple[str, str, str]: return f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges" diff --git a/tests/test_WP22_intelligence.py b/tests/test_WP22_intelligence.py index ccfd7f2..c55e7af 100644 --- a/tests/test_WP22_intelligence.py +++ b/tests/test_WP22_intelligence.py @@ -14,7 +14,7 @@ from unittest.mock import MagicMock, patch, AsyncMock import app.routers.chat from app.models.dto import ChatRequest, QueryHit, QueryRequest from app.services.edge_registry import EdgeRegistry -from app.core.retriever import _compute_total_score, _get_status_multiplier +from app.core.retrieval.retriever_scoring import compute_wp22_score, get_status_multiplier from app.routers.chat import _classify_intent, get_decision_strategy, chat_endpoint class TestWP22Integration(unittest.IsolatedAsyncioTestCase): @@ -93,19 +93,19 @@ class TestWP22Integration(unittest.IsolatedAsyncioTestCase): def test_scoring_math(self): print("\n🔵 TEST 2: Scoring Math (Lifecycle)") - with patch("app.core.retriever._get_scoring_weights", return_value=(1.0, 1.0, 0.0)): + with patch("app.core.retrieval.retriever_scoring.get_weights", return_value=(1.0, 1.0, 0.0)): # Stable (1.2) - self.assertEqual(_get_status_multiplier({"status": "stable"}), 1.2) + self.assertEqual(get_status_multiplier({"status": "stable"}), 1.2) # Draft (0.5) - self.assertEqual(_get_status_multiplier({"status": "draft"}), 0.5) + self.assertEqual(get_status_multiplier({"status": "draft"}), 0.5) # Scoring Formel Test: BaseScore * (1 + ConfigWeight + DynamicBoost) # BaseScore = 0.5 (sem) * 1.2 (stable) = 0.6 # ConfigWeight = 1.0 (neutral) - 1.0 = 0.0 # DynamicBoost = (1.0 * 0.5) = 0.5 # Total = 0.6 * (1 + 0 + 0.5) = 0.9 - total, _, _ = _compute_total_score(0.5, {"status": "stable", "retriever_weight": 1.0}, edge_bonus_raw=0.5) - self.assertAlmostEqual(total, 0.9) + result = compute_wp22_score(0.5, {"status": "stable", "retriever_weight": 1.0}, edge_bonus_raw=0.5) + self.assertAlmostEqual(result["total"], 0.9) print("✅ Scoring OK.") async def test_router_intent(self): diff --git a/tests/test_edges_all.py b/tests/test_edges_all.py index e34e491..ee552f6 100644 --- a/tests/test_edges_all.py +++ b/tests/test_edges_all.py @@ -16,7 +16,7 @@ import json from collections import Counter, defaultdict from typing import Dict, Any, List, Tuple -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client def _scroll_all(client, collection: str): diff --git a/tests/test_edges_defaults_smoke.py b/tests/test_edges_defaults_smoke.py index d6c6e5c..fc77196 100644 --- a/tests/test_edges_defaults_smoke.py +++ b/tests/test_edges_defaults_smoke.py @@ -8,7 +8,7 @@ Zeigt, ob typenbasierte edge_defaults-Relationen (z. B. depends_on/related_to) a from __future__ import annotations from collections import Counter import json -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client def main(): cfg = QdrantConfig.from_env() diff --git a/tests/test_edges_smoke.py b/tests/test_edges_smoke.py index 504f5e8..95559e1 100644 --- a/tests/test_edges_smoke.py +++ b/tests/test_edges_smoke.py @@ -7,7 +7,7 @@ import os from collections import Counter, defaultdict from qdrant_client.http import models as rest -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client def _rel(pl: dict) -> str: diff --git a/tests/test_edges_smoke_fast.py b/tests/test_edges_smoke_fast.py index 3e3a3e9..4da1903 100644 --- a/tests/test_edges_smoke_fast.py +++ b/tests/test_edges_smoke_fast.py @@ -13,7 +13,7 @@ import argparse, json from typing import Dict, Any, List, Tuple from qdrant_client.http import models as rest -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client KINDS = ["belongs_to", "next", "prev", "references", "backlink"] diff --git a/tests/test_graph_unit.py b/tests/test_graph_unit.py index 2e3b14c..0c0e6eb 100644 --- a/tests/test_graph_unit.py +++ b/tests/test_graph_unit.py @@ -1,6 +1,6 @@ from fastapi.testclient import TestClient from app.main import create_app -import app.core.graph_adapter as ga +import app.core.graph.graph_subgraph as ga def _fake_get_edges_for_sources(client, prefix, source_ids, edge_types=None, limit=2048): note_id = source_ids[0] diff --git a/tests/test_query_text_embed_unit.py b/tests/test_query_text_embed_unit.py index ca9c01c..777ff1a 100644 --- a/tests/test_query_text_embed_unit.py +++ b/tests/test_query_text_embed_unit.py @@ -1,8 +1,8 @@ from fastapi.testclient import TestClient from app.main import create_app import app.services.embeddings_client as ec -import app.core.qdrant_points as qp -import app.core.graph_adapter as ga +import app.core.database.qdrant_points as qp +import app.core.graph.graph_subgraph as ga def _fake_embed_text(text: str): # Liefert stabilen 384-d Vektor ohne echtes Modell diff --git a/tests/test_query_unit.py b/tests/test_query_unit.py index 02fd25d..043a02e 100644 --- a/tests/test_query_unit.py +++ b/tests/test_query_unit.py @@ -1,7 +1,7 @@ from fastapi.testclient import TestClient from app.main import create_app -import app.core.qdrant_points as qp -import app.core.graph_adapter as ga +import app.core.database.qdrant_points as qp +import app.core.graph.graph_subgraph as ga def _fake_search_chunks_by_vector(client, prefix, vector, top=10, filters=None): return [ diff --git a/tests/test_retriever_basic.py b/tests/test_retriever_basic.py index d250459..2e65b76 100644 --- a/tests/test_retriever_basic.py +++ b/tests/test_retriever_basic.py @@ -1,7 +1,7 @@ -from app.core import retriever as r +from app.core.retrieval import retriever as r from app.models.dto import QueryRequest -import app.core.qdrant as qdr -import app.core.qdrant_points as qp +import app.core.database.qdrant as qdr +import app.core.database.qdrant_points as qp import app.services.embeddings_client as ec diff --git a/tests/test_retriever_edges.py b/tests/test_retriever_edges.py index 12deaba..b650925 100644 --- a/tests/test_retriever_edges.py +++ b/tests/test_retriever_edges.py @@ -1,8 +1,8 @@ -from app.core import retriever as r +from app.core.retrieval import retriever as r from app.models.dto import QueryRequest -import app.core.qdrant as qdr -import app.core.qdrant_points as qp -import app.core.graph_adapter as ga +import app.core.database.qdrant as qdr +import app.core.database.qdrant_points as qp +import app.core.graph.graph_subgraph as ga import app.services.embeddings_client as ec diff --git a/tests/test_retriever_weight.py b/tests/test_retriever_weight.py index c08fb40..52bf585 100644 --- a/tests/test_retriever_weight.py +++ b/tests/test_retriever_weight.py @@ -1,7 +1,7 @@ -from app.core import retriever as r +from app.core.retrieval import retriever as r from app.models.dto import QueryRequest -import app.core.qdrant as qdr -import app.core.qdrant_points as qp +import app.core.database.qdrant as qdr +import app.core.database.qdrant_points as qp import app.services.embeddings_client as ec diff --git a/tests/test_smart_chunking_integration.py b/tests/test_smart_chunking_integration.py index 06a489d..9f80d81 100644 --- a/tests/test_smart_chunking_integration.py +++ b/tests/test_smart_chunking_integration.py @@ -14,7 +14,7 @@ sys.path.insert(0, str(ROOT_DIR)) # Import der Kernkomponenten from app.core import chunker -from app.core import derive_edges +from app.core.graph import graph_derive_edges as derive_edges from app.services.semantic_analyzer import SemanticAnalyzer diff --git a/tests/verify_chunks_integrity.py b/tests/verify_chunks_integrity.py index 78f2f3c..81fc357 100644 --- a/tests/verify_chunks_integrity.py +++ b/tests/verify_chunks_integrity.py @@ -39,7 +39,7 @@ if PROJECT_ROOT not in sys.path: import yaml from qdrant_client.http import models as rest -from app.core.qdrant import QdrantConfig, get_client +from app.core.database.qdrant import QdrantConfig, get_client # --------------------------- Helpers ---------------------------