| 445 | source, status = conn["source"], conn["status"] |
445 | source, status = conn["source"], conn["status"] |
| 446 | inc = active_incident(c, service, source) |
446 | inc = active_incident(c, service, source) |
| 447 | if status in trigger and inc is None: |
447 | if status in trigger and inc is None: |
| |
448 | + # Garde anti-boucle : une source déjà diagnostiquée irréparable |
| |
449 | + # (site_source_mort, tentatives épuisées) ne redonne pas |
| |
450 | + # d'incident tant que le délai de re-examen n'est pas écoulé. |
| |
451 | + # Sans elle, un connecteur désactivé côté app mais rapporté |
| |
452 | + # broken à perpétuité par api-ka relance une mission toutes |
| |
453 | + # les ~10 min (2026-08-24 : 37 missions sur origin-north.ai). |
| |
454 | + ab = c.execute( |
| |
455 | + "SELECT updated FROM incidents WHERE service=? AND source=? " |
| |
456 | + "AND state='abandoned' ORDER BY updated DESC LIMIT 1", |
| |
457 | + (service, source)).fetchone() |
| |
458 | + if ab and now() - ab["updated"] < POLICY.get("abandoned_retry_hours", 168) * 3600: |
| |
459 | + continue |
| 448 | iid = uuid.uuid4().hex[:10] |
460 | iid = uuid.uuid4().hex[:10] |
| 449 | c.execute("INSERT INTO incidents(id,service,source,status_detected,state,created,updated,detail) " |
461 | c.execute("INSERT INTO incidents(id,service,source,status_detected,state,created,updated,detail) " |
| 450 | "VALUES(?,?,?,?,?,?,?,?)", |
462 | "VALUES(?,?,?,?,?,?,?,?)", |