connector-usage-only: regenerate v4 goldens and schemas, format, fix tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
28f2e5d2e7
commit
bb8909f2c2
24 changed files with 206 additions and 201 deletions
|
|
@ -5,8 +5,9 @@ use std::sync::{Arc, Mutex};
|
|||
use std::time::Duration;
|
||||
|
||||
use model_connector::{
|
||||
CallerAdmission, PlanQuotaSnapshot, ReasoningEffort, StopReason, ToolDefinition, TransportAdmission, TransportDisposition, TransportInvocation,
|
||||
TransportKey, TransportReceipt, TransportService, decrypt_result, encrypt_invocation,
|
||||
CallerAdmission, PlanQuotaSnapshot, ReasoningEffort, StopReason, ToolDefinition,
|
||||
TransportAdmission, TransportDisposition, TransportInvocation, TransportKey, TransportReceipt,
|
||||
TransportService, decrypt_result, encrypt_invocation,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
|
@ -480,8 +481,7 @@ impl Door {
|
|||
.unwrap()
|
||||
});
|
||||
let service =
|
||||
TransportService::open(&dir.join("replay.cc"), PROVIDER, callers, 5_000)
|
||||
.unwrap();
|
||||
TransportService::open(&dir.join("replay.cc"), PROVIDER, callers, 5_000).unwrap();
|
||||
Self { dir, service }
|
||||
}
|
||||
|
||||
|
|
@ -498,13 +498,13 @@ impl Door {
|
|||
request: ProviderRequest,
|
||||
) -> (model_connector::ExecutionClaim, TransportInvocation) {
|
||||
let key = TransportKey::from_connection_secret(&format!("{caller}-key")).unwrap();
|
||||
let invocation =
|
||||
TransportInvocation::new(caller, 2_000, [7; 32], request).unwrap();
|
||||
let invocation = TransportInvocation::new(caller, 2_000, [7; 32], request).unwrap();
|
||||
let envelope = encrypt_invocation(&invocation, &key).unwrap();
|
||||
match self
|
||||
.service
|
||||
.begin(&envelope, 1_000, &PlanQuotaSnapshot::default(), FRAME)
|
||||
.unwrap() {
|
||||
.unwrap()
|
||||
{
|
||||
TransportAdmission::Execute(claim) => (*claim, invocation),
|
||||
TransportAdmission::Reply(_) => panic!("the door answered instead of admitting"),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ use std::time::Duration;
|
|||
|
||||
use cultcache_rs::{CultCache, DatabaseEntry, SingleFileMessagePackBackingStore};
|
||||
use model_connector::{
|
||||
CallerAdmission, CallerConfig, LeaseTurn, MIN_PAYLOAD_BYTES, ProviderBackend,
|
||||
ServeError, ServeLimits, ServiceError, TransportService, load_admissions, serve_service,
|
||||
CallerAdmission, CallerConfig, LeaseTurn, MIN_PAYLOAD_BYTES, ProviderBackend, ServeError,
|
||||
ServeLimits, ServiceError, TransportService, load_admissions, serve_service,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
|
|
@ -230,9 +230,7 @@ impl ClaudeConnectorConfig {
|
|||
}
|
||||
let mut seen = BTreeSet::new();
|
||||
for model in &caller.allowed_models {
|
||||
if !has_model_id_form(model)
|
||||
|| !seen.insert(model.as_str())
|
||||
{
|
||||
if !has_model_id_form(model) || !seen.insert(model.as_str()) {
|
||||
return Err(ConfigError::Invalid("allowed_models"));
|
||||
}
|
||||
}
|
||||
|
|
@ -344,7 +342,6 @@ fn has_model_id_form(model: &str) -> bool {
|
|||
&& after_ok
|
||||
}
|
||||
|
||||
|
||||
/// One file name under `$CREDENTIALS_DIRECTORY`, never a path.
|
||||
fn is_credential_name(name: &str) -> bool {
|
||||
!name.is_empty()
|
||||
|
|
|
|||
|
|
@ -671,9 +671,9 @@ mod tests {
|
|||
fn a_frame_that_trickles_past_its_deadline_is_refused_however_small_each_read() {
|
||||
let (mut reader, mut writer) = UnixStream::pair().unwrap();
|
||||
let frame = encode_frame(&LeaseMessage::ClaudeLeaseRefusal(LeaseRefused {
|
||||
kind: LeaseRefusalKind::Busy,
|
||||
detail: "lease:x".to_string(),
|
||||
}));
|
||||
kind: LeaseRefusalKind::Busy,
|
||||
detail: "lease:x".to_string(),
|
||||
}));
|
||||
let trickle = thread::spawn(move || {
|
||||
for byte in frame {
|
||||
if writer.write_all(&[byte]).is_err() {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ pub use launch::ChildEnv;
|
|||
#[cfg(target_os = "linux")]
|
||||
pub use lease::{
|
||||
LeaseCaller, LeaseGranted, LeaseLimits, LeaseMessage, LeaseRefusalKind, LeaseRefused,
|
||||
LeaseRequest, MAX_LEASE_FRAME_BYTES, PeerCredentials, PeerUnit,
|
||||
PeerUnits, decode_frame, encode_frame, peer_credentials, serve_leases, user_uid,
|
||||
LeaseRequest, MAX_LEASE_FRAME_BYTES, PeerCredentials, PeerUnit, PeerUnits, decode_frame,
|
||||
encode_frame, peer_credentials, serve_leases, user_uid,
|
||||
};
|
||||
#[cfg(unix)]
|
||||
pub use process::StdProcessPort;
|
||||
|
|
|
|||
|
|
@ -280,6 +280,9 @@ fn the_dollar_flags_are_not_flags() {
|
|||
let scratch = Scratch::new();
|
||||
let made = init(&scratch, &init_flags(&scratch, extra));
|
||||
assert!(!made.status.success(), "{extra:?} was accepted");
|
||||
assert!(!Path::new(&scratch.path("connector.cc")).exists(), "{extra:?}");
|
||||
assert!(
|
||||
!Path::new(&scratch.path("connector.cc")).exists(),
|
||||
"{extra:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,7 +279,12 @@ fn start(setup: Setup) -> Harness {
|
|||
});
|
||||
let quota = Arc::new(QuotaCell::new());
|
||||
let listener = UnixListener::bind(&socket).unwrap();
|
||||
let serving = (service.clone(), quota.clone(), tokens.clone(), units.clone());
|
||||
let serving = (
|
||||
service.clone(),
|
||||
quota.clone(),
|
||||
tokens.clone(),
|
||||
units.clone(),
|
||||
);
|
||||
let caller = LeaseCaller {
|
||||
uid: setup.uid,
|
||||
caller_id: CALLER.to_string(),
|
||||
|
|
@ -343,7 +348,10 @@ fn ask_until_granted(harness: &Harness, first_invocation: u64) -> Answer {
|
|||
fn a_grant_passes_one_fd_holding_the_token_then_end_of_file() {
|
||||
let harness = start(setup());
|
||||
let mut answer = ask(&harness, 60_000);
|
||||
assert_eq!(granted(&answer).lease_id, format!("lease:{}", invocation(1)));
|
||||
assert_eq!(
|
||||
granted(&answer).lease_id,
|
||||
format!("lease:{}", invocation(1))
|
||||
);
|
||||
assert_eq!(answer.fds.len(), 1);
|
||||
let mut read = Vec::new();
|
||||
File::from(answer.fds.remove(0))
|
||||
|
|
@ -351,7 +359,10 @@ fn a_grant_passes_one_fd_holding_the_token_then_end_of_file() {
|
|||
.unwrap();
|
||||
assert_eq!(read, TOKEN.as_bytes());
|
||||
assert_eq!(harness.tokens.reads.load(Ordering::SeqCst), 1);
|
||||
assert!(!contains(&answer.raw, TOKEN), "the token is in the pipe only");
|
||||
assert!(
|
||||
!contains(&answer.raw, TOKEN),
|
||||
"the token is in the pipe only"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -416,7 +427,10 @@ fn a_rejected_window_refuses_the_lease_until_its_reset() {
|
|||
.quota
|
||||
.observe([window("five_hour", 1_000, "rejected", reset)]);
|
||||
let refused = ask(&harness, 60_000);
|
||||
assert_eq!(refusal_of(&refused), Some(LeaseRefusalKind::ProviderRejected));
|
||||
assert_eq!(
|
||||
refusal_of(&refused),
|
||||
Some(LeaseRefusalKind::ProviderRejected)
|
||||
);
|
||||
assert!(refused.fds.is_empty());
|
||||
assert_eq!(harness.tokens.reads.load(Ordering::SeqCst), 0);
|
||||
// At the provider's own reset the refusal lifts, with no one lifting it.
|
||||
|
|
|
|||
Loading…
Reference in a new issue