Skip to content

feat: sd triage — PageRank + betweenness + critical path ranking#7

Open
RogerNavelsaker wants to merge 2 commits intojayminwest:mainfrom
RogerNavelsaker:rn/sd-graph-triage
Open

feat: sd triage — PageRank + betweenness + critical path ranking#7
RogerNavelsaker wants to merge 2 commits intojayminwest:mainfrom
RogerNavelsaker:rn/sd-graph-triage

Conversation

@RogerNavelsaker
Copy link
Copy Markdown

Summary

  • Adds src/graph.ts with pure graph algorithms: reversed PageRank, Brandes betweenness centrality, and critical path DFS
  • Adds src/commands/triage.tssd triage command that ranks ready issues by composite graph score
  • Registers triage in src/index.ts
  • Colocated tests in src/graph.test.ts (6 cases: empty, single node, linear chain, diamond bottleneck, score bounds, external edge filtering)

How it works

sd triage applies the same eligibility filter as sd ready (open issues with all blockers closed), then ranks them by:

score = 0.5 × PageRank + 0.3 × betweenness + 0.2 × criticalPathLength
  • PageRank runs on the reversed dep graph so nodes that unblock important work rank high (authority flows from dependents back to blockers)
  • Betweenness centrality (Brandes algorithm) identifies coordination bottlenecks — issues that sit on many shortest dependency paths
  • Critical path length — longest forward chain of blocks edges via DFS

Human output shows score (pts), critical path depth, and betweenness per issue. --json emits a structured envelope for agent consumption.

Test plan

  • bun test src/graph.test.ts — all 6 graph algorithm tests pass
  • sd triage in a repo with a dependency graph returns issues ranked by score
  • sd triage --limit 3 returns top 3
  • sd triage --json emits valid JSON with success, issues, count
  • sd ready behaviour is unchanged

Closes #6

🤖 Generated with Claude Code

Adds two new modules:

- src/graph.ts: pure graph algorithms over the issue dependency graph
  - PageRank (reversed graph): authority flows from dependents back to
    their blockers; nodes that unblock the most work rank highest
  - Betweenness centrality (Brandes): identifies coordination bottlenecks
    — nodes on many shortest paths between other nodes
  - Critical path length: longest forward chain of blocks edges; nodes
    with long forward chains should start earliest
  - Composite score: 0.5*pagerank + 0.3*betweenness + 0.2*criticalPath

- src/commands/triage.ts: sd triage command
  - Same eligibility as sd ready (open + all blockers closed)
  - Ranked by composite graph score descending, then priority ascending
  - --json emits structured output for agent consumption
  - --limit <n> returns top N issues only
  - Human output shows score, critical path length, betweenness per issue

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: sd graph / sd triage — PageRank + betweenness centrality on the dependency graph

1 participant