spur-board 0.44.2 → 0.45.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 { 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-HVASmsVd.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-BODC7qTT.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-M7jQfUT9.mjs";
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-CL9PYpaV.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-CYAzUkSd.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-DSySN2QA.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-HVASmsVd.mjs";
1
+ import { H as errorEnvelopeSchema, V as errorContextSchema, W as successEnvelopeSchema, p as renderJsonError, z as ERRORS } from "./src-CL9PYpaV.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-BODC7qTT.mjs";
1
+ import { i as requestTokenEnrollment, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./client-CYAzUkSd.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-HVASmsVd.mjs";
2
- import { a as CliError, t as fetchCatalogVersion } from "./client-BODC7qTT.mjs";
1
+ import { X as configSchema, Z as plainHttpAllowed, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-CL9PYpaV.mjs";
2
+ import { a as CliError, t as fetchCatalogVersion } from "./client-CYAzUkSd.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-HVASmsVd.mjs";
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-CL9PYpaV.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";
@@ -10083,7 +10083,7 @@ async function reconcileDoorbells(trx, at, config) {
10083
10083
  }).where("id", "=", n.id).execute();
10084
10084
  continue;
10085
10085
  }
10086
- if (session.state === "working") continue;
10086
+ if (recipientBusy(session) && !await spurBlind$1(trx)) continue;
10087
10087
  let rings = n.rings;
10088
10088
  let lastOutbox = n.last_outbox_id;
10089
10089
  if (session.id !== n.recipient_session) {
@@ -10150,19 +10150,30 @@ function ringPauses(config) {
10150
10150
  config.doorbells.unansweredAfterMs
10151
10151
  ];
10152
10152
  }
10153
- /**
10154
- * Whether the session's facts list a ring of this series, up to `rings`, still in its Spur queue.
10155
- * A detail that does not parse, or one without a queue, holds nothing.
10156
- */
10157
- function earlierRingQueued(session, notificationId, rings) {
10153
+ /** The session's last observed Spur facts, or null when its detail does not parse. */
10154
+ function observedFacts(session) {
10158
10155
  let detail;
10159
10156
  try {
10160
10157
  detail = JSON.parse(session.detail);
10161
10158
  } catch {
10162
- return false;
10159
+ return null;
10163
10160
  }
10164
10161
  const fact = sessionFactsSchema.safeParse(detail);
10165
- return fact.success && (fact.data.queuedRings ?? []).some((queued) => queued.notification === notificationId && queued.ring <= rings);
10162
+ return fact.success ? fact.data : null;
10163
+ }
10164
+ /**
10165
+ * Whether the session was last observed mid-turn. Only an observed `working` health counts: any
10166
+ * other health, or a detail that does not parse, is rung.
10167
+ */
10168
+ function recipientBusy(session) {
10169
+ return observedFacts(session)?.health === "working";
10170
+ }
10171
+ /**
10172
+ * Whether the session's facts list a ring of this series, up to `rings`, still in its Spur queue.
10173
+ * A detail that does not parse, or one without a queue, holds nothing.
10174
+ */
10175
+ function earlierRingQueued(session, notificationId, rings) {
10176
+ return (observedFacts(session)?.queuedRings ?? []).some((queued) => queued.notification === notificationId && queued.ring <= rings);
10166
10177
  }
10167
10178
  /** Count one confirmed Spur send, regardless of transport attempts for its outbox row. */
10168
10179
  async function recordRingDelivery(trx, notificationId, ring, session, at, config) {
@@ -10191,7 +10202,7 @@ async function ringStillCurrent(trx, notificationId, sessionId, config) {
10191
10202
  if (n === void 0 || n.acked_at !== null || n.exhausted_at !== null || n.recipient_session !== sessionId) return "dead";
10192
10203
  const session = await selectNotificationRecipient(trx, n, config);
10193
10204
  if (session?.id !== sessionId) return "dead";
10194
- return session.state === "working" ? "defer" : "send";
10205
+ return recipientBusy(session) && !await spurBlind$1(trx) ? "defer" : "send";
10195
10206
  }
10196
10207
  /**
10197
10208
  * The task of a ring: through its notification, or for an inbound author ring (no notification)
@@ -12249,7 +12260,8 @@ async function getStatus(deps, options = {}) {
12249
12260
  if (snapshot !== void 0) sessions.push(parseJson(sessionFactsSchema, snapshot.detail));
12250
12261
  }
12251
12262
  const ticketFacts = ticket === void 0 ? null : parseJson(ticketFactsSchema, ticket.detail);
12252
- const trackerRepo = issuesRepo(config.projects.find((entry) => entry.id === task.project));
12263
+ const project = config.projects.find((entry) => entry.id === task.project);
12264
+ const trackerRepo = issuesRepo(project);
12253
12265
  const linkHints = [];
12254
12266
  for (const session of sessions) {
12255
12267
  const pr = session.pr;
@@ -12265,6 +12277,10 @@ async function getStatus(deps, options = {}) {
12265
12277
  project: task.project,
12266
12278
  column: task.column,
12267
12279
  membership: task.membership,
12280
+ ...project?.dispatcher.mode === "shadow" ? {
12281
+ shadowColumn: task.shadow_column ?? task.column,
12282
+ shadowDiffers: (task.shadow_column ?? task.column) !== task.column
12283
+ } : {},
12268
12284
  state: taskState(ticketFacts, prs, sessions),
12269
12285
  prCount: links.filter((link) => link.entity === "pr").length,
12270
12286
  sessionCount: links.filter((link) => link.entity === "session").length,
@@ -12858,7 +12874,7 @@ function evaluateSessionHealth(input) {
12858
12874
  sessionId: session.id,
12859
12875
  kind: ENDED_WORKER_KINDS[session.endReason]
12860
12876
  };
12861
- (spur.observationComplete ? flags : held).push(flag);
12877
+ (spur.observationComplete && prsPolledSince(task, session.endedAt) ? flags : held).push(flag);
12862
12878
  }
12863
12879
  continue;
12864
12880
  }
@@ -12873,10 +12889,14 @@ function evaluateSessionHealth(input) {
12873
12889
  if (session.role === "other") continue;
12874
12890
  const heldMs = now - Date.parse(session.healthSince);
12875
12891
  let kind = null;
12892
+ let fresh = true;
12876
12893
  if (session.health === "error" && episode === null && heldMs >= config.errorAfterMs) kind = session.role === "worker" ? "stuck_worker" : "stuck_orchestrator";
12877
12894
  else if (session.health === "needs_input" && heldMs >= config.needsInputAfterMs) kind = "needs_input";
12878
- else if (session.health === "waiting" && session.role === "worker" && task !== void 0 && !task.hasOpenPr && heldMs >= config.idleInDevAfterMs) kind = "worker_idle";
12879
- if (kind !== null) flags.push({
12895
+ else if (session.health === "waiting" && session.role === "worker" && task !== void 0 && !task.hasOpenPr && heldMs >= config.idleInDevAfterMs) {
12896
+ kind = "worker_idle";
12897
+ fresh = prsPolledSince(task, session.healthSince);
12898
+ }
12899
+ if (kind !== null) (fresh ? flags : held).push({
12880
12900
  taskId: session.taskId,
12881
12901
  sessionId: session.id,
12882
12902
  kind
@@ -12890,6 +12910,10 @@ function evaluateSessionHealth(input) {
12890
12910
  episode
12891
12911
  };
12892
12912
  }
12913
+ /** Whether every PR source of the task completed a poll that began at or after `since`. */
12914
+ function prsPolledSince(task, since) {
12915
+ return task.prCompleteAt !== null && task.prCompleteAt >= Date.parse(since);
12916
+ }
12893
12917
  //#endregion
12894
12918
  //#region ../core/src/app/fromYou.ts
12895
12919
  const episodeSchema = z.object({ startedAt: z.number() }).nullable();
@@ -13019,12 +13043,14 @@ async function reconcileItems(trx, config, now, spurComplete) {
13019
13043
  "link.number",
13020
13044
  "pr_snapshot.state",
13021
13045
  "pr_snapshot.source",
13022
- "pr_snapshot.observed_at"
13046
+ "pr_snapshot.observed_at",
13047
+ "pr_snapshot.detail"
13023
13048
  ]).where("link.entity", "=", "pr").where("link.banned", "=", 0).where(pastReopenFloor).execute();
13024
13049
  const taskPrs = {};
13025
13050
  for (const task of tasks) taskPrs[String(task.id)] = {
13026
13051
  hasOpenPr: false,
13027
13052
  hasMergedPr: false,
13053
+ prCompleteAt: prCompleteAt(config.projects.find((entry) => entry.id === task.project), sourceById),
13028
13054
  turnSessions: []
13029
13055
  };
13030
13056
  for (const pr of prs) {
@@ -13038,6 +13064,7 @@ async function reconcileItems(trx, config, now, spurComplete) {
13038
13064
  const holder = turn.acked_by === null ? null : parseActorId(turn.acked_by);
13039
13065
  if (holder?.actor === "agent") taskPrs[String(turn.task_id)]?.turnSessions.push(holder.actorRef.session);
13040
13066
  }
13067
+ const heldKeys = [];
13041
13068
  for (const task of tasks) {
13042
13069
  const state = taskPrs[String(task.id)];
13043
13070
  if (state === void 0 || state.hasOpenPr || state.hasMergedPr) continue;
@@ -13047,9 +13074,15 @@ async function reconcileItems(trx, config, now, spurComplete) {
13047
13074
  })).sort((left, right) => left.ref.localeCompare(right.ref));
13048
13075
  const first = closed[0];
13049
13076
  if (first === void 0) continue;
13077
+ const closedAt = Math.max(...closed.map((pr) => pr.detail === null ? NaN : Date.parse(parseJson(prFactsSchema, pr.detail).updatedAt)));
13078
+ const key = `pr-closed:${String(task.id)}`;
13079
+ if (state.prCompleteAt === null || !(state.prCompleteAt >= closedAt)) {
13080
+ heldKeys.push(key);
13081
+ continue;
13082
+ }
13050
13083
  const refs = closed.map((pr) => pr.ref);
13051
13084
  candidates.push({
13052
- key: `pr-closed:${String(task.id)}`,
13085
+ key,
13053
13086
  kind: "anomaly",
13054
13087
  taskId: task.id,
13055
13088
  summary: `${task.key}: linked pull request ${refs.join(", ")} closed without merge, no open PR`,
@@ -13065,7 +13098,6 @@ async function reconcileItems(trx, config, now, spurComplete) {
13065
13098
  "detail",
13066
13099
  "source"
13067
13100
  ]).execute();
13068
- const unpolledTickets = [];
13069
13101
  for (const task of tasks) {
13070
13102
  const state = taskPrs[String(task.id)];
13071
13103
  const project = config.projects.find((entry) => entry.id === task.project);
@@ -13082,13 +13114,11 @@ async function reconcileItems(trx, config, now, spurComplete) {
13082
13114
  });
13083
13115
  if (!closedWhileLive) continue;
13084
13116
  const { updatedAt } = parseJson(ticketFactsSchema, ticket.detail);
13085
- const polled = project.repos.every((repo) => {
13086
- const repoSource = sourceById.get(`github:${project.id}:${repo.toLowerCase()}`);
13087
- return repoSource !== void 0 && repoSource.blind_reason === null && repoSource.last_complete_at !== null && Date.parse(repoSource.last_complete_at) > Date.parse(updatedAt);
13088
- });
13117
+ const polledAt = state.prCompleteAt;
13118
+ const polled = polledAt !== null && polledAt > Date.parse(updatedAt);
13089
13119
  const key = `ticket-closed:${String(task.id)}`;
13090
13120
  if (!polled) {
13091
- unpolledTickets.push(key);
13121
+ heldKeys.push(key);
13092
13122
  continue;
13093
13123
  }
13094
13124
  candidates.push({
@@ -13161,7 +13191,7 @@ async function reconcileItems(trx, config, now, spurComplete) {
13161
13191
  }
13162
13192
  }
13163
13193
  const ordered = orderItems(candidates);
13164
- const seen = /* @__PURE__ */ new Set([...ordered.map((item) => item.key), ...unpolledTickets]);
13194
+ const seen = /* @__PURE__ */ new Set([...ordered.map((item) => item.key), ...heldKeys]);
13165
13195
  for (const flag of health.held) {
13166
13196
  const task = taskById.get(Number(flag.taskId));
13167
13197
  if (task !== void 0) seen.add(healthKey(task.id, flag));
@@ -13215,6 +13245,20 @@ async function reconcileItems(trx, config, now, spurComplete) {
13215
13245
  }
13216
13246
  }
13217
13247
  /**
13248
+ * Start of the oldest last complete poll over the project's GitHub sources, or null while any is
13249
+ * missing, blind or never complete: a replacement PR can be in any of the project's repos.
13250
+ */
13251
+ function prCompleteAt(project, sourceById) {
13252
+ if (project === void 0) return null;
13253
+ let oldest = Infinity;
13254
+ for (const repo of project.repos) {
13255
+ const source = sourceById.get(`github:${project.id}:${repo.toLowerCase()}`);
13256
+ if (source === void 0 || source.blind_reason !== null || source.last_complete_at === null) return null;
13257
+ oldest = Math.min(oldest, Date.parse(source.last_complete_at));
13258
+ }
13259
+ return oldest;
13260
+ }
13261
+ /**
13218
13262
  * Raises a ledger item with the operator block it stands for. An active item of the key is
13219
13263
  * returned as it is, so a repeated raise opens no second block.
13220
13264
  */
@@ -15413,7 +15457,7 @@ function commandReply(id, value, input) {
15413
15457
  body: [
15414
15458
  line(`Board status: ${String(status.tasks.length)} tasks, ${String(status.items.length)} items needing attention.`),
15415
15459
  ...status.items.map((item) => line(`${item.key}: ${item.summary}`)),
15416
- ...status.tasks.map((task) => line(`${task.key}: ${task.column} (${task.membership})`)),
15460
+ ...status.tasks.map((task) => line(`${task.key}: ${task.column}${task.shadowDiffers === true ? `, shadow ${String(task.shadowColumn)}` : ""} (${task.membership})`)),
15417
15461
  line(`Unlinked: ${String(status.unlinkedPrs.length)} pull requests, ${String(status.unlinkedSessions.length)} sessions${status.hiddenUnlinkedPrs + status.hiddenUnlinkedSessions === 0 ? "" : `; ${String(status.hiddenUnlinkedPrs)} pull requests and ${String(status.hiddenUnlinkedSessions)} sessions finished over 7 days ago are hidden`}.`),
15418
15462
  ...status.sources.map((source) => line(`${source.source}: ${source.blindReason !== null ? `blind (${source.blindReason})` : source.warmingUp ? "warming up" : source.stale ? "stale" : "current"}`)),
15419
15463
  ...status.warmingUp ? [line("Sources are warming up.")] : [],
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { m as renderMcpError, u as OPERATIONS, z as ERRORS } from "./src-HVASmsVd.mjs";
2
- import { a as CliError, r as requestOperation } from "./client-BODC7qTT.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-M7jQfUT9.mjs";
1
+ import { m as renderMcpError, u as OPERATIONS, z as ERRORS } from "./src-CL9PYpaV.mjs";
2
+ import { a as CliError, r as requestOperation } from "./client-CYAzUkSd.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-DSySN2QA.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
@@ -1897,6 +1897,8 @@ const linkViewSchema = z.strictObject({
1897
1897
  const detailOnly = "Present only with detail.";
1898
1898
  const count = (what) => z.int().min(0).describe(what);
1899
1899
  const statusTaskSchema = taskViewSchema.extend({
1900
+ 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."),
1901
+ shadowDiffers: z.boolean().optional().describe("Whether shadowColumn differs from column. Present only while the project dispatcher is in shadow mode."),
1900
1902
  state: z.string().min(1).describe("One line: ticket status, pull request states and session health counts, joined by \"; \"."),
1901
1903
  prCount: count("Number of effective pull request links."),
1902
1904
  sessionCount: count("Number of effective session links."),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.44.2",
3
+ "version": "0.45.0",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"