spur-board 0.68.0 → 0.70.0
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/{chunk-C11wvkRU.mjs → chunk-BBfFVeh3.mjs} +412 -58
- package/dist/{chunk-t6u2F3E-.mjs → chunk-BxDheuT8.mjs} +1 -1
- package/dist/{chunk-AwNJBvcj.mjs → chunk-CmoLxaIV.mjs} +2 -2
- package/dist/cli.mjs +4 -4
- package/dist/client.mjs +1 -1
- package/dist/daemon.mjs +294 -66
- package/dist/mcp.mjs +3 -3
- package/package.json +1 -1
- package/skills/spur-board/references/how-board-works.md +16 -6
package/dist/daemon.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as err, A as prSourceId, B as prFactsSchema, C as userIdSchema, D as AdapterError, E as eventPayloadSchemas, F as REVIEW_STATES, G as JIRA_PROJECT_KEY, H as ringMarker, I as SESSION_HEALTH_STATES, J as encodeActorId, K as REF_NUMBER, L as SESSION_STATUSES, M as sourceCursorSchema, N as trackerSourceId, O as batchSchema, P as PR_STATES, Q as ERRORS, R as isExternalAuthor, S as messageRefSchema, T as GATE_REASONS, U as sessionFactsSchema, V as prRefSchema, W as ticketFactsSchema, X as parseActorId, Y as errorCodeOf, Z as parseRef$1, a as requestHashOf, at as DEFAULT_LINK, b as inboundEventSchema, c as tokenRequestStatusSchema, ct as RESERVED_PROJECT, d as buildCatalogSnapshot, dt as
|
|
1
|
+
import { $ as err, A as prSourceId, B as prFactsSchema, C as userIdSchema, D as AdapterError, E as eventPayloadSchemas, F as REVIEW_STATES, G as JIRA_PROJECT_KEY, H as ringMarker, I as SESSION_HEALTH_STATES, J as encodeActorId, K as REF_NUMBER, L as SESSION_STATUSES, M as sourceCursorSchema, N as trackerSourceId, O as batchSchema, P as PR_STATES, Q as ERRORS, R as isExternalAuthor, S as messageRefSchema, T as GATE_REASONS, U as sessionFactsSchema, V as prRefSchema, W as ticketFactsSchema, X as parseActorId, Y as errorCodeOf, Z as parseRef$1, _t as SLACK_BOT_SCOPES, a as requestHashOf, at as DEFAULT_LINK, b as inboundEventSchema, c as tokenRequestStatusSchema, ct as RESERVED_PROJECT, d as buildCatalogSnapshot, dt as configSchema, f as roleCanUseOperation, ft as defaultAddressee, gt as DISPATCHER_MODES, h as renderHttpProblem, ht as COLUMN_IDS, i as TOKEN_REQUEST_LIMITS, j as sessionTransitionSchema, k as entityRefSchema, l as BOARD_TICK_MS, lt as boardWideSpurProject, m as turnHandedSchema, mt as requiredSecretKeys, n as doctorReportSchema, nt as ok, o as tokenRequestResultSchema, p as OPERATIONS, pt as plainHttpAllowed, q as actorIdSchema, rt as successEnvelopeSchema, s as tokenRequestSchema, st as DEFAULT_SLACK_COMMAND, t as assertNever, ut as configBindings, v as SPACE_IDS, vt as TASK_HOLDS, w as EVENT_KINDS, x as interactionRefSchema, y as conversationRefSchema, z as parseRingMarker } from "./chunk-BBfFVeh3.mjs";
|
|
2
2
|
import { t as apiBaseUrl } from "./chunk-DAMwWWmT.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -496,11 +496,24 @@ function projectTarget(project) {
|
|
|
496
496
|
}
|
|
497
497
|
};
|
|
498
498
|
}
|
|
499
|
-
/**
|
|
500
|
-
|
|
499
|
+
/**
|
|
500
|
+
* True for the operator token and for a session of an operator Spur project. Without a
|
|
501
|
+
* board-wide operator, every operator Spur project acts on every board project, as before
|
|
502
|
+
* top-level `spurProjects`. With one, a session acts as operator on `project` only when that
|
|
503
|
+
* project lists its Spur project as operator, and on no project (`null`) only for the
|
|
504
|
+
* board-wide operator.
|
|
505
|
+
*/
|
|
506
|
+
function isOperator(actor, config, project) {
|
|
501
507
|
if (actor === "operator") return true;
|
|
502
508
|
const parsed = parseActorId(actor);
|
|
503
|
-
|
|
509
|
+
if (parsed?.actor !== "agent") return false;
|
|
510
|
+
const name = parsed.actorRef.project;
|
|
511
|
+
const operatorIn = (entry) => entry.spurProjects.some((spur) => spur.name === name && spur.role === "operator");
|
|
512
|
+
const boardWide = config.spurProjects.find((entry) => entry.role === "operator");
|
|
513
|
+
if (boardWide === void 0) return config.projects.some(operatorIn);
|
|
514
|
+
if (project === null) return name === boardWide.name;
|
|
515
|
+
const target = config.projects.find((entry) => entry.id === project);
|
|
516
|
+
return target !== void 0 && operatorIn(target);
|
|
504
517
|
}
|
|
505
518
|
/** The Spur project that curates one board project, or null when it has none. */
|
|
506
519
|
function curatorProject(config, projectId) {
|
|
@@ -512,7 +525,7 @@ function worker(actor, target) {
|
|
|
512
525
|
}
|
|
513
526
|
function orchestrator$1(actor, target, config, column) {
|
|
514
527
|
const configured = config.projects.find((entry) => entry.id === target.project)?.columns.find((entry) => entry.id === column)?.orchestrator;
|
|
515
|
-
if (configured === "operator") return isOperator(actor, config);
|
|
528
|
+
if (configured === "operator") return isOperator(actor, config, target.project);
|
|
516
529
|
const parsed = parseActorId(actor);
|
|
517
530
|
return parsed?.actor === "agent" && configured !== "none" && configured === parsed.actorRef.project;
|
|
518
531
|
}
|
|
@@ -537,7 +550,7 @@ function blockAuthor(actor, target, config) {
|
|
|
537
550
|
function matches(rule, actor, target, config) {
|
|
538
551
|
const parsed = parseActorId(actor);
|
|
539
552
|
switch (rule.grant) {
|
|
540
|
-
case "operator": return isOperator(actor, config);
|
|
553
|
+
case "operator": return isOperator(actor, config, target.project);
|
|
541
554
|
case "project-agent": return parsed?.actor === "agent" && config.projects.find((project) => project.id === target.project)?.spurProjects.some((spur) => spur.name === parsed.actorRef.project) === true;
|
|
542
555
|
case "task-worker": return worker(actor, target);
|
|
543
556
|
case "column-orchestrator": return target.task !== null && orchestrator$1(actor, target, config, target.task.column);
|
|
@@ -547,7 +560,7 @@ function matches(rule, actor, target, config) {
|
|
|
547
560
|
if (spur !== null) return parsed?.actor === "agent" && parsed.actorRef.project === spur;
|
|
548
561
|
const addressee = parseAddressee(target.block.addressee_role);
|
|
549
562
|
switch (addressee.kind) {
|
|
550
|
-
case "operator": return isOperator(actor, config);
|
|
563
|
+
case "operator": return isOperator(actor, config, target.project);
|
|
551
564
|
case "curator": return parsed?.actor === "agent" && parsed.actorRef.project === curatorProject(config, target.project);
|
|
552
565
|
case "worker": return worker(actor, target);
|
|
553
566
|
case "orchestrator": return orchestrator$1(actor, target, config, addressee.column);
|
|
@@ -563,7 +576,7 @@ function authorize(grants, actor, state) {
|
|
|
563
576
|
const rules = grants.filter((rule) => rule.mode === void 0 || rule.mode === state.mode);
|
|
564
577
|
const hint = `Allowed role: ${[...new Set(rules.map((rule) => rule.grant))].join(", ") || "none"}.`;
|
|
565
578
|
if (state.target.kind === "missing") {
|
|
566
|
-
if (rules.some((rule) => rule.grant === "operator" && isOperator(actor, state.config))) return { status: "allowed" };
|
|
579
|
+
if (rules.some((rule) => rule.grant === "operator" && isOperator(actor, state.config, null))) return { status: "allowed" };
|
|
567
580
|
return rules.every((rule) => rule.grant === "operator") ? {
|
|
568
581
|
status: "denied",
|
|
569
582
|
hint
|
|
@@ -8218,6 +8231,38 @@ async function moveViews(db, taskId, options) {
|
|
|
8218
8231
|
const query = db.selectFrom("event").selectAll().where("task_id", "=", taskId).where("kind", "in", MOVE_KINDS);
|
|
8219
8232
|
return ("after" in options ? await query.where("id", ">", options.after).orderBy("id").execute() : (await query.orderBy("id", "desc").limit(options.limit).execute()).reverse()).flatMap((row) => moveView(row) ?? []);
|
|
8220
8233
|
}
|
|
8234
|
+
/**
|
|
8235
|
+
* The return that opened the visit `turn` belongs to, or undefined. A `task.return` closes the
|
|
8236
|
+
* returned turn of the current visit and bumps the column epoch, so the visit it opens is the one
|
|
8237
|
+
* at the next epoch in the column it moved to. Read from ids and epochs, never from `at`: a later
|
|
8238
|
+
* move cannot add or remove it. The reason is the code block's current reason.
|
|
8239
|
+
*/
|
|
8240
|
+
async function turnReturn(db, turn) {
|
|
8241
|
+
const previous = await db.selectFrom("turn").select("id").where("task_id", "=", turn.task_id).where("epoch", "=", turn.epoch - 1).execute();
|
|
8242
|
+
if (previous.length === 0) return void 0;
|
|
8243
|
+
const labels = new Set(previous.map((row) => `T${String(row.id)}`));
|
|
8244
|
+
const moves = await db.selectFrom("event").select([
|
|
8245
|
+
"actor",
|
|
8246
|
+
"actor_ref",
|
|
8247
|
+
"payload"
|
|
8248
|
+
]).where("task_id", "=", turn.task_id).where("kind", "=", "task_moved").orderBy("id", "desc").execute();
|
|
8249
|
+
for (const row of moves) {
|
|
8250
|
+
const parsed = eventPayloadSchemas.task_moved.safeParse(JSON.parse(row.payload));
|
|
8251
|
+
if (!parsed.success) continue;
|
|
8252
|
+
const { from, to, turn: returned, block } = parsed.data;
|
|
8253
|
+
if (returned === void 0 || block === void 0 || to !== turn.column) continue;
|
|
8254
|
+
if (!labels.has(returned) || !/^B\d+$/.test(block)) continue;
|
|
8255
|
+
const opened = await db.selectFrom("block").select("reason").where("id", "=", Number(block.slice(1))).where("task_id", "=", turn.task_id).executeTakeFirst();
|
|
8256
|
+
if (opened === void 0) return void 0;
|
|
8257
|
+
return {
|
|
8258
|
+
by: eventActor(row),
|
|
8259
|
+
from,
|
|
8260
|
+
turn: returned,
|
|
8261
|
+
block,
|
|
8262
|
+
reason: opened.reason
|
|
8263
|
+
};
|
|
8264
|
+
}
|
|
8265
|
+
}
|
|
8221
8266
|
function taskView(task) {
|
|
8222
8267
|
return {
|
|
8223
8268
|
key: task.key,
|
|
@@ -9529,9 +9574,8 @@ function orchestrator(config, task) {
|
|
|
9529
9574
|
* column, an agent is the curator or a worker.
|
|
9530
9575
|
*/
|
|
9531
9576
|
function authorRole(config, subject, actor) {
|
|
9532
|
-
if (actor
|
|
9577
|
+
if (isOperator(actor, config, subject.project)) return "operator";
|
|
9533
9578
|
const parsed = parseActorId(actor);
|
|
9534
|
-
if (parsed?.actor === "agent" && config.projects.some((project) => project.spurProjects.some((spur) => spur.name === parsed.actorRef.project && spur.role === "operator"))) return "operator";
|
|
9535
9579
|
if (parsed?.actor !== "agent") return "worker";
|
|
9536
9580
|
const { task } = subject;
|
|
9537
9581
|
if (task !== null && parsed.actorRef.project === orchestrator(config, task)) return `orchestrator:${task.column}`;
|
|
@@ -9679,7 +9723,7 @@ function feedTime(at, config, date = false) {
|
|
|
9679
9723
|
}
|
|
9680
9724
|
/** Who acted, for a non-system actor: an agent by its session, else the operator's mention. */
|
|
9681
9725
|
function actorInline(by, parsed, config) {
|
|
9682
|
-
return parsed.actor === "agent" && !isOperator(by, config) ? {
|
|
9726
|
+
return parsed.actor === "agent" && !isOperator(by, config, null) ? {
|
|
9683
9727
|
kind: "text",
|
|
9684
9728
|
text: `${parsed.actorRef.project}/${parsed.actorRef.session}`
|
|
9685
9729
|
} : {
|
|
@@ -11030,7 +11074,7 @@ function sessionActor(project, session, config) {
|
|
|
11030
11074
|
if (!actor.success) throw new CommandError("forbidden", "Invalid session identity.");
|
|
11031
11075
|
const matches = config.projects.filter((entry) => entry.spurProjects.some((spur) => spur.name === project));
|
|
11032
11076
|
if (matches.length === 0) throw new CommandError("forbidden", `Spur project "${project}" is not listed in any spurProjects in the Board's config.yaml (not Spur's spur.yaml), and inside a Spur session a token is not used. Ask the operator to add it under projects[].spurProjects there and restart the Board daemon, or run the command outside a Spur session.`);
|
|
11033
|
-
if (matches.length > 1) throw new CommandError("forbidden", `Spur project "${project}" is listed under several Board projects: ${matches.map((entry) => entry.id).join(", ")}. Ask the operator to keep it under one of them in the Board's config.yaml (not Spur's spur.yaml) and restart the Board daemon.`);
|
|
11077
|
+
if (matches.length > 1 && boardWideSpurProject(config, project) === void 0) throw new CommandError("forbidden", `Spur project "${project}" is listed under several Board projects: ${matches.map((entry) => entry.id).join(", ")}. Ask the operator to keep it under one of them in the Board's config.yaml (not Spur's spur.yaml) and restart the Board daemon.`);
|
|
11034
11078
|
return actor.data;
|
|
11035
11079
|
}
|
|
11036
11080
|
/** Resolve the caller at the HTTP boundary; a session header always outranks a token. */
|
|
@@ -11550,14 +11594,19 @@ async function turnFeedbackCursors(db, prs, count) {
|
|
|
11550
11594
|
}
|
|
11551
11595
|
/**
|
|
11552
11596
|
* The feedback on `ref` that the turns `turnFeedbackCursors` leaves out of `handled` handed over,
|
|
11553
|
-
* oldest first and once each. A later poll may have dropped
|
|
11554
|
-
* and the poll cursor, which still counts those turns, never
|
|
11597
|
+
* oldest first and once each, as the copy with the newest edit. A later poll may have dropped
|
|
11598
|
+
* these entries from the PR snapshot, and the poll cursor, which still counts those turns, never
|
|
11599
|
+
* pages back to them.
|
|
11555
11600
|
*/
|
|
11556
11601
|
async function recalledFeedback(db, ref) {
|
|
11557
11602
|
const entries = [];
|
|
11558
11603
|
for (const row of await prTurns(db, [ref])) {
|
|
11559
11604
|
if (!isRecalled(row)) continue;
|
|
11560
|
-
for (const entry of handedOn(row, ref))
|
|
11605
|
+
for (const entry of handedOn(row, ref)) {
|
|
11606
|
+
const index = entries.findIndex((old) => sameHanded(old, entry));
|
|
11607
|
+
if (index === -1) entries.push(entry);
|
|
11608
|
+
else if (isNewerEdit(entry, entries[index])) entries[index] = entry;
|
|
11609
|
+
}
|
|
11561
11610
|
}
|
|
11562
11611
|
return (await withoutStatusComments(db, entries)).sort((left, right) => isNewer(left, right) ? 1 : -1);
|
|
11563
11612
|
}
|
|
@@ -11588,6 +11637,35 @@ async function withoutStatusComments(db, entries) {
|
|
|
11588
11637
|
}
|
|
11589
11638
|
return entries.filter((entry) => !flagged.some((old) => sameHanded(old, entry)));
|
|
11590
11639
|
}
|
|
11640
|
+
/** Whether `left` carries a newer edit than `right`. */
|
|
11641
|
+
function isNewerEdit(left, right) {
|
|
11642
|
+
if (left.editedAt === void 0) return false;
|
|
11643
|
+
return right.editedAt === void 0 || Date.parse(left.editedAt) > Date.parse(right.editedAt);
|
|
11644
|
+
}
|
|
11645
|
+
/**
|
|
11646
|
+
* The edit baseline of feedback on `ref`: an entry edited after it counts as unhandled again.
|
|
11647
|
+
* Over the turns `turnFeedbackCursors` counts as `handled`, each copy of the entry gives its
|
|
11648
|
+
* `editedAt`; else, with a `url`, no bound (this version handed it unedited, so any edit counts);
|
|
11649
|
+
* else its turn's `created_at` (handed before entries had either). The newest copy wins. An entry
|
|
11650
|
+
* no turn handed gets the earliest `created_at` of the turns that handed a newer entry, or none.
|
|
11651
|
+
*/
|
|
11652
|
+
async function editBaselines(db, ref) {
|
|
11653
|
+
const turns = (await prTurns(db, [ref])).filter((row) => !isRecalled(row)).map((row) => ({
|
|
11654
|
+
at: Date.parse(row.created_at),
|
|
11655
|
+
entries: handedOn(row, ref)
|
|
11656
|
+
}));
|
|
11657
|
+
return (entry) => {
|
|
11658
|
+
let base;
|
|
11659
|
+
for (const { at, entries } of turns) for (const copy of entries) {
|
|
11660
|
+
if (!sameHanded(copy, entry)) continue;
|
|
11661
|
+
const own = copy.editedAt !== void 0 ? Date.parse(copy.editedAt) : copy.url !== void 0 ? -Infinity : at;
|
|
11662
|
+
base = base === void 0 ? own : Math.max(base, own);
|
|
11663
|
+
}
|
|
11664
|
+
if (base !== void 0) return base;
|
|
11665
|
+
const newer = turns.filter(({ entries }) => entries.some((copy) => isNewer(copy, entry)));
|
|
11666
|
+
return Math.min(Infinity, ...newer.map(({ at }) => at));
|
|
11667
|
+
};
|
|
11668
|
+
}
|
|
11591
11669
|
/** Whether two handed entries are the same feedback on the same PR. */
|
|
11592
11670
|
function sameHanded(left, right) {
|
|
11593
11671
|
return left.repo.toLowerCase() === right.repo.toLowerCase() && left.number === right.number && left.kind === right.kind && left.id === right.id;
|
|
@@ -11599,7 +11677,8 @@ function prTurns(db, prs) {
|
|
|
11599
11677
|
"link.number",
|
|
11600
11678
|
"turn.handed",
|
|
11601
11679
|
"turn.acked_at",
|
|
11602
|
-
"turn.closed_reason"
|
|
11680
|
+
"turn.closed_reason",
|
|
11681
|
+
"turn.created_at"
|
|
11603
11682
|
]).where("link.entity", "=", "pr").where("link.banned", "=", 0).where(sql`lower(link.repo)`, "in", prs.map((pr) => pr.repo.toLowerCase())).execute();
|
|
11604
11683
|
}
|
|
11605
11684
|
/** Whether a correction or a reroute closed the turn before anyone took it. */
|
|
@@ -12636,8 +12715,15 @@ function createMembershipMutations(config) {
|
|
|
12636
12715
|
return {
|
|
12637
12716
|
add: {
|
|
12638
12717
|
id: "task.add",
|
|
12639
|
-
resolveTargets() {
|
|
12640
|
-
|
|
12718
|
+
async resolveTargets(trx, input) {
|
|
12719
|
+
let canonical;
|
|
12720
|
+
try {
|
|
12721
|
+
canonical = canonicalKey(config, input.task);
|
|
12722
|
+
} catch {
|
|
12723
|
+
return [];
|
|
12724
|
+
}
|
|
12725
|
+
const task = await trx.selectFrom("task").selectAll().where("project", "=", canonical.project.id).where("key", "=", canonical.key).executeTakeFirst();
|
|
12726
|
+
return task === void 0 ? [] : [await authorizationTarget(trx, task)];
|
|
12641
12727
|
},
|
|
12642
12728
|
async run(trx, input, ctx) {
|
|
12643
12729
|
const { project, key } = canonicalKey(config, input.task);
|
|
@@ -13477,6 +13563,20 @@ async function deliveryTask(trx, item) {
|
|
|
13477
13563
|
if (row.kind !== "doorbell") return void 0;
|
|
13478
13564
|
return ringTask(trx, typeof payload.notificationId === "number" ? payload.notificationId : void 0, row.dedupe_key);
|
|
13479
13565
|
}
|
|
13566
|
+
/** The task an item belongs to: its own, else its delivery's; undefined for a board item. */
|
|
13567
|
+
async function itemOwner(trx, item) {
|
|
13568
|
+
return item.task_id === null ? deliveryTask(trx, item) : trx.selectFrom("task").selectAll().where("id", "=", item.task_id).executeTakeFirst();
|
|
13569
|
+
}
|
|
13570
|
+
/**
|
|
13571
|
+
* An item of a task is that task's project's; a board item or an unknown ID has no target, so
|
|
13572
|
+
* only the board-wide operator or the token may act on it, and `run` raises the unknown ID.
|
|
13573
|
+
*/
|
|
13574
|
+
async function itemTarget(trx, input) {
|
|
13575
|
+
const item = await trx.selectFrom("operator_item").selectAll().where("id", "=", Number(input.item.slice(1))).executeTakeFirst();
|
|
13576
|
+
if (item === void 0) return [];
|
|
13577
|
+
const owner = await itemOwner(trx, item);
|
|
13578
|
+
return owner === void 0 ? [] : [await authorizationTarget(trx, owner)];
|
|
13579
|
+
}
|
|
13480
13580
|
function view(item, task) {
|
|
13481
13581
|
return { item: {
|
|
13482
13582
|
id: `I${String(item.id)}`,
|
|
@@ -13525,7 +13625,7 @@ function createItemMutations(deps) {
|
|
|
13525
13625
|
return {
|
|
13526
13626
|
retry: {
|
|
13527
13627
|
id: "item.retry",
|
|
13528
|
-
resolveTargets:
|
|
13628
|
+
resolveTargets: itemTarget,
|
|
13529
13629
|
async run(trx, input, ctx) {
|
|
13530
13630
|
const { item, task } = await loadItem(trx, input.item);
|
|
13531
13631
|
if ((task ?? await deliveryTask(trx, item))?.membership === "archived") throw new CommandError("task_archived", "Add the task again before retrying its item.");
|
|
@@ -13536,7 +13636,7 @@ function createItemMutations(deps) {
|
|
|
13536
13636
|
},
|
|
13537
13637
|
close: {
|
|
13538
13638
|
id: "item.close",
|
|
13539
|
-
resolveTargets:
|
|
13639
|
+
resolveTargets: itemTarget,
|
|
13540
13640
|
async run(trx, input, ctx) {
|
|
13541
13641
|
const { item, task } = await loadItem(trx, input.item);
|
|
13542
13642
|
if (item.cleared_at === null) {
|
|
@@ -13871,6 +13971,7 @@ async function getStatus(deps, options = {}) {
|
|
|
13871
13971
|
const { store, config, clock, completeSince, gateways = [] } = deps;
|
|
13872
13972
|
const { project: projectId, visibleProjects, detail = false } = options;
|
|
13873
13973
|
const includeBoardItems = options.includeBoardItems ?? visibleProjects === void 0;
|
|
13974
|
+
const operatorProjects = options.operatorProjects ?? /* @__PURE__ */ new Set();
|
|
13874
13975
|
const projects = projectId === void 0 ? config.projects.filter((project) => visibleProjects === void 0 || visibleProjects.has(project.id)) : config.projects.filter((project) => project.id === projectId && (visibleProjects === void 0 || visibleProjects.has(project.id)));
|
|
13875
13976
|
if (projects.length === 0) throw new CommandError("not_found", "Check the project ID.");
|
|
13876
13977
|
const projectIds = new Set(projects.map((project) => project.id));
|
|
@@ -14018,7 +14119,17 @@ async function getStatus(deps, options = {}) {
|
|
|
14018
14119
|
});
|
|
14019
14120
|
const itemRows = await store.db.selectFrom("operator_item").selectAll().where("cleared_at", "is", null).execute();
|
|
14020
14121
|
const itemTasks = new Map(rows.map((task) => [task.id, task]));
|
|
14021
|
-
const
|
|
14122
|
+
const ownedProjects = /* @__PURE__ */ new Map();
|
|
14123
|
+
if (!includeBoardItems && operatorProjects.size > 0) for (const item of itemRows) {
|
|
14124
|
+
if (item.task_id !== null || item.source !== null) continue;
|
|
14125
|
+
const owner = await itemOwner(store.db, item);
|
|
14126
|
+
if (owner !== void 0) ownedProjects.set(item.id, owner.project);
|
|
14127
|
+
}
|
|
14128
|
+
const ownedBy = (item) => {
|
|
14129
|
+
const owner = ownedProjects.get(item.id) ?? "";
|
|
14130
|
+
return projectIds.has(owner) && operatorProjects.has(owner);
|
|
14131
|
+
};
|
|
14132
|
+
const items = itemRows.filter((item) => item.task_id !== null ? projectIds.has(itemTasks.get(item.task_id)?.project ?? "") : item.source !== null ? required.has(item.source) : includeBoardItems || ownedBy(item)).map((item) => {
|
|
14022
14133
|
const source = item.source === null ? null : sourceById.get(item.source);
|
|
14023
14134
|
const unconfirmed = item.fact_at !== null && item.source !== null && clock.now() - Date.parse(item.fact_at) > config.thresholds.staleMultiplier * interval(config, item.source) || item.text.includes("no_access") || source !== null && source !== void 0 && source.blind_reason !== null;
|
|
14024
14135
|
const time = item.fact_at === null ? null : new Date(item.fact_at).toISOString().slice(11, 16);
|
|
@@ -14066,7 +14177,8 @@ async function getStatus(deps, options = {}) {
|
|
|
14066
14177
|
unlinkedPrs,
|
|
14067
14178
|
unlinkedSessions,
|
|
14068
14179
|
hiddenUnlinkedPrs: prRows.length - unlinkedPrs.length,
|
|
14069
|
-
hiddenUnlinkedSessions: sessionRows.length - unlinkedSessions.length
|
|
14180
|
+
hiddenUnlinkedSessions: sessionRows.length - unlinkedSessions.length,
|
|
14181
|
+
bindings: configBindings(config, projectIds)
|
|
14070
14182
|
};
|
|
14071
14183
|
}
|
|
14072
14184
|
const HOLD_ONLY = /* @__PURE__ */ new Set([
|
|
@@ -15611,8 +15723,10 @@ function externalApproval(pr, agentLogin) {
|
|
|
15611
15723
|
* by its own state, or, in a snapshot written before entries had one, when it matches the
|
|
15612
15724
|
* reviewer's latest approval. An entry is handled once a turn handed it over, or an older one,
|
|
15613
15725
|
* unless a correction or a reroute closed that turn untaken, or once a handling submission
|
|
15614
|
-
* (`handlingSubmits`) on this PR was made at or after it
|
|
15615
|
-
*
|
|
15726
|
+
* (`handlingSubmits`) on this PR was made at or after it and its last edit. An edit after the
|
|
15727
|
+
* entry's baseline (`editBaselines`) makes it unhandled again, so it is handed once per edit.
|
|
15728
|
+
* The entries such an untaken turn handed over come from the turn when a later poll dropped them
|
|
15729
|
+
* from the snapshot (`recalledFeedback`).
|
|
15616
15730
|
* A reviewer service's status comment (`statusComment`) never counts, and neither a recall nor a
|
|
15617
15731
|
* reroute hands one over again (`withoutStatusComments` in `turns.ts`).
|
|
15618
15732
|
*/
|
|
@@ -15627,11 +15741,20 @@ async function unhandledFeedback(trx, task, project, pr) {
|
|
|
15627
15741
|
number: pr.number
|
|
15628
15742
|
}], "handled");
|
|
15629
15743
|
const fromSnapshot = entries.map((entry) => handedOf(pr, entry));
|
|
15630
|
-
|
|
15744
|
+
const recalled = (await recalledFeedback(trx, {
|
|
15745
|
+
kind: "pr",
|
|
15746
|
+
repo: pr.repo,
|
|
15747
|
+
number: pr.number
|
|
15748
|
+
})).filter((entry) => !fromSnapshot.some((old) => sameHanded(old, entry)));
|
|
15749
|
+
const baseline = await editBaselines(trx, {
|
|
15631
15750
|
kind: "pr",
|
|
15632
15751
|
repo: pr.repo,
|
|
15633
15752
|
number: pr.number
|
|
15634
|
-
})
|
|
15753
|
+
});
|
|
15754
|
+
return [...recalled, ...fromSnapshot].filter((entry) => {
|
|
15755
|
+
const edited = entry.editedAt === void 0 ? -Infinity : Date.parse(entry.editedAt);
|
|
15756
|
+
return !(Math.max(Date.parse(entry.postedAt), edited) <= newest) && (cursor === void 0 || isNewer(entry, cursor) || edited > baseline(entry));
|
|
15757
|
+
});
|
|
15635
15758
|
}
|
|
15636
15759
|
/**
|
|
15637
15760
|
* The submissions of `taskIds` that handle the external feedback posted before them on the PR
|
|
@@ -15704,7 +15827,10 @@ function handedOf(pr, entry) {
|
|
|
15704
15827
|
number: pr.number,
|
|
15705
15828
|
kind: entry.kind,
|
|
15706
15829
|
id: entry.id,
|
|
15707
|
-
postedAt: entry.postedAt
|
|
15830
|
+
postedAt: entry.postedAt,
|
|
15831
|
+
...entry.url === void 0 ? {} : { url: entry.url },
|
|
15832
|
+
...entry.editedAt === void 0 ? {} : { editedAt: entry.editedAt },
|
|
15833
|
+
...entry.comments === void 0 ? {} : { comments: entry.comments }
|
|
15708
15834
|
};
|
|
15709
15835
|
}
|
|
15710
15836
|
/** The clock passed `until` and a complete poll of each of `repos` started at or after it. */
|
|
@@ -15982,7 +16108,10 @@ async function applyOn(trx, task, read, result, ctx) {
|
|
|
15982
16108
|
at
|
|
15983
16109
|
});
|
|
15984
16110
|
const carried = replaced === void 0 ? [] : await carriedFeedback(trx, replaced);
|
|
15985
|
-
const handed = [...carried
|
|
16111
|
+
const handed = [...carried.map((old) => {
|
|
16112
|
+
const fresh = read.handed.find((entry) => sameHanded(old, entry));
|
|
16113
|
+
return fresh !== void 0 && isNewerEdit(fresh, old) ? fresh : old;
|
|
16114
|
+
}), ...read.handed.filter((entry) => !carried.some((old) => sameHanded(old, entry)))];
|
|
15986
16115
|
const reason = read.mergedOpen === void 0 || turn.kind === "reroute" ? turnReason(turn, replaced?.reason) : `${turnReason(turn)} (PR ${read.mergedOpen.repo}#${String(read.mergedOpen.number)} merged, ticket still open)`;
|
|
15987
16116
|
await openTurn(trx, {
|
|
15988
16117
|
task: current,
|
|
@@ -16090,7 +16219,8 @@ async function dispatchMergedTickets(trx, source, ctx) {
|
|
|
16090
16219
|
//#region ../core/src/app/task-turns.ts
|
|
16091
16220
|
/** How many closed turns `task.get --detail` shows. */
|
|
16092
16221
|
const DETAIL_TURNS = 5;
|
|
16093
|
-
function taskTurnView(turn) {
|
|
16222
|
+
async function taskTurnView(trx, turn) {
|
|
16223
|
+
const returned = await turnReturn(trx, turn);
|
|
16094
16224
|
return {
|
|
16095
16225
|
id: `T${String(turn.id)}`,
|
|
16096
16226
|
column: turn.column,
|
|
@@ -16100,6 +16230,8 @@ function taskTurnView(turn) {
|
|
|
16100
16230
|
by: turn.acked_by,
|
|
16101
16231
|
at: turn.acked_at
|
|
16102
16232
|
},
|
|
16233
|
+
handed: turnHanded(turn),
|
|
16234
|
+
...returned === void 0 ? {} : { returned },
|
|
16103
16235
|
closed: turn.closed_at === null || turn.closed_reason === null ? null : {
|
|
16104
16236
|
at: turn.closed_at,
|
|
16105
16237
|
outcome: turn.closed_reason
|
|
@@ -16112,11 +16244,14 @@ function taskTurnView(turn) {
|
|
|
16112
16244
|
*/
|
|
16113
16245
|
async function taskTurns(trx, task, detail) {
|
|
16114
16246
|
const open = await trx.selectFrom("turn").selectAll().where("task_id", "=", task.id).where("closed_at", "is", null).orderBy("id", "desc").executeTakeFirst();
|
|
16115
|
-
const turn = open === void 0 ? null : taskTurnView(open);
|
|
16247
|
+
const turn = open === void 0 ? null : await taskTurnView(trx, open);
|
|
16116
16248
|
if (!detail) return { turn };
|
|
16249
|
+
const closed = await trx.selectFrom("turn").selectAll().where("task_id", "=", task.id).where("closed_at", "is not", null).orderBy("id", "desc").limit(DETAIL_TURNS).execute();
|
|
16250
|
+
const turns = [];
|
|
16251
|
+
for (const row of closed) turns.push(await taskTurnView(trx, row));
|
|
16117
16252
|
return {
|
|
16118
16253
|
turn,
|
|
16119
|
-
turns
|
|
16254
|
+
turns
|
|
16120
16255
|
};
|
|
16121
16256
|
}
|
|
16122
16257
|
//#endregion
|
|
@@ -16152,9 +16287,13 @@ async function turnThreads(trx, taskId, project, turn) {
|
|
|
16152
16287
|
}]);
|
|
16153
16288
|
return threads.length === 0 ? void 0 : threads;
|
|
16154
16289
|
}
|
|
16155
|
-
/**
|
|
16290
|
+
/**
|
|
16291
|
+
* A turn as the worker and `task.get --why` read it, with the return that opened its visit and the
|
|
16292
|
+
* threads of a Dev turn.
|
|
16293
|
+
*/
|
|
16156
16294
|
async function turnView(trx, turn, task, project) {
|
|
16157
16295
|
const threads = await turnThreads(trx, task.id, project, turn);
|
|
16296
|
+
const returned = await turnReturn(trx, turn);
|
|
16158
16297
|
return {
|
|
16159
16298
|
id: `T${String(turn.id)}`,
|
|
16160
16299
|
task: task.key,
|
|
@@ -16162,6 +16301,7 @@ async function turnView(trx, turn, task, project) {
|
|
|
16162
16301
|
addressee: turn.role,
|
|
16163
16302
|
reason: turn.reason,
|
|
16164
16303
|
handed: turnHanded(turn),
|
|
16304
|
+
...returned === void 0 ? {} : { returned },
|
|
16165
16305
|
head: turn.head_sha,
|
|
16166
16306
|
at: turn.created_at,
|
|
16167
16307
|
taken: turn.acked_by === null || turn.acked_at === null ? null : {
|
|
@@ -16930,6 +17070,10 @@ function createOperationRegistry(deps) {
|
|
|
16930
17070
|
config,
|
|
16931
17071
|
target: { kind: "missing" }
|
|
16932
17072
|
}).status === "allowed",
|
|
17073
|
+
operatorProjects: new Set(config.projects.filter((project) => authorize([{ grant: "operator" }], actor, {
|
|
17074
|
+
config,
|
|
17075
|
+
target: projectTarget(project.id)
|
|
17076
|
+
}).status === "allowed").map((project) => project.id)),
|
|
16933
17077
|
detail: input.detail
|
|
16934
17078
|
});
|
|
16935
17079
|
}
|
|
@@ -16989,12 +17133,16 @@ async function curatorSessions(db, config) {
|
|
|
16989
17133
|
});
|
|
16990
17134
|
return entries;
|
|
16991
17135
|
}
|
|
16992
|
-
/**
|
|
17136
|
+
/**
|
|
17137
|
+
* Configured orchestrators, where each binding comes from, and the same live session selected
|
|
17138
|
+
* for their rings.
|
|
17139
|
+
*/
|
|
16993
17140
|
async function orchestratorSessions(db, config) {
|
|
16994
17141
|
const entries = [];
|
|
16995
17142
|
for (const project of config.projects) for (const spur of project.spurProjects.filter((entry) => entry.role === "orchestrator")) entries.push({
|
|
16996
17143
|
project: project.id,
|
|
16997
17144
|
orchestrator: spur.name,
|
|
17145
|
+
source: boardWideSpurProject(config, spur.name) === void 0 ? "project" : "board-wide",
|
|
16998
17146
|
session: (await bestProjectSession(db, spur.name))?.id ?? null,
|
|
16999
17147
|
columns: project.columns.filter((column) => column.orchestrator !== "none" && column.orchestrator !== "operator" && column.orchestrator === spur.name).map((column) => column.id)
|
|
17000
17148
|
});
|
|
@@ -18122,19 +18270,18 @@ function commandReply(id, value, input) {
|
|
|
18122
18270
|
function addressOperatorMessage(text, config) {
|
|
18123
18271
|
const spurByShortName = /* @__PURE__ */ new Map();
|
|
18124
18272
|
for (const project of config.projects) for (const spur of project.spurProjects) if (spur.shortName !== void 0) spurByShortName.set(spur.shortName, spur.name);
|
|
18125
|
-
if (spurByShortName.size === 0) return null;
|
|
18126
18273
|
const prefix = /^@(\S+)\s*/.exec(text);
|
|
18127
18274
|
const named = prefix?.[1] === void 0 ? void 0 : spurByShortName.get(prefix[1]);
|
|
18128
18275
|
if (prefix?.[1] !== void 0 && named !== void 0) return {
|
|
18129
18276
|
spur: named,
|
|
18130
18277
|
text: stripShortName(text, prefix[1])
|
|
18131
18278
|
};
|
|
18132
|
-
const fallback = config
|
|
18133
|
-
|
|
18134
|
-
|
|
18135
|
-
spur: fallbackSpur,
|
|
18279
|
+
const fallback = defaultAddressee(config);
|
|
18280
|
+
if (fallback !== null) return {
|
|
18281
|
+
spur: fallback.spurProject,
|
|
18136
18282
|
text
|
|
18137
18283
|
};
|
|
18284
|
+
if (spurByShortName.size === 0) return null;
|
|
18138
18285
|
return { hint: `No addressee. Start with one of: ${[...spurByShortName.keys()].map((name) => `@${name}`).join(", ")}.` };
|
|
18139
18286
|
}
|
|
18140
18287
|
/**
|
|
@@ -18155,8 +18302,10 @@ async function namedTask(trx, config, project, text) {
|
|
|
18155
18302
|
return trx.selectFrom("task").selectAll().where("key", "=", key).where("project", "=", project).where("membership", "!=", "archived").executeTakeFirst();
|
|
18156
18303
|
}
|
|
18157
18304
|
/**
|
|
18158
|
-
* Opens the conversation an operator's new message starts, or posts the hint in its thread.
|
|
18159
|
-
*
|
|
18305
|
+
* Opens the conversation an operator's new message starts, or posts the hint in its thread. The
|
|
18306
|
+
* block goes on the task its text names in the first board project listing the addressee that
|
|
18307
|
+
* has that task, else on the first such project. Returns false, and writes nothing, when no short
|
|
18308
|
+
* name and no default addressee exist.
|
|
18160
18309
|
*/
|
|
18161
18310
|
async function openOperatorConversation(trx, input) {
|
|
18162
18311
|
const { config } = input;
|
|
@@ -18170,11 +18319,16 @@ async function openOperatorConversation(trx, input) {
|
|
|
18170
18319
|
});
|
|
18171
18320
|
return true;
|
|
18172
18321
|
}
|
|
18173
|
-
const
|
|
18174
|
-
|
|
18175
|
-
|
|
18176
|
-
const
|
|
18177
|
-
|
|
18322
|
+
const candidates = config.projects.filter((entry) => entry.spurProjects.some((spur) => spur.name === address.spur));
|
|
18323
|
+
const first = candidates[0];
|
|
18324
|
+
if (first === void 0) return false;
|
|
18325
|
+
const role = first.spurProjects.find((spur) => spur.name === address.spur)?.role === "curator" ? "curator" : "worker";
|
|
18326
|
+
let task;
|
|
18327
|
+
for (const candidate of candidates) {
|
|
18328
|
+
task = await namedTask(trx, config, candidate.id, address.text);
|
|
18329
|
+
if (task !== void 0) break;
|
|
18330
|
+
}
|
|
18331
|
+
const subject = task === void 0 ? projectSubject(first.id) : taskSubject(task);
|
|
18178
18332
|
const ctx = {
|
|
18179
18333
|
actor: "operator",
|
|
18180
18334
|
at: input.at
|
|
@@ -19456,9 +19610,9 @@ function teamScopeDenied(error, query) {
|
|
|
19456
19610
|
return /\b(?:slug|name)\b/i.test(error.message) && /\bread:(?:org|discussion)\b/i.test(error.message);
|
|
19457
19611
|
}
|
|
19458
19612
|
const REVIEWER_FIELDS = "requestedReviewer { __typename ... on Bot { login } ... on Mannequin { login } ... on User { login } ... on Team { slug } ... on EnterpriseTeam { slug } } asCodeOwner";
|
|
19459
|
-
const REVIEW_FIELDS = "id author { __typename login } state commit { oid } submittedAt";
|
|
19460
|
-
const COMMENT_FIELDS = "nodes { id author { __typename login } createdAt body } pageInfo { hasPreviousPage startCursor }";
|
|
19461
|
-
const THREAD_FIELDS = "id isResolved isOutdated comments(
|
|
19613
|
+
const REVIEW_FIELDS = "id author { __typename login } state commit { oid } submittedAt url lastEditedAt";
|
|
19614
|
+
const COMMENT_FIELDS = "nodes { id author { __typename login } createdAt body url lastEditedAt } pageInfo { hasPreviousPage startCursor }";
|
|
19615
|
+
const THREAD_FIELDS = "id isResolved isOutdated comments(last: 100) { nodes { id url lastEditedAt pullRequestReview { id } } }";
|
|
19462
19616
|
const CLOSING_FIELDS = "nodes { number repository { nameWithOwner } } pageInfo { hasNextPage endCursor }";
|
|
19463
19617
|
const prFields = (number, closing = false) => `id number url title updatedAt mergedAt closedAt state isDraft mergeable mergeStateStatus
|
|
19464
19618
|
author { login } headRefName headRefOid
|
|
@@ -19471,7 +19625,7 @@ const prFields = (number, closing = false) => `id number url title updatedAt mer
|
|
|
19471
19625
|
reviewThreads(first: 100) { nodes { ${THREAD_FIELDS} } pageInfo { hasNextPage endCursor } }
|
|
19472
19626
|
reviewRequests(first: 100) { nodes { ${REVIEWER_FIELDS} } pageInfo { hasNextPage endCursor } }${closing ? `\n closingIssuesReferences(first: 100) { ${CLOSING_FIELDS} }` : ""}`;
|
|
19473
19627
|
const DISCOVERY_FIELDS = `nodes { number updatedAt author { login } state } pageInfo { hasNextPage endCursor }`;
|
|
19474
|
-
const INDEX_FIELDS = `number updatedAt state isDraft mergeable mergeStateStatus headRefOid statusCheckRollup { state contexts(first: 100) { totalCount nodes { ... on CheckRun { __typename name status conclusion completedAt } ... on StatusContext { __typename context state } } } } reviews(first: 100) { totalCount nodes { id state } } reviewThreads(first: 100) { totalCount nodes { isResolved } } reviewRequests(first: 100) { totalCount nodes { ${REVIEWER_FIELDS} } } comments(last: 1) { totalCount nodes { id } }`;
|
|
19628
|
+
const INDEX_FIELDS = `number updatedAt state isDraft mergeable mergeStateStatus headRefOid statusCheckRollup { state contexts(first: 100) { totalCount nodes { ... on CheckRun { __typename name status conclusion completedAt } ... on StatusContext { __typename context state } } } } reviews(first: 100) { totalCount nodes { id state lastEditedAt } } reviewThreads(first: 100) { totalCount nodes { isResolved } } reviewRequests(first: 100) { totalCount nodes { ${REVIEWER_FIELDS} } } comments(last: 1) { totalCount nodes { id } } edited: comments(first: 1, orderBy: {field: UPDATED_AT, direction: DESC}) { nodes { id updatedAt } }`;
|
|
19475
19629
|
function aliases(numbers, fields) {
|
|
19476
19630
|
return numbers.map((number, i) => `pr${String(i)}: repository(owner: $owner, name: $repo) { pullRequest(number: ${String(number)}) { ${fields(number)} } }`).join("\n");
|
|
19477
19631
|
}
|
|
@@ -19627,6 +19781,47 @@ function nextPage(connection) {
|
|
|
19627
19781
|
return endCursor;
|
|
19628
19782
|
}
|
|
19629
19783
|
//#endregion
|
|
19784
|
+
//#region ../adapters/src/github/feedbackLinks.ts
|
|
19785
|
+
const threadCommentWire = z.object({
|
|
19786
|
+
id: z.string().min(1),
|
|
19787
|
+
url: z.string().optional(),
|
|
19788
|
+
lastEditedAt: z.string().nullish(),
|
|
19789
|
+
pullRequestReview: z.object({ id: z.string().min(1) }).nullish()
|
|
19790
|
+
});
|
|
19791
|
+
const threadWire = z.object({
|
|
19792
|
+
id: z.string().min(1).optional(),
|
|
19793
|
+
isResolved: z.boolean(),
|
|
19794
|
+
isOutdated: z.boolean().optional(),
|
|
19795
|
+
comments: z.object({ nodes: z.array(threadCommentWire) }).optional()
|
|
19796
|
+
});
|
|
19797
|
+
/** The newest of the given edit times; undefined when none was edited. */
|
|
19798
|
+
function newestEdit(times) {
|
|
19799
|
+
return times.reduce((newest, time) => time == null || newest !== void 0 && Date.parse(newest) >= Date.parse(time) ? newest : time, void 0);
|
|
19800
|
+
}
|
|
19801
|
+
/** The link fields of a fact: each only when GitHub gave it, never guessed. */
|
|
19802
|
+
function linkOf(url, editedAt) {
|
|
19803
|
+
return {
|
|
19804
|
+
...url === void 0 ? {} : { url },
|
|
19805
|
+
...editedAt == null ? {} : { editedAt }
|
|
19806
|
+
};
|
|
19807
|
+
}
|
|
19808
|
+
/** Each review's inline comments by review id, in thread order and oldest first in a thread. */
|
|
19809
|
+
function inlineComments(threads) {
|
|
19810
|
+
const byReview = /* @__PURE__ */ new Map();
|
|
19811
|
+
for (const thread of threads) for (const node of thread.comments?.nodes ?? []) {
|
|
19812
|
+
const review = node.pullRequestReview?.id;
|
|
19813
|
+
if (review === void 0) continue;
|
|
19814
|
+
const list = byReview.get(review) ?? [];
|
|
19815
|
+
list.push({
|
|
19816
|
+
id: node.id,
|
|
19817
|
+
...linkOf(node.url, node.lastEditedAt),
|
|
19818
|
+
...thread.id === void 0 ? {} : { threadId: thread.id }
|
|
19819
|
+
});
|
|
19820
|
+
byReview.set(review, list);
|
|
19821
|
+
}
|
|
19822
|
+
return byReview;
|
|
19823
|
+
}
|
|
19824
|
+
//#endregion
|
|
19630
19825
|
//#region ../adapters/src/github/prBatch.ts
|
|
19631
19826
|
const KEPT_REVIEWS = [
|
|
19632
19827
|
"approved",
|
|
@@ -19661,14 +19856,18 @@ const reviewWire = z.object({
|
|
|
19661
19856
|
author: typedActor,
|
|
19662
19857
|
state: z.string(),
|
|
19663
19858
|
commit: z.object({ oid: z.string() }).nullable(),
|
|
19664
|
-
submittedAt: z.string().nullish()
|
|
19859
|
+
submittedAt: z.string().nullish(),
|
|
19860
|
+
url: z.string().optional(),
|
|
19861
|
+
lastEditedAt: z.string().nullish()
|
|
19665
19862
|
}).refine((review) => review.commit !== null || !review.author?.login || review.submittedAt == null || !KEPT_REVIEWS.includes(review.state.toLowerCase()), { path: ["commit"] });
|
|
19666
19863
|
const nodes = (node) => z.object({ nodes: z.array(node) });
|
|
19667
19864
|
const commentWire = z.object({
|
|
19668
19865
|
id: z.string().min(1),
|
|
19669
19866
|
author: typedActor,
|
|
19670
19867
|
createdAt: z.iso.datetime(),
|
|
19671
|
-
body: z.string().optional()
|
|
19868
|
+
body: z.string().optional(),
|
|
19869
|
+
url: z.string().optional(),
|
|
19870
|
+
lastEditedAt: z.iso.datetime().nullish()
|
|
19672
19871
|
});
|
|
19673
19872
|
const loginReviewer = (type) => z.object({
|
|
19674
19873
|
__typename: z.literal(type),
|
|
@@ -19706,12 +19905,7 @@ const prWire = z.object({
|
|
|
19706
19905
|
statusCheckRollup: z.object({ contexts: nodes(contextWire) }).nullish(),
|
|
19707
19906
|
reviews: nodes(reviewWire),
|
|
19708
19907
|
comments: nodes(commentWire),
|
|
19709
|
-
reviewThreads: nodes(
|
|
19710
|
-
id: z.string().optional(),
|
|
19711
|
-
isResolved: z.boolean(),
|
|
19712
|
-
isOutdated: z.boolean().optional(),
|
|
19713
|
-
comments: nodes(z.object({ url: z.string() })).optional()
|
|
19714
|
-
})),
|
|
19908
|
+
reviewThreads: nodes(threadWire),
|
|
19715
19909
|
reviewRequests: nodes(z.object({
|
|
19716
19910
|
requestedReviewer: reviewerWire,
|
|
19717
19911
|
asCodeOwner: z.boolean()
|
|
@@ -19842,7 +20036,8 @@ function isStatusComment(body) {
|
|
|
19842
20036
|
const last = body?.trimEnd().split("\n").at(-1);
|
|
19843
20037
|
return last !== void 0 && STATUS_LINE.test(last);
|
|
19844
20038
|
}
|
|
19845
|
-
function feedbackOf(reviews, comments, held) {
|
|
20039
|
+
function feedbackOf(reviews, comments, threads, held) {
|
|
20040
|
+
const inline = inlineComments(threads);
|
|
19846
20041
|
const entries = /* @__PURE__ */ new Map();
|
|
19847
20042
|
const add = (entry) => {
|
|
19848
20043
|
entries.set(`${entry.kind}:${entry.id}`, entry);
|
|
@@ -19853,17 +20048,22 @@ function feedbackOf(reviews, comments, held) {
|
|
|
19853
20048
|
id: node.id,
|
|
19854
20049
|
author: feedbackAuthor(node.author),
|
|
19855
20050
|
postedAt: node.createdAt,
|
|
19856
|
-
...isStatusComment(node.body) ? { statusComment: true } : {}
|
|
20051
|
+
...isStatusComment(node.body) ? { statusComment: true } : {},
|
|
20052
|
+
...linkOf(node.url, node.lastEditedAt)
|
|
19857
20053
|
});
|
|
19858
20054
|
for (const node of reviews) {
|
|
19859
20055
|
if (node.submittedAt == null) continue;
|
|
19860
20056
|
const state = REVIEW_STATES.find((known) => known === node.state.toLowerCase());
|
|
20057
|
+
const own = inline.get(node.id) ?? [];
|
|
20058
|
+
const editedAt = newestEdit([node.lastEditedAt, ...own.map((entry) => entry.editedAt)]);
|
|
19861
20059
|
add({
|
|
19862
20060
|
kind: "review",
|
|
19863
20061
|
id: node.id,
|
|
19864
20062
|
author: feedbackAuthor(node.author),
|
|
19865
20063
|
postedAt: node.submittedAt,
|
|
19866
|
-
...state === void 0 ? {} : { state }
|
|
20064
|
+
...state === void 0 ? {} : { state },
|
|
20065
|
+
...linkOf(node.url, editedAt),
|
|
20066
|
+
...own.length === 0 ? {} : { comments: own }
|
|
19867
20067
|
});
|
|
19868
20068
|
}
|
|
19869
20069
|
const tie = (entry) => `${entry.id}\u0000${entry.kind}`;
|
|
@@ -20002,7 +20202,7 @@ function normalizePr(repo, value, rule, feedbackComplete, held = []) {
|
|
|
20002
20202
|
updatedAt: wire.updatedAt,
|
|
20003
20203
|
...state === "merged" && wire.mergedAt !== null ? { mergedAt: wire.mergedAt } : {},
|
|
20004
20204
|
...state === "closed" && wire.closedAt !== null ? { closedAt: wire.closedAt } : {},
|
|
20005
|
-
feedback: feedbackOf(wire.reviews.nodes, wire.comments.nodes, held),
|
|
20205
|
+
feedback: feedbackOf(wire.reviews.nodes, wire.comments.nodes, wire.reviewThreads.nodes, held),
|
|
20006
20206
|
feedbackComplete
|
|
20007
20207
|
};
|
|
20008
20208
|
const parsed = prFactsSchema.safeParse(facts);
|
|
@@ -20037,7 +20237,8 @@ const indexAliasWire = z.object({ pullRequest: z.object({
|
|
|
20037
20237
|
}).nullable(),
|
|
20038
20238
|
reviews: counted(z.object({
|
|
20039
20239
|
id: z.string(),
|
|
20040
|
-
state: z.string()
|
|
20240
|
+
state: z.string(),
|
|
20241
|
+
lastEditedAt: z.string().nullable()
|
|
20041
20242
|
})),
|
|
20042
20243
|
reviewThreads: counted(z.object({ isResolved: z.boolean() })),
|
|
20043
20244
|
reviewRequests: counted(z.object({
|
|
@@ -20048,7 +20249,11 @@ const indexAliasWire = z.object({ pullRequest: z.object({
|
|
|
20048
20249
|
}).nullable(),
|
|
20049
20250
|
asCodeOwner: z.boolean()
|
|
20050
20251
|
})),
|
|
20051
|
-
comments: counted(z.object({ id: z.string() }))
|
|
20252
|
+
comments: counted(z.object({ id: z.string() })),
|
|
20253
|
+
edited: z.object({ nodes: z.array(z.object({
|
|
20254
|
+
id: z.string(),
|
|
20255
|
+
updatedAt: z.string()
|
|
20256
|
+
})) })
|
|
20052
20257
|
}) });
|
|
20053
20258
|
/** Reads one index alias; a shape that does not parse means the PR is read in full. */
|
|
20054
20259
|
function indexEntry(alias) {
|
|
@@ -24049,10 +24254,10 @@ function curatorSessionsCheck(entries) {
|
|
|
24049
24254
|
return warning(id, fitFix([...segments.filter((entry) => entry.problem), ...segments.filter((entry) => !entry.problem)], ` ${CURATOR_TAIL}`, `${String(missing)} curators have no live session. Start a Spur session of each.`));
|
|
24050
24255
|
}
|
|
24051
24256
|
function orchestratorSessionsCheck(entries) {
|
|
24052
|
-
const segments = entries.map(({ project, orchestrator, session, columns }) => ({
|
|
24257
|
+
const segments = entries.map(({ project, orchestrator, source, session, columns }) => ({
|
|
24053
24258
|
problem: session === null || columns.length === 0,
|
|
24054
24259
|
unmatched: false,
|
|
24055
|
-
text: () => `${project}: orchestrator ${orchestrator}, ${session === null ? "no live session" : `session ${session}`}, ${columns.length === 0 ? "unused by columns" : `columns ${columns.join(", ")}`}`
|
|
24260
|
+
text: () => `${project}: orchestrator ${orchestrator} (${source}), ${session === null ? "no live session" : `session ${session}`}, ${columns.length === 0 ? "unused by columns" : `columns ${columns.join(", ")}`}`
|
|
24056
24261
|
}));
|
|
24057
24262
|
const problems = segments.filter((entry) => entry.problem);
|
|
24058
24263
|
const fix = fitFix([...problems, ...segments.filter((entry) => !entry.problem)], problems.length === 0 ? "" : " Assign a column and start a live session for each orchestrator.", `${String(entries.length)} orchestrators; ${String(problems.length)} need a column or live session.`);
|
|
@@ -24063,6 +24268,24 @@ function orchestratorSessionsCheck(entries) {
|
|
|
24063
24268
|
fix
|
|
24064
24269
|
} : warning("orchestrator.sessions", fix);
|
|
24065
24270
|
}
|
|
24271
|
+
/** Each project's operator Spur projects with their source, then the default Slack addressee. */
|
|
24272
|
+
function operatorBindingsText(config) {
|
|
24273
|
+
const bindings = configBindings(config, new Set(config.projects.map((project) => project.id)));
|
|
24274
|
+
const segments = config.projects.flatMap((project) => {
|
|
24275
|
+
const rows = bindings.operators.filter((row) => row.project === project.id);
|
|
24276
|
+
if (rows.length === 0) return [];
|
|
24277
|
+
const names = rows.map((row) => `${row.operator} (${row.source})`).join(", ");
|
|
24278
|
+
return [{
|
|
24279
|
+
problem: false,
|
|
24280
|
+
unmatched: false,
|
|
24281
|
+
text: () => `${project.id}: operator ${names}`
|
|
24282
|
+
}];
|
|
24283
|
+
});
|
|
24284
|
+
const addressee = bindings.defaultAddressee;
|
|
24285
|
+
const tail = addressee === null ? "" : ` Default Slack addressee: ${addressee.spurProject} (${addressee.source}).`;
|
|
24286
|
+
const count = `${String(segments.length)} projects have an operator Spur project.`;
|
|
24287
|
+
return fitFix(segments, tail, `${count}${tail}`.length <= 300 ? `${count}${tail}` : count);
|
|
24288
|
+
}
|
|
24066
24289
|
function check(id, ok, fix) {
|
|
24067
24290
|
return {
|
|
24068
24291
|
id,
|
|
@@ -24200,7 +24423,12 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch, { deadlineM
|
|
|
24200
24423
|
}
|
|
24201
24424
|
const operatorProject = config.projects.some((project) => project.spurProjects.some((spurProject) => spurProject.role === "operator"));
|
|
24202
24425
|
const token = operatorProject ? void 0 : await ctx.store.db.selectFrom("operator_token").select("id").where("status", "=", "approved").executeTakeFirst();
|
|
24203
|
-
checks.push(
|
|
24426
|
+
checks.push(operatorProject ? {
|
|
24427
|
+
id: "operator.path",
|
|
24428
|
+
status: "pass",
|
|
24429
|
+
blocking: false,
|
|
24430
|
+
fix: operatorBindingsText(config)
|
|
24431
|
+
} : check("operator.path", token !== void 0, "Configure a Spur project with the operator role or approve a named operator token."));
|
|
24204
24432
|
checks.push(await operatorTokensCheck(ctx, config));
|
|
24205
24433
|
checks.push(curatorSessionsCheck(await curatorSessions(ctx.store.db, config)));
|
|
24206
24434
|
checks.push(orchestratorSessionsCheck(await orchestratorSessions(ctx.store.db, config)));
|