spur-board 0.53.2 → 0.54.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.
@@ -1,5 +1,5 @@
1
- import { _ as buildCatalogSnapshot, ct as plainHttpAllowed, st as configSchema, y as OPERATIONS } from "./chunk-DyHtyPom.mjs";
2
- import { o as CliError, t as fetchCatalogVersion } from "./chunk-Z9DFhl-U.mjs";
1
+ import { _ as buildCatalogSnapshot, ct as plainHttpAllowed, st as configSchema, y as OPERATIONS } from "./chunk-DjHqB_QC.mjs";
2
+ import { o as CliError, t as fetchCatalogVersion } from "./chunk-DgTcmpig.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";
@@ -1,4 +1,4 @@
1
- import { $ as errorEnvelopeSchema, Q as errorContextSchema, S as renderJsonError, X as ERRORS, c as tokenRequestStatusSchema, o as tokenRequestResultSchema, tt as successEnvelopeSchema } from "./chunk-DyHtyPom.mjs";
1
+ import { $ as errorEnvelopeSchema, Q as errorContextSchema, S as renderJsonError, X as ERRORS, c as tokenRequestStatusSchema, o as tokenRequestResultSchema, tt as successEnvelopeSchema } from "./chunk-DjHqB_QC.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { request } from "node:http";
@@ -105,6 +105,21 @@ const SESSION_END_REASONS = [
105
105
  ];
106
106
  /** How a project's dispatcher runs: `shadow` records moves only, `on` moves tasks and opens turns. */
107
107
  const DISPATCHER_MODES = ["shadow", "on"];
108
+ /**
109
+ * How a turn closed: `submitted` by the executor's submit, `returned` by `task.return`, `moved`
110
+ * when the task moved on (it also covers returns and mode switches recorded by older versions),
111
+ * `corrected` by the operator's column correction, `rerouted` to another executor,
112
+ * `mode_changed` by a dispatcher mode switch, `archived` with the task.
113
+ */
114
+ const TURN_OUTCOMES = [
115
+ "submitted",
116
+ "returned",
117
+ "moved",
118
+ "corrected",
119
+ "rerouted",
120
+ "mode_changed",
121
+ "archived"
122
+ ];
108
123
  /** The exit conditions of the column gates, as `board task --why` names them. */
