patchrelay 0.36.6 → 0.36.8
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/README.md +3 -0
- package/dist/build-info.json +3 -3
- package/dist/cli/cluster-health.js +8 -8
- package/dist/cli/commands/setup.js +32 -27
- package/dist/cli/data.js +11 -11
- package/dist/cli/help.js +1 -1
- package/dist/cli/service-commands.js +11 -0
- package/dist/config.js +48 -0
- package/dist/db/issue-session-store.js +292 -0
- package/dist/db/run-store.js +127 -0
- package/dist/db/webhook-event-store.js +71 -0
- package/dist/db.js +22 -520
- package/dist/github-webhook-handler.js +25 -25
- package/dist/idle-reconciliation.js +5 -5
- package/dist/issue-query-service.js +9 -9
- package/dist/issue-session-lease-service.js +143 -0
- package/dist/linear-session-sync.js +4 -4
- package/dist/patchrelay-customization.js +68 -0
- package/dist/prompting/patchrelay.js +552 -0
- package/dist/queue-health-monitor.js +2 -2
- package/dist/run-finalizer.js +161 -0
- package/dist/run-launcher.js +193 -0
- package/dist/run-orchestrator.js +151 -1396
- package/dist/run-recovery-service.js +203 -0
- package/dist/run-wake-planner.js +101 -0
- package/dist/service.js +24 -24
- package/dist/tracked-issue-projector.js +69 -0
- package/dist/webhook-handler.js +59 -688
- package/dist/webhooks/agent-session-handler.js +212 -0
- package/dist/webhooks/comment-policy.js +41 -0
- package/dist/webhooks/comment-wake-handler.js +133 -0
- package/dist/webhooks/decision-helpers.js +74 -0
- package/dist/webhooks/desired-stage-recorder.js +177 -0
- package/dist/webhooks/issue-removal-handler.js +68 -0
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { TERMINAL_STATES } from "../factory-state.js";
|
|
2
|
+
export class IssueRemovalHandler {
|
|
3
|
+
db;
|
|
4
|
+
feed;
|
|
5
|
+
constructor(db, feed) {
|
|
6
|
+
this.db = db;
|
|
7
|
+
this.feed = feed;
|
|
8
|
+
}
|
|
9
|
+
async handle(params) {
|
|
10
|
+
if (!params.trackedIssue)
|
|
11
|
+
return;
|
|
12
|
+
const removedIssue = this.db.getIssue(params.projectId, params.issue.id);
|
|
13
|
+
const activeLease = this.db.issueSessions.getActiveIssueSessionLease(params.projectId, params.issue.id);
|
|
14
|
+
const commitRemoval = () => {
|
|
15
|
+
if (removedIssue?.activeRunId) {
|
|
16
|
+
const run = this.db.runs.getRunById(removedIssue.activeRunId);
|
|
17
|
+
if (run) {
|
|
18
|
+
this.db.runs.finishRun(run.id, { status: "released", failureReason: "Issue removed from Linear" });
|
|
19
|
+
}
|
|
20
|
+
return this.db.upsertIssue({
|
|
21
|
+
projectId: params.projectId,
|
|
22
|
+
linearIssueId: params.issue.id,
|
|
23
|
+
activeRunId: null,
|
|
24
|
+
pendingRunType: null,
|
|
25
|
+
factoryState: "failed",
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (removedIssue && !TERMINAL_STATES.has(removedIssue.factoryState)) {
|
|
29
|
+
return this.db.upsertIssue({
|
|
30
|
+
projectId: params.projectId,
|
|
31
|
+
linearIssueId: params.issue.id,
|
|
32
|
+
pendingRunType: null,
|
|
33
|
+
factoryState: "failed",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return removedIssue;
|
|
37
|
+
};
|
|
38
|
+
if (removedIssue?.activeRunId) {
|
|
39
|
+
const run = this.db.runs.getRunById(removedIssue.activeRunId);
|
|
40
|
+
if (run) {
|
|
41
|
+
await params.stopActiveRun(run, "STOP: The Linear issue was removed. Stop working immediately and exit.");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (activeLease) {
|
|
45
|
+
this.db.issueSessions.withIssueSessionLease(params.projectId, params.issue.id, activeLease.leaseId, commitRemoval);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
commitRemoval();
|
|
49
|
+
}
|
|
50
|
+
this.db.issueSessions.appendIssueSessionEvent({
|
|
51
|
+
projectId: params.projectId,
|
|
52
|
+
linearIssueId: params.issue.id,
|
|
53
|
+
eventType: "issue_removed",
|
|
54
|
+
dedupeKey: `issue_removed:${params.issue.id}`,
|
|
55
|
+
});
|
|
56
|
+
this.db.issueSessions.clearPendingIssueSessionEventsRespectingActiveLease(params.projectId, params.issue.id);
|
|
57
|
+
this.db.issueSessions.releaseIssueSessionLeaseRespectingActiveLease(params.projectId, params.issue.id);
|
|
58
|
+
this.feed?.publish({
|
|
59
|
+
level: "warn",
|
|
60
|
+
kind: "stage",
|
|
61
|
+
issueKey: params.issue.identifier,
|
|
62
|
+
projectId: params.projectId,
|
|
63
|
+
stage: "failed",
|
|
64
|
+
status: "issue_removed",
|
|
65
|
+
summary: "Issue removed from Linear",
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|