[Slice 1.3] SDK session lifecycle & reconciliation (#3351)

* feat(sdk): implement session lifecycle and reconciliation

* fix(sdk): serialize session lifecycle recovery

* fix(sdk): preserve lifecycle outcomes and output

---------

Co-authored-by: clawdbot <clawdbot@ultraworkers.dev>
This commit is contained in:
Bellmanandclawdbot authored and GitHub committed 2026-10-13 07:02:25 +01:00
1 parent 02c22b4211
commit 01e9fc3229
13 files changed
+5215 -243

No files matched your search

+19
View File
@@ -15,6 +15,8 @@ pub enum SdkErrorCode {
Unauthorized,
EndpointCredentialForbidden,
Unavailable,
/// Requested session state conflicts with an active invocation
Conflict,
ConnectionError,
ConnectionClosed,
Timeout,
@@ -37,6 +39,7 @@ impl SdkErrorCode {
Self::Unauthorized => "unauthorized",
Self::EndpointCredentialForbidden => "endpoint_credential_forbidden",
Self::Unavailable => "unavailable",
Self::Conflict => "conflict",
Self::ConnectionError => "connection_error",
Self::ConnectionClosed => "connection_closed",
Self::Timeout => "timeout",
@@ -59,6 +62,7 @@ impl SdkErrorCode {
"unauthorized" => Self::Unauthorized,
"endpoint_credential_forbidden" => Self::EndpointCredentialForbidden,
"unavailable" => Self::Unavailable,
"conflict" => Self::Conflict,
"connection_error" => Self::ConnectionError,
"connection_closed" => Self::ConnectionClosed,
"timeout" => Self::Timeout,
@@ -132,6 +136,14 @@ impl SdkError {
Self::new(SdkErrorCode::Unavailable, message)
}
pub fn not_found(message: impl Into<String>) -> Self {
Self::new(SdkErrorCode::NotFound, message)
}
pub fn conflict(message: impl Into<String>) -> Self {
Self::new(SdkErrorCode::Conflict, message)
}
pub fn connection_error(message: impl Into<String>) -> Self {
Self::new(SdkErrorCode::ConnectionError, message)
}
@@ -209,6 +221,13 @@ mod tests {
);
}
#[test]
fn conflict_error_code_round_trips_on_the_wire() {
let error = SdkError::conflict("session is active");
assert_eq!(error.code.to_string(), "conflict");
assert_eq!(SdkErrorCode::from_wire("conflict"), SdkErrorCode::Conflict);
}
#[test]
fn unknown_remote_code_is_preserved_with_typed_internal_code() {
let error = SdkError::from_remote("future_error", "failed");