diff --git a/guards/github-guard/rust-guard/src/labels/backend.rs b/guards/github-guard/rust-guard/src/labels/backend.rs index 5c0b736d..0a9015e9 100644 --- a/guards/github-guard/rust-guard/src/labels/backend.rs +++ b/guards/github-guard/rust-guard/src/labels/backend.rs @@ -335,7 +335,7 @@ pub fn is_forked_pull_request_with_callback( let response_str = std::str::from_utf8(&result_buffer[..len]).ok()?; let response = serde_json::from_str::(response_str).ok()?; - let pr = extract_mcp_payload_json(&response); + let pr = super::extract_mcp_response(&response); let base_full_name = pr .get("base") @@ -384,7 +384,7 @@ pub fn get_pull_request_facts_with_callback( let response_str = std::str::from_utf8(&result_buffer[..len]).ok()?; let response = serde_json::from_str::(response_str).ok()?; - let pr = extract_mcp_payload_json(&response); + let pr = super::extract_mcp_response(&response); let base_full_name = pr .get("base") @@ -451,7 +451,7 @@ pub fn get_issue_author_association_with_callback( let response_str = std::str::from_utf8(&result_buffer[..len]).ok()?; let response = serde_json::from_str::(response_str).ok()?; - let issue = extract_mcp_payload_json(&response); + let issue = super::extract_mcp_response(&response); issue .get("author_association") @@ -496,22 +496,6 @@ fn extract_repo_private_flag(response: &Value, repo_id: &str) -> Option { repo_visibility_from_items(&parsed, repo_id) } -fn extract_mcp_payload_json(response: &Value) -> Value { - if let Some(content) = response.get("content").and_then(|v| v.as_array()) { - if let Some(text) = content - .first() - .and_then(|item| item.get("text")) - .and_then(|v| v.as_str()) - { - if let Ok(parsed) = serde_json::from_str::(text) { - return parsed; - } - } - } - - response.clone() -} - fn extract_backend_error_text(response: &Value) -> Option<&str> { if response.get("isError").and_then(|v| v.as_bool()) != Some(true) { return None; diff --git a/guards/github-guard/rust-guard/src/labels/mod.rs b/guards/github-guard/rust-guard/src/labels/mod.rs index 45cf8221..6bcc7fa7 100644 --- a/guards/github-guard/rust-guard/src/labels/mod.rs +++ b/guards/github-guard/rust-guard/src/labels/mod.rs @@ -92,9 +92,9 @@ pub(crate) fn extract_mcp_response(response: &Value) -> Value { // Log the top-level keys to understand the structure if let Some(obj) = response.as_object() { let keys: Vec<&str> = obj.keys().map(|s| s.as_str()).collect(); - crate::log_info(&format!("extract_mcp_response: top-level keys={:?}", keys)); + crate::log_debug(&format!("extract_mcp_response: top-level keys={:?}", keys)); } else { - crate::log_info(&format!( + crate::log_debug(&format!( "extract_mcp_response: response is not an object, type={}", if response.is_array() { "array" @@ -110,34 +110,34 @@ pub(crate) fn extract_mcp_response(response: &Value) -> Value { // Try to extract content[0].text and parse it as JSON if let Some(content) = response.get("content").and_then(|v| v.as_array()) { - crate::log_info(&format!( + crate::log_debug(&format!( "extract_mcp_response: found content array with {} items", content.len() )); if let Some(first) = content.first() { if let Some(text) = first.get("text").and_then(|v| v.as_str()) { - crate::log_info(&format!( + crate::log_debug(&format!( "extract_mcp_response: found text field, len={}", text.len() )); // Try to parse the text as JSON if let Ok(parsed) = serde_json::from_str::(text) { - crate::log_info("extract_mcp_response: parsed content[0].text as JSON"); + crate::log_debug("extract_mcp_response: parsed content[0].text as JSON"); return parsed; } else { - crate::log_info("extract_mcp_response: failed to parse text as JSON"); + crate::log_debug("extract_mcp_response: failed to parse text as JSON"); } } else { - crate::log_info("extract_mcp_response: no text field in content[0]"); + crate::log_debug("extract_mcp_response: no text field in content[0]"); } } } else { - crate::log_info("extract_mcp_response: no content array found"); + crate::log_debug("extract_mcp_response: no content array found"); } // If we can't extract from MCP wrapper, return the original response // (it might already be unwrapped or in a different format) - crate::log_info("extract_mcp_response: using response as-is"); + crate::log_debug("extract_mcp_response: using response as-is"); response.clone() } diff --git a/guards/github-guard/rust-guard/src/permissions.rs b/guards/github-guard/rust-guard/src/permissions.rs index 532f9476..501da526 100644 --- a/guards/github-guard/rust-guard/src/permissions.rs +++ b/guards/github-guard/rust-guard/src/permissions.rs @@ -4,9 +4,7 @@ //! using the backend MCP server. This enables dynamic integrity //! labeling based on actual GitHub permissions. -#![allow(dead_code)] - -use crate::labels::{constants::label_constants, is_bot, MEDIUM_BUFFER_SIZE}; +use crate::labels::{constants::label_constants, MEDIUM_BUFFER_SIZE}; use serde_json::Value; /// Repository permission level from GitHub @@ -301,15 +299,6 @@ pub fn get_author_integrity_tags(author: &str, owner: &str, repo: &str) -> Vec bool { - is_bot(username) -} - /// Get integrity tags for a bot account /// /// Bots typically have approved-level integrity for their automated actions. @@ -344,6 +333,7 @@ pub fn get_bot_integrity_tags(bot_name: &str, owner: &str, repo: &str) -> Vec