patchrelay 0.52.3 → 0.52.4

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.52.3",
4
- "commit": "76e8fb03067d",
5
- "builtAt": "2026-04-22T19:20:36.664Z"
3
+ "version": "0.52.4",
4
+ "commit": "5fd50d353ab4",
5
+ "builtAt": "2026-04-22T20:52:16.943Z"
6
6
  }
@@ -37,12 +37,7 @@ export class MainBranchHealthMonitor {
37
37
  return;
38
38
  const baseBranch = project.github.baseBranch ?? "main";
39
39
  const branchName = buildMainRepairBranchName(baseBranch);
40
- const existing = this.db.listIssues().find((issue) => (issue.projectId === projectId
41
- && issue.branchName === branchName
42
- && isMainRepairIssue(issue)
43
- && issue.factoryState !== "done"
44
- && issue.factoryState !== "failed"
45
- && issue.factoryState !== "escalated"));
40
+ const existing = this.findExistingMainRepair(projectId, branchName);
46
41
  const summary = await this.readMainBranchFailure(project.github.repoFullName, baseBranch);
47
42
  if (!summary) {
48
43
  if (existing) {
@@ -114,6 +109,33 @@ export class MainBranchHealthMonitor {
114
109
  detail: summary.failingChecks.map((check) => check.name).join(", "),
115
110
  });
116
111
  }
112
+ findExistingMainRepair(projectId, branchName) {
113
+ const candidates = this.db.listIssues()
114
+ .filter((issue) => (issue.projectId === projectId
115
+ && issue.branchName === branchName
116
+ && isMainRepairIssue(issue)
117
+ && issue.factoryState !== "done"))
118
+ .sort((left, right) => this.compareMainRepairCandidates(left, right));
119
+ return candidates[0];
120
+ }
121
+ compareMainRepairCandidates(left, right) {
122
+ const leftPriority = this.rankMainRepairCandidate(left);
123
+ const rightPriority = this.rankMainRepairCandidate(right);
124
+ if (leftPriority !== rightPriority)
125
+ return leftPriority - rightPriority;
126
+ return Date.parse(right.updatedAt) - Date.parse(left.updatedAt);
127
+ }
128
+ rankMainRepairCandidate(issue) {
129
+ if (issue.activeRunId !== undefined)
130
+ return 0;
131
+ if (issue.prState === "open" || issue.factoryState === "awaiting_queue" || issue.factoryState === "pr_open")
132
+ return 1;
133
+ if (issue.factoryState === "delegated" || issue.factoryState === "implementing")
134
+ return 2;
135
+ if (issue.factoryState === "failed" || issue.factoryState === "escalated")
136
+ return 3;
137
+ return 4;
138
+ }
117
139
  queueExistingMainRepair(issue, summary, priorityLabel) {
118
140
  if (issue.activeRunId !== undefined)
119
141
  return;
@@ -121,6 +143,15 @@ export class MainBranchHealthMonitor {
121
143
  return;
122
144
  if (issue.prState === "open" || issue.factoryState === "awaiting_queue" || issue.factoryState === "pr_open")
123
145
  return;
146
+ this.db.upsertIssue({
147
+ projectId: issue.projectId,
148
+ linearIssueId: issue.linearIssueId,
149
+ delegatedToPatchRelay: true,
150
+ factoryState: "delegated",
151
+ pendingRunType: null,
152
+ pendingRunContextJson: null,
153
+ activeRunId: null,
154
+ });
124
155
  this.db.issueSessions.appendIssueSessionEventRespectingActiveLease(issue.projectId, issue.linearIssueId, {
125
156
  projectId: issue.projectId,
126
157
  linearIssueId: issue.linearIssueId,
@@ -131,6 +162,7 @@ export class MainBranchHealthMonitor {
131
162
  failingChecks: summary.failingChecks,
132
163
  pendingChecks: summary.pendingChecks,
133
164
  priorityLabel,
165
+ promptContext: buildMainRepairPromptContext(this.config.projects.find((project) => project.id === issue.projectId) ?? { id: issue.projectId }, summary, priorityLabel),
134
166
  }),
135
167
  dedupeKey: `main_repair:${issue.projectId}:${summary.baseSha}:${summary.failingChecks.map((check) => check.name).join("|")}`,
136
168
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchrelay",
3
- "version": "0.52.3",
3
+ "version": "0.52.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {