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>
89 lines
4.6 KiB
Markdown
89 lines
4.6 KiB
Markdown
# 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
|
|
|
|
1. WHEN remove_embedding() is called THEN THE FAISS_Manager SHALL remove both metadata and vector from index
|
|
2. WHEN clear() is called THEN THE FAISS_Manager SHALL reset IVF training state completely
|
|
3. THE FAISS_Manager SHALL maintain next_id counter consistency after clear operations
|
|
4. WHEN clearing IVF index THEN THE FAISS_Manager SHALL reset training_vectors collection
|
|
5. 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
|
|
|
|
1. WHEN reindex() is called with prototype items THEN THE FAISS_Manager SHALL clear existing index completely
|
|
2. WHEN reindex() processes items THEN THE FAISS_Manager SHALL add each valid vector with metadata
|
|
3. WHEN reindex() completes with IVF index THEN THE FAISS_Manager SHALL force training if requested
|
|
4. THE FAISS_Manager SHALL return count of successfully indexed items
|
|
5. 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
|
|
|
|
1. WHEN extracting node vector THEN THE System SHALL check template.embedding_prototype list format
|
|
2. WHEN template.embedding_prototype is unavailable THEN THE System SHALL check embedding.vector_id path
|
|
3. WHEN vector_id path exists THEN THE System SHALL load numpy array from disk
|
|
4. WHEN legacy screen_template exists THEN THE System SHALL check embedding_prototype_path
|
|
5. 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
|
|
|
|
1. WHEN indexing workflow embeddings THEN THE System SHALL extract all valid node vectors
|
|
2. WHEN building items list THEN THE System SHALL include workflow_id and node_id in metadata
|
|
3. WHEN calling reindex THEN THE System SHALL force IVF training for consistency
|
|
4. THE System SHALL log count of reindexed prototypes with workflow information
|
|
5. 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
|
|
|
|
1. WHEN prototype update is validated with post-conditions OK THEN THE System SHALL trigger FAISS rebuild
|
|
2. WHEN batch learning session completes THEN THE System SHALL trigger FAISS rebuild
|
|
3. THE System SHALL NOT trigger rebuild on every frame update
|
|
4. WHEN rebuild is triggered THEN THE System SHALL log rebuild operation with timing
|
|
5. 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
|
|
|
|
1. WHEN testing Flat index reindex THEN THE System SHALL remove old entries completely
|
|
2. WHEN testing IVF index reindex THEN THE System SHALL force training even with small datasets
|
|
3. THE System SHALL validate metadata consistency after reindex operations
|
|
4. WHEN querying after reindex THEN THE System SHALL return correct top results
|
|
5. THE System SHALL validate index state (ntotal, is_trained) after reindex operations |