@h-rig/dependency-graph-plugin 0.0.6-alpha.157 → 0.0.6-alpha.158
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/analysis/blockers.d.ts +35 -0
- package/dist/src/analysis/blockers.js +355 -0
- package/dist/src/{graph-model → analysis}/dependencyGraph.d.ts +1 -2
- package/dist/src/{graph.js → analysis/dependencyGraph.js} +256 -128
- package/dist/src/{graph.d.ts → analysis/graph.d.ts} +3 -4
- package/dist/src/analysis/graph.js +944 -0
- package/dist/src/analysis/rigSelectors.d.ts +26 -0
- package/dist/src/analysis/rigSelectors.js +172 -0
- package/dist/src/analysis/rollupModel.js +401 -0
- package/dist/src/{rollups.d.ts → analysis/rollups.d.ts} +2 -4
- package/dist/src/analysis/rollups.js +589 -0
- package/dist/src/{graph-model → analysis}/taskGraphCodes.js +1 -1
- package/dist/src/{graph-model → analysis}/taskGraphLayout.d.ts +2 -2
- package/dist/src/{graph-model → analysis}/taskGraphLayout.js +75 -29
- package/dist/src/analysis/taskGraphPrimitives.d.ts +58 -0
- package/dist/src/analysis/taskGraphPrimitives.js +528 -0
- package/dist/src/index.js +567 -396
- package/dist/src/plugin.d.ts +1 -11
- package/dist/src/plugin.js +567 -396
- package/package.json +3 -6
- package/dist/src/graph-model/dependencyGraph.js +0 -485
- package/dist/src/graph-model/rollups.js +0 -166
- package/dist/src/rollups.js +0 -199
- package/dist/src/taskRanking.d.ts +0 -24
- package/dist/src/taskRanking.js +0 -160
- package/dist/src/taskScore.d.ts +0 -17
- package/dist/src/taskScore.js +0 -49
- package/dist/src/taskSelection.d.ts +0 -33
- package/dist/src/taskSelection.js +0 -181
- /package/dist/src/{graph-model/rollups.d.ts → analysis/rollupModel.d.ts} +0 -0
- /package/dist/src/{graph-model → analysis}/taskGraphCodes.d.ts +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ClientTaskProjection, TaskDependencyBadgeSummary, TaskLike } from "@rig/contracts";
|
|
2
|
+
import type { BlockerClass, BlockerClassification, ActionRiskTier, RunRecord } from "@rig/contracts";
|
|
3
|
+
export type BlockerClassifier = (input: BlockerClassifierInput) => BlockerClassification;
|
|
4
|
+
export interface BlockerClassifierInput {
|
|
5
|
+
readonly task: ClientTaskProjection;
|
|
6
|
+
readonly badges: ReadonlyMap<string, TaskDependencyBadgeSummary>;
|
|
7
|
+
readonly tasksById: ReadonlyMap<string, ClientTaskProjection>;
|
|
8
|
+
readonly run?: Pick<RunRecord, "status"> | null;
|
|
9
|
+
readonly labels?: readonly string[];
|
|
10
|
+
readonly config?: {
|
|
11
|
+
readonly llm?: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface WorkspaceBlockers {
|
|
15
|
+
readonly classifications: readonly BlockerClassification[];
|
|
16
|
+
readonly byTaskId: ReadonlyMap<string, BlockerClassification>;
|
|
17
|
+
readonly human: readonly BlockerClassification[];
|
|
18
|
+
readonly machine: readonly BlockerClassification[];
|
|
19
|
+
readonly generatedAt: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function tierOf(task: ClientTaskProjection | TaskLike, labels?: readonly string[]): ActionRiskTier;
|
|
22
|
+
export declare function isHumanBlockerClass(blockerClass: BlockerClass): boolean;
|
|
23
|
+
export declare function classifyBlocker(input: BlockerClassifierInput): BlockerClassification;
|
|
24
|
+
export declare function classifyTasks(tasks: readonly TaskLike[], runs?: readonly Pick<RunRecord, "taskId" | "status" | "updatedAt" | "startedAt">[], options?: {
|
|
25
|
+
readonly classifier?: BlockerClassifier;
|
|
26
|
+
readonly generatedAt?: string;
|
|
27
|
+
readonly humanOnly?: boolean;
|
|
28
|
+
}): WorkspaceBlockers;
|
|
29
|
+
export declare function classifyWorkspaceBlockers(projectRoot: string, deps: {
|
|
30
|
+
readonly listTasks: (projectRoot: string) => Promise<readonly TaskLike[]>;
|
|
31
|
+
readonly listRuns?: (projectRoot: string) => Promise<readonly RunRecord[]>;
|
|
32
|
+
readonly classifier?: BlockerClassifier;
|
|
33
|
+
readonly humanOnly?: boolean;
|
|
34
|
+
readonly generatedAt?: string;
|
|
35
|
+
}): Promise<WorkspaceBlockers>;
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/dependency-graph-plugin/src/analysis/taskGraphPrimitives.ts
|
|
3
|
+
import {
|
|
4
|
+
OPERATOR_INACTIVE_RUN_STATUSES
|
|
5
|
+
} from "@rig/contracts";
|
|
6
|
+
function isObjectRecord(value) {
|
|
7
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function readStringList(value) {
|
|
10
|
+
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string" && entry.length > 0) : [];
|
|
11
|
+
}
|
|
12
|
+
function unique(values) {
|
|
13
|
+
return Array.from(new Set(values));
|
|
14
|
+
}
|
|
15
|
+
function readTaskMetadataStringList(task, key) {
|
|
16
|
+
const taskRecord = task;
|
|
17
|
+
const topLevel = readStringList(taskRecord[key]);
|
|
18
|
+
if (topLevel.length > 0)
|
|
19
|
+
return topLevel;
|
|
20
|
+
const metadata = isObjectRecord(task.metadata) ? task.metadata : null;
|
|
21
|
+
const metadataList = readStringList(metadata?.[key]);
|
|
22
|
+
if (metadataList.length > 0)
|
|
23
|
+
return metadataList;
|
|
24
|
+
if (key === "dependencies") {
|
|
25
|
+
return readStringList(metadata?.deps);
|
|
26
|
+
}
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
function readTaskBlockingDependencyRefs(task) {
|
|
30
|
+
return readTaskMetadataStringList(task, "dependencies");
|
|
31
|
+
}
|
|
32
|
+
function readTaskSourceIssueId(task) {
|
|
33
|
+
if (typeof task.sourceIssueId === "string" && task.sourceIssueId.length > 0) {
|
|
34
|
+
return task.sourceIssueId;
|
|
35
|
+
}
|
|
36
|
+
const metadata = isObjectRecord(task.metadata) ? task.metadata : null;
|
|
37
|
+
if (typeof metadata?.sourceIssueId === "string" && metadata.sourceIssueId.length > 0) {
|
|
38
|
+
return metadata.sourceIssueId;
|
|
39
|
+
}
|
|
40
|
+
const rigMetadata = isObjectRecord(metadata?._rig) ? metadata._rig : null;
|
|
41
|
+
return typeof rigMetadata?.sourceIssueId === "string" && rigMetadata.sourceIssueId.length > 0 ? rigMetadata.sourceIssueId : null;
|
|
42
|
+
}
|
|
43
|
+
function resolveTaskReference(ref, tasksById, taskIdByExternalRef, taskIdBySourceIssueId) {
|
|
44
|
+
if (tasksById.has(ref))
|
|
45
|
+
return ref;
|
|
46
|
+
return taskIdBySourceIssueId.get(ref) ?? taskIdByExternalRef.get(ref) ?? null;
|
|
47
|
+
}
|
|
48
|
+
function buildTaskReferenceIndex(tasks) {
|
|
49
|
+
return {
|
|
50
|
+
tasksById: new Map(tasks.map((task) => [task.id, task])),
|
|
51
|
+
taskIdByExternalRef: new Map(tasks.flatMap((task) => task.externalId ? [[task.externalId, task.id]] : [])),
|
|
52
|
+
taskIdBySourceIssueId: new Map(tasks.flatMap((task) => {
|
|
53
|
+
const sourceIssueId = readTaskSourceIssueId(task);
|
|
54
|
+
return sourceIssueId ? [[sourceIssueId, task.id]] : [];
|
|
55
|
+
}))
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function computeTaskBlockingDepths(tasks) {
|
|
59
|
+
const { tasksById, taskIdByExternalRef, taskIdBySourceIssueId } = buildTaskReferenceIndex(tasks);
|
|
60
|
+
const memo = new Map;
|
|
61
|
+
const visit = (taskId, stack) => {
|
|
62
|
+
const cached = memo.get(taskId);
|
|
63
|
+
if (cached !== undefined)
|
|
64
|
+
return cached;
|
|
65
|
+
if (stack.has(taskId))
|
|
66
|
+
return 0;
|
|
67
|
+
const task = tasksById.get(taskId);
|
|
68
|
+
if (!task)
|
|
69
|
+
return 0;
|
|
70
|
+
stack.add(taskId);
|
|
71
|
+
const blockers = readTaskBlockingDependencyRefs(task).map((ref) => resolveTaskReference(ref, tasksById, taskIdByExternalRef, taskIdBySourceIssueId)).filter((ref) => ref !== null && ref !== taskId);
|
|
72
|
+
const depth = blockers.length === 0 ? 0 : Math.max(...blockers.map((blockerId) => visit(blockerId, stack) + 1));
|
|
73
|
+
stack.delete(taskId);
|
|
74
|
+
memo.set(taskId, depth);
|
|
75
|
+
return depth;
|
|
76
|
+
};
|
|
77
|
+
for (const task of tasks) {
|
|
78
|
+
visit(task.id, new Set);
|
|
79
|
+
}
|
|
80
|
+
return memo;
|
|
81
|
+
}
|
|
82
|
+
function isTaskTerminalStatus(status) {
|
|
83
|
+
switch (status) {
|
|
84
|
+
case "closed":
|
|
85
|
+
case "completed":
|
|
86
|
+
case "done":
|
|
87
|
+
case "cancelled":
|
|
88
|
+
case "canceled":
|
|
89
|
+
return true;
|
|
90
|
+
default:
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function isTaskBlockedStatus(status) {
|
|
95
|
+
return status === "blocked";
|
|
96
|
+
}
|
|
97
|
+
function isTaskRunnableStatus(status) {
|
|
98
|
+
if (status === null || status === undefined || status === "")
|
|
99
|
+
return true;
|
|
100
|
+
if (isTaskTerminalStatus(status) || isTaskBlockedStatus(status))
|
|
101
|
+
return false;
|
|
102
|
+
switch (status) {
|
|
103
|
+
case "ready":
|
|
104
|
+
case "open":
|
|
105
|
+
case "failed":
|
|
106
|
+
return true;
|
|
107
|
+
default:
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function computeTaskDependencyBadges(tasks) {
|
|
112
|
+
const index = buildTaskReferenceIndex(tasks);
|
|
113
|
+
const blockingDepths = computeTaskBlockingDepths(tasks);
|
|
114
|
+
const dependencyIdsByTask = new Map;
|
|
115
|
+
const unresolvedRefsByTask = new Map;
|
|
116
|
+
const blocksByTask = new Map;
|
|
117
|
+
for (const task of tasks) {
|
|
118
|
+
const dependencyIds = [];
|
|
119
|
+
const unresolvedRefs = [];
|
|
120
|
+
for (const ref of readTaskBlockingDependencyRefs(task)) {
|
|
121
|
+
const dependencyId = resolveTaskReference(ref, index.tasksById, index.taskIdByExternalRef, index.taskIdBySourceIssueId);
|
|
122
|
+
if (dependencyId && dependencyId !== task.id) {
|
|
123
|
+
dependencyIds.push(dependencyId);
|
|
124
|
+
const blocks = blocksByTask.get(dependencyId);
|
|
125
|
+
if (blocks) {
|
|
126
|
+
blocks.push(task.id);
|
|
127
|
+
} else {
|
|
128
|
+
blocksByTask.set(dependencyId, [task.id]);
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
unresolvedRefs.push(ref);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
dependencyIdsByTask.set(task.id, unique(dependencyIds));
|
|
135
|
+
unresolvedRefsByTask.set(task.id, unique(unresolvedRefs));
|
|
136
|
+
}
|
|
137
|
+
const summaries = new Map;
|
|
138
|
+
for (const task of tasks) {
|
|
139
|
+
const dependencyIds = dependencyIdsByTask.get(task.id) ?? [];
|
|
140
|
+
const unresolvedDependencyRefs = unresolvedRefsByTask.get(task.id) ?? [];
|
|
141
|
+
const blockedBy = dependencyIds.filter((dependencyId) => {
|
|
142
|
+
const dependency = index.tasksById.get(dependencyId);
|
|
143
|
+
return dependency ? !isTaskTerminalStatus(dependency.status) : false;
|
|
144
|
+
});
|
|
145
|
+
const blocks = unique(blocksByTask.get(task.id) ?? []);
|
|
146
|
+
const blocked = isTaskBlockedStatus(task.status) || blockedBy.length > 0;
|
|
147
|
+
const ready = isTaskRunnableStatus(task.status) && !blocked;
|
|
148
|
+
const badges = [];
|
|
149
|
+
if (blocked) {
|
|
150
|
+
badges.push({
|
|
151
|
+
kind: "blocked",
|
|
152
|
+
label: blockedBy.length > 0 ? `blocked \xD7${blockedBy.length}` : "blocked",
|
|
153
|
+
description: blockedBy.length > 0 ? `Waiting on ${blockedBy.join(", ")}.` : "Task source marks this task blocked.",
|
|
154
|
+
...blockedBy.length > 0 ? { count: blockedBy.length } : {},
|
|
155
|
+
taskIds: blockedBy
|
|
156
|
+
});
|
|
157
|
+
} else if (ready) {
|
|
158
|
+
badges.push({
|
|
159
|
+
kind: "ready",
|
|
160
|
+
label: "ready",
|
|
161
|
+
description: "No open dependencies block this task."
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (dependencyIds.length > 0 || blocks.length > 0 || unresolvedDependencyRefs.length > 0) {
|
|
165
|
+
badges.push({
|
|
166
|
+
kind: "dependency",
|
|
167
|
+
label: `deps ${dependencyIds.length}/${blocks.length}`,
|
|
168
|
+
description: [
|
|
169
|
+
dependencyIds.length > 0 ? `Depends on ${dependencyIds.join(", ")}.` : null,
|
|
170
|
+
blocks.length > 0 ? `Blocks ${blocks.join(", ")}.` : null,
|
|
171
|
+
unresolvedDependencyRefs.length > 0 ? `Unresolved refs: ${unresolvedDependencyRefs.join(", ")}.` : null
|
|
172
|
+
].filter((part) => part !== null).join(" "),
|
|
173
|
+
count: dependencyIds.length + blocks.length,
|
|
174
|
+
taskIds: unique([...dependencyIds, ...blocks])
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
summaries.set(task.id, {
|
|
178
|
+
taskId: task.id,
|
|
179
|
+
blockingDepth: blockingDepths.get(task.id) ?? 0,
|
|
180
|
+
dependencyIds,
|
|
181
|
+
unresolvedDependencyRefs,
|
|
182
|
+
blockedBy,
|
|
183
|
+
blocks,
|
|
184
|
+
blocked,
|
|
185
|
+
ready,
|
|
186
|
+
dependencyCount: dependencyIds.length,
|
|
187
|
+
dependentCount: blocks.length,
|
|
188
|
+
badges
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return summaries;
|
|
192
|
+
}
|
|
193
|
+
var TASK_STATUSES = new Set([
|
|
194
|
+
"draft",
|
|
195
|
+
"open",
|
|
196
|
+
"ready",
|
|
197
|
+
"queued",
|
|
198
|
+
"running",
|
|
199
|
+
"in_progress",
|
|
200
|
+
"under_review",
|
|
201
|
+
"blocked",
|
|
202
|
+
"unknown",
|
|
203
|
+
"completed",
|
|
204
|
+
"failed",
|
|
205
|
+
"cancelled",
|
|
206
|
+
"closed"
|
|
207
|
+
]);
|
|
208
|
+
function stringValue(value) {
|
|
209
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
210
|
+
}
|
|
211
|
+
function stringArray(value) {
|
|
212
|
+
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string" && entry.trim().length > 0).map((entry) => entry.trim()) : [];
|
|
213
|
+
}
|
|
214
|
+
function numberOrNull(value) {
|
|
215
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : null;
|
|
216
|
+
}
|
|
217
|
+
function metadataOf(task) {
|
|
218
|
+
return isObjectRecord(task.metadata) ? task.metadata : {};
|
|
219
|
+
}
|
|
220
|
+
function normalizeTaskStatus(status) {
|
|
221
|
+
const token = typeof status === "string" ? status.trim().toLowerCase() : "";
|
|
222
|
+
if (token === "done")
|
|
223
|
+
return "completed";
|
|
224
|
+
if (token === "canceled")
|
|
225
|
+
return "cancelled";
|
|
226
|
+
return TASK_STATUSES.has(token) ? token : "unknown";
|
|
227
|
+
}
|
|
228
|
+
function toTaskDependencyProjection(task) {
|
|
229
|
+
const metadata = metadataOf(task);
|
|
230
|
+
return {
|
|
231
|
+
id: String(task.id),
|
|
232
|
+
title: stringValue(task.title),
|
|
233
|
+
status: normalizeTaskStatus(task.status),
|
|
234
|
+
priority: numberOrNull(task.priority),
|
|
235
|
+
metadata,
|
|
236
|
+
externalId: stringValue(task.externalId),
|
|
237
|
+
sourceIssueId: stringValue(task.sourceIssueId),
|
|
238
|
+
dependencies: stringArray(task.dependencies),
|
|
239
|
+
parentChildDeps: stringArray(task.parentChildDeps),
|
|
240
|
+
createdAt: stringValue(task.createdAt) ?? "",
|
|
241
|
+
updatedAt: stringValue(task.updatedAt) ?? "",
|
|
242
|
+
role: stringValue(task.role),
|
|
243
|
+
scope: stringArray(task.scope),
|
|
244
|
+
validationKeys: stringArray(task.validationKeys),
|
|
245
|
+
labels: stringArray(task.labels),
|
|
246
|
+
assignees: task.assignees ?? null,
|
|
247
|
+
assignedTo: task.assignedTo ?? null
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function latestRunByTaskId(runs) {
|
|
251
|
+
const byTask = new Map;
|
|
252
|
+
const stamp = (run) => Date.parse(run.updatedAt ?? run.startedAt ?? "") || 0;
|
|
253
|
+
for (const run of runs) {
|
|
254
|
+
if (!run.taskId)
|
|
255
|
+
continue;
|
|
256
|
+
const current = byTask.get(run.taskId);
|
|
257
|
+
if (!current || stamp(run) >= stamp(current))
|
|
258
|
+
byTask.set(run.taskId, run);
|
|
259
|
+
}
|
|
260
|
+
return byTask;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// packages/dependency-graph-plugin/src/analysis/blockers.ts
|
|
264
|
+
var HUMAN_BLOCKERS = new Set(["human-decision", "human-approval", "external-input"]);
|
|
265
|
+
function labelsFor(task) {
|
|
266
|
+
return readTaskMetadataStringList(task, "labels").map((label) => label.toLowerCase());
|
|
267
|
+
}
|
|
268
|
+
function configuredTier(task, labels) {
|
|
269
|
+
const metadata = task.metadata && typeof task.metadata === "object" && !Array.isArray(task.metadata) ? task.metadata : {};
|
|
270
|
+
const tier = metadata.riskTier ?? metadata.actionRiskTier;
|
|
271
|
+
if (tier === "t1-read" || tier === "t2-reversible" || tier === "t3-external" || tier === "t4-irreversible")
|
|
272
|
+
return tier;
|
|
273
|
+
if (labels.some((label) => /prod|deploy|migration|billing|delete|irreversible/.test(label)))
|
|
274
|
+
return "t4-irreversible";
|
|
275
|
+
if (labels.some((label) => /customer|vendor|external|secret|credential|approval|decision/.test(label)))
|
|
276
|
+
return "t3-external";
|
|
277
|
+
const scopes = task.scope ?? [];
|
|
278
|
+
if (scopes.some((scope) => /docs|readme|test|spec/.test(scope.toLowerCase())))
|
|
279
|
+
return "t1-read";
|
|
280
|
+
return "t2-reversible";
|
|
281
|
+
}
|
|
282
|
+
function tierOf(task, labels = []) {
|
|
283
|
+
const projection = "metadata" in task && "id" in task && typeof task.id === "string" ? toTaskDependencyProjection(task) : task;
|
|
284
|
+
return configuredTier(projection, labels.length > 0 ? labels : labelsFor(projection)) ?? "t2-reversible";
|
|
285
|
+
}
|
|
286
|
+
function baseClassification(task, blockerClass, source, rationale, labels) {
|
|
287
|
+
return {
|
|
288
|
+
taskId: task.id,
|
|
289
|
+
blockerClass,
|
|
290
|
+
actionRiskTier: tierOf(task, labels),
|
|
291
|
+
rationale,
|
|
292
|
+
source,
|
|
293
|
+
autoApplied: source === "llm"
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function normalizeRunStatus(status) {
|
|
297
|
+
if (status === "waiting-approval" || status === "waiting-user-input" || status === "needs-attention" || status === "completed" || status === "failed" || status === "stopped" || status === "running")
|
|
298
|
+
return status;
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
function isHumanBlockerClass(blockerClass) {
|
|
302
|
+
return HUMAN_BLOCKERS.has(blockerClass);
|
|
303
|
+
}
|
|
304
|
+
function classifyBlocker(input) {
|
|
305
|
+
const labels = input.labels ?? labelsFor(input.task);
|
|
306
|
+
const runStatus = normalizeRunStatus(input.run?.status);
|
|
307
|
+
if (runStatus === "waiting-approval")
|
|
308
|
+
return baseClassification(input.task, "human-approval", "status", "run awaiting approval", labels);
|
|
309
|
+
if (runStatus === "waiting-user-input")
|
|
310
|
+
return baseClassification(input.task, "external-input", "status", "run awaiting user input", labels);
|
|
311
|
+
if (input.task.status !== "blocked")
|
|
312
|
+
return baseClassification(input.task, "not-blocked", "elimination", "task is not blocked", labels);
|
|
313
|
+
const incomplete = (input.badges.get(input.task.id)?.blockedBy ?? []).filter((dependencyId) => {
|
|
314
|
+
const dependency = input.tasksById.get(dependencyId);
|
|
315
|
+
return dependency ? !isTaskTerminalStatus(dependency.status) : false;
|
|
316
|
+
});
|
|
317
|
+
if (incomplete.length > 0)
|
|
318
|
+
return baseClassification(input.task, "task-blocked", "elimination", `blocked by ${incomplete.length} incomplete task(s)`, labels);
|
|
319
|
+
if (labels.includes("needs-decision"))
|
|
320
|
+
return baseClassification(input.task, "human-decision", "label", "needs-decision label", labels);
|
|
321
|
+
if (labels.some((label) => /^waiting-on-/.test(label)))
|
|
322
|
+
return baseClassification(input.task, "external-input", "label", "waiting-on-* label", labels);
|
|
323
|
+
if (input.config?.llm)
|
|
324
|
+
return baseClassification(input.task, "human-decision", "llm", "LLM residue classifier marked this as human-gated", labels);
|
|
325
|
+
return baseClassification(input.task, "human-decision", "elimination", "blocked, all task dependencies terminal; non-task gate remains", labels);
|
|
326
|
+
}
|
|
327
|
+
function classifyTasks(tasks, runs = [], options = {}) {
|
|
328
|
+
const projected = tasks.map(toTaskDependencyProjection);
|
|
329
|
+
const badges = computeTaskDependencyBadges(projected);
|
|
330
|
+
const tasksById = new Map(projected.map((task) => [task.id, task]));
|
|
331
|
+
const runByTask = latestRunByTaskId(runs);
|
|
332
|
+
const classifier = options.classifier ?? classifyBlocker;
|
|
333
|
+
const classifications = projected.map((task) => classifier({ task, badges, tasksById, run: runByTask.get(task.id) ?? null, labels: labelsFor(task) })).filter((classification) => options.humanOnly !== true || isHumanBlockerClass(classification.blockerClass));
|
|
334
|
+
return {
|
|
335
|
+
classifications,
|
|
336
|
+
byTaskId: new Map(classifications.map((classification) => [classification.taskId, classification])),
|
|
337
|
+
human: classifications.filter((classification) => isHumanBlockerClass(classification.blockerClass)),
|
|
338
|
+
machine: classifications.filter((classification) => !isHumanBlockerClass(classification.blockerClass)),
|
|
339
|
+
generatedAt: options.generatedAt ?? new Date().toISOString()
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
async function classifyWorkspaceBlockers(projectRoot, deps) {
|
|
343
|
+
const [tasks, runs] = await Promise.all([
|
|
344
|
+
deps.listTasks(projectRoot),
|
|
345
|
+
deps.listRuns ? deps.listRuns(projectRoot) : Promise.resolve([])
|
|
346
|
+
]);
|
|
347
|
+
return classifyTasks(tasks, runs, deps);
|
|
348
|
+
}
|
|
349
|
+
export {
|
|
350
|
+
tierOf,
|
|
351
|
+
isHumanBlockerClass,
|
|
352
|
+
classifyWorkspaceBlockers,
|
|
353
|
+
classifyTasks,
|
|
354
|
+
classifyBlocker
|
|
355
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DependencyEdge as ContractDependencyEdge, DependencyNode as ContractDependencyNode,
|
|
1
|
+
import type { DependencyEdge as ContractDependencyEdge, DependencyNode as ContractDependencyNode, TaskSummary } from "@rig/contracts";
|
|
2
2
|
import { type TaskGraphLayout } from "./taskGraphLayout";
|
|
3
3
|
export type DependencyEdgeType = ContractDependencyEdge["type"];
|
|
4
4
|
export interface DependencyEdge {
|
|
@@ -35,7 +35,6 @@ export interface DependencyGraphModel {
|
|
|
35
35
|
readonly generatedAt: string;
|
|
36
36
|
}
|
|
37
37
|
export interface BuildDependencyGraphModelOptions {
|
|
38
|
-
readonly snapshot?: EngineReadModel | null;
|
|
39
38
|
readonly generatedAt?: string;
|
|
40
39
|
readonly graphId?: string;
|
|
41
40
|
readonly showParentChild?: boolean;
|