patchrelay 0.52.2 → 0.52.3
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
CHANGED
|
@@ -38,7 +38,7 @@ export class ImplementationOutcomePolicy {
|
|
|
38
38
|
return await this.describeLocalImplementationOutcome(issue, baseBranch);
|
|
39
39
|
}
|
|
40
40
|
async detectPublishedPrState(run, issue, repoFullName) {
|
|
41
|
-
if (issue.prNumber && issue.prState
|
|
41
|
+
if (issue.prNumber && isOpenPrState(issue.prState)) {
|
|
42
42
|
return "open";
|
|
43
43
|
}
|
|
44
44
|
if (!repoFullName || !issue.branchName) {
|
|
@@ -61,24 +61,30 @@ export class ImplementationOutcomePolicy {
|
|
|
61
61
|
return "unknown";
|
|
62
62
|
}
|
|
63
63
|
const matches = JSON.parse(stdout);
|
|
64
|
-
const pr = matches[0];
|
|
64
|
+
const pr = matches.find((candidate) => isOpenPrState(candidate.state)) ?? matches[0];
|
|
65
65
|
if (!pr?.number) {
|
|
66
|
+
this.clearObservedPrIfLeaseHeld(issue, "published PR verification found no PRs for branch");
|
|
66
67
|
return "none";
|
|
67
68
|
}
|
|
68
69
|
const state = pr.state?.toLowerCase();
|
|
69
|
-
|
|
70
|
-
projectId
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
if (isOpenPrState(state)) {
|
|
71
|
+
this.upsertIssueIfLeaseHeld(issue.projectId, issue.linearIssueId, {
|
|
72
|
+
projectId: issue.projectId,
|
|
73
|
+
linearIssueId: issue.linearIssueId,
|
|
74
|
+
prNumber: pr.number,
|
|
75
|
+
...(pr.url ? { prUrl: pr.url } : {}),
|
|
76
|
+
...(state ? { prState: state } : {}),
|
|
77
|
+
...(pr.headRefOid ? { prHeadSha: pr.headRefOid } : {}),
|
|
78
|
+
...(pr.author?.login ? { prAuthorLogin: pr.author.login } : {}),
|
|
79
|
+
}, "published PR verification refresh");
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.clearObservedPrIfLeaseHeld(issue, "published PR verification found only historical PRs for branch");
|
|
83
|
+
}
|
|
84
|
+
if (isOpenPrState(state) && isMainRepairIssue(issue)) {
|
|
79
85
|
await this.ensurePriorityQueueLabel(run.projectId, pr.number, repoFullName);
|
|
80
86
|
}
|
|
81
|
-
return state
|
|
87
|
+
return isOpenPrState(state) ? "open" : "closed";
|
|
82
88
|
}
|
|
83
89
|
catch (error) {
|
|
84
90
|
this.logger.debug({
|
|
@@ -97,6 +103,20 @@ export class ImplementationOutcomePolicy {
|
|
|
97
103
|
}
|
|
98
104
|
return updated;
|
|
99
105
|
}
|
|
106
|
+
clearObservedPrIfLeaseHeld(issue, context) {
|
|
107
|
+
this.upsertIssueIfLeaseHeld(issue.projectId, issue.linearIssueId, {
|
|
108
|
+
projectId: issue.projectId,
|
|
109
|
+
linearIssueId: issue.linearIssueId,
|
|
110
|
+
prNumber: null,
|
|
111
|
+
prUrl: null,
|
|
112
|
+
prState: null,
|
|
113
|
+
prIsDraft: null,
|
|
114
|
+
prHeadSha: null,
|
|
115
|
+
prAuthorLogin: null,
|
|
116
|
+
prReviewState: null,
|
|
117
|
+
prCheckStatus: null,
|
|
118
|
+
}, context);
|
|
119
|
+
}
|
|
100
120
|
async describeLocalImplementationOutcome(issue, baseBranch) {
|
|
101
121
|
if (!issue.worktreePath) {
|
|
102
122
|
return undefined;
|
|
@@ -177,3 +197,9 @@ export class ImplementationOutcomePolicy {
|
|
|
177
197
|
}
|
|
178
198
|
}
|
|
179
199
|
}
|
|
200
|
+
function isOpenPrState(state) {
|
|
201
|
+
if (!state)
|
|
202
|
+
return false;
|
|
203
|
+
const normalized = state.trim().toLowerCase();
|
|
204
|
+
return normalized !== "closed" && normalized !== "merged";
|
|
205
|
+
}
|
|
@@ -170,6 +170,51 @@ export async function handleNoPrCompletionCheck(params) {
|
|
|
170
170
|
});
|
|
171
171
|
return;
|
|
172
172
|
}
|
|
173
|
+
if (params.run.runType === "main_repair") {
|
|
174
|
+
const continued = params.withHeldLease(params.run.projectId, params.run.linearIssueId, (lease) => {
|
|
175
|
+
params.db.runs.finishRun(params.run.id, runUpdate);
|
|
176
|
+
params.db.runs.saveCompletionCheck(params.run.id, {
|
|
177
|
+
...completionCheck,
|
|
178
|
+
outcome: "continue",
|
|
179
|
+
summary: "Main repair cannot finish without a published repair PR; continuing automatically until the fix is published or main recovers externally.",
|
|
180
|
+
why: completionCheck.summary,
|
|
181
|
+
});
|
|
182
|
+
params.db.issues.upsertIssue({
|
|
183
|
+
projectId: params.run.projectId,
|
|
184
|
+
linearIssueId: params.run.linearIssueId,
|
|
185
|
+
activeRunId: null,
|
|
186
|
+
factoryState: "delegated",
|
|
187
|
+
pendingRunType: null,
|
|
188
|
+
pendingRunContextJson: null,
|
|
189
|
+
});
|
|
190
|
+
return Boolean(params.db.issueSessions.appendIssueSessionEventWithLease(lease, {
|
|
191
|
+
projectId: params.run.projectId,
|
|
192
|
+
linearIssueId: params.run.linearIssueId,
|
|
193
|
+
eventType: "completion_check_continue",
|
|
194
|
+
eventJson: JSON.stringify({
|
|
195
|
+
runType: params.run.runType,
|
|
196
|
+
summary: params.publishedOutcomeError,
|
|
197
|
+
}),
|
|
198
|
+
dedupeKey: `completion_check_continue:${params.run.id}`,
|
|
199
|
+
}));
|
|
200
|
+
});
|
|
201
|
+
if (!continued) {
|
|
202
|
+
params.logger.warn({ runId: params.run.id, issueId: params.run.linearIssueId }, "Skipping main-repair completion-check continue writes after losing issue-session lease");
|
|
203
|
+
params.clearProgressAndRelease(params.run);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
params.syncCompletionCheckOutcome({
|
|
207
|
+
run: params.run,
|
|
208
|
+
fallbackIssue: params.issue,
|
|
209
|
+
level: "info",
|
|
210
|
+
status: "completion_check_continue",
|
|
211
|
+
summary: "No repair PR found; continuing automatically",
|
|
212
|
+
detail: "Main repair cannot close until PatchRelay publishes a repair PR or main recovers externally.",
|
|
213
|
+
activity: buildCompletionCheckActivity("continue"),
|
|
214
|
+
enqueue: true,
|
|
215
|
+
});
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
173
218
|
const orchestrationOpenChildren = params.issue.issueClass === "orchestration"
|
|
174
219
|
? params.db.issues.countOpenChildIssues(params.run.projectId, params.run.linearIssueId)
|
|
175
220
|
: 0;
|