Skip to Content
Nextra 2 Alpha
ArchitectureTask Scoring for Agentic Development

Task Scoring for Agentic Development

The Task Scoring System provides comprehensive task scoring and constraint management for agentic development workflows, enabling agents to coordinate effectively and avoid conflicts through intelligent prioritization and resource management.

Overview

The Task Scoring System transforms implicit coordination into explicit, persistent, and discoverable task management by providing:

  • Intelligent Task Prioritization: Sophisticated scoring algorithms for optimal task ordering
  • Constraint Management: Resource exclusion and conflict prevention mechanisms
  • Agent Coordination: Real-time coordination between multiple AI agents
  • Resource Optimization: Efficient resource allocation and conflict resolution
  • Performance Tracking: Comprehensive metrics and analytics for task execution

Architecture

Core Components

The Task Scoring System consists of several key components:

pub struct TaskScoringSystem { tasks: HashMap<String, Task>, scores_cache: HashMap<String, TaskScore>, weights: ScoringWeights, prioritization_history: Vec<TaskPrioritization>, dependencies_graph: HashMap<String, Vec<String>>, }

Task Definition

Tasks are defined with comprehensive metadata for intelligent scoring:

pub struct Task { pub id: String, pub title: String, pub description: String, pub task_type: TaskType, pub priority: TaskPriority, pub status: TaskStatus, pub complexity: TaskComplexity, pub scoring_factors: TaskScoringFactors, pub scope: String, pub assigned_to: Option<String>, pub dependencies: Vec<String>, pub blocking: Vec<String>, pub related_tasks: Vec<String>, pub created_at: DateTime<Utc>, pub modified_at: DateTime<Utc>, pub due_date: Option<DateTime<Utc>>, pub estimated_completion: Option<DateTime<Utc>>, pub completed_at: Option<DateTime<Utc>>, pub metadata: HashMap<String, serde_json::Value>, }

Scoring Factors

Tasks are scored based on multiple weighted factors:

pub struct TaskScoringFactors { pub business_value: f64, // Business value (0.0-1.0) pub technical_debt_impact: f64, // Technical debt impact (0.0-1.0) pub user_impact: f64, // User impact (0.0-1.0) pub dependencies_count: usize, // Dependencies count (negative impact) pub estimated_effort_hours: f64, // Estimated effort in hours pub risk_level: f64, // Risk level (0.0-1.0) pub urgency: f64, // Urgency (0.0-1.0) pub team_capacity_impact: f64, // Team capacity impact (0.0-1.0) pub learning_value: f64, // Learning value (0.0-1.0) pub strategic_alignment: f64, // Strategic alignment (0.0-1.0) }

Implementation Details

Task Scoring Algorithm

The system uses a sophisticated weighted scoring algorithm:

impl TaskScoringSystem { pub fn calculate_task_score(&mut self, task_id: &str) -> RhemaResult<TaskScore> { let task = self.get_task(task_id) .ok_or(TaskScoringError::TaskNotFound(task_id.to_string()))?; let factors = &task.scoring_factors; // Calculate individual scores let priority_score = self.calculate_priority_score(&task.priority); let business_value_score = factors.business_value; let technical_debt_score = 1.0 - factors.technical_debt_impact; let user_impact_score = factors.user_impact; let dependency_score = self.calculate_dependency_score(&task); let effort_efficiency_score = self.calculate_effort_efficiency_score(factors); let risk_adjusted_score = self.calculate_risk_adjusted_score(factors); let urgency_score = factors.urgency; let team_capacity_score = 1.0 - factors.team_capacity_impact; let learning_value_score = factors.learning_value; let strategic_alignment_score = factors.strategic_alignment; // Calculate weighted overall score let overall_score = ( priority_score * self.weights.priority_weight + business_value_score * self.weights.business_value_weight + technical_debt_score * self.weights.technical_debt_weight + user_impact_score * self.weights.user_impact_weight + dependency_score * self.weights.dependency_weight + effort_efficiency_score * self.weights.effort_efficiency_weight + risk_adjusted_score * self.weights.risk_weight + urgency_score * self.weights.urgency_weight + team_capacity_score * self.weights.team_capacity_weight + learning_value_score * self.weights.learning_value_weight + strategic_alignment_score * self.weights.strategic_alignment_weight ) / self.get_total_weight(); Ok(TaskScore { task_id: task_id.to_string(), overall_score, priority_score, business_value_score, technical_debt_score, user_impact_score, dependency_score, effort_efficiency_score, risk_adjusted_score, urgency_score, team_capacity_score, learning_value_score, strategic_alignment_score, calculated_at: Utc::now(), explanation: self.generate_score_explanation(&task, &overall_score), }) } }

Prioritization Strategies

Multiple prioritization strategies are available:

pub enum PrioritizationStrategy { WeightedScoring, // Weighted scoring approach BusinessValueFirst, // Business value first TechnicalDebtFirst, // Technical debt reduction UserImpactFirst, // User impact focused RiskAdjustedReturn, // Risk-adjusted return EffortEfficiency, // Effort efficiency StrategicAlignment, // Strategic alignment Custom(String), // Custom strategy }

Constraint Management

The system includes sophisticated constraint management:

# .rhema/constraints.yaml constraints: - id: "cargo-singleton" name: "Single Cargo Command Constraint" description: "Only one cargo command can run per project at a time" constraint_type: "resource_exclusion" scope: "project" resources: - type: "process" pattern: "cargo.*" max_concurrent: 1 enforcement: level: "required" action: "block" notification: "warn" validation: check_interval: "5s" timeout: "30s" scoring: violation_penalty: -10 compliance_bonus: 5 priority_boost: 2

Usage

Basic Task Management

use rhema::ai::agent::task_scoring::{TaskScoringSystem, Task, TaskType, TaskPriority}; // Create task scoring system let mut scoring_system = TaskScoringSystem::new(); // Create a task let task = Task { id: "task-001".to_string(), title: "Implement new feature".to_string(), description: "Add user authentication system".to_string(), task_type: TaskType::Feature, priority: TaskPriority::High, // ... other fields }; // Add task to system scoring_system.add_task(task)?; // Calculate task score let score = scoring_system.calculate_task_score("task-001")?; println!("Task score: {:.2}", score.overall_score); // Prioritize tasks let prioritization = scoring_system.prioritize_tasks( "core", PrioritizationStrategy::WeightedScoring )?;

CLI Integration

# Add a new task rhema task add --title "Implement feature" --type feature --priority high # Calculate task scores rhema task score --task-id task-001 # Prioritize tasks rhema task prioritize --scope core --strategy weighted-scoring # List tasks by priority rhema task list --sort-by score --limit 10 # Check constraints rhema task constraints --validate # Generate task report rhema task report --scope core --format json

Configuration

[task_scoring] # Scoring weights business_value_weight = 0.25 technical_debt_weight = 0.15 user_impact_weight = 0.20 dependency_weight = 0.10 effort_efficiency_weight = 0.10 risk_weight = 0.10 urgency_weight = 0.05 team_capacity_weight = 0.05 # Constraint settings constraint_check_interval = "5s" constraint_timeout = "30s" violation_penalty = -10 compliance_bonus = 5 # Performance settings cache_enabled = true cache_ttl = 3600 parallel_scoring = true

Performance Considerations

Optimization Features

