spur-board 0.45.1 → 0.46.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/cli.mjs +3 -3
- package/dist/{client-DXseLMUK.mjs → client-Rpyht8rc.mjs} +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{config-DEL1XWGj.mjs → config-RyoKekR8.mjs} +2 -2
- package/dist/daemon.mjs +229 -86
- package/dist/mcp.mjs +3 -3
- package/dist/migrations/0015_pr_continuation.sql +13 -0
- package/dist/{src-CfmtTvPO.mjs → src-DfgP2kkK.mjs} +9 -3
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Q as requiredSecretKeys, X as configSchema, l as roleCanUseOperation, r as SYSTEMD_SERVICE_SETTINGS, tt as SLACK_BOT_SCOPES, u as OPERATIONS, z as ERRORS } from "./src-
|
|
2
|
-
import { a as CliError, c as escapeTerminalControls, i as requestTokenEnrollment, n as fetchTokenStatus, o as errorExitCode, r as requestOperation, s as renderCliError } from "./client-
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./config-
|
|
1
|
+
import { Q as requiredSecretKeys, X as configSchema, l as roleCanUseOperation, r as SYSTEMD_SERVICE_SETTINGS, tt as SLACK_BOT_SCOPES, u as OPERATIONS, z as ERRORS } from "./src-DfgP2kkK.mjs";
|
|
2
|
+
import { a as CliError, c as escapeTerminalControls, i as requestTokenEnrollment, n as fetchTokenStatus, o as errorExitCode, r as requestOperation, s as renderCliError } from "./client-Rpyht8rc.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./config-RyoKekR8.mjs";
|
|
4
4
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
5
5
|
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
6
6
|
import { homedir, hostname, userInfo } from "node:os";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as errorEnvelopeSchema, V as errorContextSchema, W as successEnvelopeSchema, p as renderJsonError, z as ERRORS } from "./src-
|
|
1
|
+
import { H as errorEnvelopeSchema, V as errorContextSchema, W as successEnvelopeSchema, p as renderJsonError, z as ERRORS } from "./src-DfgP2kkK.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { request } from "node:http";
|
package/dist/client.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as requestTokenEnrollment, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./client-
|
|
1
|
+
import { i as requestTokenEnrollment, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./client-Rpyht8rc.mjs";
|
|
2
2
|
export { fetchCatalogVersion, fetchTokenStatus, requestOperation, requestTokenEnrollment };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { X as configSchema, Z as plainHttpAllowed, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-
|
|
2
|
-
import { a as CliError, t as fetchCatalogVersion } from "./client-
|
|
1
|
+
import { X as configSchema, Z as plainHttpAllowed, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-DfgP2kkK.mjs";
|
|
2
|
+
import { a as CliError, t as fetchCatalogVersion } from "./client-Rpyht8rc.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { homedir } from "node:os";
|
package/dist/daemon.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as COLUMN_IDS, A as ringMarker, B as err, C as REVIEW_STATES, D as parseRingMarker, E as isExternalAuthor, F as errorCodeOf, I as parseActorId, J as DEFAULT_SLACK_COMMAND, K as DEFAULT_LINK, L as parseRef$1, M as ticketFactsSchema, N as actorIdSchema, O as prFactsSchema, P as encodeActorId, Q as requiredSecretKeys, R as taskKeySchema, S as eventPayloadSchemas, T as SESSION_STATUSES, U as ok, W as successEnvelopeSchema, X as configSchema, Y as RESERVED_PROJECT, Z as plainHttpAllowed, _ as inboundEventSchema, a as batchSchema, b as userIdSchema, c as buildCatalogSnapshot, d as turnHandedSchema, et as DISPATCHER_MODES, f as renderHttpProblem, g as conversationRefSchema, h as SPACE_IDS, i as AdapterError, j as sessionFactsSchema, k as prRefSchema, l as roleCanUseOperation, n as BOARD_TICK_MS, o as entityRefSchema, s as sourceCursorSchema, t as assertNever, tt as SLACK_BOT_SCOPES, u as OPERATIONS, v as interactionRefSchema, w as SESSION_HEALTH_STATES, x as EVENT_KINDS, y as messageRefSchema, z as ERRORS } from "./src-
|
|
1
|
+
import { $ as COLUMN_IDS, A as ringMarker, B as err, C as REVIEW_STATES, D as parseRingMarker, E as isExternalAuthor, F as errorCodeOf, I as parseActorId, J as DEFAULT_SLACK_COMMAND, K as DEFAULT_LINK, L as parseRef$1, M as ticketFactsSchema, N as actorIdSchema, O as prFactsSchema, P as encodeActorId, Q as requiredSecretKeys, R as taskKeySchema, S as eventPayloadSchemas, T as SESSION_STATUSES, U as ok, W as successEnvelopeSchema, X as configSchema, Y as RESERVED_PROJECT, Z as plainHttpAllowed, _ as inboundEventSchema, a as batchSchema, b as userIdSchema, c as buildCatalogSnapshot, d as turnHandedSchema, et as DISPATCHER_MODES, f as renderHttpProblem, g as conversationRefSchema, h as SPACE_IDS, i as AdapterError, j as sessionFactsSchema, k as prRefSchema, l as roleCanUseOperation, n as BOARD_TICK_MS, o as entityRefSchema, s as sourceCursorSchema, t as assertNever, tt as SLACK_BOT_SCOPES, u as OPERATIONS, v as interactionRefSchema, w as SESSION_HEALTH_STATES, x as EVENT_KINDS, y as messageRefSchema, z as ERRORS } from "./src-DfgP2kkK.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { chmodSync, closeSync, existsSync, fchmodSync, fstatSync, fsyncSync, ftruncateSync, linkSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeSync } from "node:fs";
|
|
@@ -443,7 +443,8 @@ function acknowledgeComment(revision, requested) {
|
|
|
443
443
|
}
|
|
444
444
|
//#endregion
|
|
445
445
|
//#region ../core/src/app/authorize.ts
|
|
446
|
-
|
|
446
|
+
/** True for the operator token and for a session of a Spur project with the `operator` role. */
|
|
447
|
+
function isOperator(actor, config) {
|
|
447
448
|
if (actor === "operator") return true;
|
|
448
449
|
const parsed = parseActorId(actor);
|
|
449
450
|
return parsed?.actor === "agent" && config.projects.some((project) => project.spurProjects.some((spur) => spur.name === parsed.actorRef.project && spur.role === "operator"));
|
|
@@ -458,7 +459,7 @@ function worker(actor, target) {
|
|
|
458
459
|
}
|
|
459
460
|
function orchestrator$1(actor, target, config, column) {
|
|
460
461
|
const configured = config.projects.find((entry) => entry.id === target.project)?.columns.find((entry) => entry.id === column)?.orchestrator;
|
|
461
|
-
if (configured === "operator") return
|
|
462
|
+
if (configured === "operator") return isOperator(actor, config);
|
|
462
463
|
const parsed = parseActorId(actor);
|
|
463
464
|
return parsed?.actor === "agent" && configured !== "none" && configured === parsed.actorRef.project;
|
|
464
465
|
}
|
|
@@ -483,7 +484,7 @@ function blockAuthor(actor, target, config) {
|
|
|
483
484
|
function matches(rule, actor, target, config) {
|
|
484
485
|
const parsed = parseActorId(actor);
|
|
485
486
|
switch (rule.grant) {
|
|
486
|
-
case "operator": return
|
|
487
|
+
case "operator": return isOperator(actor, config);
|
|
487
488
|
case "project-agent": return parsed?.actor === "agent" && config.projects.find((project) => project.id === target.project)?.spurProjects.some((spur) => spur.name === parsed.actorRef.project) === true;
|
|
488
489
|
case "task-worker": return worker(actor, target);
|
|
489
490
|
case "column-orchestrator": return target.task !== null && orchestrator$1(actor, target, config, target.task.column);
|
|
@@ -491,7 +492,7 @@ function matches(rule, actor, target, config) {
|
|
|
491
492
|
if (target.block === null) return false;
|
|
492
493
|
const addressee = parseAddressee(target.block.addressee_role);
|
|
493
494
|
switch (addressee.kind) {
|
|
494
|
-
case "operator": return
|
|
495
|
+
case "operator": return isOperator(actor, config);
|
|
495
496
|
case "curator": return parsed?.actor === "agent" && parsed.actorRef.project === curatorProject(config, target.project);
|
|
496
497
|
case "worker": return worker(actor, target);
|
|
497
498
|
case "orchestrator": return orchestrator$1(actor, target, config, addressee.column);
|
|
@@ -507,7 +508,7 @@ function authorize(grants, actor, state) {
|
|
|
507
508
|
const rules = grants.filter((rule) => rule.mode === void 0 || rule.mode === state.mode);
|
|
508
509
|
const hint = `Allowed role: ${[...new Set(rules.map((rule) => rule.grant))].join(", ") || "none"}.`;
|
|
509
510
|
if (state.target.kind === "missing") {
|
|
510
|
-
if (rules.some((rule) => rule.grant === "operator" &&
|
|
511
|
+
if (rules.some((rule) => rule.grant === "operator" && isOperator(actor, state.config))) return { status: "allowed" };
|
|
511
512
|
return rules.every((rule) => rule.grant === "operator") ? {
|
|
512
513
|
status: "denied",
|
|
513
514
|
hint
|
|
@@ -9101,7 +9102,7 @@ async function raiseItem(trx, input) {
|
|
|
9101
9102
|
}
|
|
9102
9103
|
/**
|
|
9103
9104
|
* Clear an item once; the edit waits for its line and is cancelled with a stale pending line.
|
|
9104
|
-
* The journal names `actor`, `system` unless an
|
|
9105
|
+
* The journal names `actor`, `system` unless an actor's action cleared it.
|
|
9105
9106
|
*/
|
|
9106
9107
|
async function clearItem(trx, itemId, at, actor = "system") {
|
|
9107
9108
|
if ((await trx.selectFrom("operator_item").selectAll().where("id", "=", itemId).executeTakeFirstOrThrow()).cleared_at !== null) return;
|
|
@@ -9163,7 +9164,7 @@ function resolvedLine(by, at, config) {
|
|
|
9163
9164
|
kind: "text",
|
|
9164
9165
|
text: "✓ Resolved by "
|
|
9165
9166
|
},
|
|
9166
|
-
parsed.actor === "agent" ? {
|
|
9167
|
+
parsed.actor === "agent" && !isOperator(by, config) ? {
|
|
9167
9168
|
kind: "text",
|
|
9168
9169
|
text: `${parsed.actorRef.project}/${parsed.actorRef.session}`
|
|
9169
9170
|
} : {
|
|
@@ -9661,7 +9662,7 @@ async function applyDoorbellPolicy(trx, event, at) {
|
|
|
9661
9662
|
if (!(parseActorId(event.block.author)?.actor === "agent" && event.block.addressee_role === event.authorRole)) await registerBlockNotification(trx, event.block, at);
|
|
9662
9663
|
return;
|
|
9663
9664
|
case "block_escalated":
|
|
9664
|
-
await closeBlockNotification(trx, event.block.id, at);
|
|
9665
|
+
await closeBlockNotification(trx, event.block.id, at, "system");
|
|
9665
9666
|
await registerBlockNotification(trx, event.block, at);
|
|
9666
9667
|
return;
|
|
9667
9668
|
case "answer":
|
|
@@ -10260,21 +10261,22 @@ async function workerNotificationAddressedTo(trx, n, session, config) {
|
|
|
10260
10261
|
if (n.recipient_session === null) return session === n.author_session || await sessionLink(trx, n.task_id, "worker", session) !== void 0;
|
|
10261
10262
|
return await liveSession(trx, n.recipient_session) !== void 0 ? session === n.recipient_session : (await selectNotificationRecipient(trx, n, config))?.id === session;
|
|
10262
10263
|
}
|
|
10263
|
-
|
|
10264
|
-
|
|
10264
|
+
/** Ends a block's ring series; its exhaustion item is cleared by `actor`, who closed the block. */
|
|
10265
|
+
async function closeBlockNotification(trx, blockId, at, actor) {
|
|
10266
|
+
await closeOwnedNotifications(trx, "block", blockId, at, actor);
|
|
10265
10267
|
}
|
|
10266
10268
|
/**
|
|
10267
10269
|
* Ends a turn's ring series and reminders for good: acked, and its exhaustion item cleared by the
|
|
10268
10270
|
* system.
|
|
10269
10271
|
*/
|
|
10270
10272
|
async function closeTurnNotification(trx, turnId, at) {
|
|
10271
|
-
await closeOwnedNotifications(trx, "turn", turnId, at);
|
|
10273
|
+
await closeOwnedNotifications(trx, "turn", turnId, at, "system");
|
|
10272
10274
|
}
|
|
10273
|
-
async function closeOwnedNotifications(trx, kind, ownerId, at) {
|
|
10275
|
+
async function closeOwnedNotifications(trx, kind, ownerId, at, actor) {
|
|
10274
10276
|
const closed = await trx.updateTable("notification").set({ acked_at: at.toISOString() }).where(kind === "block" ? "block_id" : "turn_id", "=", ownerId).where("kind", "in", kind === "block" ? ["block"] : ["turn", "turn_reminder"]).where("acked_at", "is", null).returning(["kind", "source_key"]).execute();
|
|
10275
10277
|
for (const row of closed) {
|
|
10276
10278
|
const item = await trx.selectFrom("operator_item").select("id").where("item_key", "=", exhaustedItemKey(row)).where("cleared_at", "is", null).executeTakeFirst();
|
|
10277
|
-
if (item !== void 0) await clearItem(trx, item.id, at);
|
|
10279
|
+
if (item !== void 0) await clearItem(trx, item.id, at, actor);
|
|
10278
10280
|
}
|
|
10279
10281
|
}
|
|
10280
10282
|
//#endregion
|
|
@@ -10813,9 +10815,9 @@ async function closeOpenBlock(trx, task, block, ctx, outcome, outcomeReason) {
|
|
|
10813
10815
|
actor: ctx.actor,
|
|
10814
10816
|
at: new Date(ctx.at)
|
|
10815
10817
|
});
|
|
10816
|
-
await closeBlockNotification(trx, block.id, new Date(ctx.at));
|
|
10818
|
+
await closeBlockNotification(trx, block.id, new Date(ctx.at), ctx.actor);
|
|
10817
10819
|
const items = await trx.selectFrom("operator_item").selectAll().where("kind", "in", ["post_blocked", ...BLOCK_ITEM_KINDS]).where("block_id", "=", block.id).where("cleared_at", "is", null).execute();
|
|
10818
|
-
for (const item of items) if (item.kind === "post_blocked") await clearItem(trx, item.id, new Date(ctx.at));
|
|
10820
|
+
for (const item of items) if (item.kind === "post_blocked") await clearItem(trx, item.id, new Date(ctx.at), ctx.actor);
|
|
10819
10821
|
else if (ctx.actor !== "system" && outcome !== "archived" && isItemKind(item.kind) && ITEM_POLICY[item.kind].reconciled) await dismissItem(trx, item, ctx.actor, new Date(ctx.at));
|
|
10820
10822
|
else await clearItem(trx, item.id, new Date(ctx.at), ctx.actor);
|
|
10821
10823
|
return updated;
|
|
@@ -12204,7 +12206,21 @@ function sessionView(fact) {
|
|
|
12204
12206
|
function counts(values, order) {
|
|
12205
12207
|
return order.map((value) => [value, values.filter((entry) => entry === value).length]).filter(([, n]) => n > 0).map(([value, n]) => `${String(n)} ${value}`).join(", ");
|
|
12206
12208
|
}
|
|
12207
|
-
/**
|
|
12209
|
+
/** End reasons in the words of the "worker ended" item (`ENDED_WORKER_LABELS`, fromYou.ts). */
|
|
12210
|
+
const END_WORDS = {
|
|
12211
|
+
complete: "completed",
|
|
12212
|
+
kill: "killed",
|
|
12213
|
+
vanished: "vanished",
|
|
12214
|
+
unknown: "unknown"
|
|
12215
|
+
};
|
|
12216
|
+
/** A linked session's label in the task row: `ended (<reason>)` once the board knows it ended. */
|
|
12217
|
+
function sessionLabel(fact, absentSince) {
|
|
12218
|
+
if (fact.endReason !== null) return `ended (${END_WORDS[fact.endReason]})`;
|
|
12219
|
+
if (fact.lifecycle === "killed" || fact.lifecycle === "completed") return `ended (${fact.lifecycle})`;
|
|
12220
|
+
if (absentSince !== null) return "ended (gone)";
|
|
12221
|
+
return fact.health;
|
|
12222
|
+
}
|
|
12223
|
+
/** The one-line task state: ticket status, pull request states, session counts by label. */
|
|
12208
12224
|
function taskState(ticket, prs, sessions) {
|
|
12209
12225
|
const parts = [ticket === null ? "ticket not observed" : `ticket ${ticket.status}`];
|
|
12210
12226
|
if (prs.length > 0) {
|
|
@@ -12217,8 +12233,8 @@ function taskState(ticket, prs, sessions) {
|
|
|
12217
12233
|
])}`);
|
|
12218
12234
|
}
|
|
12219
12235
|
if (sessions.length > 0) {
|
|
12220
|
-
const
|
|
12221
|
-
parts.push(`sessions ${counts(
|
|
12236
|
+
const labels = sessions.map((session) => sessionLabel(session.fact, session.absentSince));
|
|
12237
|
+
parts.push(`sessions ${counts(labels, [...new Set(labels)].sort())}`);
|
|
12222
12238
|
}
|
|
12223
12239
|
return parts.join("; ");
|
|
12224
12240
|
}
|
|
@@ -12253,12 +12269,20 @@ async function getStatus(deps, options = {}) {
|
|
|
12253
12269
|
const links = taskLinks.filter((link) => link.banned === 0);
|
|
12254
12270
|
const prs = [];
|
|
12255
12271
|
const sessions = [];
|
|
12272
|
+
const sessionStates = [];
|
|
12256
12273
|
for (const link of links) if (link.entity === "pr" && link.repo !== null && link.number !== null) {
|
|
12257
12274
|
const snapshot = await store.db.selectFrom("pr_snapshot").select("detail").where(sql`lower(repo) = ${link.repo.toLowerCase()}`).where("number", "=", link.number).executeTakeFirst();
|
|
12258
12275
|
if (snapshot !== void 0) prs.push(parseJson(prFactsSchema, snapshot.detail));
|
|
12259
12276
|
} else if (link.entity === "session" && link.session_id !== null) {
|
|
12260
|
-
const snapshot = await store.db.selectFrom("session_snapshot").select("detail").where("id", "=", link.session_id).executeTakeFirst();
|
|
12261
|
-
if (snapshot !== void 0)
|
|
12277
|
+
const snapshot = await store.db.selectFrom("session_snapshot").select(["detail", "absent_since"]).where("id", "=", link.session_id).executeTakeFirst();
|
|
12278
|
+
if (snapshot !== void 0) {
|
|
12279
|
+
const fact = parseJson(sessionFactsSchema, snapshot.detail);
|
|
12280
|
+
sessions.push(fact);
|
|
12281
|
+
sessionStates.push({
|
|
12282
|
+
fact,
|
|
12283
|
+
absentSince: snapshot.absent_since
|
|
12284
|
+
});
|
|
12285
|
+
}
|
|
12262
12286
|
}
|
|
12263
12287
|
const ticketFacts = ticket === void 0 ? null : parseJson(ticketFactsSchema, ticket.detail);
|
|
12264
12288
|
const project = config.projects.find((entry) => entry.id === task.project);
|
|
@@ -12282,7 +12306,7 @@ async function getStatus(deps, options = {}) {
|
|
|
12282
12306
|
shadowColumn: task.shadow_column ?? task.column,
|
|
12283
12307
|
shadowDiffers: (task.shadow_column ?? task.column) !== task.column
|
|
12284
12308
|
} : {},
|
|
12285
|
-
state: taskState(ticketFacts, prs,
|
|
12309
|
+
state: taskState(ticketFacts, prs, sessionStates),
|
|
12286
12310
|
prCount: links.filter((link) => link.entity === "pr").length,
|
|
12287
12311
|
sessionCount: links.filter((link) => link.entity === "session").length,
|
|
12288
12312
|
openBlocks: openBlocks.get(task.id) ?? 0,
|
|
@@ -15037,6 +15061,60 @@ async function session(trx, config, fact, at, source, ambiguousBranches) {
|
|
|
15037
15061
|
await trx.updateTable("task").set({ last_change_at: at }).where("id", "=", task.id).execute();
|
|
15038
15062
|
}
|
|
15039
15063
|
}
|
|
15064
|
+
/** The PRs of a GitHub source's repo that still have an unbanned link, one per ref key. */
|
|
15065
|
+
async function linkedPrs(db, source) {
|
|
15066
|
+
if (!source.startsWith("github:")) return [];
|
|
15067
|
+
const repo = source.slice(source.lastIndexOf(":") + 1);
|
|
15068
|
+
const prs = (await db.selectFrom("link").select(["repo", "number"]).where("entity", "=", "pr").where(sql`lower(repo) = ${repo.toLowerCase()}`).where("banned", "=", 0).execute()).flatMap((link) => link.repo === null || link.number === null ? [] : [{
|
|
15069
|
+
kind: "pr",
|
|
15070
|
+
repo: link.repo,
|
|
15071
|
+
number: link.number
|
|
15072
|
+
}]);
|
|
15073
|
+
return [...new Map(prs.map((ref) => [refKey(ref), ref])).values()];
|
|
15074
|
+
}
|
|
15075
|
+
const heldFeedbackSchema = prFactsSchema.shape.feedback.unwrap();
|
|
15076
|
+
/** The held comment histories of `prs` (A10); a row that does not parse is skipped. */
|
|
15077
|
+
async function heldContinuations(db, source, prs) {
|
|
15078
|
+
if (prs.length === 0) return [];
|
|
15079
|
+
const byKey = new Map(prs.map((ref) => [refKey(ref), ref]));
|
|
15080
|
+
return (await db.selectFrom("pr_continuation").selectAll().where("source", "=", source).where("ref_key", "in", [...byKey.keys()]).orderBy("ref_key").execute()).flatMap((row) => {
|
|
15081
|
+
const ref = byKey.get(row.ref_key);
|
|
15082
|
+
if (ref === void 0) return [];
|
|
15083
|
+
let feedback;
|
|
15084
|
+
try {
|
|
15085
|
+
feedback = parseJson(heldFeedbackSchema, row.feedback);
|
|
15086
|
+
} catch {
|
|
15087
|
+
return [];
|
|
15088
|
+
}
|
|
15089
|
+
return [{
|
|
15090
|
+
ref,
|
|
15091
|
+
resume: row.resume,
|
|
15092
|
+
feedback
|
|
15093
|
+
}];
|
|
15094
|
+
});
|
|
15095
|
+
}
|
|
15096
|
+
/** Applies a `pr` item's `continuation` (A10): omitted keeps the row, null drops it. */
|
|
15097
|
+
async function holdContinuation(trx, source, item) {
|
|
15098
|
+
if (item.continuation === void 0) return;
|
|
15099
|
+
const key = refKey({
|
|
15100
|
+
kind: "pr",
|
|
15101
|
+
repo: item.facts.repo,
|
|
15102
|
+
number: item.facts.number
|
|
15103
|
+
});
|
|
15104
|
+
if (item.continuation === null) {
|
|
15105
|
+
await trx.deleteFrom("pr_continuation").where("source", "=", source).where("ref_key", "=", key).execute();
|
|
15106
|
+
return;
|
|
15107
|
+
}
|
|
15108
|
+
const held = {
|
|
15109
|
+
resume: item.continuation.resume,
|
|
15110
|
+
feedback: toJson(heldFeedbackSchema, item.facts.feedback ?? [])
|
|
15111
|
+
};
|
|
15112
|
+
await trx.insertInto("pr_continuation").values({
|
|
15113
|
+
source,
|
|
15114
|
+
ref_key: key,
|
|
15115
|
+
...held
|
|
15116
|
+
}).onConflict((oc) => oc.columns(["source", "ref_key"]).doUpdateSet(held)).execute();
|
|
15117
|
+
}
|
|
15040
15118
|
/** Core's adapter-facing port. Every accepted batch and its source state share one transaction. */
|
|
15041
15119
|
function createObservationCore(deps) {
|
|
15042
15120
|
const { store, config, clock } = deps;
|
|
@@ -15062,12 +15140,7 @@ function createObservationCore(deps) {
|
|
|
15062
15140
|
key: task.key
|
|
15063
15141
|
}] : [];
|
|
15064
15142
|
}) : [];
|
|
15065
|
-
const
|
|
15066
|
-
const prs = repo === null ? [] : (await store.db.selectFrom("link").select(["repo", "number"]).where("entity", "=", "pr").where(sql`lower(repo) = ${repo.toLowerCase()}`).where("banned", "=", 0).execute()).flatMap((link) => link.repo === null || link.number === null ? [] : [{
|
|
15067
|
-
kind: "pr",
|
|
15068
|
-
repo: link.repo,
|
|
15069
|
-
number: link.number
|
|
15070
|
-
}]);
|
|
15143
|
+
const requested = await linkedPrs(store.db, source);
|
|
15071
15144
|
const sessions = source === "spur" ? (await store.db.selectFrom("link").innerJoin("session_snapshot", "session_snapshot.id", "link.session_id").select("link.session_id").where("link.entity", "=", "session").where("session_snapshot.ended_at", "is", null).execute()).flatMap((link) => link.session_id === null ? [] : [{
|
|
15072
15145
|
kind: "session",
|
|
15073
15146
|
id: link.session_id
|
|
@@ -15081,8 +15154,8 @@ function createObservationCore(deps) {
|
|
|
15081
15154
|
})));
|
|
15082
15155
|
}
|
|
15083
15156
|
const misses = await store.db.selectFrom("source_miss").selectAll().where("source", "=", source).execute();
|
|
15084
|
-
const requested = [...new Map(prs.map((ref) => [refKey(ref), ref])).values()];
|
|
15085
15157
|
const feedbackCursors = await pollFeedbackCursors(store.db, config, requested);
|
|
15158
|
+
const continuations = await heldContinuations(store.db, source, requested);
|
|
15086
15159
|
return {
|
|
15087
15160
|
observe: {
|
|
15088
15161
|
prs: requested,
|
|
@@ -15097,7 +15170,8 @@ function createObservationCore(deps) {
|
|
|
15097
15170
|
count: row.misses
|
|
15098
15171
|
}];
|
|
15099
15172
|
}),
|
|
15100
|
-
...feedbackCursors.length === 0 ? {} : { feedbackCursors }
|
|
15173
|
+
...feedbackCursors.length === 0 ? {} : { feedbackCursors },
|
|
15174
|
+
...continuations.length === 0 ? {} : { continuations }
|
|
15101
15175
|
};
|
|
15102
15176
|
},
|
|
15103
15177
|
async observe(source, observation) {
|
|
@@ -15129,8 +15203,12 @@ function createObservationCore(deps) {
|
|
|
15129
15203
|
return rank(left) - rank(right);
|
|
15130
15204
|
});
|
|
15131
15205
|
for (const item of orderedItems) if (item.kind === "ticket") await ticket(trx, config, item.facts, batch.observedAt, source);
|
|
15132
|
-
else if (item.kind === "pr")
|
|
15133
|
-
|
|
15206
|
+
else if (item.kind === "pr") {
|
|
15207
|
+
await pr(trx, config, item.facts, batch.observedAt, source);
|
|
15208
|
+
await holdContinuation(trx, source, item);
|
|
15209
|
+
} else await session(trx, config, item.facts, batch.observedAt, source, ambiguous);
|
|
15210
|
+
const linked = (await linkedPrs(trx, source)).map(refKey);
|
|
15211
|
+
await trx.deleteFrom("pr_continuation").where("source", "=", source).$if(linked.length > 0, (query) => query.where("ref_key", "not in", linked)).execute();
|
|
15134
15212
|
for (const entity of batch.entities) {
|
|
15135
15213
|
if (entity.ref.kind !== "session" || entity.status !== "not_found") continue;
|
|
15136
15214
|
const old = await trx.selectFrom("session_snapshot").selectAll().where("id", "=", entity.ref.id).executeTakeFirst();
|
|
@@ -16558,8 +16636,9 @@ const INDEX_FIELDS = `number updatedAt state isDraft mergeable mergeStateStatus
|
|
|
16558
16636
|
function aliases(numbers, fields) {
|
|
16559
16637
|
return numbers.map((number, i) => `pr${String(i)}: repository(owner: $owner, name: $repo) { pullRequest(number: ${String(number)}) { ${fields(number)} } }`).join("\n");
|
|
16560
16638
|
}
|
|
16639
|
+
const discoveryStates = (bootstrap) => bootstrap ? "OPEN" : "OPEN, MERGED, CLOSED";
|
|
16561
16640
|
function discoveryQuery(bootstrap = false) {
|
|
16562
|
-
return `query PrBatch($owner: String!, $repo: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, states: [${bootstrap
|
|
16641
|
+
return `query PrBatch($owner: String!, $repo: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, states: [${discoveryStates(bootstrap)}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} }${bootstrap ? " mergedBaseline: pullRequests(first: 1, states: [MERGED, CLOSED], orderBy: {field: UPDATED_AT, direction: DESC}) { nodes { updatedAt } }" : ""} } }`;
|
|
16563
16642
|
}
|
|
16564
16643
|
function indexQuery(numbers) {
|
|
16565
16644
|
return `query PrIndex($owner: String!, $repo: String!) { rateLimit { remaining resetAt } ${aliases(numbers, () => INDEX_FIELDS)} }`;
|
|
@@ -16569,7 +16648,7 @@ function detailQuery(numbers, closing = false) {
|
|
|
16569
16648
|
}
|
|
16570
16649
|
function pageQuery(connection, bootstrap = false) {
|
|
16571
16650
|
if (connection === "comments") return `query PrPage($owner: String!, $repo: String!, $number: Int!, $before: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequest(number: $number) { comments(last: 100, before: $before) { ${COMMENT_FIELDS} } } } }`;
|
|
16572
|
-
if (connection === "pullRequests") return `query DiscoveryPage($owner: String!, $repo: String!, $after: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, after: $after, states: [${bootstrap
|
|
16651
|
+
if (connection === "pullRequests") return `query DiscoveryPage($owner: String!, $repo: String!, $after: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, after: $after, states: [${discoveryStates(bootstrap)}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} } } }`;
|
|
16573
16652
|
return `query PrPage($owner: String!, $repo: String!, $number: Int!, $after: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequest(number: $number) { ${connection === "closingIssuesReferences" ? `closingIssuesReferences(first: 100, after: $after) { ${CLOSING_FIELDS} }` : connection === "contexts" ? `statusCheckRollup { contexts(first: 100, after: $after) { nodes { ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt } isRequired(pullRequestNumber: $number) } ... on StatusContext { __typename context state createdAt isRequired(pullRequestNumber: $number) } } pageInfo { hasNextPage endCursor } } }` : `${connection}(first: 100, after: $after) { nodes { ${connection === "reviews" ? REVIEW_FIELDS : connection === "reviewThreads" ? "isResolved" : REVIEWER_FIELDS} } pageInfo { hasNextPage endCursor } }`} } } }`;
|
|
16574
16653
|
}
|
|
16575
16654
|
var GithubClient = class {
|
|
@@ -16879,11 +16958,12 @@ function feedbackAuthor(wire) {
|
|
|
16879
16958
|
type: wire.__typename === "Bot" ? "bot" : "user"
|
|
16880
16959
|
};
|
|
16881
16960
|
}
|
|
16882
|
-
function feedbackOf(reviews, comments) {
|
|
16961
|
+
function feedbackOf(reviews, comments, held) {
|
|
16883
16962
|
const entries = /* @__PURE__ */ new Map();
|
|
16884
16963
|
const add = (entry) => {
|
|
16885
16964
|
entries.set(`${entry.kind}:${entry.id}`, entry);
|
|
16886
16965
|
};
|
|
16966
|
+
for (const entry of held) if (entry.kind === "comment") add(entry);
|
|
16887
16967
|
for (const node of comments) add({
|
|
16888
16968
|
kind: "comment",
|
|
16889
16969
|
id: node.id,
|
|
@@ -16983,8 +17063,11 @@ function reviewer(wire) {
|
|
|
16983
17063
|
default: return assertNever(wire);
|
|
16984
17064
|
}
|
|
16985
17065
|
}
|
|
16986
|
-
/**
|
|
16987
|
-
|
|
17066
|
+
/**
|
|
17067
|
+
* `feedbackComplete` says whether the comments in `value`, with the `held` comments an earlier
|
|
17068
|
+
* poll read, reach back to the cursor or start.
|
|
17069
|
+
*/
|
|
17070
|
+
function normalizePr(repo, value, rule, feedbackComplete, held = []) {
|
|
16988
17071
|
const wire = parseWire(prWire, value, "Malformed GitHub PR response");
|
|
16989
17072
|
const checks = latestChecks(wire.statusCheckRollup?.contexts.nodes ?? []);
|
|
16990
17073
|
const state = wire.state === "MERGED" ? "merged" : wire.state === "CLOSED" ? "closed" : "open";
|
|
@@ -17023,7 +17106,7 @@ function normalizePr(repo, value, rule, feedbackComplete) {
|
|
|
17023
17106
|
ticketKeys: prKeys(rule, title, headBranch, closingRefs(wire.closingIssuesReferences)),
|
|
17024
17107
|
updatedAt: wire.updatedAt,
|
|
17025
17108
|
...state === "merged" && wire.mergedAt !== null ? { mergedAt: wire.mergedAt } : {},
|
|
17026
|
-
feedback: feedbackOf(wire.reviews.nodes, wire.comments.nodes),
|
|
17109
|
+
feedback: feedbackOf(wire.reviews.nodes, wire.comments.nodes, held),
|
|
17027
17110
|
feedbackComplete
|
|
17028
17111
|
};
|
|
17029
17112
|
const parsed = prFactsSchema.safeParse(facts);
|
|
@@ -17166,7 +17249,7 @@ function githubSources(config, options) {
|
|
|
17166
17249
|
client,
|
|
17167
17250
|
now: options.now,
|
|
17168
17251
|
ref,
|
|
17169
|
-
|
|
17252
|
+
ctx,
|
|
17170
17253
|
cache
|
|
17171
17254
|
})
|
|
17172
17255
|
}
|
|
@@ -17277,53 +17360,95 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
|
|
|
17277
17360
|
pr
|
|
17278
17361
|
};
|
|
17279
17362
|
}
|
|
17363
|
+
const at = (time) => Date.parse(time);
|
|
17364
|
+
/** Whether `nodes` hold the `cursor` entry or one strictly older than it. */
|
|
17280
17365
|
function reachesCursor(nodes, cursor) {
|
|
17281
17366
|
if (cursor === void 0) return false;
|
|
17282
|
-
const postedAt =
|
|
17283
|
-
return nodes.some((node) => node.id === cursor.id ||
|
|
17367
|
+
const postedAt = at(cursor.postedAt);
|
|
17368
|
+
return nodes.some((node) => node.id === cursor.id || at(node.createdAt) < postedAt);
|
|
17369
|
+
}
|
|
17370
|
+
const asNode = (entry) => ({
|
|
17371
|
+
id: entry.id,
|
|
17372
|
+
createdAt: entry.postedAt
|
|
17373
|
+
});
|
|
17374
|
+
/** The newest of `items` by `time`; the first one on a tie. */
|
|
17375
|
+
function newestOf(items, time) {
|
|
17376
|
+
return items.reduce((found, item) => found === void 0 || at(time(item)) > at(time(found)) ? item : found, void 0);
|
|
17377
|
+
}
|
|
17378
|
+
/** Reads one page of comments before `before`; undefined on a GraphQL error or a bad page. */
|
|
17379
|
+
async function commentPage(scope, number, before, budget) {
|
|
17380
|
+
const response = await scope.client.query(pageQuery("comments"), {
|
|
17381
|
+
owner: scope.owner,
|
|
17382
|
+
repo: scope.name,
|
|
17383
|
+
number,
|
|
17384
|
+
before
|
|
17385
|
+
}, scope.signal);
|
|
17386
|
+
budget(response.budget);
|
|
17387
|
+
rejectUnscoped(response.errors, ["repository"]);
|
|
17388
|
+
if (response.errors.length > 0) return void 0;
|
|
17389
|
+
const page = content(() => parseWire(commentsRootWire, response.data.repository, MALFORMED$2, ["data", "repository"]).pullRequest.comments);
|
|
17390
|
+
return page instanceof AdapterError ? void 0 : page;
|
|
17284
17391
|
}
|
|
17285
17392
|
/**
|
|
17286
17393
|
* Reads comments back from `first` to `cursor`, or to the start of the PR, within
|
|
17287
|
-
* `FEEDBACK_PAGES
|
|
17288
|
-
*
|
|
17394
|
+
* `FEEDBACK_PAGES` for both phases. Phase 1 pages back from the newest comment until it reaches
|
|
17395
|
+
* the cursor or the start, or joins the newest `held` comment; phase 2 then reads further back
|
|
17396
|
+
* from the held `resume`. A transient failure keeps the comments read so far as incomplete;
|
|
17397
|
+
* every other failure, and any failure after an abort, rejects the poll.
|
|
17289
17398
|
*/
|
|
17290
|
-
async function readFeedback(
|
|
17399
|
+
async function readFeedback(scope, number, first, cursor, held, budget) {
|
|
17291
17400
|
let nodes = first.nodes;
|
|
17292
|
-
let
|
|
17293
|
-
const
|
|
17401
|
+
let kept = [];
|
|
17402
|
+
const result = (complete, continuation) => ({
|
|
17403
|
+
nodes,
|
|
17404
|
+
held: kept,
|
|
17405
|
+
complete,
|
|
17406
|
+
continuation: scope.states ? continuation : void 0
|
|
17407
|
+
});
|
|
17408
|
+
const heldComments = held?.feedback.filter((entry) => entry.kind === "comment") ?? [];
|
|
17409
|
+
const newest = newestOf(heldComments, (entry) => entry.postedAt);
|
|
17410
|
+
let pages = 1;
|
|
17294
17411
|
try {
|
|
17295
|
-
|
|
17412
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17413
|
+
for (let page = first;; pages += 1) {
|
|
17414
|
+
if (!page.pageInfo.hasPreviousPage || reachesCursor(page.nodes, cursor)) return result(true, held === void 0 ? void 0 : null);
|
|
17415
|
+
if (reachesCursor(page.nodes, newest)) break;
|
|
17296
17416
|
const before = page.pageInfo.startCursor;
|
|
17297
|
-
if (!before || seen.has(before)
|
|
17298
|
-
|
|
17299
|
-
complete: false
|
|
17300
|
-
};
|
|
17417
|
+
if (!before || seen.has(before)) return result(false);
|
|
17418
|
+
if (pages >= FEEDBACK_PAGES) return result(false, { resume: sourceCursorSchema.parse(before) });
|
|
17301
17419
|
seen.add(before);
|
|
17302
|
-
const
|
|
17303
|
-
|
|
17304
|
-
|
|
17305
|
-
number,
|
|
17306
|
-
before
|
|
17307
|
-
}, signal);
|
|
17308
|
-
budget(response.budget);
|
|
17309
|
-
rejectUnscoped(response.errors, ["repository"]);
|
|
17310
|
-
if (response.errors.length > 0) return {
|
|
17311
|
-
nodes,
|
|
17312
|
-
complete: false
|
|
17313
|
-
};
|
|
17314
|
-
page = parseWire(commentsRootWire, response.data.repository, MALFORMED$2, ["data", "repository"]).pullRequest.comments;
|
|
17420
|
+
const next = await commentPage(scope, number, before, budget);
|
|
17421
|
+
if (next === void 0) return result(false);
|
|
17422
|
+
page = next;
|
|
17315
17423
|
nodes = [...page.nodes, ...nodes];
|
|
17316
17424
|
}
|
|
17317
|
-
return
|
|
17318
|
-
|
|
17319
|
-
|
|
17320
|
-
|
|
17425
|
+
if (held === void 0) return result(false);
|
|
17426
|
+
const listed = new Set(nodes.map((node) => node.id));
|
|
17427
|
+
const oldestRead = Math.min(...nodes.map((node) => at(node.createdAt)));
|
|
17428
|
+
kept = heldComments.filter((entry) => !listed.has(entry.id) && at(entry.postedAt) <= oldestRead);
|
|
17429
|
+
const history = () => [...nodes, ...kept.map(asNode)];
|
|
17430
|
+
const reached = () => reachesCursor(history(), cursor);
|
|
17431
|
+
let resume = held.resume;
|
|
17432
|
+
const resumed = /* @__PURE__ */ new Set();
|
|
17433
|
+
for (; resume !== null && !reached() && pages < FEEDBACK_PAGES; pages += 1) {
|
|
17434
|
+
resumed.add(resume);
|
|
17435
|
+
const page = await commentPage(scope, number, resume, budget);
|
|
17436
|
+
if (page === void 0) return result(false, null);
|
|
17437
|
+
const run = history();
|
|
17438
|
+
const ids = new Set(run.map((node) => node.id));
|
|
17439
|
+
const oldest = Math.min(...run.map((node) => at(node.createdAt)));
|
|
17440
|
+
const latest = newestOf(page.nodes, (node) => node.createdAt);
|
|
17441
|
+
if (latest !== void 0 && !ids.has(latest.id) && at(latest.createdAt) > oldest) return result(false, null);
|
|
17442
|
+
nodes = [...page.nodes, ...nodes];
|
|
17443
|
+
const start = page.pageInfo.startCursor;
|
|
17444
|
+
if (!page.pageInfo.hasPreviousPage) resume = null;
|
|
17445
|
+
else if (!start || resumed.has(start)) return result(false, null);
|
|
17446
|
+
else resume = sourceCursorSchema.parse(start);
|
|
17447
|
+
}
|
|
17448
|
+
return result(resume === null || reached(), { resume });
|
|
17321
17449
|
} catch (error) {
|
|
17322
|
-
if (signal.aborted) throw error;
|
|
17323
|
-
if (error instanceof AdapterError && error.kind === "transient") return
|
|
17324
|
-
nodes,
|
|
17325
|
-
complete: false
|
|
17326
|
-
};
|
|
17450
|
+
if (scope.signal.aborted) throw error;
|
|
17451
|
+
if (error instanceof AdapterError && error.kind === "transient") return result(false);
|
|
17327
17452
|
throw error;
|
|
17328
17453
|
}
|
|
17329
17454
|
}
|
|
@@ -17391,8 +17516,7 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
|
17391
17516
|
malformed(acc, full.error, ref);
|
|
17392
17517
|
return;
|
|
17393
17518
|
}
|
|
17394
|
-
const
|
|
17395
|
-
const feedback = await readFeedback(scope.client, full.pr.comments, scope.owner, scope.name, number, cursor, scope.signal, report);
|
|
17519
|
+
const feedback = await readFeedback(scope, number, full.pr.comments, entryFor(scope.feedbackCursors, scope.repo, number), entryFor(scope.continuations, scope.repo, number), report);
|
|
17396
17520
|
const pr = {
|
|
17397
17521
|
...full.pr,
|
|
17398
17522
|
comments: {
|
|
@@ -17400,14 +17524,16 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
|
17400
17524
|
nodes: feedback.nodes
|
|
17401
17525
|
}
|
|
17402
17526
|
};
|
|
17403
|
-
const facts = content(() => normalizePr(ref?.repo ?? scope.repo, pr, scope.keys, feedback.complete));
|
|
17527
|
+
const facts = content(() => normalizePr(ref?.repo ?? scope.repo, pr, scope.keys, feedback.complete, feedback.held));
|
|
17404
17528
|
if (facts instanceof AdapterError) {
|
|
17405
17529
|
malformed(acc, facts, ref);
|
|
17406
17530
|
return;
|
|
17407
17531
|
}
|
|
17532
|
+
const { continuation } = feedback;
|
|
17408
17533
|
acc.items.push({
|
|
17409
17534
|
kind: "pr",
|
|
17410
|
-
facts
|
|
17535
|
+
facts,
|
|
17536
|
+
...continuation === void 0 ? {} : { continuation }
|
|
17411
17537
|
});
|
|
17412
17538
|
if (ref) acc.entities.push({
|
|
17413
17539
|
ref,
|
|
@@ -17415,8 +17541,9 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
|
17415
17541
|
});
|
|
17416
17542
|
return facts;
|
|
17417
17543
|
}
|
|
17418
|
-
|
|
17419
|
-
|
|
17544
|
+
/** The entry of one PR in a per-PR list of the poll context. */
|
|
17545
|
+
function entryFor(entries, repo, number) {
|
|
17546
|
+
return entries?.find((entry) => entry.ref.number === number && entry.ref.repo.toLowerCase() === repo.toLowerCase());
|
|
17420
17547
|
}
|
|
17421
17548
|
function closingSelected(keys) {
|
|
17422
17549
|
return keys.type === "issues" && keys.sources.includes("closing");
|
|
@@ -17555,7 +17682,7 @@ async function pollRepository({ id, repo, login, keys, client, now, ctx, reserve
|
|
|
17555
17682
|
if (!discovery.ok) acc.complete = false;
|
|
17556
17683
|
const { found } = discovery;
|
|
17557
17684
|
const entries = await readIndex(request, acc, numbers);
|
|
17558
|
-
const cursorKey = (number) => JSON.stringify(
|
|
17685
|
+
const cursorKey = (number) => JSON.stringify([entryFor(ctx.feedbackCursors, repo, number) ?? "none", entryFor(ctx.continuations, repo, number) ?? "none"]);
|
|
17559
17686
|
const changed = [];
|
|
17560
17687
|
for (const number of numbers) {
|
|
17561
17688
|
const facts = reusable(cache.get(number), entries.get(number), cursorKey(number), now());
|
|
@@ -17581,7 +17708,9 @@ async function pollRepository({ id, repo, login, keys, client, now, ctx, reserve
|
|
|
17581
17708
|
name,
|
|
17582
17709
|
keys,
|
|
17583
17710
|
signal: ctx.signal,
|
|
17584
|
-
...ctx.feedbackCursors === void 0 ? {} : { feedbackCursors: ctx.feedbackCursors }
|
|
17711
|
+
...ctx.feedbackCursors === void 0 ? {} : { feedbackCursors: ctx.feedbackCursors },
|
|
17712
|
+
...ctx.continuations === void 0 ? {} : { continuations: ctx.continuations },
|
|
17713
|
+
states: true
|
|
17585
17714
|
};
|
|
17586
17715
|
let discoveredOk = true;
|
|
17587
17716
|
const unread = (chunk) => {
|
|
@@ -17642,7 +17771,8 @@ async function pollRepository({ id, repo, login, keys, client, now, ctx, reserve
|
|
|
17642
17771
|
...acc.budget === void 0 ? {} : { budget: acc.budget }
|
|
17643
17772
|
};
|
|
17644
17773
|
}
|
|
17645
|
-
async function pollOnePr({ id, repo, keys, client, now, ref,
|
|
17774
|
+
async function pollOnePr({ id, repo, keys, client, now, ref, ctx, cache }) {
|
|
17775
|
+
const { signal } = ctx;
|
|
17646
17776
|
const observedAt = new Date(now()).toISOString();
|
|
17647
17777
|
const [owner, name] = repo.split("/");
|
|
17648
17778
|
if (!owner || !name) throw new AdapterError("config", "Invalid repository");
|
|
@@ -17659,7 +17789,10 @@ async function pollOnePr({ id, repo, keys, client, now, ref, signal, cache }) {
|
|
|
17659
17789
|
owner,
|
|
17660
17790
|
name,
|
|
17661
17791
|
keys,
|
|
17662
|
-
signal
|
|
17792
|
+
signal,
|
|
17793
|
+
...ctx.feedbackCursors === void 0 ? {} : { feedbackCursors: ctx.feedbackCursors },
|
|
17794
|
+
...ctx.continuations === void 0 ? {} : { continuations: ctx.continuations },
|
|
17795
|
+
states: false
|
|
17663
17796
|
}, acc, ref.number, "pr0", response.data, scoped(response.errors, "pr0"), ref);
|
|
17664
17797
|
if (signal.aborted) throw new AdapterError("transient", "GitHub poll aborted");
|
|
17665
17798
|
rethrowLoneParseFailure(acc);
|
|
@@ -18645,9 +18778,19 @@ function runSource(entry, options, runnerStartMs) {
|
|
|
18645
18778
|
message: "The source is throttled until retryAt"
|
|
18646
18779
|
});
|
|
18647
18780
|
const aborted = () => abort.signal.aborted;
|
|
18648
|
-
let step = "
|
|
18781
|
+
let step = "context";
|
|
18649
18782
|
try {
|
|
18650
|
-
const
|
|
18783
|
+
const received = await untilAborted(core.context(source), abort.signal);
|
|
18784
|
+
if (aborted() || received === void 0) return err(stoppedError);
|
|
18785
|
+
const own = ({ ref: held }) => held.number === ref.number && held.repo.toLowerCase() === ref.repo.toLowerCase();
|
|
18786
|
+
const feedbackCursors = received.feedbackCursors?.filter(own) ?? [];
|
|
18787
|
+
const continuations = received.continuations?.filter(own) ?? [];
|
|
18788
|
+
step = "poll";
|
|
18789
|
+
const batch = await untilAborted(adapter.pollPr(ref, {
|
|
18790
|
+
signal: abort.signal,
|
|
18791
|
+
...feedbackCursors.length === 0 ? {} : { feedbackCursors },
|
|
18792
|
+
...continuations.length === 0 ? {} : { continuations }
|
|
18793
|
+
}), abort.signal);
|
|
18651
18794
|
if (aborted()) return err(stoppedError);
|
|
18652
18795
|
step = "batch";
|
|
18653
18796
|
const observedAt = iso$1(startMs);
|
|
@@ -18660,7 +18803,7 @@ function runSource(entry, options, runnerStartMs) {
|
|
|
18660
18803
|
prs: [ref],
|
|
18661
18804
|
tickets: [],
|
|
18662
18805
|
sessions: []
|
|
18663
|
-
}, parsed.data.entities) ? "does not answer the request" : parsed.data.complete ? "is marked complete" : parsed.data.cursor !== void 0 ? "carries a cursor" : value === void 0 ? "carries another item" : void 0;
|
|
18806
|
+
}, parsed.data.entities) ? "does not answer the request" : parsed.data.complete ? "is marked complete" : parsed.data.cursor !== void 0 ? "carries a cursor" : parsed.data.items.some((item) => item.kind === "pr" && item.continuation !== void 0) ? "carries a continuation" : value === void 0 ? "carries another item" : void 0;
|
|
18664
18807
|
if (!parsed.success || invalid !== void 0 || value === void 0) {
|
|
18665
18808
|
const error = new AdapterError("transient", `Invalid batch: ${invalid ?? "fails the batch schema"}`);
|
|
18666
18809
|
fail("batch", error, parsed.error?.issues.map((issue) => ({
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as renderMcpError, u as OPERATIONS, z as ERRORS } from "./src-
|
|
2
|
-
import { a as CliError, r as requestOperation } from "./client-
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-
|
|
1
|
+
import { m as renderMcpError, u as OPERATIONS, z as ERRORS } from "./src-DfgP2kkK.mjs";
|
|
2
|
+
import { a as CliError, r as requestOperation } from "./client-Rpyht8rc.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-RyoKekR8.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- A PR comment history the GitHub adapter is still reading back, per source and PR. A regular
|
|
2
|
+
-- poll's `pr` item asks core to hold it (`continuation` with an opaque `resume`, NULL once the
|
|
3
|
+
-- read reached the start of the PR) and core passes it back in `PollContext.continuations`.
|
|
4
|
+
-- `ref_key` is the PR's entity ref key; `feedback` is the JSON array of feedback entries read so
|
|
5
|
+
-- far, checked by zod on read. Core never parses `resume`. A row goes when an item states `null`
|
|
6
|
+
-- or when the source no longer has an unbanned link to the PR.
|
|
7
|
+
CREATE TABLE pr_continuation (
|
|
8
|
+
source TEXT NOT NULL REFERENCES source_state (source),
|
|
9
|
+
ref_key TEXT NOT NULL,
|
|
10
|
+
resume TEXT,
|
|
11
|
+
feedback TEXT NOT NULL,
|
|
12
|
+
PRIMARY KEY (source, ref_key)
|
|
13
|
+
) STRICT;
|
|
@@ -396,7 +396,12 @@ function isTimeZone(tz) {
|
|
|
396
396
|
return false;
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
|
-
/**
|
|
399
|
+
/**
|
|
400
|
+
* A Spur project can be listed under only one board project (#245). A session's actor is
|
|
401
|
+
* `agent:<spur project>/<session>`, with no board project in it; its roles are looked up by Spur
|
|
402
|
+
* project, and a curator ring picks a session by Spur project. The config is refused here rather
|
|
403
|
+
* than resolving roles per board project, so every session has one owning board project.
|
|
404
|
+
*/
|
|
400
405
|
function rejectSharedSpurProjects(items, ctx) {
|
|
401
406
|
const owners = /* @__PURE__ */ new Map();
|
|
402
407
|
items.forEach((project, i) => {
|
|
@@ -1907,7 +1912,7 @@ const count = (what) => z.int().min(0).describe(what);
|
|
|
1907
1912
|
const statusTaskSchema = taskViewSchema.extend({
|
|
1908
1913
|
shadowColumn: z.enum(COLUMN_IDS).optional().describe("Column the dispatcher works from in shadow mode: where the board would have the task. Present only while the project dispatcher is in shadow mode."),
|
|
1909
1914
|
shadowDiffers: z.boolean().optional().describe("Whether shadowColumn differs from column. Present only while the project dispatcher is in shadow mode."),
|
|
1910
|
-
state: z.string().min(1).describe("One line: ticket status, pull request states and session health
|
|
1915
|
+
state: z.string().min(1).describe("One line: ticket status, pull request states and session counts by health, an ended session counted as `ended (<reason>)`, joined by \"; \"."),
|
|
1911
1916
|
prCount: count("Number of effective pull request links."),
|
|
1912
1917
|
sessionCount: count("Number of effective session links."),
|
|
1913
1918
|
openBlocks: count("Number of open blocks on the task."),
|
|
@@ -3473,7 +3478,8 @@ const entityRefSchema = z.discriminatedUnion("kind", [
|
|
|
3473
3478
|
const batchItemSchema = z.discriminatedUnion("kind", [
|
|
3474
3479
|
z.strictObject({
|
|
3475
3480
|
kind: z.literal("pr").describe("Pull request facts."),
|
|
3476
|
-
facts: prFactsSchema
|
|
3481
|
+
facts: prFactsSchema,
|
|
3482
|
+
continuation: z.strictObject({ resume: sourceCursorSchema.nullable().describe("Opaque position to read further back from; null at the start of the PR.") }).nullable().optional().describe("Comment history core holds for the next poll (A10): omitted says nothing, null drops it, an object holds facts.feedback with resume.")
|
|
3477
3483
|
}),
|
|
3478
3484
|
z.strictObject({
|
|
3479
3485
|
kind: z.literal("ticket").describe("Ticket facts."),
|