Files
leleka/desktop-core/src/runtime_gateway.rs
T
Pavlo Ratushnyi 6b5fcd242e STRA-338 S12b: fns and impl blocks of 59 cold oversize modules move into child modules (model-format, gateway, desktop-core, leaf libraries)
scripts/dev/split_module.py (lexer-based, with 16 self-tests) moves the top-level fn and impl items of 59 oversize module files in control-plane, desktop-core, model-format, gateway-text, leleka-memory, experimental-ref, context, serving-policy, tokenizer, backend-api, quant-core, harmony, igpu, libc-shim, npu-service and runtime-client into foo/<name>.rs groups of about 250 lines; types, constants, macros, nested modules and tests stay, every path stays valid through pub use re-exports, restricted visibilities keep their scope one level down, include paths and super:: paths are shifted. Not touched: leleka-runtime, cuda-driver, native-cpu-expert, sampler-ref and cpu-* (hot path, next wave) and the files kar-off-ab edits.

The baseline drops from 311 to 263 oversize files and from 273,600 to about 233,000 lines; the path-include ratchet ignores dir/name.rs child declarations.
2026-11-05 15:29:39 +01:00

95 lines
2.3 KiB
Rust

//! Explicit runtime catalog and OpenAI text adapter; compute stays behind gRPC.
use crate::{
gateway,
runtime_client::{RuntimeClient, RuntimeGeneration},
runtime_prompt::{self, Effort, Message, Role},
runtime_rpc::proto,
};
use axum::{
Json, Router,
body::{Body, Bytes},
extract::{DefaultBodyLimit, State},
http::{HeaderMap, StatusCode},
response::{IntoResponse, Response},
routing::{get, post},
};
use leleka_sampler_ref::params::FixedPoint;
use serde::Deserialize;
use serde_json::{Value, json};
use std::{collections::HashSet, net::SocketAddr, sync::Arc, time::Duration};
use subtle::ConstantTimeEq;
use tokio::sync::Mutex;
#[derive(Clone, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Member {
pub id: String,
pub address: SocketAddr,
pub token_env: String,
pub artifact_digest: String,
}
#[derive(Clone, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Config {
pub schema_version: u32,
pub listen: SocketAddr,
pub token_env: String,
pub runtimes: Vec<Member>,
pub http_pool: Option<gateway::Config>,
#[serde(default)]
pub experimental_native_tools: bool,
}
struct MemberState {
client: Option<RuntimeClient>,
snapshot: Option<proto::Snapshot>,
blocked: bool,
}
struct Peer {
config: Member,
token: String,
state: Mutex<MemberState>,
}
struct Inner {
token: String,
peers: Vec<Peer>,
fallback: Option<gateway::Gateway>,
experimental_native_tools: bool,
}
#[derive(Clone)]
pub struct Registry(Arc<Inner>);
/// Commands can address only members already admitted by operator configuration.
/// UUID and epoch identify uncertain outcomes; lifecycle calls are never replayed.
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct Control {
model: String,
operation_id: String,
epoch: String,
mode: Option<String>,
profile_id: Option<String>,
handle: Option<String>,
}
struct Trace {
id: String,
model: String,
text: String,
usage: proto::Usage,
sequence: u64,
}
#[cfg(test)]
mod tests;
mod credential;
#[allow(unused_imports)]
pub use credential::*;
mod load;
#[allow(unused_imports)]
pub use load::*;
mod response_value;
#[allow(unused_imports)]
pub use response_value::*;
mod buffered_tool_generation;
#[allow(unused_imports)]
pub use buffered_tool_generation::*;