  • Intelligent Caching: Task scores are cached for performance
  • Parallel Processing: Multiple tasks can be scored simultaneously
  • Incremental Updates: Only recalculate scores when dependencies change
  • Lazy Evaluation: Scores are calculated on-demand

Performance Metrics

  • Scoring Time: < 10ms per task for typical workloads
  • Prioritization Time: < 100ms for 1000 tasks
  • Memory Usage: Optimized for large task sets
  • Cache Hit Rate: > 90% for repeated operations

Integration

With AI Agents

The Task Scoring System integrates seamlessly with AI agents:

// AI agent using task scoring impl AIAgent { pub async fn select_next_task(&self) -> RhemaResult<Option<Task>> { let scoring_system = self.get_task_scoring_system(); // Get available tasks let available_tasks = scoring_system.get_scope_tasks(&self.scope); if available_tasks.is_empty() { return Ok(None); } // Prioritize tasks let prioritization = scoring_system.prioritize_tasks( &self.scope, PrioritizationStrategy::WeightedScoring )?; // Select highest priority task let top_task = prioritization.prioritized_tasks.first(); Ok(top_task.map(|score| { scoring_system.get_task(&score.task_id).unwrap().clone() })) } }

With Constraint System

// Constraint-aware task execution impl TaskExecutor { pub async fn execute_task(&self, task: &Task) -> RhemaResult<()> { // Check constraints before execution let constraint_checker = self.get_constraint_checker(); constraint_checker.validate_task(task).await?; // Execute task let result = self.run_task(task).await?; // Update task status self.update_task_status(task.id, TaskStatus::Completed).await?; Ok(result) } }

Monitoring and Analytics

Metrics Collection

The system provides comprehensive metrics:

  • Task Completion Rate: Percentage of tasks completed on time
  • Constraint Violations: Number and frequency of constraint violations
  • Scoring Accuracy: Correlation between predicted and actual task outcomes
  • Agent Coordination: Effectiveness of multi-agent coordination
  • Resource Utilization: Efficiency of resource allocation

Reporting

# Generate task scoring report rhema task report --scope core --period last-week # Export task analytics rhema task analytics --export csv --output task-analytics.csv # Monitor constraint violations rhema task constraints --monitor --alert
Last updated on