Core Components
TaskGraph
TaskGraph builds a dependency DAG from tasks and computes critical path, fan-out (dependent count), and depth for prioritization. Used by the graph-prioritized claim strategy.
Graph Metrics
| Metric | Description |
|---|---|
| Critical Path | Longest chain to completion — tasks here block project finish (+100 score) |
| Fan-out (Dependent Count) | Number of transitive dependents (+10 per dependent) |
| Depth | Distance from root — shallower tasks prioritized first (+(1-normalizedDepth)*20) |
How graph-prioritized Works
The priority score is computed using the following formula:
score = 0 if (isOnCriticalPath) score += 100 score += dependentCount * 10 // fan-out: more dependents = higher priority score += (1 - normalizedDepth) * 20 // shallower tasks first
Tasks on the critical path get the highest boost. Fan-out rewards tasks that unblock the most downstream work. Depth favors shallower tasks so the graph can be parallelized early.
API Usage
import { TaskGraph } from '@jetpack-agent/coordinator';
const tasks = await dataLayer.tasks.list();
const graph = new TaskGraph(tasks);
// Priority scoring
graph.getPriorityScore(taskId); // Combined score for a task
graph.isOnCriticalPath(taskId); // Is this task on the critical path?
graph.getDependentCount(taskId); // How many tasks depend on this?
graph.getDepth(taskId); // Distance from root
// Graph analysis
graph.getCriticalPath(); // Array of task IDs on the longest chain
graph.getMetrics(); // All metrics for all tasks
graph.detectCycles(); // Check for circular dependencies
graph.getRoots(); // Tasks with no dependencies
graph.getLeaves(); // Tasks with no dependents