tx

PRD-004: Task Scoring & Prioritization

Numeric scoring system with LLM-based reprioritization for intelligent task ordering

Status: Draft Priority: P1 (Should Have) Owner: TBD Last Updated: 2025-01-28


Problem Statement

When agents query "what should I work on?", they need a single, comparable metric to rank tasks. Current approaches fail because:

  1. No scoring - agents pick arbitrarily or by creation order
  2. Human-only scoring - doesn't adapt to changing conditions
  3. Static priorities (P0/P1/P2) - too coarse, can't distinguish between 50 P1 tasks

We need numeric scores that:

  • Can be set by humans for strategic priorities
  • Can be updated by LLMs based on context
  • Automatically factor in dependencies and blocking relationships

Scoring Model

Base Score (0-1000)

Set by humans or agents to indicate inherent importance:

RangeMeaningExample
900-1000Critical / Blocking releaseSecurity fix
700-899High priority / Important featureCore feature
400-699Medium priority / Normal workStandard task
100-399Low priority / Nice to havePolish
0-99Backlog / SomedayFuture idea

Dynamic Adjustments

Applied at query time, not stored:

FactorAdjustmentRationale
Blocking count+25 per taskUnblocking work is valuable
Age > 48 hours+100Old tasks shouldn't rot
Age > 24 hours+50Mild age bonus
Depth > 2-10 per levelPrefer root tasks over deep subtasks
Status = blocked-1000Never show blocked tasks as ready

Final Score Formula

final_score = base_score
            + (blocking_count * 25)
            + age_bonus
            - (depth * 10)
            + custom_adjustments

LLM Score Updates

Single Task Update

tx score-update tx-001 --reason "This is now blocking the release"

Batch Recalculation

tx reprioritize --context "We're focusing on performance this sprint"

What LLM Considers

  • Task title and description
  • Current score and dependencies
  • Provided context
  • What tasks this blocks

Requirements

Scoring Operations

IDRequirementCLI Command
S-001Manually set base scoretx score <id> <value>
S-002Show current score breakdowntx score <id>
S-003LLM recalculates all scorestx reprioritize
S-004List sorted by score (default)tx list --sort=score

Scoring API

MethodDescription
TaskService.setScore(id, score)Set base score
ScoreService.calculate(task)Get final score with adjustments
ScoreService.recalculateAll(context?)Batch LLM update

Constraints

IDConstraintRationale
S-005Scores are integersNo floating point comparison issues
S-006Base score stored in DBAdjustments computed at runtime
S-007ANTHROPIC_API_KEY is optionalManual tx score <id> <value> and dynamic adjustments work without LLM. Only tx reprioritize requires the API key. If ANTHROPIC_API_KEY is set as env var, use it automatically. If not, LLM scoring commands fail gracefully with a clear error message.

API Examples

Set Score

# Set base score
$ tx score tx-a1b2c3 800
Score updated: tx-a1b2c3 = 800

# View score breakdown
$ tx score tx-a1b2c3
Task: tx-a1b2c3
  Base score: 800
  Blocking bonus: +50 (2 tasks)
  Age bonus: +100 (>48h)
  Depth penalty: -20 (depth 2)
  Final score: 930

Reprioritize

$ tx reprioritize --context "Focus on auth this week"
Analyzing 15 tasks...
Updated scores:
  tx-auth1: 400 850 (auth-related)
  tx-auth2: 300 800 (auth-related)
  tx-perf1: 700 500 (not priority)

List by Score

$ tx list --sort=score
15 tasks (sorted by score):
  tx-a1b2c3 [930] Implement JWT validation
  tx-d4e5f6 [870] Add login endpoint
  tx-g7h8i9 [650] Write auth tests
  ...

Score Calculation Implementation

function calculateFinalScore(task: Task, context: ScoreContext): number {
  let score = task.score  // Base score from DB

  // Blocking bonus: tasks that unblock others are more valuable
  score += context.blockingCount * 25

  // Age bonus: don't let old tasks rot
  const ageHours = (Date.now() - task.createdAt.getTime()) / (1000 * 60 * 60)
  if (ageHours > 48) {
    score += 100
  } else if (ageHours > 24) {
    score += 50
  }

  // Depth penalty: prefer root tasks over deep subtasks
  score -= context.depth * 10

  return score
}

On this page