spur-board 0.29.0 → 0.30.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 CHANGED
@@ -1,6 +1,6 @@
1
- import { G as configSchema, K as requiredSecretKeys, P as ERRORS, l as roleCanUseOperation, q as SLACK_BOT_SCOPES, r as SYSTEMD_SERVICE_SETTINGS, u as OPERATIONS } from "./src-XNs3RhSm.mjs";
2
- import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-BHnD83EW.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./config-CoUN_LCM.mjs";
1
+ import { G as configSchema, K as requiredSecretKeys, P as ERRORS, l as roleCanUseOperation, q as SLACK_BOT_SCOPES, r as SYSTEMD_SERVICE_SETTINGS, u as OPERATIONS } from "./src-B63VaSzU.mjs";
2
+ import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-DtDNMMO-.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./config-D3ltZ-MU.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 { I as errorContextSchema, L as errorEnvelopeSchema, P as ERRORS, f as renderJsonError, z as successEnvelopeSchema } from "./src-XNs3RhSm.mjs";
1
+ import { I as errorContextSchema, L as errorEnvelopeSchema, P as ERRORS, f as renderJsonError, z as successEnvelopeSchema } from "./src-B63VaSzU.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 { n as requestOperation, r as requestTokenEnrollment, t as fetchCatalogVersion } from "./client-BHnD83EW.mjs";
1
+ import { n as requestOperation, r as requestTokenEnrollment, t as fetchCatalogVersion } from "./client-DtDNMMO-.mjs";
2
2
  export { fetchCatalogVersion, requestOperation, requestTokenEnrollment };
