spur-board 0.148.0 → 0.149.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, c as tokenRequestStatusSchema, dt as errorContextSchema, ft as errorEnvelopeSchema, lt as ERRORS, mt as successEnvelopeSchema, o as tokenRequestResultSchema } from "./chunk-B49czSp7.mjs";
1
+ import { _ as renderJsonError, c as tokenRequestStatusSchema, dt as errorContextSchema, ft as errorEnvelopeSchema, lt as ERRORS, mt as successEnvelopeSchema, o as tokenRequestResultSchema } from "./chunk-Cy6VBP_I.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 { Ot as plainHttpAllowed, Tt as configSchema, d as buildCatalogSnapshot, p as OPERATIONS } from "./chunk-B49czSp7.mjs";
2
- import { o as CliError, t as fetchCatalogVersion } from "./chunk-BqpntwKX.mjs";
1
+ import { Ot as plainHttpAllowed, Tt as configSchema, d as buildCatalogSnapshot, p as OPERATIONS } from "./chunk-Cy6VBP_I.mjs";
2
+ import { o as CliError, t as fetchCatalogVersion } from "./chunk-BhHKMsqI.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";
@@ -2407,12 +2407,18 @@ const prChange = {
2407
2407
  from,
2408
2408
  to: S
2409
2409
  };
