spur-board 0.45.1 → 0.46.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/cli.mjs +3 -3
- package/dist/{client-DXseLMUK.mjs → client-BAwxhgyr.mjs} +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{config-DEL1XWGj.mjs → config-C0nYXJX4.mjs} +2 -2
- package/dist/daemon.mjs +226 -84
- package/dist/mcp.mjs +3 -3
- package/dist/migrations/0015_pr_continuation.sql +13 -0
- package/dist/{src-CfmtTvPO.mjs → src-DYURByVi.mjs} +3 -2
- 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-DYURByVi.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-BAwxhgyr.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-C0nYXJX4.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-DYURByVi.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-BAwxhgyr.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-DYURByVi.mjs";
|
|
2
|
+
import { a as CliError, t as fetchCatalogVersion } from "./client-BAwxhgyr.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-DYURByVi.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();
|
|
@@ -16879,11 +16957,12 @@ function feedbackAuthor(wire) {
|
|
|
16879
16957
|
type: wire.__typename === "Bot" ? "bot" : "user"
|
|
16880
16958
|
};
|
|
16881
16959
|
}
|
|
16882
|
-
function feedbackOf(reviews, comments) {
|
|
16960
|
+
function feedbackOf(reviews, comments, held) {
|
|
16883
16961
|
const entries = /* @__PURE__ */ new Map();
|
|
16884
16962
|
const add = (entry) => {
|
|
16885
16963
|
entries.set(`${entry.kind}:${entry.id}`, entry);
|
|
16886
16964
|
};
|
|
16965
|
+
for (const entry of held) if (entry.kind === "comment") add(entry);
|
|
16887
16966
|
for (const node of comments) add({
|
|
16888
16967
|
kind: "comment",
|
|
16889
16968
|
id: node.id,
|
|
@@ -16983,8 +17062,11 @@ function reviewer(wire) {
|
|
|
16983
17062
|
default: return assertNever(wire);
|
|
16984
17063
|
}
|
|
16985
17064
|
}
|
|
16986
|
-
/**
|
|
16987
|
-
|
|
17065
|
+
/**
|
|
17066
|
+
* `feedbackComplete` says whether the comments in `value`, with the `held` comments an earlier
|
|
17067
|
+
* poll read, reach back to the cursor or start.
|
|
17068
|
+
*/
|
|
17069
|
+
function normalizePr(repo, value, rule, feedbackComplete, held = []) {
|
|
16988
17070
|
const wire = parseWire(prWire, value, "Malformed GitHub PR response");
|
|
16989
17071
|
const checks = latestChecks(wire.statusCheckRollup?.contexts.nodes ?? []);
|
|
16990
17072
|
const state = wire.state === "MERGED" ? "merged" : wire.state === "CLOSED" ? "closed" : "open";
|
|
@@ -17023,7 +17105,7 @@ function normalizePr(repo, value, rule, feedbackComplete) {
|
|
|
17023
17105
|
ticketKeys: prKeys(rule, title, headBranch, closingRefs(wire.closingIssuesReferences)),
|
|
17024
17106
|
updatedAt: wire.updatedAt,
|
|
17025
17107
|
...state === "merged" && wire.mergedAt !== null ? { mergedAt: wire.mergedAt } : {},
|
|
17026
|
-
feedback: feedbackOf(wire.reviews.nodes, wire.comments.nodes),
|
|
17108
|
+
feedback: feedbackOf(wire.reviews.nodes, wire.comments.nodes, held),
|
|
17027
17109
|
feedbackComplete
|
|
17028
17110
|
};
|
|
17029
17111
|
const parsed = prFactsSchema.safeParse(facts);
|
|
@@ -17166,7 +17248,7 @@ function githubSources(config, options) {
|
|
|
17166
17248
|
client,
|
|
17167
17249
|
now: options.now,
|
|
17168
17250
|
ref,
|
|
17169
|
-
|
|
17251
|
+
ctx,
|
|
17170
17252
|
cache
|
|
17171
17253
|
})
|
|
17172
17254
|
}
|
|
@@ -17277,53 +17359,95 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
|
|
|
17277
17359
|
pr
|
|
17278
17360
|
};
|
|
17279
17361
|
}
|
|
17362
|
+
const at = (time) => Date.parse(time);
|
|
17363
|
+
/** Whether `nodes` hold the `cursor` entry or one strictly older than it. */
|
|
17280
17364
|
function reachesCursor(nodes, cursor) {
|
|
17281
17365
|
if (cursor === void 0) return false;
|
|
17282
|
-
const postedAt =
|
|
17283
|
-
return nodes.some((node) => node.id === cursor.id ||
|
|
17366
|
+
const postedAt = at(cursor.postedAt);
|
|
17367
|
+
return nodes.some((node) => node.id === cursor.id || at(node.createdAt) < postedAt);
|
|
17368
|
+
}
|
|
17369
|
+
const asNode = (entry) => ({
|
|
17370
|
+
id: entry.id,
|
|
17371
|
+
createdAt: entry.postedAt
|
|
17372
|
+
});
|
|
17373
|
+
/** The newest of `items` by `time`; the first one on a tie. */
|
|
17374
|
+
function newestOf(items, time) {
|
|
17375
|
+
return items.reduce((found, item) => found === void 0 || at(time(item)) > at(time(found)) ? item : found, void 0);
|
|
17376
|
+
}
|
|
17377
|
+
/** Reads one page of comments before `before`; undefined on a GraphQL error or a bad page. */
|
|
17378
|
+
async function commentPage(scope, number, before, budget) {
|
|
17379
|
+
const response = await scope.client.query(pageQuery("comments"), {
|
|
17380
|
+
owner: scope.owner,
|
|
17381
|
+
repo: scope.name,
|
|
17382
|
+
number,
|
|
17383
|
+
before
|
|
17384
|
+
}, scope.signal);
|
|
17385
|
+
budget(response.budget);
|
|
17386
|
+
rejectUnscoped(response.errors, ["repository"]);
|
|
17387
|
+
if (response.errors.length > 0) return void 0;
|
|
17388
|
+
const page = content(() => parseWire(commentsRootWire, response.data.repository, MALFORMED$2, ["data", "repository"]).pullRequest.comments);
|
|
17389
|
+
return page instanceof AdapterError ? void 0 : page;
|
|
17284
17390
|
}
|
|
17285
17391
|
/**
|
|
17286
17392
|
* Reads comments back from `first` to `cursor`, or to the start of the PR, within
|
|
17287
|
-
* `FEEDBACK_PAGES
|
|
17288
|
-
*
|
|
17393
|
+
* `FEEDBACK_PAGES` for both phases. Phase 1 pages back from the newest comment until it reaches
|
|
17394
|
+
* the cursor or the start, or joins the newest `held` comment; phase 2 then reads further back
|
|
17395
|
+
* from the held `resume`. A transient failure keeps the comments read so far as incomplete;
|
|
17396
|
+
* every other failure, and any failure after an abort, rejects the poll.
|
|
17289
17397
|
*/
|
|
17290
|
-
async function readFeedback(
|
|
17398
|
+
async function readFeedback(scope, number, first, cursor, held, budget) {
|
|
17291
17399
|
let nodes = first.nodes;
|
|
17292
|
-
let
|
|
17293
|
-
const
|
|
17400
|
+
let kept = [];
|
|
17401
|
+
const result = (complete, continuation) => ({
|
|
17402
|
+
nodes,
|
|
17403
|
+
held: kept,
|
|
17404
|
+
complete,
|
|
17405
|
+
continuation: scope.states ? continuation : void 0
|
|
17406
|
+
});
|
|
17407
|
+
const heldComments = held?.feedback.filter((entry) => entry.kind === "comment") ?? [];
|
|
17408
|
+
const newest = newestOf(heldComments, (entry) => entry.postedAt);
|
|
17409
|
+
let pages = 1;
|
|
17294
17410
|
try {
|
|
17295
|
-
|
|
17411
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17412
|
+
for (let page = first;; pages += 1) {
|
|
17413
|
+
if (!page.pageInfo.hasPreviousPage || reachesCursor(page.nodes, cursor)) return result(true, held === void 0 ? void 0 : null);
|
|
17414
|
+
if (reachesCursor(page.nodes, newest)) break;
|
|
17296
17415
|
const before = page.pageInfo.startCursor;
|
|
17297
|
-
if (!before || seen.has(before)
|
|
17298
|
-
|
|
17299
|
-
complete: false
|
|
17300
|
-
};
|
|
17416
|
+
if (!before || seen.has(before)) return result(false);
|
|
17417
|
+
if (pages >= FEEDBACK_PAGES) return result(false, { resume: sourceCursorSchema.parse(before) });
|
|
17301
17418
|
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;
|
|
17419
|
+
const next = await commentPage(scope, number, before, budget);
|
|
17420
|
+
if (next === void 0) return result(false);
|
|
17421
|
+
page = next;
|
|
17315
17422
|
nodes = [...page.nodes, ...nodes];
|
|
17316
17423
|
}
|
|
17317
|
-
return
|
|
17318
|
-
|
|
17319
|
-
|
|
17320
|
-
|
|
17424
|
+
if (held === void 0) return result(false);
|
|
17425
|
+
const listed = new Set(nodes.map((node) => node.id));
|
|
17426
|
+
const oldestRead = Math.min(...nodes.map((node) => at(node.createdAt)));
|
|
17427
|
+
kept = heldComments.filter((entry) => !listed.has(entry.id) && at(entry.postedAt) <= oldestRead);
|
|
17428
|
+
const history = () => [...nodes, ...kept.map(asNode)];
|
|
17429
|
+
const reached = () => reachesCursor(history(), cursor);
|
|
17430
|
+
let resume = held.resume;
|
|
17431
|
+
const resumed = /* @__PURE__ */ new Set();
|
|
17432
|
+
for (; resume !== null && !reached() && pages < FEEDBACK_PAGES; pages += 1) {
|
|
17433
|
+
resumed.add(resume);
|
|
17434
|
+
const page = await commentPage(scope, number, resume, budget);
|
|
17435
|
+
if (page === void 0) return result(false, null);
|
|
17436
|
+
const run = history();
|
|
17437
|
+
const ids = new Set(run.map((node) => node.id));
|
|
17438
|
+
const oldest = Math.min(...run.map((node) => at(node.createdAt)));
|
|
17439
|
+
const latest = newestOf(page.nodes, (node) => node.createdAt);
|
|
17440
|
+
if (latest !== void 0 && !ids.has(latest.id) && at(latest.createdAt) > oldest) return result(false, null);
|
|
17441
|
+
nodes = [...page.nodes, ...nodes];
|
|
17442
|
+
const start = page.pageInfo.startCursor;
|
|
17443
|
+
if (!page.pageInfo.hasPreviousPage) resume = null;
|
|
17444
|
+
else if (!start || resumed.has(start)) return result(false, null);
|
|
17445
|
+
else resume = sourceCursorSchema.parse(start);
|
|
17446
|
+
}
|
|
17447
|
+
return result(resume === null || reached(), { resume });
|
|
17321
17448
|
} catch (error) {
|
|
17322
|
-
if (signal.aborted) throw error;
|
|
17323
|
-
if (error instanceof AdapterError && error.kind === "transient") return
|
|
17324
|
-
nodes,
|
|
17325
|
-
complete: false
|
|
17326
|
-
};
|
|
17449
|
+
if (scope.signal.aborted) throw error;
|
|
17450
|
+
if (error instanceof AdapterError && error.kind === "transient") return result(false);
|
|
17327
17451
|
throw error;
|
|
17328
17452
|
}
|
|
17329
17453
|
}
|
|
@@ -17391,8 +17515,7 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
|
17391
17515
|
malformed(acc, full.error, ref);
|
|
17392
17516
|
return;
|
|
17393
17517
|
}
|
|
17394
|
-
const
|
|
17395
|
-
const feedback = await readFeedback(scope.client, full.pr.comments, scope.owner, scope.name, number, cursor, scope.signal, report);
|
|
17518
|
+
const feedback = await readFeedback(scope, number, full.pr.comments, entryFor(scope.feedbackCursors, scope.repo, number), entryFor(scope.continuations, scope.repo, number), report);
|
|
17396
17519
|
const pr = {
|
|
17397
17520
|
...full.pr,
|
|
17398
17521
|
comments: {
|
|
@@ -17400,14 +17523,16 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
|
17400
17523
|
nodes: feedback.nodes
|
|
17401
17524
|
}
|
|
17402
17525
|
};
|
|
17403
|
-
const facts = content(() => normalizePr(ref?.repo ?? scope.repo, pr, scope.keys, feedback.complete));
|
|
17526
|
+
const facts = content(() => normalizePr(ref?.repo ?? scope.repo, pr, scope.keys, feedback.complete, feedback.held));
|
|
17404
17527
|
if (facts instanceof AdapterError) {
|
|
17405
17528
|
malformed(acc, facts, ref);
|
|
17406
17529
|
return;
|
|
17407
17530
|
}
|
|
17531
|
+
const { continuation } = feedback;
|
|
17408
17532
|
acc.items.push({
|
|
17409
17533
|
kind: "pr",
|
|
17410
|
-
facts
|
|
17534
|
+
facts,
|
|
17535
|
+
...continuation === void 0 ? {} : { continuation }
|
|
17411
17536
|
});
|
|
17412
17537
|
if (ref) acc.entities.push({
|
|
17413
17538
|
ref,
|
|
@@ -17415,8 +17540,9 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
|
17415
17540
|
});
|
|
17416
17541
|
return facts;
|
|
17417
17542
|
}
|
|
17418
|
-
|
|
17419
|
-
|
|
17543
|
+
/** The entry of one PR in a per-PR list of the poll context. */
|
|
17544
|
+
function entryFor(entries, repo, number) {
|
|
17545
|
+
return entries?.find((entry) => entry.ref.number === number && entry.ref.repo.toLowerCase() === repo.toLowerCase());
|
|
17420
17546
|
}
|
|
17421
17547
|
function closingSelected(keys) {
|
|
17422
17548
|
return keys.type === "issues" && keys.sources.includes("closing");
|
|
@@ -17555,7 +17681,7 @@ async function pollRepository({ id, repo, login, keys, client, now, ctx, reserve
|
|
|
17555
17681
|
if (!discovery.ok) acc.complete = false;
|
|
17556
17682
|
const { found } = discovery;
|
|
17557
17683
|
const entries = await readIndex(request, acc, numbers);
|
|
17558
|
-
const cursorKey = (number) => JSON.stringify(
|
|
17684
|
+
const cursorKey = (number) => JSON.stringify([entryFor(ctx.feedbackCursors, repo, number) ?? "none", entryFor(ctx.continuations, repo, number) ?? "none"]);
|
|
17559
17685
|
const changed = [];
|
|
17560
17686
|
for (const number of numbers) {
|
|
17561
17687
|
const facts = reusable(cache.get(number), entries.get(number), cursorKey(number), now());
|
|
@@ -17581,7 +17707,9 @@ async function pollRepository({ id, repo, login, keys, client, now, ctx, reserve
|
|
|
17581
17707
|
name,
|
|
17582
17708
|
keys,
|
|
17583
17709
|
signal: ctx.signal,
|
|
17584
|
-
...ctx.feedbackCursors === void 0 ? {} : { feedbackCursors: ctx.feedbackCursors }
|
|
17710
|
+
...ctx.feedbackCursors === void 0 ? {} : { feedbackCursors: ctx.feedbackCursors },
|
|
17711
|
+
...ctx.continuations === void 0 ? {} : { continuations: ctx.continuations },
|
|
17712
|
+
states: true
|
|
17585
17713
|
};
|
|
17586
17714
|
let discoveredOk = true;
|
|
17587
17715
|
const unread = (chunk) => {
|
|
@@ -17642,7 +17770,8 @@ async function pollRepository({ id, repo, login, keys, client, now, ctx, reserve
|
|
|
17642
17770
|
...acc.budget === void 0 ? {} : { budget: acc.budget }
|
|
17643
17771
|
};
|
|
17644
17772
|
}
|
|
17645
|
-
async function pollOnePr({ id, repo, keys, client, now, ref,
|
|
17773
|
+
async function pollOnePr({ id, repo, keys, client, now, ref, ctx, cache }) {
|
|
17774
|
+
const { signal } = ctx;
|
|
17646
17775
|
const observedAt = new Date(now()).toISOString();
|
|
17647
17776
|
const [owner, name] = repo.split("/");
|
|
17648
17777
|
if (!owner || !name) throw new AdapterError("config", "Invalid repository");
|
|
@@ -17659,7 +17788,10 @@ async function pollOnePr({ id, repo, keys, client, now, ref, signal, cache }) {
|
|
|
17659
17788
|
owner,
|
|
17660
17789
|
name,
|
|
17661
17790
|
keys,
|
|
17662
|
-
signal
|
|
17791
|
+
signal,
|
|
17792
|
+
...ctx.feedbackCursors === void 0 ? {} : { feedbackCursors: ctx.feedbackCursors },
|
|
17793
|
+
...ctx.continuations === void 0 ? {} : { continuations: ctx.continuations },
|
|
17794
|
+
states: false
|
|
17663
17795
|
}, acc, ref.number, "pr0", response.data, scoped(response.errors, "pr0"), ref);
|
|
17664
17796
|
if (signal.aborted) throw new AdapterError("transient", "GitHub poll aborted");
|
|
17665
17797
|
rethrowLoneParseFailure(acc);
|
|
@@ -18645,9 +18777,19 @@ function runSource(entry, options, runnerStartMs) {
|
|
|
18645
18777
|
message: "The source is throttled until retryAt"
|
|
18646
18778
|
});
|
|
18647
18779
|
const aborted = () => abort.signal.aborted;
|
|
18648
|
-
let step = "
|
|
18780
|
+
let step = "context";
|
|
18649
18781
|
try {
|
|
18650
|
-
const
|
|
18782
|
+
const received = await untilAborted(core.context(source), abort.signal);
|
|
18783
|
+
if (aborted() || received === void 0) return err(stoppedError);
|
|
18784
|
+
const own = ({ ref: held }) => held.number === ref.number && held.repo.toLowerCase() === ref.repo.toLowerCase();
|
|
18785
|
+
const feedbackCursors = received.feedbackCursors?.filter(own) ?? [];
|
|
18786
|
+
const continuations = received.continuations?.filter(own) ?? [];
|
|
18787
|
+
step = "poll";
|
|
18788
|
+
const batch = await untilAborted(adapter.pollPr(ref, {
|
|
18789
|
+
signal: abort.signal,
|
|
18790
|
+
...feedbackCursors.length === 0 ? {} : { feedbackCursors },
|
|
18791
|
+
...continuations.length === 0 ? {} : { continuations }
|
|
18792
|
+
}), abort.signal);
|
|
18651
18793
|
if (aborted()) return err(stoppedError);
|
|
18652
18794
|
step = "batch";
|
|
18653
18795
|
const observedAt = iso$1(startMs);
|
|
@@ -18660,7 +18802,7 @@ function runSource(entry, options, runnerStartMs) {
|
|
|
18660
18802
|
prs: [ref],
|
|
18661
18803
|
tickets: [],
|
|
18662
18804
|
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;
|
|
18805
|
+
}, 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
18806
|
if (!parsed.success || invalid !== void 0 || value === void 0) {
|
|
18665
18807
|
const error = new AdapterError("transient", `Invalid batch: ${invalid ?? "fails the batch schema"}`);
|
|
18666
18808
|
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-DYURByVi.mjs";
|
|
2
|
+
import { a as CliError, r as requestOperation } from "./client-BAwxhgyr.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-C0nYXJX4.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;
|
|
@@ -1907,7 +1907,7 @@ const count = (what) => z.int().min(0).describe(what);
|
|
|
1907
1907
|
const statusTaskSchema = taskViewSchema.extend({
|
|
1908
1908
|
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
1909
|
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
|
|
1910
|
+
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
1911
|
prCount: count("Number of effective pull request links."),
|
|
1912
1912
|
sessionCount: count("Number of effective session links."),
|
|
1913
1913
|
openBlocks: count("Number of open blocks on the task."),
|
|
@@ -3473,7 +3473,8 @@ const entityRefSchema = z.discriminatedUnion("kind", [
|
|
|
3473
3473
|
const batchItemSchema = z.discriminatedUnion("kind", [
|
|
3474
3474
|
z.strictObject({
|
|
3475
3475
|
kind: z.literal("pr").describe("Pull request facts."),
|
|
3476
|
-
facts: prFactsSchema
|
|
3476
|
+
facts: prFactsSchema,
|
|
3477
|
+
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
3478
|
}),
|
|
3478
3479
|
z.strictObject({
|
|
3479
3480
|
kind: z.literal("ticket").describe("Ticket facts."),
|