spur-board 0.19.0 → 0.20.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/daemon.mjs +31 -7
- package/package.json +1 -1
package/dist/daemon.mjs
CHANGED
|
@@ -11484,6 +11484,11 @@ async function reconcileMembership(trx, config, completeSince, at) {
|
|
|
11484
11484
|
}
|
|
11485
11485
|
//#endregion
|
|
11486
11486
|
//#region ../core/src/domain/health.ts
|
|
11487
|
+
const ENDED_WORKER_KINDS = {
|
|
11488
|
+
complete: "worker_completed",
|
|
11489
|
+
kill: "worker_killed",
|
|
11490
|
+
vanished: "worker_vanished"
|
|
11491
|
+
};
|
|
11487
11492
|
/** Derive actionable health facts without reading the clock or mutating input. */
|
|
11488
11493
|
function evaluateSessionHealth(input) {
|
|
11489
11494
|
const { sessions, tasks, spur, config, now } = input;
|
|
@@ -11530,7 +11535,7 @@ function evaluateSessionHealth(input) {
|
|
|
11530
11535
|
const flag = {
|
|
11531
11536
|
taskId: session.taskId,
|
|
11532
11537
|
sessionId: session.id,
|
|
11533
|
-
kind:
|
|
11538
|
+
kind: ENDED_WORKER_KINDS[session.endReason]
|
|
11534
11539
|
};
|
|
11535
11540
|
(spur.observationComplete ? flags : held).push(flag);
|
|
11536
11541
|
}
|
|
@@ -11567,6 +11572,11 @@ function evaluateSessionHealth(input) {
|
|
|
11567
11572
|
//#endregion
|
|
11568
11573
|
//#region ../core/src/app/fromYou.ts
|
|
11569
11574
|
const episodeSchema = z.object({ startedAt: z.number() }).nullable();
|
|
11575
|
+
const ENDED_WORKER_LABELS = {
|
|
11576
|
+
worker_completed: "worker ended (completed), no PR",
|
|
11577
|
+
worker_killed: "worker ended (killed), no PR",
|
|
11578
|
+
worker_vanished: "worker vanished, no PR"
|
|
11579
|
+
};
|
|
11570
11580
|
/** Reconciles every item in the caller's observation or tick transaction. */
|
|
11571
11581
|
async function reconcileItems(trx, config, now, spurComplete) {
|
|
11572
11582
|
const candidates = [];
|
|
@@ -11712,14 +11722,16 @@ async function reconcileItems(trx, config, now, spurComplete) {
|
|
|
11712
11722
|
const task = taskById.get(Number(flag.taskId));
|
|
11713
11723
|
if (task === void 0) continue;
|
|
11714
11724
|
const fact = subjects.find((subject) => subject.taskId === flag.taskId && subject.id === flag.sessionId);
|
|
11725
|
+
const endedLabel = ENDED_WORKER_LABELS[flag.kind];
|
|
11715
11726
|
candidates.push({
|
|
11716
11727
|
key: healthKey(task.id, flag),
|
|
11717
11728
|
taskId: task.id,
|
|
11718
|
-
summary: `${task.key}: ${flag.kind.replaceAll("_", " ")} (${flag.sessionId})`,
|
|
11729
|
+
summary: `${task.key}: ${endedLabel ?? flag.kind.replaceAll("_", " ")} (${flag.sessionId})`,
|
|
11719
11730
|
factAt: fact?.healthSince ?? null,
|
|
11720
11731
|
source: "spur",
|
|
11721
11732
|
priority: 4,
|
|
11722
|
-
revision:
|
|
11733
|
+
revision: endedLabel === void 0 ? fact?.healthSince ?? null : fact?.endedAt ?? null,
|
|
11734
|
+
suppressFeed: flag.kind === "worker_completed" || flag.kind === "worker_killed"
|
|
11723
11735
|
});
|
|
11724
11736
|
}
|
|
11725
11737
|
const ordered = orderItems(candidates);
|
|
@@ -12095,9 +12107,16 @@ async function session(trx, config, fact, at, source, ambiguousBranches) {
|
|
|
12095
12107
|
role = label === "board-worker" ? "worker" : "other";
|
|
12096
12108
|
if (key !== void 0) break;
|
|
12097
12109
|
}
|
|
12110
|
+
let prOnlyKey;
|
|
12098
12111
|
if (key === void 0 && fact.pr !== null) {
|
|
12099
|
-
const linked = await trx.selectFrom("link").innerJoin("task", "task.id", "link.task_id").
|
|
12100
|
-
|
|
12112
|
+
const linked = await trx.selectFrom("link").innerJoin("task", "task.id", "link.task_id").leftJoin("pr_snapshot", (join) => join.on(sql`lower(pr_snapshot.repo) = lower(link.repo)`).onRef("pr_snapshot.number", "=", "link.number")).select([
|
|
12113
|
+
"task.key",
|
|
12114
|
+
"task.project",
|
|
12115
|
+
"pr_snapshot.head_branch"
|
|
12116
|
+
]).where("link.entity", "=", "pr").where(sql`lower(link.repo) = ${fact.pr.repo.toLowerCase()}`).where("link.number", "=", fact.pr.number).where("link.banned", "=", 0).executeTakeFirst();
|
|
12117
|
+
const project = config.projects.find((entry) => entry.id === linked?.project);
|
|
12118
|
+
if (linked !== void 0 && project?.spurProjects.some((spur) => spur.name === fact.spurProject && spur.role === "worker")) if (fact.branch !== null && linked.head_branch === fact.branch) key = linked.key;
|
|
12119
|
+
else prOnlyKey = linked.key;
|
|
12101
12120
|
}
|
|
12102
12121
|
if (key === void 0 && fact.branch !== null) {
|
|
12103
12122
|
const tasks = await trx.selectFrom("task").selectAll().where("membership", "!=", "archived").execute();
|
|
@@ -12111,6 +12130,11 @@ async function session(trx, config, fact, at, source, ambiguousBranches) {
|
|
|
12111
12130
|
if (!ambiguousBranches.has(fact.branch) || worker !== void 0) key = candidate?.key;
|
|
12112
12131
|
}
|
|
12113
12132
|
}
|
|
12133
|
+
const fromLabel = role !== void 0;
|
|
12134
|
+
if (key === void 0 && prOnlyKey !== void 0) {
|
|
12135
|
+
key = prOnlyKey;
|
|
12136
|
+
role = "other";
|
|
12137
|
+
}
|
|
12114
12138
|
if (key !== void 0 && projectForKey(config, key) !== null) {
|
|
12115
12139
|
const task = await trx.selectFrom("task").selectAll().where("key", "=", key).executeTakeFirst();
|
|
12116
12140
|
if (task !== void 0) {
|
|
@@ -12125,7 +12149,7 @@ async function session(trx, config, fact, at, source, ambiguousBranches) {
|
|
|
12125
12149
|
pr_state: null,
|
|
12126
12150
|
session_id: fact.id,
|
|
12127
12151
|
role: chosenRole,
|
|
12128
|
-
source:
|
|
12152
|
+
source: fromLabel ? "spawn_link" : "branch",
|
|
12129
12153
|
banned: 0,
|
|
12130
12154
|
created_at: at,
|
|
12131
12155
|
ticket_key: null,
|
|
@@ -12135,7 +12159,7 @@ async function session(trx, config, fact, at, source, ambiguousBranches) {
|
|
|
12135
12159
|
entity: "session",
|
|
12136
12160
|
session: fact.id,
|
|
12137
12161
|
role: chosenRole,
|
|
12138
|
-
source:
|
|
12162
|
+
source: fromLabel ? "spawn_link" : "branch",
|
|
12139
12163
|
facts: fact
|
|
12140
12164
|
});
|
|
12141
12165
|
}
|