2410
+ const checkRuns = z.array(prFactsSchema.shape.checks.element.pick({
2411
+ name: true,
2412
+ completedAt: true
2413
+ })).optional();
2410
2414
  const eventPayloadSchemas = {
2411
2415
  head_moved: z.looseObject(prChange),
2412
2416
  pr_facts_changed: z.looseObject({ facts: prFactsSchema }),
2413
2417
  checks_changed: z.looseObject({
2414
2418
  ...prChange,
2415
- sha: S
2419
+ sha: S,
2420
+ waiting: checkRuns,
2421
+ confirmed: checkRuns
2416
2422
  }),
2417
2423
  review_submitted: z.looseObject({
2418
2424
  repo: S,
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { At as requiredSecretKeys, D as sortSkillFiles, Lt as SLACK_BOT_SCOPES, T as skillReloadFileSchema, Tt as configSchema, a as requestHashOf, f as roleCanUseOperation, it as actorIdSchema, jt as resolveWebOrigin, lt as ERRORS, mt as successEnvelopeSchema, p as OPERATIONS, r as remoteDoctorReportSchema, u as SYSTEMD_SERVICE_SETTINGS, yt as DEFAULT_STAND_PORT_RANGE } from "./chunk-B49czSp7.mjs";
1
+ import { At as requiredSecretKeys, D as sortSkillFiles, Lt as SLACK_BOT_SCOPES, T as skillReloadFileSchema, Tt as configSchema, a as requestHashOf, f as roleCanUseOperation, it as actorIdSchema, jt as resolveWebOrigin, lt as ERRORS, mt as successEnvelopeSchema, p as OPERATIONS, r as remoteDoctorReportSchema, u as SYSTEMD_SERVICE_SETTINGS, yt as DEFAULT_STAND_PORT_RANGE } from "./chunk-Cy6VBP_I.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-BqpntwKX.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-CwyzJDIl.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-BhHKMsqI.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-C-Jr3pwy.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-BqpntwKX.mjs";
1
+ export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-BhHKMsqI.mjs";
package/dist/daemon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as ringMarker, A as eventPayloadSchemas, At as requiredSecretKeys, B as sourceCursorSchema, Bt as VIAS, C as messageRefSchema, Ct as columnTurnTimings, D as sortSkillFiles, Dt as externalQuietAfterMs, E as skillReloadFilesSchema, Et as defaultAddressee, F as defaultBranchFactSchema, Ft as DISPATCHER_MODES, G as SESSION_HEALTH_STATES, H as PR_STATES, I as entityRefSchema, It as ITEM_KINDS, J as parseRingMarker, K as SESSION_STATUSES, L as mirrorSourceId, Lt as SLACK_BOT_SCOPES, M as MIRROR_FAILURES, Mt as COLUMNS, N as MIRROR_FAILURE_CODES, Nt as COLUMN_GROUPS, O as EVENT_KINDS, Ot as plainHttpAllowed, P as batchSchema, Pt as COLUMN_IDS, Q as prReviewRuleSchema, R as prSourceId, Rt as TASK_HOLDS, S as interactionRefSchema, St as boardWideSpurProject, Tt as configSchema, U as REVIEW_DECISIONS, V as trackerSourceId, Vt as isTodoGroupColumn, W as REVIEW_STATES, X as prFactsSchema, Y as prApprovalPairSchema, Z as prRefSchema, a as requestHashOf, at as encodeActorId, b as conversationRefSchema, bt as RESERVED_PROJECT, c as tokenRequestStatusSchema, ct as parseRef$1, d as buildCatalogSnapshot, et as sessionFactsSchema, f as roleCanUseOperation, g as renderHttpProblem, gt as DEFAULT_LINK, h as turnHandedSchema, i as TOKEN_REQUEST_LIMITS, it as actorIdSchema, j as AdapterError, jt as resolveWebOrigin, k as GATE_REASONS, kt as readyMirrorOf, l as BOARD_TICK_MS, lt as ERRORS, m as defaultBranchViewSchema, mt as successEnvelopeSchema, n as doctorReportSchema, nt as JIRA_PROJECT_KEY, o as tokenRequestResultSchema, ot as errorCodeOf, p as OPERATIONS, pt as ok, q as isExternalAuthor, rt as REF_NUMBER, s as tokenRequestSchema, st as parseActorId, t as assertNever, tt as ticketFactsSchema, ut as err, vt as DEFAULT_SLACK_COMMAND, w as userIdSchema, wt as configBindings, x as inboundEventSchema, xt as approvalRuleOf, y as SPACE_IDS, z as sessionTransitionSchema, zt as TODO_GROUP_COLUMN_IDS } from "./chunk-B49czSp7.mjs";
1
+ import { $ as ringMarker, A as eventPayloadSchemas, At as requiredSecretKeys, B as sourceCursorSchema, Bt as VIAS, C as messageRefSchema, Ct as columnTurnTimings, D as sortSkillFiles, Dt as externalQuietAfterMs, E as skillReloadFilesSchema, Et as defaultAddressee, F as defaultBranchFactSchema, Ft as DISPATCHER_MODES, G as SESSION_HEALTH_STATES, H as PR_STATES, I as entityRefSchema, It as ITEM_KINDS, J as parseRingMarker, K as SESSION_STATUSES, L as mirrorSourceId, Lt as SLACK_BOT_SCOPES, M as MIRROR_FAILURES, Mt as COLUMNS, N as MIRROR_FAILURE_CODES, Nt as COLUMN_GROUPS, O as EVENT_KINDS, Ot as plainHttpAllowed, P as batchSchema, Pt as COLUMN_IDS, Q as prReviewRuleSchema, R as prSourceId, Rt as TASK_HOLDS, S as interactionRefSchema, St as boardWideSpurProject, Tt as configSchema, U as REVIEW_DECISIONS, V as trackerSourceId, Vt as isTodoGroupColumn, W as REVIEW_STATES, X as prFactsSchema, Y as prApprovalPairSchema, Z as prRefSchema, a as requestHashOf, at as encodeActorId, b as conversationRefSchema, bt as RESERVED_PROJECT, c as tokenRequestStatusSchema, ct as parseRef$1, d as buildCatalogSnapshot, et as sessionFactsSchema, f as roleCanUseOperation, g as renderHttpProblem, gt as DEFAULT_LINK, h as turnHandedSchema, i as TOKEN_REQUEST_LIMITS, it as actorIdSchema, j as AdapterError, jt as resolveWebOrigin, k as GATE_REASONS, kt as readyMirrorOf, l as BOARD_TICK_MS, lt as ERRORS, m as defaultBranchViewSchema, mt as successEnvelopeSchema, n as doctorReportSchema, nt as JIRA_PROJECT_KEY, o as tokenRequestResultSchema, ot as errorCodeOf, p as OPERATIONS, pt as ok, q as isExternalAuthor, rt as REF_NUMBER, s as tokenRequestSchema, st as parseActorId, t as assertNever, tt as ticketFactsSchema, ut as err, vt as DEFAULT_SLACK_COMMAND, w as userIdSchema, wt as configBindings, x as inboundEventSchema, xt as approvalRuleOf, y as SPACE_IDS, z as sessionTransitionSchema, zt as TODO_GROUP_COLUMN_IDS } from "./chunk-Cy6VBP_I.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";
@@ -11610,13 +11610,19 @@ function noCiWaives(pr, project) {
11610
11610
  return project.reposWithoutCi.some((listed) => listed.toLowerCase() === repo);
11611
11611
  }
11612
11612
  /**
11613
- * The verdict over the required checks on head, or, when none is required, over every check on
11614
- * head except skipped ones. No check gives pending, and red wins over pending. `waived` (from
11615
- * `noCiWaives`, so the head has no checks) gives green.
11613
+ * The checks the gate and History count: the required checks on head, or, when none is required,
11614
+ * every check on head except skipped ones.
11615
+ */
11616
+ function countedChecks(pr) {
11617
+ return pr.requiredChecks.length > 0 ? pr.requiredChecks : pr.checks.filter((check) => check.state !== "skipped");
11618
+ }
11619
+ /**
11620
+ * The verdict over the counted checks (`countedChecks`). No check gives pending, and red wins over
11621
+ * pending. `waived` (from `noCiWaives`, so the head has no checks) gives green.
11616
11622
  */
11617
11623
  function checksVerdict(pr, waived) {
11618
11624
  if (waived) return "green";
11619
- const verdicts = (pr.requiredChecks.length > 0 ? pr.requiredChecks : pr.checks.filter((check) => check.state !== "skipped")).map((check) => VERDICT[check.state]);
11625
+ const verdicts = countedChecks(pr).map((check) => VERDICT[check.state]);
11620
11626
  if (verdicts.includes("red")) return "red";
11621
11627
  if (verdicts.length === 0 || verdicts.includes("pending")) return "pending";
11622
11628
  return "green";
@@ -11632,14 +11638,21 @@ function executorDone(column, facts) {
11632
11638
  }
11633
11639
  /**
11634
11640
  * The leftmost enabled column that requires resolved threads: `requireResolvedThreads`, by default
11635
- * true on Ready to Merge only. Undefined when no enabled column requires them.
11641
+ * true on Ready to Merge only. Under `approvalRule: github-rules`, a review rule GitHub blocks on
11642
+ * unresolved threads (`facts.reviewRule`) also requires them from External Review on, whatever
11643
+ * `requireResolvedThreads` says. Undefined when no column requires them.
11636
11644
  */
11637
- function threadsFrom(project) {
11638
- return project.columns.find((c) => c.enabled && (c.requireResolvedThreads ?? c.id === "ready-to-merge"))?.id;
11645
+ function threadsFrom(project, facts) {
11646
+ const from = project.columns.find((c) => c.enabled && (c.requireResolvedThreads ?? c.id === "ready-to-merge"))?.id;
11647
+ if (facts?.reviewRule?.decision !== "unresolved_threads" || approvalRuleOf(project) !== "github-rules") return from;
11648
+ return from !== void 0 && COLUMN_IDS.indexOf(from) < COLUMN_IDS.indexOf("external-review") ? from : "external-review";
11639
11649
  }
11640
- /** Whether any enabled column of the project requires resolved review threads. */
11641
- function threadsGated(project) {
11642
- return threadsFrom(project) !== void 0;
11650
+ /**
11651
+ * Whether any column of the project requires resolved review threads, with `facts` as
11652
+ * `threadsFrom` reads them.
11653
+ */
11654
+ function threadsGated(project, facts) {
11655
+ return threadsFrom(project, facts) !== void 0;
11643
11656
  }
11644
11657
  /**
11645
11658
  * Dev's failing reasons. `threads` adds the resolved-threads condition: it holds for the gate of
@@ -11665,7 +11678,7 @@ function gateCheckReasons(facts, waived) {
11665
11678
  * The failing reasons of one column's exit condition. Only Dev's resolved-threads condition depends
11666
11679
  * on the column asked: `threads` says whether it counts. A `gate_broken` move re-evaluates at Dev,
11667
11680
  * where that condition may not count, so a reason or hand-over that must survive it keys on the
11668
- * facts and `threadsGated(project)` (`withThreads`, `turnThreads`), and `explainGates` takes
11681
+ * facts and `threadsGated(project, facts)` (`withThreads`, `turnThreads`), and `explainGates` takes
11669
11682
  * `blockedIn` from `evaluateGate`.
11670
11683
  */
11671
11684
  function columnCondition(column, facts, project, waived, threads) {
@@ -11758,14 +11771,15 @@ function describeConditions(column, project) {
11758
11771
  * Evaluates the exit conditions of every enabled column from To Do up to and including `column`,
11759
11772
  * and returns the leftmost one that fails. A column absent from the project's columns or disabled
11760
11773
  * passes through. A merged pull request passes every column. Dev's resolved-threads condition
11761
- * counts when `column` is at or right of the leftmost enabled column requiring resolved threads.
11774
+ * counts when `column` is at or right of the leftmost column requiring resolved threads
11775
+ * (`threadsFrom`).
11762
11776
  * Once Dev is evaluated with its check condition passed by `reposWithoutCi`, the result carries
11763
11777
  * `checksWaivedBy`.
11764
11778
  */
11765
11779
  function evaluateGate(column, facts, project) {
11766
11780
  if (facts.pr?.state === "merged") return { ok: true };
11767
11781
  const waived = noCiWaives(facts.pr, project);
11768
- const from = threadsFrom(project);
11782
+ const from = threadsFrom(project, facts);
11769
11783
  const threads = from !== void 0 && COLUMN_IDS.indexOf(from) <= COLUMN_IDS.indexOf(column);
11770
11784
  let marker = {};
11771
11785
  for (const id of COLUMN_IDS.slice(0, COLUMN_IDS.indexOf(column) + 1)) {
@@ -11855,14 +11869,15 @@ const CONDITION_OF = {
11855
11869
  const STOPS_DEV = /* @__PURE__ */ new Set(["no_pr", "pr_closed"]);
11856
11870
  /**
11857
11871
  * Every column's own exit conditions with their state, and where its cumulative gate blocks, as
11858
- * `evaluateGate` decides it for each column. Dev's own conditions count resolved threads once any
11859
- * enabled column requires them. A merged pull request passes every column and every condition.
11872
+ * `evaluateGate` decides it for each column. Dev's own conditions count resolved threads once a
11873
+ * column requires them (`threadsGated`). A merged pull request passes every column and every
11874
+ * condition.
11860
11875
  * `checksWaivedBy` is the marker `evaluateGate('done')` carries, or null.
11861
11876
  */
11862
11877
  function explainGates(facts, project) {
11863
11878
  const merged = facts.pr?.state === "merged";
11864
11879
  const waived = noCiWaives(facts.pr, project);
11865
- const threads = threadsGated(project);
11880
+ const threads = threadsGated(project, facts);
11866
11881
  let checksWaivedBy = null;
11867
11882
  return {
11868
11883
  gates: COLUMN_IDS.map((column) => {
@@ -12090,7 +12105,7 @@ function dispatch(input) {
12090
12105
  };
12091
12106
  };
12092
12107
  const withThreads = (next) => {
12093
- if (next?.column !== "dev" || !threadsGated(project) || facts.unresolvedThreads === 0) return next;
12108
+ if (next?.column !== "dev" || !threadsGated(project, facts) || facts.unresolvedThreads === 0) return next;
12094
12109
  const { reasons } = next;
12095
12110
  if (reasons.some((r) => r === "no_pr" || r === "pr_closed" || r === "unresolved_threads")) return next;
12096
12111
  const added = /* @__PURE__ */ new Set([...reasons, "unresolved_threads"]);
@@ -14553,21 +14568,26 @@ function cancelledOnHead(fact) {
14553
14568
  });
14554
14569
  }
14555
14570
  const sameRun = (left, right) => left.name === right.name && left.completedAt === right.completedAt;
14571
+ const NO_CANCELS = {
14572
+ waiting: [],
14573
+ confirmed: []
14574
+ };
14556
14575
  /**
14557
14576
  * Counts the polls since each cancelled check on the PR head was first seen: a new entry starts at
14558
14577
  * 0, a scheduled complete poll adds 1, and a head change starts over. It deletes the row of a PR
14559
- * that is not open or has no cancelled check. Returns true when this poll confirms a cancel.
14578
+ * that is not open or has no cancelled check. Returns the runs still waiting after this poll and
14579
+ * the runs this poll confirms as red, each once by name and completion time, in check order.
14560
14580
  */
14561
14581
  async function countCancelledChecks(trx, source, fact, scheduled) {
14562
14582
  const key = cancelledChecksKey(source, fact);
14563
14583
  const cancelled = fact.state === "open" ? cancelledOnHead(fact) : [];
14564
14584
  if (cancelled.length === 0) {
14565
14585
  await trx.deleteFrom("meta").where("key", "=", key).execute();
14566
- return false;
14586
+ return NO_CANCELS;
14567
14587
  }
14568
14588
  const head = fact.headSha.toLowerCase();
14569
14589
  const previous = await countsOnHead(trx, key, head);
14570
- let confirmed = false;
14590
+ const confirmed = [];
14571
14591
  const next = cancelled.map((check) => {
14572
14592
  const before = previous.find((entry) => sameRun(entry, check));
14573
14593
  if (before === void 0) return {
@@ -14575,7 +14595,7 @@ async function countCancelledChecks(trx, source, fact, scheduled) {
14575
14595
  polls: 0
14576
14596
  };
14577
14597
  if (!scheduled || before.polls >= CANCEL_CONFIRM_POLLS) return before;
14578
- if (before.polls + 1 === CANCEL_CONFIRM_POLLS) confirmed = true;
14598
+ if (before.polls + 1 === CANCEL_CONFIRM_POLLS) confirmed.push(check);
14579
14599
  return {
14580
14600
  ...before,
14581
14601
  polls: before.polls + 1
@@ -14589,7 +14609,13 @@ async function countCancelledChecks(trx, source, fact, scheduled) {
14589
14609
  key,
14590
14610
  value
14591
14611
  }).onConflict((oc) => oc.column("key").doUpdateSet({ value })).execute();
14592
- return confirmed;
14612
+ return {
14613
+ waiting: next.filter((entry) => entry.polls < CANCEL_CONFIRM_POLLS).map(({ name, completedAt }) => ({
14614
+ name,
14615
+ completedAt
14616
+ })),
14617
+ confirmed
14618
+ };
14593
14619
  }
14594
14620
  /**
14595
14621
  * The PR with each cancelled check on head that is not confirmed yet read as pending: no stored
@@ -14818,8 +14844,11 @@ async function storedReviewRule(trx, source, pr, agentLogin) {
14818
14844
  }
14819
14845
  const upper = (value) => value === null ? "null" : value.toUpperCase();
14820
14846
  /**
14821
- * The items of github-rules tasks in External Review whose head has stayed undecided for
14822
- * `REVIEW_RULE_UNDECIDED_MS` and whose gate, read as `readInput` reads it, still runs the clock: a
14847
+ * The items of github-rules tasks in External Review. A head GitHub blocks with every review thread
14848
+ * resolved, while the external approval is in place and External Review has no orchestrator, raises
14849
+ * one at once; its shown text carries GitHub's current values and nothing is written. Otherwise an
14850
+ * item comes for a head that has stayed undecided for `REVIEW_RULE_UNDECIDED_MS` and whose gate,
14851
+ * read as `readInput` reads it, still runs the clock: a
14823
14852
  * newer read of the head by another project's source can name someone to act first or carry
14824
14853
  * GitHub's answer, and then no item is raised or kept. GitHub's values are frozen in the row at
14825
14854
  * the first reconcile past the threshold and again when the cause changes, so a later poll or a
@@ -14838,9 +14867,24 @@ async function reviewRuleItems(trx, config, now, tasks) {
14838
14867
  const source = prSourceId(project.id, pr.repo);
14839
14868
  const gate = await gateRead(trx, source, project.checksGate === "dev" ? pr : await withUnconfirmedCancels(trx, source, pr), project.operatorGithubLogin);
14840
14869
  const row = gate.row;
14870
+ const ref = `${pr.repo.toLowerCase()}#${String(pr.number)}`;
14871
+ const executor = project.columns.find((column) => column.id === "external-review")?.orchestrator ?? "none";
14872
+ if (row !== null && gate.decision === "blocked" && gate.approved && !gate.changesRequested && executor === "none") {
14873
+ const what = `${task.key}: GitHub blocks the merge of ${ref} on ${row.headSha.slice(0, 7)} with every review thread resolved and the approval in place`;
14874
+ candidates.push({
14875
+ key: `${REVIEW_RULE_KEY}${String(task.id)}:${ref}:${row.headSha}`,
14876
+ kind: "board_observation",
14877
+ taskId: task.id,
14878
+ summary: `${what} (mergeStateStatus=${upper(pr.mergeState)}, mergeable=${upper(pr.mergeable)}, reviewDecision=${upper(row.reviewDecision)})`,
14879
+ hashedSummary: what,
14880
+ factAt: row.observedAt ?? null,
14881
+ source,
14882
+ priority: 4
14883
+ });
14884
+ continue;
14885
+ }
14841
14886
  if (row?.undecidedSince == null || !gate.clock) continue;
14842
14887
  if (now - Date.parse(row.undecidedSince) < REVIEW_RULE_UNDECIDED_MS) continue;
14843
- const ref = `${pr.repo.toLowerCase()}#${String(pr.number)}`;
14844
14888
  const what = gate.decision === "unreadable" ? `The GitHub review rule for the base branch of ${ref} could not be read` : `GitHub has not decided the review rule of ${ref}`;
14845
14889
  let raised = row.raised;
14846
14890
  if (raised === null || !raised.startsWith(what)) {
@@ -15807,7 +15851,11 @@ async function reconcileItems(trx, config, now, spurComplete, warnSkipped, spurC
15807
15851
  if (item.source === "spur" && spurHeld.has(item.item_key) || stillInError.has(item.item_key)) seen.add(item.item_key);
15808
15852
  }
15809
15853
  for (const item of existing) if (!seen.has(item.item_key)) await clearReconciled(trx, item, new Date(now));
15810
- const ended = (await trx.selectFrom("dismissal").select("item_key").where((eb) => eb.or([eb("item_key", "like", "pr-closed:%"), eb("item_key", "like", "ticket-closed:%")])).execute()).map((row) => row.item_key).filter((key) => !seen.has(key));
15854
+ const ended = (await trx.selectFrom("dismissal").select("item_key").where((eb) => eb.or([
15855
+ eb("item_key", "like", "pr-closed:%"),
15856
+ eb("item_key", "like", "ticket-closed:%"),
15857
+ eb("item_key", "like", `${REVIEW_RULE_KEY}%`)
15858
+ ])).execute()).map((row) => row.item_key).filter((key) => !seen.has(key));
15811
15859
  if (ended.length > 0) await trx.deleteFrom("dismissal").where("item_key", "in", ended).execute();
15812
15860
  for (const candidate of ordered) {
15813
15861
  const hash = fingerprint(candidate);
@@ -18772,19 +18820,32 @@ function factsSummary(entity, previous) {
18772
18820
  const texts = named.slice(0, NAMED_CHANGES).map((field) => changeText(field, previous[field], entity.facts[field]));
18773
18821
  return `${entity.prefix}: ${texts.join(", ")}${more(named.length)}`;
18774
18822
  }
18775
- /** `Checks on <ref>:` with the failed names, or the green and pending counts. */
18823
+ /**
18824
+ * `Checks on <ref>:` with the failed names, or the green and pending counts. A cancelled check
18825
+ * whose run (name and completion time) the row lists as `waiting` counts as pending; a clause names
18826
+ * the counted cancels whose run this poll confirmed, then the ones still waiting.
18827
+ */
18776
18828
  function checksSummary(payload) {
18777
18829
  const lists = checksSchema.safeParse(parsedJson(payload.to));
18778
18830
  if (!lists.success) return null;
18779
18831
  const [checks, requiredChecks] = lists.data;
18780
- const list = requiredChecks.length > 0 ? requiredChecks : checks.filter((check) => check.state !== "skipped");
18832
+ const list = countedChecks({
18833
+ checks,
18834
+ requiredChecks
18835
+ });
18781
18836
  const head = `Checks on ${ref$1(payload.repo, payload.pr)}`;
18782
18837
  if (list.length === 0) return `${head}: none`;
18783
- const failed = list.filter((check) => VERDICT[check.state] === "red").map(({ name }) => name);
18784
- if (failed.length > 0) return `${head}: ${String(failed.length)} failed: ${failed.slice(0, NAMED_CHANGES).join(", ")}${more(failed.length)}`;
18838
+ const listed = (check, runs) => check.state === "cancelled" && (runs ?? []).some((run) => sameRun(run, check));
18839
+ const clause = (runs, text) => {
18840
+ const counted = [...new Set(list.filter((check) => listed(check, runs)).map(({ name }) => name))];
18841
+ return counted.length === 0 ? "" : `; ${counted.slice(0, NAMED_CHANGES).join(", ")}${more(counted.length)} cancelled, ${text}`;
18842
+ };
18843
+ const clauses = clause(payload.confirmed, "now counts as red") + clause(payload.waiting, "waiting for a new run");
18844
+ const failed = list.filter((check) => VERDICT[check.state] === "red" && !listed(check, payload.waiting)).map(({ name }) => name);
18845
+ if (failed.length > 0) return `${head}: ${String(failed.length)} failed: ${failed.slice(0, NAMED_CHANGES).join(", ")}${more(failed.length)}${clauses}`;
18785
18846
  const green = list.filter((check) => VERDICT[check.state] === "green").length;
18786
18847
  const pending = list.length - green;
18787
- return `${head}: ${String(green)}/${String(list.length)} green${pending > 0 ? `, ${String(pending)} pending` : ""}`;
18848
+ return `${head}: ${String(green)}/${String(list.length)} green${pending > 0 ? `, ${String(pending)} pending` : ""}${clauses}`;
18788
18849
  }
18789
18850
  const gates = (gate) => gate === void 0 || gate.length === 0 ? "" : ` (${gate.join(", ")})`;
18790
18851
  const optional = (prefix, value) => value === void 0 ? "" : `${prefix}${value}`;
@@ -18888,11 +18949,13 @@ async function taskSessions(trx, taskId) {
18888
18949
  // ../core/src/app/turn-view.ts
18889
18950
  /**
18890
18951
  * The unresolved review threads a Dev turn lists, read live from the task's PR snapshot: only on a
18891
- * project requiring resolved threads and an open PR, and only threads with an id and a link (facts
18892
- * stored by an earlier version lack them). Undefined when none.
18952
+ * project requiring resolved threads, or for a turn whose reason names `unresolved_threads` (a
18953
+ * return GitHub's review rule caused), and an open PR, and only threads with an id and a link
18954
+ * (facts stored by an earlier version lack them). Undefined when none.
18893
18955
  */
18894
18956
  async function turnThreads(trx, taskId, project, turn) {
18895
- if (turn.column !== "dev" || project === void 0 || !threadsGated(project)) return void 0;
18957
+ if (turn.column !== "dev" || project === void 0) return void 0;
18958
+ if (!(turn.reason.split(": ")[1] ?? "").split(", ").includes("unresolved_threads") && !threadsGated(project)) return void 0;
18896
18959
  const pr = await prFacts(trx, taskId);
18897
18960
  if (pr?.state !== "open") return void 0;
18898
18961
  const threads = pr.reviewThreads.flatMap(({ resolved, id, url, outdated }) => resolved || id === void 0 || url === void 0 ? [] : [{
@@ -21069,7 +21132,10 @@ function comparableFacts(facts, timestamp) {
21069
21132
  * Applies one PR fact. `scheduled` is a complete scheduled poll, the only kind that advances the
21070
21133
  * cancelled-check count; `reviewRule` is the full read's review rule of a github-rules source.
21071
21134
  * Returns true when this poll confirmed a cancelled check as red, or changed the review rule with
21072
- * the facts unchanged: no fact event dispatches the PR's tasks then.
21135
+ * the facts unchanged: no fact event dispatches the PR's tasks then. A `checks_changed` row lists
21136
+ * the cancelled runs still in their grace window and the ones this poll confirms; a confirm of a
21137
+ * counted check's run (`countedChecks`, by name and completion time) with the checks unchanged
21138
+ * still writes one, with `from` equal to `to`.
21073
21139
  */
21074
21140
  async function pr(trx, config, fact, at, source, scheduled, reviewRule) {
21075
21141
  await trx.deleteFrom("source_miss").where("source", "=", source).where("ref_key", "=", refKey({
@@ -21117,7 +21183,9 @@ async function pr(trx, config, fact, at, source, scheduled, reviewRule) {
21117
21183
  });
21118
21184
  const project = projectForSource(config, source);
21119
21185
  if (project === void 0) return false;
21120
- const confirmed = project.checksGate !== "dev" && await countCancelledChecks(trx, source, fact, scheduled);
21186
+ const cancels = project.checksGate === "dev" ? NO_CANCELS : await countCancelledChecks(trx, source, fact, scheduled);
21187
+ const confirmed = cancels.confirmed.length > 0;
21188
+ const confirmRow = countedChecks(fact).some((check) => check.state === "cancelled" && cancels.confirmed.some((run) => sameRun(run, check)));
21121
21189
  const ruled = approvalRuleOf(project) === "github-rules" && await recordReviewRule(trx, source, fact, reviewRule, at, project.operatorGithubLogin);
21122
21190
  for (const key of fact.ticketKeys) {
21123
21191
  const task = await trx.selectFrom("task").selectAll().where("project", "=", project.id).where("key", "=", key).executeTakeFirst();
@@ -21151,7 +21219,7 @@ async function pr(trx, config, fact, at, source, scheduled, reviewRule) {
21151
21219
  else await trx.updateTable("link").set({ pr_open: 1 }).where("id", "=", link.id).execute();
21152
21220
  }
21153
21221
  await applyPendingReopen(trx, fact, at);
21154
- if (!changed) return confirmed || ruled;
21222
+ if (!changed && !confirmRow) return confirmed || ruled;
21155
21223
  const links = await trx.selectFrom("link").select(["task_id"]).where("entity", "=", "pr").where(sql`lower(repo) = ${fact.repo.toLowerCase()}`).where("number", "=", fact.number).execute();
21156
21224
  for (const link of links) {
21157
21225
  const task = await trx.selectFrom("task").selectAll().where("id", "=", link.task_id).executeTakeFirstOrThrow();
@@ -21161,12 +21229,15 @@ async function pr(trx, config, fact, at, source, scheduled, reviewRule) {
21161
21229
  from: previous.headSha,
21162
21230
  to: fact.headSha
21163
21231
  });
21164
- if (previous !== null && JSON.stringify([previous.checks, previous.requiredChecks]) !== JSON.stringify([fact.checks, fact.requiredChecks])) await emit(trx, "checks_changed", task.project, task.id, at, {
21232
+ const from = previous === null ? null : checksJson(previous);
21233
+ if (from !== null && from !== checksJson(fact) || confirmRow) await emit(trx, "checks_changed", task.project, task.id, at, {
21165
21234
  repo: fact.repo,
21166
21235
  pr: fact.number,
21167
- from: JSON.stringify([previous.checks, previous.requiredChecks]),
21168
- to: JSON.stringify([fact.checks, fact.requiredChecks]),
21169
- sha: fact.headSha
21236
+ from,
21237
+ to: checksJson(fact),
21238
+ sha: fact.headSha,
21239
+ ...cancels.waiting.length > 0 && { waiting: cancels.waiting },
21240
+ ...confirmed && { confirmed: cancels.confirmed }
21170
21241
  });
21171
21242
  if (previous !== null && previous.mergeable !== fact.mergeable) await emit(trx, "mergeable_changed", task.project, task.id, at, {
21172
21243
  repo: fact.repo,
@@ -21189,11 +21260,13 @@ async function pr(trx, config, fact, at, source, scheduled, reviewRule) {
21189
21260
  state: review.state
21190
21261
  });
21191
21262
  }
21263
+ if (!changed) continue;
21192
21264
  await emit(trx, "pr_facts_changed", task.project, task.id, at, { facts: fact });
21193
21265
  await markTaskChanged(trx, task.id, at);
21194
21266
  }
21195
21267
  return confirmed;
21196
21268
  }
21269
+ const checksJson = (facts) => JSON.stringify([facts.checks, facts.requiredChecks]);
21197
21270
  function branchHasKey(branch, key) {
21198
21271
  const text = branch.toLowerCase();
21199
21272
  const needle = key.toLowerCase();
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { lt as ERRORS, p as OPERATIONS, v as renderMcpError } from "./chunk-B49czSp7.mjs";
2
- import { o as CliError, r as requestOperation } from "./chunk-BqpntwKX.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-CwyzJDIl.mjs";
1
+ import { lt as ERRORS, p as OPERATIONS, v as renderMcpError } from "./chunk-Cy6VBP_I.mjs";
2
+ import { o as CliError, r as requestOperation } from "./chunk-BhHKMsqI.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-C-Jr3pwy.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";