spur-board 0.117.1 → 0.118.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.
@@ -122,6 +122,12 @@ const SESSION_END_REASONS = [
122
122
  ];
123
123
  /** How a project's dispatcher runs: `shadow` records moves only, `on` moves tasks and opens turns. */
124
124
  const DISPATCHER_MODES = ["shadow", "on"];
125
+ /** The submitter's declared testing provenance. */
126
+ const SUBMISSION_BASES = [
127
+ "tested",
128
+ "carried",
129
+ "skipped"
130
+ ];
125
131
  /**
126
132
  * How a turn closed: `submitted` by the executor's submit, `returned` by `task.return`, `moved`
127
133
  * when the task moved on (it also covers returns and mode switches recorded by older versions),
@@ -1151,6 +1157,20 @@ const ERRORS = {
1151
1157
  hint: "Take the turn with `board inbox ack` first; only the session that took it can submit or return it.",
1152
1158
  recovery: noRetry("Take the turn first; only the session that took it can submit or return it.")
1153
1159
  }),
1160
+ submit_basis_invalid: spec("submit_basis_invalid", {
1161
+ status: 409,
1162
+ exit: EXIT_CODES.refused,
1163
+ message: "The submission basis fields are inconsistent.",
1164
+ hint: "Use from and a nonblank reason for carried, a nonblank reason for skipped, and from only with carried.",
1165
+ recovery: noRetry("Correct the basis fields and submit again.")
1166
+ }),
1167
+ submit_source_not_tested: spec("submit_source_not_tested", {
1168
+ status: 409,
1169
+ exit: EXIT_CODES.refused,
1170
+ message: "The source has no tested origin on this task.",
1171
+ hint: "Choose a tested submission SHA on this task, or a carried SHA with a tested origin; otherwise test or explicitly skip with a reason.",
1172
+ recovery: noRetry("Choose a source with a tested origin on this task or change the basis.")
1173
+ }),
1154
1174
  head_mismatch: spec("head_mismatch", {
1155
1175
  status: 409,
1156
1176
  exit: EXIT_CODES.refused,
@@ -2095,6 +2115,10 @@ const eventPayloadSchemas = {
2095
2115
  task_added: z.looseObject({ column: z.enum(COLUMN_IDS) }),
2096
2116
  task_archived: z.looseObject({ reason: z.enum(ARCHIVE_REASONS) }),
2097
2117
  task_submitted: z.looseObject({
2118
+ basis: z.enum(SUBMISSION_BASES).optional(),
2119
+ from: S.optional(),
2120
+ testedOrigin: S.optional(),
2121
+ reason: S.optional(),
2098
2122
  turn: S.optional(),
2099
2123
  column: z.enum(COLUMN_IDS),
2100
2124
  sha: S,
@@ -2628,6 +2652,39 @@ const statusReturnedSchema = z.strictObject({
2628
2652
  block: blockIdSchema.describe("The code block the return opened."),
2629
2653
  findings: z.int().min(0).nullable().describe("Number of review findings the return sent; null when not given.")
2630
2654
  });
2655
+ const latestSubmissionSchema = z.strictObject({
2656
+ column: z.enum(COLUMN_IDS).describe("Column submitted from."),
2657
+ sha: commitShaSchema.describe("Full submitted commit SHA."),
2658
+ at: z.iso.datetime().describe("Submission time, ISO 8601 UTC."),
2659
+ basis: z.enum(SUBMISSION_BASES).describe("Declared testing provenance; tested does not claim tests passed."),
2660
+ from: commitShaSchema.nullable().describe("Supplied source SHA for carried work, otherwise null."),
2661
+ testedOrigin: commitShaSchema.nullable().describe("Original tested submission SHA for carried work, otherwise null."),
2662
+ reason: z.string().max(2e3).nullable().describe("Literal explanation supplied by the submitter."),
2663
+ pending: z.boolean().describe("Whether head confirmation is pending."),
2664
+ voided: z.boolean().describe("Whether this submission has been voided for gate purposes.")
2665
+ }).describe("Latest accepted submission by row order, including pending and voided submissions.").nullable().optional().describe("Latest submission; null when none, absent on older servers.");
2666
+ const summaryCount = (what) => z.int().min(0).describe(what);
2667
+ const prSummarySchema = z.strictObject({
2668
+ repo: prFactsSchema.shape.repo,
2669
+ number: prFactsSchema.shape.number,
2670
+ checks: z.strictObject({
2671
+ pass: summaryCount("Successful or neutral checks."),
2672
+ fail: summaryCount("Failed checks, including skipped."),
2673
+ pending: summaryCount("Expected or pending checks.")
2674
+ }).describe("Required checks when nonempty, otherwise all reported checks; a factual rollup, not a gate verdict."),
2675
+ mergeable: prFactsSchema.shape.mergeable,
2676
+ threads: z.strictObject({
2677
+ unresolved: summaryCount("Unresolved review threads."),
2678
+ total: summaryCount("All review threads.")
2679
+ }).describe("Review thread counts."),
2680
+ reviewsOnHead: z.strictObject({
2681
+ approved: z.array(z.string()).describe("Reviewers approving the current head."),
2682
+ changesRequested: z.array(z.string()).describe("Reviewers requesting changes on the current head.")
2683
+ }).describe("Latest recorded reviews on the current head, without gate filtering."),
2684
+ draft: prFactsSchema.shape.draft,
2685
+ factAt: z.iso.datetime().describe("Snapshot observation time, ISO 8601 UTC."),
2686
+ unconfirmed: z.boolean().describe("Observation is stale or its supporting source is blind or missing.")
2687
+ }).describe("Compact observed pull request facts.");
2631
2688
  // ../contracts/src/ops/schemas.ts
2632
2689
  /**
2633
2690
  * A comment as every output returns it. `untrusted` is always `true`: the text comes from a
@@ -2747,28 +2804,8 @@ const linkViewSchema = z.strictObject({
2747
2804
  }).describe("An effective link to a task.");
2748
2805
  const detailOnly = "Present only with detail.";
2749
2806
  const count = (what) => z.int().min(0).describe(what);
2750
- const prSummarySchema = z.strictObject({
2751
- repo: prFactsSchema.shape.repo,
2752
- number: prFactsSchema.shape.number,
2753
- checks: z.strictObject({
2754
- pass: count("Successful or neutral checks."),
2755
- fail: count("Failed checks, including skipped."),
2756
- pending: count("Expected or pending checks.")
2757
- }).describe("Required checks when nonempty, otherwise all reported checks; a factual rollup, not a gate verdict."),
2758
- mergeable: prFactsSchema.shape.mergeable,
2759
- threads: z.strictObject({
2760
- unresolved: count("Unresolved review threads."),
2761
- total: count("All review threads.")
2762
- }).describe("Review thread counts."),
2763
- reviewsOnHead: z.strictObject({
2764
- approved: z.array(z.string()).describe("Reviewers approving the current head."),
2765
- changesRequested: z.array(z.string()).describe("Reviewers requesting changes on the current head.")
2766
- }).describe("Latest recorded reviews on the current head, without gate filtering."),
2767
- draft: prFactsSchema.shape.draft,
2768
- factAt: z.iso.datetime().describe("Snapshot observation time, ISO 8601 UTC."),
2769
- unconfirmed: z.boolean().describe("Observation is stale or its supporting source is blind or missing.")
2770
- }).describe("Compact observed pull request facts.");
2771
2807
  const statusTaskSchema = taskViewSchema.extend({
2808
+ submission: latestSubmissionSchema,
2772
2809
  columnEnteredAt: z.iso.datetime().nullable().describe("Time the task entered its current real column, ISO 8601 UTC; latest real move or correction, falling back to the original add time, or null if neither is known."),
2773
2810
  shadowColumn: z.enum(COLUMN_IDS).optional().describe("Column the dispatcher works from in shadow mode: where the board would have the task. Present only while the project dispatcher is in shadow mode."),
2774
2811
  shadowDiffers: z.boolean().optional().describe("Whether shadowColumn differs from column. Present only while the project dispatcher is in shadow mode."),
@@ -3062,6 +3099,7 @@ const taskGetInputSchema = z.strictObject({
3062
3099
  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.")
3063
3100
  });
3064
3101
  const taskGetOutputSchema = z.strictObject({
3102
+ submission: latestSubmissionSchema,
3065
3103
  task: taskViewSchema,
3066
3104
  turn: taskTurnSchema.nullable().describe("The task's unclosed turn; null when none is open."),
3067
3105
  turns: z.array(taskTurnSchema).optional().describe("Present only with detail: the last 5 closed turns, newest first."),
@@ -4613,12 +4651,15 @@ const OPERATIONS = [
4613
4651
  kind: "mutation",
4614
4652
  description: "Submit the task's pull request head for a turn this session took; the turn closes; a pending result is final.",
4615
4653
  mcp: {
4616
- whenToUse: "Hand in the work of a turn you took, at the pull request head. While the project dispatcher is in shadow mode no turn opens: the column executor submits with the task key.",
4654
+ whenToUse: "Hand in the work of a turn you took, at the pull request head. Declare tested (default), carried from a tested origin on this task, or skipped; carried requires from and reason, skipped requires reason. While the project dispatcher is in shadow mode no turn opens: the column executor submits with the task key.",
4617
4655
  whenNotToUse: "Use task_return to send the task back to Dev instead."
4618
4656
  },
4619
4657
  input: z.strictObject({
4620
4658
  turn: z.union([turnIdSchema, taskKeyInputSchema]).describe("Turn ID you took (T4); while the project dispatcher is in shadow mode, the task key instead."),
4621
- sha: commitShaSchema.max(64).describe("Full commit SHA at the head of the pull request, lowercase.")
4659
+ sha: commitShaSchema.max(64).describe("Full commit SHA at the head of the pull request, lowercase."),
4660
+ basis: z.enum(SUBMISSION_BASES).optional().describe("Testing provenance: tested (default), carried from a tested origin on this task, or skipped with a reason."),
4661
+ from: commitShaSchema.max(64).optional().describe("Full lowercase source SHA on this task; required only for carried."),
4662
+ reason: z.string().max(2e3).optional().describe("Literal nonblank explanation, up to 2000 UTF-16 units; required for carried and skipped.")
4622
4663
  }),
4623
4664
  output: z.strictObject({
4624
4665
  task: taskViewSchema,
@@ -4633,6 +4674,8 @@ const OPERATIONS = [
4633
4674
  "task_archived",
4634
4675
  "turn_closed",
4635
4676
  "not_turn_taker",
4677
+ "submit_basis_invalid",
4678
+ "submit_source_not_tested",
4636
4679
  "head_mismatch",
4637
4680
  "github_unavailable"
4638
4681
  ],
@@ -4658,6 +4701,25 @@ const OPERATIONS = [
4658
4701
  status: "confirmed"
4659
4702
  }
4660
4703
  },
4704
+ {
4705
+ summary: "Carry tested work from a submission on this task",
4706
+ input: {
4707
+ turn: "T4",
4708
+ sha: submittedSha,
4709
+ basis: "carried",
4710
+ from: "a".repeat(40),
4711
+ reason: "The tested work is unchanged."
4712
+ },
4713
+ output: {
4714
+ task: {
4715
+ ...task,
4716
+ column: "review"
4717
+ },
4718
+ turn: "T4",
4719
+ sha: submittedSha,
4720
+ status: "confirmed"
4721
+ }
4722
+ },
4661
4723
  {
4662
4724
  summary: "Submit a dev turn before the board has seen the pull request",
4663
4725
  input: {
@@ -1,5 +1,5 @@
1
- import { _t as configSchema, d as buildCatalogSnapshot, p as OPERATIONS, yt as plainHttpAllowed } from "./chunk-CoXzv4dC.mjs";
2
- import { o as CliError, t as fetchCatalogVersion } from "./chunk-Qzs7Xloy.mjs";
1
+ import { _t as configSchema, d as buildCatalogSnapshot, p as OPERATIONS, yt as plainHttpAllowed } from "./chunk-BLyH3LBD.mjs";
2
+ import { o as CliError, t as fetchCatalogVersion } from "./chunk-DsnvKf_Q.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 renderJsonError, at as errorContextSchema, c as tokenRequestStatusSchema, ct as successEnvelopeSchema, o as tokenRequestResultSchema, ot as errorEnvelopeSchema, rt as ERRORS } from "./chunk-CoXzv4dC.mjs";
1
+ import { _ as renderJsonError, at as errorContextSchema, c as tokenRequestStatusSchema, ct as successEnvelopeSchema, o as tokenRequestResultSchema, ot as errorEnvelopeSchema, rt as ERRORS } from "./chunk-BLyH3LBD.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 { D as sortSkillFiles, Q as actorIdSchema, T as skillReloadFileSchema, Tt as SLACK_BOT_SCOPES, _t as configSchema, a as requestHashOf, bt as requiredSecretKeys, ct as successEnvelopeSchema, f as roleCanUseOperation, p as OPERATIONS, pt as DEFAULT_STAND_PORT_RANGE, r as remoteDoctorReportSchema, rt as ERRORS, u as SYSTEMD_SERVICE_SETTINGS, xt as resolveWebOrigin } from "./chunk-CoXzv4dC.mjs";
1
+ import { D as sortSkillFiles, Q as actorIdSchema, T as skillReloadFileSchema, Tt as SLACK_BOT_SCOPES, _t as configSchema, a as requestHashOf, bt as requiredSecretKeys, ct as successEnvelopeSchema, f as roleCanUseOperation, p as OPERATIONS, pt as DEFAULT_STAND_PORT_RANGE, r as remoteDoctorReportSchema, rt as ERRORS, u as SYSTEMD_SERVICE_SETTINGS, xt as resolveWebOrigin } from "./chunk-BLyH3LBD.mjs";
2
2
  import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
3
- import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-Qzs7Xloy.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-BXfL5iBi.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-DsnvKf_Q.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-CBEgOEgI.mjs";
5
5
  import { createHash, randomBytes, randomUUID } from "node:crypto";
6
6
  import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
7
7
  import { homedir, hostname, tmpdir, userInfo } from "node:os";
package/dist/client.mjs CHANGED
@@ -1 +1 @@
1
- export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-Qzs7Xloy.mjs";
1
+ export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-DsnvKf_Q.mjs";
package/dist/daemon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as encodeActorId, A as eventPayloadSchemas, B as REVIEW_STATES, C as messageRefSchema, Ct as DISPATCHER_MODES, D as sortSkillFiles, Dt as VIAS, E as skillReloadFilesSchema, Et as TASK_HOLDS, F as prSourceId, G as prFactsSchema, H as SESSION_STATUSES, I as sessionTransitionSchema, J as sessionFactsSchema, K as prRefSchema, L as sourceCursorSchema, M as batchSchema, N as defaultBranchFactSchema, O as EVENT_KINDS, P as entityRefSchema, Q as actorIdSchema, R as trackerSourceId, S as interactionRefSchema, St as COLUMN_IDS, Tt as SLACK_BOT_SCOPES, U as isExternalAuthor, V as SESSION_HEALTH_STATES, W as parseRingMarker, X as JIRA_PROJECT_KEY, Y as ticketFactsSchema, Z as REF_NUMBER, _t as configSchema, a as requestHashOf, b as conversationRefSchema, bt as requiredSecretKeys, c as tokenRequestStatusSchema, ct as successEnvelopeSchema, d as buildCatalogSnapshot, et as errorCodeOf, f as roleCanUseOperation, ft as DEFAULT_SLACK_COMMAND, g as renderHttpProblem, gt as configBindings, h as turnHandedSchema, ht as boardWideSpurProject, i as TOKEN_REQUEST_LIMITS, it as err, j as AdapterError, k as GATE_REASONS, l as BOARD_TICK_MS, m as defaultBranchViewSchema, mt as RESERVED_PROJECT, n as doctorReportSchema, nt as parseRef$1, o as tokenRequestResultSchema, p as OPERATIONS, q as ringMarker, rt as ERRORS, s as tokenRequestSchema, st as ok, t as assertNever, tt as parseActorId, ut as DEFAULT_LINK, vt as defaultAddressee, w as userIdSchema, wt as ITEM_KINDS, x as inboundEventSchema, xt as resolveWebOrigin, y as SPACE_IDS, yt as plainHttpAllowed, z as PR_STATES } from "./chunk-CoXzv4dC.mjs";
1
+ import { $ as encodeActorId, A as eventPayloadSchemas, B as REVIEW_STATES, C as messageRefSchema, Ct as DISPATCHER_MODES, D as sortSkillFiles, Dt as VIAS, E as skillReloadFilesSchema, Et as TASK_HOLDS, F as prSourceId, G as prFactsSchema, H as SESSION_STATUSES, I as sessionTransitionSchema, J as sessionFactsSchema, K as prRefSchema, L as sourceCursorSchema, M as batchSchema, N as defaultBranchFactSchema, O as EVENT_KINDS, P as entityRefSchema, Q as actorIdSchema, R as trackerSourceId, S as interactionRefSchema, St as COLUMN_IDS, Tt as SLACK_BOT_SCOPES, U as isExternalAuthor, V as SESSION_HEALTH_STATES, W as parseRingMarker, X as JIRA_PROJECT_KEY, Y as ticketFactsSchema, Z as REF_NUMBER, _t as configSchema, a as requestHashOf, b as conversationRefSchema, bt as requiredSecretKeys, c as tokenRequestStatusSchema, ct as successEnvelopeSchema, d as buildCatalogSnapshot, et as errorCodeOf, f as roleCanUseOperation, ft as DEFAULT_SLACK_COMMAND, g as renderHttpProblem, gt as configBindings, h as turnHandedSchema, ht as boardWideSpurProject, i as TOKEN_REQUEST_LIMITS, it as err, j as AdapterError, k as GATE_REASONS, l as BOARD_TICK_MS, m as defaultBranchViewSchema, mt as RESERVED_PROJECT, n as doctorReportSchema, nt as parseRef$1, o as tokenRequestResultSchema, p as OPERATIONS, q as ringMarker, rt as ERRORS, s as tokenRequestSchema, st as ok, t as assertNever, tt as parseActorId, ut as DEFAULT_LINK, vt as defaultAddressee, w as userIdSchema, wt as ITEM_KINDS, x as inboundEventSchema, xt as resolveWebOrigin, y as SPACE_IDS, yt as plainHttpAllowed, z as PR_STATES } from "./chunk-BLyH3LBD.mjs";
2
2
  import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -14433,6 +14433,68 @@ function blockRows(trx) {
14433
14433
  function turnRows(trx) {
14434
14434
  return trx.selectFrom("turn").innerJoin("task", "task.id", "turn.task_id").selectAll("turn").select(taskColumns).where("turn.role", "=", "operator");
14435
14435
  }
14436
+ // ../core/src/app/submissions.ts
14437
+ /** How long a submit waits for its on-demand PR read. */
14438
+ const SUBMIT_POLL_TIMEOUT_MS = 1e4;
14439
+ /** Polls the task's PR on demand for a submit; `skipped` when the task has none. */
14440
+ async function pollTaskPr(db, task, poll) {
14441
+ const pr = await taskPr(db, task.id);
14442
+ if (pr === null) return { kind: "skipped" };
14443
+ const repo = pr.repo.toLowerCase();
14444
+ const result = poll === void 0 ? null : await poll(prSourceId(task.project, repo), {
14445
+ kind: "pr",
14446
+ repo: pr.repo,
14447
+ number: pr.number
14448
+ }, { timeoutMs: SUBMIT_POLL_TIMEOUT_MS });
14449
+ return {
14450
+ kind: "polled",
14451
+ repo,
14452
+ number: pr.number,
14453
+ result
14454
+ };
14455
+ }
14456
+ /** Resolve provenance independently of current gate validity, pinning the original tested row. */
14457
+ async function submissionBasis(db, task, input) {
14458
+ const basis = input.basis ?? "tested";
14459
+ if (input.reason !== void 0 && input.reason.trim().length === 0 || basis !== "tested" && input.reason === void 0 || (basis === "carried" ? input.from === void 0 : input.from !== void 0)) throw new CommandError("submit_basis_invalid", "Supply from and a nonblank reason for carried, a nonblank reason for skipped, and from only with carried.");
14460
+ let origin;
14461
+ if (basis === "carried" && input.from !== void 0) {
14462
+ origin = await db.selectFrom("submission").select(["id", "commit_sha"]).where("task_id", "=", task).where("commit_sha", "=", input.from).where((eb) => eb.or([eb("basis", "is", null), eb("basis", "=", "tested")])).orderBy("id", "desc").executeTakeFirst();
14463
+ origin ??= await db.selectFrom("submission as carried").innerJoin("submission as origin", "origin.id", "carried.tested_source_id").select(["origin.id", "origin.commit_sha"]).where("carried.task_id", "=", task).where("origin.task_id", "=", task).where("carried.commit_sha", "=", input.from).where("carried.basis", "=", "carried").where((eb) => eb.or([eb("origin.basis", "is", null), eb("origin.basis", "=", "tested")])).orderBy("carried.id", "desc").executeTakeFirst();
14464
+ if (origin === void 0) throw new CommandError("submit_source_not_tested", "Choose a source SHA with a tested origin on this task, or test or skip with a reason.");
14465
+ }
14466
+ return {
14467
+ values: {
14468
+ basis,
14469
+ source_sha: input.from ?? null,
14470
+ basis_reason: input.reason ?? null,
14471
+ tested_source_id: origin?.id ?? null
14472
+ },
14473
+ event: {
14474
+ basis,
14475
+ ...input.from === void 0 ? {} : { from: input.from },
14476
+ ...input.reason === void 0 ? {} : { reason: input.reason },
14477
+ ...origin === void 0 ? {} : { testedOrigin: origin.commit_sha }
14478
+ }
14479
+ };
14480
+ }
14481
+ /** One bounded latest row per task, ordered by identity even at equal timestamps. */
14482
+ async function latestSubmissions(db, tasks) {
14483
+ if (tasks.length === 0) return /* @__PURE__ */ new Map();
14484
+ const ids = tasks.map((task) => task.id);
14485
+ const rows = await db.selectFrom("submission as s").leftJoin("submission as origin", "origin.id", "s.tested_source_id").selectAll("s").select("origin.commit_sha as origin_sha").where("s.task_id", "in", ids).where("s.id", "in", db.selectFrom("submission").select(sql`max(id)`.as("id")).where("task_id", "in", ids).groupBy("task_id")).execute();
14486
+ return new Map(rows.map((row) => [row.task_id, {
14487
+ column: row.column,
14488
+ sha: row.commit_sha,
14489
+ at: row.submitted_at,
14490
+ basis: row.basis ?? "tested",
14491
+ from: row.source_sha,
14492
+ testedOrigin: row.origin_sha,
14493
+ reason: row.basis_reason,
14494
+ pending: row.pending_until !== null && row.voided_at === null,
14495
+ voided: row.voided_at !== null
14496
+ }]));
14497
+ }
14436
14498
  // ../core/src/app/status-services.ts
