feat: harden community production foundation through story 1.5

This commit is contained in:
bsodfather committed 2026-08-14 00:21:59 +03:00
1 parent c30461cc92
commit f6fc2e5c9b
161 files changed
+16758 -2515

No files matched your search

+8 -2
View File
@@ -14,11 +14,13 @@ pub struct ToolErrorContract {
#[serde(skip_serializing_if = "Option::is_none")]
pub upstream_status: Option<u16>,
pub request_id: String,
pub trace_id: String,
}
pub fn tool_error_contract_from_runtime(
error: &RuntimeError,
request_id: &str,
trace_id: &str,
) -> ToolErrorContract {
let error_code = runtime_error_code(error);
ToolErrorContract {
@@ -29,6 +31,7 @@ pub fn tool_error_contract_from_runtime(
suggested_action: suggested_action(error),
upstream_status: upstream_status(error),
request_id: request_id.to_owned(),
trace_id: trace_id.to_owned(),
}
}
@@ -36,6 +39,7 @@ pub fn generic_tool_error_contract(
error_code: &'static str,
message: impl Into<String>,
request_id: &str,
trace_id: &str,
recoverable: bool,
suggested_action: Option<&'static str>,
) -> ToolErrorContract {
@@ -47,6 +51,7 @@ pub fn generic_tool_error_contract(
suggested_action,
upstream_status: None,
request_id: request_id.to_owned(),
trace_id: trace_id.to_owned(),
}
}
@@ -64,7 +69,8 @@ pub fn tool_error_value(error: &ToolErrorContract) -> Value {
"error_code": "runtime_error",
"message": "Не удалось выполнить инструмент.",
"recoverable": false,
"request_id": error.request_id
"request_id": error.request_id,
"trace_id": error.trace_id
})
})
}
@@ -109,7 +115,7 @@ fn upstream_status_code(status: u16) -> &'static str {
}
}
fn safe_runtime_error_message(error: &RuntimeError) -> String {
pub(crate) fn safe_runtime_error_message(error: &RuntimeError) -> String {
match error {
RuntimeError::Schema(_) => "Входные параметры не прошли проверку схемы.".to_owned(),
RuntimeError::Mapping(_) => {