patchrelay 0.51.0 → 0.51.1

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "service": "patchrelay",
3
- "version": "0.51.0",
4
- "commit": "c8ad40f06a1c",
5
- "builtAt": "2026-04-21T21:25:15.871Z"
3
+ "version": "0.51.1",
4
+ "commit": "0b16fe78f8c9",
5
+ "builtAt": "2026-04-21T22:06:12.939Z"
6
6
  }
@@ -2,6 +2,13 @@ import { resolveMergeQueueProtocol } from "./merge-queue-protocol.js";
2
2
  import { buildMainRepairBranchName, buildMainRepairDescription, buildMainRepairPromptContext, buildMainRepairTitle, isMainRepairIssue, } from "./main-repair.js";
3
3
  import { execCommand } from "./utils.js";
4
4
  const MAIN_BRANCH_HEALTH_GRACE_MS = 120_000;
5
+ function isUnhealthyMainConclusion(conclusion) {
6
+ return conclusion === "failure"
7
+ || conclusion === "timed_out"
8
+ || conclusion === "cancelled"
9
+ || conclusion === "action_required"
10
+ || conclusion === "stale";
11
+ }
5
12
  export class MainBranchHealthMonitor {
6
13
  db;
7
14
  config;
@@ -36,17 +43,20 @@ export class MainBranchHealthMonitor {
36
43
  && issue.factoryState !== "done"
37
44
  && issue.factoryState !== "failed"
38
45
  && issue.factoryState !== "escalated"));
46
+ const summary = await this.readMainBranchFailure(project.github.repoFullName, baseBranch);
47
+ if (!summary) {
48
+ if (existing) {
49
+ this.resolveRecoveredMainRepair(existing);
50
+ }
51
+ return;
52
+ }
53
+ const protocol = resolveMergeQueueProtocol(project);
39
54
  if (existing) {
40
55
  const age = Date.now() - Date.parse(existing.updatedAt);
41
56
  if (age < MAIN_BRANCH_HEALTH_GRACE_MS) {
42
57
  return;
43
58
  }
44
59
  }
45
- const summary = await this.readMainBranchFailure(project.github.repoFullName, baseBranch);
46
- if (!summary) {
47
- return;
48
- }
49
- const protocol = resolveMergeQueueProtocol(project);
50
60
  if (existing) {
51
61
  this.queueExistingMainRepair(existing, summary, protocol.priorityLabel);
52
62
  return;
@@ -128,6 +138,29 @@ export class MainBranchHealthMonitor {
128
138
  this.enqueueIssue(issue.projectId, issue.linearIssueId);
129
139
  }
130
140
  }
141
+ resolveRecoveredMainRepair(issue) {
142
+ if (issue.activeRunId !== undefined)
143
+ return;
144
+ if (issue.prState === "open" || issue.factoryState === "awaiting_queue" || issue.factoryState === "pr_open") {
145
+ return;
146
+ }
147
+ this.db.issueSessions.clearPendingIssueSessionEventsRespectingActiveLease(issue.projectId, issue.linearIssueId);
148
+ this.db.upsertIssue({
149
+ projectId: issue.projectId,
150
+ linearIssueId: issue.linearIssueId,
151
+ factoryState: "done",
152
+ pendingRunType: null,
153
+ });
154
+ this.feed?.publish({
155
+ level: "info",
156
+ kind: "github",
157
+ issueKey: issue.issueKey,
158
+ projectId: issue.projectId,
159
+ stage: "done",
160
+ status: "main_repair_resolved",
161
+ summary: "Closed stale main_repair after main recovered externally",
162
+ });
163
+ }
131
164
  async readMainBranchFailure(repoFullName, baseBranch) {
132
165
  const { stdout: shaOut } = await execCommand("gh", [
133
166
  "api",
@@ -146,7 +179,7 @@ export class MainBranchHealthMonitor {
146
179
  ], { timeoutMs: 10_000 });
147
180
  const runs = JSON.parse(checksOut || "[]");
148
181
  const failingChecks = runs
149
- .filter((run) => run.status === "completed" && run.conclusion === "failure" && typeof run.name === "string" && run.name.trim())
182
+ .filter((run) => run.status === "completed" && isUnhealthyMainConclusion(run.conclusion) && typeof run.name === "string" && run.name.trim())
150
183
  .map((run) => ({ name: run.name.trim(), ...(run.details_url ? { url: run.details_url } : {}) }));
151
184
  if (failingChecks.length === 0) {
152
185
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchrelay",
3
- "version": "0.51.0",
3
+ "version": "0.51.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {