spur-board 0.131.0 → 0.132.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/daemon.mjs CHANGED
@@ -8298,6 +8298,15 @@ async function turnReturn(db, turn) {
8298
8298
  };
8299
8299
  }
8300
8300
  }
8301
+ /**
8302
+ * The open `code` block of the return that opened `turn`'s visit while it is still addressed to
8303
+ * the turn's role, else undefined. Taking the turn reads it; the turn's submit closes it.
8304
+ */
8305
+ async function openReturnBlock(db, turn) {
8306
+ const returned = await turnReturn(db, turn);
8307
+ if (returned === void 0) return void 0;
8308
+ return db.selectFrom("block").selectAll().where("id", "=", Number(returned.block.slice(1))).where("task_id", "=", turn.task_id).where("state", "=", "open").where("type", "=", "code").where("addressee_role", "=", turn.role).executeTakeFirst();
8309
+ }
8301
8310
  function taskView(task) {
8302
8311
  return {
8303
8312
  key: task.key,
@@ -12301,6 +12310,15 @@ async function closeBlockIfOpen(trx, blockId, ctx, outcome, outcomeReason) {
12301
12310
  if (block === void 0) return;
12302
12311
  await closeOpenBlock(trx, await blockSubject(trx, block), block, ctx, outcome, outcomeReason);
12303
12312
  }
12313
+ /**
12314
+ * Closes the open `code` block of the return that opened `turn`'s visit (`openReturnBlock`) as
12315
+ * done at `sha`: the turn's submit, once confirmed, answered it. A pending submit waits, so a
12316
+ * voided one leaves the block to the next submit.
12317
+ */
12318
+ async function answerReturn(trx, task, turn, ctx, sha) {
12319
+ const block = await openReturnBlock(trx, turn);
12320
+ if (block !== void 0) await closeOpenBlock(trx, taskSubject(task), block, ctx, "done", sha);
12321
+ }
12304
12322
  /** The thread messages that close an operator conversation, compared after trimming. */
12305
12323
  const CLOSE_COMMANDS = /* @__PURE__ */ new Set([
12306
12324
  "close",
@@ -12677,14 +12695,29 @@ function createBlockMutations(config) {
12677
12695
  if (unread !== void 0) throw new CommandError("forbidden", "Only the addressed task role can acknowledge.");
12678
12696
  throw new CommandError("not_found", "No unread block notification.");
12679
12697
  }
12680
- /** Takes a turn; a turn the caller took or was rung for before it closed is already handled. */
12698
+ /**
12699
+ * Takes a turn; a turn the caller took or was rung for before it closed is already handled.
12700
+ * Taking the Dev turn of a return also reads the return's open `code` block
12701
+ * (`openReturnBlock`), so its rings stop and it never raises `worker_not_reading`.
12702
+ */
12681
12703
  async function ackTurn(trx, id, ctx) {
12704
+ const at = new Date(ctx.at);
12682
12705
  if (await takeTurn(trx, {
12683
12706
  turnId: id,
12684
12707
  actor: ctx.actor,
12685
- at: new Date(ctx.at),
12708
+ at,
12686
12709
  config
12687
- })) return "acked";
12710
+ })) {
12711
+ const block = await openReturnBlock(trx, await trx.selectFrom("turn").selectAll().where("id", "=", id).executeTakeFirstOrThrow());
12712
+ if (block !== void 0) await acknowledgeNotification(trx, {
12713
+ blockId: block.id,
12714
+ actor: ctx.actor,
12715
+ at,
12716
+ config,
12717
+ takeover: true
12718
+ });
12719
+ return "acked";
12720
+ }
12688
12721
  const turn = await trx.selectFrom("turn").selectAll().where("id", "=", id).executeTakeFirst();
12689
12722
  if (turn?.acked_by === ctx.actor) return "handled";
12690
12723
  if (turn !== void 0 && turn.closed_at !== null) {
@@ -15432,13 +15465,30 @@ async function supersedeSubmit(trx, task, pending, at) {
15432
15465
  supersededByMerge: pending.head
15433
15466
  });
15434
15467
  }
15435
- /** Counts a pending submit a poll confirmed: from its receipt time, on the linked PR. */
15436
- async function confirmSubmit(trx, pending) {
15437
- await trx.updateTable("submission").set((eb) => ({
15468
+ /**
15469
+ * Counts a pending submit a poll confirmed: from its receipt time, on the linked PR. The turn it
15470
+ * closed answered its visit's return, so the return's code block closes at the confirmed head.
15471
+ */
15472
+ async function confirmSubmit(trx, task, pending, at) {
15473
+ const row = await trx.updateTable("submission").set((eb) => ({
15438
15474
  pending_until: null,
15439
15475
  pr_repo: eb.fn.coalesce("pr_repo", eb.val(pending.pr.repo)),
15440
15476
  pr_number: eb.fn.coalesce("pr_number", eb.val(pending.pr.number))
15441
- })).where("id", "=", pending.id).execute();
15477
+ })).where("id", "=", pending.id).returning([
15478
+ "column",
15479
+ "epoch",
15480
+ "author"
15481
+ ]).executeTakeFirstOrThrow();
15482
+ const turn = await trx.selectFrom("turn").select([
15483
+ "task_id",
15484
+ "column",
15485
+ "epoch",
15486
+ "role"
15487
+ ]).where("task_id", "=", task.id).where("column", "=", row.column).where("epoch", "=", row.epoch).where("acked_by", "=", row.author).where("closed_reason", "=", "submitted").orderBy("id", "desc").executeTakeFirst();
15488
+ if (turn !== void 0) await answerReturn(trx, task, turn, {
15489
+ actor: row.author,
15490
+ at: at.toISOString()
15491
+ }, pending.sha);
15442
15492
  }
15443
15493
  /**
15444
15494
  * Re-evaluates the gates of each task and applies the cascade: in `on` mode it moves the column
@@ -15458,7 +15508,7 @@ async function dispatchTasks(trx, taskIds, ctx) {
15458
15508
  if (read === null) continue;
15459
15509
  if (read.pending?.state === "superseded") await supersedeSubmit(trx, task, read.pending, ctx.at);
15460
15510
  if (read.ticketUnconfirmed) continue;
15461
- if (read.pending?.state === "confirmed") await confirmSubmit(trx, read.pending);
15511
+ if (read.pending?.state === "confirmed") await confirmSubmit(trx, task, read.pending, ctx.at);
15462
15512
  const result = dispatch(read.input);
15463
15513
  if (mode === "shadow") await applyShadow(trx, task, project, result, ctx.at);
15464
15514
  else await applyOn(trx, task, read, result, ctx);
@@ -18739,6 +18789,7 @@ function createTurnMutations(deps) {
18739
18789
  column: turn.column,
18740
18790
  epoch: turn.epoch
18741
18791
  }, ctx, completeSince, config.projects.find((entry) => entry.id === task.project)?.dispatcher.submitConfirmMs);
18792
+ if (confirmed !== "pending") await answerReturn(trx, task, turn, ctx, input.sha);
18742
18793
  await closeTurns(trx, {
18743
18794
  taskId: task.id,
18744
18795
  reason: "submitted",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.131.0",
3
+ "version": "0.132.0",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"
@@ -41,6 +41,15 @@ Read [the worker flow](references/worker-flow.md) for session links, asks, updat
41
41
  - On doorbell, read `board inbox` and the addressed C<number>@<revision> comment or B<number>
42
42
  block. Once handled, ack its revision, ID or ring N<number>-<ring> with keyed
43
43
  `board inbox ack <entries>`. Keyed `board answer` handles its block; no ack follows.
44
+ - A return: ack its Dev turn, fix and submit; the take reads its `code` block, your confirmed
45
+ submit closes it; no unblock. Keyed `board unblock <block> --done <ref>` after the fix only
46
+ if `board task <task>` shows it open with `addressee` worker, after your submit if a Dev
47
+ turn is yours. Ack it when you read it in `board inbox`; `not_found`: none due. If the ack
48
+ answers `forbidden` (the block's ring is assigned to another worker, or you authored the
49
+ block), skip the ack: close it with `--done` if it is yours to close, otherwise leave it to
50
+ the worker it rings. While `board task <task> --why` lists `submit_pending` or another hold,
51
+ wait. A hold that does not clear: keyed `board ask <task> <text>` naming it; its recipient
52
+ checks or escalates it, up to the operator ([how the Board works](references/how-board-works.md)).
44
53
 
45
54
  ## Board commands
46
55
 
@@ -48,6 +48,8 @@ The Dev turn hands the comments, beside a return's `code` block.
48
48
  Each handed entry has its `url`, `editedAt` once edited, and a review's inline
49
49
  `comments` with `url` and `threadId`. Turns of a Dev visit opened by a return
50
50
  show `returned`: who, from, the turn, the `code` block and the verbatim reason.
51
+ A worker taking that turn reads its block; the block closes `done` with the SHA once
52
+ the Board confirms the turn's submit.
51
53
 
52
54
  Closed turns receive no further Board sends; Obsolete queued rings are dropped;
53
55
  a message already accepted by Spur cannot be retracted. Check `board inbox` and
@@ -5,8 +5,19 @@
5
5
  `board link`. URL from the key: `o/r#12` is `https://github.com/o/r/issues/12`.
6
6
  - Blocking: keyed `board ask <task> <text>`; keep its B<number> and wait for the
7
7
  doorbell. Update: keyed `board comment <task> <text>`.
8
- - For a "back" code block to you, read `board task <task>` for the reason, fix it,
9
- then keyed `board unblock <block> --done <ref>` with commit/PR link.
8
+ - A return to Dev: ack its Dev turn, read the reason in `board task <task>`, fix it, then
9
+ keyed `board submit <turn> <sha>`. The take reads the "back" code block; your confirmed
10
+ submit closes it `done`, no unblock.
11
+ - Close a "back" block by hand: keyed `board unblock <block> --done <commit/PR link>` once the
12
+ fix is in, only if `board task <task>` shows it open with `addressee` worker, and that
13
+ submit left it open or you have no Dev turn (an orchestrator or operator runs Dev). Ack it
14
+ when you read it in `board inbox`; `not_found` means no notification, no ack. If the ack
15
+ answers `forbidden` (the block's ring is assigned to another worker, or you authored the
16
+ block), skip the ack: close it with `--done` if it is yours to close, otherwise leave it to
17
+ the worker it rings. While `board task <task> --why` lists `submit_pending` or another hold,
18
+ wait. A hold that does not clear: keyed `board ask <task> <text>` naming it; its recipient
19
+ checks or escalates it with keyed `board escalate <block>`, up to the operator
20
+ ([Blocks and escalation](how-board-works-blocks.md)).
10
21
  - Exit 3: not applied. Ask in your own session; when the Board returns, retry identically.
11
22
  - Exit 4: no Board config; report in your session; keep the key.
12
23
  - Exit 5 (unknown): retry up to 3 times in a minute, then ask in your own session.