Skip to main content

synapse_application/
diagnostic.rs

1use serde::Deserialize;
2use soma_ops::{DiagnosticCode, DiagnosticSeverity, RetryClass};
3
4/// Product-owned projection of a stable diagnostic to every legacy surface.
5#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
6pub struct DiagnosticProjection {
7    code: DiagnosticCode,
8    category: String,
9    cli_exit_code: u8,
10    http_status: u16,
11    mcp_error_code: i32,
12    event_severity: DiagnosticSeverity,
13    retry: RetryClass,
14    terminal: bool,
15}
16
17impl DiagnosticProjection {
18    /// Returns the stable code.
19    #[must_use]
20    pub fn code(&self) -> &DiagnosticCode {
21        &self.code
22    }
23    /// Returns the diagnostic category.
24    #[must_use]
25    pub fn category(&self) -> &str {
26        &self.category
27    }
28    /// Returns the CLI process exit code.
29    #[must_use]
30    pub const fn cli_exit_code(&self) -> u8 {
31        self.cli_exit_code
32    }
33    /// Returns the REST HTTP status.
34    #[must_use]
35    pub const fn http_status(&self) -> u16 {
36        self.http_status
37    }
38    /// Returns the JSON-RPC/MCP error code, or zero for non-errors.
39    #[must_use]
40    pub const fn mcp_error_code(&self) -> i32 {
41        self.mcp_error_code
42    }
43    /// Returns lifecycle event severity.
44    #[must_use]
45    pub const fn event_severity(&self) -> DiagnosticSeverity {
46        self.event_severity
47    }
48    /// Returns retry classification.
49    #[must_use]
50    pub const fn retry(&self) -> RetryClass {
51        self.retry
52    }
53    /// Returns whether the diagnostic terminates the operation.
54    #[must_use]
55    pub const fn terminal(&self) -> bool {
56        self.terminal
57    }
58}
59
60#[cfg(test)]
61#[path = "diagnostic_tests.rs"]
62mod tests;