kernel/error/provider.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! What kind of provider failure an `E_PROVIDER` error reports.
7//! The part `crates/kernel/spec/Error.lean` specifies this module with the
8//! rest of `kernel::error`.
9
10use serde::{Deserialize, Serialize};
11
12/// The kind of one provider failure, as the call site that saw it named
13/// it. It travels on the wire so a page can say it in the reader's own
14/// language; the city's recovery sentence stays beside it for the fold.
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
16#[serde(tag = "kind", rename_all = "snake_case")]
17#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
18pub enum ProviderFailureKind {
19 /// The exchange never completed: the request did not reach the
20 /// provider, the answer stopped before its end, or the transport's
21 /// deadline passed.
22 Exchange,
23 /// A streamed body could not be read further off the socket.
24 Cut,
25 /// A stream stayed open and silent past the bound set for silence.
26 Silence,
27 /// The provider answered, and its status refuses the request. Held
28 /// as `u32` because the wire's schema subset has no upper bound to
29 /// spell a `u16` with.
30 Refused { status: u32 },
31 /// The provider refused the request because it no longer fits the
32 /// model's context window.
33 Overflow { status: u32 },
34 /// The provider answered 2xx with a body this city cannot read.
35 Unreadable,
36 /// A stream that already answered 2xx carried an error frame. The
37 /// provider's type for it stays in the error's subject.
38 Reported,
39 /// The request could not be built on this side.
40 Unbuilt,
41}