patchrelay 0.74.5 → 0.74.7
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/build-info.json +3 -3
- package/dist/cli/commands/repo.js +2 -2
- package/dist/db/issue-session-store.js +46 -4
- package/dist/db/issue-store.js +9 -4
- package/dist/db/run-store.js +44 -8
- package/dist/db.js +44 -11
- package/dist/issue-session-lease-service.js +57 -3
- package/dist/issue-session-projection-invalidator.js +90 -0
- package/dist/run-orchestrator.js +66 -3
- package/dist/service.js +9 -3
- package/dist/telemetry.js +85 -0
- package/dist/wake-dispatcher.js +180 -6
- package/dist/webhook-handler.js +6 -3
- package/dist/webhooks/dependency-readiness-handler.js +57 -6
- package/dist/workflow-wake-resolver.js +5 -3
- package/package.json +1 -1
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { emitTelemetry, noopTelemetry } from "../telemetry.js";
|
|
1
2
|
export class DependencyReadinessHandler {
|
|
2
3
|
db;
|
|
3
4
|
wakeDispatcher;
|
|
4
5
|
peekPendingSessionWakeRunType;
|
|
5
|
-
|
|
6
|
+
telemetry;
|
|
7
|
+
constructor(db, wakeDispatcher, peekPendingSessionWakeRunType, telemetry = noopTelemetry) {
|
|
6
8
|
this.db = db;
|
|
7
9
|
this.wakeDispatcher = wakeDispatcher;
|
|
8
10
|
this.peekPendingSessionWakeRunType = peekPendingSessionWakeRunType;
|
|
11
|
+
this.telemetry = telemetry;
|
|
9
12
|
}
|
|
10
13
|
reconcile(projectId, blockerLinearIssueId) {
|
|
11
14
|
const newlyReady = [];
|
|
@@ -16,6 +19,25 @@ export class DependencyReadinessHandler {
|
|
|
16
19
|
}
|
|
17
20
|
const unresolved = this.db.issues.countUnresolvedBlockers(projectId, dependent.linearIssueId);
|
|
18
21
|
if (unresolved > 0) {
|
|
22
|
+
const blockerKeys = this.unresolvedBlockerKeys(projectId, dependent.linearIssueId);
|
|
23
|
+
emitTelemetry(this.telemetry, {
|
|
24
|
+
type: "dependency.remaining_blockers",
|
|
25
|
+
projectId,
|
|
26
|
+
linearIssueId: dependent.linearIssueId,
|
|
27
|
+
...(issue.issueKey ? { issueKey: issue.issueKey } : {}),
|
|
28
|
+
blockerLinearIssueId,
|
|
29
|
+
blockerCount: unresolved,
|
|
30
|
+
blockerKeys,
|
|
31
|
+
});
|
|
32
|
+
emitTelemetry(this.telemetry, {
|
|
33
|
+
type: "dependency.dependent_blocked",
|
|
34
|
+
projectId,
|
|
35
|
+
linearIssueId: dependent.linearIssueId,
|
|
36
|
+
...(issue.issueKey ? { issueKey: issue.issueKey } : {}),
|
|
37
|
+
blockerLinearIssueId,
|
|
38
|
+
blockerCount: unresolved,
|
|
39
|
+
blockerKeys,
|
|
40
|
+
});
|
|
19
41
|
if (this.peekPendingSessionWakeRunType(projectId, dependent.linearIssueId) === "implementation"
|
|
20
42
|
&& issue.activeRunId === undefined
|
|
21
43
|
&& !this.db.issueSessions.hasPendingIssueSessionEvents(projectId, dependent.linearIssueId)) {
|
|
@@ -28,10 +50,25 @@ export class DependencyReadinessHandler {
|
|
|
28
50
|
}
|
|
29
51
|
continue;
|
|
30
52
|
}
|
|
31
|
-
if (issue.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
53
|
+
if (!issue.delegatedToPatchRelay || issue.activeRunId !== undefined) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const pendingWakeRunType = this.db.workflowWakes.peekIssueWake(projectId, dependent.linearIssueId)?.runType
|
|
57
|
+
?? issue.pendingRunType;
|
|
58
|
+
if (pendingWakeRunType) {
|
|
59
|
+
const dispatchedRunType = this.wakeDispatcher.dispatchIfWakePending(projectId, dependent.linearIssueId);
|
|
60
|
+
emitTelemetry(this.telemetry, {
|
|
61
|
+
type: "dependency.dependent_unblocked",
|
|
62
|
+
projectId,
|
|
63
|
+
linearIssueId: dependent.linearIssueId,
|
|
64
|
+
...(issue.issueKey ? { issueKey: issue.issueKey } : {}),
|
|
65
|
+
blockerLinearIssueId,
|
|
66
|
+
...(dispatchedRunType ? { dispatchedRunType } : {}),
|
|
67
|
+
});
|
|
68
|
+
newlyReady.push(dependent.linearIssueId);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (issue.factoryState !== "delegated" || this.db.issueSessions.hasPendingIssueSessionEvents(projectId, dependent.linearIssueId)) {
|
|
35
72
|
continue;
|
|
36
73
|
}
|
|
37
74
|
if (this.peekPendingSessionWakeRunType(projectId, dependent.linearIssueId) === "implementation") {
|
|
@@ -42,12 +79,26 @@ export class DependencyReadinessHandler {
|
|
|
42
79
|
pendingRunContextJson: null,
|
|
43
80
|
});
|
|
44
81
|
}
|
|
45
|
-
this.wakeDispatcher.recordEventAndDispatch(projectId, dependent.linearIssueId, {
|
|
82
|
+
const dispatchedRunType = this.wakeDispatcher.recordEventAndDispatch(projectId, dependent.linearIssueId, {
|
|
46
83
|
eventType: "delegated",
|
|
47
84
|
dedupeKey: `delegated:${dependent.linearIssueId}`,
|
|
48
85
|
});
|
|
86
|
+
emitTelemetry(this.telemetry, {
|
|
87
|
+
type: "dependency.dependent_unblocked",
|
|
88
|
+
projectId,
|
|
89
|
+
linearIssueId: dependent.linearIssueId,
|
|
90
|
+
...(issue.issueKey ? { issueKey: issue.issueKey } : {}),
|
|
91
|
+
blockerLinearIssueId,
|
|
92
|
+
...(dispatchedRunType ? { dispatchedRunType } : {}),
|
|
93
|
+
});
|
|
49
94
|
newlyReady.push(dependent.linearIssueId);
|
|
50
95
|
}
|
|
51
96
|
return newlyReady;
|
|
52
97
|
}
|
|
98
|
+
unresolvedBlockerKeys(projectId, linearIssueId) {
|
|
99
|
+
return this.db.issues.listIssueDependencies(projectId, linearIssueId)
|
|
100
|
+
.filter((entry) => entry.blockerCurrentLinearStateType !== "completed"
|
|
101
|
+
&& entry.blockerCurrentLinearState?.trim().toLowerCase() !== "done")
|
|
102
|
+
.map((entry) => entry.blockerIssueKey ?? entry.blockerLinearIssueId);
|
|
103
|
+
}
|
|
53
104
|
}
|
|
@@ -85,12 +85,14 @@ export class WorkflowWakeResolver {
|
|
|
85
85
|
this.issueSessions = issueSessions;
|
|
86
86
|
}
|
|
87
87
|
peekIssueWake(projectId, linearIssueId) {
|
|
88
|
-
const explicitWake = this.issueSessions.peekIssueSessionWake(projectId, linearIssueId);
|
|
89
|
-
if (explicitWake)
|
|
90
|
-
return explicitWake;
|
|
91
88
|
const issue = this.issues.getIssue(projectId, linearIssueId);
|
|
92
89
|
if (!issue)
|
|
93
90
|
return undefined;
|
|
91
|
+
if (this.issues.countUnresolvedBlockers(projectId, linearIssueId) > 0)
|
|
92
|
+
return undefined;
|
|
93
|
+
const explicitWake = this.issueSessions.peekIssueSessionWake(projectId, linearIssueId);
|
|
94
|
+
if (explicitWake)
|
|
95
|
+
return explicitWake;
|
|
94
96
|
const implicitWake = deriveImplicitReactiveWake(issue);
|
|
95
97
|
if (!implicitWake)
|
|
96
98
|
return undefined;
|