spur-board 0.104.1 → 0.104.3

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.
@@ -1,4 +1,4 @@
1
- import { _ as renderJsonError, at as successEnvelopeSchema, c as tokenRequestStatusSchema, et as ERRORS, nt as errorContextSchema, o as tokenRequestResultSchema, rt as errorEnvelopeSchema } from "./chunk-C34hsfqb.mjs";
1
+ import { _ as renderJsonError, at as successEnvelopeSchema, c as tokenRequestStatusSchema, et as ERRORS, nt as errorContextSchema, o as tokenRequestResultSchema, rt as errorEnvelopeSchema } from "./chunk-DGsDK61k.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { request } from "node:http";
@@ -1,5 +1,5 @@
1
- import { d as buildCatalogSnapshot, gt as plainHttpAllowed, mt as configSchema, p as OPERATIONS } from "./chunk-C34hsfqb.mjs";
2
- import { o as CliError, t as fetchCatalogVersion } from "./chunk-Dz9IMhY5.mjs";
1
+ import { d as buildCatalogSnapshot, gt as plainHttpAllowed, mt as configSchema, p as OPERATIONS } from "./chunk-DGsDK61k.mjs";
2
+ import { o as CliError, t as fetchCatalogVersion } from "./chunk-2UOGIWN_.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";
@@ -126,7 +126,8 @@ const DISPATCHER_MODES = ["shadow", "on"];
126
126
  * How a turn closed: `submitted` by the executor's submit, `returned` by `task.return`, `moved`
127
127
  * when the task moved on (it also covers returns and mode switches recorded by older versions),
128
128
  * `corrected` by the operator's column correction, `rerouted` to another executor,
129
- * `mode_changed` by a dispatcher mode switch, `archived` with the task.
129
+ * `mode_changed` by a dispatcher mode switch, `archived` with the task. `moved` also closes a
130
+ * Done wrap-up turn whose holder session ended.
130
131
  */
131
132
  const TURN_OUTCOMES = [
132
133
  "submitted",
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { St as SLACK_BOT_SCOPES, Y as actorIdSchema, _t as requiredSecretKeys, a as requestHashOf, at as successEnvelopeSchema, et as ERRORS, f as roleCanUseOperation, mt as configSchema, p as OPERATIONS, r as remoteDoctorReportSchema, u as SYSTEMD_SERVICE_SETTINGS, ut as DEFAULT_STAND_PORT_RANGE, vt as resolveWebOrigin } from "./chunk-C34hsfqb.mjs";
1
+ import { St as SLACK_BOT_SCOPES, Y as actorIdSchema, _t as requiredSecretKeys, a as requestHashOf, at as successEnvelopeSchema, et as ERRORS, f as roleCanUseOperation, mt as configSchema, p as OPERATIONS, r as remoteDoctorReportSchema, u as SYSTEMD_SERVICE_SETTINGS, ut as DEFAULT_STAND_PORT_RANGE, vt as resolveWebOrigin } from "./chunk-DGsDK61k.mjs";
2
2
  import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
3
- import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-Dz9IMhY5.mjs";
4
- 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 "./chunk-4C7tYXYO.mjs";
3
+ import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-2UOGIWN_.mjs";
4
+ 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 "./chunk-BTkdnlO3.mjs";
5
5
  import { createHash, randomBytes, randomUUID } from "node:crypto";
6
6
  import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
7
7
  import { homedir, hostname, userInfo } from "node:os";
package/dist/client.mjs CHANGED
@@ -1 +1 @@
1
- export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-Dz9IMhY5.mjs";
1
+ export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-2UOGIWN_.mjs";
package/dist/daemon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as parseRef$1, A as defaultBranchFactSchema, B as isExternalAuthor, C as messageRefSchema, Ct as TASK_HOLDS, D as eventPayloadSchemas, E as GATE_REASONS, F as trackerSourceId, G as sessionFactsSchema, H as prFactsSchema, I as PR_STATES, J as REF_NUMBER, K as ticketFactsSchema, L as REVIEW_STATES, M as prSourceId, N as sessionTransitionSchema, O as AdapterError, P as sourceCursorSchema, Q as parseActorId, R as SESSION_HEALTH_STATES, S as interactionRefSchema, St as SLACK_BOT_SCOPES, T as EVENT_KINDS, U as prRefSchema, V as parseRingMarker, W as ringMarker, X as encodeActorId, Y as actorIdSchema, Z as errorCodeOf, _t as requiredSecretKeys, a as requestHashOf, at as successEnvelopeSchema, b as conversationRefSchema, bt as DISPATCHER_MODES, c as tokenRequestStatusSchema, d as buildCatalogSnapshot, dt as RESERVED_PROJECT, et as ERRORS, f as roleCanUseOperation, ft as boardWideSpurProject, g as renderHttpProblem, gt as plainHttpAllowed, h as turnHandedSchema, ht as defaultAddressee, i as TOKEN_REQUEST_LIMITS, it as ok, j as entityRefSchema, k as batchSchema, l as BOARD_TICK_MS, lt as DEFAULT_SLACK_COMMAND, m as defaultBranchViewSchema, mt as configSchema, n as doctorReportSchema, o as tokenRequestResultSchema, p as OPERATIONS, pt as configBindings, q as JIRA_PROJECT_KEY, s as tokenRequestSchema, st as DEFAULT_LINK, t as assertNever, tt as err, vt as resolveWebOrigin, w as userIdSchema, wt as VIAS, x as inboundEventSchema, xt as ITEM_KINDS, y as SPACE_IDS, yt as COLUMN_IDS, z as SESSION_STATUSES } from "./chunk-C34hsfqb.mjs";
1
+ import { $ as parseRef$1, A as defaultBranchFactSchema, B as isExternalAuthor, C as messageRefSchema, Ct as TASK_HOLDS, D as eventPayloadSchemas, E as GATE_REASONS, F as trackerSourceId, G as sessionFactsSchema, H as prFactsSchema, I as PR_STATES, J as REF_NUMBER, K as ticketFactsSchema, L as REVIEW_STATES, M as prSourceId, N as sessionTransitionSchema, O as AdapterError, P as sourceCursorSchema, Q as parseActorId, R as SESSION_HEALTH_STATES, S as interactionRefSchema, St as SLACK_BOT_SCOPES, T as EVENT_KINDS, U as prRefSchema, V as parseRingMarker, W as ringMarker, X as encodeActorId, Y as actorIdSchema, Z as errorCodeOf, _t as requiredSecretKeys, a as requestHashOf, at as successEnvelopeSchema, b as conversationRefSchema, bt as DISPATCHER_MODES, c as tokenRequestStatusSchema, d as buildCatalogSnapshot, dt as RESERVED_PROJECT, et as ERRORS, f as roleCanUseOperation, ft as boardWideSpurProject, g as renderHttpProblem, gt as plainHttpAllowed, h as turnHandedSchema, ht as defaultAddressee, i as TOKEN_REQUEST_LIMITS, it as ok, j as entityRefSchema, k as batchSchema, l as BOARD_TICK_MS, lt as DEFAULT_SLACK_COMMAND, m as defaultBranchViewSchema, mt as configSchema, n as doctorReportSchema, o as tokenRequestResultSchema, p as OPERATIONS, pt as configBindings, q as JIRA_PROJECT_KEY, s as tokenRequestSchema, st as DEFAULT_LINK, t as assertNever, tt as err, vt as resolveWebOrigin, w as userIdSchema, wt as VIAS, x as inboundEventSchema, xt as ITEM_KINDS, y as SPACE_IDS, yt as COLUMN_IDS, z as SESSION_STATUSES } from "./chunk-DGsDK61k.mjs";
2
2
  import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -15262,7 +15262,7 @@ const uncounted = (reason) => reason === "ticket_reopened" || reason === "mode_c
