# Requirements Document ## Introduction Ce document spécifie les exigences pour un système de workflows auto-réparateurs (self-healing) pour RPA Vision V3. Le système permettra aux workflows de se corriger automatiquement en cas d'échec, en utilisant des stratégies de fallback intelligentes, l'apprentissage des corrections, et la mémorisation des solutions pour les exécutions futures. ## Glossary - **Self-Healing Workflow**: Workflow capable de se corriger automatiquement en cas d'échec sans intervention humaine - **Fallback Strategy**: Stratégie alternative utilisée quand l'approche principale échoue - **Healing Action**: Action corrective appliquée pour résoudre un échec - **Correction Memory**: Base de données des corrections appliquées avec succès - **Semantic Variant**: Variante sémantique d'un élément UI (ex: "Submit" → "Envoyer" → "Valider") - **Spatial Fallback**: Recherche d'éléments dans une zone élargie autour de la position attendue - **Retry Policy**: Politique de réessai avec backoff exponentiel - **Healing Context**: Contexte d'exécution incluant l'historique des tentatives et corrections ## Requirements ### Requirement 1 **User Story:** As a workflow executor, I want workflows to automatically try semantic variants when an element is not found, so that UI changes don't break automation. #### Acceptance Criteria 1. WHEN an element match fails with the original description, THE Self-Healing System SHALL generate semantic variants of the description 2. WHEN semantic variants are generated, THE Self-Healing System SHALL attempt matching with each variant in order of semantic similarity 3. WHEN a semantic variant succeeds, THE Self-Healing System SHALL record the successful variant in Correction Memory 4. WHEN the same element is searched again, THE Self-Healing System SHALL prioritize previously successful variants ### Requirement 2 **User Story:** As a workflow executor, I want workflows to search in expanded spatial regions when elements move, so that layout changes don't break automation. #### Acceptance Criteria 1. WHEN an element is not found at the expected position, THE Self-Healing System SHALL expand the search region incrementally 2. WHEN searching in expanded regions, THE Self-Healing System SHALL maintain a maximum search radius to avoid false positives 3. WHEN an element is found in an expanded region, THE Self-Healing System SHALL update the element position in the workflow 4. WHEN multiple candidates are found in expanded regions, THE Self-Healing System SHALL select the candidate with highest confidence score ### Requirement 3 **User Story:** As a workflow executor, I want workflows to retry failed actions with exponential backoff, so that temporary issues don't cause permanent failures. #### Acceptance Criteria 1. WHEN an action fails, THE Self-Healing System SHALL retry the action according to the configured retry policy 2. WHEN retrying actions, THE Self-Healing System SHALL apply exponential backoff between attempts 3. WHEN the maximum retry count is reached, THE Self-Healing System SHALL escalate to alternative healing strategies 4. WHEN an action succeeds after retries, THE Self-Healing System SHALL log the number of attempts required ### Requirement 4 **User Story:** As a system administrator, I want corrections to be memorized and reused, so that the system learns from past fixes. #### Acceptance Criteria 1. WHEN a healing action succeeds, THE Correction Memory SHALL store the correction with context including workflow_id, node_id, and original description 2. WHEN the same failure occurs again, THE Correction Memory SHALL retrieve applicable corrections ordered by success rate 3. WHEN a correction is reused successfully, THE Correction Memory SHALL increment its success counter 4. WHEN a correction fails, THE Correction Memory SHALL decrement its confidence score ### Requirement 5 **User Story:** As a workflow developer, I want healing strategies to be configurable per workflow, so that I can control the healing behavior. #### Acceptance Criteria 1. WHEN a workflow is created, THE Self-Healing System SHALL allow configuration of enabled healing strategies 2. WHEN healing strategies are configured, THE Self-Healing System SHALL validate that strategy parameters are within acceptable ranges 3. WHEN a workflow executes, THE Self-Healing System SHALL apply only the enabled healing strategies in configured order 4. WHEN healing is disabled for a workflow, THE Self-Healing System SHALL execute without any healing attempts ### Requirement 6 **User Story:** As a system operator, I want to monitor healing effectiveness, so that I can optimize healing strategies. #### Acceptance Criteria 1. WHEN healing actions are attempted, THE Self-Healing System SHALL record metrics including strategy used, success/failure, and duration 2. WHEN healing succeeds, THE Self-Healing System SHALL increment Prometheus counters for successful healings by strategy type 3. WHEN healing fails after all strategies, THE Self-Healing System SHALL log the failure with all attempted strategies 4. WHEN healing metrics are requested, THE Admin Dashboard SHALL display healing success rates by strategy and workflow ### Exigence 7 **Histoire utilisateur :** En tant que résolveur de cibles, je veux assouplir progressivement les critères de correspondance lors des tentatives, afin que les changements d'interface utilisateur ne cassent pas l'automatisation. #### Critères d'acceptation 1. QUAND une correspondance d'élément échoue à la première tentative, LE Résolveur de Cibles DOIT maintenir des critères de correspondance stricts 2. QUAND le compteur de tentatives de guérison augmente, LE Résolveur de Cibles DOIT progressivement assouplir les seuils de correspondance floue 3. QUAND le compteur de tentatives de guérison augmente, LE Résolveur de Cibles DOIT étendre les alias de rôles pour inclure les variantes sémantiques 4. QUAND le compteur de tentatives de guérison augmente, LE Résolveur de Cibles DOIT augmenter les multiplicateurs de padding de recherche spatiale 5. QUAND la guérison réussit avec des critères assouplis, LE Résolveur de Cibles DOIT enregistrer le profil de guérison réussi ### Exigence 8 **Histoire utilisateur :** En tant qu'exécuteur d'actions, je veux activer le mode de guérison lors des tentatives, afin que les actions échouées puissent récupérer automatiquement. #### Critères d'acceptation 1. QUAND une action échoue et qu'une nouvelle tentative est configurée, L'Exécuteur d'Actions DOIT incrémenter le compteur de tentatives de guérison sur le résolveur de cibles 2. QUAND une action est retentée, L'Exécuteur d'Actions DOIT appliquer un backoff exponentiel entre les tentatives 3. QUAND le compteur de tentatives de guérison est actif, LE Résolveur de Cibles DOIT utiliser des profils de correspondance progressivement plus tolérants 4. QUAND la nouvelle tentative réussit, L'Exécuteur d'Actions DOIT remettre à zéro le compteur de tentatives de guérison 5. QUAND le nombre maximum de tentatives est atteint, L'Exécuteur d'Actions DOIT enregistrer l'échec avec toutes les tentatives de guérison effectuées