@h-rig/blocker-classifier-plugin 0.0.6-alpha.157 → 0.0.6-alpha.159
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/{blockers.d.ts → analysis/blockers.d.ts} +1 -2
- package/dist/src/analysis/blockers.js +355 -0
- package/dist/src/analysis/taskGraphPrimitives.d.ts +58 -0
- package/dist/src/analysis/taskGraphPrimitives.js +528 -0
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +277 -21
- package/dist/src/plugin.d.ts +1 -7
- package/dist/src/plugin.js +274 -21
- package/package.json +3 -4
- package/dist/src/blockers.js +0 -101
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { TaskLike } from "@rig/
|
|
2
|
-
import type { ClientTaskProjection, TaskDependencyBadgeSummary } from "@rig/contracts";
|
|
1
|
+
import type { ClientTaskProjection, TaskDependencyBadgeSummary, TaskLike } from "@rig/contracts";
|
|
3
2
|
import type { BlockerClass, BlockerClassification, ActionRiskTier, RunRecord } from "@rig/contracts";
|
|
4
3
|
export type BlockerClassifier = (input: BlockerClassifierInput) => BlockerClassification;
|
|
5
4
|
export interface BlockerClassifierInput {
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/blocker-classifier-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/blocker-classifier-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
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type ClientTaskProjection, type RunJournalProjection, type RunStatus, type TaskDependencyBadgeSummary, type TaskDependencyProjection, type TaskProjectionInput, type TaskScopeInput, type TaskSummary } from "@rig/contracts";
|
|
2
|
+
export declare function readTaskMetadataStringList(task: TaskDependencyProjection, key: "dependencies" | "parentChildDeps" | "labels"): string[];
|
|
3
|
+
export declare function readTaskBlockingDependencyRefs(task: TaskDependencyProjection): string[];
|
|
4
|
+
export declare function readTaskDependencyRefs(task: TaskDependencyProjection): string[];
|
|
5
|
+
export declare function readTaskSourceIssueId(task: TaskDependencyProjection): string | null;
|
|
6
|
+
export declare function readTaskScope(task: TaskDependencyProjection): string[];
|
|
7
|
+
export declare function disjointScope(left: TaskScopeInput, right: TaskScopeInput): boolean;
|
|
8
|
+
export declare function resolveTaskReference(ref: string, tasksById: ReadonlyMap<string, TaskDependencyProjection>, taskIdByExternalRef: ReadonlyMap<string, string>, taskIdBySourceIssueId: ReadonlyMap<string, string>): string | null;
|
|
9
|
+
export declare function buildTaskReferenceIndex<T extends TaskDependencyProjection>(tasks: readonly T[]): {
|
|
10
|
+
readonly tasksById: Map<string, T>;
|
|
11
|
+
readonly taskIdByExternalRef: Map<string, string>;
|
|
12
|
+
readonly taskIdBySourceIssueId: Map<string, string>;
|
|
13
|
+
};
|
|
14
|
+
export declare function computeTaskBlockingDepths<T extends TaskDependencyProjection>(tasks: readonly T[]): Map<string, number>;
|
|
15
|
+
export declare function isTaskTerminalStatus(status: string | null | undefined): boolean;
|
|
16
|
+
export declare function computeTaskDependencyBadges(tasks: readonly TaskDependencyProjection[]): Map<string, TaskDependencyBadgeSummary>;
|
|
17
|
+
export declare function normalizeTaskStatus(status: unknown): TaskSummary["status"];
|
|
18
|
+
export declare function toTaskDependencyProjection(task: TaskProjectionInput): ClientTaskProjection;
|
|
19
|
+
export declare function toTaskSummary(task: TaskProjectionInput, defaults?: {
|
|
20
|
+
readonly workspaceId?: string;
|
|
21
|
+
readonly graphId?: string | null;
|
|
22
|
+
}): TaskSummary;
|
|
23
|
+
export declare function selectNextReadyTaskByPriority<T extends TaskDependencyProjection>(tasks: readonly T[], options?: {
|
|
24
|
+
readonly excludeTaskIds?: Iterable<string>;
|
|
25
|
+
readonly filter?: (task: T) => boolean;
|
|
26
|
+
}): T | null;
|
|
27
|
+
export type RigTaskSessionProjection = Pick<RunJournalProjection, "record" | "status" | "lastEventAt"> & {
|
|
28
|
+
readonly taskId?: string | null;
|
|
29
|
+
};
|
|
30
|
+
export interface RigTaskStatusGroupingInput<T extends TaskDependencyProjection = TaskDependencyProjection> {
|
|
31
|
+
readonly tasks: readonly T[];
|
|
32
|
+
readonly sessions?: readonly RigTaskSessionProjection[];
|
|
33
|
+
readonly workspaceId?: string | null;
|
|
34
|
+
}
|
|
35
|
+
export interface RigTaskStatusGroup<T extends TaskDependencyProjection = TaskDependencyProjection> {
|
|
36
|
+
readonly status: string;
|
|
37
|
+
readonly tasks: readonly T[];
|
|
38
|
+
}
|
|
39
|
+
export declare function projectTaskStatusForGrouping(status: string | null | undefined): string;
|
|
40
|
+
export declare function projectRunStatusForTaskGrouping(status: RunStatus | null | undefined): string | null;
|
|
41
|
+
export declare function projectTaskStatusWithSessions(task: TaskDependencyProjection, sessionsByTask?: ReadonlyMap<string, RigTaskSessionProjection>): string;
|
|
42
|
+
export declare function selectTasksGroupedByStatus<T extends TaskDependencyProjection>(input: RigTaskStatusGroupingInput<T>): Array<RigTaskStatusGroup<T>>;
|
|
43
|
+
export declare function normalizeTaskAssigneeFilter(assignee: string | null | undefined, currentUserLogin?: string | null): string | null;
|
|
44
|
+
export declare function readTaskAssigneeLogins(task: TaskDependencyProjection): readonly string[];
|
|
45
|
+
export declare function taskMatchesAssigneeFilter(task: TaskDependencyProjection, assignee: string | null | undefined, options?: {
|
|
46
|
+
readonly currentUserLogin?: string | null;
|
|
47
|
+
}): boolean;
|
|
48
|
+
export declare function selectTasksAssignedTo<T extends TaskDependencyProjection>(tasks: readonly T[], assignee: string | null | undefined, options?: {
|
|
49
|
+
readonly currentUserLogin?: string | null;
|
|
50
|
+
}): T[];
|
|
51
|
+
export declare function selectTasksAssignedToMe<T extends TaskDependencyProjection>(tasks: readonly T[], currentUserLogin: string | null | undefined): T[];
|
|
52
|
+
/** Keep only the most-recently-updated run per task id. */
|
|
53
|
+
export declare function latestRunByTaskId<T extends {
|
|
54
|
+
readonly taskId: string | null;
|
|
55
|
+
readonly updatedAt: string | null;
|
|
56
|
+
readonly startedAt: string | null;
|
|
57
|
+
}>(runs: readonly T[]): Map<string, T>;
|
|
58
|
+
export declare function isOperatorActiveRunStatus(status: unknown): boolean;
|