Skip to main content

sqlite_graphrag/i18n/validation/
messages_queue.rs

1//! Messages from the enrich QUEUE and its sidecar (GAP-SG-146).
2//!
3//! Sidecar write failures, re-embed key shapes, and the fields an enrich LLM
4//! response must carry for the item to be persisted.
5
6use crate::i18n::{current, Language};
7
8/// Queue clear failed.
9pub fn queue_clear_failed(err: &impl std::fmt::Display) -> String {
10    match current() {
11        Language::English => format!("queue clear failed: {err}"),
12        Language::Portuguese => format!("falha ao limpar a fila: {err}"),
13    }
14}
15
16/// Queue insert failed.
17pub fn queue_insert_failed(err: &impl std::fmt::Display) -> String {
18    match current() {
19        Language::English => format!("queue insert failed: {err}"),
20        Language::Portuguese => format!("falha ao inserir na fila: {err}"),
21    }
22}
23
24/// Queue namespace migration failed.
25pub fn queue_namespace_migration_failed(err: &impl std::fmt::Display) -> String {
26    match current() {
27        Language::English => format!("queue namespace migration failed: {err}"),
28        Language::Portuguese => {
29            format!("migração de namespace da fila falhou: {err}")
30        }
31    }
32}
33
34/// Queue resume (`status=processing` → `pending`) failed.
35pub fn queue_resume_failed(err: &impl std::fmt::Display) -> String {
36    match current() {
37        Language::English => format!("queue resume failed: {err}"),
38        Language::Portuguese => format!("falha ao retomar a fila: {err}"),
39    }
40}
41
42/// Queue retry-failed reset failed.
43pub fn queue_retry_failed_reset_failed(err: &impl std::fmt::Display) -> String {
44    match current() {
45        Language::English => format!("queue retry-failed reset failed: {err}"),
46        Language::Portuguese => {
47            format!("falha ao redefinir itens com falha da fila: {err}")
48        }
49    }
50}
51
52/// Requeue-dead failed.
53pub fn requeue_dead_failed(err: &impl std::fmt::Display) -> String {
54    match current() {
55        Language::English => format!("requeue-dead failed: {err}"),
56        Language::Portuguese => format!("requeue-dead falhou: {err}"),
57    }
58}
59
60/// Requeue-skipped failed.
61pub fn requeue_skipped_failed(err: &impl std::fmt::Display) -> String {
62    match current() {
63        Language::English => format!("requeue-skipped failed: {err}"),
64        Language::Portuguese => format!("requeue-skipped falhou: {err}"),
65    }
66}
67
68/// Invalid chunk id in re-embed key.
69pub fn invalid_chunk_id_in_reembed_key(chunk_key: &str) -> String {
70    match current() {
71        Language::English => format!("invalid chunk id in re-embed key: {chunk_key}"),
72        Language::Portuguese => {
73            format!("id de chunk inválido na chave de re-embed: {chunk_key}")
74        }
75    }
76}
77
78/// LLM result missing calibrated_weight.
79pub fn llm_missing_calibrated_weight() -> String {
80    match current() {
81        Language::English => "LLM result missing 'calibrated_weight'".to_string(),
82        Language::Portuguese => "resultado LLM sem 'calibrated_weight'".to_string(),
83    }
84}
85
86/// LLM result missing description field.
87pub fn llm_missing_description_field() -> String {
88    match current() {
89        Language::English => "LLM result missing 'description' field".to_string(),
90        Language::Portuguese => "resultado LLM sem campo 'description'".to_string(),
91    }
92}
93
94/// LLM result missing enriched_body field.
95pub fn llm_missing_enriched_body_field() -> String {
96    match current() {
97        Language::English => "LLM result missing 'enriched_body' field".to_string(),
98        Language::Portuguese => "resultado LLM sem campo 'enriched_body'".to_string(),
99    }
100}
101
102/// LLM result missing relation.
103pub fn llm_missing_relation() -> String {
104    match current() {
105        Language::English => "LLM result missing 'relation'".to_string(),
106        Language::Portuguese => "resultado LLM sem 'relation'".to_string(),
107    }
108}
109
110/// Deep-research output file is empty.
111pub fn deep_research_output_empty(path: &str) -> String {
112    match current() {
113        Language::English => {
114            format!("deep-research --output failed: written file is empty (0 bytes): {path}")
115        }
116        Language::Portuguese => {
117            format!("deep-research --output falhou: arquivo escrito está vazio (0 bytes): {path}")
118        }
119    }
120}
121
122/// Deep-research output path missing after atomic write.
123pub fn deep_research_output_missing(path: &str) -> String {
124    match current() {
125        Language::English => {
126            format!("deep-research --output failed: path does not exist after atomic write: {path}")
127        }
128        Language::Portuguese => format!(
129            "deep-research --output falhou: caminho não existe após escrita atômica: {path}"
130        ),
131    }
132}