spur-board 0.62.1 → 0.62.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-CzdGYlBy.mjs → chunk-C2Q6FYcu.mjs} +65 -33
- package/dist/{chunk-Czc8fVqW.mjs → chunk-OVqHRmrz.mjs} +1 -1
- package/dist/{chunk-DyPssI65.mjs → chunk-TFUh3jZ2.mjs} +2 -2
- package/dist/cli.mjs +3 -3
- package/dist/client.mjs +1 -1
- package/dist/daemon.mjs +263 -50
- package/dist/mcp.mjs +3 -3
- package/dist/migrations/0021_submission_pending.sql +7 -0
- package/package.json +1 -1
- package/skills/spur-board/references/commands.md +1 -1
- package/skills/spur-board/references/errors.md +2 -2
- package/skills/spur-board/references/how-board-works.md +8 -5
|
@@ -149,6 +149,7 @@ const TASK_HOLDS = [
|
|
|
149
149
|
"github_blind",
|
|
150
150
|
"spur_blind",
|
|
151
151
|
"ticket_unconfirmed",
|
|
152
|
+
"submit_pending",
|
|
152
153
|
"cycle_limit",
|
|
153
154
|
"work_not_started"
|
|
154
155
|
];
|
|
@@ -388,7 +389,10 @@ const projectSchema = z.strictObject({
|
|
|
388
389
|
cycleLimit: DEFAULT_CYCLE_LIMIT,
|
|
389
390
|
courseCheck: DEFAULT_COURSE_CHECK
|
|
390
391
|
}))).describe("The project's board columns in canonical order. todo, dev and done must be present and enabled. A column left out or disabled is skipped. Without this key, all nine columns are enabled with orchestrator none."),
|
|
391
|
-
dispatcher: z.strictObject({
|
|
392
|
+
dispatcher: z.strictObject({
|
|
393
|
+
mode: z.enum(DISPATCHER_MODES).default("shadow").describe("shadow: the board evaluates the column gates and records where each task would go in its shadow column, and opens no turn, doorbell or block; the column executor submits with the task key. on: the board moves the task between columns, hands the column executor a turn, and raises the cycle-limit and course-check blocks."),
|
|
394
|
+
submitConfirmMs: durationMs(18e4, "How long the board waits to confirm a turn submit it accepted pending (no PR linked yet, or GitHub not confirming the head) before handing the turn back to its executor with the reason")
|
|
395
|
+
}).prefault({}).describe("How the board moves tasks between columns. The board records the mode it last ran with. The daemon reads the mode at start, so a change takes effect after a restart; a switch from shadow to on copies the shadow column of each task into its column, and a switch back to shadow closes the open turns and starts the shadow column from the column again.")
|
|
392
396
|
}).superRefine((project, ctx) => {
|
|
393
397
|
const repos = new Set(project.repos.map((repo) => repo.toLowerCase()));
|
|
394
398
|
project.reposWithoutCi.forEach((repo, j) => {
|
|
@@ -763,9 +767,9 @@ const ERRORS = {
|
|
|
763
767
|
head_mismatch: spec("head_mismatch", {
|
|
764
768
|
status: 409,
|
|
765
769
|
exit: EXIT_CODES.refused,
|
|
766
|
-
message: "The commit is not the head
|
|
767
|
-
hint: "Push the commit to the task's pull request branch and submit
|
|
768
|
-
recovery: noRetry("Push the commit to the task's pull request branch and submit
|
|
770
|
+
message: "The commit is not the head GitHub reports for the task's pull request, or a submit by task key found no pull request.",
|
|
771
|
+
hint: "Push the commit to the task's pull request branch and submit the head GitHub shows.",
|
|
772
|
+
recovery: noRetry("Push the commit to the task's pull request branch and submit the head GitHub shows.")
|
|
769
773
|
}),
|
|
770
774
|
return_not_allowed: spec("return_not_allowed", {
|
|
771
775
|
status: 409,
|
|
@@ -834,8 +838,8 @@ const ERRORS = {
|
|
|
834
838
|
status: 503,
|
|
835
839
|
exit: EXIT_CODES.notApplied,
|
|
836
840
|
message: "GitHub did not confirm current pull request facts.",
|
|
837
|
-
hint: "
|
|
838
|
-
recovery: retry("
|
|
841
|
+
hint: "Follow the message: ask the operator to fix what it names, or retry a read or link once GitHub answers the board's polls; repeat a submit only by task key in shadow mode.",
|
|
842
|
+
recovery: retry("Ask the operator to fix what the message names; retry a read or link once GitHub answers, and repeat a submit only by task key in shadow mode.", "After GitHub answers the board's polls.")
|
|
839
843
|
}),
|
|
840
844
|
version_mismatch: spec("version_mismatch", {
|
|
841
845
|
status: 409,
|
|
@@ -1468,7 +1472,11 @@ const eventPayloadSchemas = {
|
|
|
1468
1472
|
column: z.enum(COLUMN_IDS),
|
|
1469
1473
|
sha: S,
|
|
1470
1474
|
/** The head was confirmed by the board's newest poll; GitHub did not answer the submit. */
|
|
1471
|
-
confirmedByPoll: z.literal(true).optional()
|
|
1475
|
+
confirmedByPoll: z.literal(true).optional(),
|
|
1476
|
+
/** The board accepted the submit before it could confirm the head; it confirms it on a later poll. */
|
|
1477
|
+
pending: z.literal(true).optional(),
|
|
1478
|
+
/** A pending submit settled without a turn: its PR merged at this head, not at `sha`. */
|
|
1479
|
+
supersededByMerge: S.optional()
|
|
1472
1480
|
}),
|
|
1473
1481
|
task_moved: z.looseObject({
|
|
1474
1482
|
from: z.enum(COLUMN_IDS),
|
|
@@ -2004,6 +2012,11 @@ const taskWhySchema = z.strictObject({
|
|
|
2004
2012
|
dispatcher: z.enum(DISPATCHER_MODES).nullable().describe("The project's dispatcher mode; null when the project is not configured."),
|
|
2005
2013
|
holds: z.array(z.enum(TASK_HOLDS)).describe("What holds the dispatcher from acting on the task; empty when nothing does."),
|
|
2006
2014
|
heldBy: z.array(blockIdSchema).min(1).optional().describe("Blocks of the open cycle-limit or course-check items holding the task; absent when none does."),
|
|
2015
|
+
pendingSubmit: z.strictObject({
|
|
2016
|
+
sha: commitShaSchema.describe("The submitted commit SHA the board has not confirmed yet."),
|
|
2017
|
+
until: z.iso.datetime().describe("When the board stops waiting for a PR, ISO 8601 UTC; a linked PR is waited for until a poll observes it."),
|
|
2018
|
+
text: z.string().describe("The hold in words: submit pending confirmation of <sha7>.")
|
|
2019
|
+
}).optional().describe("The turn submit the board accepted pending; absent when no submit waits."),
|
|
2007
2020
|
gates: z.array(z.strictObject({
|
|
2008
2021
|
column: z.enum(COLUMN_IDS).describe("Board column."),
|
|
2009
2022
|
enabled: z.boolean().describe("Whether the column is enabled in the project."),
|
|
@@ -3494,7 +3507,7 @@ const OPERATIONS = [
|
|
|
3494
3507
|
defineOperation({
|
|
3495
3508
|
id: "task.submit",
|
|
3496
3509
|
kind: "mutation",
|
|
3497
|
-
description: "Submit the
|
|
3510
|
+
description: "Submit the task's pull request head for a turn this session took; the turn closes; a pending result is final.",
|
|
3498
3511
|
mcp: {
|
|
3499
3512
|
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.",
|
|
3500
3513
|
whenNotToUse: "Use task_return to send the task back to Dev instead."
|
|
@@ -3506,7 +3519,8 @@ const OPERATIONS = [
|
|
|
3506
3519
|
output: z.strictObject({
|
|
3507
3520
|
task: taskViewSchema,
|
|
3508
3521
|
turn: turnIdSchema.nullable().describe("The closed turn; null for a submit by task key in shadow mode."),
|
|
3509
|
-
sha: commitShaSchema.describe("The submitted commit SHA.")
|
|
3522
|
+
sha: commitShaSchema.describe("The submitted commit SHA."),
|
|
3523
|
+
status: z.enum(["confirmed", "pending"]).default("confirmed").describe("confirmed: the board saw the PR head at sha. pending: accepted, pending confirmation - the board confirms the head on its next polls and hands the turn back with the reason if it cannot; do not resubmit or raise a block.")
|
|
3510
3524
|
}),
|
|
3511
3525
|
grants: [{ grant: "task-worker" }, { grant: "column-orchestrator" }],
|
|
3512
3526
|
errors: [
|
|
@@ -3523,35 +3537,53 @@ const OPERATIONS = [
|
|
|
3523
3537
|
args: ["turn", "sha"]
|
|
3524
3538
|
},
|
|
3525
3539
|
slack: null,
|
|
3526
|
-
examples: [
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3540
|
+
examples: [
|
|
3541
|
+
{
|
|
3542
|
+
summary: "Submit the pull request head",
|
|
3543
|
+
input: {
|
|
3544
|
+
turn: "T4",
|
|
3545
|
+
sha: submittedSha
|
|
3546
|
+
},
|
|
3547
|
+
output: {
|
|
3548
|
+
task: {
|
|
3549
|
+
...task,
|
|
3550
|
+
column: "review"
|
|
3551
|
+
},
|
|
3552
|
+
turn: "T4",
|
|
3553
|
+
sha: submittedSha,
|
|
3554
|
+
status: "confirmed"
|
|
3555
|
+
}
|
|
3531
3556
|
},
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3557
|
+
{
|
|
3558
|
+
summary: "Submit a dev turn before the board has seen the pull request",
|
|
3559
|
+
input: {
|
|
3560
|
+
turn: "T3",
|
|
3561
|
+
sha: submittedSha
|
|
3536
3562
|
},
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
turn: "PROJ-123",
|
|
3544
|
-
sha: submittedSha
|
|
3563
|
+
output: {
|
|
3564
|
+
task,
|
|
3565
|
+
turn: "T3",
|
|
3566
|
+
sha: submittedSha,
|
|
3567
|
+
status: "pending"
|
|
3568
|
+
}
|
|
3545
3569
|
},
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3570
|
+
{
|
|
3571
|
+
summary: "Submit the pull request head by task key while the dispatcher is in shadow mode",
|
|
3572
|
+
input: {
|
|
3573
|
+
turn: "PROJ-123",
|
|
3574
|
+
sha: submittedSha
|
|
3550
3575
|
},
|
|
3551
|
-
|
|
3552
|
-
|
|
3576
|
+
output: {
|
|
3577
|
+
task: {
|
|
3578
|
+
...task,
|
|
3579
|
+
column: "review"
|
|
3580
|
+
},
|
|
3581
|
+
turn: null,
|
|
3582
|
+
sha: submittedSha,
|
|
3583
|
+
status: "confirmed"
|
|
3584
|
+
}
|
|
3553
3585
|
}
|
|
3554
|
-
|
|
3586
|
+
]
|
|
3555
3587
|
}),
|
|
3556
3588
|
defineOperation({
|
|
3557
3589
|
id: "task.return",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as errorEnvelopeSchema, Q as errorContextSchema, S as renderJsonError, X as ERRORS, c as tokenRequestStatusSchema, o as tokenRequestResultSchema, tt as successEnvelopeSchema } from "./chunk-
|
|
1
|
+
import { $ as errorEnvelopeSchema, Q as errorContextSchema, S as renderJsonError, X as ERRORS, c as tokenRequestStatusSchema, o as tokenRequestResultSchema, tt as successEnvelopeSchema } from "./chunk-C2Q6FYcu.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 { _ as buildCatalogSnapshot, ct as plainHttpAllowed, st as configSchema, y as OPERATIONS } from "./chunk-
|
|
2
|
-
import { o as CliError, t as fetchCatalogVersion } from "./chunk-
|
|
1
|
+
import { _ as buildCatalogSnapshot, ct as plainHttpAllowed, st as configSchema, y as OPERATIONS } from "./chunk-C2Q6FYcu.mjs";
|
|
2
|
+
import { o as CliError, t as fetchCatalogVersion } from "./chunk-OVqHRmrz.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";
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { G as actorIdSchema, X as ERRORS, a as requestHashOf, ft as SLACK_BOT_SCOPES, lt as requiredSecretKeys, r as remoteDoctorReportSchema, st as configSchema, tt as successEnvelopeSchema, u as SYSTEMD_SERVICE_SETTINGS, v as roleCanUseOperation, y as OPERATIONS } from "./chunk-
|
|
1
|
+
import { G as actorIdSchema, X as ERRORS, a as requestHashOf, ft as SLACK_BOT_SCOPES, lt as requiredSecretKeys, r as remoteDoctorReportSchema, st as configSchema, tt as successEnvelopeSchema, u as SYSTEMD_SERVICE_SETTINGS, v as roleCanUseOperation, y as OPERATIONS } from "./chunk-C2Q6FYcu.mjs";
|
|
2
2
|
import { t as apiBaseUrl } from "./chunk-DAMwWWmT.mjs";
|
|
3
|
-
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-
|
|
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-
|
|
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-OVqHRmrz.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-TFUh3jZ2.mjs";
|
|
5
5
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
6
6
|
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
7
7
|
import { homedir, hostname, userInfo } from "node:os";
|
package/dist/client.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as requestTokenEnrollment, i as requestSkillReload, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./chunk-
|
|
1
|
+
import { a as requestTokenEnrollment, i as requestSkillReload, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./chunk-OVqHRmrz.mjs";
|
|
2
2
|
export { fetchCatalogVersion, fetchTokenStatus, requestOperation, requestSkillReload, requestTokenEnrollment };
|
package/dist/daemon.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as EVENT_KINDS, B as ringMarker, D as interactionRefSchema, E as inboundEventSchema, F as SESSION_STATUSES, G as actorIdSchema, H as ticketFactsSchema, I as isExternalAuthor, J as parseActorId, K as encodeActorId, L as parseRingMarker, M as PR_STATES, N as REVIEW_STATES, O as messageRefSchema, P as SESSION_HEALTH_STATES, R as prFactsSchema, T as conversationRefSchema, U as JIRA_PROJECT_KEY, V as sessionFactsSchema, W as REF_NUMBER, X as ERRORS, Y as parseRef$1, Z as err, _ as buildCatalogSnapshot, a as requestHashOf, at as DEFAULT_SLACK_COMMAND, b as turnHandedSchema, c as tokenRequestStatusSchema, ct as plainHttpAllowed, d as AdapterError, dt as DISPATCHER_MODES, et as ok, f as batchSchema, ft as SLACK_BOT_SCOPES, g as trackerSourceId, h as sourceCursorSchema, i as TOKEN_REQUEST_LIMITS, j as eventPayloadSchemas, k as userIdSchema, l as BOARD_TICK_MS, lt as requiredSecretKeys, m as prSourceId, n as doctorReportSchema, o as tokenRequestResultSchema, ot as RESERVED_PROJECT, p as entityRefSchema, pt as TASK_HOLDS, q as errorCodeOf, rt as DEFAULT_LINK, s as tokenRequestSchema, st as configSchema, t as assertNever, tt as successEnvelopeSchema, ut as COLUMN_IDS, v as roleCanUseOperation, w as SPACE_IDS, x as renderHttpProblem, y as OPERATIONS, z as prRefSchema } from "./chunk-
|
|
1
|
+
import { A as EVENT_KINDS, B as ringMarker, D as interactionRefSchema, E as inboundEventSchema, F as SESSION_STATUSES, G as actorIdSchema, H as ticketFactsSchema, I as isExternalAuthor, J as parseActorId, K as encodeActorId, L as parseRingMarker, M as PR_STATES, N as REVIEW_STATES, O as messageRefSchema, P as SESSION_HEALTH_STATES, R as prFactsSchema, T as conversationRefSchema, U as JIRA_PROJECT_KEY, V as sessionFactsSchema, W as REF_NUMBER, X as ERRORS, Y as parseRef$1, Z as err, _ as buildCatalogSnapshot, a as requestHashOf, at as DEFAULT_SLACK_COMMAND, b as turnHandedSchema, c as tokenRequestStatusSchema, ct as plainHttpAllowed, d as AdapterError, dt as DISPATCHER_MODES, et as ok, f as batchSchema, ft as SLACK_BOT_SCOPES, g as trackerSourceId, h as sourceCursorSchema, i as TOKEN_REQUEST_LIMITS, j as eventPayloadSchemas, k as userIdSchema, l as BOARD_TICK_MS, lt as requiredSecretKeys, m as prSourceId, n as doctorReportSchema, o as tokenRequestResultSchema, ot as RESERVED_PROJECT, p as entityRefSchema, pt as TASK_HOLDS, q as errorCodeOf, rt as DEFAULT_LINK, s as tokenRequestSchema, st as configSchema, t as assertNever, tt as successEnvelopeSchema, ut as COLUMN_IDS, v as roleCanUseOperation, w as SPACE_IDS, x as renderHttpProblem, y as OPERATIONS, z as prRefSchema } from "./chunk-C2Q6FYcu.mjs";
|
|
2
2
|
import { t as apiBaseUrl } from "./chunk-DAMwWWmT.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -14225,15 +14225,16 @@ function workStarted(input) {
|
|
|
14225
14225
|
return input.openPr || !input.reopened && workerLive;
|
|
14226
14226
|
}
|
|
14227
14227
|
/**
|
|
14228
|
-
* What holds the dispatcher on the task now: a blind GitHub stops it, a blind
|
|
14229
|
-
* worker's turn, an active cycle-limit or course-check item stops every turn and
|
|
14230
|
-
* To Do and Ready for Dev wait for the work to start. The last is judged at the
|
|
14231
|
-
* while `dispatch` judges it at each column the cascade reaches.
|
|
14228
|
+
* What holds the dispatcher on the task now: a blind GitHub or a pending submit stops it, a blind
|
|
14229
|
+
* Spur defers a worker's turn, an active cycle-limit or course-check item stops every turn and
|
|
14230
|
+
* move right, and To Do and Ready for Dev wait for the work to start. The last is judged at the
|
|
14231
|
+
* task's column, while `dispatch` judges it at each column the cascade reaches.
|
|
14232
14232
|
*/
|
|
14233
14233
|
function dispatchHolds(input) {
|
|
14234
14234
|
const holds = [];
|
|
14235
14235
|
if (input.githubBlind) holds.push("github_blind");
|
|
14236
14236
|
if (input.spurBlind) holds.push("spur_blind");
|
|
14237
|
+
if (input.submitPending) holds.push("submit_pending");
|
|
14237
14238
|
if (input.cycleHeld) holds.push("cycle_limit");
|
|
14238
14239
|
if ((input.column === "todo" || input.column === "ready-for-dev") && !workStarted(input)) holds.push("work_not_started");
|
|
14239
14240
|
return holds;
|
|
@@ -14245,13 +14246,14 @@ function dispatchHolds(input) {
|
|
|
14245
14246
|
*/
|
|
14246
14247
|
function dispatch(input) {
|
|
14247
14248
|
const moves = [];
|
|
14248
|
-
if (input.githubBlind) return {
|
|
14249
|
+
if (input.githubBlind || input.submitPending) return {
|
|
14249
14250
|
moves,
|
|
14250
14251
|
turn: null
|
|
14251
14252
|
};
|
|
14252
14253
|
const { project, reopened, cycleHeld } = input;
|
|
14253
14254
|
const workerLive = input.liveWorker && !input.spurBlind;
|
|
14254
14255
|
const started = workStarted(input);
|
|
14256
|
+
const handsBack = input.submitFailed && input.turn.visit !== "unclosed";
|
|
14255
14257
|
let { column, facts, turn } = input;
|
|
14256
14258
|
const move = (to, reason, gate) => {
|
|
14257
14259
|
moves.push({
|
|
@@ -14320,7 +14322,7 @@ function dispatch(input) {
|
|
|
14320
14322
|
}
|
|
14321
14323
|
const executor = orchestratorOf(project, column);
|
|
14322
14324
|
if (column === "external-review" && executor === "none") return result(null);
|
|
14323
|
-
if (reasons.includes("pr_closed")) return result(null);
|
|
14325
|
+
if (reasons.includes("pr_closed") && !handsBack) return result(null);
|
|
14324
14326
|
switch (turn.visit) {
|
|
14325
14327
|
case "none": return result({
|
|
14326
14328
|
column,
|
|
@@ -15124,22 +15126,25 @@ const MARK_COLUMNS = ["review", "product-review"];
|
|
|
15124
15126
|
const indexOf = (column) => COLUMN_IDS.indexOf(column);
|
|
15125
15127
|
/**
|
|
15126
15128
|
* Sets `voided_at` on the unvoided submits of `columns`. Review and product-review marks are
|
|
15127
|
-
* not voided by a move; a new PR head voids them (`voidMarksOffHead`).
|
|
15129
|
+
* not voided by a move; a new PR head voids them (`voidMarksOffHead`). A pending submit is never
|
|
15130
|
+
* voided here: it settles only when its hand-back turn opens, as confirmed, or as superseded by
|
|
15131
|
+
* a merge (`readPendingSubmit`), and counts as no mark until then.
|
|
15128
15132
|
*/
|
|
15129
15133
|
async function voidColumns(trx, taskId, columns, at) {
|
|
15130
15134
|
const voided = columns.filter((column) => !MARK_COLUMNS.includes(column));
|
|
15131
15135
|
if (voided.length === 0) return;
|
|
15132
|
-
await trx.updateTable("submission").set({ voided_at: at.toISOString() }).where("task_id", "=", taskId).where("voided_at", "is", null).where("column", "in", voided).execute();
|
|
15136
|
+
await trx.updateTable("submission").set({ voided_at: at.toISOString() }).where("task_id", "=", taskId).where("voided_at", "is", null).where("pending_until", "is", null).where("column", "in", voided).execute();
|
|
15133
15137
|
}
|
|
15134
15138
|
/**
|
|
15135
15139
|
* Sets `voided_at` on the unvoided Review and Product Review marks of PR `repo#number` that are
|
|
15136
15140
|
* not on `head`, for the PR's new head: a mark lasts only while its head stays the PR's head, so
|
|
15137
15141
|
* a head that comes back to an earlier commit needs fresh marks. Marks made before submissions
|
|
15138
|
-
* recorded their PR count for the tasks linked to the PR.
|
|
15142
|
+
* recorded their PR count for the tasks linked to the PR. A pending mark is left to the
|
|
15143
|
+
* dispatcher, which hands it back with the new head (`readPendingSubmit`).
|
|
15139
15144
|
*/
|
|
15140
15145
|
async function voidMarksOffHead(trx, input) {
|
|
15141
15146
|
const repo = input.repo.toLowerCase();
|
|
15142
|
-
await trx.updateTable("submission").set({ voided_at: input.at }).where("voided_at", "is", null).where("column", "in", MARK_COLUMNS).where(sql`lower(commit_sha) != ${input.head.toLowerCase()}`).where((eb) => eb.or([eb.and([eb(sql`lower(pr_repo)`, "=", repo), eb("pr_number", "=", input.number)]), eb.and([eb("pr_repo", "is", null), eb("task_id", "in", eb.selectFrom("link").select("task_id").where("entity", "=", "pr").where(sql`lower(repo) = ${repo}`).where("number", "=", input.number))])])).execute();
|
|
15147
|
+
await trx.updateTable("submission").set({ voided_at: input.at }).where("voided_at", "is", null).where("column", "in", MARK_COLUMNS).where("pending_until", "is", null).where(sql`lower(commit_sha) != ${input.head.toLowerCase()}`).where((eb) => eb.or([eb.and([eb(sql`lower(pr_repo)`, "=", repo), eb("pr_number", "=", input.number)]), eb.and([eb("pr_repo", "is", null), eb("task_id", "in", eb.selectFrom("link").select("task_id").where("entity", "=", "pr").where(sql`lower(repo) = ${repo}`).where("number", "=", input.number))])])).execute();
|
|
15143
15148
|
}
|
|
15144
15149
|
/** Voids the submits of `to` and every column right of it, as a left move does. */
|
|
15145
15150
|
async function voidSubmits(trx, taskId, to, at) {
|
|
@@ -15418,11 +15423,115 @@ function handedOf(pr, entry) {
|
|
|
15418
15423
|
postedAt: entry.postedAt
|
|
15419
15424
|
};
|
|
15420
15425
|
}
|
|
15426
|
+
/** The clock passed `until` and a complete poll of each of `repos` started at or after it. */
|
|
15427
|
+
function pastBound(project, until, input, repos) {
|
|
15428
|
+
const bound = Date.parse(until);
|
|
15429
|
+
if (input.at.getTime() < bound) return false;
|
|
15430
|
+
return repos.every((repo) => {
|
|
15431
|
+
const since = input.complete.get(prSourceId(project.id, repo));
|
|
15432
|
+
return since !== void 0 && Date.parse(since) >= bound;
|
|
15433
|
+
});
|
|
15434
|
+
}
|
|
15435
|
+
/**
|
|
15436
|
+
* The newest unvoided pending submit of the task's current visit in `on` mode, settled from
|
|
15437
|
+
* stored facts (`settlePending`). With `carry` (no turn yet in the current visit), the task's
|
|
15438
|
+
* newest submission from an earlier visit counts too, but only once it failed or was superseded:
|
|
15439
|
+
* a left move whose
|
|
15440
|
+
* turn was deferred or held still hands the failure back with the turn it opens later. Such a
|
|
15441
|
+
* row never confirms or holds the task here.
|
|
15442
|
+
*/
|
|
15443
|
+
async function readPendingSubmit(trx, task, project, input) {
|
|
15444
|
+
const current = await trx.selectFrom("submission").select([
|
|
15445
|
+
"id",
|
|
15446
|
+
"commit_sha",
|
|
15447
|
+
"author",
|
|
15448
|
+
"submitted_at",
|
|
15449
|
+
"pending_until"
|
|
15450
|
+
]).where("task_id", "=", task.id).where("column", "=", task.column).where("epoch", "=", task.column_epoch).where("voided_at", "is", null).where("pending_until", "is not", null).orderBy("id", "desc").executeTakeFirst();
|
|
15451
|
+
if (current?.pending_until != null) return settlePending(trx, {
|
|
15452
|
+
...current,
|
|
15453
|
+
pending_until: current.pending_until
|
|
15454
|
+
}, project, input);
|
|
15455
|
+
if (!input.carry) return void 0;
|
|
15456
|
+
const newest = await trx.selectFrom("submission").select([
|
|
15457
|
+
"id",
|
|
15458
|
+
"commit_sha",
|
|
15459
|
+
"author",
|
|
15460
|
+
"submitted_at",
|
|
15461
|
+
"pending_until",
|
|
15462
|
+
"voided_at"
|
|
15463
|
+
]).where("task_id", "=", task.id).orderBy("id", "desc").executeTakeFirst();
|
|
15464
|
+
if (newest?.pending_until == null || newest.voided_at !== null) return void 0;
|
|
15465
|
+
const settled = await settlePending(trx, {
|
|
15466
|
+
...newest,
|
|
15467
|
+
pending_until: newest.pending_until
|
|
15468
|
+
}, project, input);
|
|
15469
|
+
return settled.state === "failed" || settled.state === "superseded" ? settled : void 0;
|
|
15470
|
+
}
|
|
15471
|
+
/**
|
|
15472
|
+
* Settles a pending submit from stored facts: the linked PR's snapshot observed at or after the
|
|
15473
|
+
* submit decides it, and so does a merged one observed before; a closed one observed before fails
|
|
15474
|
+
* it, and no PR linked fails it, only once the bound passed and a complete poll of the PR's repo,
|
|
15475
|
+
* or of every project repo, started at or after the bound. Nothing settles while GitHub is blind.
|
|
15476
|
+
*/
|
|
15477
|
+
async function settlePending(trx, row, project, input) {
|
|
15478
|
+
const sha = row.commit_sha.toLowerCase();
|
|
15479
|
+
const pending = {
|
|
15480
|
+
id: row.id,
|
|
15481
|
+
sha,
|
|
15482
|
+
until: row.pending_until,
|
|
15483
|
+
state: "pending"
|
|
15484
|
+
};
|
|
15485
|
+
if (input.githubBlind) return pending;
|
|
15486
|
+
const { link } = input;
|
|
15487
|
+
if (link !== null) {
|
|
15488
|
+
const snap = await trx.selectFrom("pr_snapshot").select([
|
|
15489
|
+
"head_sha",
|
|
15490
|
+
"state",
|
|
15491
|
+
"observed_at"
|
|
15492
|
+
]).where(sql`lower(repo) = ${link.repo.toLowerCase()}`).where("number", "=", link.number).executeTakeFirst();
|
|
15493
|
+
if (snap === void 0) return pending;
|
|
15494
|
+
const stale = Date.parse(snap.observed_at) < Date.parse(row.submitted_at);
|
|
15495
|
+
if (snap.state === "open" && stale) return pending;
|
|
15496
|
+
if (snap.state === "closed") {
|
|
15497
|
+
if (stale && !pastBound(project, row.pending_until, input, [link.repo])) return pending;
|
|
15498
|
+
return {
|
|
15499
|
+
...pending,
|
|
15500
|
+
state: "failed",
|
|
15501
|
+
failure: `PR ${link.repo}#${String(link.number)} closed`
|
|
15502
|
+
};
|
|
15503
|
+
}
|
|
15504
|
+
if (snap.head_sha.toLowerCase() === sha) return {
|
|
15505
|
+
...pending,
|
|
15506
|
+
state: "confirmed",
|
|
15507
|
+
pr: link
|
|
15508
|
+
};
|
|
15509
|
+
if (snap.state === "merged") return {
|
|
15510
|
+
...pending,
|
|
15511
|
+
state: "superseded",
|
|
15512
|
+
head: snap.head_sha.toLowerCase()
|
|
15513
|
+
};
|
|
15514
|
+
return {
|
|
15515
|
+
...pending,
|
|
15516
|
+
state: "failed",
|
|
15517
|
+
failure: `head moved to ${snap.head_sha.toLowerCase().slice(0, 7)}`
|
|
15518
|
+
};
|
|
15519
|
+
}
|
|
15520
|
+
if (!pastBound(project, row.pending_until, input, project.repos)) return pending;
|
|
15521
|
+
const parsed = parseActorId(row.author);
|
|
15522
|
+
const session = parsed?.actor === "agent" ? parsed.actorRef.session : void 0;
|
|
15523
|
+
const branch = session === void 0 ? void 0 : (await trx.selectFrom("session_snapshot").select("branch").where("id", "=", session).executeTakeFirst())?.branch;
|
|
15524
|
+
return {
|
|
15525
|
+
...pending,
|
|
15526
|
+
state: "failed",
|
|
15527
|
+
failure: branch == null ? "no PR found" : `no PR found for ${branch}`
|
|
15528
|
+
};
|
|
15529
|
+
}
|
|
15421
15530
|
/**
|
|
15422
15531
|
* The dispatcher input of one task, or null when a stored snapshot is missing or unreadable. It
|
|
15423
15532
|
* only reads.
|
|
15424
15533
|
*/
|
|
15425
|
-
async function readInput(trx, task, project, mode, blind, config) {
|
|
15534
|
+
async function readInput(trx, task, project, mode, blind, config, clock) {
|
|
15426
15535
|
const readPr = async (ref) => parsePr((await trx.selectFrom("pr_snapshot").select("detail").where(sql`lower(repo) = ${ref.repo.toLowerCase()}`).where("number", "=", ref.number).executeTakeFirst())?.detail);
|
|
15427
15536
|
const link = await taskPr(trx, task.id);
|
|
15428
15537
|
let pr = null;
|
|
@@ -15457,7 +15566,19 @@ async function readInput(trx, task, project, mode, blind, config) {
|
|
|
15457
15566
|
}
|
|
15458
15567
|
if (mergedOpen !== void 0) pr = null;
|
|
15459
15568
|
const githubBlind = (pr === null ? project.repos : [pr.repo]).some((repo) => blind(prSourceId(project.id, repo)));
|
|
15460
|
-
const
|
|
15569
|
+
const last = mode === "shadow" ? void 0 : await trx.selectFrom("turn").selectAll().where("task_id", "=", task.id).where("column", "=", task.column).where("epoch", "=", task.column_epoch).orderBy("seq", "desc").executeTakeFirst();
|
|
15570
|
+
const pending = mode === "on" ? await readPendingSubmit(trx, task, project, {
|
|
15571
|
+
link,
|
|
15572
|
+
githubBlind,
|
|
15573
|
+
...clock,
|
|
15574
|
+
carry: last === void 0
|
|
15575
|
+
}) : void 0;
|
|
15576
|
+
const marks = (await trx.selectFrom("submission").select([
|
|
15577
|
+
"id",
|
|
15578
|
+
"column",
|
|
15579
|
+
"commit_sha",
|
|
15580
|
+
"pending_until"
|
|
15581
|
+
]).where("task_id", "=", task.id).where("voided_at", "is", null).orderBy("id").execute()).filter((row) => row.pending_until === null || pending?.state === "confirmed" && row.id === pending.id).map((row) => {
|
|
15461
15582
|
const headSha = row.commit_sha.toLowerCase();
|
|
15462
15583
|
return row.column === "review" || row.column === "product-review" ? {
|
|
15463
15584
|
kind: "mark",
|
|
@@ -15472,7 +15593,6 @@ async function readInput(trx, task, project, mode, blind, config) {
|
|
|
15472
15593
|
const unhandled = pr === null ? [] : await unhandledFeedback(trx, task, project, pr);
|
|
15473
15594
|
const handed = pr?.feedbackComplete === true ? unhandled : [];
|
|
15474
15595
|
const column = mode === "shadow" ? task.shadow_column ?? task.column : task.column;
|
|
15475
|
-
const last = mode === "shadow" ? void 0 : await trx.selectFrom("turn").selectAll().where("task_id", "=", task.id).where("column", "=", task.column).where("epoch", "=", task.column_epoch).orderBy("seq", "desc").executeTakeFirst();
|
|
15476
15596
|
const unclosed = last?.closed_at === null ? last : void 0;
|
|
15477
15597
|
const held = mode === "on" && await trx.selectFrom("operator_item").select("id").where((eb) => eb.or([eb("item_key", "like", `${cycleKeyPrefix(task.id)}%`), eb("item_key", "like", `${courseKeyPrefix(task.id)}%`)])).where("cleared_at", "is", null).executeTakeFirst() !== void 0;
|
|
15478
15598
|
return {
|
|
@@ -15495,6 +15615,8 @@ async function readInput(trx, task, project, mode, blind, config) {
|
|
|
15495
15615
|
spurBlind: blind("spur"),
|
|
15496
15616
|
liveWorker: await linkedSession(trx, task.id, "worker") !== void 0,
|
|
15497
15617
|
cycleHeld: held,
|
|
15618
|
+
submitPending: pending?.state === "pending",
|
|
15619
|
+
submitFailed: pending?.state === "failed",
|
|
15498
15620
|
turn: {
|
|
15499
15621
|
visit: last === void 0 ? "none" : unclosed !== void 0 ? "unclosed" : last.closed_reason === "submitted" ? "submitted" : "none",
|
|
15500
15622
|
open: unclosed?.acked_at != null,
|
|
@@ -15505,7 +15627,8 @@ async function readInput(trx, task, project, mode, blind, config) {
|
|
|
15505
15627
|
handed,
|
|
15506
15628
|
unclosed,
|
|
15507
15629
|
mergedOpen,
|
|
15508
|
-
ticketUnconfirmed
|
|
15630
|
+
ticketUnconfirmed,
|
|
15631
|
+
pending
|
|
15509
15632
|
};
|
|
15510
15633
|
}
|
|
15511
15634
|
async function applyShadow(trx, task, project, result, at) {
|
|
@@ -15526,6 +15649,11 @@ async function applyShadow(trx, task, project, result, at) {
|
|
|
15526
15649
|
}
|
|
15527
15650
|
async function applyOn(trx, task, read, result, ctx) {
|
|
15528
15651
|
const { at, config } = ctx;
|
|
15652
|
+
const failed = read.pending?.state === "failed" ? read.pending : void 0;
|
|
15653
|
+
const voidFailed = async () => {
|
|
15654
|
+
if (failed === void 0) return;
|
|
15655
|
+
await trx.updateTable("submission").set({ voided_at: at.toISOString() }).where("id", "=", failed.id).execute();
|
|
15656
|
+
};
|
|
15529
15657
|
let current = task;
|
|
15530
15658
|
for (const move of result.moves) {
|
|
15531
15659
|
if (indexOf(move.to) < indexOf(move.from)) {
|
|
@@ -15560,6 +15688,8 @@ async function applyOn(trx, task, read, result, ctx) {
|
|
|
15560
15688
|
const turn = result.turn;
|
|
15561
15689
|
if (turn === null) return;
|
|
15562
15690
|
if (result.voids !== void 0) await voidColumns(trx, current.id, [result.voids], at);
|
|
15691
|
+
const handedBack = turn.kind === "after_submit" || turn.kind === "entry" ? failed : void 0;
|
|
15692
|
+
if (handedBack !== void 0) await voidFailed();
|
|
15563
15693
|
const replaced = turn.kind === "reroute" ? read.unclosed : void 0;
|
|
15564
15694
|
if (replaced !== void 0) await closeTurns(trx, {
|
|
15565
15695
|
taskId: current.id,
|
|
@@ -15568,15 +15698,36 @@ async function applyOn(trx, task, read, result, ctx) {
|
|
|
15568
15698
|
});
|
|
15569
15699
|
const carried = replaced === void 0 ? [] : turnHanded(replaced);
|
|
15570
15700
|
const handed = [...carried, ...read.handed.filter((entry) => !carried.some((old) => sameHanded(old, entry)))];
|
|
15701
|
+
const reason = read.mergedOpen === void 0 || turn.kind === "reroute" ? turnReason(turn, replaced?.reason) : `${turnReason(turn)} (PR ${read.mergedOpen.repo}#${String(read.mergedOpen.number)} merged, ticket still open)`;
|
|
15571
15702
|
await openTurn(trx, {
|
|
15572
15703
|
task: current,
|
|
15573
|
-
reason:
|
|
15704
|
+
reason: handedBack === void 0 ? reason : `${reason} (submit of ${handedBack.sha.slice(0, 7)}: ${handedBack.failure})`,
|
|
15574
15705
|
handed: current.column === "dev" ? handed : [],
|
|
15575
15706
|
at,
|
|
15576
15707
|
config
|
|
15577
15708
|
});
|
|
15578
15709
|
}
|
|
15579
15710
|
/**
|
|
15711
|
+
* Voids a pending submit whose PR merged at another head and journals it; it opens no turn, as
|
|
15712
|
+
* the merge decides the task (a ticket left open sends it back to Dev on its own).
|
|
15713
|
+
*/
|
|
15714
|
+
async function supersedeSubmit(trx, task, pending, at) {
|
|
15715
|
+
const row = await trx.updateTable("submission").set({ voided_at: at.toISOString() }).where("id", "=", pending.id).returning("column").executeTakeFirstOrThrow();
|
|
15716
|
+
await emit(trx, "task_submitted", task.project, task.id, at.toISOString(), {
|
|
15717
|
+
column: row.column,
|
|
15718
|
+
sha: pending.sha,
|
|
15719
|
+
supersededByMerge: pending.head
|
|
15720
|
+
});
|
|
15721
|
+
}
|
|
15722
|
+
/** Counts a pending submit a poll confirmed: from its receipt time, on the linked PR. */
|
|
15723
|
+
async function confirmSubmit(trx, pending) {
|
|
15724
|
+
await trx.updateTable("submission").set((eb) => ({
|
|
15725
|
+
pending_until: null,
|
|
15726
|
+
pr_repo: eb.fn.coalesce("pr_repo", eb.val(pending.pr.repo)),
|
|
15727
|
+
pr_number: eb.fn.coalesce("pr_number", eb.val(pending.pr.number))
|
|
15728
|
+
})).where("id", "=", pending.id).execute();
|
|
15729
|
+
}
|
|
15730
|
+
/**
|
|
15580
15731
|
* Re-evaluates the gates of each task and applies the cascade: in `on` mode it moves the column
|
|
15581
15732
|
* and opens turns, in `shadow` it moves only the shadow column. Archived tasks and tasks of
|
|
15582
15733
|
* unconfigured projects are skipped; a task with a missing or unreadable snapshot is held.
|
|
@@ -15590,8 +15741,11 @@ async function dispatchTasks(trx, taskIds, ctx) {
|
|
|
15590
15741
|
const project = ctx.config.projects.find((entry) => entry.id === task.project);
|
|
15591
15742
|
if (project === void 0) continue;
|
|
15592
15743
|
const mode = project.dispatcher.mode;
|
|
15593
|
-
const read = await readInput(trx, task, project, mode, blind, ctx.config);
|
|
15594
|
-
if (read === null
|
|
15744
|
+
const read = await readInput(trx, task, project, mode, blind, ctx.config, ctx);
|
|
15745
|
+
if (read === null) continue;
|
|
15746
|
+
if (read.pending?.state === "superseded") await supersedeSubmit(trx, task, read.pending, ctx.at);
|
|
15747
|
+
if (read.ticketUnconfirmed) continue;
|
|
15748
|
+
if (read.pending?.state === "confirmed") await confirmSubmit(trx, read.pending);
|
|
15595
15749
|
const result = dispatch(read.input);
|
|
15596
15750
|
if (mode === "shadow") await applyShadow(trx, task, project, result, ctx.at);
|
|
15597
15751
|
else await applyOn(trx, task, read, result, ctx);
|
|
@@ -15616,6 +15770,18 @@ async function dispatchJournaled(trx, ctx) {
|
|
|
15616
15770
|
}).onConflict((oc) => oc.column("key").doUpdateSet({ value })).execute();
|
|
15617
15771
|
}
|
|
15618
15772
|
/**
|
|
15773
|
+
* Evaluates the tasks of `on`-mode projects whose current visit has an unvoided pending submit:
|
|
15774
|
+
* its bound passes and a poll confirms it without a journal entry. A still-pending task gets no
|
|
15775
|
+
* write.
|
|
15776
|
+
*/
|
|
15777
|
+
async function dispatchPendingSubmits(trx, ctx) {
|
|
15778
|
+
const projects = ctx.config.projects.filter((project) => project.dispatcher.mode === "on").map((project) => project.id);
|
|
15779
|
+
if (projects.length === 0) return;
|
|
15780
|
+
const tasks = await trx.selectFrom("task").innerJoin("submission", (join) => join.onRef("submission.task_id", "=", "task.id").onRef("submission.column", "=", "task.column").onRef("submission.epoch", "=", "task.column_epoch")).select("task.id").distinct().where("task.project", "in", projects).where("task.membership", "!=", "archived").where("submission.voided_at", "is", null).where("submission.pending_until", "is not", null).execute();
|
|
15781
|
+
if (tasks.length === 0) return;
|
|
15782
|
+
await dispatchTasks(trx, tasks.map((task) => task.id), ctx);
|
|
15783
|
+
}
|
|
15784
|
+
/**
|
|
15619
15785
|
* Evaluates every non-archived task of the source's project, or of every project for `spur`: on
|
|
15620
15786
|
* the source's first complete poll since start and when it recovers from blindness.
|
|
15621
15787
|
*/
|
|
@@ -15742,12 +15908,19 @@ function shadowSummary(kind, payloadText) {
|
|
|
15742
15908
|
return null;
|
|
15743
15909
|
}
|
|
15744
15910
|
}
|
|
15745
|
-
/**
|
|
15911
|
+
/**
|
|
15912
|
+
* The summary of a submit whose head the board's newest poll confirmed, that waits for one, or
|
|
15913
|
+
* that a merge at another head superseded.
|
|
15914
|
+
*/
|
|
15746
15915
|
function submitSummary(kind, payloadText) {
|
|
15747
15916
|
if (kind !== "task_submitted") return null;
|
|
15748
15917
|
try {
|
|
15749
15918
|
const payload = eventPayloadSchemas[kind].safeParse(JSON.parse(payloadText));
|
|
15750
|
-
|
|
15919
|
+
if (!payload.success) return null;
|
|
15920
|
+
const merged = payload.data.supersededByMerge;
|
|
15921
|
+
if (merged !== void 0) return `Submit of ${payload.data.sha.slice(0, 7)} superseded: PR merged at ${merged.slice(0, 7)}`;
|
|
15922
|
+
if (payload.data.pending === true) return "Turn submitted, pending confirmation";
|
|
15923
|
+
return payload.data.confirmedByPoll === true ? "Turn submitted on the head of the last poll" : null;
|
|
15751
15924
|
} catch {
|
|
15752
15925
|
return null;
|
|
15753
15926
|
}
|
|
@@ -15786,7 +15959,7 @@ function turnView(turn, key) {
|
|
|
15786
15959
|
};
|
|
15787
15960
|
}
|
|
15788
15961
|
function createTaskQueries(deps) {
|
|
15789
|
-
const { config, completeSince } = deps;
|
|
15962
|
+
const { config, clock, completeSince } = deps;
|
|
15790
15963
|
const taskKey = (key) => {
|
|
15791
15964
|
const parsed = parseRef$1(key, "task");
|
|
15792
15965
|
return parsed.ok && parsed.value.kind === "task" && parsed.value.form === "github-short" ? canonicalKey(config, key).key : key;
|
|
@@ -15816,7 +15989,10 @@ function createTaskQueries(deps) {
|
|
|
15816
15989
|
const read = await readInput(trx, {
|
|
15817
15990
|
...task,
|
|
15818
15991
|
column
|
|
15819
|
-
}, project, mode, await blindSources(trx, completeSince), config
|
|
15992
|
+
}, project, mode, await blindSources(trx, completeSince), config, {
|
|
15993
|
+
at: new Date(clock.now()),
|
|
15994
|
+
complete: completeSince
|
|
15995
|
+
});
|
|
15820
15996
|
if (read === null) return {
|
|
15821
15997
|
...shared,
|
|
15822
15998
|
dispatcher: mode,
|
|
@@ -15835,11 +16011,17 @@ function createTaskQueries(deps) {
|
|
|
15835
16011
|
}));
|
|
15836
16012
|
const holds = [...dispatchHolds(read.input), ...read.ticketUnconfirmed ? ["ticket_unconfirmed"] : []].sort((left, right) => TASK_HOLDS.indexOf(left) - TASK_HOLDS.indexOf(right));
|
|
15837
16013
|
const heldBy = holds.includes("cycle_limit") ? await holdBlocks(trx, task.id) : [];
|
|
16014
|
+
const pending = read.pending?.state === "pending" ? read.pending : void 0;
|
|
15838
16015
|
return {
|
|
15839
16016
|
...shared,
|
|
15840
16017
|
dispatcher: mode,
|
|
15841
16018
|
holds,
|
|
15842
16019
|
...heldBy.length === 0 ? {} : { heldBy },
|
|
16020
|
+
...pending === void 0 ? {} : { pendingSubmit: {
|
|
16021
|
+
sha: pending.sha,
|
|
16022
|
+
until: pending.until,
|
|
16023
|
+
text: `submit pending confirmation of ${pending.sha.slice(0, 7)}`
|
|
16024
|
+
} },
|
|
15843
16025
|
gates,
|
|
15844
16026
|
checksWaivedBy,
|
|
15845
16027
|
...waiting.length === 0 ? {} : { waiting }
|
|
@@ -16105,25 +16287,37 @@ function pollErrorHint(error, pr) {
|
|
|
16105
16287
|
function pollMayConfirm(error) {
|
|
16106
16288
|
return error.kind === "timeout" || error.kind === "failed" && (error.adapterKind === "transient" || error.adapterKind === "unexpected" || error.adapterKind === "throttled");
|
|
16107
16289
|
}
|
|
16290
|
+
/** A failed poll that waiting can fix, beyond `pollMayConfirm`: a stale source, a stopped poller. */
|
|
16291
|
+
function submitAgain(error) {
|
|
16292
|
+
return error.kind === "blind" && error.reason === "stale" || error.kind === "stopped";
|
|
16293
|
+
}
|
|
16108
16294
|
/**
|
|
16109
16295
|
* How the PR head behind a submit is confirmed: `live` by this call's poll, `poll` by the
|
|
16110
16296
|
* board's newest poll when GitHub did not answer. Throws `head_mismatch` when the confirmed head
|
|
16111
|
-
* is not `sha`, `github_unavailable` when nothing confirms it.
|
|
16297
|
+
* is not `sha`, `github_unavailable` when nothing confirms it. With `allowPending` (turn
|
|
16298
|
+
* submits), a result a later poll can settle is `pending` instead of `github_unavailable`.
|
|
16112
16299
|
*/
|
|
16113
16300
|
function confirmHead(input) {
|
|
16114
|
-
const { prepared, pr, sha, snapshot, completeAt } = input;
|
|
16301
|
+
const { prepared, pr, sha, snapshot, completeAt, allowPending } = input;
|
|
16115
16302
|
const label = `${pr.repo}#${String(pr.number)}`;
|
|
16116
16303
|
const unavailable = (hint) => new CommandError("github_unavailable", hint);
|
|
16117
|
-
|
|
16304
|
+
const waitable = (hint) => {
|
|
16305
|
+
if (allowPending) return "pending";
|
|
16306
|
+
throw unavailable(hint);
|
|
16307
|
+
};
|
|
16308
|
+
if (prepared?.kind !== "polled" || prepared.repo !== pr.repo.toLowerCase() || prepared.number !== pr.number) return waitable(`The board did not poll ${label} for this call; submit again.`);
|
|
16118
16309
|
const { result } = prepared;
|
|
16119
16310
|
if (result === null) throw unavailable(`This daemon runs no GitHub poller; ${noRepeat("check the daemon")}`);
|
|
16120
16311
|
if (!result.ok) {
|
|
16121
16312
|
const hint = pollErrorHint(result.error, label);
|
|
16122
|
-
if (!pollMayConfirm(result.error))
|
|
16123
|
-
|
|
16124
|
-
|
|
16125
|
-
|
|
16126
|
-
if (
|
|
16313
|
+
if (!pollMayConfirm(result.error)) {
|
|
16314
|
+
if (submitAgain(result.error)) return waitable(hint);
|
|
16315
|
+
throw unavailable(hint);
|
|
16316
|
+
}
|
|
16317
|
+
if (completeAt === void 0) return waitable(`${hint} The board has had no complete GitHub poll since it started.`);
|
|
16318
|
+
if (snapshot === void 0) return waitable(`${hint} The board has not seen the head of ${label} yet.`);
|
|
16319
|
+
if (Date.parse(snapshot.observed_at) < Date.parse(completeAt)) return waitable(`${hint} The board last saw head ${snapshot.head_sha} at ${snapshot.observed_at}, before its last complete GitHub poll.`);
|
|
16320
|
+
if (snapshot.head_sha.toLowerCase() !== sha) return waitable(`${hint} Its last poll saw head ${snapshot.head_sha}.`);
|
|
16127
16321
|
return "poll";
|
|
16128
16322
|
}
|
|
16129
16323
|
if (result.value.status !== "ok") throw unavailable(`GitHub answered ${result.value.status} for ${label}; ${noRepeat("check the board's GitHub access")}`);
|
|
@@ -16149,20 +16343,26 @@ async function pollTaskPr(db, task, poll) {
|
|
|
16149
16343
|
}
|
|
16150
16344
|
/**
|
|
16151
16345
|
* Records the submit of `sha` for the task's `column` visit `epoch` and says how its head was
|
|
16152
|
-
* confirmed (`confirmHead`). Throws `head_mismatch` or `github_unavailable` otherwise.
|
|
16346
|
+
* confirmed (`confirmHead`). Throws `head_mismatch` or `github_unavailable` otherwise. With
|
|
16347
|
+
* `pendingMs` (turn submits: the project's `submitConfirmMs`), a task with no PR or a head a later
|
|
16348
|
+
* poll can confirm records a pending row with `pending_until = at + pendingMs`.
|
|
16153
16349
|
*/
|
|
16154
|
-
async function insertSubmission(trx, input, ctx, completeSince) {
|
|
16350
|
+
async function insertSubmission(trx, input, ctx, completeSince, pendingMs) {
|
|
16155
16351
|
const { task, column, epoch, sha } = input;
|
|
16156
16352
|
const pr = await taskPr(trx, task.id);
|
|
16157
|
-
if (pr === null) 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.");
|
|
16158
|
-
|
|
16159
|
-
|
|
16160
|
-
|
|
16161
|
-
|
|
16162
|
-
|
|
16163
|
-
|
|
16164
|
-
|
|
16165
|
-
|
|
16353
|
+
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.");
|
|
16354
|
+
let confirmed = "pending";
|
|
16355
|
+
if (pr !== null) {
|
|
16356
|
+
const snapshot = await trx.selectFrom("pr_snapshot").select(["head_sha", "observed_at"]).where(sql`lower(repo) = ${pr.repo.toLowerCase()}`).where("number", "=", pr.number).executeTakeFirst();
|
|
16357
|
+
confirmed = confirmHead({
|
|
16358
|
+
prepared: ctx.prepared,
|
|
16359
|
+
pr,
|
|
16360
|
+
sha,
|
|
16361
|
+
snapshot,
|
|
16362
|
+
completeAt: completeSince.get(prSourceId(task.project, pr.repo)),
|
|
16363
|
+
allowPending: pendingMs !== void 0
|
|
16364
|
+
});
|
|
16365
|
+
}
|
|
16166
16366
|
await trx.insertInto("submission").values({
|
|
16167
16367
|
task_id: task.id,
|
|
16168
16368
|
column,
|
|
@@ -16171,13 +16371,18 @@ async function insertSubmission(trx, input, ctx, completeSince) {
|
|
|
16171
16371
|
author: ctx.actor,
|
|
16172
16372
|
submitted_at: ctx.at,
|
|
16173
16373
|
note: null,
|
|
16174
|
-
pr_repo: pr
|
|
16175
|
-
pr_number: pr
|
|
16374
|
+
pr_repo: pr?.repo ?? null,
|
|
16375
|
+
pr_number: pr?.number ?? null,
|
|
16376
|
+
pending_until: confirmed === "pending" && pendingMs !== void 0 ? new Date(Date.parse(ctx.at) + pendingMs).toISOString() : null
|
|
16176
16377
|
}).execute();
|
|
16177
16378
|
return confirmed;
|
|
16178
16379
|
}
|
|
16179
|
-
/** The `task_submitted` payload mark of a head confirmed by the board's last poll. */
|
|
16180
|
-
const
|
|
16380
|
+
/** The `task_submitted` payload mark of a head confirmed by the board's last poll, or pending. */
|
|
16381
|
+
const CONFIRMATION = {
|
|
16382
|
+
live: {},
|
|
16383
|
+
poll: { confirmedByPoll: true },
|
|
16384
|
+
pending: { pending: true }
|
|
16385
|
+
};
|
|
16181
16386
|
/**
|
|
16182
16387
|
* The executor's submit and return of a turn it took, the turnless shadow submit, and the
|
|
16183
16388
|
* operator's column correction.
|
|
@@ -16208,12 +16413,13 @@ function createTurnMutations(deps) {
|
|
|
16208
16413
|
await emit(trx, "task_submitted", task.project, task.id, ctx.at, {
|
|
16209
16414
|
column,
|
|
16210
16415
|
sha: input.sha,
|
|
16211
|
-
...
|
|
16416
|
+
...CONFIRMATION[confirmed]
|
|
16212
16417
|
}, ctx.actor);
|
|
16213
16418
|
return {
|
|
16214
16419
|
task: taskView(await dispatched(trx, task.id, ctx.at)),
|
|
16215
16420
|
turn: null,
|
|
16216
|
-
sha: input.sha
|
|
16421
|
+
sha: input.sha,
|
|
16422
|
+
status: "confirmed"
|
|
16217
16423
|
};
|
|
16218
16424
|
}
|
|
16219
16425
|
return {
|
|
@@ -16240,7 +16446,7 @@ function createTurnMutations(deps) {
|
|
|
16240
16446
|
column: turn.column,
|
|
16241
16447
|
epoch: turn.epoch,
|
|
16242
16448
|
sha: input.sha
|
|
16243
|
-
}, ctx, completeSince);
|
|
16449
|
+
}, ctx, completeSince, config.projects.find((entry) => entry.id === task.project)?.dispatcher.submitConfirmMs);
|
|
16244
16450
|
await closeTurns(trx, {
|
|
16245
16451
|
taskId: task.id,
|
|
16246
16452
|
reason: "submitted",
|
|
@@ -16250,12 +16456,13 @@ function createTurnMutations(deps) {
|
|
|
16250
16456
|
turn: input.turn,
|
|
16251
16457
|
column: turn.column,
|
|
16252
16458
|
sha: input.sha,
|
|
16253
|
-
...
|
|
16459
|
+
...CONFIRMATION[confirmed]
|
|
16254
16460
|
}, ctx.actor);
|
|
16255
16461
|
return {
|
|
16256
16462
|
task: taskView(await dispatched(trx, task.id, ctx.at)),
|
|
16257
16463
|
turn: input.turn,
|
|
16258
|
-
sha: input.sha
|
|
16464
|
+
sha: input.sha,
|
|
16465
|
+
status: confirmed === "pending" ? "pending" : "confirmed"
|
|
16259
16466
|
};
|
|
16260
16467
|
}
|
|
16261
16468
|
},
|
|
@@ -16330,6 +16537,7 @@ function createOperationRegistry(deps) {
|
|
|
16330
16537
|
const blocks = createBlockMutations(config);
|
|
16331
16538
|
const taskQueries = createTaskQueries({
|
|
16332
16539
|
config,
|
|
16540
|
+
clock,
|
|
16333
16541
|
completeSince,
|
|
16334
16542
|
prPoller: deps.prPoller
|
|
16335
16543
|
});
|
|
@@ -17420,6 +17628,11 @@ async function tickBoard(deps) {
|
|
|
17420
17628
|
at: new Date(now),
|
|
17421
17629
|
complete: completeSince
|
|
17422
17630
|
});
|
|
17631
|
+
await dispatchPendingSubmits(trx, {
|
|
17632
|
+
config,
|
|
17633
|
+
at: new Date(now),
|
|
17634
|
+
complete: completeSince
|
|
17635
|
+
});
|
|
17423
17636
|
await remindStuckTurns(trx, config, new Date(now));
|
|
17424
17637
|
await reconcileItems(trx, config, now, completeSince.has("spur"), deps.warnSkipped);
|
|
17425
17638
|
});
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as renderMcpError, X as ERRORS, y as OPERATIONS } from "./chunk-
|
|
2
|
-
import { o as CliError, r as requestOperation } from "./chunk-
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-
|
|
1
|
+
import { C as renderMcpError, X as ERRORS, y as OPERATIONS } from "./chunk-C2Q6FYcu.mjs";
|
|
2
|
+
import { o as CliError, r as requestOperation } from "./chunk-OVqHRmrz.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-TFUh3jZ2.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
-- A turn submit the board accepted before it could confirm the head waits for a later poll.
|
|
2
|
+
-- pending_until is the ISO-8601 UTC deadline for a PR to appear; NULL means not pending, which is
|
|
3
|
+
-- every row recorded before this migration and every submit whose head was confirmed. The board
|
|
4
|
+
-- clears it when a poll confirms the head and voids the row when it hands the turn back.
|
|
5
|
+
-- A null pr_repo / pr_number, which 0014 reserved for a submit recorded before it, now also marks
|
|
6
|
+
-- a pending submit made before the board linked a PR; confirmation fills them in.
|
|
7
|
+
ALTER TABLE submission ADD COLUMN pending_until TEXT;
|
package/package.json
CHANGED
|
@@ -147,7 +147,7 @@ Other errors: `wrong_id_kind`, `not_found`, `block_not_open`, `task_archived`, `
|
|
|
147
147
|
|
|
148
148
|
### `board submit`
|
|
149
149
|
|
|
150
|
-
Purpose: Submit the
|
|
150
|
+
Purpose: Submit the task's pull request head for a turn this session took; the turn closes; a pending result is final.
|
|
151
151
|
Arguments: `<turn>`, `<sha>`.
|
|
152
152
|
Flags: `--key <key>`, `--json`.
|
|
153
153
|
Use when: 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.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
- `not_found`: Check the ID with `board status` or `board task <KEY>`.
|
|
15
15
|
- `wrong_id_kind`: Pass the ID kind the operation expects, e.g. B<n> for a block or a task key for a task.
|
|
16
|
-
- `github_unavailable`:
|
|
16
|
+
- `github_unavailable`: Follow the message: ask the operator to fix what it names, or retry a read or link once GitHub answers the board's polls; repeat a submit only by task key in shadow mode.
|
|
17
17
|
- `stale_comment_revision`: Read the latest comment revision, then acknowledge that revision.
|
|
18
18
|
- `idempotency_key_mismatch`: Use a new key for a new command, or repeat the earlier input with the same key.
|
|
19
19
|
- `task_archived`: Ask an operator to add the task to the board again if work continues.
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
- `wrong_block_type`: Read the block type with `board task <KEY>` and use the operation for that type.
|
|
22
22
|
- `turn_closed`: Read your open turns with `board inbox` and act only on a turn listed there.
|
|
23
23
|
- `not_turn_taker`: Take the turn with `board inbox ack` first; only the session that took it can submit or return it.
|
|
24
|
-
- `head_mismatch`: Push the commit to the task's pull request branch and submit
|
|
24
|
+
- `head_mismatch`: Push the commit to the task's pull request branch and submit the head GitHub shows.
|
|
25
25
|
- `return_not_allowed`: In Dev, ask with `board ask` instead.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# How the Board works
|
|
2
2
|
|
|
3
3
|
Start with `board task <task> --why`: it explains the gates, holds, open turn and
|
|
4
|
-
last moves behind the task's position.
|
|
4
|
+
last moves behind the task's position.
|
|
5
5
|
|
|
6
6
|
## Columns and executors
|
|
7
7
|
|
|
8
8
|
The fixed order is `todo`, `ready-for-dev`, `dev`, `review`, `product-review`,
|
|
9
9
|
`external-review`, `qa`, `ready-to-merge`, `done`.
|
|
10
|
-
`projects[].columns[].enabled`
|
|
11
|
-
and Done must stay enabled.
|
|
10
|
+
`projects[].columns[].enabled` false, or omitting an optional column, skips it and
|
|
11
|
+
its gate; To Do, Dev and Done must stay enabled.
|
|
12
12
|
|
|
13
13
|
Each column has one executor, selected by `projects[].columns[].orchestrator`:
|
|
14
14
|
`none` uses the task's live worker, falling back to the operator; `operator` uses
|
|
@@ -59,6 +59,9 @@ with keyed `board inbox ack <entries>`. Only the acknowledging session may submi
|
|
|
59
59
|
or return it: keyed `board submit <turn> <sha>` accepts the head, and keyed
|
|
60
60
|
`board return <turn> <reason>` sends findings back to Dev. A worker submits a fresh
|
|
61
61
|
PR head after pushing. In shadow mode, use keyed `board submit <task> <sha>`.
|
|
62
|
+
An unseen head answers `pending`: that submit is final,
|
|
63
|
+
so do not resubmit or raise a block; the Board confirms it or hands the turn back
|
|
64
|
+
(`projects[].dispatcher.submitConfirmMs`).
|
|
62
65
|
|
|
63
66
|
A new head closes taken turns outside Dev; a taken Dev turn survives the worker's
|
|
64
67
|
push so that worker can submit it. An unacknowledged turn does not hold back a
|
|
@@ -111,8 +114,8 @@ ID). Role addresses follow the current session filling the role.
|
|
|
111
114
|
|
|
112
115
|
## Slack now
|
|
113
116
|
|
|
114
|
-
`slack.channels.feed` carries summaries
|
|
115
|
-
items,
|
|
117
|
+
`slack.channels.feed` carries summaries like curator answers and operator
|
|
118
|
+
items, except items shown elsewhere and delivery problems.
|
|
116
119
|
`slack.channels.orchestrators` carries block threads addressed to the operator by
|
|
117
120
|
someone else. Answer in the existing block thread to preserve its task context.
|
|
118
121
|
|