Skip to content

[Bug] No embedding model validation on incremental index update #4

@ngmks

Description

@ngmks

🏷️ Priorité : HAUTE | Type : Bug

Problème

Lors d'un update incrémental, aucune vérification ne garantit que le modèle d'embedding correspond à celui de l'index existant. Changer de modèle entre deux runs produit des embeddings incompatibles dans le même index → recherches incohérentes.

Localisation

Fichier : apps/claude_code_rag.py, méthode run(), lignes ~340-342

# ACTUEL :
manifest = self._load_manifest(index_dir)
# ← PAS de vérification args.embedding_model vs manifest["embedding_model"]
if new_sessions:
    self._do_incremental_update(args, new_sessions)

Comment reproduire

  1. python -m apps.claude_code_rag --build (utilise contriever par défaut)
  2. python -m apps.claude_code_rag --build --embedding-model BAAI/bge-m3
  3. L'incremental ajoute des embeddings BGE dans un index Contriever → corruption silencieuse

Correction attendue

manifest = self._load_manifest(index_dir)

manifest_model = manifest.get("embedding_model")
if manifest_model and manifest_model != args.embedding_model:
    print(
        f"Error: Embedding model mismatch.\n"
        f"  Index built with: {manifest_model}\n"
        f"  You specified:    {args.embedding_model}\n"
        f"  Use --rebuild to recreate the index with the new model."
    )
    return

Critères de succès

  • Modèle différent → erreur claire + arrêt
  • Modèle identique → comportement inchangé
  • Manifest sans champ embedding_model (ancien format) → warning mais continue
  • Test unitaire couvrant ce cas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions