spur-board 0.120.0 → 0.121.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.
@@ -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-CkCVuwFY.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-w6KrYs3j.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { request } from "node:http";
@@ -1,5 +1,5 @@
1
- import { _t as configSchema, d as buildCatalogSnapshot, p as OPERATIONS, yt as plainHttpAllowed } from "./chunk-CkCVuwFY.mjs";
2
- import { o as CliError, t as fetchCatalogVersion } from "./chunk-DLPQMmSY.mjs";
1
+ import { _t as configSchema, d as buildCatalogSnapshot, p as OPERATIONS, yt as plainHttpAllowed } from "./chunk-w6KrYs3j.mjs";
2
+ import { o as CliError, t as fetchCatalogVersion } from "./chunk-DS95rV33.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";
@@ -108,6 +108,17 @@ function isTodoGroupColumn(column) {
108
108
  }
109
109
  /** Columns every project board has, enabled. */
110
110
  const REQUIRED_COLUMN_IDS = COLUMNS.filter((column) => column.required).map((column) => column.id);
111
+ /**
112
+ * The columns `projects[].checksGate` may name: running or missing checks hold a task only at the
113
+ * exit of that column. Each is left of qa and ready-to-merge, so a task never reaches them without
114
+ * green checks.
115
+ */
116
+ const CHECKS_GATE_COLUMNS = [
117
+ "dev",
118
+ "review",
119
+ "product-review",
120
+ "external-review"
121
+ ];
111
122
  /** Where a column's effective orchestrator comes from: its own column entry or top-level `spurProjects`. */
112
123
  const COLUMN_BINDING_SOURCES = ["project", "board-wide"];
113
124
  /**
@@ -202,6 +213,7 @@ const GATE_CONDITIONS = [
202
213
  "pr_open",
203
214
  "not_draft",
204
215
  "checks_green",
216
+ "checks_not_red",
205
217
  "no_conflict",
206
218
  "external_comments_handled",
207
219
  "comment_history_read",
@@ -492,6 +504,7 @@ const projectSchema = z.strictObject({
492
504
  tracker: z.discriminatedUnion("type", [jiraTracker, githubIssuesTracker]),
493
505
  repos: z.array(repoSlugSchema.describe("A repository as owner/name.")).min(1).describe("GitHub repositories as owner/name whose PRs the board polls for this project, one source each. A done task is archived only after every listed repository has a complete poll since its last change."),
494
506
  reposWithoutCi: z.array(repoSlugSchema.describe("A repository from repos as owner/name, in any letter case.")).default([]).describe("Repos from repos that run no CI checks, in any letter case. In a listed repo, a PR whose check list on head is empty passes the Dev gate check condition instead of waiting in Dev. A list of only skipped checks still waits, and red or pending checks still count. A listed repo whose branch protection requires checks that have not reported yet also passes, so list only repos that run no checks. Without this key, a PR with no checks waits in Dev."),
507
+ checksGate: z.enum(CHECKS_GATE_COLUMNS, { error: (issue) => typeof issue.input === "string" ? `checksGate ${JSON.stringify(issue.input)} is not allowed: use one of ${CHECKS_GATE_COLUMNS.join(", ")}` : `checksGate must be one of ${CHECKS_GATE_COLUMNS.join(", ")}` }).default("dev").describe("The column whose exit requires green checks on the PR head: dev (the default), review, product-review or external-review, and the column must be enabled. Running checks, or no checks yet, hold a task only at the exit of this column. Red checks return the task to Dev from any column; a task whose turn is taken returns right after that turn's submit. A task enters ready-to-merge only with green checks. With dev, a cancelled check is red at once. With another column, a cancelled check counts as running until two complete GitHub polls after the one that saw it, about two GitHub poll intervals, and then counts as red; a new run in that window replaces it, and a source whose polls stay incomplete keeps it running. The daemon reads the key at start, so a change takes effect after a restart."),
495
508
  link: z.strictObject({
496
509
  sources: z.array(z.enum(LINK_SOURCES).describe("One place a PR can name its task: closing, branch or title.")).min(1).superRefine((sources, ctx) => {
497
510
  sources.forEach((source, i) => {
@@ -540,6 +553,11 @@ const projectSchema = z.strictObject({
540
553
  message: `Repository ${JSON.stringify(repo)} is not in repos`
541
554
  });
542
555
  });
556
+ if (!project.columns.some((column) => column.id === project.checksGate && column.enabled)) ctx.addIssue({
557
+ code: "custom",
558
+ path: ["checksGate"],
559
+ message: `checksGate ${JSON.stringify(project.checksGate)} names a column that is absent or disabled: use one of ${CHECKS_GATE_COLUMNS.join(", ")} whose column is enabled`
560
+ });
543
561
  const spurNames = new Set(project.spurProjects.filter((p) => p.role === "orchestrator" || p.role === "curator").map((p) => p.name));
544
562
  project.columns.forEach(({ orchestrator }, j) => {
545
563
  if (orchestrator === "none" || orchestrator === "operator" || spurNames.has(orchestrator)) return;
@@ -2819,10 +2837,10 @@ const taskWhySchema = z.strictObject({
2819
2837
  turn: turnViewSchema.nullable().describe("The open turn of the task; null when none is open."),
2820
2838
  moves: z.array(moveViewSchema).describe("The last 5 column moves, oldest first."),
2821
2839
  waiting: z.array(z.strictObject({
2822
- reason: z.enum(GATE_REASONS).describe("The gate reason that waits on the fact."),
2840
+ reason: z.enum(GATE_REASONS).describe("The gate reason that waits on the fact; checks_red only when the project checksGate is not dev."),
2823
2841
  head: commitShaSchema.describe("Head commit of the pull request the fact is about."),
2824
- text: z.string().describe("The fact in one line, e.g. waiting for CI on <sha>.")
2825
- }).describe("One fact the task waits for.")).min(1).optional().describe("Facts the task waits for that GitHub has not settled yet; absent when none.")
2842
+ text: z.string().describe("The fact in one line, e.g. waiting for CI on <sha>. When the project checksGate is not dev, checks_pending reads checks running, exit from <checksGate> waits for green, and checks_red reads checks red.")
2843
+ }).describe("One fact the task waits for.")).min(1).optional().describe("Facts the task waits for that GitHub has not settled yet, plus red checks the task returns to Dev on when the project checksGate is not dev; absent when none.")
2826
2844
  }).describe("Why the task is in its column and what the dispatcher waits for.");
2827
2845
  const itemViewSchema = z.strictObject({
2828
2846
  id: itemIdSchema,
@@ -2999,7 +3017,8 @@ const configViewSchema = z.strictObject({
2999
3017
  role: configSchema.shape.projects.element.shape.spurProjects.unwrap().element.shape.role,
3000
3018
  displayName: z.string().min(1).describe("Configured display name, falling back to project name.")
3001
3019
  })).describe("Effective Spur project bindings."),
3002
- ticketBrowseBase: z.url({ protocol: /^https?$/ }).nullable().describe("Ticket page prefix; append a task key such as PROJ-12. <baseUrl>/browse/ for a Jira project; null when the tracker has none, as for GitHub Issues.")
3020
+ ticketBrowseBase: z.url({ protocol: /^https?$/ }).nullable().describe("Ticket page prefix; append a task key such as PROJ-12. <baseUrl>/browse/ for a Jira project; null when the tracker has none, as for GitHub Issues."),
3021
+ checksGate: z.enum(CHECKS_GATE_COLUMNS).describe("The column whose exit waits for green checks, as the running daemon read it at start; dev when not configured.")
3003
3022
  })).describe("Effective projects visible to this caller."),
3004
3023
  web: z.strictObject({
3005
3024
  publicOrigin: z.url({ protocol: /^https?$/ }).nullable().describe("Origin the board web listener answers on; null when the listener is off or not bound yet."),
@@ -5016,7 +5035,8 @@ const OPERATIONS = [
5016
5035
  role: "worker",
5017
5036
  displayName: "web-worker"
5018
5037
  }],
5019
- ticketBrowseBase: "https://jira.example.com/browse/"
5038
+ ticketBrowseBase: "https://jira.example.com/browse/",
5039
+ checksGate: "dev"
5020
5040
  }],
5021
5041
  web: {
5022
5042
  publicOrigin: "http://127.0.0.1:4778",
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { D as sortSkillFiles, Dt as SLACK_BOT_SCOPES, Q as actorIdSchema, T as skillReloadFileSchema, _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-CkCVuwFY.mjs";
1
+ import { D as sortSkillFiles, Dt as SLACK_BOT_SCOPES, Q as actorIdSchema, T as skillReloadFileSchema, _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-w6KrYs3j.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-DLPQMmSY.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-zj6P829U.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-DS95rV33.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-DywuekMO.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";
@@ -921,6 +921,10 @@ async function runDoctor(options = {}) {
921
921
  const range = config.stand.portRange ?? DEFAULT_STAND_PORT_RANGE;
922
922
  const overlaps = [["http.port", config.http.port], ["web.port", config.web.port]].filter(([, port]) => port !== void 0 && port >= range.min && port <= range.max).map(([field, port]) => `${field} ${String(port)}`);
923
923
  checks.push(overlaps.length === 0 ? result("stand.port_range", true, "") : warning("stand.port_range", `Implicit stand port range ${String(range.min)}..${String(range.max)} overlaps ${overlaps.join(", ")}. Set a nonoverlapping stand.portRange. The stand refuses the overlapping ports.`));
924
+ checks.push({
925
+ ...result("projects.checksGate", true, ""),
926
+ present: config.projects.map((project) => `${project.id}=${project.checksGate}`)
927
+ });
924
928
  if (options.offline) return checks;
925
929
  const unitPath = unitFile(env, home);
926
930
  let unit = null;
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-DLPQMmSY.mjs";
1
+ export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-DS95rV33.mjs";
package/dist/daemon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as encodeActorId, A as eventPayloadSchemas, At as isTodoGroupColumn, B as REVIEW_STATES, C as messageRefSchema, Ct as COLUMN_GROUPS, D as sortSkillFiles, Dt as SLACK_BOT_SCOPES, E as skillReloadFilesSchema, Et as ITEM_KINDS, 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, Ot as TASK_HOLDS, P as entityRefSchema, Q as actorIdSchema, R as trackerSourceId, S as interactionRefSchema, St as COLUMNS, Tt as DISPATCHER_MODES, 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, kt as VIAS, 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 COLUMN_IDS, x as inboundEventSchema, xt as resolveWebOrigin, y as SPACE_IDS, yt as plainHttpAllowed, z as PR_STATES } from "./chunk-CkCVuwFY.mjs";
1
+ import { $ as encodeActorId, A as eventPayloadSchemas, At as isTodoGroupColumn, B as REVIEW_STATES, C as messageRefSchema, Ct as COLUMN_GROUPS, D as sortSkillFiles, Dt as SLACK_BOT_SCOPES, E as skillReloadFilesSchema, Et as ITEM_KINDS, 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, Ot as TASK_HOLDS, P as entityRefSchema, Q as actorIdSchema, R as trackerSourceId, S as interactionRefSchema, St as COLUMNS, Tt as DISPATCHER_MODES, 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, kt as VIAS, 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 COLUMN_IDS, x as inboundEventSchema, xt as resolveWebOrigin, y as SPACE_IDS, yt as plainHttpAllowed, z as PR_STATES } from "./chunk-w6KrYs3j.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";
@@ -15139,9 +15139,10 @@ function threadsGated(project) {
15139
15139
  }
15140
15140
  /**
15141
15141
  * Dev's failing reasons. `threads` adds the resolved-threads condition: it holds for the gate of
15142
- * every column at or right of the leftmost column requiring resolved threads.
15142
+ * every column at or right of the leftmost column requiring resolved threads. Red checks fail Dev
15143
+ * whatever `checksGate` is; pending checks hold Dev only when `checksGate` is Dev.
15143
15144
  */
15144
- function devReasons(facts, columns, waived, threads) {
15145
+ function devReasons(facts, project, waived, threads) {
15145
15146
  const { pr } = facts;
15146
15147
  if (pr === null) return ["no_pr"];
15147
15148
  if (pr.state === "closed") return ["pr_closed"];
@@ -15149,27 +15150,42 @@ function devReasons(facts, columns, waived, threads) {
15149
15150
  if (pr.draft) reasons.push("pr_draft");
15150
15151
  const verdict = checksVerdict(pr, waived);
15151
15152
  if (verdict === "red") reasons.push("checks_red");
15152
- if (verdict === "pending") reasons.push("checks_pending");
15153
+ if (verdict === "pending" && project.checksGate === "dev") reasons.push("checks_pending");
15153
15154
  if (pr.mergeable === "conflicting") reasons.push("conflict");
15154
15155
  if (pr.mergeable === "unknown") reasons.push("mergeable_unknown");
15155
15156
  if (facts.unhandledExternalComments > 0) reasons.push("external_comments");
15156
15157
  if (facts.commentHistory === "incomplete") reasons.push("comment_history_incomplete");
15157
15158
  if (threads && facts.unresolvedThreads > 0) reasons.push("unresolved_threads");
15158
- if (!executorDone("dev", facts, columns)) reasons.push("no_submit_on_head");
15159
+ if (!executorDone("dev", facts, project.columns)) reasons.push("no_submit_on_head");
15159
15160
  return reasons;
15160
15161
  }
15161
15162
  /**
15163
+ * The check reasons of a `checksGate` column right of Dev: red or pending checks on the open PR's
15164
+ * head. Dev already fails on red, so in a cumulative gate only pending reaches this column.
15165
+ */
15166
+ function gateCheckReasons(facts, waived) {
15167
+ const { pr } = facts;
15168
+ if (pr === null || pr.state !== "open") return [];
15169
+ const verdict = checksVerdict(pr, waived);
15170
+ return verdict === "red" ? ["checks_red"] : verdict === "pending" ? ["checks_pending"] : [];
15171
+ }
15172
+ /**
15162
15173
  * The failing reasons of one column's exit condition. Only Dev's resolved-threads condition depends
15163
15174
  * on the column asked: `threads` says whether it counts. A `gate_broken` move re-evaluates at Dev,
15164
15175
  * where that condition may not count, so a reason or hand-over that must survive it keys on the
15165
15176
  * facts and `threadsGated(project)` (`withThreads`, `turnThreads`), and `explainGates` takes
15166
15177
  * `blockedIn` from `evaluateGate`.
15167
15178
  */
15168
- function columnCondition(column, facts, columns, waived, threads) {
15179
+ function columnCondition(column, facts, project, waived, threads) {
15180
+ if (column === "dev") return devReasons(facts, project, waived, threads);
15181
+ const own = ownCondition(column, facts, project.columns);
15182
+ return column === project.checksGate ? [...gateCheckReasons(facts, waived), ...own] : own;
15183
+ }
15184
+ /** The failing reasons of a column's exit condition other than Dev, without checks. */
15185
+ function ownCondition(column, facts, columns) {
15169
15186
  if (isTodoGroupColumn(column)) return [];
15170
15187
  switch (column) {
15171
15188
  case "done": return [];
15172
- case "dev": return devReasons(facts, columns, waived, threads);
15173
15189
  case "review":
15174
15190
  case "product-review": return executorDone(column, facts, columns) ? [] : ["no_review_on_head"];
15175
15191
  case "external-review": return facts.externalReviewApproved ? [] : ["not_approved"];
@@ -15195,7 +15211,7 @@ function evaluateGate(column, facts, project) {
15195
15211
  for (const id of COLUMN_IDS.slice(0, COLUMN_IDS.indexOf(column) + 1)) {
15196
15212
  if (project.columns.find((c) => c.id === id)?.enabled !== true) continue;
15197
15213
  if (id === "dev" && waived) marker = { checksWaivedBy: "reposWithoutCi" };
15198
- const [first, ...rest] = columnCondition(id, facts, project.columns, waived, threads);
15214
+ const [first, ...rest] = columnCondition(id, facts, project, waived, threads);
15199
15215
  if (first !== void 0) return {
15200
15216
  ok: false,
15201
15217
  column: id,
@@ -15210,7 +15226,7 @@ function evaluateGate(column, facts, project) {
15210
15226
  }
15211
15227
  /**
15212
15228
  * The exit conditions of each column outside the Todo group, which has none, in the order the
15213
- * gates report their reasons.
15229
+ * gates report their reasons, with checks green at Dev.
15214
15230
  */
15215
15231
  const COLUMN_CONDITIONS = {
15216
15232
  dev: [
@@ -15230,7 +15246,25 @@ const COLUMN_CONDITIONS = {
15230
15246
  "ready-to-merge": ["merged"],
15231
15247
  done: []
15232
15248
  };
15233
- /** The condition each gate reason fails. */
15249
+ /**
15250
+ * The exit conditions of `column` under `checksGate`: with a gate right of Dev, Dev requires
15251
+ * checks not red, and the gate column requires checks green before its own conditions.
15252
+ */
15253
+ function columnConditions(column, checksGate) {
15254
+ if (checksGate === "dev") return COLUMN_CONDITIONS[column];
15255
+ if (column === "dev") return COLUMN_CONDITIONS.dev.map((condition) => condition === "checks_green" ? "checks_not_red" : condition);
15256
+ if (column === checksGate) return ["checks_green", ...COLUMN_CONDITIONS[column]];
15257
+ return COLUMN_CONDITIONS[column];
15258
+ }
15259
+ /**
15260
+ * The condition a gate reason fails in `column`: with a gate right of Dev, red checks fail Dev's
15261
+ * checks not red, and every other check reason fails checks green.
15262
+ */
15263
+ function conditionOf(reason, column, checksGate) {
15264
+ if (reason === "checks_red" && column === "dev" && checksGate !== "dev") return "checks_not_red";
15265
+ return CONDITION_OF[reason];
15266
+ }
15267
+ /** The condition each gate reason fails, with checks green at Dev. */
15234
15268
  const CONDITION_OF = {
15235
15269
  no_pr: "pr_open",
15236
15270
  pr_closed: "pr_open",
@@ -15263,13 +15297,13 @@ function explainGates(facts, project) {
15263
15297
  return {
15264
15298
  gates: COLUMN_IDS.map((column) => {
15265
15299
  const enabled = project.columns.find((c) => c.id === column)?.enabled === true;
15266
- const reasons = merged ? [] : columnCondition(column, facts, project.columns, waived, threads);
15300
+ const reasons = merged ? [] : columnCondition(column, facts, project, waived, threads);
15267
15301
  if (enabled && !merged && column === "dev" && waived) checksWaivedBy = "reposWithoutCi";
15268
15302
  const gate = evaluateGate(column, facts, project);
15269
15303
  const blockedIn = gate.ok ? null : gate.column;
15270
15304
  const stopped = reasons.some((reason) => STOPS_DEV.has(reason));
15271
- const conditions = (isTodoGroupColumn(column) ? [] : COLUMN_CONDITIONS[column]).map((condition) => {
15272
- const reason = reasons.find((r) => CONDITION_OF[r] === condition) ?? null;
15305
+ const conditions = (isTodoGroupColumn(column) ? [] : columnConditions(column, project.checksGate)).map((condition) => {
15306
+ const reason = reasons.find((r) => conditionOf(r, column, project.checksGate) === condition) ?? null;
15273
15307
  if (reason === null) return {
15274
15308
  condition,
15275
15309
  state: stopped ? "unchecked" : "met",
@@ -15470,11 +15504,13 @@ function dispatch(input) {
15470
15504
  if (column === "external-review" && executor === "none") return result(null);
15471
15505
  if (reasons.includes("pr_closed") && !handsBack) return result(null);
15472
15506
  switch (turn.visit) {
15473
- case "none": return result({
15474
- column,
15475
- reasons,
15476
- kind: "entry"
15477
- });
15507
+ case "none":
15508
+ if (column !== "dev" && reasons.every((reason) => HOLD_ONLY.has(reason))) return result(null);
15509
+ return result({
15510
+ column,
15511
+ reasons,
15512
+ kind: "entry"
15513
+ });
15478
15514
  case "unclosed": return result(turn.operatorUntaken && executor === "none" && workerLive ? {
15479
15515
  column,
15480
15516
  reasons,
@@ -15699,6 +15735,99 @@ async function shadowCourseCheck(trx, taskId, move, project) {
15699
15735
  const after = countCycles([...past, current], move.from, every).count;
15700
15736
  return after > before && after % every === 0;
15701
15737
  }
15738
+ // ../core/src/app/cancelled-checks.ts
15739
+ /** Complete scheduled polls after the sighting that confirm a cancel as red. */
15740
+ const CANCEL_CONFIRM_POLLS = 2;
15741
+ const cancelledChecksSchema = z.strictObject({
15742
+ headSha: prFactsSchema.shape.headSha,
15743
+ cancelled: z.array(z.strictObject({
15744
+ name: z.string().min(1),
15745
+ completedAt: z.string().nullable(),
15746
+ polls: z.int().min(0)
15747
+ }))
15748
+ });
15749
+ const cancelledChecksKey = (source, ref) => `checks-cancel:${source}:pr:${ref.repo.toLowerCase()}#${String(ref.number)}`;
15750
+ /** The stored counts on `headSha`; none when the row is absent, unreadable or for another head. */
15751
+ async function countsOnHead(trx, key, headSha) {
15752
+ const row = await trx.selectFrom("meta").select("value").where("key", "=", key).executeTakeFirst();
15753
+ if (row === void 0) return [];
15754
+ try {
15755
+ const saved = parseJson(cancelledChecksSchema, row.value);
15756
+ return saved.headSha.toLowerCase() === headSha.toLowerCase() ? saved.cancelled : [];
15757
+ } catch {
15758
+ return [];
15759
+ }
15760
+ }
15761
+ /** The cancelled checks on head, once each by name and completion time. */
15762
+ function cancelledOnHead(fact) {
15763
+ const seen = /* @__PURE__ */ new Set();
15764
+ return [...fact.requiredChecks, ...fact.checks].flatMap((check) => {
15765
+ if (check.state !== "cancelled") return [];
15766
+ const id = JSON.stringify([check.name, check.completedAt]);
15767
+ if (seen.has(id)) return [];
15768
+ seen.add(id);
15769
+ return [{
15770
+ name: check.name,
15771
+ completedAt: check.completedAt
15772
+ }];
15773
+ });
15774
+ }
15775
+ const sameRun = (left, right) => left.name === right.name && left.completedAt === right.completedAt;
15776
+ /**
15777
+ * Counts the polls since each cancelled check on the PR head was first seen: a new entry starts at
15778
+ * 0, a scheduled complete poll adds 1, and a head change starts over. It deletes the row of a PR
15779
+ * that is not open or has no cancelled check. Returns true when this poll confirms a cancel.
15780
+ */
15781
+ async function countCancelledChecks(trx, source, fact, scheduled) {
15782
+ const key = cancelledChecksKey(source, fact);
15783
+ const cancelled = fact.state === "open" ? cancelledOnHead(fact) : [];
15784
+ if (cancelled.length === 0) {
15785
+ await trx.deleteFrom("meta").where("key", "=", key).execute();
15786
+ return false;
15787
+ }
15788
+ const head = fact.headSha.toLowerCase();
15789
+ const previous = await countsOnHead(trx, key, head);
15790
+ let confirmed = false;
15791
+ const next = cancelled.map((check) => {
15792
+ const before = previous.find((entry) => sameRun(entry, check));
15793
+ if (before === void 0) return {
15794
+ ...check,
15795
+ polls: 0
15796
+ };
15797
+ if (!scheduled || before.polls >= CANCEL_CONFIRM_POLLS) return before;
15798
+ if (before.polls + 1 === CANCEL_CONFIRM_POLLS) confirmed = true;
15799
+ return {
15800
+ ...before,
15801
+ polls: before.polls + 1
15802
+ };
15803
+ });
15804
+ const value = toJson(cancelledChecksSchema, {
15805
+ headSha: head,
15806
+ cancelled: next
15807
+ });
15808
+ await trx.insertInto("meta").values({
15809
+ key,
15810
+ value
15811
+ }).onConflict((oc) => oc.column("key").doUpdateSet({ value })).execute();
15812
+ return confirmed;
15813
+ }
15814
+ /**
15815
+ * The PR with each cancelled check on head that is not confirmed yet read as pending: no stored
15816
+ * count for it on this head, or fewer than two complete polls since its sighting.
15817
+ */
15818
+ async function withUnconfirmedCancels(trx, source, pr) {
15819
+ if (cancelledOnHead(pr).length === 0) return pr;
15820
+ const counted = await countsOnHead(trx, cancelledChecksKey(source, pr), pr.headSha);
15821
+ const map = (checks) => checks.map((check) => check.state === "cancelled" && !counted.some((entry) => sameRun(entry, check) && entry.polls >= CANCEL_CONFIRM_POLLS) ? {
15822
+ ...check,
15823
+ state: "pending"
15824
+ } : check);
15825
+ return {
15826
+ ...pr,
15827
+ checks: map(pr.checks),
15828
+ requiredChecks: map(pr.requiredChecks)
15829
+ };
15830
+ }
15702
15831
  // ../core/src/domain/health.ts
15703
15832
  const ENDED_WORKER_KINDS = {
15704
15833
  complete: "worker_completed",
@@ -16997,10 +17126,11 @@ async function readInput(trx, task, project, mode, blind, config, clock) {
16997
17126
  column,
16998
17127
  project: {
16999
17128
  columns: project.columns,
17000
- reposWithoutCi: project.reposWithoutCi
17129
+ reposWithoutCi: project.reposWithoutCi,
17130
+ checksGate: project.checksGate
17001
17131
  },
17002
17132
  facts: {
17003
- pr,
17133
+ pr: pr !== null && pr.state === "open" && project.checksGate !== "dev" ? await withUnconfirmedCancels(trx, prSourceId(project.id, pr.repo), pr) : pr,
17004
17134
  externalReviewApproved: pr !== null && externalApproval(pr, project.operatorGithubLogin),
17005
17135
  commentHistory: pr?.feedbackComplete === true ? "complete" : "incomplete",
17006
17136
  unhandledExternalComments: unhandled.length,
@@ -17700,11 +17830,17 @@ function createTaskQueries(deps) {
17700
17830
  const { gates, checksWaivedBy } = explainGates(facts, read.input.project);
17701
17831
  const gate = evaluateGate(column, facts, read.input.project);
17702
17832
  const head = facts.pr?.headSha.toLowerCase();
17703
- const waiting = gate.ok || head === void 0 ? [] : gate.reasons.filter((reason) => HOLD_ONLY.has(reason)).map((reason) => ({
17833
+ const { checksGate } = project;
17834
+ const waitText = (reason, sha) => reason === "checks_pending" && checksGate !== "dev" ? `checks running, exit from ${checksGate} waits for green` : `${WAITING_FOR[reason]} on ${sha}`;
17835
+ const waiting = gate.ok || head === void 0 ? [] : gate.reasons.flatMap((reason) => HOLD_ONLY.has(reason) ? [{
17704
17836
  reason,
17705
17837
  head,
17706
- text: `${WAITING_FOR[reason]} on ${head}`
17707
- }));
17838
+ text: waitText(reason, head)
17839
+ }] : reason === "checks_red" && checksGate !== "dev" ? [{
17840
+ reason,
17841
+ head,
17842
+ text: "checks red"
17843
+ }] : []);
17708
17844
  const holds = [...dispatchHolds(read.input), ...read.ticketUnconfirmed ? ["ticket_unconfirmed"] : []].sort((left, right) => TASK_HOLDS.indexOf(left) - TASK_HOLDS.indexOf(right));
17709
17845
  const heldBy = holds.includes("cycle_limit") ? await holdBlocks(trx, task.id) : [];
17710
17846
  const pending = read.pending?.state === "pending" ? read.pending : void 0;
@@ -18337,7 +18473,8 @@ function createOperationRegistry(deps) {
18337
18473
  role: spur.role,
18338
18474
  displayName: spur.displayName ?? spur.name
18339
18475
  })),
18340
- ticketBrowseBase: ticketBrowseBase(project.tracker)
18476
+ ticketBrowseBase: ticketBrowseBase(project.tracker),
18477
+ checksGate: project.checksGate
18341
18478
  })),
18342
18479
  web: {
18343
18480
  publicOrigin: webOrigin() ?? null,
@@ -18740,7 +18877,11 @@ async function ticket(trx, config, fact, at, source) {
18740
18877
  function comparableFacts(facts, timestamp) {
18741
18878
  return JSON.stringify(Object.fromEntries(Object.entries(facts).filter(([key]) => key !== timestamp)));
18742
18879
  }
18743
- async function pr(trx, config, fact, at, source) {
18880
+ /**
18881
+ * Applies one PR fact. `scheduled` is a complete scheduled poll, the only kind that advances the
18882
+ * cancelled-check count. Returns true when this poll confirmed a cancelled check as red.
18883
+ */
18884
+ async function pr(trx, config, fact, at, source, scheduled) {
18744
18885
  await trx.deleteFrom("source_miss").where("source", "=", source).where("ref_key", "=", refKey({
18745
18886
  kind: "pr",
18746
18887
  repo: fact.repo,
@@ -18785,7 +18926,8 @@ async function pr(trx, config, fact, at, source) {
18785
18926
  at
18786
18927
  });
18787
18928
  const project = projectForSource(config, source);
18788
- if (project === void 0) return;
18929
+ if (project === void 0) return false;
18930
+ const confirmed = project.checksGate !== "dev" && await countCancelledChecks(trx, source, fact, scheduled);
18789
18931
  for (const key of fact.ticketKeys) {
18790
18932
  const task = await trx.selectFrom("task").selectAll().where("project", "=", project.id).where("key", "=", key).executeTakeFirst();
18791
18933
  if (task === void 0 || task.membership === "archived") continue;
@@ -18818,7 +18960,7 @@ async function pr(trx, config, fact, at, source) {
18818
18960
  else await trx.updateTable("link").set({ pr_open: 1 }).where("id", "=", link.id).execute();
18819
18961
  }
18820
18962
  await applyPendingReopen(trx, fact, at);
18821
- if (!changed) return;
18963
+ if (!changed) return confirmed;
18822
18964
  const links = await trx.selectFrom("link").select(["task_id"]).where("entity", "=", "pr").where(sql`lower(repo) = ${fact.repo.toLowerCase()}`).where("number", "=", fact.number).execute();
18823
18965
  for (const link of links) {
18824
18966
  const task = await trx.selectFrom("task").selectAll().where("id", "=", link.task_id).executeTakeFirstOrThrow();
@@ -18859,6 +19001,7 @@ async function pr(trx, config, fact, at, source) {
18859
19001
  await emit(trx, "pr_facts_changed", task.project, task.id, at, { facts: fact });
18860
19002
  await markTaskChanged(trx, task.id, at);
18861
19003
  }
19004
+ return confirmed;
18862
19005
  }
18863
19006
  function branchHasKey(branch, key) {
18864
19007
  const text = branch.toLowerCase();
@@ -19255,9 +19398,10 @@ function createObservationCore(deps) {
19255
19398
  const rank = (item) => item.kind === "ticket" ? 0 : item.kind === "pr" ? 1 : item.facts.links["board-worker"] === void 0 ? 3 : 2;
19256
19399
  return rank(left) - rank(right);
19257
19400
  });
19401
+ const confirmedCancels = [];
19258
19402
  for (const item of orderedItems) if (item.kind === "ticket") await ticket(trx, config, item.facts, batch.observedAt, source);
19259
19403
  else if (item.kind === "pr") {
19260
- await pr(trx, config, item.facts, batch.observedAt, source);
19404
+ if (await pr(trx, config, item.facts, batch.observedAt, source, observation.effectiveComplete)) confirmedCancels.push(item.facts);
19261
19405
  await holdContinuation(trx, source, item);
19262
19406
  } else await session(trx, config, item.facts, batch.observedAt, source, ambiguous, batch.sessionTransitions !== void 0);
19263
19407
  for (const edge of batch.sessionTransitions ?? []) await sessionTransition(trx, config, edge);
@@ -19332,6 +19476,12 @@ function createObservationCore(deps) {
19332
19476
  if (observation.effectiveComplete && !completeSince.has(source) || recovered) await dispatchSource(trx, source, dispatchContext);
19333
19477
  if (observation.effectiveComplete) await dispatchDoneTickets(trx, source, dispatchContext);
19334
19478
  await dispatchMergedTickets(trx, source, dispatchContext);
19479
+ const confirmedTasks = [];
19480
+ for (const fact of confirmedCancels) {
19481
+ const links = await trx.selectFrom("link").select("task_id").where("entity", "=", "pr").where(sql`lower(repo) = ${fact.repo.toLowerCase()}`).where("number", "=", fact.number).execute();
19482
+ confirmedTasks.push(...links.map((link) => link.task_id));
19483
+ }
19484
+ if (confirmedTasks.length > 0) await dispatchTasks(trx, confirmedTasks, dispatchContext);
19335
19485
  await dispatchJournaled(trx, dispatchContext);
19336
19486
  await reconcileItems(trx, config, now, currentComplete.has("spur"), warnSkipped, source === "spur" && observation.effectiveComplete && (!completeSince.has("spur") || spurGap) ? Date.parse(batch.observedAt) : void 0);
19337
19487
  if (deps.productVersion !== void 0) await enqueueLiveAfterFirstPoll(trx, {
@@ -20733,9 +20883,23 @@ async function loadFiles(root) {
20733
20883
  }
20734
20884
  return files;
20735
20885
  }
20886
+ function escapeHtml(value) {
20887
+ return value.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
20888
+ }
20889
+ /** Names the daemon version in the page right after its first `<head>` tag; no `<head>`, no change. */
20890
+ function stampVersion(index, version) {
20891
+ const html = index.toString("utf8");
20892
+ const head = /<head(?:\s[^>]*)?>/i.exec(html);
20893
+ if (head === null) return index;
20894
+ const end = head.index + head[0].length;
20895
+ return Buffer.from(`${html.slice(0, end)}<meta name="board-version" content="${escapeHtml(version)}">${html.slice(end)}`);
20896
+ }
20736
20897
  /** Independent browser transport; the caller owns listening and shutdown. */
20737
20898
  async function createWebServer(options) {
20738
20899
  const files = await loadFiles(options.webRoot);
20900
+ const { productVersion } = options;
20901
+ const index = files.get("/index.html");
20902
+ if (productVersion !== void 0 && index !== void 0) files.set("/index.html", stampVersion(index, productVersion));
20739
20903
  const app = Fastify({
20740
20904
  logger: false,
20741
20905
  genReqId: () => randomUUID(),
@@ -20780,6 +20944,7 @@ async function createWebServer(options) {
20780
20944
  reply.header("x-frame-options", "DENY");
20781
20945
  reply.header("x-content-type-options", "nosniff");
20782
20946
  reply.header("referrer-policy", "no-referrer");
20947
+ if (productVersion !== void 0) reply.header("x-board-version", productVersion);
20783
20948
  }
20784
20949
  const audited = /* @__PURE__ */ new WeakSet();
20785
20950
  function audit(request, reply) {
@@ -26633,7 +26798,8 @@ function createWebModule(ctx, options) {
26633
26798
  step
26634
26799
  }, "event stream read failed");
26635
26800
  },
26636
- ...options.instance === void 0 ? {} : { instance: options.instance }
26801
+ ...options.instance === void 0 ? {} : { instance: options.instance },
26802
+ ...options.productVersion === void 0 ? {} : { productVersion: options.productVersion }
26637
26803
  });
26638
26804
  if (aborted()) return;
26639
26805
  const address = await server.listen({
@@ -27036,6 +27202,7 @@ function createDaemonModules(ctxFor, ports = {}) {
27036
27202
  firstPollDone: () => firstPollDone(board.store.db, board.config, core.completeSince),
27037
27203
  ...ports.afterOperation === void 0 ? {} : { afterOperation: ports.afterOperation },
27038
27204
  ...ports.webRoot === void 0 ? {} : { webRoot: ports.webRoot },
27205
+ ...ports.productVersion === void 0 ? {} : { productVersion: ports.productVersion },
27039
27206
  onListening: (address) => {
27040
27207
  webPort = listenerPort(address);
27041
27208
  ports.onWebListening?.(address);
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { p as OPERATIONS, rt as ERRORS, v as renderMcpError } from "./chunk-CkCVuwFY.mjs";
2
- import { o as CliError, r as requestOperation } from "./chunk-DLPQMmSY.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-zj6P829U.mjs";
1
+ import { p as OPERATIONS, rt as ERRORS, v as renderMcpError } from "./chunk-w6KrYs3j.mjs";
2
+ import { o as CliError, r as requestOperation } from "./chunk-DS95rV33.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-DywuekMO.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";