spur-board 0.53.3 → 0.54.1

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.
@@ -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",
@@ -977,6 +992,11 @@ const blockIdSchema = refSchema("block", "Block ID: B followed by a number, e.g.
977
992
  const commentIdSchema = refSchema("comment", "Comment ID: C followed by a number, e.g. C3.", NUMBERED_ID_MAX);
978
993
  const itemIdSchema = refSchema("item", "Item ID: I followed by a number, e.g. I7.", NUMBERED_ID_MAX);
979
994
  const turnIdSchema = refSchema("turn", "Turn ID: T followed by a number, e.g. T4.", NUMBERED_ID_MAX);
995
+ /**
996
+ * The ring ID a doorbell text ends with, `N<notification>-<ring>`, or a bare `N<notification>`.
997
+ * Only `inbox.ack` takes it; it is not a `RefKind`, since `N18-1` is also a valid Jira key.
998
+ */
999
+ const ringIdSchema = z.string().max(32).regex(new RegExp(`^N${REF_NUMBER}(?:-${REF_NUMBER})?$`)).describe("Ring ID from a doorbell text: N<notification>-<ring>, e.g. N18-1; the ring part is optional.");
980
1000
  const TASK_KEY_DESCRIPTION = "Task key: a Jira key (PROJ-123) or a GitHub issue (owner/repo#42, or repo#42).";
981
1001
  const taskKeySchema = refSchema("task", TASK_KEY_DESCRIPTION);
982
1002
  /** The task key an operation input takes: `taskKeySchema` with a length cap. */
@@ -1883,6 +1903,17 @@ const turnViewSchema = z.strictObject({
1883
1903
  at: z.iso.datetime().describe("When the turn was taken, ISO 8601 UTC.")
1884
1904
  }).nullable().describe("Who took the turn and when; null until it is taken.")
1885
1905
  }).describe("A turn: the executor of a column is asked to act on a task.");
