rustfmt the connector kit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-28 06:05:16 +01:00
commit 15a41343ce
6 changed files with 73 additions and 43 deletions

View file

@ -70,7 +70,6 @@ impl ConnectorClient {
}
}
#[cfg(test)]
mod client_endpoint_tests {
use super::*;
@ -110,7 +109,6 @@ mod client_endpoint_tests {
}
}
#[derive(Debug, Error)]
pub enum ConnectorClientError {
#[error("invalid connector client configuration")]

View file

@ -289,10 +289,7 @@ impl TransportResult {
}
}
pub fn validate_against(
&self,
invocation: &TransportInvocation,
) -> Result<(), ContractError> {
pub fn validate_against(&self, invocation: &TransportInvocation) -> Result<(), ContractError> {
if self.schema_id != RESULT_SCHEMA_ID {
return Err(ContractError::Schema);
}
@ -363,10 +360,7 @@ pub struct TransportReceipt {
}
impl TransportReceipt {
pub fn validate_against(
&self,
invocation: &TransportInvocation,
) -> Result<(), ContractError> {
pub fn validate_against(&self, invocation: &TransportInvocation) -> Result<(), ContractError> {
if self.schema_id != RECEIPT_SCHEMA_ID {
return Err(ContractError::Schema);
}
@ -518,7 +512,6 @@ pub enum ContractError {
Encoding,
}
#[cfg(test)]
mod tests {
use super::*;
@ -618,8 +611,7 @@ mod tests {
assert_eq!(result.validate_against(&invocation), Ok(()));
let mut reordered = result;
let TransportDisposition::Transported { events, .. } = &mut reordered.disposition
else {
let TransportDisposition::Transported { events, .. } = &mut reordered.disposition else {
unreachable!()
};
events[0].sequence = 1;

View file

@ -497,12 +497,18 @@ mod tests {
#[test]
fn the_payload_bound_a_frame_allows_inverts_the_frame_a_payload_needs() {
assert_eq!(payload_bytes_for_frame(frame_bytes_for_payload(0) - 1), None);
assert_eq!(
payload_bytes_for_frame(frame_bytes_for_payload(0) - 1),
None
);
assert_eq!(payload_bytes_for_frame(frame_bytes_for_payload(0)), Some(0));
for bytes in [1, 15, 16, 4096, 65_535, 65_536, 100_000, 2_000_000] {
let frame = frame_bytes_for_payload(bytes);
assert_eq!(payload_bytes_for_frame(frame), Some(bytes), "{bytes}");
assert!(payload_bytes_for_frame(frame - 1).unwrap() < bytes, "{bytes}");
assert!(
payload_bytes_for_frame(frame - 1).unwrap() < bytes,
"{bytes}"
);
}
}
}

View file

@ -126,4 +126,3 @@ pub(crate) fn invocation_for(caller_runtime_id: &str, request_id: &str) -> Trans
request.request_id = request_id.to_string();
TransportInvocation::new(caller_runtime_id, 2_000, [7; 32], request).unwrap()
}

View file

@ -12,8 +12,8 @@ use zeroize::Zeroizing;
use crate::contract::{TransportInvocation, TransportResult};
use crate::envelope::{
ServiceError, TransportEnvelope, TransportFrameError, read_transport_frame, frame_bytes_for_payload,
write_transport_frame,
ServiceError, TransportEnvelope, TransportFrameError, frame_bytes_for_payload,
read_transport_frame, write_transport_frame,
};
use crate::service::{CallerAdmission, TransportAdmission, TransportService};
@ -766,20 +766,14 @@ mod tests {
);
// The tightest legal pair: the smallest payload in the smallest frame.
assert_eq!(refusal(frame(tightest), payload(4096)), None);
assert_eq!(
refusal(frame(tightest), payload(4097)),
Some("frame bound")
);
assert_eq!(refusal(frame(tightest), payload(4097)), Some("frame bound"));
assert_eq!(
refusal(frame(tightest), payload(4095)),
Some("caller admission")
);
// The bound is the sealed frame at its worst encoding, not the payload:
// a payload that is the whole frame cannot be carried.
assert_eq!(
refusal(frame(FRAME), payload(FRAME)),
Some("frame bound")
);
assert_eq!(refusal(frame(FRAME), payload(FRAME)), Some("frame bound"));
for bytes in [8192, 65_535, 65_536, 100_000] {
let widest = frame_bytes_for_payload(bytes);
assert_eq!(refusal(frame(widest), payload(bytes)), None, "{bytes}");

View file

@ -531,7 +531,8 @@ mod tests {
.begin(
&encrypt_invocation(&epiphany, &security("epiphany-distinct-test-key"))
.unwrap(),
1_000, FRAME,
1_000,
FRAME,
)
.unwrap(),
TransportAdmission::Execute(_)
@ -541,7 +542,8 @@ mod tests {
.begin(
&encrypt_invocation(&ghostlight, &security("ghostlight-distinct-test-key"))
.unwrap(),
1_000, FRAME,
1_000,
FRAME,
)
.unwrap(),
TransportAdmission::Execute(_)
@ -555,7 +557,11 @@ mod tests {
let security = security("epiphany-distinct-test-key");
let mut service = open_service(&store, 1);
let claim = match service
.begin(&encrypt_invocation(&invocation, &security).unwrap(), 1_000, FRAME)
.begin(
&encrypt_invocation(&invocation, &security).unwrap(),
1_000,
FRAME,
)
.unwrap()
{
TransportAdmission::Execute(claim) => claim,
@ -583,7 +589,11 @@ mod tests {
let mut service = open_service(&store, 1);
let replay = match service
.begin(&encrypt_invocation(&invocation, &security).unwrap(), 1_000, FRAME)
.begin(
&encrypt_invocation(&invocation, &security).unwrap(),
1_000,
FRAME,
)
.unwrap()
{
TransportAdmission::Reply(response) => response,
@ -602,7 +612,11 @@ mod tests {
TransportInvocation::new("epiphany-yggdrasil", 2_000, [7; 32], changed_request)
.unwrap();
let refusal = match service
.begin(&encrypt_invocation(&conflicting, &security).unwrap(), 1_000, FRAME)
.begin(
&encrypt_invocation(&conflicting, &security).unwrap(),
1_000,
FRAME,
)
.unwrap()
{
TransportAdmission::Reply(response) => response,
@ -631,7 +645,11 @@ mod tests {
for (invocation, expected) in [(&first, Refusal::InFlight), (&second, Refusal::Capacity)] {
let response = match service
.begin(&encrypt_invocation(invocation, &security).unwrap(), 1_000, FRAME)
.begin(
&encrypt_invocation(invocation, &security).unwrap(),
1_000,
FRAME,
)
.unwrap()
{
TransportAdmission::Reply(response) => response,
@ -655,7 +673,11 @@ mod tests {
let mut service = open_service(&store, 1);
assert!(matches!(
service
.begin(&encrypt_invocation(&first, &security).unwrap(), 1_000, FRAME)
.begin(
&encrypt_invocation(&first, &security).unwrap(),
1_000,
FRAME
)
.unwrap(),
TransportAdmission::Execute(_)
));
@ -663,7 +685,11 @@ mod tests {
let mut restarted = open_service(&store, 1);
let ambiguous = match restarted
.begin(&encrypt_invocation(&first, &security).unwrap(), 1_000, FRAME)
.begin(
&encrypt_invocation(&first, &security).unwrap(),
1_000,
FRAME,
)
.unwrap()
{
TransportAdmission::Reply(response) => response,
@ -677,7 +703,11 @@ mod tests {
);
assert!(matches!(
restarted
.begin(&encrypt_invocation(&second, &security).unwrap(), 1_000, FRAME)
.begin(
&encrypt_invocation(&second, &security).unwrap(),
1_000,
FRAME
)
.unwrap(),
TransportAdmission::Execute(_)
));
@ -808,12 +838,16 @@ mod tests {
let mut expired = invocation_for(CALLER, "expired");
expired.expires_at_unix_ms = 10;
let reply = service.begin(&raw_envelope(&expired), 1_000, FRAME).unwrap();
let reply = service
.begin(&raw_envelope(&expired), 1_000, FRAME)
.unwrap();
assert_eq!(refusal_of(reply, &expired), Refusal::Expired);
let mut substituted = invocation_for(CALLER, "substituted");
substituted.provider_request_sha256 = [9; 32];
let reply = service.begin(&raw_envelope(&substituted), 1_000, FRAME).unwrap();
let reply = service
.begin(&raw_envelope(&substituted), 1_000, FRAME)
.unwrap();
assert_eq!(
refusal_of(reply, &substituted),
Refusal::ProviderDigestSubstitution
@ -821,7 +855,9 @@ mod tests {
let mut malformed = invocation_for(CALLER, "malformed");
malformed.native_request_sha256 = [0; 32];
let reply = service.begin(&raw_envelope(&malformed), 1_000, FRAME).unwrap();
let reply = service
.begin(&raw_envelope(&malformed), 1_000, FRAME)
.unwrap();
assert_eq!(refusal_of(reply, &malformed), Refusal::Malformed);
}
@ -1003,7 +1039,10 @@ mod tests {
request_id: &str,
) -> (Box<ExecutionClaim>, TransportInvocation) {
let invocation = invocation_for(CALLER, request_id);
match service.begin(&raw_envelope(&invocation), 1_000, FRAME).unwrap() {
match service
.begin(&raw_envelope(&invocation), 1_000, FRAME)
.unwrap()
{
TransportAdmission::Execute(claim) => (claim, invocation),
TransportAdmission::Reply(_) => panic!("expected an execution claim"),
}
@ -1053,8 +1092,9 @@ mod tests {
assert_eq!(receipt.transport, "model-connector");
// The recorded replay is the stand-in's exact bytes.
let TransportAdmission::Reply(replay) =
service.begin(&raw_envelope(&invocation), 1_000, FRAME).unwrap()
let TransportAdmission::Reply(replay) = service
.begin(&raw_envelope(&invocation), 1_000, FRAME)
.unwrap()
else {
panic!("expected a replay");
};
@ -1174,8 +1214,9 @@ mod tests {
);
// Still active, never completed, and no longer live: the retry is told the
// outcome is indeterminate.
let TransportAdmission::Reply(reply) =
service.begin(&raw_envelope(&invocation), 1_000, FRAME).unwrap()
let TransportAdmission::Reply(reply) = service
.begin(&raw_envelope(&invocation), 1_000, FRAME)
.unwrap()
else {
panic!("expected a refusal");
};