15262
15262
  const indexOf$1 = (column) => COLUMN_IDS.indexOf(column);
15263
15263
  const isColumn = (text) => COLUMN_IDS.includes(text);
15264
15264
  /** A left move as a return with its causes, or null when it is no counted return. */
15265
- function counted$1(move, blocked) {
15265
+ function counted$2(move, blocked) {
15266
15266
  if (indexOf$1(move.to) >= indexOf$1(move.from) || uncounted(move.reason)) return null;
15267
15267
  const [first, ...rest] = returnCauses(move.gate ?? [], blocked);
15268
15268
  return first === void 0 ? null : {
@@ -15304,7 +15304,7 @@ async function returnCounts(trx, taskId, column) {
15304
15304
  continue;
15305
15305
  }
15306
15306
  const moved = eventPayloadSchemas.task_moved.safeParse(JSON.parse(row.payload));
15307
- const event = moved.success ? counted$1(moved.data, moved.data.block !== void 0) : null;
15307
+ const event = moved.success ? counted$2(moved.data, moved.data.block !== void 0) : null;
15308
15308
  if (event === null) continue;
15309
15309
  events.cycle.push(event);
15310
15310
  events.course.push(event);
@@ -15421,13 +15421,13 @@ async function openFindings(trx, taskId) {
15421
15421
  */
15422
15422
  async function shadowCourseCheck(trx, taskId, move, project) {
15423
15423
  const every = project.columns.find((column) => column.id === move.from)?.courseCheck ?? 0;
15424
- const current = counted$1(move, false);
15424
+ const current = counted$2(move, false);
15425
15425
  if (every <= 0 || current === null) return false;
15426
15426
  const rows = await trx.selectFrom("event").select("payload").where("task_id", "=", taskId).where("kind", "=", "task_shadow_moved").orderBy("id").execute();
15427
15427
  const past = [];
15428
15428
  for (const row of rows) {
15429
15429
  const moved = eventPayloadSchemas.task_shadow_moved.safeParse(JSON.parse(row.payload));
15430
- const event = moved.success ? counted$1(moved.data, false) : null;
15430
+ const event = moved.success ? counted$2(moved.data, false) : null;
15431
15431
  if (event !== null) past.push(event);
15432
15432
  }
15433
15433
  const before = countCycles(past, move.from, every).count;
@@ -15584,8 +15584,13 @@ async function conversationWaiting(trx, config, block, subject) {
15584
15584
  priority: ITEM_POLICY.conversation_waiting.priority
15585
15585
  };
15586
15586
  }
15587
- /** Reconciles every item in the caller's observation or tick transaction. */
15587
+ /**
15588
+ * Reconciles every item in the caller's observation or tick transaction. It first closes each
15589
+ * Done wrap-up turn whose holder session ended (`closeEndedDoneTurns`), so no stall item is
15590
+ * raised for it.
15591
+ */
15588
15592
  async function reconcileItems(trx, config, now, spurComplete, warnSkipped, spurContinuityStartAt) {
15593
+ await closeEndedDoneTurns(trx, new Date(now));
15589
15594
  const candidates = [];
15590
15595
  const sources = await trx.selectFrom("source_state").selectAll().execute();
15591
15596
  const sourceById = new Map(sources.map((state) => [state.source, state]));
@@ -16105,17 +16110,49 @@ async function raiseAnomaly(trx, config, task, input, executorId) {
16105
16110
  });
16106
16111
  }
16107
16112
  /** Clears a reconciled item; a ledger item's open block is withdrawn by the board first. */
16108
- async function clearReconciled(trx, item, at) {
16113
+ async function clearReconciled(trx, item, at, reason = "condition ended") {
16109
16114
  if (item.block_id !== null) {
16110
16115
  const ctx = {
16111
16116
  actor: "system",
16112
16117
  at: at.toISOString()
16113
16118
  };
16114
- await closeBlockIfOpen(trx, item.block_id, ctx, "withdrawn", "condition ended");
16119
+ await closeBlockIfOpen(trx, item.block_id, ctx, "withdrawn", reason);
16115
16120
  }
16116
16121
  await clearItem(trx, item.id, at);
16117
16122
  }
16118
16123
  /**
16124
+ * Closes, as `moved`, each taken Done wrap-up turn of an unarchived Done task whose agent holder
16125
+ * session ended, and withdraws the stall items of that turn and holder with a reason naming both.
16126
+ * The holder can no longer submit, so a stall block on its turn would never clear.
16127
+ */
16128
+ async function closeEndedDoneTurns(trx, at) {
16129
+ const turns = await trx.selectFrom("turn").innerJoin("task", "task.id", "turn.task_id").select([
16130
+ "turn.id",
16131
+ "turn.task_id",
16132
+ "turn.acked_by"
16133
+ ]).where("turn.closed_at", "is", null).where("turn.acked_at", "is not", null).where("turn.role", "!=", "operator").where("turn.column", "=", "done").where("task.column", "=", "done").where("task.membership", "!=", "archived").orderBy("turn.id").execute();
16134
+ for (const turn of turns) {
16135
+ const holder = turn.acked_by === null ? void 0 : parseActorId(turn.acked_by);
16136
+ if (holder?.actor !== "agent") continue;
16137
+ const sessionId = holder.actorRef.session;
16138
+ const session = await trx.selectFrom("session_snapshot").select("ended_at").where("id", "=", sessionId).executeTakeFirst();
16139
+ if (session === void 0 || session.ended_at === null) continue;
16140
+ await closeTurns(trx, {
16141
+ taskId: turn.task_id,
16142
+ reason: "moved",
16143
+ at
16144
+ });
16145
+ const keys = [`stuck-turn:${String(turn.id)}`, healthKey(turn.task_id, {
16146
+ taskId: String(turn.task_id),
16147
+ sessionId,
16148
+ kind: "worker_lost"
16149
+ })];
16150
+ const items = await trx.selectFrom("operator_item").selectAll().where("item_key", "in", keys).where("cleared_at", "is", null).execute();
16151
+ const reason = `turn T${String(turn.id)} closed: its holder ${sessionId} ended in Done`;
16152
+ for (const item of items) await clearReconciled(trx, item, at, reason);
16153
+ }
16154
+ }
16155
+ /**
16119
16156
  * Raises the cycle-limit block of a task's column, once while it is open. The operator's close
16120
16157
  * of the block or its item is the reset: a later call opens a new block.
16121
16158
  */
@@ -20802,7 +20839,7 @@ const CLOSING_FIELDS = "nodes { number repository { nameWithOwner } } pageInfo {
20802
20839
  const prFields = (number, closing = false) => `id number url title updatedAt mergedAt closedAt state isDraft mergeable mergeStateStatus
20803
20840
  author { login } headRefName headRefOid
20804
20841
  statusCheckRollup { contexts(first: 100) { nodes {
20805
- ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt } isRequired(pullRequestNumber: ${String(number)}) }
20842
+ ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt workflowRun { workflow { id } } app { id } } isRequired(pullRequestNumber: ${String(number)}) }
20806
20843
  ... on StatusContext { __typename context state createdAt isRequired(pullRequestNumber: ${String(number)}) }
20807
20844
  } pageInfo { hasNextPage endCursor } } }
20808
20845
  reviews(first: 100) { nodes { ${REVIEW_FIELDS} } pageInfo { hasNextPage endCursor } }
@@ -20831,7 +20868,7 @@ function detailQuery(numbers, closing = false) {
20831
20868
  function pageQuery(connection, bootstrap = false) {
20832
20869
  if (connection === "comments") return `query PrPage($owner: String!, $repo: String!, $number: Int!, $before: String!) { rateLimit { cost limit remaining resetAt } repository(owner: $owner, name: $repo) { pullRequest(number: $number) { comments(last: 100, before: $before) { ${COMMENT_FIELDS} } } } }`;
20833
20870
  if (connection === "pullRequests") return `query DiscoveryPage($owner: String!, $repo: String!, $after: String!) { rateLimit { cost limit remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, after: $after, states: [${discoveryStates(bootstrap)}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} } } }`;
20834
- return `query PrPage($owner: String!, $repo: String!, $number: Int!, $after: String!) { rateLimit { cost limit 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" ? THREAD_FIELDS : REVIEWER_FIELDS} } pageInfo { hasNextPage endCursor } }`} } } }`;
20871
+ return `query PrPage($owner: String!, $repo: String!, $number: Int!, $after: String!) { rateLimit { cost limit 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 workflowRun { workflow { id } } app { id } } 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" ? THREAD_FIELDS : REVIEWER_FIELDS} } pageInfo { hasNextPage endCursor } }`} } } }`;
20835
20872
  }
20836
20873
  /**
20837
20874
  * The failure that GraphQL `errors` mean for the whole request, in rule order: a rate limit is
@@ -20920,6 +20957,217 @@ var GithubClient = class {
20920
20957
  };
20921
20958
  }
20922
20959
  };
20960
+ // ../adapters/src/github/checks.ts
20961
+ const checkRunWire = z.object({
20962
+ __typename: z.literal("CheckRun"),
20963
+ name: z.string(),
20964
+ status: z.string(),
20965
+ conclusion: z.string().nullable(),
20966
+ startedAt: z.string().nullish(),
20967
+ completedAt: z.string().nullable(),
20968
+ checkSuite: z.object({
20969
+ createdAt: z.string(),
20970
+ workflowRun: z.object({ workflow: z.object({ id: z.string().min(1) }) }).nullish(),
20971
+ app: z.object({ id: z.string().min(1) }).nullish()
20972
+ }).nullish(),
20973
+ isRequired: z.boolean().nullish()
20974
+ }).refine((run) => run.status !== "COMPLETED" || run.conclusion !== null, { path: ["conclusion"] });
20975
+ const statusContextWire = z.object({
20976
+ __typename: z.literal("StatusContext"),
20977
+ context: z.string(),
20978
+ state: z.string(),
20979
+ createdAt: z.string(),
20980
+ isRequired: z.boolean().nullish()
20981
+ });
20982
+ const contextWire = z.discriminatedUnion("__typename", [checkRunWire, statusContextWire]);
20983
+ /** The contracts check state of a check run or commit status. */
20984
+ function checkState(node) {
20985
+ if (node.__typename === "StatusContext") {
20986
+ const state = node.state.toLowerCase();
20987
+ return state === "success" ? "success" : state === "pending" ? "pending" : state === "expected" ? "expected" : "failure";
20988
+ }
20989
+ if (node.status !== "COMPLETED") return "pending";
20990
+ const value = node.conclusion?.toLowerCase();
20991
+ return [
20992
+ "success",
20993
+ "neutral",
20994
+ "skipped",
20995
+ "failure",
20996
+ "cancelled",
20997
+ "timed_out",
20998
+ "action_required",
20999
+ "stale"
21000
+ ].find((state) => state === value) ?? "error";
21001
+ }
21002
+ /** When a context ran, to keep the latest of each check; an empty string sorts first. */
21003
+ function contextAt(node) {
21004
+ return node.__typename === "StatusContext" ? node.createdAt : node.startedAt ?? node.checkSuite?.createdAt ?? node.completedAt ?? "";
21005
+ }
21006
+ /** The display name of a check run or commit status. */
21007
+ function contextName(node) {
21008
+ return node.__typename === "StatusContext" ? node.context : node.name;
21009
+ }
21010
+ /**
21011
+ * Only reruns of one check replace each other: a commit status by its context, an Actions check
21012
+ * run by its workflow and job name, another check run by its app and name. A check run with
21013
+ * neither, as in the older recordings, falls back to its name.
21014
+ */
21015
+ function checkKey(node) {
21016
+ if (node.__typename === "StatusContext") return `status:${node.context}`;
21017
+ const workflow = node.checkSuite?.workflowRun?.workflow.id;
21018
+ if (workflow !== void 0) return `check:${workflow}:${node.name}`;
21019
+ const app = node.checkSuite?.app?.id;
21020
+ return app === void 0 ? `name:${node.name}` : `app:${app}:${node.name}`;
21021
+ }
21022
+ /**
21023
+ * The latest node of each check (see `checkKey`), sorted by display name, then key. Of two runs
21024
+ * with one time the later node wins.
21025
+ */
21026
+ function latestContexts(nodes) {
21027
+ const latest = /* @__PURE__ */ new Map();
21028
+ for (const node of nodes) {
21029
+ const key = checkKey(node);
21030
+ const old = latest.get(key);
21031
+ if (old !== void 0 && contextAt(old) > contextAt(node)) continue;
21032
+ latest.set(key, node);
21033
+ }
21034
+ return [...latest.entries()].sort(([a, x], [b, y]) => contextName(x).localeCompare(contextName(y)) || a.localeCompare(b)).map(([, node]) => node);
21035
+ }
21036
+ // ../adapters/src/github/discovery.ts
21037
+ const timestamp$1 = z.string().min(1).refine((value) => !Number.isNaN(Date.parse(value)));
21038
+ const discoveryNodeWire = z.object({
21039
+ number: z.int().positive(),
21040
+ state: z.string().optional(),
21041
+ updatedAt: timestamp$1,
21042
+ author: z.object({ login: z.string() }).nullable()
21043
+ });
21044
+ const baselineNodeWire = z.object({ updatedAt: timestamp$1 });
21045
+ function latestUpdatedAt(nodes, previous) {
21046
+ let high = previous;
21047
+ for (const node of nodes) {
21048
+ const updated = sourceCursorSchema.parse(node.updatedAt);
21049
+ if (high === void 0 || Date.parse(updated) > Date.parse(high)) high = updated;
21050
+ }
21051
+ return high;
21052
+ }
21053
+ /** The high-water cursor is an ISO timestamp. Equal timestamps are revisited. */
21054
+ function discover(nodes, previous, login) {
21055
+ let high = previous;
21056
+ const numbers = /* @__PURE__ */ new Set();
21057
+ const states = /* @__PURE__ */ new Map();
21058
+ for (const node of nodes) {
21059
+ const updated = sourceCursorSchema.parse(node.updatedAt);
21060
+ const updatedMs = Date.parse(updated);
21061
+ if (high === void 0 || updatedMs > Date.parse(high)) high = updated;
21062
+ if (previous !== void 0 && updatedMs < Date.parse(previous)) continue;
21063
+ states.set(node.number, node.state);
21064
+ if (node.author?.login.toLowerCase() !== login.toLowerCase()) continue;
21065
+ numbers.add(node.number);
21066
+ }
21067
+ return {
21068
+ numbers: [...numbers],
21069
+ states,
21070
+ ...high === void 0 ? {} : { cursor: high }
21071
+ };
21072
+ }
21073
+ /** Pages are sorted newest first; older nodes end the scan, while ties must be revisited. */
21074
+ function pastCursor(nodes, previous) {
21075
+ const oldest = nodes.at(-1);
21076
+ if (previous === void 0 || oldest === void 0) return false;
21077
+ return Date.parse(oldest.updatedAt) < Date.parse(previous);
21078
+ }
21079
+ function nextPage(connection) {
21080
+ const { hasNextPage, endCursor } = connection.pageInfo;
21081
+ if (!hasNextPage) return void 0;
21082
+ if (!endCursor) throw new Error("Malformed GitHub pagination");
21083
+ return endCursor;
21084
+ }
21085
+ const branchCheckRunWire = z.object({
21086
+ __typename: z.literal("CheckRun"),
21087
+ name: z.string(),
21088
+ status: z.string(),
21089
+ conclusion: z.string().nullable(),
21090
+ startedAt: z.string().nullish(),
21091
+ completedAt: z.string().nullable(),
21092
+ detailsUrl: z.string().nullish(),
21093
+ checkSuite: z.object({
21094
+ createdAt: z.string(),
21095
+ workflowRun: z.object({
21096
+ event: z.string(),
21097
+ workflow: z.object({ id: z.string().min(1) })
21098
+ }).nullish()
21099
+ }).nullish()
21100
+ });
21101
+ const branchStatusWire = z.object({
21102
+ __typename: z.literal("StatusContext"),
21103
+ context: z.string(),
21104
+ state: z.string(),
21105
+ createdAt: z.string(),
21106
+ targetUrl: z.string().nullish()
21107
+ });
21108
+ const branchContextWire = z.discriminatedUnion("__typename", [branchCheckRunWire, branchStatusWire]);
21109
+ const defaultBranchWire = z.object({ defaultBranchRef: z.object({
21110
+ name: z.string(),
21111
+ target: z.object({
21112
+ __typename: z.literal("Commit"),
21113
+ oid: z.string(),
21114
+ statusCheckRollup: z.object({ contexts: z.object({
21115
+ nodes: z.array(branchContextWire),
21116
+ pageInfo: z.object({ hasNextPage: z.boolean() })
21117
+ }) })
21118
+ })
21119
+ }) });
21120
+ function counted$1(node) {
21121
+ return node.__typename === "StatusContext" || node.checkSuite?.workflowRun?.event === "push";
21122
+ }
21123
+ const PASSED = /* @__PURE__ */ new Set([
21124
+ "success",
21125
+ "neutral",
21126
+ "skipped"
21127
+ ]);
21128
+ const RUNNING = /* @__PURE__ */ new Set(["pending", "expected"]);
21129
+ /**
21130
+ * The colour of the default-branch head in a discovery response's `repository`, or undefined
21131
+ * when it is unknown: an unexpected shape, a running head, no counted check, or a truncated page
21132
+ * with no failure in it. Only check runs of push-triggered workflows and commit statuses count;
21133
+ * the latest run of each check decides (see `latestContexts`). A run URL that is not http(s)
21134
+ * becomes null.
21135
+ */
21136
+ function defaultBranchFact(repository) {
21137
+ const parsed = defaultBranchWire.safeParse(repository);
21138
+ if (!parsed.success) return void 0;
21139
+ const { name: branch, target } = parsed.data.defaultBranchRef;
21140
+ const { nodes, pageInfo } = target.statusCheckRollup.contexts;
21141
+ const kept = latestContexts(nodes.filter(counted$1)).map((node) => ({
21142
+ check: contextName(node),
21143
+ node,
21144
+ state: checkState(node)
21145
+ }));
21146
+ const failing = kept.find(({ state }) => !PASSED.has(state) && !RUNNING.has(state));
21147
+ if (failing !== void 0) {
21148
+ const { check, node } = failing;
21149
+ const url = (node.__typename === "StatusContext" ? node.targetUrl : node.detailsUrl) ?? null;
21150
+ const red = {
21151
+ state: "red",
21152
+ branch,
21153
+ sha: target.oid,
21154
+ check,
21155
+ url
21156
+ };
21157
+ const fact = defaultBranchFactSchema.safeParse(red);
21158
+ if (fact.success) return fact.data;
21159
+ return url === null ? void 0 : defaultBranchFactSchema.safeParse({
21160
+ ...red,
21161
+ url: null
21162
+ }).data;
21163
+ }
21164
+ if (kept.length === 0 || pageInfo.hasNextPage || kept.some(({ state }) => !PASSED.has(state))) return void 0;
21165
+ return defaultBranchFactSchema.safeParse({
21166
+ state: "green",
21167
+ branch,
21168
+ sha: target.oid
21169
+ }).data;
21170
+ }
20923
21171
  // ../adapters/src/github/feedbackLinks.ts
20924
21172
  const threadCommentWire = z.object({
20925
21173
  id: z.string().min(1),
@@ -20971,24 +21219,6 @@ const typedActor = z.object({
20971
21219
  __typename: z.string(),
20972
21220
  login: z.string().min(1)
20973
21221
  }).nullable();
20974
- const checkRunWire = z.object({
20975
- __typename: z.literal("CheckRun"),
20976
- name: z.string(),
20977
- status: z.string(),
20978
- conclusion: z.string().nullable(),
20979
- startedAt: z.string().nullish(),
20980
- completedAt: z.string().nullable(),
20981
- checkSuite: z.object({ createdAt: z.string() }).nullish(),
20982
- isRequired: z.boolean().nullish()
20983
- }).refine((run) => run.status !== "COMPLETED" || run.conclusion !== null, { path: ["conclusion"] });
20984
- const statusContextWire = z.object({
20985
- __typename: z.literal("StatusContext"),
20986
- context: z.string(),
20987
- state: z.string(),
20988
- createdAt: z.string(),
20989
- isRequired: z.boolean().nullish()
20990
- });
20991
- const contextWire = z.discriminatedUnion("__typename", [checkRunWire, statusContextWire]);
20992
21222
  const reviewWire = z.object({
20993
21223
  id: z.string().min(1),
20994
21224
  author: typedActor,
@@ -21097,49 +21327,15 @@ function closingRefs(wire) {
21097
21327
  number: node.number
21098
21328
  }] : []);
21099
21329
  }
21100
- /** The contracts check state of a check run or commit status. */
21101
- function checkState(node) {
21102
- if (node.__typename === "StatusContext") {
21103
- const state = node.state.toLowerCase();
21104
- return state === "success" ? "success" : state === "pending" ? "pending" : state === "expected" ? "expected" : "failure";
21105
- }
21106
- if (node.status !== "COMPLETED") return "pending";
21107
- const value = node.conclusion?.toLowerCase();
21108
- return [
21109
- "success",
21110
- "neutral",
21111
- "skipped",
21112
- "failure",
21113
- "cancelled",
21114
- "timed_out",
21115
- "action_required",
21116
- "stale"
21117
- ].find((state) => state === value) ?? "error";
21118
- }
21119
- /** When a context ran, to keep the latest per name; an empty string sorts first. */
21120
- function contextAt(node) {
21121
- return node.__typename === "StatusContext" ? node.createdAt : node.startedAt ?? node.checkSuite?.createdAt ?? node.completedAt ?? "";
21122
- }
21123
21330
  function latestChecks(nodes) {
21124
- const latest = /* @__PURE__ */ new Map();
21125
- for (const node of nodes) {
21126
- const status = node.__typename === "StatusContext";
21127
- const name = status ? node.context : node.name;
21128
- const completedAt = status ? null : node.completedAt;
21129
- const at = contextAt(node);
21130
- const old = latest.get(name);
21131
- if (old !== void 0 && old.at > at) continue;
21132
- latest.set(name, {
21133
- check: {
21134
- name,
21135
- state: checkState(node),
21136
- completedAt
21137
- },
21138
- required: node.isRequired === true,
21139
- at
21140
- });
21141
- }
21142
- const values = [...latest.values()].sort((a, b) => a.check.name.localeCompare(b.check.name));
21331
+ const values = latestContexts(nodes).map((node) => ({
21332
+ check: {
21333
+ name: contextName(node),
21334
+ state: checkState(node),
21335
+ completedAt: node.__typename === "StatusContext" ? null : node.completedAt
21336
+ },
21337
+ required: node.isRequired === true
21338
+ }));
21143
21339
  return {
21144
21340
  checks: values.map((v) => v.check),
21145
21341
  requiredChecks: values.filter((v) => v.required).map((v) => v.check)
@@ -21352,158 +21548,6 @@ function normalizePr(repo, value, rule, feedbackComplete, held = []) {
21352
21548
  if (!parsed.success) throw new AdapterError("transient", "Malformed GitHub PR facts", { cause: parsed.error });
21353
21549
  return parsed.data;
21354
21550
  }
21355
- // ../adapters/src/github/discovery.ts
21356
- const timestamp$1 = z.string().min(1).refine((value) => !Number.isNaN(Date.parse(value)));
21357
- const discoveryNodeWire = z.object({
21358
- number: z.int().positive(),
21359
- state: z.string().optional(),
21360
- updatedAt: timestamp$1,
21361
- author: z.object({ login: z.string() }).nullable()
21362
- });
21363
- const baselineNodeWire = z.object({ updatedAt: timestamp$1 });
21364
- function latestUpdatedAt(nodes, previous) {
21365
- let high = previous;
21366
- for (const node of nodes) {
21367
- const updated = sourceCursorSchema.parse(node.updatedAt);
21368
- if (high === void 0 || Date.parse(updated) > Date.parse(high)) high = updated;
21369
- }
21370
- return high;
21371
- }
21372
- /** The high-water cursor is an ISO timestamp. Equal timestamps are revisited. */
21373
- function discover(nodes, previous, login) {
21374
- let high = previous;
21375
- const numbers = /* @__PURE__ */ new Set();
21376
- const states = /* @__PURE__ */ new Map();
21377
- for (const node of nodes) {
21378
- const updated = sourceCursorSchema.parse(node.updatedAt);
21379
- const updatedMs = Date.parse(updated);
21380
- if (high === void 0 || updatedMs > Date.parse(high)) high = updated;
21381
- if (previous !== void 0 && updatedMs < Date.parse(previous)) continue;
21382
- states.set(node.number, node.state);
21383
- if (node.author?.login.toLowerCase() !== login.toLowerCase()) continue;
21384
- numbers.add(node.number);
21385
- }
21386
- return {
21387
- numbers: [...numbers],
21388
- states,
21389
- ...high === void 0 ? {} : { cursor: high }
21390
- };
21391
- }
21392
- /** Pages are sorted newest first; older nodes end the scan, while ties must be revisited. */
21393
- function pastCursor(nodes, previous) {
21394
- const oldest = nodes.at(-1);
21395
- if (previous === void 0 || oldest === void 0) return false;
21396
- return Date.parse(oldest.updatedAt) < Date.parse(previous);
21397
- }
21398
- function nextPage(connection) {
21399
- const { hasNextPage, endCursor } = connection.pageInfo;
21400
- if (!hasNextPage) return void 0;
21401
- if (!endCursor) throw new Error("Malformed GitHub pagination");
21402
- return endCursor;
21403
- }
21404
- const branchCheckRunWire = z.object({
21405
- __typename: z.literal("CheckRun"),
21406
- name: z.string(),
21407
- status: z.string(),
21408
- conclusion: z.string().nullable(),
21409
- startedAt: z.string().nullish(),
21410
- completedAt: z.string().nullable(),
21411
- detailsUrl: z.string().nullish(),
21412
- checkSuite: z.object({
21413
- createdAt: z.string(),
21414
- workflowRun: z.object({
21415
- event: z.string(),
21416
- workflow: z.object({ id: z.string().min(1) })
21417
- }).nullish()
21418
- }).nullish()
21419
- });
21420
- const branchStatusWire = z.object({
21421
- __typename: z.literal("StatusContext"),
21422
- context: z.string(),
21423
- state: z.string(),
21424
- createdAt: z.string(),
21425
- targetUrl: z.string().nullish()
21426
- });
21427
- const branchContextWire = z.discriminatedUnion("__typename", [branchCheckRunWire, branchStatusWire]);
21428
- const defaultBranchWire = z.object({ defaultBranchRef: z.object({
21429
- name: z.string(),
21430
- target: z.object({
21431
- __typename: z.literal("Commit"),
21432
- oid: z.string(),
21433
- statusCheckRollup: z.object({ contexts: z.object({
21434
- nodes: z.array(branchContextWire),
21435
- pageInfo: z.object({ hasNextPage: z.boolean() })
21436
- }) })
21437
- })
21438
- }) });
21439
- /**
21440
- * Only reruns of one check replace each other: a commit status by its context, a check run by
21441
- * its workflow and job name. A check run outside a push-triggered workflow has no key.
21442
- */
21443
- function checkKey(node) {
21444
- if (node.__typename === "StatusContext") return `status:${node.context}`;
21445
- const run = node.checkSuite?.workflowRun;
21446
- if (run?.event !== "push") return void 0;
21447
- return `check:${run.workflow.id}:${node.name}`;
21448
- }
21449
- const PASSED = /* @__PURE__ */ new Set([
21450
- "success",
21451
- "neutral",
21452
- "skipped"
21453
- ]);
21454
- const RUNNING = /* @__PURE__ */ new Set(["pending", "expected"]);
21455
- /**
21456
- * The colour of the default-branch head in a discovery response's `repository`, or undefined
21457
- * when it is unknown: an unexpected shape, a running head, no counted check, or a truncated page
21458
- * with no failure in it. Only check runs of push-triggered workflows and commit statuses count;
21459
- * the latest run of each check decides (see `checkKey`). A run URL that is not http(s) becomes null.
21460
- */
21461
- function defaultBranchFact(repository) {
21462
- const parsed = defaultBranchWire.safeParse(repository);
21463
- if (!parsed.success) return void 0;
21464
- const { name: branch, target } = parsed.data.defaultBranchRef;
21465
- const { nodes, pageInfo } = target.statusCheckRollup.contexts;
21466
- const latest = /* @__PURE__ */ new Map();
21467
- for (const node of nodes) {
21468
- const key = checkKey(node);
21469
- if (key === void 0) continue;
21470
- const old = latest.get(key);
21471
- if (old !== void 0 && contextAt(old.node) > contextAt(node)) continue;
21472
- latest.set(key, {
21473
- check: node.__typename === "StatusContext" ? node.context : node.name,
21474
- node
21475
- });
21476
- }
21477
- const kept = [...latest.entries()].sort(([a, x], [b, y]) => x.check.localeCompare(y.check) || a.localeCompare(b)).map(([, { check, node }]) => ({
21478
- check,
21479
- node,
21480
- state: checkState(node)
21481
- }));
21482
- const failing = kept.find(({ state }) => !PASSED.has(state) && !RUNNING.has(state));
21483
- if (failing !== void 0) {
21484
- const { check, node } = failing;
21485
- const url = (node.__typename === "StatusContext" ? node.targetUrl : node.detailsUrl) ?? null;
21486
- const red = {
21487
- state: "red",
21488
- branch,
21489
- sha: target.oid,
21490
- check,
21491
- url
21492
- };
21493
- const fact = defaultBranchFactSchema.safeParse(red);
21494
- if (fact.success) return fact.data;
21495
- return url === null ? void 0 : defaultBranchFactSchema.safeParse({
21496
- ...red,
21497
- url: null
21498
- }).data;
21499
- }
21500
- if (kept.length === 0 || pageInfo.hasNextPage || kept.some(({ state }) => !PASSED.has(state))) return void 0;
21501
- return defaultBranchFactSchema.safeParse({
21502
- state: "green",
21503
- branch,
21504
- sha: target.oid
21505
- }).data;
21506
- }
21507
21551
  const counted = (node) => z.object({
21508
21552
  totalCount: z.int().nonnegative(),
21509
21553
  nodes: z.array(node)
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { et as ERRORS, p as OPERATIONS, v as renderMcpError } from "./chunk-C34hsfqb.mjs";
2
- import { o as CliError, r as requestOperation } from "./chunk-Dz9IMhY5.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-4C7tYXYO.mjs";
1
+ import { et as ERRORS, p as OPERATIONS, v as renderMcpError } from "./chunk-DGsDK61k.mjs";
2
+ import { o as CliError, r as requestOperation } from "./chunk-2UOGIWN_.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-BTkdnlO3.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.104.1",
3
+ "version": "0.104.3",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"
@@ -4,3 +4,12 @@
4
4
 
5
5
  One linked PR merging does not by itself finish the task. Done: `projects[].tracker.doneStatuses` for Jira; for GitHub, the Issue must be
6
6
  closed. If still open, link another PR.
7
+
8
+ ## Done wrap-up
9
+
10
+ Entering Done opens one wrap-up turn (`done: wrap up`) for the live worker, or for the Done
11
+ column's orchestrator (`projects[].columns[].orchestrator`); none for an operator Done or when no
12
+ live worker is seen. It closes like any turn (submit, the task leaving Done, archive), and
13
+ also when its holder session ends: that close shows `turn_closed` outcome `moved`, and the
14
+ holder's end raises no stall block on it. After an end, a live worker still linked to the task,
15
+ or the Done orchestrator, gets a new one.