@@ -1,5 +1,5 @@
1
- import { G as configSchema, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-XNs3RhSm.mjs";
2
- import { i as CliError, t as fetchCatalogVersion } from "./client-BHnD83EW.mjs";
1
+ import { G as configSchema, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-B63VaSzU.mjs";
2
+ import { i as CliError, t as fetchCatalogVersion } from "./client-DtDNMMO-.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 { A as errorCodeOf, C as SESSION_STATUSES, D as ticketFactsSchema, E as sessionFactsSchema, F as err, G as configSchema, K as requiredSecretKeys, M as parseRef$1, N as taskKeySchema, O as actorIdSchema, P as ERRORS, R as ok, S as SESSION_HEALTH_STATES, T as prRefSchema, U as DEFAULT_SLACK_COMMAND, V as DEFAULT_LINK, W as RESERVED_PROJECT, _ as interactionRefSchema, a as batchSchema, b as EVENT_KINDS, c as buildCatalogSnapshot, d as renderHttpProblem, g as inboundEventSchema, h as conversationRefSchema, i as AdapterError, j as parseActorId, k as encodeActorId, l as roleCanUseOperation, m as SPACE_IDS, n as BOARD_TICK_MS, o as entityRefSchema, q as SLACK_BOT_SCOPES, s as sourceCursorSchema, t as assertNever, u as OPERATIONS, v as messageRefSchema, w as prFactsSchema, x as eventPayloadSchemas, y as userIdSchema, z as successEnvelopeSchema } from "./src-XNs3RhSm.mjs";
1
+ import { A as errorCodeOf, C as SESSION_STATUSES, D as ticketFactsSchema, E as sessionFactsSchema, F as err, G as configSchema, K as requiredSecretKeys, M as parseRef$1, N as taskKeySchema, O as actorIdSchema, P as ERRORS, R as ok, S as SESSION_HEALTH_STATES, T as prRefSchema, U as DEFAULT_SLACK_COMMAND, V as DEFAULT_LINK, W as RESERVED_PROJECT, _ as interactionRefSchema, a as batchSchema, b as EVENT_KINDS, c as buildCatalogSnapshot, d as renderHttpProblem, g as inboundEventSchema, h as conversationRefSchema, i as AdapterError, j as parseActorId, k as encodeActorId, l as roleCanUseOperation, m as SPACE_IDS, n as BOARD_TICK_MS, o as entityRefSchema, q as SLACK_BOT_SCOPES, s as sourceCursorSchema, t as assertNever, u as OPERATIONS, v as messageRefSchema, w as prFactsSchema, x as eventPayloadSchemas, y as userIdSchema, z as successEnvelopeSchema } from "./src-B63VaSzU.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import { closeSync, existsSync, fstatSync, fsyncSync, ftruncateSync, linkSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeSync } from "node:fs";
@@ -8191,32 +8191,137 @@ async function dispatchOperation(deps, id, input, actor, key) {
8191
8191
  return operation.kind === "query" ? createQuery(deps)(handler, input, actor) : createApply(deps)(handler, input, actor, key);
8192
8192
  }
8193
8193
  //#endregion
8194
- //#region ../core/src/app/item-raise.ts
8195
- const NO_FEED = /* @__PURE__ */ new Set([
8194
+ //#region ../core/src/domain/fromYou.ts
8195
+ /** Every operator item kind; `ITEM_POLICY` must give each one a policy. */
8196
+ const ITEM_KINDS = [
8197
+ "token_request",
8198
+ "post_blocked",
8196
8199
  "post_failed",
8200
+ "transport_health",
8197
8201
  "answer_undelivered",
8198
- "transport_health"
8199
- ]);
8202
+ "worker_not_reading",
8203
+ "answer_author_unavailable",
8204
+ "inbound_failure",
8205
+ "inbound_gap",
8206
+ "board_observation",
8207
+ "worker_ended"
8208
+ ];
8209
+ const ITEM_POLICY = {
8210
+ token_request: {
8211
+ retry: "none",
8212
+ feed: true,
8213
+ priority: 4,
8214
+ buttons: "approve_deny",
8215
+ reconciled: false
8216
+ },
8217
+ post_blocked: {
8218
+ retry: "never_sent",
8219
+ feed: true,
8220
+ priority: 4,
8221
+ buttons: "item",
8222
+ reconciled: false
8223
+ },
8224
+ post_failed: {
8225
+ retry: "requeue_post",
8226
+ feed: false,
8227
+ priority: 1,
8228
+ buttons: "item",
8229
+ reconciled: true
8230
+ },
8231
+ transport_health: {
8232
+ retry: "probe_transport",
8233
+ feed: false,
8234
+ priority: 1,
8235
+ buttons: "item",
8236
+ reconciled: false
8237
+ },
8238
+ answer_undelivered: {
8239
+ retry: "restart_ring",
8240
+ feed: false,
8241
+ priority: 4,
8242
+ buttons: "item",
8243
+ reconciled: false
8244
+ },
8245
+ worker_not_reading: {
8246
+ retry: "restart_ring",
8247
+ feed: true,
8248
+ priority: 4,
8249
+ buttons: "item",
8250
+ reconciled: false
8251
+ },
8252
+ answer_author_unavailable: {
8253
+ retry: "none",
8254
+ feed: true,
8255
+ priority: 4,
8256
+ buttons: "item",
8257
+ reconciled: false
8258
+ },
8259
+ inbound_failure: {
8260
+ retry: "reapply_inbound",
8261
+ feed: true,
8262
+ priority: 4,
8263
+ buttons: "item",
8264
+ reconciled: false
8265
+ },
8266
+ inbound_gap: {
8267
+ retry: "none",
8268
+ feed: true,
8269
+ priority: 4,
8270
+ buttons: "item",
8271
+ reconciled: false
8272
+ },
8273
+ board_observation: {
8274
+ retry: "none",
8275
+ feed: true,
8276
+ priority: 4,
8277
+ buttons: "item",
8278
+ reconciled: true
8279
+ },
8280
+ worker_ended: {
8281
+ retry: "none",
8282
+ feed: false,
8283
+ priority: 4,
8284
+ buttons: "item",
8285
+ reconciled: true
8286
+ }
8287
+ };
8288
+ /** Guards a stored kind: the column is free text and old or hand-written rows may hold others. */
8289
+ function isItemKind(kind) {
8290
+ return Object.hasOwn(ITEM_POLICY, kind);
8291
+ }
8292
+ /** Whether the kind's feed line and status entry offer Retry. */
8293
+ function hasRetryButton(kind) {
8294
+ const retry = ITEM_POLICY[kind].retry;
8295
+ return retry === "requeue_post" || retry === "restart_ring" || retry === "reapply_inbound" || retry === "probe_transport";
8296
+ }
8297
+ /** The kinds `reconcileItems` owns: it clears an active one whose candidate is gone. */
8298
+ const RECONCILED_KINDS = ITEM_KINDS.filter((kind) => ITEM_POLICY[kind].reconciled);
8299
+ function fingerprint(candidate) {
8300
+ return createHash("sha256").update(JSON.stringify([
8301
+ candidate.key,
8302
+ candidate.summary,
8303
+ candidate.source,
8304
+ candidate.revision ?? null
8305
+ ])).digest("hex");
8306
+ }
8307
+ /** Stable ordering within priority, then by item identity. */
8308
+ function orderItems(items) {
8309
+ return [...items].sort((left, right) => left.priority - right.priority || left.key.localeCompare(right.key));
8310
+ }
8200
8311
  async function journal$3(trx, item, kind, at, rule, actor = "system") {
8201
8312
  await emit(trx, kind, (item.task_id === null ? void 0 : await trx.selectFrom("task").select(["project"]).where("id", "=", item.task_id).executeTakeFirstOrThrow())?.project ?? "_board", item.task_id, at.toISOString(), {
8202
8313
  item: `I${String(item.id)}`,
8203
8314
  ...kind === "from_you_raised" && rule !== void 0 ? { rule } : {}
8204
8315
  }, actor);
8205
8316
  }
8206
- /** Kinds whose item has a retry action besides `delivery:<id>` (see `items.ts`). */
8207
- const RETRY_KINDS = /* @__PURE__ */ new Set([
8208
- "answer_undelivered",
8209
- "worker_not_reading",
8210
- "inbound_failure"
8211
- ]);
8212
8317
  /** Every item line gets Close, after Retry when its kind has a retry action. */
8213
- function itemActions(item) {
8214
- const id = String(item.id);
8318
+ function itemActions(itemId, kind) {
8319
+ const id = String(itemId);
8215
8320
  const close = {
8216
8321
  id: `item:${id}:close`,
8217
8322
  label: "Close"
8218
8323
  };
8219
- if (item.kind === "token_request") return [
8324
+ if (ITEM_POLICY[kind].buttons === "approve_deny") return [
8220
8325
  {
8221
8326
  id: `token:${id}:approve`,
8222
8327
  label: "Approve"
@@ -8227,7 +8332,7 @@ function itemActions(item) {
8227
8332
  },
8228
8333
  close
8229
8334
  ];
8230
- return item.item_key.startsWith("delivery:") || RETRY_KINDS.has(item.kind) ? [{
8335
+ return hasRetryButton(kind) ? [{
8231
8336
  id: `item:${id}:retry`,
8232
8337
  label: "Retry"
8233
8338
  }, close] : [close];
@@ -8254,11 +8359,11 @@ async function raiseItemWith(trx, input, writeLine) {
8254
8359
  fingerprint: input.fingerprint ?? null,
8255
8360
  fact_at: input.factAt ?? null,
8256
8361
  source: input.source ?? null,
8257
- priority: input.priority ?? null,
8362
+ priority: input.priority ?? ITEM_POLICY[input.kind].priority,
8258
8363
  inbound_event_json: null
8259
8364
  }).returningAll().executeTakeFirstOrThrow();
8260
8365
  await journal$3(trx, item, "from_you_raised", input.at, input.rule);
8261
- if (!NO_FEED.has(item.kind) && !input.suppressFeed) {
8366
+ if (ITEM_POLICY[input.kind].feed) {
8262
8367
  const key = (item.task_id === null ? null : await trx.selectFrom("task").select("key").where("id", "=", item.task_id).executeTakeFirstOrThrow())?.key ?? "spur-board";
8263
8368
  const line = await writeLine(trx, {
8264
8369
  itemId: item.id,
@@ -8269,7 +8374,7 @@ async function raiseItemWith(trx, input, writeLine) {
8269
8374
  title: `${key}: ${item.text}`,
8270
8375
  url: item.url,
8271
8376
  taskId: item.task_id,
8272
- actions: itemActions(item),
8377
+ actions: itemActions(item.id, input.kind),
8273
8378
  at: input.at
8274
8379
  });
8275
8380
  if (line !== null) item = await trx.updateTable("operator_item").set({ line_outbox_id: line }).where("id", "=", item.id).returningAll().executeTakeFirstOrThrow();
@@ -10194,7 +10299,7 @@ async function archiveTask(trx, input) {
10194
10299
  };
10195
10300
  const blocks = await trx.selectFrom("block").selectAll().where("task_id", "=", task.id).where("state", "=", "open").orderBy("id").execute();
10196
10301
  for (const block of blocks) await closeOpenBlock(trx, task, block, ctx, "archived", null);
10197
- const items = await trx.selectFrom("operator_item").select("id").where("kind", "=", "board_observation").where("task_id", "=", task.id).where("cleared_at", "is", null).orderBy("id").execute();
10302
+ const items = await trx.selectFrom("operator_item").select("id").where("kind", "in", RECONCILED_KINDS).where("task_id", "=", task.id).where("cleared_at", "is", null).orderBy("id").execute();
10198
10303
  for (const item of items) await clearItem(trx, item.id, new Date(at), actor);
10199
10304
  const comments = await trx.selectFrom("comment").select("id").where("task_id", "=", task.id).execute();
10200
10305
  await trx.updateTable("outbox").set({
@@ -10310,20 +10415,6 @@ function createMembershipMutations(config) {
10310
10415
  };
10311
10416
  }
10312
10417
  //#endregion
10313
- //#region ../core/src/domain/fromYou.ts
10314
- function fingerprint(candidate) {
10315
- return createHash("sha256").update(JSON.stringify([
10316
- candidate.key,
10317
- candidate.summary,
10318
- candidate.source,
10319
- candidate.revision ?? null
10320
- ])).digest("hex");
10321
- }
10322
- /** Stable ordering within priority, then by item identity. */
10323
- function orderItems(items) {
10324
- return [...items].sort((left, right) => left.priority - right.priority || left.key.localeCompare(right.key));
10325
- }
10326
- //#endregion
10327
10418
  //#region ../core/src/app/sender.ts
10328
10419
  /**
10329
10420
  * Spur refused a doorbell for good (a permanent 4xx): the sender stops ringing and ends the ring
@@ -10384,8 +10475,6 @@ async function syncTransportItem(trx, gateway, at) {
10384
10475
  url: "",
10385
10476
  taskId: null,
10386
10477
  blockId: null,
10387
- priority: 1,
10388
- suppressFeed: true,
10389
10478
  at
10390
10479
  });
10391
10480
  if (item.text !== text) await trx.updateTable("operator_item").set({ text }).where("id", "=", item.id).execute();
@@ -10977,7 +11066,6 @@ function createSender(options) {
10977
11066
  }
10978
11067
  //#endregion
10979
11068
  //#region ../core/src/app/items.ts
10980
- const DOORBELL_ITEM = /^(?:answer_undelivered|worker_not_reading):(.+)$/;
10981
11069
  async function loadItem(trx, id) {
10982
11070
  const item = await trx.selectFrom("operator_item").selectAll().where("id", "=", Number(id.slice(1))).executeTakeFirst();
10983
11071
  if (item === void 0) throw new CommandError("not_found", "Check the item ID.");
@@ -10988,7 +11076,7 @@ async function loadItem(trx, id) {
10988
11076
  }
10989
11077
  /** The task a `delivery:<outbox id>` item's row belongs to; the item itself has no task. */
10990
11078
  async function deliveryTask(trx, item) {
10991
- if (!item.item_key.startsWith("delivery:")) return void 0;
11079
+ if (item.kind !== "post_failed") return void 0;
10992
11080
  const row = await trx.selectFrom("outbox").select([
10993
11081
  "kind",
10994
11082
  "dedupe_key",
@@ -11016,25 +11104,34 @@ function notApplicable(hint) {
11016
11104
  * except a retry on a transport item, which the sender clears when the transport is back.
11017
11105
  */
11018
11106
  function createItemMutations(deps) {
11107
+ /** Runs the retry behind the item's kind; false when the item must stay raised. */
11019
11108
  async function retryAction(trx, item, at) {
11020
11109
  const closeHint = `close it with \`board item close I${String(item.id)}\`.`;
11021
- if (item.item_key.startsWith("delivery:")) {
11022
- if (await requeuePostFailed(trx, [Number(item.item_key.slice(9))], at) === 0) throw notApplicable("The delivery is no longer failed.");
11023
- return;
11024
- }
11025
- const doorbell = DOORBELL_ITEM.exec(item.item_key);
11026
- if (doorbell?.[1] !== void 0) {
11027
- await restartNotification(trx, doorbell[1], new Date(at));
11028
- return;
11029
- }
11030
- if (item.kind === "inbound_failure") {
11031
- const reapply = deps.reapplyInbound?.();
11032
- if (reapply === void 0) throw notApplicable("Slack inbound is not running; close the item instead.");
11033
- await reapply(trx, item.id, at);
11034
- return;
11110
+ const noAction = notApplicable(`This item has no retry action; ${closeHint}`);
11111
+ const action = isItemKind(item.kind) ? ITEM_POLICY[item.kind].retry : "none";
11112
+ switch (action) {
11113
+ case "requeue_post":
11114
+ if (await requeuePostFailed(trx, [Number(item.item_key.slice(9))], at) === 0) throw notApplicable("The delivery is no longer failed.");
11115
+ return true;
11116
+ case "restart_ring": {
11117
+ const prefix = `${item.kind}:`;
11118
+ if (!item.item_key.startsWith(prefix) || item.item_key.length === prefix.length) throw noAction;
11119
+ await restartNotification(trx, item.item_key.slice(prefix.length), new Date(at));
11120
+ return true;
11121
+ }
11122
+ case "reapply_inbound": {
11123
+ const reapply = deps.reapplyInbound?.();
11124
+ if (reapply === void 0) throw notApplicable("Slack inbound is not running; close the item instead.");
11125
+ await reapply(trx, item.id, at);
11126
+ return true;
11127
+ }
11128
+ case "probe_transport":
11129
+ if (await retryTransport(trx, item.item_key.slice(10), at) === 0) throw notApplicable("No transport outage is recorded; the item clears on its own.");
11130
+ return false;
11131
+ case "never_sent": throw notApplicable(`The blocked text is never sent; ${closeHint}`);
11132
+ case "none": throw noAction;
11133
+ default: return assertNever(action);
11035
11134
  }
11036
- if (item.kind === "post_blocked") throw notApplicable(`The blocked text is never sent; ${closeHint}`);
11037
- throw notApplicable(`This item has no retry action; ${closeHint}`);
11038
11135
  }
11039
11136
  return {
11040
11137
  retry: {
@@ -11044,12 +11141,7 @@ function createItemMutations(deps) {
11044
11141
  const { item, task } = await loadItem(trx, input.item);
11045
11142
  if ((task ?? await deliveryTask(trx, item))?.membership === "archived") throw new CommandError("task_archived", "Add the task again before retrying its item.");
11046
11143
  if (item.cleared_at !== null) throw notApplicable("The item is already cleared.");
11047
- if (item.kind === "transport_health") {
11048
- if (await retryTransport(trx, item.item_key.slice(10), ctx.at) === 0) throw notApplicable("No transport outage is recorded; the item clears on its own.");
11049
- return view(item, task);
11050
- }
11051
- await retryAction(trx, item, ctx.at);
11052
- await clearItem(trx, item.id, new Date(ctx.at), ctx.actor);
11144
+ if (await retryAction(trx, item, ctx.at)) await clearItem(trx, item.id, new Date(ctx.at), ctx.actor);
11053
11145
  return view(item, task);
11054
11146
  }
11055
11147
  },
@@ -11061,11 +11153,8 @@ function createItemMutations(deps) {
11061
11153
  if (item.cleared_at === null) {
11062
11154
  const hash = item.fingerprint ?? fingerprint({
11063
11155
  key: item.item_key,
11064
- taskId: item.task_id,
11065
11156
  summary: item.text,
11066
- factAt: item.fact_at,
11067
11157
  source: item.source,
11068
- priority: item.priority ?? 0,
11069
11158
  revision: null
11070
11159
  });
11071
11160
  await trx.insertInto("dismissal").values({
@@ -11078,7 +11167,7 @@ function createItemMutations(deps) {
11078
11167
  dismissed_by: ctx.actor,
11079
11168
  dismissed_at: ctx.at
11080
11169
  })).execute();
11081
- if (item.item_key.startsWith("delivery:")) await trx.updateTable("outbox").set({
11170
+ if (item.kind === "post_failed") await trx.updateTable("outbox").set({
11082
11171
  state: "dead",
11083
11172
  last_error: `closed by ${ctx.actor} (I${String(item.id)})`
11084
11173
  }).where("id", "=", Number(item.item_key.slice(9))).where("state", "=", "post_failed").execute();
@@ -11966,8 +12055,10 @@ async function reconcileItems(trx, config, now, spurComplete) {
11966
12055
  const sourceById = new Map(sources.map((state) => [state.source, state]));
11967
12056
  for (const source of sources) {
11968
12057
  if (source.blind_reason === null) continue;
12058
+ if (source.blind_reason === "stale" && source.source !== "spur") continue;
11969
12059
  candidates.push({
11970
12060
  key: `source:${source.source}`,
12061
+ kind: "board_observation",
11971
12062
  taskId: null,
11972
12063
  summary: `${source.source}: ${source.blind_message ?? source.blind_reason}`,
11973
12064
  factAt: source.observed_at,
@@ -11979,7 +12070,7 @@ async function reconcileItems(trx, config, now, spurComplete) {
11979
12070
  const taskById = new Map(tasks.map((task) => [task.id, task]));
11980
12071
  const misses = await trx.selectFrom("source_miss").selectAll().execute();
11981
12072
  for (const miss of misses) {
11982
- if (miss.outcome !== "not_found" && miss.outcome !== "no_access" && miss.gone !== 1) continue;
12073
+ if (miss.gone !== 1) continue;
11983
12074
  const ref = JSON.parse(miss.ref);
11984
12075
  if (ref.kind === "pr" && ref.repo !== void 0 && ref.number !== void 0) {
11985
12076
  const links = await trx.selectFrom("link").select("task_id").where("entity", "=", "pr").where(sql`lower(repo) = ${ref.repo.toLowerCase()}`).where("number", "=", ref.number).execute();
@@ -11988,6 +12079,7 @@ async function reconcileItems(trx, config, now, spurComplete) {
11988
12079
  if (task === void 0) continue;
11989
12080
  candidates.push({
11990
12081
  key: `pr-outcome:${String(task.id)}:${ref.repo}#${String(ref.number)}`,
12082
+ kind: "board_observation",
11991
12083
  taskId: task.id,
11992
12084
  summary: `${task.key}: linked pull request ${miss.outcome ?? "gone"}`,
11993
12085
  factAt: sourceById.get(miss.source)?.observed_at ?? null,
@@ -11998,10 +12090,11 @@ async function reconcileItems(trx, config, now, spurComplete) {
11998
12090
  continue;
11999
12091
  }
12000
12092
  if (ref.kind !== "ticket") continue;
12001
- const task = tasks.find((entry) => entry.key === ref.key && (entry.manual_include === 1 || miss.outcome === "no_access" || miss.gone === 1));
12093
+ const task = tasks.find((entry) => entry.key === ref.key);
12002
12094
  if (task === void 0) continue;
12003
12095
  candidates.push({
12004
12096
  key: `lookup:${String(task.id)}`,
12097
+ kind: "board_observation",
12005
12098
  taskId: task.id,
12006
12099
  summary: `${task.key}: tracker returned ${miss.outcome ?? "gone"}`,
12007
12100
  factAt: sourceById.get(miss.source)?.observed_at ?? null,
@@ -12011,6 +12104,7 @@ async function reconcileItems(trx, config, now, spurComplete) {
12011
12104
  }
12012
12105
  for (const task of tasks) if (task.membership === "out_of_filter") candidates.push({
12013
12106
  key: `filter:${String(task.id)}`,
12107
+ kind: "board_observation",
12014
12108
  taskId: task.id,
12015
12109
  summary: `${task.key} left the tracker filter while work is still linked`,
12016
12110
  factAt: task.last_change_at,
@@ -12025,6 +12119,7 @@ async function reconcileItems(trx, config, now, spurComplete) {
12025
12119
  if (task === void 0) continue;
12026
12120
  if (block.addressee_role === "operator" && block.author !== "operator" && !blockedIds.has(block.id)) candidates.push({
12027
12121
  key: `operator-block:${String(block.id)}`,
12122
+ kind: "board_observation",
12028
12123
  taskId: task.id,
12029
12124
  summary: `${task.key}: ${block.reason}`,
12030
12125
  factAt: block.created_at,
@@ -12033,6 +12128,7 @@ async function reconcileItems(trx, config, now, spurComplete) {
12033
12128
  });
12034
12129
  if (now - Date.parse(block.created_at) >= config.thresholds.blockOpenMs) candidates.push({
12035
12130
  key: `block:${String(block.id)}`,
12131
+ kind: "board_observation",
12036
12132
  taskId: task.id,
12037
12133
  summary: `${task.key}: block has been open for more than a day`,
12038
12134
  factAt: block.created_at,
@@ -12043,12 +12139,12 @@ async function reconcileItems(trx, config, now, spurComplete) {
12043
12139
  const failedDeliveries = await trx.selectFrom("outbox").select(["id", "kind"]).where("state", "=", "post_failed").execute();
12044
12140
  for (const delivery of failedDeliveries) candidates.push({
12045
12141
  key: `delivery:${String(delivery.id)}`,
12142
+ kind: "post_failed",
12046
12143
  taskId: null,
12047
12144
  summary: `Delivery failed: ${delivery.kind}`,
12048
12145
  factAt: null,
12049
12146
  source: null,
12050
- priority: 1,
12051
- suppressFeed: delivery.kind === "feed.line" || delivery.kind === "feed.line.edit"
12147
+ priority: ITEM_POLICY.post_failed.priority
12052
12148
  });
12053
12149
  const subjects = (await trx.selectFrom("link").innerJoin("session_snapshot", "session_snapshot.id", "link.session_id").select([
12054
12150
  "link.task_id",
@@ -12091,15 +12187,6 @@ async function reconcileItems(trx, config, now, spurComplete) {
12091
12187
  key: "host_load_episode",
12092
12188
  value: toJson(episodeSchema, health.episode)
12093
12189
  }).onConflict((oc) => oc.column("key").doUpdateSet({ value: toJson(episodeSchema, health.episode) })).execute();
12094
- if (health.hostLoad !== null) candidates.push({
12095
- key: "host-load",
12096
- taskId: null,
12097
- summary: "Host under load",
12098
- factAt: health.episode === null ? null : new Date(health.episode.startedAt).toISOString(),
12099
- source: "spur",
12100
- priority: 4,
12101
- revision: health.episode === null ? null : String(health.episode.startedAt)
12102
- });
12103
12190
  for (const flag of health.flags) {
12104
12191
  const task = taskById.get(Number(flag.taskId));
12105
12192
  if (task === void 0) continue;
@@ -12107,13 +12194,13 @@ async function reconcileItems(trx, config, now, spurComplete) {
12107
12194
  const endedLabel = ENDED_WORKER_LABELS[flag.kind];
12108
12195
  candidates.push({
12109
12196
  key: healthKey(task.id, flag),
12197
+ kind: flag.kind === "worker_completed" || flag.kind === "worker_killed" ? "worker_ended" : "board_observation",
12110
12198
  taskId: task.id,
12111
12199
  summary: `${task.key}: ${endedLabel ?? flag.kind.replaceAll("_", " ")} (${flag.sessionId})`,
12112
12200
  factAt: fact?.healthSince ?? null,
12113
12201
  source: "spur",
12114
12202
  priority: 4,
12115
- revision: endedLabel === void 0 ? fact?.healthSince ?? null : fact?.endedAt ?? null,
12116
- suppressFeed: flag.kind === "worker_completed" || flag.kind === "worker_killed"
12203
+ revision: endedLabel === void 0 ? fact?.healthSince ?? null : fact?.endedAt ?? null
12117
12204
  });
12118
12205
  }
12119
12206
  const ordered = orderItems(candidates);
@@ -12122,15 +12209,16 @@ async function reconcileItems(trx, config, now, spurComplete) {
12122
12209
  const task = taskById.get(Number(flag.taskId));
12123
12210
  if (task !== void 0) seen.add(healthKey(task.id, flag));
12124
12211
  }
12125
- const existing = await trx.selectFrom("operator_item").selectAll().where("kind", "=", "board_observation").where("cleared_at", "is", null).execute();
12212
+ const existing = await trx.selectFrom("operator_item").selectAll().where("kind", "in", RECONCILED_KINDS).where("cleared_at", "is", null).execute();
12126
12213
  for (const item of existing) if (!seen.has(item.item_key)) await clearItem(trx, item.id, new Date(now));
12127
12214
  for (const candidate of ordered) {
12128
12215
  const hash = fingerprint(candidate);
12129
12216
  const old = existing.find((item) => item.item_key === candidate.key);
12130
12217
  const dismissal = await trx.selectFrom("dismissal").select("fingerprint").where("item_key", "=", candidate.key).executeTakeFirst();
12131
- if (old !== void 0 && (dismissal?.fingerprint === hash || old.fingerprint !== hash)) await clearItem(trx, old.id, new Date(now));
12218
+ const kept = old !== void 0 && old.fingerprint === hash && old.kind === candidate.kind;
12219
+ if (old !== void 0 && (dismissal?.fingerprint === hash || !kept)) await clearItem(trx, old.id, new Date(now));
12132
12220
  if (dismissal?.fingerprint === hash) continue;
12133
- if (old !== void 0 && old.fingerprint === hash) {
12221
+ if (kept) {
12134
12222
  if (old.fact_at !== candidate.factAt || old.source !== candidate.source) await trx.updateTable("operator_item").set({
12135
12223
  fact_at: candidate.factAt,
12136
12224
  source: candidate.source
@@ -12140,7 +12228,7 @@ async function reconcileItems(trx, config, now, spurComplete) {
12140
12228
  const task = candidate.taskId === null ? null : taskById.get(candidate.taskId);
12141
12229
  await raiseItem(trx, {
12142
12230
  itemKey: candidate.key,
12143
- kind: "board_observation",
12231
+ kind: candidate.kind,
12144
12232
  text: candidate.summary,
12145
12233
  url: task === null || task === void 0 ? "https://github.com" : taskUrl(task, config),
12146
12234
  taskId: candidate.taskId,
@@ -12149,8 +12237,7 @@ async function reconcileItems(trx, config, now, spurComplete) {
12149
12237
  fingerprint: hash,
12150
12238
  factAt: candidate.factAt,
12151
12239
  source: candidate.source,
12152
- priority: candidate.priority,
12153
- suppressFeed: candidate.suppressFeed ?? false
12240
+ priority: candidate.priority
12154
12241
  });
12155
12242
  }
12156
12243
  }
@@ -13980,6 +14067,8 @@ function teamScopeDenied(error, query) {
13980
14067
  return /\b(?:slug|name)\b/i.test(error.message) && /\bread:(?:org|discussion)\b/i.test(error.message);
13981
14068
  }
13982
14069
  const REVIEWER_FIELDS = "requestedReviewer { __typename ... on Bot { login } ... on Mannequin { login } ... on User { login } ... on Team { slug } ... on EnterpriseTeam { slug } } asCodeOwner";
14070
+ const REVIEW_FIELDS = "id author { __typename login } state commit { oid } submittedAt";
14071
+ const COMMENT_FIELDS = "nodes { id author { __typename login } createdAt } pageInfo { hasPreviousPage startCursor }";
13983
14072
  const CLOSING_FIELDS = "nodes { number repository { nameWithOwner } } pageInfo { hasNextPage endCursor }";
13984
14073
  const prFields = (number, closing = false) => `id number url title updatedAt state isDraft mergeable mergeStateStatus
13985
14074
  author { login } headRefName headRefOid
@@ -13987,7 +14076,8 @@ const prFields = (number, closing = false) => `id number url title updatedAt sta
13987
14076
  ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt } isRequired(pullRequestNumber: ${String(number)}) }
13988
14077
  ... on StatusContext { __typename context state createdAt isRequired(pullRequestNumber: ${String(number)}) }
13989
14078
  } pageInfo { hasNextPage endCursor } } }
13990
- reviews(first: 100) { nodes { author { login } state commit { oid } submittedAt } pageInfo { hasNextPage endCursor } }
14079
+ reviews(first: 100) { nodes { ${REVIEW_FIELDS} } pageInfo { hasNextPage endCursor } }
14080
+ comments(last: 100) { ${COMMENT_FIELDS} }
13991
14081
  reviewThreads(first: 100) { nodes { isResolved } pageInfo { hasNextPage endCursor } }
13992
14082
  reviewRequests(first: 100) { nodes { ${REVIEWER_FIELDS} } pageInfo { hasNextPage endCursor } }${closing ? `\n closingIssuesReferences(first: 100) { ${CLOSING_FIELDS} }` : ""}`;
13993
14083
  const DISCOVERY_FIELDS = `nodes { number updatedAt author { login } state } pageInfo { hasNextPage endCursor }`;
@@ -14001,8 +14091,9 @@ function detailQuery(numbers, closing = false) {
14001
14091
  return `query PrDetails($owner: String!, $repo: String!) { rateLimit { remaining resetAt } ${aliases(numbers, closing)} }`;
14002
14092
  }
14003
14093
  function pageQuery(connection, bootstrap = false) {
14094
+ 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} } } } }`;
14004
14095
  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 ? "OPEN" : "OPEN, MERGED"}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} } } }`;
14005
- 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" ? "author { login } state commit { oid } submittedAt" : connection === "reviewThreads" ? "isResolved" : REVIEWER_FIELDS} } pageInfo { hasNextPage endCursor } }`} } } }`;
14096
+ 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 } }`} } } }`;
14006
14097
  }
14007
14098
  var GithubClient = class {
14008
14099
  token;
@@ -14114,6 +14205,10 @@ const KEPT_REVIEWS = [
14114
14205
  "dismissed"
14115
14206
  ];
14116
14207
  const actor = z.object({ login: z.string().optional() }).nullish();
14208
+ const typedActor = z.object({
14209
+ __typename: z.string(),
14210
+ login: z.string().min(1)
14211
+ }).nullable();
14117
14212
  const checkRunWire = z.object({
14118
14213
  __typename: z.literal("CheckRun"),
14119
14214
  name: z.string(),
@@ -14133,12 +14228,18 @@ const statusContextWire = z.object({
14133
14228
  });
14134
14229
  const contextWire = z.discriminatedUnion("__typename", [checkRunWire, statusContextWire]);
14135
14230
  const reviewWire = z.object({
14136
- author: actor,
14231
+ id: z.string().min(1),
14232
+ author: typedActor,
14137
14233
  state: z.string(),
14138
14234
  commit: z.object({ oid: z.string() }).nullable(),
14139
14235
  submittedAt: z.string().nullish()
14140
14236
  }).refine((review) => review.commit !== null || !review.author?.login || review.submittedAt == null || !KEPT_REVIEWS.includes(review.state.toLowerCase()), { path: ["commit"] });
14141
14237
  const nodes = (node) => z.object({ nodes: z.array(node) });
14238
+ const commentWire = z.object({
14239
+ id: z.string().min(1),
14240
+ author: typedActor,
14241
+ createdAt: z.iso.datetime()
14242
+ });
14142
14243
  const loginReviewer = (type) => z.object({
14143
14244
  __typename: z.literal(type),
14144
14245
  login: z.string()
@@ -14172,6 +14273,7 @@ const prWire = z.object({
14172
14273
  headRefOid: z.string(),
14173
14274
  statusCheckRollup: z.object({ contexts: nodes(contextWire) }).nullish(),
14174
14275
  reviews: nodes(reviewWire),
14276
+ comments: nodes(commentWire),
14175
14277
  reviewThreads: nodes(z.object({ isResolved: z.boolean() })),
14176
14278
  reviewRequests: nodes(z.object({
14177
14279
  requestedReviewer: reviewerWire,
@@ -14287,6 +14389,35 @@ function latestReviews(nodes) {
14287
14389
  }
14288
14390
  return [...latest.values()].sort((a, b) => a.reviewer.localeCompare(b.reviewer));
14289
14391
  }
14392
+ function feedbackAuthor(wire) {
14393
+ return wire === null ? null : {
14394
+ login: wire.login,
14395
+ type: wire.__typename === "Bot" ? "bot" : "user"
14396
+ };
14397
+ }
14398
+ function feedbackOf(reviews, comments) {
14399
+ const entries = /* @__PURE__ */ new Map();
14400
+ const add = (entry) => {
14401
+ entries.set(`${entry.kind}:${entry.id}`, entry);
14402
+ };
14403
+ for (const node of comments) add({
14404
+ kind: "comment",
14405
+ id: node.id,
14406
+ author: feedbackAuthor(node.author),
14407
+ postedAt: node.createdAt
14408
+ });
14409
+ for (const node of reviews) {
14410
+ if (node.submittedAt == null) continue;
14411
+ add({
14412
+ kind: "review",
14413
+ id: node.id,
14414
+ author: feedbackAuthor(node.author),
14415
+ postedAt: node.submittedAt
14416
+ });
14417
+ }
14418
+ const tie = (entry) => `${entry.id}\u0000${entry.kind}`;
14419
+ return [...entries.values()].sort((a, b) => Date.parse(a.postedAt) - Date.parse(b.postedAt) || (tie(a) < tie(b) ? -1 : tie(a) > tie(b) ? 1 : 0));
14420
+ }
14290
14421
  function ticketKeys(title, branch, prefixes) {
14291
14422
  return scanKeys(`${title} ${branch}`, prefixes);
14292
14423
  }
@@ -14366,7 +14497,8 @@ function reviewer(wire) {
14366
14497
  default: return assertNever(wire);
14367
14498
  }
14368
14499
  }
14369
- function normalizePr(repo, value, rule) {
14500
+ /** `feedbackComplete` says whether the comments in `value` reach back to the cursor or start. */
14501
+ function normalizePr(repo, value, rule, feedbackComplete) {
14370
14502
  const wire = parseWire(prWire, value, "Malformed GitHub PR response");
14371
14503
  const checks = latestChecks(wire.statusCheckRollup?.contexts.nodes ?? []);
14372
14504
  const state = wire.state === "MERGED" ? "merged" : wire.state === "CLOSED" ? "closed" : "open";
@@ -14403,7 +14535,9 @@ function normalizePr(repo, value, rule) {
14403
14535
  asCodeOwner
14404
14536
  }]),
14405
14537
  ticketKeys: prKeys(rule, title, headBranch, closingRefs(wire.closingIssuesReferences)),
14406
- updatedAt: wire.updatedAt
14538
+ updatedAt: wire.updatedAt,
14539
+ feedback: feedbackOf(wire.reviews.nodes, wire.comments.nodes),
14540
+ feedbackComplete
14407
14541
  };
14408
14542
  const parsed = prFactsSchema.safeParse(facts);
14409
14543
  if (!parsed.success) throw new AdapterError("transient", "Malformed GitHub PR facts", { cause: parsed.error });
@@ -14415,8 +14549,16 @@ const MALFORMED$2 = "Malformed GitHub response";
14415
14549
  const discoveryRootWire = z.object({ pullRequests: connectionWire(discoveryNodeWire) });
14416
14550
  const baselineRootWire = z.object({ mergedBaseline: z.object({ nodes: z.array(baselineNodeWire) }) });
14417
14551
  const pagingWire = connectionWire(z.unknown());
14552
+ const backPagingWire = z.object({
14553
+ nodes: z.array(commentWire),
14554
+ pageInfo: z.object({
14555
+ hasPreviousPage: z.boolean(),
14556
+ startCursor: z.string().nullable()
14557
+ })
14558
+ });
14418
14559
  const prPagingWire = z.looseObject({
14419
14560
  reviews: pagingWire,
14561
+ comments: backPagingWire,
14420
14562
  reviewThreads: pagingWire,
14421
14563
  reviewRequests: pagingWire,
14422
14564
  statusCheckRollup: z.object({ contexts: pagingWire }).nullish(),
@@ -14424,6 +14566,8 @@ const prPagingWire = z.looseObject({
14424
14566
  });
14425
14567
  const aliasWire = z.object({ pullRequest: prPagingWire.nullish() }).nullish();
14426
14568
  const pageRootWire = z.object({ pullRequest: prPagingWire.partial() });
14569
+ const commentsRootWire = z.object({ pullRequest: z.object({ comments: backPagingWire }) });
14570
+ const FEEDBACK_PAGES = 3;
14427
14571
  function sourceId(project, repo) {
14428
14572
  return `github:${project}:${repo.toLowerCase()}`;
14429
14573
  }
@@ -14567,6 +14711,56 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
14567
14711
  pr
14568
14712
  };
14569
14713
  }
14714
+ function reachesCursor(nodes, cursor) {
14715
+ if (cursor === void 0) return false;
14716
+ const postedAt = Date.parse(cursor.postedAt);
14717
+ return nodes.some((node) => node.id === cursor.id || Date.parse(node.createdAt) < postedAt);
14718
+ }
14719
+ /**
14720
+ * Reads comments back from `first` to `cursor`, or to the start of the PR, within
14721
+ * `FEEDBACK_PAGES`. A transient failure keeps the comments read so far as incomplete; every
14722
+ * other failure, and any failure after an abort, rejects the poll.
14723
+ */
14724
+ async function readFeedback(client, first, owner, name, number, cursor, signal, budget) {
14725
+ let nodes = first.nodes;
14726
+ let page = first;
14727
+ const seen = /* @__PURE__ */ new Set();
14728
+ try {
14729
+ for (let pages = 1; page.pageInfo.hasPreviousPage && !reachesCursor(page.nodes, cursor); pages += 1) {
14730
+ const before = page.pageInfo.startCursor;
14731
+ if (!before || seen.has(before) || pages >= FEEDBACK_PAGES) return {
14732
+ nodes,
14733
+ complete: false
14734
+ };
14735
+ seen.add(before);
14736
+ const response = await client.query(pageQuery("comments"), {
14737
+ owner,
14738
+ repo: name,
14739
+ number,
14740
+ before
14741
+ }, signal);
14742
+ budget(response.budget);
14743
+ rejectUnscoped(response.errors, ["repository"]);
14744
+ if (response.errors.length > 0) return {
14745
+ nodes,
14746
+ complete: false
14747
+ };
14748
+ page = parseWire(commentsRootWire, response.data.repository, MALFORMED$2, ["data", "repository"]).pullRequest.comments;
14749
+ nodes = [...page.nodes, ...nodes];
14750
+ }
14751
+ return {
14752
+ nodes,
14753
+ complete: true
14754
+ };
14755
+ } catch (error) {
14756
+ if (signal.aborted) throw error;
14757
+ if (error instanceof AdapterError && error.kind === "transient") return {
14758
+ nodes,
14759
+ complete: false
14760
+ };
14761
+ throw error;
14762
+ }
14763
+ }
14570
14764
  function accumulator(complete, budget) {
14571
14765
  return {
14572
14766
  complete,
@@ -14613,9 +14807,10 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
14613
14807
  else acc.complete = false;
14614
14808
  return false;
14615
14809
  }
14616
- const full = await fullPr(scope.client, wire, scope.owner, scope.name, number, scope.signal, (next) => {
14810
+ const report = (next) => {
14617
14811
  acc.budget = next;
14618
- });
14812
+ };
14813
+ const full = await fullPr(scope.client, wire, scope.owner, scope.name, number, scope.signal, report);
14619
14814
  if (full.status === "denied") {
14620
14815
  acc.complete = false;
14621
14816
  if (ref) acc.entities.push({
@@ -14625,7 +14820,16 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
14625
14820
  return false;
14626
14821
  }
14627
14822
  if (full.status === "malformed") return malformed(acc, full.error, ref);
14628
- const facts = content(() => normalizePr(ref?.repo ?? scope.repo, full.pr, scope.keys));
14823
+ const cursor = scope.feedbackCursors?.find((entry) => entry.ref.number === number && entry.ref.repo.toLowerCase() === scope.repo.toLowerCase());
14824
+ const feedback = await readFeedback(scope.client, full.pr.comments, scope.owner, scope.name, number, cursor, scope.signal, report);
14825
+ const pr = {
14826
+ ...full.pr,
14827
+ comments: {
14828
+ ...full.pr.comments,
14829
+ nodes: feedback.nodes
14830
+ }
14831
+ };
14832
+ const facts = content(() => normalizePr(ref?.repo ?? scope.repo, pr, scope.keys, feedback.complete));
14629
14833
  if (facts instanceof AdapterError) return malformed(acc, facts, ref);
14630
14834
  acc.items.push({
14631
14835
  kind: "pr",
@@ -14691,7 +14895,8 @@ async function pollRepository({ id, repo, login, keys, client, now, ctx }) {
14691
14895
  owner,
14692
14896
  name,
14693
14897
  keys,
14694
- signal: ctx.signal
14898
+ signal: ctx.signal,
14899
+ ...ctx.feedbackCursors === void 0 ? {} : { feedbackCursors: ctx.feedbackCursors }
14695
14900
  };
14696
14901
  let discoveredOk = true;
14697
14902
  for (const [i, number] of numbers.entries()) {
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { P as ERRORS, p as renderMcpError, u as OPERATIONS } from "./src-XNs3RhSm.mjs";
2
- import { i as CliError, n as requestOperation } from "./client-BHnD83EW.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-CoUN_LCM.mjs";
1
+ import { P as ERRORS, p as renderMcpError, u as OPERATIONS } from "./src-B63VaSzU.mjs";
2
+ import { i as CliError, n as requestOperation } from "./client-DtDNMMO-.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-D3ltZ-MU.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
@@ -222,10 +222,12 @@ const spurProject = z.strictObject({
222
222
  "curator"
223
223
  ]).describe("worker: sessions of this Spur project may link to this project's tasks through their PR or branch. operator: sessions act as the operator. curator: sessions answer the questions no column orchestrator takes and escalate the rest to the operator; a board project has at most one.")
224
224
  });
225
+ const DEFAULT_CYCLE_LIMIT = 10;
225
226
  const columnConfig = z.strictObject({
226
227
  id: z.enum(COLUMN_IDS, { error: (issue) => typeof issue.input === "string" ? `Unknown column ${JSON.stringify(issue.input)}: custom columns arrive with custom matchers and are not supported yet. Built-in columns: ${COLUMN_IDS.join(", ")}` : void 0 }),
227
228
  enabled: z.boolean().default(true),
228
- orchestrator: nonEmpty.default("none")
229
+ orchestrator: nonEmpty.default("none"),
230
+ cycleLimit: z.int().min(1).default(DEFAULT_CYCLE_LIMIT).describe("How many times a task may return to Dev from this column before the board stops it for the operator. Returns by the column executor, changes requested and external comments count; a conflict, red CI and a draft do not.")
229
231
  });
230
232
  /** The board rules: required columns present and enabled, built-ins in canonical order. */
231
233
  function checkBoard(items, ctx) {
@@ -291,7 +293,8 @@ const projectSchema = z.strictObject({
291
293
  columns: z.array(columnConfig).superRefine(checkBoard).default(() => COLUMN_IDS.map((id) => ({
292
294
  id,
293
295
  enabled: true,
294
- orchestrator: "none"
296
+ orchestrator: "none",
297
+ cycleLimit: DEFAULT_CYCLE_LIMIT
295
298
  })))
296
299
  }).superRefine((project, ctx) => {
297
300
  const spurNames = new Set(project.spurProjects.map((p) => p.name));
@@ -915,6 +918,8 @@ const REVIEWER_KINDS = [
915
918
  "team",
916
919
  "bot"
917
920
  ];
921
+ const FEEDBACK_KINDS = ["comment", "review"];
922
+ const AUTHOR_TYPES = ["user", "bot"];
918
923
  /** Spur session lifecycle values known today. */
919
924
  const SESSION_STATUSES = [
920
925
  "spawning",
@@ -951,6 +956,15 @@ const checkSchema = z.strictObject({
951
956
  state: z.enum(CHECK_STATES).describe("State of the latest run of this check on the head commit."),
952
957
  completedAt: at$2.nullable().describe("When the latest run finished; null while it runs.")
953
958
  });
959
+ const feedbackSchema = z.strictObject({
960
+ kind: z.enum(FEEDBACK_KINDS).describe("Whether this is a comment or a submitted review."),
961
+ id: z.string().min(1).describe("Stable id of the comment or review in the source."),
962
+ author: z.strictObject({
963
+ login: login.describe("Login of the author."),
964
+ type: z.enum(AUTHOR_TYPES).describe("Whether the author is a user or a bot.")
965
+ }).nullable().describe("Who posted it; null for a deleted account."),
966
+ postedAt: at$2.describe("When the comment was posted or the review submitted.")
967
+ });
954
968
  const prFactsSchema = z.strictObject({
955
969
  repo: repoSlugSchema.describe("Repository as owner/name."),
956
970
  number: z.int().min(1).describe("Pull request number in the repository."),
@@ -984,7 +998,9 @@ const prFactsSchema = z.strictObject({
984
998
  });
985
999
  })).describe("Pending review requests."),
986
1000
  ticketKeys: z.array(taskKeySchema).describe("Ticket keys found in the head branch name and the title."),
987
- updatedAt: at$2.describe("When the pull request last changed.")
1001
+ updatedAt: at$2.describe("When the pull request last changed."),
1002
+ feedback: z.array(feedbackSchema).optional().describe("Comments and submitted reviews on the pull request, oldest first, without their text."),
1003
+ feedbackComplete: z.boolean().optional().describe("Whether feedback holds every comment back to the last one handed over, or to the start of the pull request; missing reads as incomplete.")
988
1004
  }).describe("Facts about one pull request.");
989
1005
  /** A tracker ticket; tracker-neutral, so a Jira issue and a GitHub issue both fit. */
990
1006
  const ticketFactsSchema = z.strictObject({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"