109
124
  const GATE_CONDITIONS = [
110
125
  "pr_open",
@@ -1394,7 +1409,9 @@ const eventPayloadSchemas = {
1394
1409
  task_submitted: z.looseObject({
1395
1410
  turn: S.optional(),
1396
1411
  column: z.enum(COLUMN_IDS),
1397
- sha: S
1412
+ sha: S,
1413
+ /** The head was confirmed by the board's newest poll; GitHub did not answer the submit. */
1414
+ confirmedByPoll: z.literal(true).optional()
1398
1415
  }),
1399
1416
  task_moved: z.looseObject({
1400
1417
  from: z.enum(COLUMN_IDS),
@@ -1881,6 +1898,17 @@ const turnViewSchema = z.strictObject({
1881
1898
  at: z.iso.datetime().describe("When the turn was taken, ISO 8601 UTC.")
1882
1899
  }).nullable().describe("Who took the turn and when; null until it is taken.")
1883
1900
  }).describe("A turn: the executor of a column is asked to act on a task.");
1901
+ /** A turn as `task.get` shows it: who executes it, whether it was taken, and how it closed. */
1902
+ const taskTurnSchema = turnViewSchema.pick({
1903
+ id: true,
1904
+ column: true,
1905
+ addressee: true,
1906
+ at: true,
1907
+ taken: true
1908
+ }).extend({ closed: z.strictObject({
1909
+ at: z.iso.datetime().describe("When the turn closed, ISO 8601 UTC."),
1910
+ outcome: z.enum(TURN_OUTCOMES).describe("How the turn closed; turns closed by a return or a mode switch before those were recorded read moved.")
1911
+ }).nullable().describe("How and when the turn closed; null while it is open.") }).describe("A task's turn: the executor of a column is asked to act on it.");
1884
1912
  /** One column move from the journal: a dispatcher move, a return to Dev or a correction. */
1885
1913
  const moveViewSchema = z.strictObject({
1886
1914
  at: z.iso.datetime().describe("When the task moved, ISO 8601 UTC."),
@@ -2136,6 +2164,15 @@ const reviewTurn = {
2136
2164
  at,
2137
2165
  taken: null
2138
2166
  };
2167
+ const devTurn = {
2168
+ id: "T3",
2169
+ column: "dev",
2170
+ addressee: "worker",
2171
+ at,
2172
+ taken: null,
2173
+ closed: null
2174
+ };
2175
+ const later = "2026-01-05T10:15:00.000Z";
2139
2176
  const handedReview = {
2140
2177
  repo: "acme/web",
2141
2178
  number: 42,
@@ -2344,17 +2381,20 @@ const OPERATIONS = [
2344
2381
  defineOperation({
2345
2382
  id: "task.get",
2346
2383
  kind: "query",
2347
- description: "Show a task with its links, blocks and comments.",
2384
+ description: "Show a task with its open turn, links, blocks and comments.",
2348
2385
  mcp: {
2349
- whenToUse: "Inspect one task now.",
2386
+ whenToUse: "Inspect one task now; pass detail for its last closed turns.",
2350
2387
  whenNotToUse: "Use task_history for past events."
2351
2388
  },
2352
2389
  input: z.strictObject({
2353
2390
  task: taskKeyInputSchema,
2391
+ detail: z.boolean().optional().describe("Also list the last 5 closed turns, newest first; absent means none."),
2354
2392
  why: z.boolean().optional().describe("Explain why the task is in its column: gates, holds, the open turn and the last moves; absent means no explanation.")
2355
2393
  }),
2356
2394
  output: z.strictObject({
2357
2395
  task: taskViewSchema,
2396
+ turn: taskTurnSchema.nullable().describe("The task's unclosed turn; null when none is open."),
2397
+ turns: z.array(taskTurnSchema).optional().describe("Present only with detail: the last 5 closed turns, newest first."),
2358
2398
  links: z.array(linkViewSchema).describe("Effective pull request, session, and ticket links."),
2359
2399
  blocks: z.array(blockViewSchema).describe("Blocks on the task, open and unblocked."),
2360
2400
  comments: z.array(commentSchema).describe("Comments on the task, oldest first."),
@@ -2370,56 +2410,100 @@ const OPERATIONS = [
2370
2410
  kind: "slash-command",
2371
2411
  usage: "/board task <KEY> [why]"
2372
2412
  },
2373
- examples: [{
2374
- summary: "Show one task",
2375
- input: { task: "PROJ-123" },
2376
- output: {
2377
- task,
2378
- links: [],
2379
- blocks: [question],
2380
- comments: [comment]
2381
- }
2382
- }, {
2383
- summary: "Explain why a task waits in Review",
2384
- input: {
2385
- task: "PROJ-123",
2386
- why: true
2413
+ examples: [
2414
+ {
2415
+ summary: "Show one task",
2416
+ input: { task: "PROJ-123" },
2417
+ output: {
2418
+ task,
2419
+ turn: devTurn,
2420
+ links: [],
2421
+ blocks: [question],
2422
+ comments: [comment]
2423
+ }
2387
2424
  },
2388
- output: {
2389
- task: {
2390
- ...task,
2391
- column: "review"
2425
+ {
2426
+ summary: "Explain why a task waits in Review",
2427
+ input: {
2428
+ task: "PROJ-123",
2429
+ why: true
2392
2430
  },
2393
- links: [],
2394
- blocks: [],
2395
- comments: [],
2396
- why: {
2397
- column: "review",
2398
- dispatcher: "on",
2399
- holds: [],
2400
- gates: reviewGates,
2401
- checksWaivedBy: null,
2431
+ output: {
2432
+ task: {
2433
+ ...task,
2434
+ column: "review"
2435
+ },
2402
2436
  turn: {
2403
- ...reviewTurn,
2404
- handed: [],
2437
+ id: reviewTurn.id,
2438
+ column: reviewTurn.column,
2439
+ addressee: reviewTurn.addressee,
2440
+ at,
2405
2441
  taken: {
2406
2442
  by: "agent:rev/rev-1",
2407
2443
  at
2444
+ },
2445
+ closed: null
2446
+ },
2447
+ links: [],
2448
+ blocks: [],
2449
+ comments: [],
2450
+ why: {
2451
+ column: "review",
2452
+ dispatcher: "on",
2453
+ holds: [],
2454
+ gates: reviewGates,
2455
+ checksWaivedBy: null,
2456
+ turn: {
2457
+ ...reviewTurn,
2458
+ handed: [],
2459
+ taken: {
2460
+ by: "agent:rev/rev-1",
2461
+ at
2462
+ }
2463
+ },
2464
+ moves: [{
2465
+ at,
2466
+ kind: "task_moved",
2467
+ actor: "system",
2468
+ from: "dev",
2469
+ to: "review",
2470
+ reason: "gate_passed",
2471
+ gate: [],
2472
+ text: null
2473
+ }]
2474
+ }
2475
+ }
2476
+ },
2477
+ {
2478
+ summary: "Show a task with its last closed turns",
2479
+ input: {
2480
+ task: "PROJ-123",
2481
+ detail: true
2482
+ },
2483
+ output: {
2484
+ task,
2485
+ turn: {
2486
+ ...devTurn,
2487
+ id: "T4",
2488
+ at: later,
2489
+ taken: {
2490
+ by: "agent:web/web-7",
2491
+ at: later
2408
2492
  }
2409
2493
  },
2410
- moves: [{
2411
- at,
2412
- kind: "task_moved",
2413
- actor: "system",
2414
- from: "dev",
2415
- to: "review",
2416
- reason: "gate_passed",
2417
- gate: [],
2418
- text: null
2419
- }]
2494
+ turns: [{
2495
+ ...devTurn,
2496
+ closed: {
2497
+ at: later,
2498
+ outcome: "submitted"
2499
+ }
2500
+ }],
2501
+ links: [],
2502
+ blocks: [],
2503
+ comments: []
2420
2504
  }
2421
2505
  }
2422
- }]
2506
+ ]
2423
2507
  }),
2424
2508
  defineOperation({
2425
2509
  id: "task.history",
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { W as actorIdSchema, X as ERRORS, a as requestHashOf, ft as SLACK_BOT_SCOPES, lt as requiredSecretKeys, r as remoteDoctorReportSchema, st as configSchema, tt as successEnvelopeSchema, u as SYSTEMD_SERVICE_SETTINGS, v as roleCanUseOperation, y as OPERATIONS } from "./chunk-DyHtyPom.mjs";
1
+ import { W as actorIdSchema, X as ERRORS, a as requestHashOf, ft as SLACK_BOT_SCOPES, lt as requiredSecretKeys, r as remoteDoctorReportSchema, st as configSchema, tt as successEnvelopeSchema, u as SYSTEMD_SERVICE_SETTINGS, v as roleCanUseOperation, y as OPERATIONS } from "./chunk-DjHqB_QC.mjs";
2
2
  import { t as apiBaseUrl } from "./chunk-DAMwWWmT.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-Z9DFhl-U.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-BbwZCNQh.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-DgTcmpig.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-C7CHbmMl.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,2 +1,2 @@
1
- import { a as requestTokenEnrollment, i as requestSkillReload, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./chunk-Z9DFhl-U.mjs";
1
+ import { a as requestTokenEnrollment, i as requestSkillReload, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./chunk-DgTcmpig.mjs";
2
2
  export { fetchCatalogVersion, fetchTokenStatus, requestOperation, requestSkillReload, requestTokenEnrollment };
package/dist/daemon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as EVENT_KINDS, B as sessionFactsSchema, D as interactionRefSchema, E as inboundEventSchema, F as isExternalAuthor, G as encodeActorId, H as JIRA_PROJECT_KEY, I as parseRingMarker, J as parseRef$1, K as errorCodeOf, L as prFactsSchema, M as REVIEW_STATES, N as SESSION_HEALTH_STATES, O as messageRefSchema, P as SESSION_STATUSES, R as prRefSchema, T as conversationRefSchema, U as REF_NUMBER, V as ticketFactsSchema, W as actorIdSchema, X as ERRORS, Y as taskKeySchema, Z as err, _ as buildCatalogSnapshot, a as requestHashOf, at as DEFAULT_SLACK_COMMAND, b as turnHandedSchema, c as tokenRequestStatusSchema, ct as plainHttpAllowed, d as AdapterError, dt as DISPATCHER_MODES, et as ok, f as batchSchema, ft as SLACK_BOT_SCOPES, g as trackerSourceId, h as sourceCursorSchema, i as TOKEN_REQUEST_LIMITS, j as eventPayloadSchemas, k as userIdSchema, l as BOARD_TICK_MS, lt as requiredSecretKeys, m as prSourceId, n as doctorReportSchema, o as tokenRequestResultSchema, ot as RESERVED_PROJECT, p as entityRefSchema, q as parseActorId, rt as DEFAULT_LINK, s as tokenRequestSchema, st as configSchema, t as assertNever, tt as successEnvelopeSchema, ut as COLUMN_IDS, v as roleCanUseOperation, w as SPACE_IDS, x as renderHttpProblem, y as OPERATIONS, z as ringMarker } from "./chunk-DyHtyPom.mjs";
1
+ import { A as EVENT_KINDS, B as sessionFactsSchema, D as interactionRefSchema, E as inboundEventSchema, F as isExternalAuthor, G as encodeActorId, H as JIRA_PROJECT_KEY, I as parseRingMarker, J as parseRef$1, K as errorCodeOf, L as prFactsSchema, M as REVIEW_STATES, N as SESSION_HEALTH_STATES, O as messageRefSchema, P as SESSION_STATUSES, R as prRefSchema, T as conversationRefSchema, U as REF_NUMBER, V as ticketFactsSchema, W as actorIdSchema, X as ERRORS, Y as taskKeySchema, Z as err, _ as buildCatalogSnapshot, a as requestHashOf, at as DEFAULT_SLACK_COMMAND, b as turnHandedSchema, c as tokenRequestStatusSchema, ct as plainHttpAllowed, d as AdapterError, dt as DISPATCHER_MODES, et as ok, f as batchSchema, ft as SLACK_BOT_SCOPES, g as trackerSourceId, h as sourceCursorSchema, i as TOKEN_REQUEST_LIMITS, j as eventPayloadSchemas, k as userIdSchema, l as BOARD_TICK_MS, lt as requiredSecretKeys, m as prSourceId, n as doctorReportSchema, o as tokenRequestResultSchema, ot as RESERVED_PROJECT, p as entityRefSchema, q as parseActorId, rt as DEFAULT_LINK, s as tokenRequestSchema, st as configSchema, t as assertNever, tt as successEnvelopeSchema, ut as COLUMN_IDS, v as roleCanUseOperation, w as SPACE_IDS, x as renderHttpProblem, y as OPERATIONS, z as ringMarker } from "./chunk-DjHqB_QC.mjs";
2
2
  import { t as apiBaseUrl } from "./chunk-DAMwWWmT.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -14308,9 +14308,10 @@ async function voidSubmits(trx, taskId, to, at) {
14308
14308
  }
14309
14309
  /**
14310
14310
  * Moves a task left to `to` as a new visit: bumps `column_epoch` and `left_moves`, voids the
14311
- * submits of `to` and right of it, closes its turns and journals `task_moved`. In `on` mode a
14312
- * counted return that reaches the column's cycle limit raises its cycle-limit block; otherwise
14313
- * one that reaches its course check raises the course check. Either holds the task, and
14311
+ * submits of `to` and right of it, closes its turns (`returned` for a `task.return` of `turn`,
14312
+ * else `moved`) and journals `task_moved`. In `on` mode a counted return that reaches the
14313
+ * column's cycle limit raises its cycle-limit block; otherwise one that reaches its course check
14314
+ * raises the course check. Either holds the task, and
14314
14315
  * `limitReached` tells the dispatcher to stop the cascade.
14315
14316
  */
14316
14317
  async function moveLeft(trx, input) {
@@ -14324,7 +14325,7 @@ async function moveLeft(trx, input) {
14324
14325
  await voidSubmits(trx, task.id, to, at);
14325
14326
  await closeTurns(trx, {
14326
14327
  taskId: task.id,
14327
- reason: "moved",
14328
+ reason: turn === void 0 ? "moved" : "returned",
14328
14329
  at
14329
14330
  });
14330
14331
  await emit(trx, "task_moved", task.project, task.id, at.toISOString(), {
@@ -14375,8 +14376,9 @@ async function moveLeft(trx, input) {
14375
14376
  /**
14376
14377
  * Applies a changed dispatcher mode of each project, as stored in `meta`. A first run only stores
14377
14378
  * the mode. A switch to `on` copies each task's shadow column into its column as a new visit; a
14378
- * switch to `shadow` closes the project's unclosed turns. Either switch then clears the shadow
14379
- * column and journals `dispatcher_mode_changed`.
14379
+ * switch to `shadow` closes the project's unclosed turns. Turns either switch closes record
14380
+ * `mode_changed`. Either switch then clears the shadow column and journals
14381
+ * `dispatcher_mode_changed`.
14380
14382
  */
14381
14383
  async function syncModes(trx, config, at) {
14382
14384
  for (const project of config.projects) {
@@ -14400,7 +14402,7 @@ async function syncModes(trx, config, at) {
14400
14402
  }).where("id", "=", task.id).execute();
14401
14403
  await closeTurns(trx, {
14402
14404
  taskId: task.id,
14403
- reason: "moved",
14405
+ reason: "mode_changed",
14404
14406
  at
14405
14407
  });
14406
14408
  await emit(trx, "task_moved", task.project, task.id, at.toISOString(), {
@@ -14413,7 +14415,7 @@ async function syncModes(trx, config, at) {
14413
14415
  const open = await trx.selectFrom("turn").innerJoin("task", "task.id", "turn.task_id").select("turn.task_id").distinct().where("task.project", "=", project.id).where("turn.closed_at", "is", null).orderBy("turn.task_id").execute();
14414
14416
  for (const { task_id } of open) await closeTurns(trx, {
14415
14417
  taskId: task_id,
14416
- reason: "moved",
14418
+ reason: "mode_changed",
14417
14419
  at
14418
14420
  });
14419
14421
  }
@@ -14754,6 +14756,39 @@ async function dispatchSource(trx, source, ctx) {
14754
14756
  await dispatchTasks(trx, (await trx.selectFrom("task").select("id").where("project", "in", projects).where("membership", "!=", "archived").execute()).map((task) => task.id), ctx);
14755
14757
  }
14756
14758
  //#endregion
14759
+ //#region ../core/src/app/task-turns.ts
14760
+ /** How many closed turns `task.get --detail` shows. */
14761
+ const DETAIL_TURNS = 5;
14762
+ function taskTurnView(turn) {
14763
+ return {
14764
+ id: `T${String(turn.id)}`,
14765
+ column: turn.column,
14766
+ addressee: turn.role,
14767
+ at: turn.created_at,
14768
+ taken: turn.acked_by === null || turn.acked_at === null ? null : {
14769
+ by: turn.acked_by,
14770
+ at: turn.acked_at
14771
+ },
14772
+ closed: turn.closed_at === null || turn.closed_reason === null ? null : {
14773
+ at: turn.closed_at,
14774
+ outcome: turn.closed_reason
14775
+ }
14776
+ };
14777
+ }
14778
+ /**
14779
+ * The turns `task.get` shows: the task's unclosed turn, and with `detail` its last closed turns,
14780
+ * newest first.
14781
+ */
14782
+ async function taskTurns(trx, task, detail) {
14783
+ const open = await trx.selectFrom("turn").selectAll().where("task_id", "=", task.id).where("closed_at", "is", null).orderBy("id", "desc").executeTakeFirst();
14784
+ const turn = open === void 0 ? null : taskTurnView(open);
14785
+ if (!detail) return { turn };
14786
+ return {
14787
+ turn,
14788
+ turns: (await trx.selectFrom("turn").selectAll().where("task_id", "=", task.id).where("closed_at", "is not", null).orderBy("id", "desc").limit(DETAIL_TURNS).execute()).map(taskTurnView)
14789
+ };
14790
+ }
14791
+ //#endregion
14757
14792
  //#region ../core/src/app/task-queries.ts
14758
14793
  /** How many of the last moves `task.get --why` shows. */
14759
14794
  const WHY_MOVES = 5;
@@ -14822,6 +14857,16 @@ function shadowSummary(kind, payloadText) {
14822
14857
  return null;
14823
14858
  }
14824
14859
  }
14860
+ /** The summary of a submit whose head the board's newest poll confirmed. */
14861
+ function submitSummary(kind, payloadText) {
14862
+ if (kind !== "task_submitted") return null;
14863
+ try {
14864
+ const payload = eventPayloadSchemas[kind].safeParse(JSON.parse(payloadText));
14865
+ return payload.success && payload.data.confirmedByPoll === true ? "Turn submitted on the head of the last poll" : null;
14866
+ } catch {
14867
+ return null;
14868
+ }
14869
+ }
14825
14870
  function projectTarget(project) {
14826
14871
  return {
14827
14872
  kind: "found",
@@ -14926,6 +14971,7 @@ function createTaskQueries(deps) {
14926
14971
  ]);
14927
14972
  return {
14928
14973
  task: taskView(task),
14974
+ ...await taskTurns(trx, task, input.detail === true),
14929
14975
  links: links.map(linkView),
14930
14976
  blocks: blocks.map((block) => blockView(block, task)),
14931
14977
  comments: comments.map((comment) => commentView(comment, task)),
@@ -14945,7 +14991,7 @@ function createTaskQueries(deps) {
14945
14991
  at: row.at,
14946
14992
  kind,
14947
14993
  actor: eventActor(row),
14948
- summary: linkSummary(kind, row.payload) ?? shadowSummary(kind, row.payload) ?? EVENT_SUMMARIES[kind]
14994
+ summary: linkSummary(kind, row.payload) ?? shadowSummary(kind, row.payload) ?? submitSummary(kind, row.payload) ?? EVENT_SUMMARIES[kind]
14949
14995
  }];
14950
14996
  });
14951
14997
  return {
@@ -15131,25 +15177,49 @@ async function takenTurn(trx, id, ctx) {
15131
15177
  task
15132
15178
  };
15133
15179
  }
15180
+ /** Ends a hint for a refusal that a later submit cannot fix. */
15181
+ const noRepeat = (step) => `repeating will not help; ask the operator to ${step}.`;
15182
+ /** The next step for an on-demand poll that answered nothing. */
15134
15183
  function pollErrorHint(error, pr) {
15135
15184
  switch (error.kind) {
15136
- case "timeout": return `GitHub did not answer for ${pr} within ${String(SUBMIT_POLL_TIMEOUT_MS / 1e3)} s; wait, then submit again.`;
15137
- case "blind": return `The board cannot read ${pr} (${error.reason}); ask the operator to fix the GitHub access, then submit again.`;
15138
- case "failed": return error.retryAt === void 0 ? `The GitHub poll of ${pr} failed (${error.adapterKind}); wait, then submit again.` : `GitHub is throttled until ${error.retryAt}; submit again after that.`;
15185
+ case "timeout": return `GitHub did not answer for ${pr} within ${String(SUBMIT_POLL_TIMEOUT_MS / 1e3)} s; wait a minute, then submit again.`;
15186
+ case "blind": return error.reason === "stale" ? `The board has no recent complete GitHub poll for ${pr}; submit again in a few minutes, once GitHub answers its polls.` : `The board cannot read ${pr} (${error.reason}); ${noRepeat("fix the GitHub access")}`;
15187
+ case "failed":
15188
+ if (error.adapterKind === "auth" || error.adapterKind === "config") return `The board cannot read ${pr} (${error.adapterKind}); ${noRepeat("fix the GitHub access")}`;
15189
+ return error.retryAt === void 0 ? `The GitHub poll of ${pr} failed (${error.adapterKind}); wait a minute, then submit again.` : `GitHub is throttled until ${error.retryAt}; submit again after that.`;
15139
15190
  case "stopped": return "The GitHub poller is not running; submit again once the daemon is up.";
15140
- case "unknown_source": return `The repo of ${pr} is not in the project's repos; ask the operator to add it to the config.`;
15141
- case "unsupported": return "This daemon cannot poll a pull request on demand; ask the operator to update the daemon.";
15191
+ case "unknown_source": return `The repo of ${pr} is not in the project's repos; ${noRepeat("add it to the config")}`;
15192
+ case "unsupported": return `This daemon cannot poll a pull request on demand; ${noRepeat("update the daemon")}`;
15142
15193
  }
15143
15194
  }
15144
- /** Throws `github_unavailable` unless `prepared` is a successful poll of this PR. */
15145
- function confirmPolled(prepared, pr) {
15195
+ /** True when GitHub gave no answer this call and the last poll may stand in for it. */
15196
+ function pollMayConfirm(error) {
15197
+ return error.kind === "timeout" || error.kind === "failed" && (error.adapterKind === "transient" || error.adapterKind === "unexpected" || error.adapterKind === "throttled");
15198
+ }
15199
+ /**
15200
+ * How the PR head behind a submit is confirmed: `live` by this call's poll, `poll` by the
15201
+ * board's newest poll when GitHub did not answer. Throws `head_mismatch` when the confirmed head
15202
+ * is not `sha`, `github_unavailable` when nothing confirms it.
15203
+ */
15204
+ function confirmHead(input) {
15205
+ const { prepared, pr, sha, snapshot, completeAt } = input;
15146
15206
  const label = `${pr.repo}#${String(pr.number)}`;
15147
15207
  const unavailable = (hint) => new CommandError("github_unavailable", hint);
15148
15208
  if (prepared?.kind !== "polled" || prepared.repo !== pr.repo.toLowerCase() || prepared.number !== pr.number) throw unavailable(`The board did not poll ${label} for this call; submit again.`);
15149
15209
  const { result } = prepared;
15150
- if (result === null) throw unavailable("This daemon runs no GitHub poller; ask the operator to check the daemon.");
15151
- if (!result.ok) throw unavailable(pollErrorHint(result.error, label));
15152
- if (result.value.status !== "ok") throw unavailable(`GitHub answered ${result.value.status} for ${label}; ask the operator to check the board's GitHub access.`);
15210
+ if (result === null) throw unavailable(`This daemon runs no GitHub poller; ${noRepeat("check the daemon")}`);
15211
+ if (!result.ok) {
15212
+ const hint = pollErrorHint(result.error, label);
15213
+ if (!pollMayConfirm(result.error)) throw unavailable(hint);
15214
+ if (completeAt === void 0) throw unavailable(`${hint} The board has had no complete GitHub poll since it started.`);
15215
+ if (snapshot === void 0) throw unavailable(`${hint} The board has not seen the head of ${label} yet.`);
15216
+ if (Date.parse(snapshot.observed_at) < Date.parse(completeAt)) throw unavailable(`${hint} The board last saw head ${snapshot.head_sha} at ${snapshot.observed_at}, before its last complete GitHub poll.`);
15217
+ if (snapshot.head_sha.toLowerCase() !== sha) throw unavailable(`${hint} Its last poll saw head ${snapshot.head_sha}.`);
15218
+ return "poll";
15219
+ }
15220
+ if (result.value.status !== "ok") throw unavailable(`GitHub answered ${result.value.status} for ${label}; ${noRepeat("check the board's GitHub access")}`);
15221
+ if (snapshot?.head_sha.toLowerCase() !== sha) throw new CommandError("head_mismatch", `The head of ${label} is ${snapshot?.head_sha ?? "unknown"}; push the commit, then submit the head.`);
15222
+ return "live";
15153
15223
  }
15154
15224
  /** Polls the task's PR on demand for a submit; `skipped` when the task has none. */
15155
15225
  async function pollTaskPr(db, task, poll) {
@@ -15169,16 +15239,21 @@ async function pollTaskPr(db, task, poll) {
15169
15239
  };
15170
15240
  }
15171
15241
  /**
15172
- * Records the submit of `sha` for the task's `column` visit `epoch`. Throws `head_mismatch` or
15173
- * `github_unavailable` unless `sha` is the freshly polled PR head.
15242
+ * Records the submit of `sha` for the task's `column` visit `epoch` and says how its head was
15243
+ * confirmed (`confirmHead`). Throws `head_mismatch` or `github_unavailable` otherwise.
15174
15244
  */
15175
- async function insertSubmission(trx, input, ctx) {
15245
+ async function insertSubmission(trx, input, ctx, completeSince) {
15176
15246
  const { task, column, epoch, sha } = input;
15177
15247
  const pr = await taskPr(trx, task.id);
15178
15248
  if (pr === null) throw new CommandError("head_mismatch", "The task has no active pull request; ask the operator to link it with `board link`, then submit its head.");
15179
- confirmPolled(ctx.prepared, pr);
15180
- const snapshot = await trx.selectFrom("pr_snapshot").select("head_sha").where(sql`lower(repo) = ${pr.repo.toLowerCase()}`).where("number", "=", pr.number).executeTakeFirst();
15181
- if (snapshot?.head_sha.toLowerCase() !== sha) throw new CommandError("head_mismatch", `The head of ${pr.repo}#${String(pr.number)} is ${snapshot?.head_sha ?? "unknown"}; push the commit, then submit the head.`);
15249
+ const snapshot = await trx.selectFrom("pr_snapshot").select(["head_sha", "observed_at"]).where(sql`lower(repo) = ${pr.repo.toLowerCase()}`).where("number", "=", pr.number).executeTakeFirst();
15250
+ const confirmed = confirmHead({
15251
+ prepared: ctx.prepared,
15252
+ pr,
15253
+ sha,
15254
+ snapshot,
15255
+ completeAt: completeSince.get(prSourceId(task.project, pr.repo))
15256
+ });
15182
15257
  await trx.insertInto("submission").values({
15183
15258
  task_id: task.id,
15184
15259
  column,
@@ -15190,7 +15265,10 @@ async function insertSubmission(trx, input, ctx) {
15190
15265
  pr_repo: pr.repo,
15191
15266
  pr_number: pr.number
15192
15267
  }).execute();
15268
+ return confirmed;
15193
15269
  }
15270
+ /** The `task_submitted` payload mark of a head confirmed by the board's last poll. */
15271
+ const confirmation = (confirmed) => confirmed === "poll" ? { confirmedByPoll: true } : {};
15194
15272
  /**
15195
15273
  * The executor's submit and return of a turn it took, the turnless shadow submit, and the
15196
15274
  * operator's column correction.
@@ -15212,15 +15290,16 @@ function createTurnMutations(deps) {
15212
15290
  if (task.membership === "archived") throw new CommandError("task_archived", "Add the task again before changing it.");
15213
15291
  const column = shadowColumn(task);
15214
15292
  if (!await executesShadowColumn(trx, task, ctx.actor, config)) throw new CommandError("forbidden", `Only the executor of ${column} submits this task while the dispatcher is in shadow mode.`);
15215
- await insertSubmission(trx, {
15293
+ const confirmed = await insertSubmission(trx, {
15216
15294
  task,
15217
15295
  column,
15218
15296
  epoch: task.column_epoch,
15219
15297
  sha: input.sha
15220
- }, ctx);
15298
+ }, ctx, completeSince);
15221
15299
  await emit(trx, "task_submitted", task.project, task.id, ctx.at, {
15222
15300
  column,
15223
- sha: input.sha
15301
+ sha: input.sha,
15302
+ ...confirmation(confirmed)
15224
15303
  }, ctx.actor);
15225
15304
  return {
15226
15305
  task: taskView(await dispatched(trx, task.id, ctx.at)),
@@ -15247,12 +15326,12 @@ function createTurnMutations(deps) {
15247
15326
  async run(trx, input, ctx) {
15248
15327
  if (!isTurnId(input.turn)) return submitShadow(trx, input, ctx);
15249
15328
  const { turn, task } = await takenTurn(trx, input.turn, ctx);
15250
- await insertSubmission(trx, {
15329
+ const confirmed = await insertSubmission(trx, {
15251
15330
  task,
15252
15331
  column: turn.column,
15253
15332
  epoch: turn.epoch,
15254
15333
  sha: input.sha
15255
- }, ctx);
15334
+ }, ctx, completeSince);
15256
15335
  await closeTurns(trx, {
15257
15336
  taskId: task.id,
15258
15337
  reason: "submitted",
@@ -15261,7 +15340,8 @@ function createTurnMutations(deps) {
15261
15340
  await emit(trx, "task_submitted", task.project, task.id, ctx.at, {
15262
15341
  turn: input.turn,
15263
15342
  column: turn.column,
15264
- sha: input.sha
15343
+ sha: input.sha,
15344
+ ...confirmation(confirmed)
15265
15345
  }, ctx.actor);
15266
15346
  return {
15267
15347
  task: taskView(await dispatched(trx, task.id, ctx.at)),
@@ -16364,6 +16444,12 @@ function quote(text) {
16364
16444
  }]
16365
16445
  };
16366
16446
  }
16447
+ /** The open turn: who executes it, when it opened and whether it was acked. */
16448
+ function turnLine(turn) {
16449
+ if (turn === null) return line("No open turn.");
16450
+ const ack = turn.taken === null ? "not acked" : `acked by ${turn.taken.by} at ${turn.taken.at}`;
16451
+ return line(`Turn ${turn.id} (${turn.column}, ${turn.addressee}), opened ${turn.at}: ${ack}.`);
16452
+ }
16367
16453
  /** Failed and waiting conditions lead a column's line; unchecked and met follow. */
16368
16454
  const STATE_ORDER = {
16369
16455
  failed: 0,
@@ -16380,7 +16466,6 @@ function whyLines(key, why, blocks) {
16380
16466
  const mode = why.dispatcher === null ? " (project not configured)" : why.dispatcher === "shadow" ? " (shadow)" : "";
16381
16467
  const here = why.gates.find((gate) => gate.column === why.column);
16382
16468
  const passing = why.gates.filter((gate) => gate.enabled && gate.ok).map((gate) => gate.column);
16383
- const turn = why.turn;
16384
16469
  return [
16385
16470
  line(`Task ${key} is in ${why.column}${mode}.`),
16386
16471
  ...why.holds.length === 0 ? [] : [line(`Held: ${why.holds.join(", ")}.`)],
@@ -16388,7 +16473,7 @@ function whyLines(key, why, blocks) {
16388
16473
  ...passing.length === 0 ? [] : [line(`Gates passing: ${passing.join(", ")}.`)],
16389
16474
  ...here === void 0 ? [] : [line(here.blockedIn === null ? `The ${why.column} gate passes.` : `The ${why.column} gate is blocked at ${here.blockedIn}.`)],
16390
16475
  ...why.checksWaivedBy === null ? [] : [line(`Dev checks are waived by ${why.checksWaivedBy}.`)],
16391
- line(turn === null ? "No open turn." : `Turn ${turn.id} (${turn.column}, ${turn.addressee}): ${turn.taken === null ? "not taken" : `taken by ${turn.taken.by}`}.`),
16476
+ turnLine(why.turn),
16392
16477
  ...blocks.filter((block) => block.state === "open").flatMap((block) => [line(`Open block ${block.id} (${block.type}):`), quote(block.reason)]),
16393
16478
  ...why.moves.flatMap((move) => {
16394
16479
  const gate = move.gate.length === 0 ? "" : `: ${move.gate.join(", ")}`;
@@ -16431,6 +16516,7 @@ function commandReply(id, value, input) {
16431
16516
  cliHint: `board ${operation.cli.command} ${request.task}`,
16432
16517
  body: [
16433
16518
  line(`Task ${result.task.key}: ${result.task.column} (${result.task.membership})`),
16519
+ turnLine(result.turn),
16434
16520
  ...result.blocks.flatMap((block) => [line(`Block ${block.id} (${block.state}, ${block.type}):`), quote(block.reason)]),
16435
16521
  ...result.comments.flatMap((comment) => [line(`Comment ${comment.id} by ${comment.author}:`), quote(comment.text)])
16436
16522
  ]
@@ -19602,6 +19688,8 @@ function applyEntityOutcomes(input) {
19602
19688
  //#region ../adapters/src/runner/runner.ts
19603
19689
  /** The setTimeout limit: a longer delay would otherwise fire after 1 ms. */
19604
19690
  const MAX_TIMER_MS = 2147483647;
19691
+ /** Waits before the second and third attempt of an on-demand poll after a transient failure. */
19692
+ const DEMAND_RETRY_WAITS_MS = [1e3, 2e3];
19605
19693
  function startRunner(options) {
19606
19694
  const startedAt = options.now();
19607
19695
  const sources = options.entries.map((entry) => runSource(entry, options, startedAt));
@@ -19843,8 +19931,11 @@ function runSource(entry, options, runnerStartMs) {
19843
19931
  if (!options.oneShot) schedule(delay.delayMs);
19844
19932
  return outcome;
19845
19933
  }
19846
- /** One on-demand request at its turn on the chain; `live` is false once its caller left. */
19847
- async function demandTurn(ref, abort, live, observing) {
19934
+ /**
19935
+ * One on-demand request at its turn on the chain; `live` is false once its caller left.
19936
+ * `retryable` is called before it returns a `transient` failure of the `poll` step.
19937
+ */
19938
+ async function demandTurn(ref, abort, live, observing, retryable) {
19848
19939
  if (stopping) return err(stoppedError);
19849
19940
  if (!live()) return;
19850
19941
  const startMs = now();
@@ -19924,6 +20015,7 @@ function runSource(entry, options, runnerStartMs) {
19924
20015
  } catch (error) {
19925
20016
  if (aborted()) return err(stoppedError);
19926
20017
  fail(step, error);
20018
+ if (step === "poll" && error instanceof AdapterError && error.kind === "transient") retryable();
19927
20019
  const retryAt = throttledRetryAt(error);
19928
20020
  return err({
19929
20021
  kind: "failed",
@@ -19941,12 +20033,17 @@ function runSource(entry, options, runnerStartMs) {
19941
20033
  if (stopping) return Promise.resolve(err(stoppedError));
19942
20034
  return new Promise((resolve) => {
19943
20035
  const abort = new AbortController();
20036
+ const deadlineMs = now() + timeoutMs;
19944
20037
  let settled = false;
19945
20038
  let observing = false;
20039
+ let attempts = 0;
20040
+ let retryTimer;
19946
20041
  const settle = (result) => {
19947
20042
  if (settled) return;
19948
20043
  settled = true;
19949
20044
  clearTimeout(timer);
20045
+ clearTimeout(retryTimer);
20046
+ retryTimer = void 0;
19950
20047
  pending.delete(cancel);
19951
20048
  resolve(result);
19952
20049
  };
@@ -19964,12 +20061,27 @@ function runSource(entry, options, runnerStartMs) {
19964
20061
  }));
19965
20062
  abort.abort();
19966
20063
  }, timeoutMs);
19967
- run(async () => {
20064
+ const attempt = () => run(async () => {
20065
+ let retry = false;
20066
+ const transient = () => retry;
19968
20067
  const result = await demandTurn(ref, abort, () => !settled, () => {
19969
20068
  observing = true;
20069
+ }, () => {
20070
+ retry = true;
19970
20071
  });
19971
- if (result !== void 0) settle(result);
20072
+ if (result === void 0) return;
20073
+ const waitMs = DEMAND_RETRY_WAITS_MS[attempts];
20074
+ attempts += 1;
20075
+ if (transient() && waitMs !== void 0 && !settled && now() + waitMs < deadlineMs) {
20076
+ retryTimer = setTimeout(() => {
20077
+ retryTimer = void 0;
20078
+ attempt();
20079
+ }, waitMs);
20080
+ return;
20081
+ }
20082
+ settle(result);
19972
20083
  });
20084
+ attempt();
19973
20085
  });
19974
20086
  }
19975
20087
  if (!options.oneShot) armDeadline();
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { C as renderMcpError, X as ERRORS, y as OPERATIONS } from "./chunk-DyHtyPom.mjs";
2
- import { o as CliError, r as requestOperation } from "./chunk-Z9DFhl-U.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-BbwZCNQh.mjs";
1
+ import { C as renderMcpError, X as ERRORS, y as OPERATIONS } from "./chunk-DjHqB_QC.mjs";
2
+ import { o as CliError, r as requestOperation } from "./chunk-DgTcmpig.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-C7CHbmMl.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.53.2",
3
+ "version": "0.54.0",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"
@@ -14,10 +14,10 @@ Other errors: `not_found`.
14
14
 
15
15
  ### `board task`
16
16
 
17
- Purpose: Show a task with its links, blocks and comments.
17
+ Purpose: Show a task with its open turn, links, blocks and comments.
18
18
  Arguments: `<task>`.
19
- Flags: `--why`, `--json`.
20
- Use when: Inspect one task now.
19
+ Flags: `--detail`, `--why`, `--json`.
20
+ Use when: Inspect one task now; pass detail for its last closed turns.
21
21
  Avoid when: Use `board task history <task>` for past events.
22
22
  Example: `board task PROJ-123` — Show one task.
23
23
  Other errors: `wrong_id_kind`, `not_found`.