B4b1 claude-connector-binary: connector daemon over one CultCache config document; token from a systemd credential, pin before every spawn, private prompt dir, 401/403/429 door set, shared readiness for check and serve (squash of eureka-body/claude-connector-binary 200933f..67c7849; Soul s1, s2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
200933f7cf
commit
e867fad379
14 changed files with 2273 additions and 134 deletions
|
|
@ -23,10 +23,11 @@ use crate::service::{
|
|||
/// The only provider seam of the connector kit. A connector binary implements
|
||||
/// it over one model provider; the kit names no provider.
|
||||
pub trait ProviderBackend: Send + Sync {
|
||||
/// Whether the provider can take work. `serve` consults it once, before it
|
||||
/// opens the replay store or accepts a connection; the request path does
|
||||
/// not consult it.
|
||||
fn ready(&self) -> bool;
|
||||
/// Whether the provider can take work; `Err` names the backend field that
|
||||
/// is not ready, never a value. `serve` consults it once, before it opens
|
||||
/// the replay store or accepts a connection; the request path does not
|
||||
/// consult it.
|
||||
fn ready(&self) -> Result<(), &'static str>;
|
||||
/// The tag of the provider this backend fronts. The service owns it from
|
||||
/// `serve` on: it names the provider on every receipt and decides which
|
||||
/// reasoning state is foreign.
|
||||
|
|
@ -59,7 +60,7 @@ impl ServeLimits {
|
|||
/// largest whose sealed frame, at its worst-case encoding, fits the frame.
|
||||
/// An admitted payload therefore always fits, and `complete` is given the
|
||||
/// same frame bound to fit every result in.
|
||||
fn validate(&self, admissions: &[CallerAdmission]) -> Result<(), ServeError> {
|
||||
pub fn validate(&self, admissions: &[CallerAdmission]) -> Result<(), ServeError> {
|
||||
if self.max_frame_bytes == 0
|
||||
|| self.max_frame_bytes > u32::MAX as usize
|
||||
|| self.max_connections == 0
|
||||
|
|
@ -171,9 +172,7 @@ pub fn serve(
|
|||
{
|
||||
return Err(ServeError::InvalidConfig("listener address"));
|
||||
}
|
||||
if !backend.ready() {
|
||||
return Err(ServeError::BackendUnready);
|
||||
}
|
||||
backend.ready().map_err(ServeError::BackendUnready)?;
|
||||
let service = Arc::new(Mutex::new(TransportService::open(
|
||||
replay_store,
|
||||
backend.provider(),
|
||||
|
|
@ -322,8 +321,8 @@ pub enum ServeError {
|
|||
ConnectionKey(#[source] std::io::Error),
|
||||
#[error(transparent)]
|
||||
Service(#[from] ServiceError),
|
||||
#[error("provider backend is not ready")]
|
||||
BackendUnready,
|
||||
#[error("provider backend is not ready: {0}")]
|
||||
BackendUnready(&'static str),
|
||||
#[error("connector service lock was poisoned")]
|
||||
ServicePoisoned,
|
||||
#[error("connector listener failed")]
|
||||
|
|
@ -379,9 +378,9 @@ mod tests {
|
|||
}
|
||||
|
||||
impl ProviderBackend for CountingBackend {
|
||||
fn ready(&self) -> bool {
|
||||
fn ready(&self) -> Result<(), &'static str> {
|
||||
self.ready_calls.fetch_add(1, Ordering::SeqCst);
|
||||
self.ready
|
||||
self.ready.then_some(()).ok_or("fixture")
|
||||
}
|
||||
|
||||
fn provider(&self) -> &str {
|
||||
|
|
@ -710,7 +709,10 @@ mod tests {
|
|||
&store.path,
|
||||
backend.clone(),
|
||||
);
|
||||
assert!(matches!(result, Some(Err(ServeError::BackendUnready))));
|
||||
assert!(matches!(
|
||||
result,
|
||||
Some(Err(ServeError::BackendUnready("fixture")))
|
||||
));
|
||||
assert_eq!(backend.executions.load(Ordering::SeqCst), 0);
|
||||
assert!(
|
||||
!store.path.exists(),
|
||||
|
|
@ -1016,8 +1018,8 @@ mod tests {
|
|||
}
|
||||
|
||||
impl ProviderBackend for SizedBackend {
|
||||
fn ready(&self) -> bool {
|
||||
true
|
||||
fn ready(&self) -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn provider(&self) -> &str {
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ impl CallerAdmission {
|
|||
}
|
||||
|
||||
/// What one million tokens of each class cost, in micro-USD.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Rates {
|
||||
pub input: u64,
|
||||
pub cache_write_short: u64,
|
||||
|
|
@ -129,7 +129,7 @@ pub struct Rates {
|
|||
}
|
||||
|
||||
/// The rates a prompt strictly above `above_prompt_tokens` is priced at.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct LongContext {
|
||||
pub above_prompt_tokens: u64,
|
||||
pub rates: Rates,
|
||||
|
|
@ -138,7 +138,7 @@ pub struct LongContext {
|
|||
/// One model's price. Explicit zero rates are admitted (a local model is
|
||||
/// free); a missing price is not. `overhead_tokens` is added to the byte
|
||||
/// bound of a request when its worst case is reserved.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ModelPrice {
|
||||
pub rates: Rates,
|
||||
pub long_context: Option<LongContext>,
|
||||
|
|
|
|||
Loading…
Reference in a new issue