Skip to main content

mojentic/llm/recovery/
capabilities.rs

1//! Inspected endpoint declarations. These do not control request or retry behavior.
2use super::{Capabilities, Provider, Support};
3use serde::Serialize;
4
5/// Documentation supporting one endpoint capability declaration.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
7pub struct CapabilityEvidence {
8    /// Supported, unsupported, or undocumented/ambiguous for this endpoint.
9    pub value: Support,
10    /// Canonical provider endpoint; configured hosts may differ.
11    pub endpoint: &'static str,
12    /// Provider documentation inspected for this facility.
13    pub documentation: &'static str,
14    /// Original inspection date in ISO 8601 form (YYYY-MM-DD).
15    pub inspected_on: &'static str,
16    /// Endpoint-specific interpretation and limits of the cited documentation.
17    pub basis: &'static str,
18}
19
20/// Evidence for all five recovery capabilities of one completion adapter.
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
22pub struct CapabilityEvidenceSet {
23    /// Evidence for `local_request_cancellation`.
24    pub local_request_cancellation: CapabilityEvidence,
25    /// Evidence for `remote_request_cancellation`.
26    pub remote_request_cancellation: CapabilityEvidence,
27    /// Evidence for `request_status`.
28    pub request_status: CapabilityEvidence,
29    /// Evidence for `idempotency`.
30    pub idempotency: CapabilityEvidence,
31    /// Evidence for `exact_attempt_termination`.
32    pub exact_attempt_termination: CapabilityEvidence,
33}
34impl CapabilityEvidenceSet {
35    pub(crate) fn values(self) -> Capabilities {
36        Capabilities {
37            request_cancel: self.remote_request_cancellation.value,
38            local_request_cancellation: self.local_request_cancellation.value,
39            remote_request_cancellation: self.remote_request_cancellation.value,
40            request_status: self.request_status.value,
41            idempotency: self.idempotency.value,
42            exact_attempt_termination: self.exact_attempt_termination.value,
43        }
44    }
45    pub(crate) fn for_provider(provider: Provider) -> Self {
46        match provider {
47            Provider::Ollama => Self {
48                local_request_cancellation: CapabilityEvidence {
49                    value: Support::Supported,
50                    endpoint: "POST http://localhost:11434/api/chat",
51                    documentation: "https://github.com/ollama/ollama-js#abort",
52                    inspected_on: "2026-10-16",
53                    basis: "The provider SDK documents chat streaming and abort of streamed generations, raising AbortError locally; it does not attest to exact remote termination.",
54                },
55                remote_request_cancellation: CapabilityEvidence {
56                    value: Support::Unsupported,
57                    endpoint: "POST http://localhost:11434/api/chat",
58                    documentation: "https://docs.ollama.com/api/chat",
59                    inspected_on: "2026-10-16",
60                    basis: "The chat endpoint documents generation, with no remote request cancellation facility. keep_alive controls model residency, not one request.",
61                },
62                request_status: CapabilityEvidence {
63                    value: Support::Unsupported,
64                    endpoint: "POST http://localhost:11434/api/chat",
65                    documentation: "https://docs.ollama.com/api/chat",
66                    inspected_on: "2026-10-16",
67                    basis: "The chat request and response document no in-flight request status facility; done reports completion in the current response only.",
68                },
69                idempotency: CapabilityEvidence {
70                    value: Support::Unsupported,
71                    endpoint: "POST http://localhost:11434/api/chat",
72                    documentation: "https://docs.ollama.com/api/chat",
73                    inspected_on: "2026-10-16",
74                    basis: "The chat request documents no idempotency key or deduplicated resend facility.",
75                },
76                exact_attempt_termination: CapabilityEvidence {
77                    value: Support::Unknown,
78                    endpoint: "POST http://localhost:11434/api/chat",
79                    documentation: "https://docs.ollama.com/api/chat",
80                    inspected_on: "2026-10-16",
81                    basis: "The chat documentation does not prove termination of one exact wire attempt; SDK abort is not that evidence.",
82                },
83            },
84            Provider::Omlx => Self {
85                local_request_cancellation: CapabilityEvidence {
86                    value: Support::Unknown,
87                    endpoint: "POST http://localhost:8000/v1/chat/completions",
88                    documentation: "https://github.com/jundot/omlx/blob/53ab0e66d75fe46e3cfa7ed7a7762d3bbcf21e9c/README.md#api-compatibility",
89                    inspected_on: "2026-10-16",
90                    basis: "The API endpoint inventory documents streaming chat completion but does not describe local request cancellation; OpenAI protocol compatibility alone is ambiguous.",
91                },
92                remote_request_cancellation: CapabilityEvidence {
93                    value: Support::Unsupported,
94                    endpoint: "POST http://localhost:8000/v1/chat/completions",
95                    documentation: "https://github.com/jundot/omlx/blob/53ab0e66d75fe46e3cfa7ed7a7762d3bbcf21e9c/README.md#api-compatibility",
96                    inspected_on: "2026-10-16",
97                    basis: "The documented API endpoint inventory has no remote cancellation operation for chat completions; admin model management is not per-request cancellation.",
98                },
99                request_status: CapabilityEvidence {
100                    value: Support::Unsupported,
101                    endpoint: "POST http://localhost:8000/v1/chat/completions",
102                    documentation: "https://github.com/jundot/omlx/blob/53ab0e66d75fe46e3cfa7ed7a7762d3bbcf21e9c/README.md#api-compatibility",
103                    inspected_on: "2026-10-16",
104                    basis: "The documented API endpoint inventory has no chat request status operation; model listing and usage analytics are not in-flight request status.",
105                },
106                idempotency: CapabilityEvidence {
107                    value: Support::Unknown,
108                    endpoint: "POST http://localhost:8000/v1/chat/completions",
109                    documentation: "https://github.com/jundot/omlx/blob/53ab0e66d75fe46e3cfa7ed7a7762d3bbcf21e9c/README.md#api-compatibility",
110                    inspected_on: "2026-10-16",
111                    basis: "The endpoint inventory does not specify chat request headers or deduplication semantics, so idempotency is ambiguous.",
112                },
113                exact_attempt_termination: CapabilityEvidence {
114                    value: Support::Unknown,
115                    endpoint: "POST http://localhost:8000/v1/chat/completions",
116                    documentation: "https://github.com/jundot/omlx/blob/53ab0e66d75fe46e3cfa7ed7a7762d3bbcf21e9c/README.md#api-compatibility",
117                    inspected_on: "2026-10-16",
118                    basis: "The streaming endpoint documentation does not prove termination of one exact wire attempt.",
119                },
120            },
121            Provider::OpenAi => Self {
122                local_request_cancellation: CapabilityEvidence {
123                    value: Support::Supported,
124                    endpoint: "POST https://api.openai.com/v1/chat/completions",
125                    documentation: "https://developers.openai.com/api/reference/resources/chat/subresources/completions/streaming-events",
126                    inspected_on: "2026-10-16",
127                    basis: "Chat Completions streaming documents interrupted or cancelled streams and potentially missing final usage; this is local stream cancellation only.",
128                },
129                remote_request_cancellation: CapabilityEvidence {
130                    value: Support::Unsupported,
131                    endpoint: "POST https://api.openai.com/v1/chat/completions",
132                    documentation: "https://developers.openai.com/api/reference/resources/chat/subresources/completions",
133                    inspected_on: "2026-10-16",
134                    basis: "The Chat Completions operation inventory has no remote cancel operation. Deleting a stored completion is not cancellation of inference.",
135                },
136                request_status: CapabilityEvidence {
137                    value: Support::Unsupported,
138                    endpoint: "POST https://api.openai.com/v1/chat/completions",
139                    documentation: "https://developers.openai.com/api/reference/resources/chat/subresources/completions",
140                    inspected_on: "2026-10-16",
141                    basis: "Retrieval requires store=true and a completion ID; it retrieves a stored result, not the status of an in-flight or ambiguously accepted POST.",
142                },
143                idempotency: CapabilityEvidence {
144                    value: Support::Unsupported,
145                    endpoint: "POST https://api.openai.com/v1/chat/completions",
146                    documentation: "https://developers.openai.com/api/reference/resources/chat/subresources/completions",
147                    inspected_on: "2026-10-16",
148                    basis: "The documented Chat Completions request parameters describe no idempotency facility for replaying this POST.",
149                },
150                exact_attempt_termination: CapabilityEvidence {
151                    value: Support::Unknown,
152                    endpoint: "POST https://api.openai.com/v1/chat/completions",
153                    documentation: "https://developers.openai.com/api/reference/resources/chat/subresources/completions",
154                    inspected_on: "2026-10-16",
155                    basis: "The documentation does not prove termination of one exact wire attempt; local stream closure is insufficient.",
156                },
157            },
158        }
159    }
160}