patchrelay 0.46.1 → 0.47.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.
- package/dist/build-info.json +3 -3
- package/dist/cli/cluster-health.js +4 -2
- package/dist/cli/watch/issue-token.js +22 -0
- package/dist/db/migrations.js +7 -0
- package/dist/db.js +1 -0
- package/dist/issue-session-projector.js +5 -4
- package/dist/tracked-issue-list-query.js +5 -4
- package/package.json +1 -1
package/dist/build-info.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { deriveGateCheckStatusFromRollup } from "../github-rollup.js";
|
|
2
2
|
import { ACTIVE_RUN_STATES } from "../factory-state.js";
|
|
3
|
+
import { isUndelegatedPausedNoPrWork } from "../paused-issue-state.js";
|
|
3
4
|
import { hasOpenPr, resolveClosedPrDisposition } from "../pr-state.js";
|
|
4
5
|
const RECONCILIATION_GRACE_MS = 120_000;
|
|
5
6
|
const DOWNSTREAM_STALE_MS = 900_000;
|
|
@@ -166,6 +167,7 @@ export async function collectClusterHealth(config, db, runCommand) {
|
|
|
166
167
|
}
|
|
167
168
|
function evaluateLocalIssueHealth(snapshot) {
|
|
168
169
|
const { issue, session, missingTrackedBlockers, blockedBy, ageMs, readyForExecution } = snapshot;
|
|
170
|
+
const pausedNoPrWork = isUndelegatedPausedNoPrWork(issue);
|
|
169
171
|
if (issue.factoryState === "failed" || issue.factoryState === "escalated") {
|
|
170
172
|
return {
|
|
171
173
|
status: "fail",
|
|
@@ -204,14 +206,14 @@ function evaluateLocalIssueHealth(snapshot) {
|
|
|
204
206
|
message: "Issue is ready for execution but no active run has started",
|
|
205
207
|
};
|
|
206
208
|
}
|
|
207
|
-
if (ACTIVE_RUN_STATES.has(issue.factoryState) && issue.activeRunId === undefined && ageMs >= RECONCILIATION_GRACE_MS) {
|
|
209
|
+
if (!pausedNoPrWork && ACTIVE_RUN_STATES.has(issue.factoryState) && issue.activeRunId === undefined && ageMs >= RECONCILIATION_GRACE_MS) {
|
|
208
210
|
return {
|
|
209
211
|
status: "fail",
|
|
210
212
|
scope: "issue:dispatch",
|
|
211
213
|
message: `Issue is parked in ${issue.factoryState} without an active run`,
|
|
212
214
|
};
|
|
213
215
|
}
|
|
214
|
-
if (issue.factoryState === "delegated" && issue.activeRunId === undefined && !readyForExecution && ageMs >= RECONCILIATION_GRACE_MS) {
|
|
216
|
+
if (!pausedNoPrWork && issue.factoryState === "delegated" && issue.activeRunId === undefined && !readyForExecution && ageMs >= RECONCILIATION_GRACE_MS) {
|
|
215
217
|
return {
|
|
216
218
|
status: "fail",
|
|
217
219
|
scope: "issue:dispatch",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isUndelegatedPausedIssue } from "../../paused-issue-state.js";
|
|
1
2
|
const GLYPH = {
|
|
2
3
|
running: "\u25cf",
|
|
3
4
|
queued: "\u25cb",
|
|
@@ -13,6 +14,9 @@ const COLOR = {
|
|
|
13
14
|
attention: "red",
|
|
14
15
|
};
|
|
15
16
|
export function issueTokenFor(issue) {
|
|
17
|
+
if (isUndelegatedPausedIssue(issue)) {
|
|
18
|
+
return { glyph: GLYPH.queued, color: COLOR.queued, kind: "queued", phrase: phraseForPaused(issue) };
|
|
19
|
+
}
|
|
16
20
|
if (issue.factoryState === "done") {
|
|
17
21
|
return { glyph: GLYPH.approved, color: COLOR.approved, kind: "approved", phrase: "done" };
|
|
18
22
|
}
|
|
@@ -53,6 +57,24 @@ function phraseForRunning(issue) {
|
|
|
53
57
|
return issue.factoryState;
|
|
54
58
|
}
|
|
55
59
|
}
|
|
60
|
+
function phraseForPaused(issue) {
|
|
61
|
+
switch (issue.factoryState) {
|
|
62
|
+
case "implementing":
|
|
63
|
+
return "paused impl";
|
|
64
|
+
case "pr_open":
|
|
65
|
+
return "paused pr";
|
|
66
|
+
case "changes_requested":
|
|
67
|
+
return "paused review";
|
|
68
|
+
case "repairing_ci":
|
|
69
|
+
return "paused ci";
|
|
70
|
+
case "awaiting_queue":
|
|
71
|
+
return "paused queue";
|
|
72
|
+
case "repairing_queue":
|
|
73
|
+
return "paused merge";
|
|
74
|
+
default:
|
|
75
|
+
return "paused";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
56
78
|
export function prTokenFor(issue) {
|
|
57
79
|
if (issue.prNumber === undefined)
|
|
58
80
|
return null;
|
package/dist/db/migrations.js
CHANGED
|
@@ -87,6 +87,7 @@ CREATE TABLE IF NOT EXISTS issue_sessions (
|
|
|
87
87
|
worker_id TEXT,
|
|
88
88
|
leased_until TEXT,
|
|
89
89
|
created_at TEXT NOT NULL,
|
|
90
|
+
display_updated_at TEXT NOT NULL,
|
|
90
91
|
updated_at TEXT NOT NULL,
|
|
91
92
|
UNIQUE(project_id, linear_issue_id)
|
|
92
93
|
);
|
|
@@ -249,6 +250,12 @@ export function runPatchRelayMigrations(connection) {
|
|
|
249
250
|
addColumnIfMissing(connection, "issues", "review_fix_attempts", "INTEGER NOT NULL DEFAULT 0");
|
|
250
251
|
// Preserve the PR head SHA seen when a run started so PatchRelay can
|
|
251
252
|
// verify that requested-changes work actually published a new head.
|
|
253
|
+
addColumnIfMissing(connection, "issue_sessions", "display_updated_at", "TEXT");
|
|
254
|
+
connection.prepare(`
|
|
255
|
+
UPDATE issue_sessions
|
|
256
|
+
SET display_updated_at = COALESCE(display_updated_at, updated_at, created_at)
|
|
257
|
+
WHERE display_updated_at IS NULL
|
|
258
|
+
`).run();
|
|
252
259
|
addColumnIfMissing(connection, "runs", "source_head_sha", "TEXT");
|
|
253
260
|
addColumnIfMissing(connection, "runs", "completion_check_thread_id", "TEXT");
|
|
254
261
|
addColumnIfMissing(connection, "runs", "completion_check_turn_id", "TEXT");
|
package/dist/db.js
CHANGED
|
@@ -236,6 +236,7 @@ function mapIssueSessionRow(row) {
|
|
|
236
236
|
...(row.worker_id !== null && row.worker_id !== undefined ? { workerId: String(row.worker_id) } : {}),
|
|
237
237
|
...(row.leased_until !== null && row.leased_until !== undefined ? { leasedUntil: String(row.leased_until) } : {}),
|
|
238
238
|
createdAt: String(row.created_at),
|
|
239
|
+
displayUpdatedAt: String(row.display_updated_at ?? row.updated_at),
|
|
239
240
|
updatedAt: String(row.updated_at),
|
|
240
241
|
};
|
|
241
242
|
}
|
|
@@ -58,9 +58,10 @@ export function syncIssueSessionFromIssue(params) {
|
|
|
58
58
|
ci_repair_attempts = ?,
|
|
59
59
|
queue_repair_attempts = ?,
|
|
60
60
|
review_fix_attempts = ?,
|
|
61
|
+
display_updated_at = ?,
|
|
61
62
|
updated_at = ?
|
|
62
63
|
WHERE project_id = ? AND linear_issue_id = ?
|
|
63
|
-
`).run(issue.issueKey ?? null, issue.projectId, issue.branchName ?? null, issue.worktreePath ?? null, issue.prNumber ?? null, issue.prHeadSha ?? null, issue.prAuthorLogin ?? null, sessionState, tracked.waitingReason ?? null, summaryText ?? null, activeThreadId ?? null, threadGeneration, issue.activeRunId ?? null, latestRunType ?? null, lastWakeReason ?? null, issue.ciRepairAttempts, issue.queueRepairAttempts, issue.reviewFixAttempts, now, issue.projectId, issue.linearIssueId);
|
|
64
|
+
`).run(issue.issueKey ?? null, issue.projectId, issue.branchName ?? null, issue.worktreePath ?? null, issue.prNumber ?? null, issue.prHeadSha ?? null, issue.prAuthorLogin ?? null, sessionState, tracked.waitingReason ?? null, summaryText ?? null, activeThreadId ?? null, threadGeneration, issue.activeRunId ?? null, latestRunType ?? null, lastWakeReason ?? null, issue.ciRepairAttempts, issue.queueRepairAttempts, issue.reviewFixAttempts, now, now, issue.projectId, issue.linearIssueId);
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
67
|
connection.prepare(`
|
|
@@ -69,9 +70,9 @@ export function syncIssueSessionFromIssue(params) {
|
|
|
69
70
|
pr_number, pr_head_sha, pr_author_login, session_state, waiting_reason, summary_text,
|
|
70
71
|
active_thread_id, thread_generation, active_run_id, last_run_type, last_wake_reason,
|
|
71
72
|
ci_repair_attempts, queue_repair_attempts, review_fix_attempts,
|
|
72
|
-
created_at, updated_at
|
|
73
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
74
|
-
`).run(issue.projectId, issue.linearIssueId, issue.issueKey ?? null, issue.projectId, issue.branchName ?? null, issue.worktreePath ?? null, issue.prNumber ?? null, issue.prHeadSha ?? null, issue.prAuthorLogin ?? null, sessionState, tracked.waitingReason ?? null, summaryText ?? null, activeThreadId ?? null, threadGeneration, issue.activeRunId ?? null, latestRunType ?? null, lastWakeReason ?? null, issue.ciRepairAttempts, issue.queueRepairAttempts, issue.reviewFixAttempts, now, now);
|
|
73
|
+
created_at, display_updated_at, updated_at
|
|
74
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
75
|
+
`).run(issue.projectId, issue.linearIssueId, issue.issueKey ?? null, issue.projectId, issue.branchName ?? null, issue.worktreePath ?? null, issue.prNumber ?? null, issue.prHeadSha ?? null, issue.prAuthorLogin ?? null, sessionState, tracked.waitingReason ?? null, summaryText ?? null, activeThreadId ?? null, threadGeneration, issue.activeRunId ?? null, latestRunType ?? null, lastWakeReason ?? null, issue.ciRepairAttempts, issue.queueRepairAttempts, issue.reviewFixAttempts, now, now, now);
|
|
75
76
|
}
|
|
76
77
|
function resolveIssueSessionSummary(issue, runs, latestRun, existingSummaryText, explicitSummaryText) {
|
|
77
78
|
if (explicitSummaryText?.trim()) {
|
|
@@ -80,7 +80,7 @@ export class TrackedIssueListQuery {
|
|
|
80
80
|
const rows = this.db.connection
|
|
81
81
|
.prepare(`SELECT
|
|
82
82
|
s.project_id, s.linear_issue_id, s.issue_key, i.title,
|
|
83
|
-
i.current_linear_state, i.factory_state, i.delegated_to_patchrelay, s.session_state, s.waiting_reason, s.summary_text, s.
|
|
83
|
+
i.current_linear_state, i.factory_state, i.delegated_to_patchrelay, s.session_state, s.waiting_reason, s.summary_text, s.display_updated_at,
|
|
84
84
|
i.pending_run_type,
|
|
85
85
|
i.pr_number, i.pr_state, i.pr_head_sha, i.pr_review_state, i.pr_check_status, i.last_blocking_review_head_sha,
|
|
86
86
|
i.last_github_ci_snapshot_json,
|
|
@@ -144,7 +144,7 @@ export class TrackedIssueListQuery {
|
|
|
144
144
|
WHERE r.project_id = s.project_id AND r.linear_issue_id = s.linear_issue_id
|
|
145
145
|
ORDER BY r.id DESC LIMIT 1
|
|
146
146
|
)
|
|
147
|
-
ORDER BY s.
|
|
147
|
+
ORDER BY s.display_updated_at DESC, s.issue_key ASC`)
|
|
148
148
|
.all();
|
|
149
149
|
return rows.map((row) => {
|
|
150
150
|
const failureContext = parseGitHubFailureContext(typeof row.last_github_failure_context_json === "string" ? row.last_github_failure_context_json : undefined);
|
|
@@ -205,7 +205,7 @@ export class TrackedIssueListQuery {
|
|
|
205
205
|
...(typeof row.latest_run_completion_check_question === "string" ? { completionCheckQuestion: row.latest_run_completion_check_question } : {}),
|
|
206
206
|
...(typeof row.latest_run_completion_check_why === "string" ? { completionCheckWhy: row.latest_run_completion_check_why } : {}),
|
|
207
207
|
...(typeof row.latest_run_completion_check_recommended_reply === "string" ? { completionCheckRecommendedReply: row.latest_run_completion_check_recommended_reply } : {}),
|
|
208
|
-
startedAt: String(row.
|
|
208
|
+
startedAt: String(row.display_updated_at),
|
|
209
209
|
}
|
|
210
210
|
: undefined;
|
|
211
211
|
const latestEvent = this.db.issueSessions.listIssueSessionEvents(String(row.project_id), String(row.linear_issue_id), { limit: 1 }).at(-1);
|
|
@@ -234,6 +234,7 @@ export class TrackedIssueListQuery {
|
|
|
234
234
|
...(row.title !== null ? { title: String(row.title) } : {}),
|
|
235
235
|
...(statusNoteForReturn ? { statusNote: statusNoteForReturn } : {}),
|
|
236
236
|
projectId: String(row.project_id),
|
|
237
|
+
delegatedToPatchRelay: row.delegated_to_patchrelay === null ? true : Number(row.delegated_to_patchrelay) !== 0,
|
|
237
238
|
...(row.session_state !== null ? { sessionState: String(row.session_state) } : {}),
|
|
238
239
|
factoryState: String(row.factory_state ?? "delegated"),
|
|
239
240
|
blockedByCount,
|
|
@@ -256,7 +257,7 @@ export class TrackedIssueListQuery {
|
|
|
256
257
|
...(failureContext?.summary ? { latestFailureSummary: failureContext.summary } : {}),
|
|
257
258
|
...(waitingReason ? { waitingReason } : {}),
|
|
258
259
|
...(completionCheckActive ? { completionCheckActive } : {}),
|
|
259
|
-
updatedAt: String(row.
|
|
260
|
+
updatedAt: String(row.display_updated_at),
|
|
260
261
|
};
|
|
261
262
|
});
|
|
262
263
|
}
|