docs: scope historical notification design (#389)
Heimdall Gitea / Detect CI scope (pull_request) Successful in 5s
Heimdall Gitea / Build and tests (pull_request) Skipped
Heimdall Gitea / Build and scan server image (pull_request) Skipped
Heimdall Gitea / Build and scan agent image (pull_request) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (pull_request) Skipped
Heimdall Gitea / Publish versioned installer release (pull_request) Skipped
Heimdall Gitea / CI policy (pull_request) Successful in 2s

This commit is contained in:
arnaud.dartois committed 2026-11-13 11:19:11 +01:00
1 parent b4d24c3345
commit 0679dfed66
2 files changed
+46 -117

No files matched your search

+44 -117
View File
@@ -158,6 +158,11 @@ services:
### 2.1 Définitions
> **Schéma de conception historique (2026-07-16).** Les champs de
> notification ci-dessous, dont `GotifyEnabled` et `NotificationTemplate`, ne
> sont pas l’inventaire du modèle livré. Voir le [guide actuel des
> notifications](notifications.md) et le [modèle d’identité courant](auth-roles.md).
```
Site Agent Camera
├── Id (Guid) PK ├── Id (Guid) PK ├── Id (Guid) PK
@@ -302,12 +307,15 @@ CREATE INDEX idx_license_plate ON license_plates USING GIN
### 3.1 Problème : Objets Stationnaires
> **Estimation théorique historique**, pas une mesure ni une description des
> canaux livrés.
**Sans dédoublonnage** : une personne immobile 10 minutes génère :
- 3000 snapshots (200ms × 600s)
- 3000 inférences YOLOv8 nano
- 3000 analyses IA (ONNX local ou via broker)
- 3000 événements en base
- 3000 notifications (email + gotify + in-app)
- 3000 notifications dans ce scénario théorique
**Solution** : Architecture de dédoublonnage à 4 niveaux.
@@ -841,6 +849,10 @@ await storageProvider.DeleteBatchAsync(storagePaths, ct);
### 7.4 Hangfire Configuration
> **Exemple de queues historique.** Les queues `email`/`gotify` du bloc
> suivant ne décrivent pas les jobs actuels; voir le [guide Hangfire](hangfire-usage.md)
> et le [guide des notifications livrées](notifications.md).
```csharp
// Central — with schema isolation
builder.Services.AddHangfire(config =>
@@ -852,7 +864,7 @@ builder.Services.AddHangfire(config =>
});
});
// Queue isolation
// Queue isolation (conception historique)
[Queue("email")]
public class SendNotificationEmailJob { ... }
@@ -872,6 +884,10 @@ builder.Services.AddHangfireServer(options =>
### 7.5 Jobs Hangfire — Tous
> **Inventaire historique (2026-07-16), pas la liste des jobs actuellement
> enregistrés.** Consulter le [guide Hangfire actuel](hangfire-usage.md) pour
> les jobs et queues livrés.
**Central (PostgreSQL)**
| Job | Schedule | Queue | Description |
@@ -898,60 +914,13 @@ builder.Services.AddHangfireServer(options =>
## PARTIE 8 : Notifications
### 8.1 Canaux
> **Conception historique non livrée.** Les canaux Gotify, l’éditeur de
> templates Scriban et les événements de ces tableaux ne décrivent pas le
> produit actuel. Pour les canaux, réglages et jobs livrés, voir
> [Notifications](notifications.md).
| Canal | Usage | Priorité | Queue Hangfire |
|---|---|---|---|
| **Email (SMTP)** | Importants + résumés | P0 | `email` |
| **Gotify** | Alertes temps réel | P0 | `gotify` |
| **In-app (SignalR)** | Badge UI | P0 | Direct (pas Hangfire) |
### 8.2 Types d'Événements Notifiables
| EventType | Email | Gotify | In-App | Cooldown (secondes) |
|---|---|---|---|---|
| `PersonDetected` | ✅ | ✅ | ✅ | 30 |
| `UnknownPerson` | ✅ (haut) | ✅ | ✅ | 300 (5 min) |
| `FaceRecognized` | 🟡 (option) | 🟡 | ✅ | 30 |
| `VehicleDetected` | ✅ | ✅ | ✅ | 60 |
| `LicensePlateDetected` | 🟡 | ✅ | ✅ | 60 |
| `MotionDetected` | ❌ (trop) | ❌ | ✅ (silencieux) | 10 |
| `CameraOffline` | ✅ | ✅ | ✅ | 600 (10 min) |
| `CameraOnline` | 🟡 | 🟡 | ✅ | 600 |
| `DailySummary` | ✅ | ❌ | ❌ | N/A |
| `WeeklySummary` | ✅ | ❌ | ❌ | N/A |
### 8.3 Rate Limiting Notifications
```csharp
public class NotificationRateLimiter
{
private readonly IMemoryCache _cache;
public bool ShouldSend(Guid cameraId, EventType type, Guid? trackId)
{
var key = $"notif-rate:{cameraId}:{type}:{trackId ?? Guid.Empty}";
var count = _cache.GetOrCreate(key, entry =>
{
entry.SlidingExpiration = TimeSpan.FromMinutes(1);
return 0;
});
if (count >= 20) return false; // Max 20 events/min/camera/type
_cache.Set(key, count + 1, TimeSpan.FromMinutes(1));
return true;
}
}
```
### 8.4 Templates
- Moteur : Scriban (Markdown → HTML pour email)
- Stockés en DB (table `NotificationTemplate`)
- Éditables depuis l'UI Admin
- Fallback : fr → en → template par défaut hardcodé
- Signature : `[Heimdall]` dans le sujet
Le détail historique de cette partie a été retiré pour éviter de confondre
les propositions de 2026-07-16 avec les fonctions livrées.
---
@@ -1754,68 +1723,14 @@ Phase 17 — API Events + Persons + Vehicles
│ • Tout est filtré par site-scope (User voit ses sites)
│ • Données accessibles via API pour l'UI (Étape 5)
Phase 18 — Notifications
├── SendNotificationEmailJob (SMTP, queue=email, retry 3x)
├── SendNotificationGotifyJob (queue=gotify)
├── NotificationRateLimiter (IMemoryCache, max 20 events/min/camera)
├── DetectionCooldownService (cooldown par type d'événement)
├── Scriban templates (DB + fallback hardcodé fr → en)
├── Hiérarchie des notifications :
│ ├── "PersonDetected" → Email + Gotify (si configuré)
│ ├── "UnknownPerson" → Email + Gotify + In-app (badge rouge)
│ ├── "VehicleDetected" → Email (si config) + Gotify
│ ├── "CameraOffline" → Email + Gotify (alerte admin)
│ └── "MotionDetected" → SILENCIEUX (in-app sans notif)
├── Verify: notifications flows green
│
✅ Fonctionnel à la fin de cette phase :
│
│ ┌─ SCÉNARIO NOTIFICATION ──────────────────────────────────────┐
│ │ │
│ │ 1. Personne détectée devant la caméra "Entrée" │
│ │ → Événement créé (Phase 16) │
│ │ │
│ │ 2. Central envoie SendNotificationJob à Hangfire │
│ │ → Queue "email" : SendNotificationEmailJob │
│ │ → Queue "gotify" : SendNotificationGotifyJob │
│ │ │
│ │ 3. SendNotificationEmailJob : │
│ │ → Render template Scriban : "Personne détectée" │
│ │ → Sujet : "[Heimdall] Personne détectée — Entrée" │
│ │ → Corps : snapshot incluse (embed) + heure + lieu │
│ │ → SMTP : envoi à tous les users configurés │
│ │ │
│ │ 4. SendNotificationGotifyJob : │
│ │ → POST Gotify API : "Personne détectée - Entrée" │
│ │ → Priorité : 5 (haute) │
│ │ │
│ │ 5. SignalR NotificationsHub envoie NewNotification │
│ │ → Groupe "notif-{userId}" │
│ │ → Badge dans l'UI : "3 notifications non lues" │
│ │ │
│ │ 6. RateLimiter : max 20 notifs/min/camera │
│ │ → Si seuil atteint → pas de nouvelle notification │
│ │ → Log "Rate limit atteint pour camera guid-cam-1" │
│ │ │
│ └──────────────────────────────────────────────────────────────┘
│
│ ┌─ CONFIGURER SES NOTIFICATIONS ───────────────────────────────┐
│ │ PUT /api/auth/profile │
│ │ { │
│ │ "notificationConfig": { │
│ │ "emailEnabled": true, │
│ │ "gotifyEnabled": true, │
│ │ "subscribedEvents": ["personDetected", "unknownPerson", │
│ │ "vehicleDetected", "cameraOffline"],│
│ │ "dailyDigest": true │
│ │ } │
│ │ } │
│ └──────────────────────────────────────────────────────────────┘
│
│ • 3 canaux : Email, Gotify, In-app (SignalR)
│ • Rate limiting : pas de spam même en rafale
│ • Templates personnalisables par l'Admin
│ • Chaque user choisit ses types d'événements
> **Phase 18 — scénario historique (non état livré).** La conception initiale
> Gotify/Scriban ci-dessous a été retirée; voir [l’état courant des
> notifications](notifications.md).
Phase 18 — Notifications (historique)
> Détails de cette proposition retirés : ils ne décrivent pas les services,
> queues ni contrats actuellement livrés.
Phase 19 — Jobs Métier (retention, cleanup)
├── RetentionCheckJob (quotidien 3h, queue=maintenance)
@@ -2021,6 +1936,11 @@ Phase 22 — Blazor UI Events + Persons + Live
│ └──────────────────────────────────────────────────────────────┘
Phase 23 — Blazor UI Admin
> **Maquette historique, pas l’interface livrée.** Le dashboard/configuration
> consolidés et le réglage Gotify ci-dessous ne sont pas des routes ou écrans
> actuels. Consulter [`ui-pages.md`](ui-pages.md), [`auth-roles.md`](auth-roles.md)
> et [les réglages de notification livrés](notifications.md).
├── Users management (tab Utilisateurs)
│ ├── Liste des users avec rôle, email, 2FA status
│ ├── [Modifier le rôle], [Reset 2FA], [Supprimer]
@@ -2201,6 +2121,10 @@ CPU; l'inférence GPU nécessite encore une image et un runtime dédiés.
## PARTIE 12 : Tests
> **Scénarios de test historiques (2026-07-16), pas résultats ni couverture
> actuelle.** La référence `gotify` ci-dessous décrit une ancienne conception
> de queue; voir [les canaux livrés](notifications.md) et [les jobs actuels](hangfire-usage.md).
### 12.1 Stack de Test
| Niveau | Technologie | Couverture |
@@ -2324,6 +2248,9 @@ liées dans l'en-tête de ce document.
## Annexe A : Résumé des 36 Issues Critiques Résolues
> **Annexe historique de la baseline 2026-07-16**; ses résolutions et noms de
> composants ne constituent pas une validation du runtime actuel.
| # | Issue | Source | Résolution |
|---|---|---|---|
| C2 | Agent Registration ne retourne pas d'API Key | council-agent | ApiKey ajoutée à la réponse |
+2
View File
@@ -9,6 +9,8 @@ The header bell is rendered by `Components/Shared/NotificationBadge.razor`; it d
When documenting delivery channels, verify `NotificationChannel`, `SendNotificationJob`, `NotificationSettingsSection.razor`, `Profile.razor`, the delivery services, and `BackgroundJobs/JobSetup.cs`. The shipped external channels are SMTP email and ntfy; do not describe Gotify as integrated. `/settings` owns global SMTP/ntfy settings and test actions, while `/profile` owns user preferences. Check both digest job implementations and their schedules before documenting cadence. Distinguish source inspection from validation against a real SMTP/ntfy deployment. Remove obsolete channel integrations, editor flows, and test claims from `docs/notifications.md`; if a historical example must remain, label that exact heading/table/snippet locally rather than relying on a broad notice elsewhere in the guide. When the notification guide’s scope or delivered status changes, update both notification summaries in `docs/README.md` to match it.
When legacy notification designs remain in `docs/MASTER_SPECIFICATION.md`, put a local dated historical/non-shipped note beside each section, queue example, or UI mockup, and link to `docs/notifications.md`. A document-level historical header alone is not sufficient for Gotify or template-editor claims.
## Acceptance
1. Build `Heimdall.Web` with the SDK from `global.json` and run focused Web tests.