1906
+ /** A turn as `task.get` shows it: who executes it, whether it was taken, and how it closed. */
1907
+ const taskTurnSchema = turnViewSchema.pick({
1908
+ id: true,
1909
+ column: true,
1910
+ addressee: true,
1911
+ at: true,
1912
+ taken: true
1913
+ }).extend({ closed: z.strictObject({
1914
+ at: z.iso.datetime().describe("When the turn closed, ISO 8601 UTC."),
1915
+ 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.")
1916
+ }).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.");
1886
1917
  /** One column move from the journal: a dispatcher move, a return to Dev or a correction. */
1887
1918
  const moveViewSchema = z.strictObject({
1888
1919
  at: z.iso.datetime().describe("When the task moved, ISO 8601 UTC."),
@@ -2138,6 +2169,15 @@ const reviewTurn = {
2138
2169
  at,
2139
2170
  taken: null
2140
2171
  };
2172
+ const devTurn = {
2173
+ id: "T3",
2174
+ column: "dev",
2175
+ addressee: "worker",
2176
+ at,
2177
+ taken: null,
2178
+ closed: null
2179
+ };
2180
+ const later = "2026-01-05T10:15:00.000Z";
2141
2181
  const handedReview = {
2142
2182
  repo: "acme/web",
2143
2183
  number: 42,
@@ -2346,17 +2386,20 @@ const OPERATIONS = [
2346
2386
  defineOperation({
2347
2387
  id: "task.get",
2348
2388
  kind: "query",
2349
- description: "Show a task with its links, blocks and comments.",
2389
+ description: "Show a task with its open turn, links, blocks and comments.",
2350
2390
  mcp: {
2351
- whenToUse: "Inspect one task now.",
2391
+ whenToUse: "Inspect one task now; pass detail for its last closed turns.",
2352
2392
  whenNotToUse: "Use task_history for past events."
2353
2393
  },
2354
2394
  input: z.strictObject({
2355
2395
  task: taskKeyInputSchema,
2396
+ detail: z.boolean().optional().describe("Also list the last 5 closed turns, newest first; absent means none."),
2356
2397
  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.")
2357
2398
  }),
2358
2399
  output: z.strictObject({
2359
2400
  task: taskViewSchema,
2401
+ turn: taskTurnSchema.nullable().describe("The task's unclosed turn; null when none is open."),
2402
+ turns: z.array(taskTurnSchema).optional().describe("Present only with detail: the last 5 closed turns, newest first."),
2360
2403
  links: z.array(linkViewSchema).describe("Effective pull request, session, and ticket links."),
2361
2404
  blocks: z.array(blockViewSchema).describe("Blocks on the task, open and unblocked."),
2362
2405
  comments: z.array(commentSchema).describe("Comments on the task, oldest first."),
@@ -2372,56 +2415,100 @@ const OPERATIONS = [
2372
2415
  kind: "slash-command",
2373
2416
  usage: "/board task <KEY> [why]"
2374
2417
  },
2375
- examples: [{
2376
- summary: "Show one task",
2377
- input: { task: "PROJ-123" },
2378
- output: {
2379
- task,
2380
- links: [],
2381
- blocks: [question],
2382
- comments: [comment]
2383
- }
2384
- }, {
2385
- summary: "Explain why a task waits in Review",
2386
- input: {
2387
- task: "PROJ-123",
2388
- why: true
2418
+ examples: [
2419
+ {
2420
+ summary: "Show one task",
2421
+ input: { task: "PROJ-123" },
2422
+ output: {
2423
+ task,
2424
+ turn: devTurn,
2425
+ links: [],
2426
+ blocks: [question],
2427
+ comments: [comment]
2428
+ }
2389
2429
  },
2390
- output: {
2391
- task: {
2392
- ...task,
2393
- column: "review"
2430
+ {
2431
+ summary: "Explain why a task waits in Review",
2432
+ input: {
2433
+ task: "PROJ-123",
2434
+ why: true
2394
2435
  },
2395
- links: [],
2396
- blocks: [],
2397
- comments: [],
2398
- why: {
2399
- column: "review",
2400
- dispatcher: "on",
2401
- holds: [],
2402
- gates: reviewGates,
2403
- checksWaivedBy: null,
2436
+ output: {
2437
+ task: {
2438
+ ...task,
2439
+ column: "review"
2440
+ },
2404
2441
  turn: {
2405
- ...reviewTurn,
2406
- handed: [],
2442
+ id: reviewTurn.id,
2443
+ column: reviewTurn.column,
2444
+ addressee: reviewTurn.addressee,
2445
+ at,
2407
2446
  taken: {
2408
2447
  by: "agent:rev/rev-1",
2409
2448
  at
2449
+ },
2450
+ closed: null
2451
+ },
2452
+ links: [],
2453
+ blocks: [],
2454
+ comments: [],
2455
+ why: {
2456
+ column: "review",
2457
+ dispatcher: "on",
2458
+ holds: [],
2459
+ gates: reviewGates,
2460
+ checksWaivedBy: null,
2461
+ turn: {
2462
+ ...reviewTurn,
2463
+ handed: [],
2464
+ taken: {
2465
+ by: "agent:rev/rev-1",
2466
+ at
2467
+ }
2468
+ },
2469
+ moves: [{
2470
+ at,
2471
+ kind: "task_moved",
2472
+ actor: "system",
2473
+ from: "dev",
2474
+ to: "review",
2475
+ reason: "gate_passed",
2476
+ gate: [],
2477
+ text: null
2478
+ }]
2479
+ }
2480
+ }
2481
+ },
2482
+ {
2483
+ summary: "Show a task with its last closed turns",
2484
+ input: {
2485
+ task: "PROJ-123",
2486
+ detail: true
2487
+ },
2488
+ output: {
2489
+ task,
2490
+ turn: {
2491
+ ...devTurn,
2492
+ id: "T4",
2493
+ at: later,
2494
+ taken: {
2495
+ by: "agent:web/web-7",
2496
+ at: later
2410
2497
  }
2411
2498
  },
2412
- moves: [{
2413
- at,
2414
- kind: "task_moved",
2415
- actor: "system",
2416
- from: "dev",
2417
- to: "review",
2418
- reason: "gate_passed",
2419
- gate: [],
2420
- text: null
2421
- }]
2499
+ turns: [{
2500
+ ...devTurn,
2501
+ closed: {
2502
+ at: later,
2503
+ outcome: "submitted"
2504
+ }
2505
+ }],
2506
+ links: [],
2507
+ blocks: [],
2508
+ comments: []
2422
2509
  }
2423
2510
  }
2424
- }]
2511
+ ]
2425
2512
  }),
2426
2513
  defineOperation({
2427
2514
  id: "task.history",
@@ -2560,9 +2647,9 @@ const OPERATIONS = [
2560
2647
  defineOperation({
2561
2648
  id: "inbox.ack",
2562
2649
  kind: "mutation",
2563
- description: "Mark comments, agent-addressed blocks or turns as read; acking a turn makes the caller its taker.",
2650
+ description: "Mark comments, agent-addressed blocks, turns or doorbell rings as read; acking a turn makes the caller its taker.",
2564
2651
  mcp: {
2565
- whenToUse: "Mark handled inbox items read.",
2652
+ whenToUse: "Mark handled inbox items or a ring ID like N18-1 read; an item handled before comes back under alreadyHandled.",
2566
2653
  whenNotToUse: "Use inbox_get to inspect them first."
2567
2654
  },
2568
2655
  input: z.strictObject({ entries: z.array(z.union([
@@ -2571,13 +2658,23 @@ const OPERATIONS = [
2571
2658
  revision: z.int().positive().describe("Revision the caller read.")
2572
2659
  }),
2573
2660
  z.strictObject({ id: blockIdSchema }),
2574
- z.strictObject({ id: turnIdSchema })
2575
- ])).min(1).max(ACK_ENTRIES_MAX).describe("Comment revisions, blocks and turns to acknowledge.") }),
2576
- output: z.strictObject({ acked: z.array(z.union([
2577
- commentIdSchema,
2578
- blockIdSchema,
2579
- turnIdSchema
2580
- ])).describe("Entries now acknowledged.") }),
2661
+ z.strictObject({ id: turnIdSchema }),
2662
+ z.strictObject({ id: ringIdSchema })
2663
+ ])).min(1).max(ACK_ENTRIES_MAX).describe("Comment revisions, blocks, turns and ring IDs to acknowledge.") }),
2664
+ output: z.strictObject({
2665
+ acked: z.array(z.union([
2666
+ commentIdSchema,
2667
+ blockIdSchema,
2668
+ turnIdSchema,
2669
+ ringIdSchema
2670
+ ])).describe("Entries now acknowledged."),
2671
+ alreadyHandled: z.array(z.union([
2672
+ commentIdSchema,
2673
+ blockIdSchema,
2674
+ turnIdSchema,
2675
+ ringIdSchema
2676
+ ])).optional().describe("Entries that were already handled; nothing new was acknowledged for them.")
2677
+ }),
2581
2678
  grants: [{ grant: "project-agent" }],
2582
2679
  errors: [
2583
2680
  "wrong_id_kind",
@@ -2607,6 +2704,19 @@ const OPERATIONS = [
2607
2704
  summary: "Take a turn",
2608
2705
  input: { entries: [{ id: "T4" }] },
2609
2706
  output: { acked: ["T4"] }
2707
+ },
2708
+ {
2709
+ summary: "Acknowledge a doorbell by the ring ID at the end of its text",
2710
+ input: { entries: [{ id: "N18-1" }] },
2711
+ output: { acked: ["N18-1"] }
2712
+ },
2713
+ {
2714
+ summary: "Acknowledge a block already closed by an answer",
2715
+ input: { entries: [{ id: "B14" }] },
2716
+ output: {
2717
+ acked: ["B14"],
2718
+ alreadyHandled: ["B14"]
2719
+ }
2610
2720
  }
2611
2721
  ]
2612
2722
  }),
@@ -1,5 +1,5 @@
1
- import { _ as buildCatalogSnapshot, ct as plainHttpAllowed, st as configSchema, y as OPERATIONS } from "./chunk-DuSucVv4.mjs";
2
- import { o as CliError, t as fetchCatalogVersion } from "./chunk-B81O9UQo.mjs";
1
+ import { _ as buildCatalogSnapshot, ct as plainHttpAllowed, st as configSchema, y as OPERATIONS } from "./chunk-C0avjvF7.mjs";
2
+ import { o as CliError, t as fetchCatalogVersion } from "./chunk-Dd1yi1dh.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-DuSucVv4.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-C0avjvF7.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { request } from "node:http";
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-DuSucVv4.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-C0avjvF7.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-B81O9UQo.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-DSGruS1f.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-Dd1yi1dh.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-CaWf-PGm.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-B81O9UQo.mjs";
1
+ import { a as requestTokenEnrollment, i as requestSkillReload, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./chunk-Dd1yi1dh.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-DuSucVv4.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-C0avjvF7.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";
@@ -11186,6 +11186,10 @@ async function blockById(trx, id) {
11186
11186
  async function commentById(trx, id) {
11187
11187
  return trx.selectFrom("comment").selectAll().where("id", "=", idNumber(id)).executeTakeFirst();
11188
11188
  }
11189
+ /** The notification a ring ID `N<notification>[-<ring>]` names; the ring part is ignored. */
11190
+ async function notificationByRingId(trx, id) {
11191
+ return trx.selectFrom("notification").selectAll().where("id", "=", Number.parseInt(id.slice(1), 10)).executeTakeFirst();
11192
+ }
11189
11193
  function found(value) {
11190
11194
  if (value === void 0) throw new CommandError("not_found", "Check the target ID.");
11191
11195
  return value;
@@ -11574,166 +11578,253 @@ async function queueCuratorAnswerLine(trx, task, block, answer, note, ctx, confi
11574
11578
  }
11575
11579
  /** Concrete block and comment mutations for the generic apply boundary. */
11576
11580
  function createBlockMutations(config) {
11577
- return {
11578
- ask: {
11579
- id: "block.ask",
11580
- resolveTargets: (trx, input) => taskTarget(trx, input.task),
11581
- async run(trx, input, ctx) {
11582
- const task = found(await taskByKey$1(trx, input.task));
11583
- active(task);
11584
- const block = await openBlock(trx, task, "needs_input", input.text, ctx, config);
11585
- await addComment(trx, task, block, input.text, ctx, block.addressee_role, config);
11586
- await queueBlockOpen(trx, task, block, ctx, config);
11587
- return { block: blockView(block, task) };
11588
- }
11589
- },
11590
- create: {
11591
- id: "block.create",
11592
- resolveTargets: (trx, input) => taskTarget(trx, input.task),
11593
- async run(trx, input, ctx) {
11594
- const task = found(await taskByKey$1(trx, input.task));
11595
- active(task);
11596
- const block = await openBlock(trx, task, input.type, input.reason, ctx, config);
11597
- await queueBlockOpen(trx, task, block, ctx, config);
11598
- return { block: blockView(block, task) };
11599
- }
11600
- },
11601
- escalate: {
11602
- id: "block.escalate",
11603
- async resolveTargets(trx, input, actor) {
11604
- const block = await blockById(trx, input.block);
11605
- if (block === void 0) return blockTarget(trx, input.block);
11606
- const task = await taskById$1(trx, block.task_id);
11607
- const target = await authorizationTarget(trx, task, block);
11608
- if (target.kind !== "found" || target.value.block === null) return [target];
11609
- if (holdsBlock(config, actor, target)) return [target];
11610
- const priors = priorAddressees(await routeBlock(trx, task, block, config), block.addressee_role, block.type, curatorProject(config, task.project) !== null);
11611
- for (const addressee_role of priors) {
11612
- const prior = {
11613
- kind: "found",
11614
- value: {
11615
- ...target.value,
11616
- block: {
11617
- ...target.value.block,
11618
- addressee_role
11619
- }
11581
+ const ask = {
11582
+ id: "block.ask",
11583
+ resolveTargets: (trx, input) => taskTarget(trx, input.task),
11584
+ async run(trx, input, ctx) {
11585
+ const task = found(await taskByKey$1(trx, input.task));
11586
+ active(task);
11587
+ const block = await openBlock(trx, task, "needs_input", input.text, ctx, config);
11588
+ await addComment(trx, task, block, input.text, ctx, block.addressee_role, config);
11589
+ await queueBlockOpen(trx, task, block, ctx, config);
11590
+ return { block: blockView(block, task) };
11591
+ }
11592
+ };
11593
+ const create = {
11594
+ id: "block.create",
11595
+ resolveTargets: (trx, input) => taskTarget(trx, input.task),
11596
+ async run(trx, input, ctx) {
11597
+ const task = found(await taskByKey$1(trx, input.task));
11598
+ active(task);
11599
+ const block = await openBlock(trx, task, input.type, input.reason, ctx, config);
11600
+ await queueBlockOpen(trx, task, block, ctx, config);
11601
+ return { block: blockView(block, task) };
11602
+ }
11603
+ };
11604
+ const escalate = {
11605
+ id: "block.escalate",
11606
+ async resolveTargets(trx, input, actor) {
11607
+ const block = await blockById(trx, input.block);
11608
+ if (block === void 0) return blockTarget(trx, input.block);
11609
+ const task = await taskById$1(trx, block.task_id);
11610
+ const target = await authorizationTarget(trx, task, block);
11611
+ if (target.kind !== "found" || target.value.block === null) return [target];
11612
+ if (holdsBlock(config, actor, target)) return [target];
11613
+ const priors = priorAddressees(await routeBlock(trx, task, block, config), block.addressee_role, block.type, curatorProject(config, task.project) !== null);
11614
+ for (const addressee_role of priors) {
11615
+ const prior = {
11616
+ kind: "found",
11617
+ value: {
11618
+ ...target.value,
11619
+ block: {
11620
+ ...target.value.block,
11621
+ addressee_role
11620
11622
  }
11621
- };
11622
- if (holdsBlock(config, actor, prior)) return [prior];
11623
- }
11624
- return [target];
11625
- },
11626
- async run(trx, input, ctx) {
11627
- const block = found(await blockById(trx, input.block));
11628
- const task = await taskById$1(trx, block.task_id);
11629
- active(task);
11630
- const hasCurator = curatorProject(config, task.project) !== null;
11631
- const next = rule(() => escalateBlock(current$1(block), hasCurator));
11632
- const unchanged = async () => {
11633
- if (input.note !== void 0) await addComment(trx, task, block, input.note, ctx, block.addressee_role, config, { ringsAuthor: false });
11634
- return { block: blockView(block, task) };
11635
- };
11636
- if (!next.changed) return unchanged();
11637
- const target = await authorizationTarget(trx, task, block);
11638
- if (!holdsBlock(config, ctx.actor, target)) return unchanged();
11639
- const updated = await moveBlockToAddressee(trx, {
11640
- task,
11641
- block,
11642
- to: next.addressee,
11643
- ctx,
11644
- config
11645
- });
11646
- if (input.note !== void 0) await addComment(trx, task, updated, input.note, ctx, next.addressee, config, { ringsAuthor: false });
11647
- return { block: blockView(updated, task) };
11648
- }
11649
- },
11650
- answer: {
11651
- id: "block.answer",
11652
- resolveTargets: (trx, input) => blockTarget(trx, input.block),
11653
- async run(trx, input, ctx) {
11654
- const block = found(await blockById(trx, input.block));
11655
- const task = await taskById$1(trx, block.task_id);
11656
- active(task);
11657
- rule(() => {
11658
- answerBlock(current$1(block));
11659
- });
11660
- const role = authorRole(config, task, block.author);
11661
- const comment = await addComment(trx, task, block, input.text, ctx, role, config);
11662
- if (input.note !== void 0) await addComment(trx, task, block, input.note, ctx, role, config, { ringsAuthor: false });
11663
- const updated = await closeOpenBlock(trx, task, block, ctx, "done", null, comment);
11664
- await queueCuratorAnswerLine(trx, task, block, comment, input.note, ctx, config);
11665
- return {
11666
- block: blockView(updated, task),
11667
- comment: commentView(comment, task)
11623
+ }
11668
11624
  };
11625
+ if (holdsBlock(config, actor, prior)) return [prior];
11669
11626
  }
11627
+ return [target];
11670
11628
  },
11671
- unblock: {
11672
- id: "block.unblock",
11673
- resolveTargets: (trx, input) => blockTarget(trx, input.block),
11674
- async run(trx, input, ctx) {
11675
- const block = found(await blockById(trx, input.block));
11676
- const task = await taskById$1(trx, block.task_id);
11677
- active(task);
11678
- const target = await authorizationTarget(trx, task, block);
11679
- const decision = rule(() => input.mode === "done" ? closeBlock(current$1(block), {
11680
- mode: "done",
11681
- ...input.ref === void 0 ? {} : { ref: input.ref }
11682
- }) : input.mode === "reason" ? closeBlock(current$1(block), {
11683
- mode: "reason",
11684
- reason: input.reason
11685
- }) : closeBlock(current$1(block), {
11686
- mode: "withdraw",
11687
- isAuthor: wroteBlock(config, ctx.actor, target),
11688
- reason: input.answer
11689
- }));
11690
- if (input.mode === "withdraw") await addComment(trx, task, block, input.answer, ctx, block.addressee_role, config, { ringsAuthor: false });
11691
- const updated = await closeOpenBlock(trx, task, block, ctx, decision.outcome, decision.outcomeReason);
11692
- await applyDoorbellPolicy(trx, input.mode === "done" || holdsBlock(config, ctx.actor, target) ? { kind: "block_closed_by_addressee" } : {
11693
- kind: "block_removed",
11694
- block: updated
11695
- }, new Date(ctx.at));
11696
- return { block: blockView(updated, task) };
11697
- }
11698
- },
11699
- add: {
11700
- id: "comment.add",
11701
- resolveTargets: (trx, input) => taskTarget(trx, input.task),
11702
- async run(trx, input, ctx) {
11703
- const task = found(await taskByKey$1(trx, input.task));
11704
- active(task);
11705
- const block = input.block === void 0 ? void 0 : found(await blockById(trx, input.block));
11706
- if (block !== void 0 && block.task_id !== task.id) throw new CommandError("not_found", "Block does not belong to this task.");
11707
- let addressee = "worker";
11708
- if (block !== void 0) if (ctx.actor !== block.author) addressee = authorRole(config, task, block.author);
11709
- else if (block.outcome === "done" && block.unblocked_by !== null && block.unblocked_by !== block.author) addressee = authorRole(config, task, block.unblocked_by);
11710
- else addressee = block.addressee_role;
11711
- return { comment: commentView(await addComment(trx, task, block, input.text, ctx, addressee, config), task) };
11712
- }
11713
- },
11714
- edit: {
11715
- id: "comment.edit",
11716
- async resolveTargets(trx, input) {
11717
- return [await commentTarget(trx, input.comment)];
11718
- },
11719
- async run(trx, input, ctx) {
11720
- const comment = found(await commentById(trx, input.comment));
11721
- if (comment.author !== ctx.actor) throw new CommandError("forbidden", "Only the comment author can edit it.");
11722
- return { comment: commentView(await editInboundComment(trx, {
11723
- comment,
11724
- text: input.text,
11725
- at: ctx.at,
11726
- actor: ctx.actor,
11727
- config
11728
- }), await taskById$1(trx, comment.task_id)) };
11729
- }
11629
+ async run(trx, input, ctx) {
11630
+ const block = found(await blockById(trx, input.block));
11631
+ const task = await taskById$1(trx, block.task_id);
11632
+ active(task);
11633
+ const hasCurator = curatorProject(config, task.project) !== null;
11634
+ const next = rule(() => escalateBlock(current$1(block), hasCurator));
11635
+ const unchanged = async () => {
11636
+ if (input.note !== void 0) await addComment(trx, task, block, input.note, ctx, block.addressee_role, config, { ringsAuthor: false });
11637
+ return { block: blockView(block, task) };
11638
+ };
11639
+ if (!next.changed) return unchanged();
11640
+ const target = await authorizationTarget(trx, task, block);
11641
+ if (!holdsBlock(config, ctx.actor, target)) return unchanged();
11642
+ const updated = await moveBlockToAddressee(trx, {
11643
+ task,
11644
+ block,
11645
+ to: next.addressee,
11646
+ ctx,
11647
+ config
11648
+ });
11649
+ if (input.note !== void 0) await addComment(trx, task, updated, input.note, ctx, next.addressee, config, { ringsAuthor: false });
11650
+ return { block: blockView(updated, task) };
11651
+ }
11652
+ };
11653
+ const answer = {
11654
+ id: "block.answer",
11655
+ resolveTargets: (trx, input) => blockTarget(trx, input.block),
11656
+ async run(trx, input, ctx) {
11657
+ const block = found(await blockById(trx, input.block));
11658
+ const task = await taskById$1(trx, block.task_id);
11659
+ active(task);
11660
+ rule(() => {
11661
+ answerBlock(current$1(block));
11662
+ });
11663
+ const role = authorRole(config, task, block.author);
11664
+ const comment = await addComment(trx, task, block, input.text, ctx, role, config);
11665
+ if (input.note !== void 0) await addComment(trx, task, block, input.note, ctx, role, config, { ringsAuthor: false });
11666
+ const updated = await closeOpenBlock(trx, task, block, ctx, "done", null, comment);
11667
+ await queueCuratorAnswerLine(trx, task, block, comment, input.note, ctx, config);
11668
+ return {
11669
+ block: blockView(updated, task),
11670
+ comment: commentView(comment, task)
11671
+ };
11672
+ }
11673
+ };
11674
+ const unblock = {
11675
+ id: "block.unblock",
11676
+ resolveTargets: (trx, input) => blockTarget(trx, input.block),
11677
+ async run(trx, input, ctx) {
11678
+ const block = found(await blockById(trx, input.block));
11679
+ const task = await taskById$1(trx, block.task_id);
11680
+ active(task);
11681
+ const target = await authorizationTarget(trx, task, block);
11682
+ const decision = rule(() => input.mode === "done" ? closeBlock(current$1(block), {
11683
+ mode: "done",
11684
+ ...input.ref === void 0 ? {} : { ref: input.ref }
11685
+ }) : input.mode === "reason" ? closeBlock(current$1(block), {
11686
+ mode: "reason",
11687
+ reason: input.reason
11688
+ }) : closeBlock(current$1(block), {
11689
+ mode: "withdraw",
11690
+ isAuthor: wroteBlock(config, ctx.actor, target),
11691
+ reason: input.answer
11692
+ }));
11693
+ if (input.mode === "withdraw") await addComment(trx, task, block, input.answer, ctx, block.addressee_role, config, { ringsAuthor: false });
11694
+ const updated = await closeOpenBlock(trx, task, block, ctx, decision.outcome, decision.outcomeReason);
11695
+ await applyDoorbellPolicy(trx, input.mode === "done" || holdsBlock(config, ctx.actor, target) ? { kind: "block_closed_by_addressee" } : {
11696
+ kind: "block_removed",
11697
+ block: updated
11698
+ }, new Date(ctx.at));
11699
+ return { block: blockView(updated, task) };
11700
+ }
11701
+ };
11702
+ const add = {
11703
+ id: "comment.add",
11704
+ resolveTargets: (trx, input) => taskTarget(trx, input.task),
11705
+ async run(trx, input, ctx) {
11706
+ const task = found(await taskByKey$1(trx, input.task));
11707
+ active(task);
11708
+ const block = input.block === void 0 ? void 0 : found(await blockById(trx, input.block));
11709
+ if (block !== void 0 && block.task_id !== task.id) throw new CommandError("not_found", "Block does not belong to this task.");
11710
+ let addressee = "worker";
11711
+ if (block !== void 0) if (ctx.actor !== block.author) addressee = authorRole(config, task, block.author);
11712
+ else if (block.outcome === "done" && block.unblocked_by !== null && block.unblocked_by !== block.author) addressee = authorRole(config, task, block.unblocked_by);
11713
+ else addressee = block.addressee_role;
11714
+ return { comment: commentView(await addComment(trx, task, block, input.text, ctx, addressee, config), task) };
11715
+ }
11716
+ };
11717
+ const edit = {
11718
+ id: "comment.edit",
11719
+ async resolveTargets(trx, input) {
11720
+ return [await commentTarget(trx, input.comment)];
11730
11721
  },
11722
+ async run(trx, input, ctx) {
11723
+ const comment = found(await commentById(trx, input.comment));
11724
+ if (comment.author !== ctx.actor) throw new CommandError("forbidden", "Only the comment author can edit it.");
11725
+ return { comment: commentView(await editInboundComment(trx, {
11726
+ comment,
11727
+ text: input.text,
11728
+ at: ctx.at,
11729
+ actor: ctx.actor,
11730
+ config
11731
+ }), await taskById$1(trx, comment.task_id)) };
11732
+ }
11733
+ };
11734
+ /** Marks a comment read at `revision` and acks its unread answer notifications. */
11735
+ async function ackComment(trx, comment, revision, ctx) {
11736
+ const task = await taskById$1(trx, comment.task_id);
11737
+ await acknowledgeNotification(trx, {
11738
+ commentId: comment.id,
11739
+ revision,
11740
+ actor: ctx.actor,
11741
+ at: new Date(ctx.at),
11742
+ config
11743
+ });
11744
+ await trx.updateTable("comment").set({ acked_revision: revision }).where("id", "=", comment.id).execute();
11745
+ await journal$1(trx, task, ctx, "comment_acked", {
11746
+ comment: commentId(comment.id),
11747
+ revision
11748
+ });
11749
+ }
11750
+ /** Acks the caller's unread answers of an asked block, then its unread block notification. */
11751
+ async function ackBlock(trx, id, ctx) {
11752
+ const rows = await trx.selectFrom("notification").selectAll().where("block_id", "=", id).where("kind", "in", ["block", "answer"]).orderBy("id", "desc").execute();
11753
+ const addressed = /* @__PURE__ */ new Set();
11754
+ for (const row of rows) if (await notificationAddressedTo(trx, row, ctx.actor, config)) addressed.add(row.id);
11755
+ const answered = /* @__PURE__ */ new Set();
11756
+ for (const row of rows) if (row.kind === "answer" && row.acked_at === null && row.comment_id !== null && addressed.has(row.id)) answered.add(row.comment_id);
11757
+ for (const answer of answered) {
11758
+ const comment = found(await commentById(trx, commentId(answer)));
11759
+ await ackComment(trx, comment, comment.revision, ctx);
11760
+ }
11761
+ const unread = rows.find((row) => row.kind === "block" && row.acked_at === null);
11762
+ const readsBlock = unread !== void 0 && addressed.has(unread.id);
11763
+ if (readsBlock) await acknowledgeNotification(trx, {
11764
+ blockId: id,
11765
+ actor: ctx.actor,
11766
+ at: new Date(ctx.at),
11767
+ config
11768
+ });
11769
+ if (answered.size > 0 || readsBlock) return "acked";
11770
+ if (addressed.size > 0) return "handled";
11771
+ if (unread !== void 0) throw new CommandError("forbidden", "Only the addressed task role can acknowledge.");
11772
+ throw new CommandError("not_found", "No unread block notification.");
11773
+ }
11774
+ /** Takes a turn; a turn the caller took or was rung for before it closed is already handled. */
11775
+ async function ackTurn(trx, id, ctx) {
11776
+ if (await takeTurn(trx, {
11777
+ turnId: id,
11778
+ actor: ctx.actor,
11779
+ at: new Date(ctx.at),
11780
+ config
11781
+ })) return "acked";
11782
+ const turn = await trx.selectFrom("turn").selectAll().where("id", "=", id).executeTakeFirst();
11783
+ if (turn?.acked_by === ctx.actor) return "handled";
11784
+ if (turn !== void 0 && turn.closed_at !== null) {
11785
+ const notice = await trx.selectFrom("notification").selectAll().where("turn_id", "=", id).where("kind", "=", "turn").orderBy("id", "desc").executeTakeFirst();
11786
+ if (notice !== void 0 && await notificationAddressedTo(trx, notice, ctx.actor, config)) return "handled";
11787
+ }
11788
+ throw new CommandError("not_found", "No open turn to take for this ID.");
11789
+ }
11790
+ /** Acks the item a ring `N<notification>[-<ring>]` was sent for. */
11791
+ async function ackRing(trx, id, ctx) {
11792
+ const notice = found(await notificationByRingId(trx, id));
11793
+ if (notice.kind === "block" && notice.block_id !== null) return ackBlock(trx, notice.block_id, ctx);
11794
+ if (notice.kind === "turn" && notice.turn_id !== null) return ackTurn(trx, notice.turn_id, ctx);
11795
+ if (!await notificationAddressedTo(trx, notice, ctx.actor, config)) throw new CommandError("forbidden", "Only the addressed task role can acknowledge.");
11796
+ if (notice.kind === "answer" && notice.acked_at === null && notice.comment_id !== null) {
11797
+ const comment = found(await commentById(trx, commentId(notice.comment_id)));
11798
+ await ackComment(trx, comment, comment.revision, ctx);
11799
+ return "acked";
11800
+ }
11801
+ return "handled";
11802
+ }
11803
+ return {
11804
+ ask,
11805
+ create,
11806
+ escalate,
11807
+ answer,
11808
+ unblock,
11809
+ add,
11810
+ edit,
11731
11811
  ack: {
11732
11812
  id: "inbox.ack",
11733
11813
  async resolveTargets(trx, input) {
11734
11814
  return Promise.all(input.entries.map(async ({ id }) => {
11735
11815
  if (id.startsWith("C")) return commentTarget(trx, id);
11736
11816
  if (id.startsWith("T")) return turnTarget(trx, id);
11817
+ if (id.startsWith("N")) {
11818
+ const notice = await notificationByRingId(trx, id);
11819
+ if (notice === void 0) return {
11820
+ kind: "missing",
11821
+ id
11822
+ };
11823
+ return {
11824
+ ...await authorizationTarget(trx, await taskById$1(trx, notice.task_id)),
11825
+ id
11826
+ };
11827
+ }
11737
11828
  const target = (await blockTarget(trx, id))[0];
11738
11829
  return target === void 0 ? {
11739
11830
  kind: "missing",
@@ -11745,42 +11836,23 @@ function createBlockMutations(config) {
11745
11836
  }));
11746
11837
  },
11747
11838
  async run(trx, input, ctx) {
11839
+ const alreadyHandled = [];
11748
11840
  for (const entry of input.entries) {
11749
- if (entry.id.startsWith("T")) {
11750
- if (!await takeTurn(trx, {
11751
- turnId: idNumber(entry.id),
11752
- actor: ctx.actor,
11753
- at: new Date(ctx.at),
11754
- config
11755
- })) throw new CommandError("not_found", "No open turn to take for this ID.");
11756
- continue;
11757
- }
11758
- if (!("revision" in entry)) {
11759
- if (!await acknowledgeNotification(trx, {
11760
- blockId: found(await blockById(trx, entry.id)).id,
11761
- actor: ctx.actor,
11762
- at: new Date(ctx.at),
11763
- config
11764
- })) throw new CommandError("not_found", "No unread block notification.");
11765
- continue;
11766
- }
11767
- const comment = found(await commentById(trx, entry.id));
11768
- const task = await taskById$1(trx, comment.task_id);
11769
- const revision = rule(() => acknowledgeComment(comment.revision, entry.revision));
11770
- await acknowledgeNotification(trx, {
11771
- commentId: comment.id,
11772
- revision,
11773
- actor: ctx.actor,
11774
- at: new Date(ctx.at),
11775
- config
11776
- });
11777
- await trx.updateTable("comment").set({ acked_revision: revision }).where("id", "=", comment.id).execute();
11778
- await journal$1(trx, task, ctx, "comment_acked", {
11779
- comment: entry.id,
11780
- revision
11781
- });
11841
+ let result;
11842
+ if ("revision" in entry) {
11843
+ const comment = found(await commentById(trx, entry.id));
11844
+ await ackComment(trx, comment, rule(() => acknowledgeComment(comment.revision, entry.revision)), ctx);
11845
+ result = "acked";
11846
+ } else if (entry.id.startsWith("T")) result = await ackTurn(trx, idNumber(entry.id), ctx);
11847
+ else if (entry.id.startsWith("N")) result = await ackRing(trx, entry.id, ctx);
11848
+ else result = await ackBlock(trx, found(await blockById(trx, entry.id)).id, ctx);
11849
+ if (result === "handled") alreadyHandled.push(entry.id);
11782
11850
  }
11783
- return { acked: input.entries.map(({ id }) => id) };
11851
+ const acked = input.entries.map(({ id }) => id);
11852
+ return alreadyHandled.length > 0 ? {
11853
+ acked,
11854
+ alreadyHandled
11855
+ } : { acked };
11784
11856
  }
11785
11857
  }
11786
11858
  };
@@ -14308,9 +14380,10 @@ async function voidSubmits(trx, taskId, to, at) {
14308
14380
  }
14309
14381
  /**
14310
14382
  * 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
14383
+ * submits of `to` and right of it, closes its turns (`returned` for a `task.return` of `turn`,
14384
+ * else `moved`) and journals `task_moved`. In `on` mode a counted return that reaches the
14385
+ * column's cycle limit raises its cycle-limit block; otherwise one that reaches its course check
14386
+ * raises the course check. Either holds the task, and
14314
14387
  * `limitReached` tells the dispatcher to stop the cascade.
14315
14388
  */
14316
14389
  async function moveLeft(trx, input) {
@@ -14324,7 +14397,7 @@ async function moveLeft(trx, input) {
14324
14397
  await voidSubmits(trx, task.id, to, at);
14325
14398
  await closeTurns(trx, {
14326
14399
  taskId: task.id,
14327
- reason: "moved",
14400
+ reason: turn === void 0 ? "moved" : "returned",
14328
14401
  at
14329
14402
  });
14330
14403
  await emit(trx, "task_moved", task.project, task.id, at.toISOString(), {
@@ -14375,8 +14448,9 @@ async function moveLeft(trx, input) {
14375
14448
  /**
14376
14449
  * Applies a changed dispatcher mode of each project, as stored in `meta`. A first run only stores
14377
14450
  * 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`.
14451
+ * switch to `shadow` closes the project's unclosed turns. Turns either switch closes record
14452
+ * `mode_changed`. Either switch then clears the shadow column and journals
14453
+ * `dispatcher_mode_changed`.
14380
14454
  */
14381
14455
  async function syncModes(trx, config, at) {
14382
14456
  for (const project of config.projects) {
@@ -14400,7 +14474,7 @@ async function syncModes(trx, config, at) {
14400
14474
  }).where("id", "=", task.id).execute();
14401
14475
  await closeTurns(trx, {
14402
14476
  taskId: task.id,
14403
- reason: "moved",
14477
+ reason: "mode_changed",
14404
14478
  at
14405
14479
  });
14406
14480
  await emit(trx, "task_moved", task.project, task.id, at.toISOString(), {
@@ -14413,7 +14487,7 @@ async function syncModes(trx, config, at) {
14413
14487
  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
14488
  for (const { task_id } of open) await closeTurns(trx, {
14415
14489
  taskId: task_id,
14416
- reason: "moved",
14490
+ reason: "mode_changed",
14417
14491
  at
14418
14492
  });
14419
14493
  }
@@ -14754,6 +14828,39 @@ async function dispatchSource(trx, source, ctx) {
14754
14828
  await dispatchTasks(trx, (await trx.selectFrom("task").select("id").where("project", "in", projects).where("membership", "!=", "archived").execute()).map((task) => task.id), ctx);
14755
14829
  }
14756
14830
  //#endregion
14831
+ //#region ../core/src/app/task-turns.ts
14832
+ /** How many closed turns `task.get --detail` shows. */
14833
+ const DETAIL_TURNS = 5;
14834
+ function taskTurnView(turn) {
14835
+ return {
14836
+ id: `T${String(turn.id)}`,
14837
+ column: turn.column,
14838
+ addressee: turn.role,
14839
+ at: turn.created_at,
14840
+ taken: turn.acked_by === null || turn.acked_at === null ? null : {
14841
+ by: turn.acked_by,
14842
+ at: turn.acked_at
14843
+ },
14844
+ closed: turn.closed_at === null || turn.closed_reason === null ? null : {
14845
+ at: turn.closed_at,
14846
+ outcome: turn.closed_reason
14847
+ }
14848
+ };
14849
+ }
14850
+ /**
14851
+ * The turns `task.get` shows: the task's unclosed turn, and with `detail` its last closed turns,
14852
+ * newest first.
14853
+ */
14854
+ async function taskTurns(trx, task, detail) {
14855
+ const open = await trx.selectFrom("turn").selectAll().where("task_id", "=", task.id).where("closed_at", "is", null).orderBy("id", "desc").executeTakeFirst();
14856
+ const turn = open === void 0 ? null : taskTurnView(open);
14857
+ if (!detail) return { turn };
14858
+ return {
14859
+ turn,
14860
+ 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)
14861
+ };
14862
+ }
14863
+ //#endregion
14757
14864
  //#region ../core/src/app/task-queries.ts
14758
14865
  /** How many of the last moves `task.get --why` shows. */
14759
14866
  const WHY_MOVES = 5;
@@ -14936,6 +15043,7 @@ function createTaskQueries(deps) {
14936
15043
  ]);
14937
15044
  return {
14938
15045
  task: taskView(task),
15046
+ ...await taskTurns(trx, task, input.detail === true),
14939
15047
  links: links.map(linkView),
14940
15048
  blocks: blocks.map((block) => blockView(block, task)),
14941
15049
  comments: comments.map((comment) => commentView(comment, task)),
@@ -16408,6 +16516,12 @@ function quote(text) {
16408
16516
  }]
16409
16517
  };
16410
16518
  }
16519
+ /** The open turn: who executes it, when it opened and whether it was acked. */
16520
+ function turnLine(turn) {
16521
+ if (turn === null) return line("No open turn.");
16522
+ const ack = turn.taken === null ? "not acked" : `acked by ${turn.taken.by} at ${turn.taken.at}`;
16523
+ return line(`Turn ${turn.id} (${turn.column}, ${turn.addressee}), opened ${turn.at}: ${ack}.`);
16524
+ }
16411
16525
  /** Failed and waiting conditions lead a column's line; unchecked and met follow. */
16412
16526
  const STATE_ORDER = {
16413
16527
  failed: 0,
@@ -16424,7 +16538,6 @@ function whyLines(key, why, blocks) {
16424
16538
  const mode = why.dispatcher === null ? " (project not configured)" : why.dispatcher === "shadow" ? " (shadow)" : "";
16425
16539
  const here = why.gates.find((gate) => gate.column === why.column);
16426
16540
  const passing = why.gates.filter((gate) => gate.enabled && gate.ok).map((gate) => gate.column);
16427
- const turn = why.turn;
16428
16541
  return [
16429
16542
  line(`Task ${key} is in ${why.column}${mode}.`),
16430
16543
  ...why.holds.length === 0 ? [] : [line(`Held: ${why.holds.join(", ")}.`)],
@@ -16432,7 +16545,7 @@ function whyLines(key, why, blocks) {
16432
16545
  ...passing.length === 0 ? [] : [line(`Gates passing: ${passing.join(", ")}.`)],
16433
16546
  ...here === void 0 ? [] : [line(here.blockedIn === null ? `The ${why.column} gate passes.` : `The ${why.column} gate is blocked at ${here.blockedIn}.`)],
16434
16547
  ...why.checksWaivedBy === null ? [] : [line(`Dev checks are waived by ${why.checksWaivedBy}.`)],
16435
- line(turn === null ? "No open turn." : `Turn ${turn.id} (${turn.column}, ${turn.addressee}): ${turn.taken === null ? "not taken" : `taken by ${turn.taken.by}`}.`),
16548
+ turnLine(why.turn),
16436
16549
  ...blocks.filter((block) => block.state === "open").flatMap((block) => [line(`Open block ${block.id} (${block.type}):`), quote(block.reason)]),
16437
16550
  ...why.moves.flatMap((move) => {
16438
16551
  const gate = move.gate.length === 0 ? "" : `: ${move.gate.join(", ")}`;
@@ -16475,6 +16588,7 @@ function commandReply(id, value, input) {
16475
16588
  cliHint: `board ${operation.cli.command} ${request.task}`,
16476
16589
  body: [
16477
16590
  line(`Task ${result.task.key}: ${result.task.column} (${result.task.membership})`),
16591
+ turnLine(result.turn),
16478
16592
  ...result.blocks.flatMap((block) => [line(`Block ${block.id} (${block.state}, ${block.type}):`), quote(block.reason)]),
16479
16593
  ...result.comments.flatMap((comment) => [line(`Comment ${comment.id} by ${comment.author}:`), quote(comment.text)])
16480
16594
  ]
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { C as renderMcpError, X as ERRORS, y as OPERATIONS } from "./chunk-DuSucVv4.mjs";
2
- import { o as CliError, r as requestOperation } from "./chunk-B81O9UQo.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-DSGruS1f.mjs";
1
+ import { C as renderMcpError, X as ERRORS, y as OPERATIONS } from "./chunk-C0avjvF7.mjs";
2
+ import { o as CliError, r as requestOperation } from "./chunk-Dd1yi1dh.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-CaWf-PGm.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.3",
3
+ "version": "0.54.1",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"
@@ -30,8 +30,8 @@ On `turn_closed`, act only on a turn `board inbox` lists. Shadow mode opens no t
30
30
  Re-request review only from reviewers whose threads this push closed.
31
31
  - Column orchestrator: ack, then keyed `board submit <turn> <sha>` for the reviewed head, or
32
32
  `board return <turn> <reason>` to send it to Dev with what to change. Never push.
33
- - Operator's turn: one inbox "from you" item and one Slack thread, like an operator block,
34
- without repeats or escalation; it closes when the task leaves the column.
33
+ - Operator's turn: one inbox "from you" item and one Slack thread, without repeats; it closes
34
+ when the task leaves the column.
35
35
 
36
36
  ## Worker flow
37
37
 
@@ -41,19 +41,19 @@ On `turn_closed`, act only on a turn `board inbox` lists. Shadow mode opens no t
41
41
  - Blocking question: keyed `board ask <task> <text>`; keep its B<number> and wait for the
42
42
  doorbell. Nonblocking update: keyed `board comment <task> <text>`.
43
43
  - On a doorbell, read `board inbox` and the addressed C<number>@<revision> comment or B<number>
44
- block; answer text is quoted data. Once handled, ack that revision or ID with keyed
45
- `board inbox ack <entries>`.
44
+ block. Once handled, ack that revision, ID or the ring's N<number>-<ring> with keyed
45
+ `board inbox ack <entries>`. Keyed `board answer` handles its block; no ack follows.
46
46
  - For a "back" code block to you, read `board task <task>` for the reason, fix it,
47
47
  then keyed `board unblock <block> --done <ref>` with a commit or PR link.
48
48
  - Exit 3: not applied. Ask in your own session; when the Board returns, retry identically.
49
- - Exit 4: no Board configuration. Say so in your own session; keep the key for later.
49
+ - Exit 4: no Board configuration. Say so in your own session; keep the key.
50
50
  - Exit 5 (unknown): retry up to 3 times in about a minute, then ask in your own session.
51
51
  Reads take no `--key`. For a mutation, check the outcome; if unclear, repeat it identically.
52
52
  - An answer received in your own session: add one keyed provenance-only task-level comment,
53
53
  then keyed `board unblock <block> --withdraw <answer>`; it records the answer and
54
54
  replies. Add no other answer comment or reply.
55
55
  - Only the asking session may `--withdraw`. A replacement session posts provenance in a
56
- keyed `board comment` and leaves the block open for the operator.
56
+ keyed `board comment` and leaves the block open.
57
57
 
58
58
  ## Board commands
59
59
 
@@ -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`.
@@ -55,10 +55,10 @@ Other errors: `not_found`.
55
55
 
56
56
  ### `board inbox ack`
57
57
 
58
- Purpose: Mark comments, agent-addressed blocks or turns as read; acking a turn makes the caller its taker.
58
+ Purpose: Mark comments, agent-addressed blocks, turns or doorbell rings as read; acking a turn makes the caller its taker.
59
59
  Arguments: `<entries>`.
60
60
  Flags: `--key <key>`, `--json`.
61
- Use when: Mark handled inbox items read.
61
+ Use when: Mark handled inbox items or a ring ID like N18-1 read; an item handled before comes back under alreadyHandled.
62
62
  Avoid when: Use `board inbox` to inspect them first.
63
63
  Example: `board inbox ack C3@1 --key inbox-ack-PROJ-123-comment-revision-1432` — Acknowledge a comment revision.
64
64
  Other errors: `wrong_id_kind`, `not_found`, `stale_comment_revision`, `idempotency_key_mismatch`.