Validé sur PC Windows (DESKTOP-58D5CAC, 2560x1600) : - 8 clics résolus visuellement (1 anchor_template, 1 som_text_match, 6 som_vlm) - Score moyen 0.75, temps moyen 1.6s - Texte tapé correctement (bonjour, test word, date, email) - 0 retries, 2 actions non vérifiées (OK) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4.6 KiB
Requirements Document - FAISS Rebuild Propre
Auteur : Dom, Alice Kiro - 22 décembre 2025
Introduction
Le système FAISS Rebuild Propre permet de maintenir un index FAISS propre et cohérent en éliminant la pollution causée par l'accumulation de vecteurs obsolètes lors des mises à jour de prototypes d'apprentissage.
Glossary
- FAISS_Manager : Gestionnaire d'index FAISS pour la recherche de similarité
- Prototype : Vecteur représentatif d'un état d'écran ou d'un node de workflow
- Index_Pollution : Accumulation de vecteurs obsolètes dans l'index FAISS
- Reindex : Reconstruction complète de l'index depuis une source canonique
- IVF_Training : Entraînement des index FAISS de type Inverted File
Requirements
Requirement 1
User Story: En tant que système d'apprentissage, je veux nettoyer l'index FAISS, afin d'éliminer les vecteurs obsolètes et maintenir la cohérence.
Acceptance Criteria
- WHEN remove_embedding() is called THEN THE FAISS_Manager SHALL remove both metadata and vector from index
- WHEN clear() is called THEN THE FAISS_Manager SHALL reset IVF training state completely
- THE FAISS_Manager SHALL maintain next_id counter consistency after clear operations
- WHEN clearing IVF index THEN THE FAISS_Manager SHALL reset training_vectors collection
- THE FAISS_Manager SHALL set is_trained flag appropriately based on index type after clear
Requirement 2
User Story: En tant que système d'apprentissage, je veux reconstruire l'index FAISS depuis une source canonique, afin de garantir que l'index reflète exactement les prototypes actuels.
Acceptance Criteria
- WHEN reindex() is called with prototype items THEN THE FAISS_Manager SHALL clear existing index completely
- WHEN reindex() processes items THEN THE FAISS_Manager SHALL add each valid vector with metadata
- WHEN reindex() completes with IVF index THEN THE FAISS_Manager SHALL force training if requested
- THE FAISS_Manager SHALL return count of successfully indexed items
- WHEN reindex() encounters invalid vectors THEN THE FAISS_Manager SHALL skip them and continue processing
Requirement 3
User Story: En tant que pipeline de workflow, je veux extraire les vecteurs prototypes des nodes, afin de supporter différentes versions de modèles de données.
Acceptance Criteria
- WHEN extracting node vector THEN THE System SHALL check template.embedding_prototype list format
- WHEN template.embedding_prototype is unavailable THEN THE System SHALL check embedding.vector_id path
- WHEN vector_id path exists THEN THE System SHALL load numpy array from disk
- WHEN legacy screen_template exists THEN THE System SHALL check embedding_prototype_path
- WHEN no valid vector found THEN THE System SHALL return None gracefully
Requirement 4
User Story: En tant que pipeline de workflow, je veux reconstruire l'index FAISS avec les prototypes actuels, afin d'éliminer les doublons et maintenir la cohérence.
Acceptance Criteria
- WHEN indexing workflow embeddings THEN THE System SHALL extract all valid node vectors
- WHEN building items list THEN THE System SHALL include workflow_id and node_id in metadata
- WHEN calling reindex THEN THE System SHALL force IVF training for consistency
- THE System SHALL log count of reindexed prototypes with workflow information
- WHEN no valid vectors found THEN THE System SHALL handle empty reindex gracefully
Requirement 5
User Story: En tant qu'administrateur système, je veux déclencher le rebuild FAISS au bon moment, afin d'optimiser les performances sans impact négatif.
Acceptance Criteria
- WHEN prototype update is validated with post-conditions OK THEN THE System SHALL trigger FAISS rebuild
- WHEN batch learning session completes THEN THE System SHALL trigger FAISS rebuild
- THE System SHALL NOT trigger rebuild on every frame update
- WHEN rebuild is triggered THEN THE System SHALL log rebuild operation with timing
- THE System SHALL handle rebuild failures gracefully without corrupting existing index
Requirement 6
User Story: En tant que développeur, je veux tester le système de rebuild FAISS, afin de valider le comportement avec différents types d'index.
Acceptance Criteria
- WHEN testing Flat index reindex THEN THE System SHALL remove old entries completely
- WHEN testing IVF index reindex THEN THE System SHALL force training even with small datasets
- THE System SHALL validate metadata consistency after reindex operations
- WHEN querying after reindex THEN THE System SHALL return correct top results
- THE System SHALL validate index state (ntotal, is_trained) after reindex operations