From 3ee59e01d201e550e8b4086e443bea34d9417600 Mon Sep 17 00:00:00 2001 From: MethodWhite Date: Fri, 10 Jul 2026 01:32:02 -0400 Subject: [PATCH] fix: zero cargo warnings, zero actionlint warnings - Fix actionlint: pass github expressions via env vars instead of inline - Fix 27 cargo warnings: unused imports, dead code, privacy, mut - cargo fix auto-fixed 9 warnings - Made types pub where needed (ColdFragment, AssistantDecision, etc.) - Added #[allow(dead_code)] on struct fields intentionally unused --- .github/workflows/pr-review.yml | 17 +++++++++++------ src/infrastructure/context/cold_storage.rs | 13 ++++++------- src/infrastructure/context/hot_recycler.rs | 3 ++- .../context/prompting_assistant.rs | 18 +++++++++++++----- src/infrastructure/context/registry.rs | 3 ++- src/infrastructure/context/relevance.rs | 8 ++++---- src/presentation/mcp/server.rs | 1 - 7 files changed, 38 insertions(+), 25 deletions(-) diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml index 9f6d751..0db8948 100644 --- a/.github/workflows/pr-review.yml +++ b/.github/workflows/pr-review.yml @@ -22,18 +22,22 @@ jobs: fetch-depth: 0 - name: Analyze PR changes id: changes + env: + BASE_REF: ${{ github.base_ref }} run: | - FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | wc -l) - ADDITIONS=$(git diff --numstat origin/${{ github.base_ref }}...HEAD | awk '{s+=$1} END {print s+0}') - DELETIONS=$(git diff --numstat origin/${{ github.base_ref }}...HEAD | awk '{s+=$2} END {print s+0}') + FILES=$(git diff --name-only "origin/${BASE_REF}...HEAD" | wc -l) + ADDITIONS=$(git diff --numstat "origin/${BASE_REF}...HEAD" | awk '{s+=$1} END {print s+0}') + DELETIONS=$(git diff --numstat "origin/${BASE_REF}...HEAD" | awk '{s+=$2} END {print s+0}') echo "files=$FILES" >> "$GITHUB_OUTPUT" echo "additions=$ADDITIONS" >> "$GITHUB_OUTPUT" echo "deletions=$DELETIONS" >> "$GITHUB_OUTPUT" - name: Check migration version if: contains(github.event.pull_request.labels.*.name, 'database') + env: + BASE_REF: ${{ github.base_ref }} run: | - if git diff origin/${{ github.base_ref }}...HEAD -- src/infrastructure/database/mod.rs | grep -q 'version <\|schema_version'; then + if git diff "origin/${BASE_REF}...HEAD" -- src/infrastructure/database/mod.rs | grep -q 'version <\|schema_version'; then echo "Migration version bump detected" else echo "Database PR without schema version bump!" @@ -49,9 +53,10 @@ jobs: - uses: actions/checkout@v4 - name: Validate PR title id: conventions + env: + PR_TITLE: ${{ github.event.pull_request.title }} run: | - TITLE="${{ github.event.pull_request.title }}" - if echo "$TITLE" | grep -qE '^(feat|fix|refactor|test|docs|ci|config|perf|style|chore|db|mcp)(\([a-z0-9_-]+\))?!?:\s.+'; then + if echo "${PR_TITLE}" | grep -qE '^(feat|fix|refactor|test|docs|ci|config|perf|style|chore|db|mcp)(\([a-z0-9_-]+\))?!?:\s.+'; then echo "title_valid=true" >> "$GITHUB_OUTPUT" else echo "title_valid=false" >> "$GITHUB_OUTPUT" diff --git a/src/infrastructure/context/cold_storage.rs b/src/infrastructure/context/cold_storage.rs index a2978be..ab935f7 100644 --- a/src/infrastructure/context/cold_storage.rs +++ b/src/infrastructure/context/cold_storage.rs @@ -10,15 +10,14 @@ //! 4. Reconstitución perezosa bajo demanda use super::context_types::now_ts as now_timestamp; -use super::context_types::{ - Context, ContextId, ContextState, ContextType, ContextValue, Priority, Timestamp, -}; +use super::context_types::{ContextId, ContextState, ContextType, Priority, Timestamp}; use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap}; use std::path::PathBuf; /// Almacenamiento frío de contextos /// Los datos se archivan, no se eliminan +#[allow(dead_code)] pub struct ColdStorage { /// Directorio base de almacenamiento frío base_path: PathBuf, @@ -53,7 +52,7 @@ struct ColdIndex { /// Metadata que se mantiene indexada incluso en frío #[derive(Debug, Clone, Serialize, Deserialize)] -struct ColdMetadata { +pub struct ColdMetadata { pub name: String, pub context_type: ContextType, pub tags: Vec, @@ -65,7 +64,7 @@ struct ColdMetadata { /// Un fragmento de contexto archivado #[derive(Debug, Clone, Serialize, Deserialize)] -struct ColdFragment { +pub struct ColdFragment { pub id: FragmentId, pub fragment_type: FragmentType, pub data: Vec, @@ -74,7 +73,7 @@ struct ColdFragment { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -enum FragmentType { +pub enum FragmentType { Variables, Connections, Metadata, @@ -83,7 +82,7 @@ enum FragmentType { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -struct FragmentId(pub u64); +pub struct FragmentId(pub u64); #[derive(Debug, Clone, Serialize, Deserialize)] struct ColdConfig { diff --git a/src/infrastructure/context/hot_recycler.rs b/src/infrastructure/context/hot_recycler.rs index 85b3809..65885f3 100644 --- a/src/infrastructure/context/hot_recycler.rs +++ b/src/infrastructure/context/hot_recycler.rs @@ -8,7 +8,7 @@ //! - Recicla partes no usadas frecuentemente use super::context_types::now_ts as now_timestamp; -use super::context_types::{Context, ContextId, ContextValue, Timestamp}; +use super::context_types::{Context, ContextId, Timestamp}; use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap, HashSet}; @@ -161,6 +161,7 @@ impl ChunkIndex { /// Configuración del recycler #[derive(Debug, Clone)] +#[allow(dead_code)] struct RecyclerConfig { /// Tamaño máximo de chunk (bytes) max_chunk_size: usize, diff --git a/src/infrastructure/context/prompting_assistant.rs b/src/infrastructure/context/prompting_assistant.rs index 2ccbc65..1e4e37d 100644 --- a/src/infrastructure/context/prompting_assistant.rs +++ b/src/infrastructure/context/prompting_assistant.rs @@ -15,8 +15,7 @@ use super::context_types::{ }; use super::hot_recycler::HotRecycler; -use serde::{Deserialize, Serialize}; -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; /// Motor de asistencia de prompting pub struct PromptingAssistant { @@ -38,6 +37,7 @@ pub struct PromptingAssistant { /// Configuración del asistente #[derive(Debug, Clone)] +#[allow(dead_code)] struct AssistantConfig { /// Cuántas sugerencias generar máximo max_suggestions: usize, @@ -62,6 +62,7 @@ impl Default for AssistantConfig { /// Evaluador de contexto #[derive(Debug, Clone)] +#[allow(dead_code)] struct ContextEvaluator { /// Aspectos a evaluar aspects: Vec, @@ -447,6 +448,7 @@ pub struct Suggestion { /// Monitor de tareas pendientes #[derive(Debug, Clone)] +#[allow(dead_code)] struct TaskMonitor { /// Tareas pendientes pending_tasks: Vec, @@ -455,6 +457,7 @@ struct TaskMonitor { } #[derive(Debug, Clone)] +#[allow(dead_code)] struct PendingTask { pub id: String, pub description: String, @@ -464,6 +467,7 @@ struct PendingTask { } #[derive(Debug, Clone)] +#[allow(dead_code)] struct CompletedTask { pub id: String, pub description: String, @@ -512,6 +516,7 @@ impl TaskMonitor { } /// Registra una nueva tarea sugerida + #[allow(dead_code)] fn add_pending_task(&mut self, description: String, context_id: Option) { self.pending_tasks.push(PendingTask { id: format!("task_{}", now_timestamp()), @@ -525,7 +530,8 @@ impl TaskMonitor { /// Decisión del asistente #[derive(Debug, Clone)] -struct AssistantDecision { +#[allow(dead_code)] +pub struct AssistantDecision { pub timestamp: Timestamp, pub decision_type: DecisionType, pub context_id: Option, @@ -534,14 +540,16 @@ struct AssistantDecision { } #[derive(Debug, Clone, Copy)] -enum DecisionType { +#[allow(dead_code)] +pub enum DecisionType { Suggestion, AutoAction, UserOverride, } #[derive(Debug, Clone, Copy)] -enum DecisionOutcome { +#[allow(dead_code)] +pub enum DecisionOutcome { Success, Partial, Failed, diff --git a/src/infrastructure/context/registry.rs b/src/infrastructure/context/registry.rs index f70da8f..2dfb7ab 100644 --- a/src/infrastructure/context/registry.rs +++ b/src/infrastructure/context/registry.rs @@ -54,6 +54,7 @@ struct ColdRef { } #[derive(Debug, Clone)] +#[allow(dead_code)] struct RegistryConfig { pub max_hot_contexts: usize, pub max_warm_contexts: usize, @@ -92,7 +93,7 @@ impl ContextRegistry { /// Crea un nuevo contexto pub fn create(&mut self, name: String, context_type: ContextType) -> ContextId { - let mut context = Context::new(name, context_type); + let context = Context::new(name, context_type); let id = context.id.clone(); self.hot_contexts.insert(id.clone(), context); diff --git a/src/infrastructure/context/relevance.rs b/src/infrastructure/context/relevance.rs index 29184b4..0847094 100644 --- a/src/infrastructure/context/relevance.rs +++ b/src/infrastructure/context/relevance.rs @@ -36,7 +36,7 @@ struct RelevanceModel { } #[derive(Debug, Clone, Serialize, Deserialize)] -struct RelevanceWeights { +pub struct RelevanceWeights { pub recency: f64, pub frequency: f64, pub affinity: f64, @@ -224,7 +224,7 @@ impl RelevanceEngine { let predicted = self.predict_next(current); // Basado en patrones aprendidos - let mut suggestions = predicted; + let suggestions = predicted; suggestions } @@ -233,7 +233,7 @@ impl RelevanceEngine { pub fn update_weights(&mut self, feedback: RelevanceFeedback) { match feedback { RelevanceFeedback::Accessed { - context_id, + context_id: _, helpful, } => { if helpful { @@ -246,7 +246,7 @@ impl RelevanceEngine { self.normalize_weights(); } RelevanceFeedback::NotAccessed { - context_id, + context_id: _, expected, } => { if expected { diff --git a/src/presentation/mcp/server.rs b/src/presentation/mcp/server.rs index b6410e2..8afb9fb 100644 --- a/src/presentation/mcp/server.rs +++ b/src/presentation/mcp/server.rs @@ -9,7 +9,6 @@ use crate::core::agent_registry_ext::AgentRegistryExt; use crate::core::antibrick::{AntiBrickConfig, AntiBrickEngine}; use crate::core::auth::challenge::ChallengeResponse; use crate::core::auth::classifier::AgentClassifier; -use crate::core::auth::permissions::{Permission, PermissionSet}; use crate::core::auth::tpm::TpmMfaProvider; use crate::core::auto_integrate::AutoIntegrate; use crate::core::chunk_query::ChunkQueryManager;