Modèle de données¶
Le pipeline persiste son état dans quatre tables PostgreSQL et une collection
Qdrant ; cette dernière est documentée dans
Intégration RAG.
Pour une description transversale des autres tables référencées
(transcripts, segments, enriched_segments, users), se référer à la
page Data Models.
Schéma relationnel¶
erDiagram
transcripts ||--o{ reliability_suggestions : "1..N (CASCADE)"
transcripts ||--o{ reliability_score_snapshots : "1..N (CASCADE)"
transcripts ||--o{ reliability_actions : "1..N (CASCADE)"
reliability_suggestions ||--o{ reliability_actions : "1..N (CASCADE)"
enriched_segments ||--o{ reliability_suggestions : "0..N (SET NULL)"
segments ||--o{ reliability_suggestions : "0..N (SET NULL)"
users ||--o{ reliability_corrections_quarantine : "1..N (CASCADE)"
reliability_suggestions ||--o{ reliability_corrections_quarantine : "0..N (SET NULL)"
transcripts ||--o{ reliability_corrections_quarantine : "0..N (SET NULL)"
reliability_suggestions {
string id PK
string transcript_id FK
string enriched_segment_id FK
string segment_id FK
int segment_index
string suggestion_type
text original_value
text suggested_value
text normalized_original
text normalized_suggested
float confidence_score
string source
string status
string reason_code
json evidence_json
string dedupe_key
string analysis_version
datetime created_at
datetime updated_at
}
reliability_actions {
string id PK
string suggestion_id FK
string transcript_id FK
string action_type
string actor_type
string actor_id
string idempotency_key
json payload_json
datetime created_at
}
reliability_score_snapshots {
string id PK
string transcript_id FK
float global_score
float score_places
float score_persons
float score_acronyms
float score_orgs
float score_typos
int pending_count
int validated_count
int ignored_count
int auto_applied_count
string calculation_version
datetime created_at
}
reliability_corrections_quarantine {
string id PK
string qdrant_point_id UK
string user_id FK
string source_suggestion_id FK
string transcript_id FK
string entity_type
text original_text
text final_text
text context_phrase
string action
int frequency
bool promoted_to_canonical
datetime quarantine_until
datetime created_at
datetime updated_at
}
reliability_suggestions¶
Suggestion individuelle produite par le pipeline.
| Colonne | Type | Notes |
|---|---|---|
id |
String(36) PK |
UUID. |
transcript_id |
String(36) FK → transcripts.uuid |
ON DELETE CASCADE, passive_deletes=True. Indexé. |
enriched_segment_id |
String(36) FK → enriched_segments.id |
ON DELETE SET NULL. Indexé. |
segment_id |
String(36) FK → segments.id |
ON DELETE SET NULL. |
segment_index |
Integer |
Position dans la transcription. |
suggestion_type |
String(20) |
CHECK IN ('place','person','acronym','org','typo'). |
original_value |
Text |
Valeur extraite avant correction. |
suggested_value |
Text |
Valeur corrigée proposée. |
normalized_original, normalized_suggested |
Text |
Formes normalisées NFKD lower. |
confidence_score |
Float |
[0, 1]. |
source |
String(20) |
CHECK IN ('NER','RAG','LLM','NOMINATIM','RULE'). |
status |
String(20) |
CHECK IN ('pending','validated','ignored','auto_applied'). |
reason_code |
String(100) |
Trace technique (règle, code de décision). |
evidence_json |
JSON |
Audit trail complet (signaux, poids, seuil, contexte). |
dedupe_key |
String(255) |
SHA-256 de la signature stable. |
analysis_version |
String(50) |
Identifie la version logique du pipeline. |
created_at, updated_at |
DateTime(tz=True) |
UTC. |
Contraintes¶
UNIQUE (transcript_id, dedupe_key, analysis_version)— clé d'idempotence
pour l'UPSERT en fin de pipeline.
Index¶
ix_reliability_suggestions_transcript_idix_reliability_suggestions_enriched_segment_idix_reliability_suggestions_statusix_reliability_suggestions_suggestion_type
reliability_actions¶
Audit trail immutable des actions utilisateur.
| Colonne | Type | Notes |
|---|---|---|
id |
String(36) PK |
|
suggestion_id |
String(36) FK → reliability_suggestions.id |
ON DELETE CASCADE. Indexé. |
transcript_id |
String(36) FK → transcripts.uuid |
ON DELETE CASCADE. Indexé. |
action_type |
String(20) |
CHECK IN ('validated','ignored','auto_applied','reverted'). |
actor_type |
String(20) |
CHECK IN ('user','system'). |
actor_id |
String(36) |
UUID utilisateur ou identifiant système. |
idempotency_key |
String(100) |
Fournie par le client. |
payload_json |
JSON |
Avant/après, propagation texte, etc. |
created_at |
DateTime(tz=True) |
UTC. |
Contraintes¶
UNIQUE (suggestion_id, action_type, idempotency_key)— replay idempotent
d'une même action.
reliability_score_snapshots¶
Snapshots historisés du score par transcription.
| Colonne | Type | Notes |
|---|---|---|
id |
String(36) PK |
|
transcript_id |
String(36) FK → transcripts.uuid |
ON DELETE CASCADE, passive_deletes=True. Indexé. |
global_score |
Float |
[0, 1]. |
score_places, score_persons, score_acronyms, score_orgs, score_typos |
Float nullable |
NULL si aucune suggestion du type pour cette transcription. |
pending_count, validated_count, ignored_count, auto_applied_count |
Integer |
Compteurs au moment du snapshot. |
calculation_version |
String(50) |
Version logique du calcul, suffixée par le mode (__ragenh ou __ctxfree). |
created_at |
DateTime(tz=True) |
UTC, indexé. |
Index¶
ix_reliability_score_snapshots_transcript_latest
— composite(transcript_id, created_at DESC), optimise les lectures
« dernier snapshot par transcription ».
Règle d'idempotence¶
Aucun INSERT n'est effectué si tous les compteurs et tous les sous-scores
sont identiques au dernier snapshot existant.
reliability_corrections_quarantine¶
Mirror PostgreSQL de la mémoire des corrections (collection Qdrant
reliability_corrections_memory).
| Colonne | Type | Notes |
|---|---|---|
id |
String(36) PK |
|
qdrant_point_id |
String(36) |
UNIQUE. Pivot vers Qdrant. |
user_id |
String(36) FK → users.id |
ON DELETE CASCADE. Indexé. |
source_suggestion_id |
String(36) FK → reliability_suggestions.id |
ON DELETE SET NULL. |
transcript_id |
String(36) FK → transcripts.uuid |
ON DELETE SET NULL. |
entity_type |
String(20) |
CHECK IN ('person','org','location','acronym','date','typo'). |
original_text, final_text |
Text |
final_text plafonné à FINAL_TEXT_MAX_LEN (défaut 200). |
context_phrase |
Text |
Fenêtre ±CONTEXT_RADIUS caractères. |
action |
String(10) |
CHECK IN ('accept','edit'). |
frequency |
Integer |
Compteur cumulatif. |
promoted_to_canonical |
Boolean |
Marqué true après promotion. |
quarantine_until |
DateTime(tz=True) |
Expiration de la quarantaine. |
created_at, updated_at |
DateTime(tz=True) |
UTC. |
Index¶
ix_reliability_corrections_quarantine_user_quarantine
— composite(user_id, quarantine_until).ix_reliability_corrections_quarantine_promo_job
— composite(promoted_to_canonical, quarantine_until).ix_reliability_corrections_quarantine_user_id.
Migrations Alembic¶
Le schéma est créé et maintenu par les migrations situées dans
alembic/versions/ :
| Migration | Objet |
|---|---|
20260421_reliability_v1_phase1.py |
Création de reliability_suggestions, reliability_actions, reliability_score_snapshots et de leurs index. |
20260424_reliability_phase25_hotfix_score_places_nullable.py |
Rend nullable les sous-scores typés. |
20260519_reliability_corrections_memory.py |
Création de reliability_corrections_quarantine et de ses index. |