14437
14499
  /** The daemon row is degraded after this long without a completed board tick. */
14438
14500
  const DAEMON_STALL_MS = 2 * BOARD_TICK_MS;
@@ -14665,7 +14727,7 @@ function sourceInterval(config, source) {
14665
14727
  if (source.startsWith("github-issues:")) return config.adapters.githubIssues.intervalMs;
14666
14728
  return config.adapters.github.intervalMs;
14667
14729
  }
14668
- // ../core/src/app/status.ts
14730
+ /** Session facts rendered in status detail. */
14669
14731
  function sessionView(fact) {
14670
14732
  return {
14671
14733
  ...fact,
@@ -14675,6 +14737,7 @@ function sessionView(fact) {
14675
14737
  }))
14676
14738
  };
14677
14739
  }
14740
+ // ../core/src/app/status.ts
14678
14741
  /** Counts of each value, rendered as `<n> <value>` in the given order. */
14679
14742
  function counts(values, order) {
14680
14743
  return order.map((value) => [value, values.filter((entry) => entry === value).length]).filter(([, n]) => n > 0).map(([value, n]) => `${String(n)} ${value}`).join(", ");
@@ -14746,6 +14809,7 @@ async function getStatus(deps, options = {}) {
14746
14809
  const entries = await readStatusColumnEntries(store.db, projectIds);
14747
14810
  const columnEntries = new Map(entries.map((entry) => [entry.task_id, entry.at]));
14748
14811
  const tasks = [];
14812
+ const submissions = await latestSubmissions(store.db, rows);
14749
14813
  for (const task of rows) {
14750
14814
  if (!projectIds.has(task.project)) continue;
14751
14815
  const ticket = await store.db.selectFrom("ticket_snapshot").selectAll().where("task_id", "=", task.id).executeTakeFirst();
@@ -14796,6 +14860,7 @@ async function getStatus(deps, options = {}) {
14796
14860
  const returned = returns.get(task.id);
14797
14861
  tasks.push({
14798
14862
  key: task.key,
14863
+ submission: submissions.get(task.id) ?? null,
14799
14864
  project: task.project,
14800
14865
  column: task.column,
14801
14866
  columnEnteredAt: columnEntries.get(task.id) ?? task.created_at,
@@ -17413,8 +17478,7 @@ const SUMMARIES = {
17413
17478
  link_removed: (p) => linkSummary("Link removed", p),
17414
17479
  task_submitted: (p) => {
17415
17480
  if (p.supersededByMerge !== void 0) return `Submit of ${p.sha.slice(0, 7)} superseded: PR merged at ${p.supersededByMerge.slice(0, 7)}`;
17416
- if (p.pending === true) return "Turn submitted, pending confirmation";
17417
- return p.confirmedByPoll === true ? "Turn submitted on the head of the last poll" : null;
17481
+ return `Turn submitted${p.pending === true ? ", pending confirmation" : p.confirmedByPoll === true ? " on the head of the last poll" : ""}: ${p.sha}, basis ${p.basis ?? "tested"}${optional(", from ", p.from)}${optional(", tested origin ", p.testedOrigin)}${optional(" — ", p.reason)}`;
17418
17482
  }
17419
17483
  };
17420
17484
  function linkSummary(verb, p) {
@@ -17659,6 +17723,7 @@ function createTaskQueries(deps) {
17659
17723
  const subject = taskSubject(task);
17660
17724
  return {
17661
17725
  sessions: await taskSessions(trx, task.id),
17726
+ submission: (await latestSubmissions(trx, [task])).get(task.id) ?? null,
17662
17727
  task: taskView(task),
17663
17728
  ...await taskTurns(trx, task, input.detail === true),
17664
17729
  links: links.map(({ state, ...link }) => {
@@ -17769,8 +17834,6 @@ function createTaskQueries(deps) {
17769
17834
  };
17770
17835
  }
17771
17836
  // ../core/src/app/turn-commands.ts
17772
- /** How long `task.submit` waits for its on-demand PR poll; the CLI gives up at 30 s. */
17773
- const SUBMIT_POLL_TIMEOUT_MS = 1e4;
17774
17837
  /** Columns a task returns to Dev from: right of Dev, before the terminal Done. */
17775
17838
  const RETURNABLE = [
17776
17839
  "review",
@@ -17924,23 +17987,6 @@ function confirmHead(input) {
17924
17987
  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.`);
17925
17988
  return "live";
17926
17989
  }
17927
- /** Polls the task's PR on demand for a submit; `skipped` when the task has none. */
17928
- async function pollTaskPr(db, task, poll) {
17929
- const pr = await taskPr(db, task.id);
17930
- if (pr === null) return { kind: "skipped" };
17931
- const repo = pr.repo.toLowerCase();
17932
- const result = poll === void 0 ? null : await poll(prSourceId(task.project, repo), {
17933
- kind: "pr",
17934
- repo: pr.repo,
17935
- number: pr.number
17936
- }, { timeoutMs: SUBMIT_POLL_TIMEOUT_MS });
17937
- return {
17938
- kind: "polled",
17939
- repo,
17940
- number: pr.number,
17941
- result
17942
- };
17943
- }
17944
17990
  /**
17945
17991
  * Records the submit of `sha` for the task's `column` visit `epoch` and says how its head was
17946
17992
  * confirmed (`confirmHead`). Throws `head_mismatch` or `github_unavailable` otherwise. With
@@ -17949,6 +17995,7 @@ async function pollTaskPr(db, task, poll) {
17949
17995
  */
17950
17996
  async function insertSubmission(trx, input, ctx, completeSince, pendingMs) {
17951
17997
  const { task, column, epoch, sha } = input;
17998
+ const provenance = await submissionBasis(trx, task.id, input);
17952
17999
  const pr = await taskPr(trx, task.id);
17953
18000
  if (pr === null && pendingMs === void 0) 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.");
17954
18001
  let confirmed = "pending";
@@ -17971,11 +18018,15 @@ async function insertSubmission(trx, input, ctx, completeSince, pendingMs) {
17971
18018
  author: ctx.actor,
17972
18019
  submitted_at: ctx.at,
17973
18020
  note: null,
18021
+ ...provenance.values,
17974
18022
  pr_repo: pr?.repo ?? null,
17975
18023
  pr_number: pr?.number ?? null,
17976
18024
  pending_until: confirmed === "pending" && pendingMs !== void 0 ? new Date(Date.parse(ctx.at) + pendingMs).toISOString() : null
17977
18025
  }).execute();
17978
- return confirmed;
18026
+ return {
18027
+ confirmed,
18028
+ event: provenance.event
18029
+ };
17979
18030
  }
17980
18031
  /** The `task_submitted` payload mark of a head confirmed by the board's last poll, or pending. */
17981
18032
  const CONFIRMATION = {
@@ -18005,15 +18056,16 @@ function createTurnMutations(deps) {
18005
18056
  if (task.membership === "archived") throw new CommandError("task_archived", "Add the task again before changing it.");
18006
18057
  const column = shadowColumn(task);
18007
18058
  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.`);
18008
- const confirmed = await insertSubmission(trx, {
18059
+ const { confirmed, event } = await insertSubmission(trx, {
18060
+ ...input,
18009
18061
  task,
18010
18062
  column,
18011
- epoch: task.column_epoch,
18012
- sha: input.sha
18063
+ epoch: task.column_epoch
18013
18064
  }, ctx, completeSince);
18014
18065
  await emit(trx, "task_submitted", task.project, task.id, ctx.at, {
18015
18066
  column,
18016
18067
  sha: input.sha,
18068
+ ...event,
18017
18069
  ...CONFIRMATION[confirmed]
18018
18070
  }, ctx.actor);
18019
18071
  return {
@@ -18042,11 +18094,11 @@ function createTurnMutations(deps) {
18042
18094
  async run(trx, input, ctx) {
18043
18095
  if (!isTurnId(input.turn)) return submitShadow(trx, input, ctx);
18044
18096
  const { turn, task } = await takenTurn(trx, input.turn, ctx);
18045
- const confirmed = await insertSubmission(trx, {
18097
+ const { confirmed, event } = await insertSubmission(trx, {
18098
+ ...input,
18046
18099
  task,
18047
18100
  column: turn.column,
18048
- epoch: turn.epoch,
18049
- sha: input.sha
18101
+ epoch: turn.epoch
18050
18102
  }, ctx, completeSince, config.projects.find((entry) => entry.id === task.project)?.dispatcher.submitConfirmMs);
18051
18103
  await closeTurns(trx, {
18052
18104
  taskId: task.id,
@@ -18057,6 +18109,7 @@ function createTurnMutations(deps) {
18057
18109
  turn: input.turn,
18058
18110
  column: turn.column,
18059
18111
  sha: input.sha,
18112
+ ...event,
18060
18113
  ...CONFIRMATION[confirmed]
18061
18114
  }, ctx.actor);
18062
18115
  return {
@@ -19401,6 +19454,11 @@ function quote(text) {
19401
19454
  }]
19402
19455
  };
19403
19456
  }
19457
+ function submissionLines(submission) {
19458
+ if (submission === void 0) return [];
19459
+ if (submission === null) return [line("No submissions yet.")];
19460
+ return [line(`Latest submission: ${submission.column}, ${submission.at}, ${submission.sha}, basis ${submission.basis}${submission.from === null ? "" : `, from ${submission.from}`}${submission.testedOrigin === null ? "" : `, tested origin ${submission.testedOrigin}`}, pending ${String(submission.pending)}, voided ${String(submission.voided)}.`), ...submission.reason === null ? [] : [quote(submission.reason)]];
19461
+ }
19404
19462
  /** The open turn: who executes it, when it opened and whether it was acked. */
19405
19463
  function turnLine(turn) {
19406
19464
  if (turn === null) return line("No open turn.");
@@ -19468,13 +19526,14 @@ function commandReply(id, value, input) {
19468
19526
  const request = operation.input.parse(input);
19469
19527
  if (request.why === true && result.why !== void 0) return {
19470
19528
  cliHint: `board ${operation.cli.command} ${request.task} --why`,
19471
- body: whyLines(result.task.key, result.why, result.blocks)
19529
+ body: [...whyLines(result.task.key, result.why, result.blocks), ...submissionLines(result.submission)]
19472
19530
  };
19473
19531
  return {
19474
19532
  cliHint: `board ${operation.cli.command} ${request.task}`,
19475
19533
  body: [
19476
19534
  line(`Task ${result.task.key}: ${result.task.column} (${result.task.membership})`),
19477
19535
  turnLine(result.turn),
19536
+ ...submissionLines(result.submission),
19478
19537
  ...result.links.flatMap((link) => link.kind === "pr" ? [line(`Pull request ${link.ref}: ${link.state ?? "not observed yet"}`)] : []),
19479
19538
  ...result.blocks.flatMap((block) => [line(`Block ${block.id} (${block.state}, ${block.type}):`), quote(block.reason)]),
19480
19539
  ...result.comments.flatMap((comment) => [line(`Comment ${comment.id} by ${comment.author}:`), quote(comment.text)])
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { p as OPERATIONS, rt as ERRORS, v as renderMcpError } from "./chunk-CoXzv4dC.mjs";
2
- import { o as CliError, r as requestOperation } from "./chunk-Qzs7Xloy.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-BXfL5iBi.mjs";
1
+ import { p as OPERATIONS, rt as ERRORS, v as renderMcpError } from "./chunk-BLyH3LBD.mjs";
2
+ import { o as CliError, r as requestOperation } from "./chunk-DsnvKf_Q.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-CBEgOEgI.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
@@ -0,0 +1,4 @@
1
+ ALTER TABLE submission ADD COLUMN basis TEXT;
2
+ ALTER TABLE submission ADD COLUMN source_sha TEXT;
3
+ ALTER TABLE submission ADD COLUMN basis_reason TEXT;
4
+ ALTER TABLE submission ADD COLUMN tested_source_id INTEGER REFERENCES submission(id);