style(server,agent): fmt + clippy fixes for Task 5 (CI green)
All checks were successful
All checks were successful
9082e11 compiles + passes all 50 server tests on the build host; only blocked
CI on cargo fmt (4 files) and one clippy -D dead-code denial:
- cargo fmt --all (relay/mod.rs, session/mod.rs, agent consent/mod.rs + session/mod.rs)
- #[cfg_attr(not(test), allow(dead_code))] on session::get_consent_state (a
read accessor currently exercised only by tests)
No logic change.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -851,7 +851,8 @@ async fn handle_agent_connection(
|
||||
tracing::debug!(
|
||||
"Late ConsentResponse from agent {} on session {}; ignoring \
|
||||
(consent already finalized)",
|
||||
agent_id, session_id
|
||||
agent_id,
|
||||
session_id
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
@@ -978,7 +979,16 @@ async fn run_consent_handshake(
|
||||
"Failed to encode ConsentRequest for session {}; denying",
|
||||
session_id
|
||||
);
|
||||
finalize_consent(sessions, db, session_id, agent_id, false, "encode_error", client_ip).await;
|
||||
finalize_consent(
|
||||
sessions,
|
||||
db,
|
||||
session_id,
|
||||
agent_id,
|
||||
false,
|
||||
"encode_error",
|
||||
client_ip,
|
||||
)
|
||||
.await;
|
||||
return false;
|
||||
}
|
||||
if ws_sender.send(Message::Binary(buf)).await.is_err() {
|
||||
@@ -986,7 +996,16 @@ async fn run_consent_handshake(
|
||||
"Failed to send ConsentRequest to agent {} (session {}); denying",
|
||||
agent_id, session_id
|
||||
);
|
||||
finalize_consent(sessions, db, session_id, agent_id, false, "send_error", client_ip).await;
|
||||
finalize_consent(
|
||||
sessions,
|
||||
db,
|
||||
session_id,
|
||||
agent_id,
|
||||
false,
|
||||
"send_error",
|
||||
client_ip,
|
||||
)
|
||||
.await;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1010,8 +1029,8 @@ async fn run_consent_handshake(
|
||||
}
|
||||
|
||||
// 2. Wait for the ConsentResponse, bounded by the timeout.
|
||||
let deadline = tokio::time::Instant::now()
|
||||
+ std::time::Duration::from_secs(CONSENT_TIMEOUT_SECS);
|
||||
let deadline =
|
||||
tokio::time::Instant::now() + std::time::Duration::from_secs(CONSENT_TIMEOUT_SECS);
|
||||
|
||||
loop {
|
||||
let remaining = deadline.saturating_duration_since(tokio::time::Instant::now());
|
||||
@@ -1020,7 +1039,10 @@ async fn run_consent_handshake(
|
||||
"Attended session {}: consent timed out after {}s; denying",
|
||||
session_id, CONSENT_TIMEOUT_SECS
|
||||
);
|
||||
finalize_consent(sessions, db, session_id, agent_id, false, "timeout", client_ip).await;
|
||||
finalize_consent(
|
||||
sessions, db, session_id, agent_id, false, "timeout", client_ip,
|
||||
)
|
||||
.await;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1031,8 +1053,10 @@ async fn run_consent_handshake(
|
||||
"Attended session {}: consent timed out after {}s; denying",
|
||||
session_id, CONSENT_TIMEOUT_SECS
|
||||
);
|
||||
finalize_consent(sessions, db, session_id, agent_id, false, "timeout", client_ip)
|
||||
.await;
|
||||
finalize_consent(
|
||||
sessions, db, session_id, agent_id, false, "timeout", client_ip,
|
||||
)
|
||||
.await;
|
||||
return false;
|
||||
}
|
||||
// Socket closed before answering.
|
||||
@@ -1042,7 +1066,13 @@ async fn run_consent_handshake(
|
||||
session_id, agent_id
|
||||
);
|
||||
finalize_consent(
|
||||
sessions, db, session_id, agent_id, false, "agent_disconnected", client_ip,
|
||||
sessions,
|
||||
db,
|
||||
session_id,
|
||||
agent_id,
|
||||
false,
|
||||
"agent_disconnected",
|
||||
client_ip,
|
||||
)
|
||||
.await;
|
||||
return false;
|
||||
@@ -1106,7 +1136,13 @@ async fn run_consent_handshake(
|
||||
session_id, agent_id
|
||||
);
|
||||
finalize_consent(
|
||||
sessions, db, session_id, agent_id, false, "agent_closed", client_ip,
|
||||
sessions,
|
||||
db,
|
||||
session_id,
|
||||
agent_id,
|
||||
false,
|
||||
"agent_closed",
|
||||
client_ip,
|
||||
)
|
||||
.await;
|
||||
return false;
|
||||
@@ -1152,8 +1188,8 @@ async fn finalize_consent(
|
||||
|
||||
if let Some(db) = db {
|
||||
// Durable mirror of the consent decision on the session row.
|
||||
let _ = db::sessions::update_consent_state(db.pool(), session_id, new_state.as_db_str())
|
||||
.await;
|
||||
let _ =
|
||||
db::sessions::update_consent_state(db.pool(), session_id, new_state.as_db_str()).await;
|
||||
|
||||
// Audit event (consent_granted | consent_denied) with the agent id and
|
||||
// the (non-secret) reason so the decision is fully traceable.
|
||||
|
||||
Reference in New Issue
Block a user