-
Notifications
You must be signed in to change notification settings - Fork 0
Fix DeepSource bug-risk alerts #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,6 +157,7 @@ impl MotionReading { | |
| } | ||
|
|
||
| #[wasm_bindgen] | ||
| #[derive(Default)] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ LOW RISK Suggestion: Manual Default implementation replaced by derive macro. This is a clean refactor that maintains the expected initialization state. |
||
| pub struct DeviceSensors { | ||
| active: bool, | ||
| orientation_state: Rc<RefCell<Option<OrientationReadingState>>>, | ||
|
|
@@ -165,12 +166,6 @@ pub struct DeviceSensors { | |
| motion_listener: Option<Closure<dyn FnMut(Event)>>, | ||
| } | ||
|
|
||
| impl Default for DeviceSensors { | ||
| fn default() -> Self { | ||
| Self::new() | ||
| } | ||
| } | ||
|
|
||
| #[wasm_bindgen] | ||
| impl DeviceSensors { | ||
| #[must_use] | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -156,18 +156,18 @@ pub async fn run(agent: InitializedAgent) -> Result<(), RunnerError> { | |||||
| // Populate the slot before `on_connect` so Python sees a valid | ||||||
| // `storage.agent_id` from the first instant it can act. | ||||||
| *agent_id_slot.lock().unwrap_or_else(PoisonError::into_inner) = Some(agent_id.clone()); | ||||||
| drop(inbound_tx.send(InboundEvent::Connect(agent_id))); | ||||||
| let _connect_sent = inbound_tx.send(InboundEvent::Connect(agent_id)); | ||||||
|
|
||||||
| let result = drive(&mut socket, &inbound_tx, &mut outbound_rx).await; | ||||||
|
|
||||||
| // Queue `on_shutdown` (the worker drains any frames ahead of it first), | ||||||
| // then drop our sender so the worker's recv loop ends. Join before aborting | ||||||
| // the storage task so an `on_shutdown` that persists state can still reach | ||||||
| // it; only then close the socket and stop storage. | ||||||
| drop(inbound_tx.send(InboundEvent::Shutdown)); | ||||||
| let _shutdown_sent = inbound_tx.send(InboundEvent::Shutdown); | ||||||
| drop(inbound_tx); | ||||||
| drop(worker.join()); | ||||||
| drop(socket.send(tungstenite::Message::Close(None)).await); | ||||||
| let _joined = worker.join(); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 MEDIUM RISK Suggestion: Swallowing the join result hides panics in the dispatcher thread. Propagating the panic ensures that the agent fails visibly if the Python worker crashes.
Suggested change
Comment on lines
+159
to
+169
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: sed -n '1,360p' services/ws-pyo3-runner/src/agent.rsRepository: edge-toolkit/core Length of output: 13589 🏁 Script executed: rg -n "enum RunnerError|impl From<.*Join|SendError|worker.join|unbounded_channel|InboundEvent" services/ws-pyo3-runner/src -SRepository: edge-toolkit/core Length of output: 1770 🏁 Script executed: sed -n '1,220p' services/ws-pyo3-runner/src/error.rsRepository: edge-toolkit/core Length of output: 1160 Propagate dispatch-worker failure instead of silently dropping events. If 🤖 Prompt for AI Agents |
||||||
| let _close_sent = socket.send(tungstenite::Message::Close(None)).await; | ||||||
| storage_task.abort(); | ||||||
| result | ||||||
| } | ||||||
|
|
@@ -195,12 +195,16 @@ fn python_worker( | |||||
| } | ||||||
| } | ||||||
| InboundEvent::Text(text) => match dispatcher.on_text_frame(&text) { | ||||||
| Ok(Some(reply)) => drop(outbound_tx.send(OutboundFrame::Text(reply))), | ||||||
| Ok(Some(reply)) => { | ||||||
| let _sent = outbound_tx.send(OutboundFrame::Text(reply)); | ||||||
| } | ||||||
| Ok(None) => {} | ||||||
| Err(err) => warn!("on_text_frame raised: {err}"), | ||||||
| }, | ||||||
| InboundEvent::Binary(bytes) => match dispatcher.on_binary_frame(&bytes) { | ||||||
| Ok(Some(reply)) => drop(outbound_tx.send(OutboundFrame::Binary(reply))), | ||||||
| Ok(Some(reply)) => { | ||||||
| let _sent = outbound_tx.send(OutboundFrame::Binary(reply)); | ||||||
| } | ||||||
| Ok(None) => {} | ||||||
| Err(err) => warn!("on_binary_frame raised: {err}"), | ||||||
| }, | ||||||
|
|
@@ -233,7 +237,7 @@ async fn storage_worker(http_base: String, mut rx: mpsc::UnboundedReceiver<Stora | |||||
| Err(et_rest_client::Error::ErrorResponse(_)) => Ok(None), | ||||||
| Err(source) => Err(StorageError::get(&agent_id, &key, source.to_string())), | ||||||
| }; | ||||||
| drop(reply.send(outcome)); | ||||||
| let _reply_sent = reply.send(outcome); | ||||||
| } | ||||||
| StorageOp::Put { | ||||||
| agent_id, | ||||||
|
|
@@ -245,7 +249,7 @@ async fn storage_worker(http_base: String, mut rx: mpsc::UnboundedReceiver<Stora | |||||
| Ok(_) => Ok(()), | ||||||
| Err(source) => Err(StorageError::put(&agent_id, &key, source.to_string())), | ||||||
| }; | ||||||
| drop(reply.send(outcome)); | ||||||
| let _reply_sent = reply.send(outcome); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
@@ -273,10 +277,10 @@ async fn drive( | |||||
| // pushes to via WsSender, so multi-send + reply compose in order. | ||||||
| frame = socket.next() => match frame { | ||||||
| Some(Ok(tungstenite::Message::Binary(bytes))) => { | ||||||
| drop(inbound_tx.send(InboundEvent::Binary(bytes))); | ||||||
| let _forwarded = inbound_tx.send(InboundEvent::Binary(bytes)); | ||||||
| } | ||||||
| Some(Ok(tungstenite::Message::Text(text))) => { | ||||||
| drop(inbound_tx.send(InboundEvent::Text(text))); | ||||||
| let _forwarded = inbound_tx.send(InboundEvent::Text(text)); | ||||||
| } | ||||||
| Some(Ok(tungstenite::Message::Close(_))) => { | ||||||
| info!("server closed connection"); | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -116,8 +116,8 @@ async fn module_behaves( | |||||
| }; | ||||||
| let outcome = tokio::time::timeout(budget, run_exchange(&mut control, &control_id, &exchange)).await; | ||||||
|
|
||||||
| drop(runner.kill()); | ||||||
| drop(runner.wait()); | ||||||
| runner.kill().unwrap(); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 MEDIUM RISK This
Suggested change
|
||||||
| let _status = runner.wait().unwrap(); | ||||||
|
|
||||||
| match outcome { | ||||||
| Ok(result) => result, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -328,13 +328,13 @@ impl Connection { | |
| "Direct message {} delivered from {} to {}", | ||
| message_id, from_agent_id, to_agent_id | ||
| ); | ||
| drop(recipient.send(SessionMessage::Json(ServerMessage::AgentMessage { | ||
| let _sent = recipient.send(SessionMessage::Json(ServerMessage::AgentMessage { | ||
| message_id: message_id.clone(), | ||
| from_agent_id, | ||
| scope: MessageScope::Direct, | ||
| server_received_at: pending.server_received_at, | ||
| message: pending.message, | ||
| }))); | ||
| })); | ||
|
Comment on lines
+331
to
+337
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: set -euo pipefail
# Show the relevant file and line ranges.
sed -n '300,360p' services/ws/src/lib.rs
printf '\n====\n'
sed -n '500,540p' services/ws/src/lib.rs
printf '\n====\n'
# Find delivery/status related enums or message variants in the same file.
rg -n "Delivered|Broadcast|Direct|send\\(" services/ws/src/lib.rsRepository: edge-toolkit/core Length of output: 6305 🏁 Script executed: set -euo pipefail
printf 'Need tool output\n'Repository: edge-toolkit/core Length of output: 172 Don't mark direct or broadcast delivery as successful when 🤖 Prompt for AI Agents |
||
| self.send_status( | ||
| Some(message_id), | ||
| MessageDeliveryStatus::Delivered, | ||
|
|
@@ -367,7 +367,7 @@ impl Connection { | |
| recipients.len() | ||
| ); | ||
| for (_, recipient) in recipients { | ||
| drop(recipient.send(SessionMessage::Text(text.to_string()))); | ||
| let _sent = recipient.send(SessionMessage::Text(text.to_string())); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -381,7 +381,7 @@ impl Connection { | |
| recipients.len() | ||
| ); | ||
| for (_, recipient) in recipients { | ||
| drop(recipient.send(SessionMessage::Binary(bytes.clone()))); | ||
| let _sent = recipient.send(SessionMessage::Binary(bytes.clone())); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -509,13 +509,13 @@ impl Connection { | |
| recipients.len() | ||
| ); | ||
| for (_, recipient) in &recipients { | ||
| drop(recipient.send(SessionMessage::Json(ServerMessage::AgentMessage { | ||
| let _sent = recipient.send(SessionMessage::Json(ServerMessage::AgentMessage { | ||
| message_id: message_id.clone(), | ||
| from_agent_id: from_agent_id.clone(), | ||
| scope: MessageScope::Broadcast, | ||
| server_received_at: server_received_at.clone(), | ||
| message: message.clone(), | ||
| }))); | ||
| })); | ||
| } | ||
| self.send_status( | ||
| Some(message_id), | ||
|
|
@@ -545,11 +545,11 @@ impl Connection { | |
| ) | ||
| .await; | ||
| if let Some(sender) = sender_session { | ||
| drop(sender.send(SessionMessage::Json(ServerMessage::MessageStatus { | ||
| let _sent = sender.send(SessionMessage::Json(ServerMessage::MessageStatus { | ||
| message_id: Some(message_id), | ||
| status: MessageDeliveryStatus::Acknowledged, | ||
| detail: format!("agent {recipient_agent_id} acknowledged receipt"), | ||
| }))); | ||
| })); | ||
| } | ||
| } | ||
| Err(error) => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 MEDIUM RISK
Suggestion: Changed from silent ignore (drop) to error propagation (?). While this is a robustness improvement that prevents running with broken telemetry, it will cause initialization to fail if a global logger was already set elsewhere. Verify that callers are prepared to handle this change in return type.