spur-board 0.136.0 → 0.138.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-ssUCRu8d.mjs → chunk-BZqvZUqX.mjs} +2 -2
- package/dist/{chunk-CEGynnHg.mjs → chunk-CDsQwru1.mjs} +1 -1
- package/dist/{chunk-CRtgKvgx.mjs → chunk-ELGKyFVI.mjs} +167 -15
- package/dist/cli.mjs +3 -3
- package/dist/client.mjs +1 -1
- package/dist/daemon.mjs +561 -81
- package/dist/mcp.mjs +3 -3
- package/dist/migrations/0028_source_mirror.sql +6 -0
- package/dist/web/assets/index-DOLk88Lg.js +64 -0
- package/dist/web/assets/index-DvNi81Mg.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/skills/spur-board/references/how-board-works-columns.md +15 -14
- package/skills/spur-board/references/how-board-works-history.md +16 -15
- package/skills/spur-board/references/how-board-works-web.md +1 -1
- package/skills/spur-board/references/how-board-works.md +4 -4
- package/skills/spur-board/references/web-ui-board.md +6 -0
- package/skills/spur-board/references/web-ui.md +3 -3
- package/dist/web/assets/index-D5kusio6.css +0 -1
- package/dist/web/assets/index-QJ-oMVfK.js +0 -64
package/dist/daemon.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as sessionFactsSchema, A as eventPayloadSchemas, At as COLUMNS, B as sourceCursorSchema, C as messageRefSchema, Ct as configBindings, D as sortSkillFiles, Dt as readyMirrorOf, E as skillReloadFilesSchema, Et as plainHttpAllowed, F as defaultBranchFactSchema, Ft as SLACK_BOT_SCOPES, G as SESSION_HEALTH_STATES, H as PR_STATES, I as entityRefSchema, It as TASK_HOLDS, J as parseRingMarker, K as SESSION_STATUSES, L as mirrorSourceId, Lt as TODO_GROUP_COLUMN_IDS, M as MIRROR_FAILURES, Mt as COLUMN_IDS, N as MIRROR_FAILURE_CODES, Nt as DISPATCHER_MODES, O as EVENT_KINDS, Ot as requiredSecretKeys, P as batchSchema, Pt as ITEM_KINDS, Q as ringMarker, R as prSourceId, Rt as VIAS, S as interactionRefSchema, St as columnTurnTimings, Tt as defaultAddressee, U as REVIEW_DECISIONS, V as trackerSourceId, W as REVIEW_STATES, X as prRefSchema, Y as prFactsSchema, Z as prReviewRuleSchema, _t as DEFAULT_SLACK_COMMAND, a as requestHashOf, at as errorCodeOf, b as conversationRefSchema, bt as approvalRuleOf, c as tokenRequestStatusSchema, ct as ERRORS, d as buildCatalogSnapshot, et as ticketFactsSchema, f as roleCanUseOperation, ft as ok, g as renderHttpProblem, h as turnHandedSchema, ht as DEFAULT_LINK, i as TOKEN_REQUEST_LIMITS, it as encodeActorId, j as AdapterError, jt as COLUMN_GROUPS, k as GATE_REASONS, kt as resolveWebOrigin, l as BOARD_TICK_MS, lt as err, m as defaultBranchViewSchema, n as doctorReportSchema, nt as REF_NUMBER, o as tokenRequestResultSchema, ot as parseActorId, p as OPERATIONS, pt as successEnvelopeSchema, q as isExternalAuthor, rt as actorIdSchema, s as tokenRequestSchema, st as parseRef$1, t as assertNever, tt as JIRA_PROJECT_KEY, w as userIdSchema, wt as configSchema, x as inboundEventSchema, xt as boardWideSpurProject, y as SPACE_IDS, yt as RESERVED_PROJECT, z as sessionTransitionSchema, zt as isTodoGroupColumn } from "./chunk-ELGKyFVI.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";
|
|
@@ -8133,7 +8133,7 @@ function parseDefaultBranch(text) {
|
|
|
8133
8133
|
}
|
|
8134
8134
|
/** The project whose tracker or repo source wrote an observation. */
|
|
8135
8135
|
function projectForSource(config, source) {
|
|
8136
|
-
return config.projects.find((project) => source === trackerSourceId(project) || project.repos.some((repo) => source === prSourceId(project.id, repo)));
|
|
8136
|
+
return config.projects.find((project) => source === trackerSourceId(project) || source === mirrorSourceId(project) || project.repos.some((repo) => source === prSourceId(project.id, repo)));
|
|
8137
8137
|
}
|
|
8138
8138
|
/** The one project whose tracker takes `key` by its form: Jira for `ABC-1`, GitHub for `#`. */
|
|
8139
8139
|
function projectForKey(config, key) {
|
|
@@ -8223,7 +8223,8 @@ const MOVE_KINDS = [
|
|
|
8223
8223
|
"task_moved",
|
|
8224
8224
|
"task_shadow_moved",
|
|
8225
8225
|
"task_corrected",
|
|
8226
|
-
"task_manually_moved"
|
|
8226
|
+
"task_manually_moved",
|
|
8227
|
+
"task_mirror_moved"
|
|
8227
8228
|
];
|
|
8228
8229
|
function moveView(row) {
|
|
8229
8230
|
const base = {
|
|
@@ -8244,6 +8245,20 @@ function moveView(row) {
|
|
|
8244
8245
|
text: parsed.data.reason
|
|
8245
8246
|
};
|
|
8246
8247
|
}
|
|
8248
|
+
if (row.kind === "task_mirror_moved") {
|
|
8249
|
+
const parsed = eventPayloadSchemas.task_mirror_moved.safeParse(payload);
|
|
8250
|
+
if (!parsed.success) return null;
|
|
8251
|
+
const { from, to, source } = parsed.data;
|
|
8252
|
+
return {
|
|
8253
|
+
...base,
|
|
8254
|
+
kind: row.kind,
|
|
8255
|
+
from,
|
|
8256
|
+
to,
|
|
8257
|
+
reason: "mirrored",
|
|
8258
|
+
gate: [],
|
|
8259
|
+
text: source
|
|
8260
|
+
};
|
|
8261
|
+
}
|
|
8247
8262
|
if (row.kind === "task_corrected") {
|
|
8248
8263
|
const parsed = eventPayloadSchemas.task_corrected.safeParse(payload);
|
|
8249
8264
|
if (!parsed.success) return null;
|
|
@@ -13489,6 +13504,30 @@ function workStarted(input) {
|
|
|
13489
13504
|
const workerLive = input.liveWorker && !input.spurBlind;
|
|
13490
13505
|
return input.openPr || !input.reopened && workerLive;
|
|
13491
13506
|
}
|
|
13507
|
+
/**
|
|
13508
|
+
* Where a GitHub Project mirror puts the task, or null to leave it. For an idle task whose real
|
|
13509
|
+
* column is To Do or Ready for Dev, the Project's readiness picks the target: `ready` is Ready for
|
|
13510
|
+
* Dev, `not_ready` is To Do. The real column goes to the target, and so does a shadow column in
|
|
13511
|
+
* To Do or Ready for Dev, even when the real column is already there. A shadow column anywhere
|
|
13512
|
+
* else (Triage, Dev and right of it) stays. A null shadow column stays null, unless the real
|
|
13513
|
+
* column moves in shadow mode. `unknown` (no complete read, or the task missing from it), started
|
|
13514
|
+
* work and every other real column stay put.
|
|
13515
|
+
*/
|
|
13516
|
+
function mirrorPlacement(input) {
|
|
13517
|
+
if (input.workStarted || input.readiness === "unknown") return null;
|
|
13518
|
+
if (!isMirrored(input.column)) return null;
|
|
13519
|
+
const target = input.readiness === "ready" ? "ready-for-dev" : "todo";
|
|
13520
|
+
const moved = input.column !== target;
|
|
13521
|
+
const shadowColumn = input.shadowColumn === null ? moved && input.shadowMode ? target : null : isMirrored(input.shadowColumn) ? target : input.shadowColumn;
|
|
13522
|
+
if (!moved && shadowColumn === input.shadowColumn) return null;
|
|
13523
|
+
return {
|
|
13524
|
+
column: target,
|
|
13525
|
+
shadowColumn
|
|
13526
|
+
};
|
|
13527
|
+
}
|
|
13528
|
+
function isMirrored(column) {
|
|
13529
|
+
return column === "todo" || column === "ready-for-dev";
|
|
13530
|
+
}
|
|
13492
13531
|
function ticketFinished(input) {
|
|
13493
13532
|
return input.ticketDone && !input.hasOpenLinkedPr && !input.liveWorker;
|
|
13494
13533
|
}
|
|
@@ -14194,7 +14233,7 @@ async function readStatusColumnEntries(db, projectIds, taskId) {
|
|
|
14194
14233
|
entry.kind = 'task_added' AND entry.at = task.created_at AND json_extract(entry.payload, '$.column') = task.column AND entry.id = (
|
|
14195
14234
|
SELECT MIN(original.id) FROM event original WHERE original.task_id = task.id AND original.kind = 'task_added'
|
|
14196
14235
|
)
|
|
14197
|
-
))`).where(sql`(entry.kind in ('task_added', 'task_moved', 'task_manually_moved') or (entry.kind = 'task_corrected' and json_extract(entry.payload, '$.shadow') = 0))`).groupBy("entry.task_id").as("latest"), (join) => join.onRef("latest.id", "=", "event.id")).select([
|
|
14236
|
+
))`).where(sql`(entry.kind in ('task_added', 'task_moved', 'task_manually_moved') or (entry.kind = 'task_mirror_moved' and json_extract(entry.payload, '$.shadow') is null) or (entry.kind = 'task_corrected' and json_extract(entry.payload, '$.shadow') = 0))`).groupBy("entry.task_id").as("latest"), (join) => join.onRef("latest.id", "=", "event.id")).select([
|
|
14198
14237
|
"event.task_id",
|
|
14199
14238
|
"event.at",
|
|
14200
14239
|
"event.id"
|
|
@@ -14203,7 +14242,7 @@ async function readStatusColumnEntries(db, projectIds, taskId) {
|
|
|
14203
14242
|
function sourceInterval(config, source) {
|
|
14204
14243
|
if (source === "spur") return config.adapters.spur.intervalMs;
|
|
14205
14244
|
if (source.startsWith("jira:")) return config.adapters.jira.intervalMs;
|
|
14206
|
-
if (source.startsWith("github-issues:")) return config.adapters.githubIssues.intervalMs;
|
|
14245
|
+
if (source.startsWith("github-issues:") || source.startsWith("github-project:")) return config.adapters.githubIssues.intervalMs;
|
|
14207
14246
|
return config.adapters.github.intervalMs;
|
|
14208
14247
|
}
|
|
14209
14248
|
/** Counts of each value, rendered as `<n> <value>` in the given order. */
|
|
@@ -14233,6 +14272,47 @@ function orderTodoGroupRows(rows, entries, projects) {
|
|
|
14233
14272
|
}
|
|
14234
14273
|
}
|
|
14235
14274
|
}
|
|
14275
|
+
/** A mirror source's stored failure; a code this version does not know reads as a failed read. */
|
|
14276
|
+
function storedFailure(row) {
|
|
14277
|
+
if (row?.failure_code == null) return null;
|
|
14278
|
+
const code = MIRROR_FAILURE_CODES.find((known) => known === row.failure_code) ?? "mirror_read_failed";
|
|
14279
|
+
const message = row.failure_message ?? "";
|
|
14280
|
+
return {
|
|
14281
|
+
code,
|
|
14282
|
+
message: message === "" ? MIRROR_FAILURES[code].meaning : message
|
|
14283
|
+
};
|
|
14284
|
+
}
|
|
14285
|
+
/**
|
|
14286
|
+
* One source's view in `status.get`, from its stored row and this run's maps. `config.get`
|
|
14287
|
+
* builds a mirror's view through it, so both reads judge its health alike.
|
|
14288
|
+
*/
|
|
14289
|
+
function sourceView(input) {
|
|
14290
|
+
const { source, row, config, now } = input;
|
|
14291
|
+
const last = row?.last_complete_at ?? null;
|
|
14292
|
+
const blindReason = row?.blind_reason === "auth" || row?.blind_reason === "config" || row?.blind_reason === "stale" ? row.blind_reason : null;
|
|
14293
|
+
return {
|
|
14294
|
+
source,
|
|
14295
|
+
project: projectForSource(config, source)?.id ?? null,
|
|
14296
|
+
...source.startsWith("github:") && {
|
|
14297
|
+
pointsLastHour: input.points.get(source) ?? 0,
|
|
14298
|
+
defaultBranch: parseDefaultBranch(row?.default_branch)
|
|
14299
|
+
},
|
|
14300
|
+
...source.startsWith("github-project:") && { failure: storedFailure(row) },
|
|
14301
|
+
observedAt: row?.observed_at ?? null,
|
|
14302
|
+
lastCompleteAt: last,
|
|
14303
|
+
blindReason,
|
|
14304
|
+
message: row?.blind_message ?? null,
|
|
14305
|
+
budget: row?.budget_remaining != null && row.budget_reset_at != null ? {
|
|
14306
|
+
remaining: row.budget_remaining,
|
|
14307
|
+
limit: row.budget_limit,
|
|
14308
|
+
resetAt: row.budget_reset_at
|
|
14309
|
+
} : null,
|
|
14310
|
+
waitsForBudget: input.budgetWaits?.has(source) ?? false,
|
|
14311
|
+
stale: last === null || now - Date.parse(last) > config.thresholds.staleMultiplier * sourceInterval(config, source),
|
|
14312
|
+
healthySince: input.healthySince?.get(source) ?? null,
|
|
14313
|
+
warmingUp: !input.completeSince.has(source)
|
|
14314
|
+
};
|
|
14315
|
+
}
|
|
14236
14316
|
// ../core/src/app/external-rounds.ts
|
|
14237
14317
|
/**
|
|
14238
14318
|
* While the task is in Dev with the dispatcher on and External Review's course check on, records
|
|
@@ -15788,26 +15868,36 @@ async function syncModes(trx, config, at) {
|
|
|
15788
15868
|
});
|
|
15789
15869
|
}
|
|
15790
15870
|
}
|
|
15791
|
-
/**
|
|
15792
|
-
async function
|
|
15793
|
-
|
|
15794
|
-
|
|
15795
|
-
|
|
15796
|
-
|
|
15797
|
-
const enabledGroup = (id) => TODO_GROUP_COLUMN_IDS.some((column) => column === id) && project?.columns.some((column) => column.id === id && column.enabled);
|
|
15798
|
-
if (!enabledGroup(task.column) || !enabledGroup(to)) throw new CommandError("move_outside_todo_group", `Pick enabled Todo-group columns in project ${task.project}.`);
|
|
15799
|
-
if (await trx.selectFrom("link").select("id").where("task_id", "=", taskId).where("entity", "=", "pr").where("banned", "=", 0).where("pr_open", "=", 1).where(pastReopenFloor).executeTakeFirst() !== void 0 || await linkedSession(trx, taskId, "worker") !== void 0) throw new CommandError("work_started", "Resolve the open pull request or live worker before moving idle work.");
|
|
15871
|
+
/** Whether work on the task started: an eligible open linked PR or a live linked worker. */
|
|
15872
|
+
async function workStartedOn(trx, taskId) {
|
|
15873
|
+
return await trx.selectFrom("link").select("id").where("task_id", "=", taskId).where("entity", "=", "pr").where("banned", "=", 0).where("pr_open", "=", 1).where(pastReopenFloor).executeTakeFirst() !== void 0 || await linkedSession(trx, taskId, "worker") !== void 0;
|
|
15874
|
+
}
|
|
15875
|
+
/** Put the task in a fresh visit of a Todo-group column and close its turns. */
|
|
15876
|
+
async function placeInTodoGroup(trx, task, project, to, at) {
|
|
15800
15877
|
await trx.updateTable("task").set({
|
|
15801
15878
|
column: to,
|
|
15802
15879
|
shadow_column: task.shadow_column === null && project?.dispatcher.mode !== "shadow" ? null : to,
|
|
15803
15880
|
column_epoch: task.column_epoch + 1,
|
|
15804
15881
|
last_change_at: taskChangeAt(at.toISOString())
|
|
15805
|
-
}).where("id", "=",
|
|
15882
|
+
}).where("id", "=", task.id).execute();
|
|
15806
15883
|
await closeTurns(trx, {
|
|
15807
|
-
taskId,
|
|
15884
|
+
taskId: task.id,
|
|
15808
15885
|
reason: "moved",
|
|
15809
15886
|
at
|
|
15810
15887
|
});
|
|
15888
|
+
}
|
|
15889
|
+
/** Place idle work in a fresh real-column visit after synchronizing dispatcher mode. */
|
|
15890
|
+
async function manuallyMoveColumn(trx, input) {
|
|
15891
|
+
const { taskId, to, at, actor, reason, config } = input;
|
|
15892
|
+
await syncModes(trx, config, at);
|
|
15893
|
+
const task = await trx.selectFrom("task").selectAll().where("id", "=", taskId).executeTakeFirstOrThrow();
|
|
15894
|
+
const project = config.projects.find((entry) => entry.id === task.project);
|
|
15895
|
+
const enabledGroup = (id) => TODO_GROUP_COLUMN_IDS.some((column) => column === id) && project?.columns.some((column) => column.id === id && column.enabled);
|
|
15896
|
+
if (!enabledGroup(task.column) || !enabledGroup(to)) throw new CommandError("move_outside_todo_group", `Pick enabled Todo-group columns in project ${task.project}.`);
|
|
15897
|
+
const mirror = project === void 0 ? void 0 : readyMirrorOf(project);
|
|
15898
|
+
if (mirror !== void 0 && (task.column === "ready-for-dev" || to === "ready-for-dev")) throw new CommandError("column_mirrored", `Change the status of ${task.key} in GitHub Project ${mirror.project} (${mirror.field}) instead.`);
|
|
15899
|
+
if (await workStartedOn(trx, taskId)) throw new CommandError("work_started", "Resolve the open pull request or live worker before moving idle work.");
|
|
15900
|
+
await placeInTodoGroup(trx, task, project, to, at);
|
|
15811
15901
|
await emit(trx, "task_manually_moved", task.project, taskId, at.toISOString(), {
|
|
15812
15902
|
from: task.column,
|
|
15813
15903
|
to,
|
|
@@ -15820,6 +15910,57 @@ async function manuallyMoveColumn(trx, input) {
|
|
|
15820
15910
|
};
|
|
15821
15911
|
}
|
|
15822
15912
|
/**
|
|
15913
|
+
* Apply a complete GitHub Project read of `source`, after synchronizing dispatcher mode: every
|
|
15914
|
+
* live task of the mirrored project goes where `mirrorPlacement` puts it, journaled as
|
|
15915
|
+
* `task_mirror_moved` by `system`. A real column move is a fresh visit that closes the task's
|
|
15916
|
+
* turns. A move of only the shadow column keeps the visit and the turns, and its event carries
|
|
15917
|
+
* `shadow: true` with the shadow positions. A task the read does not list stays put.
|
|
15918
|
+
*/
|
|
15919
|
+
async function applyMirror(trx, input) {
|
|
15920
|
+
const { source, at, config } = input;
|
|
15921
|
+
const project = config.projects.find((entry) => mirrorSourceId(entry) === source);
|
|
15922
|
+
if (project === void 0) return;
|
|
15923
|
+
await syncModes(trx, config, at);
|
|
15924
|
+
const readiness = new Map(input.readiness.map((entry) => [entry.key, entry.state]));
|
|
15925
|
+
const tasks = await trx.selectFrom("task").selectAll().where("project", "=", project.id).where("membership", "!=", "archived").where("column", "in", ["todo", "ready-for-dev"]).orderBy("id").execute();
|
|
15926
|
+
for (const task of tasks) {
|
|
15927
|
+
const state = readiness.get(task.key);
|
|
15928
|
+
if (state === void 0) continue;
|
|
15929
|
+
const placement = mirrorPlacement({
|
|
15930
|
+
column: task.column,
|
|
15931
|
+
shadowColumn: task.shadow_column,
|
|
15932
|
+
shadowMode: project.dispatcher.mode === "shadow",
|
|
15933
|
+
workStarted: await workStartedOn(trx, task.id),
|
|
15934
|
+
readiness: state
|
|
15935
|
+
});
|
|
15936
|
+
if (placement === null) continue;
|
|
15937
|
+
const moved = placement.column !== task.column;
|
|
15938
|
+
await trx.updateTable("task").set({
|
|
15939
|
+
shadow_column: placement.shadowColumn,
|
|
15940
|
+
last_change_at: taskChangeAt(at.toISOString()),
|
|
15941
|
+
...moved ? {
|
|
15942
|
+
column: placement.column,
|
|
15943
|
+
column_epoch: task.column_epoch + 1
|
|
15944
|
+
} : {}
|
|
15945
|
+
}).where("id", "=", task.id).execute();
|
|
15946
|
+
if (moved) await closeTurns(trx, {
|
|
15947
|
+
taskId: task.id,
|
|
15948
|
+
reason: "moved",
|
|
15949
|
+
at
|
|
15950
|
+
});
|
|
15951
|
+
await emit(trx, "task_mirror_moved", project.id, task.id, at.toISOString(), moved ? {
|
|
15952
|
+
from: task.column,
|
|
15953
|
+
to: placement.column,
|
|
15954
|
+
source
|
|
15955
|
+
} : {
|
|
15956
|
+
from: task.shadow_column ?? task.column,
|
|
15957
|
+
to: placement.shadowColumn ?? placement.column,
|
|
15958
|
+
source,
|
|
15959
|
+
shadow: true
|
|
15960
|
+
});
|
|
15961
|
+
}
|
|
15962
|
+
}
|
|
15963
|
+
/**
|
|
15823
15964
|
* The operator's correction of a task's column to `to`, as a new visit of `to`. It first applies
|
|
15824
15965
|
* a pending dispatcher mode switch, so the switch cannot overwrite the correction. In `on` mode it
|
|
15825
15966
|
* sets the column and bumps `column_epoch`, voids the submits of `to` and right of it, closes the
|
|
@@ -16095,8 +16236,12 @@ async function settlePending(trx, row, project, input) {
|
|
|
16095
16236
|
}
|
|
16096
16237
|
/** Whether a reopen still needs to override the latest explicit placement. */
|
|
16097
16238
|
async function reopenNeedsDispatch(trx, taskId, project) {
|
|
16098
|
-
const placement = await trx.selectFrom("event").select(["id", "kind"]).where("task_id", "=", taskId).where("kind", "in", [
|
|
16099
|
-
|
|
16239
|
+
const placement = await trx.selectFrom("event").select(["id", "kind"]).where("task_id", "=", taskId).where("kind", "in", [
|
|
16240
|
+
"task_manually_moved",
|
|
16241
|
+
"task_mirror_moved",
|
|
16242
|
+
"task_corrected"
|
|
16243
|
+
]).orderBy("id", "desc").executeTakeFirst();
|
|
16244
|
+
if (placement === void 0 || placement.kind === "task_corrected") return true;
|
|
16100
16245
|
return (await trx.selectFrom("event").select("payload").where("task_id", "=", taskId).where("kind", "=", "ticket_status_changed").where("id", ">", placement.id).execute()).some((row) => {
|
|
16101
16246
|
const status = parseJson(eventPayloadSchemas.ticket_status_changed, row.payload);
|
|
16102
16247
|
return status.from !== null && ticketDone(project, status.from) && !ticketDone(project, status.to);
|
|
@@ -17418,6 +17563,7 @@ const DAEMON_STALL_MS = 2 * BOARD_TICK_MS;
|
|
|
17418
17563
|
const SOURCE_SERVICES = {
|
|
17419
17564
|
github: "github",
|
|
17420
17565
|
"github-issues": "github",
|
|
17566
|
+
"github-project": "github-project",
|
|
17421
17567
|
spur: "spur",
|
|
17422
17568
|
jira: "jira"
|
|
17423
17569
|
};
|
|
@@ -17435,7 +17581,10 @@ function pickTime(values, pick) {
|
|
|
17435
17581
|
}
|
|
17436
17582
|
return chosen;
|
|
17437
17583
|
}
|
|
17438
|
-
/**
|
|
17584
|
+
/**
|
|
17585
|
+
* One source's health: failing when blind or when its last poll failed with a code, degraded
|
|
17586
|
+
* while not fully usable, else healthy. `config.get` reads a mirror's health through it too.
|
|
17587
|
+
*/
|
|
17439
17588
|
function sourceHealth(source) {
|
|
17440
17589
|
if (source.blindReason !== null) {
|
|
17441
17590
|
const message = source.message === null ? "" : `: ${source.message}`;
|
|
@@ -17444,6 +17593,10 @@ function sourceHealth(source) {
|
|
|
17444
17593
|
reason: `${source.source} blind (${source.blindReason})${message}`
|
|
17445
17594
|
};
|
|
17446
17595
|
}
|
|
17596
|
+
if (source.failure != null) return {
|
|
17597
|
+
state: "failing",
|
|
17598
|
+
reason: `${source.source} failing (${source.failure.code}): ${source.failure.message}`
|
|
17599
|
+
};
|
|
17447
17600
|
const degraded = (reason) => ({
|
|
17448
17601
|
state: "degraded",
|
|
17449
17602
|
reason
|
|
@@ -17458,8 +17611,8 @@ function sourceHealth(source) {
|
|
|
17458
17611
|
};
|
|
17459
17612
|
}
|
|
17460
17613
|
/**
|
|
17461
|
-
* One health row per service: the daemon, each gateway (board-wide), then github,
|
|
17462
|
-
* rolled up from the given sources only.
|
|
17614
|
+
* One health row per service: the daemon, each gateway (board-wide), then github,
|
|
17615
|
+
* github-project, spur and jira rolled up from the given sources only.
|
|
17463
17616
|
*/
|
|
17464
17617
|
function services(input) {
|
|
17465
17618
|
const { now, daemon } = input;
|
|
@@ -17490,6 +17643,7 @@ function services(input) {
|
|
|
17490
17643
|
}
|
|
17491
17644
|
for (const service of [
|
|
17492
17645
|
"github",
|
|
17646
|
+
"github-project",
|
|
17493
17647
|
"spur",
|
|
17494
17648
|
"jira"
|
|
17495
17649
|
]) {
|
|
@@ -17726,38 +17880,29 @@ async function getStatus(deps, options = {}) {
|
|
|
17726
17880
|
health
|
|
17727
17881
|
};
|
|
17728
17882
|
});
|
|
17729
|
-
const sourceIds = (scope) => /* @__PURE__ */ new Set(["spur", ...scope.flatMap((project) =>
|
|
17730
|
-
|
|
17731
|
-
|
|
17883
|
+
const sourceIds = (scope, mirrors) => /* @__PURE__ */ new Set(["spur", ...scope.flatMap((project) => {
|
|
17884
|
+
const mirror = mirrors ? mirrorSourceId(project) : void 0;
|
|
17885
|
+
return [
|
|
17886
|
+
trackerSourceId(project),
|
|
17887
|
+
...project.repos.map((repo) => prSourceId(project.id, repo)),
|
|
17888
|
+
...mirror === void 0 ? [] : [mirror]
|
|
17889
|
+
];
|
|
17890
|
+
})]);
|
|
17891
|
+
const required = sourceIds(projects, false);
|
|
17892
|
+
const boardSources = sourceIds(visible, true);
|
|
17732
17893
|
const costs = await store.db.selectFrom("source_cost").select(["source", "points"]).where("at", ">", (/* @__PURE__ */ new Date(clock.now() - 36e5)).toISOString()).where("at", "<=", new Date(clock.now()).toISOString()).execute();
|
|
17733
17894
|
const points = /* @__PURE__ */ new Map();
|
|
17734
17895
|
for (const cost of costs) points.set(cost.source, (points.get(cost.source) ?? 0) + cost.points);
|
|
17735
|
-
const sources = [...boardSources].map((source) => {
|
|
17736
|
-
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17741
|
-
|
|
17742
|
-
|
|
17743
|
-
|
|
17744
|
-
|
|
17745
|
-
},
|
|
17746
|
-
observedAt: row?.observed_at ?? null,
|
|
17747
|
-
lastCompleteAt: last,
|
|
17748
|
-
blindReason,
|
|
17749
|
-
message: row?.blind_message ?? null,
|
|
17750
|
-
budget: row?.budget_remaining != null && row.budget_reset_at != null ? {
|
|
17751
|
-
remaining: row.budget_remaining,
|
|
17752
|
-
limit: row.budget_limit,
|
|
17753
|
-
resetAt: row.budget_reset_at
|
|
17754
|
-
} : null,
|
|
17755
|
-
waitsForBudget: deps.budgetWaits?.has(source) ?? false,
|
|
17756
|
-
stale: last === null || clock.now() - Date.parse(last) > config.thresholds.staleMultiplier * sourceInterval(config, source),
|
|
17757
|
-
healthySince: deps.healthySince?.get(source) ?? null,
|
|
17758
|
-
warmingUp: !completeSince.has(source)
|
|
17759
|
-
};
|
|
17760
|
-
});
|
|
17896
|
+
const sources = [...boardSources].map((source) => sourceView({
|
|
17897
|
+
source,
|
|
17898
|
+
row: sourceById.get(source),
|
|
17899
|
+
config,
|
|
17900
|
+
now: clock.now(),
|
|
17901
|
+
points,
|
|
17902
|
+
completeSince,
|
|
17903
|
+
healthySince: deps.healthySince,
|
|
17904
|
+
budgetWaits: deps.budgetWaits
|
|
17905
|
+
}));
|
|
17761
17906
|
const itemRows = await store.db.selectFrom("operator_item").selectAll().where("cleared_at", "is", null).execute();
|
|
17762
17907
|
const itemTasks = new Map(rows.map((task) => [task.id, task]));
|
|
17763
17908
|
const ownedProjects = /* @__PURE__ */ new Map();
|
|
@@ -17916,6 +18061,7 @@ const EVENT_SUMMARIES = {
|
|
|
17916
18061
|
task_shadow_moved: "Shadow move",
|
|
17917
18062
|
task_corrected: "Column corrected by the operator",
|
|
17918
18063
|
task_manually_moved: "Task manually moved by the operator",
|
|
18064
|
+
task_mirror_moved: "Task moved by the GitHub Project mirror",
|
|
17919
18065
|
external_round: "External change-request round",
|
|
17920
18066
|
dispatcher_mode_changed: "Dispatcher mode changed",
|
|
17921
18067
|
turn_opened: "Turn opened",
|
|
@@ -18106,6 +18252,7 @@ const optional = (prefix, value) => value === void 0 ? "" : `${prefix}${value}`;
|
|
|
18106
18252
|
/** Summaries built from a row's payload; null falls back to the fixed text. */
|
|
18107
18253
|
const SUMMARIES = {
|
|
18108
18254
|
task_manually_moved: (p) => `Manually moved ${p.from} → ${p.to}: ${p.reason}`,
|
|
18255
|
+
task_mirror_moved: (p) => `Mirror moved ${p.from} → ${p.to}${p.shadow === true ? " (shadow mode)" : ""}: ${p.source}`,
|
|
18109
18256
|
session_state_changed: (p) => `Session ${p.session}: ${from(p.from, p.to)}${optional(", ended (", p.endReason === void 0 ? void 0 : `${END_WORDS[p.endReason]})`)}`,
|
|
18110
18257
|
checks_changed: checksSummary,
|
|
18111
18258
|
head_moved: (p) => `New head ${p.to.slice(0, 7)} on ${ref$1(p.repo, p.pr)}`,
|
|
@@ -18576,6 +18723,7 @@ async function describeProject(trx, config, project) {
|
|
|
18576
18723
|
text: role === "operator" ? "The operator." : role === "worker" ? "The task-linked live worker, else the operator; no arbitrary project worker is selected." : parsed.kind === "curator" && purpose !== "executor" ? "Always the current project-selected curator session; task-linked and author sessions do not override it. Without a live curator recipient this question falls back to the operator." : purpose === "executor" ? `${parsed.kind === "curator" ? "A curator-bound executor turn uses column orchestrator routing. " : ""}Project-selected live session; task-linked or author sessions can override it. Without a live executor recipient, the turn waits for a session.` : purpose === "course-check" ? "Project-selected live session; task-linked or author sessions can override it. Without a live recipient this question falls back to the operator." : "Project-selected live session; task-linked or author sessions can override it. Without a live orchestrator, ordinary questions wait for a session."
|
|
18577
18724
|
};
|
|
18578
18725
|
}
|
|
18726
|
+
const mirror = readyMirrorOf(project);
|
|
18579
18727
|
const columns = [];
|
|
18580
18728
|
for (const metadata of COLUMNS) {
|
|
18581
18729
|
const column = project.columns.find((entry) => entry.id === metadata.id && entry.enabled);
|
|
@@ -18661,7 +18809,10 @@ async function describeProject(trx, config, project) {
|
|
|
18661
18809
|
text: `Active with dispatcher on; shadow only models policy. A taken named executor uses its effective column quietTurnAfterMs. Existing worker/operator turns keep the global idle threshold. A taken agent turn gets one reminder after observed idle time; an operator item follows after the reminder is read and another quiet period. Open questions and blind sources pause observation. An unread reminder does not start the post-read timer; an exhausted failed reminder can raise an operator item once the current quiet period reaches remindAfterMs. Unhealthy executor episodes use continuous observation and turnStallAfterMs. Ordinary doorbells wait ${String(config.doorbells.firstRetryMs)}, then ${String(config.doorbells.secondRetryMs)} ms between delivered rings; the final unanswered pause is ${String(config.doorbells.unansweredAfterMs)} ms.`
|
|
18662
18810
|
}
|
|
18663
18811
|
},
|
|
18664
|
-
movedBy: {
|
|
18812
|
+
movedBy: mirror !== void 0 && column.id === "ready-for-dev" ? {
|
|
18813
|
+
kind: "mirror",
|
|
18814
|
+
text: `GitHub Project ${mirror.project} places idle work here while its ${mirror.field} field is ${mirror.value}, and back in Todo otherwise; manual moves into or out of this column are refused. Operator correction can still repair placement until the next complete read. Work starting leaves the whole Todo group.`
|
|
18815
|
+
} : {
|
|
18665
18816
|
kind: metadata.group !== null ? "manual" : "dispatcher",
|
|
18666
18817
|
text: metadata.group !== null ? column.id === "todo" ? "New and reopened tasks enter Todo; task add and manual moves place idle work here; operator correction can also repair placement. Work starting leaves the whole Todo group." : "Manual moves place idle work here; operator correction can also repair placement. New and reopened tasks enter Todo; work starting leaves the whole Todo group." : "The dispatcher advances passing gates and completion shortcuts; in shadow mode it records only a shadow position. Operator corrections can also place tasks here."
|
|
18667
18818
|
}
|
|
@@ -18986,7 +19137,7 @@ function capitalized(text) {
|
|
|
18986
19137
|
}
|
|
18987
19138
|
function serviceOf(source) {
|
|
18988
19139
|
if (source === "spur") return "Spur";
|
|
18989
|
-
if (source.startsWith("github:") || source.startsWith("github-issues:")) return "GitHub";
|
|
19140
|
+
if (source.startsWith("github:") || source.startsWith("github-issues:") || source.startsWith("github-project:")) return "GitHub";
|
|
18990
19141
|
return source.startsWith("jira:") ? "Jira" : void 0;
|
|
18991
19142
|
}
|
|
18992
19143
|
const externalUrlSchema = z.url({ protocol: /^https?$/ });
|
|
@@ -19623,6 +19774,7 @@ function createTurnMutations(deps) {
|
|
|
19623
19774
|
}
|
|
19624
19775
|
// ../core/src/app/registry.ts
|
|
19625
19776
|
const catalog = await buildCatalogSnapshot(OPERATIONS);
|
|
19777
|
+
const MANUAL_SOURCE = { kind: "manual" };
|
|
19626
19778
|
/**
|
|
19627
19779
|
* `<baseUrl>/browse/` of a Jira tracker, without userinfo, query or fragment; null for a tracker
|
|
19628
19780
|
* whose keys do not append to one prefix, as GitHub Issues.
|
|
@@ -19732,10 +19884,39 @@ function createOperationRegistry(deps) {
|
|
|
19732
19884
|
resolveTargets(_trx, input, actor) {
|
|
19733
19885
|
return Promise.resolve(projectTargets(config, input.project, actor));
|
|
19734
19886
|
},
|
|
19735
|
-
run(
|
|
19887
|
+
async run(trx, input, actor) {
|
|
19736
19888
|
const visible = visibleProjects(config, actor);
|
|
19737
|
-
|
|
19738
|
-
|
|
19889
|
+
const shown = config.projects.filter((project) => visible.has(project.id) && (input.project === void 0 || input.project === project.id));
|
|
19890
|
+
const mirrors = /* @__PURE__ */ new Map();
|
|
19891
|
+
for (const project of shown) {
|
|
19892
|
+
const mirror = readyMirrorOf(project);
|
|
19893
|
+
const source = mirrorSourceId(project);
|
|
19894
|
+
if (mirror === void 0 || source === void 0) continue;
|
|
19895
|
+
const row = await trx.selectFrom("source_state").selectAll().where("source", "=", source).executeTakeFirst();
|
|
19896
|
+
const view = sourceView({
|
|
19897
|
+
source,
|
|
19898
|
+
row,
|
|
19899
|
+
config,
|
|
19900
|
+
now: clock.now(),
|
|
19901
|
+
points: /* @__PURE__ */ new Map(),
|
|
19902
|
+
completeSince,
|
|
19903
|
+
healthySince: deps.healthySince,
|
|
19904
|
+
budgetWaits: deps.budgetWaits?.()
|
|
19905
|
+
});
|
|
19906
|
+
mirrors.set(project.id, {
|
|
19907
|
+
kind: "mirror",
|
|
19908
|
+
tracker: "github-project",
|
|
19909
|
+
name: row?.project_title ?? mirror.project,
|
|
19910
|
+
project: mirror.project,
|
|
19911
|
+
field: mirror.field,
|
|
19912
|
+
value: mirror.value,
|
|
19913
|
+
health: sourceHealth(view).state,
|
|
19914
|
+
readAt: view.lastCompleteAt,
|
|
19915
|
+
...view.failure == null ? {} : { error: view.failure }
|
|
19916
|
+
});
|
|
19917
|
+
}
|
|
19918
|
+
return {
|
|
19919
|
+
projects: shown.map((project) => ({
|
|
19739
19920
|
id: project.id,
|
|
19740
19921
|
columns: project.columns.filter((column) => column.enabled).map((column) => {
|
|
19741
19922
|
const named = column.orchestrator === "none" || column.orchestrator === "operator" ? void 0 : project.spurProjects.find((spur) => spur.name === column.orchestrator);
|
|
@@ -19747,7 +19928,10 @@ function createOperationRegistry(deps) {
|
|
|
19747
19928
|
kind: column.orchestrator === "operator" ? "operator" : named?.role === "curator" ? "curator" : named !== void 0 ? "orchestrator" : column.id === "external-review" ? "dispatcher" : "worker",
|
|
19748
19929
|
name: named?.name ?? null
|
|
19749
19930
|
},
|
|
19750
|
-
...group === null ? {} : {
|
|
19931
|
+
...group === null ? {} : {
|
|
19932
|
+
group,
|
|
19933
|
+
source: column.id === "ready-for-dev" ? mirrors.get(project.id) ?? MANUAL_SOURCE : MANUAL_SOURCE
|
|
19934
|
+
},
|
|
19751
19935
|
...timings === null ? {} : {
|
|
19752
19936
|
quietTurnAfterMs: timings.quietTurnAfterMs,
|
|
19753
19937
|
noRecipientAfterMs: timings.noRecipientAfterMs
|
|
@@ -19767,7 +19951,7 @@ function createOperationRegistry(deps) {
|
|
|
19767
19951
|
publicOrigin: webOrigin() ?? null,
|
|
19768
19952
|
spurUiOrigin: config.web.spurUiOrigin ?? null
|
|
19769
19953
|
}
|
|
19770
|
-
}
|
|
19954
|
+
};
|
|
19771
19955
|
}
|
|
19772
19956
|
},
|
|
19773
19957
|
"columns.describe": createColumnsQuery(config),
|
|
@@ -19967,7 +20151,7 @@ async function nextDefaultBranch(trx, source, fact, at) {
|
|
|
19967
20151
|
url: fact.state === "red" ? fact.url : null
|
|
19968
20152
|
});
|
|
19969
20153
|
}
|
|
19970
|
-
async function sourceState(trx, source, state, observedAt, cursor, budget, defaultBranch) {
|
|
20154
|
+
async function sourceState(trx, source, state, observedAt, cursor, budget, defaultBranch, projectTitle) {
|
|
19971
20155
|
const branch = await nextDefaultBranch(trx, source, defaultBranch, observedAt);
|
|
19972
20156
|
await trx.insertInto("source_state").values({
|
|
19973
20157
|
source,
|
|
@@ -19981,7 +20165,10 @@ async function sourceState(trx, source, state, observedAt, cursor, budget, defau
|
|
|
19981
20165
|
budget_remaining: budget?.remaining ?? null,
|
|
19982
20166
|
budget_limit: budget?.limit ?? null,
|
|
19983
20167
|
budget_reset_at: budget?.resetAt ?? null,
|
|
19984
|
-
default_branch: branch ?? null
|
|
20168
|
+
default_branch: branch ?? null,
|
|
20169
|
+
failure_code: state.failure?.code ?? null,
|
|
20170
|
+
failure_message: state.failure?.message ?? null,
|
|
20171
|
+
project_title: projectTitle ?? null
|
|
19985
20172
|
}).onConflict((oc) => oc.column("source").doUpdateSet((eb) => ({
|
|
19986
20173
|
initialized: observedAt === void 0 ? eb.ref("source_state.initialized") : 1,
|
|
19987
20174
|
last_complete_at: state.lastCompleteAt ?? eb.ref("source_state.last_complete_at"),
|
|
@@ -19993,7 +20180,10 @@ async function sourceState(trx, source, state, observedAt, cursor, budget, defau
|
|
|
19993
20180
|
budget_remaining: budget === void 0 ? eb.ref("source_state.budget_remaining") : budget.remaining,
|
|
19994
20181
|
budget_limit: budget === void 0 ? eb.ref("source_state.budget_limit") : budget.limit ?? null,
|
|
19995
20182
|
budget_reset_at: budget === void 0 ? eb.ref("source_state.budget_reset_at") : budget.resetAt,
|
|
19996
|
-
default_branch: branch ?? eb.ref("source_state.default_branch")
|
|
20183
|
+
default_branch: branch ?? eb.ref("source_state.default_branch"),
|
|
20184
|
+
failure_code: state.failure?.code ?? null,
|
|
20185
|
+
failure_message: state.failure?.message ?? null,
|
|
20186
|
+
project_title: projectTitle ?? eb.ref("source_state.project_title")
|
|
19997
20187
|
}))).execute();
|
|
19998
20188
|
}
|
|
19999
20189
|
/**
|
|
@@ -20653,7 +20843,7 @@ function createObservationCore(deps) {
|
|
|
20653
20843
|
const wasBlind = await blindReason(trx, source);
|
|
20654
20844
|
const previousSpur = source === "spur" ? await trx.selectFrom("source_state").select("last_complete_at").where("source", "=", source).executeTakeFirst() : void 0;
|
|
20655
20845
|
const spurGap = previousSpur?.last_complete_at != null && Date.parse(batch.observedAt) > Date.parse(previousSpur.last_complete_at) + config.adapters.spur.intervalMs * config.thresholds.staleMultiplier;
|
|
20656
|
-
await sourceState(trx, source, observation.state, batch.observedAt, batch.cursor, batch.budget, batch.defaultBranch);
|
|
20846
|
+
await sourceState(trx, source, observation.state, batch.observedAt, batch.cursor, batch.budget, batch.defaultBranch, batch.mirror?.title);
|
|
20657
20847
|
await recordUsage(trx, source, batch.usage, now);
|
|
20658
20848
|
for (const probe of batch.prProbes ?? []) {
|
|
20659
20849
|
if (probe.status !== "closed") continue;
|
|
@@ -20780,6 +20970,12 @@ function createObservationCore(deps) {
|
|
|
20780
20970
|
confirmedTasks.push(...links.map((link) => link.task_id));
|
|
20781
20971
|
}
|
|
20782
20972
|
if (confirmedTasks.length > 0) await dispatchTasks(trx, confirmedTasks, dispatchContext);
|
|
20973
|
+
if (observation.effectiveComplete && batch.mirror !== void 0) await applyMirror(trx, {
|
|
20974
|
+
source,
|
|
20975
|
+
readiness: batch.mirror.readiness,
|
|
20976
|
+
at: dispatchContext.at,
|
|
20977
|
+
config
|
|
20978
|
+
});
|
|
20783
20979
|
await dispatchJournaled(trx, dispatchContext);
|
|
20784
20980
|
await reconcileItems(trx, config, now, currentComplete.has("spur"), warnSkipped, source === "spur" && observation.effectiveComplete && (!completeSince.has("spur") || spurGap) ? Date.parse(batch.observedAt) : void 0);
|
|
20785
20981
|
if (deps.productVersion !== void 0) await enqueueLiveAfterFirstPoll(trx, {
|
|
@@ -22770,7 +22966,7 @@ async function withTimeout(signal, message, work) {
|
|
|
22770
22966
|
}
|
|
22771
22967
|
}
|
|
22772
22968
|
// ../adapters/src/github/client.ts
|
|
22773
|
-
const MALFORMED$
|
|
22969
|
+
const MALFORMED$4 = "Malformed GitHub response";
|
|
22774
22970
|
const graphErrorWire = z.object({
|
|
22775
22971
|
message: z.string(),
|
|
22776
22972
|
path: z.array(z.union([z.string(), z.number()])).optional(),
|
|
@@ -22909,7 +23105,7 @@ var GithubClient = class {
|
|
|
22909
23105
|
try {
|
|
22910
23106
|
body = await response.json();
|
|
22911
23107
|
} catch (cause) {
|
|
22912
|
-
throw new AdapterError("transient", MALFORMED$
|
|
23108
|
+
throw new AdapterError("transient", MALFORMED$4, { cause });
|
|
22913
23109
|
}
|
|
22914
23110
|
return {
|
|
22915
23111
|
response,
|
|
@@ -22918,11 +23114,11 @@ var GithubClient = class {
|
|
|
22918
23114
|
});
|
|
22919
23115
|
const cost = z.object({ data: z.object({ rateLimit: z.object({ cost: z.int().nonnegative() }) }) }).safeParse(body);
|
|
22920
23116
|
if (cost.success) this.points = (this.points ?? 0) + cost.data.data.rateLimit.cost;
|
|
22921
|
-
const wire = parseWire(graphEnvelopeWire, body, MALFORMED$
|
|
23117
|
+
const wire = parseWire(graphEnvelopeWire, body, MALFORMED$4);
|
|
22922
23118
|
const errors = wire.errors ?? [];
|
|
22923
23119
|
const failure = graphqlFailure(errors, query, response.headers, this.now());
|
|
22924
23120
|
if (failure !== null) throw failure;
|
|
22925
|
-
const data = parseWire(dataWire, wire.data, MALFORMED$
|
|
23121
|
+
const data = parseWire(dataWire, wire.data, MALFORMED$4, ["data"]);
|
|
22926
23122
|
const limit = z.object({ rateLimit: z.object({ limit: z.int().positive() }) }).safeParse(wire.data);
|
|
22927
23123
|
return {
|
|
22928
23124
|
data,
|
|
@@ -23686,7 +23882,7 @@ function reusable(cached, entry, cursorKey, now) {
|
|
|
23686
23882
|
return cached.facts;
|
|
23687
23883
|
}
|
|
23688
23884
|
// ../adapters/src/github/index.ts
|
|
23689
|
-
const MALFORMED$
|
|
23885
|
+
const MALFORMED$3 = "Malformed GitHub response";
|
|
23690
23886
|
const discoveryRootWire = z.object({ pullRequests: connectionWire(discoveryNodeWire) });
|
|
23691
23887
|
const baselineRootWire = z.object({ mergedBaseline: z.object({ nodes: z.array(baselineNodeWire) }) });
|
|
23692
23888
|
const pagingWire = connectionWire(z.unknown());
|
|
@@ -23854,7 +24050,7 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
|
|
|
23854
24050
|
requireCheckAccess(response.errors);
|
|
23855
24051
|
const denied = response.errors.some(deniedReference);
|
|
23856
24052
|
if (withoutDeniedReferences(response.errors).length > 0) return { status: "denied" };
|
|
23857
|
-
const root = content(() => parseWire(pageRootWire, response.data.repository, MALFORMED$
|
|
24053
|
+
const root = content(() => parseWire(pageRootWire, response.data.repository, MALFORMED$3, ["data", "repository"]));
|
|
23858
24054
|
if (root instanceof AdapterError) return {
|
|
23859
24055
|
status: "malformed",
|
|
23860
24056
|
error: root
|
|
@@ -23902,7 +24098,7 @@ async function commentPage(scope, number, before, budget) {
|
|
|
23902
24098
|
budget(response.budget);
|
|
23903
24099
|
rejectUnscoped(response.errors, ["repository"]);
|
|
23904
24100
|
if (response.errors.length > 0) return void 0;
|
|
23905
|
-
const page = content(() => parseWire(commentsRootWire, response.data.repository, MALFORMED$
|
|
24101
|
+
const page = content(() => parseWire(commentsRootWire, response.data.repository, MALFORMED$3, ["data", "repository"]).pullRequest.comments);
|
|
23906
24102
|
return page instanceof AdapterError ? void 0 : page;
|
|
23907
24103
|
}
|
|
23908
24104
|
/**
|
|
@@ -24003,7 +24199,7 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
|
24003
24199
|
});
|
|
24004
24200
|
return;
|
|
24005
24201
|
}
|
|
24006
|
-
const root = content(() => parseWire(aliasWire, data[alias], MALFORMED$
|
|
24202
|
+
const root = content(() => parseWire(aliasWire, data[alias], MALFORMED$3, ["data", alias]));
|
|
24007
24203
|
if (root instanceof AdapterError) {
|
|
24008
24204
|
malformed(acc, root, ref);
|
|
24009
24205
|
return;
|
|
@@ -24142,7 +24338,7 @@ async function readDiscovery(scope, acc, ctx, login) {
|
|
|
24142
24338
|
const defaultBranch = errors.length === response.errors.length ? defaultBranchFact(response.data.repository) : void 0;
|
|
24143
24339
|
rejectUnscoped(errors, ["repository"]);
|
|
24144
24340
|
let ok = scoped(errors, "repository").length === 0;
|
|
24145
|
-
const first = ok ? parseWire(discoveryRootWire, response.data.repository, MALFORMED$
|
|
24341
|
+
const first = ok ? parseWire(discoveryRootWire, response.data.repository, MALFORMED$3, ["data", "repository"]).pullRequests : void 0;
|
|
24146
24342
|
const nodes = first === void 0 ? [] : [...first.nodes];
|
|
24147
24343
|
let cursor = first === void 0 || pastCursor(nodes, ctx.cursor) ? void 0 : nextPage(first);
|
|
24148
24344
|
const seenPages = /* @__PURE__ */ new Set();
|
|
@@ -24160,12 +24356,12 @@ async function readDiscovery(scope, acc, ctx, login) {
|
|
|
24160
24356
|
ok = false;
|
|
24161
24357
|
break;
|
|
24162
24358
|
}
|
|
24163
|
-
const connection = parseWire(discoveryRootWire, page.data.repository, MALFORMED$
|
|
24359
|
+
const connection = parseWire(discoveryRootWire, page.data.repository, MALFORMED$3, ["data", "repository"]).pullRequests;
|
|
24164
24360
|
nodes.push(...connection.nodes);
|
|
24165
24361
|
cursor = pastCursor(connection.nodes, ctx.cursor) ? void 0 : nextPage(connection);
|
|
24166
24362
|
}
|
|
24167
24363
|
const found = discover(nodes, ctx.cursor, login);
|
|
24168
|
-
const bootstrapCursor = bootstrap && ok ? latestUpdatedAt(parseWire(baselineRootWire, response.data.repository, MALFORMED$
|
|
24364
|
+
const bootstrapCursor = bootstrap && ok ? latestUpdatedAt(parseWire(baselineRootWire, response.data.repository, MALFORMED$3, ["data", "repository"]).mergedBaseline.nodes, found.cursor) ?? sourceCursorSchema.parse("1970-01-01T00:00:00.000Z") : void 0;
|
|
24169
24365
|
return {
|
|
24170
24366
|
ok,
|
|
24171
24367
|
found,
|
|
@@ -24402,7 +24598,7 @@ var GithubIssuesHttpError = class extends AdapterError {
|
|
|
24402
24598
|
this.status = status;
|
|
24403
24599
|
}
|
|
24404
24600
|
};
|
|
24405
|
-
const MALFORMED$
|
|
24601
|
+
const MALFORMED$2 = "Malformed GitHub issue response";
|
|
24406
24602
|
const text$2 = z.string().min(1);
|
|
24407
24603
|
const issueWire$1 = z.object({
|
|
24408
24604
|
node_id: text$2,
|
|
@@ -24420,13 +24616,13 @@ const milestoneWire = z.object({
|
|
|
24420
24616
|
title: z.string(),
|
|
24421
24617
|
number: z.int().positive()
|
|
24422
24618
|
});
|
|
24423
|
-
const repositoryWire = z.object({ id: z.int().positive() });
|
|
24619
|
+
const repositoryWire$1 = z.object({ id: z.int().positive() });
|
|
24424
24620
|
const PAGINATION = "Malformed GitHub issue pagination";
|
|
24425
24621
|
function issueNumber(ref, repo) {
|
|
24426
24622
|
const match = /^(.+)#([1-9]\d*)$/.exec(ref.key);
|
|
24427
24623
|
if (match?.[1]?.toLowerCase() !== repo.toLowerCase()) throw new AdapterError("config", "Requested issue is outside its configured repository");
|
|
24428
24624
|
const value = Number(match[2]);
|
|
24429
|
-
if (!Number.isSafeInteger(value) || value <= 0) throw new AdapterError("transient", MALFORMED$
|
|
24625
|
+
if (!Number.isSafeInteger(value) || value <= 0) throw new AdapterError("transient", MALFORMED$2);
|
|
24430
24626
|
return value;
|
|
24431
24627
|
}
|
|
24432
24628
|
function normalize$1(issue, trackerId, repo, inFilter) {
|
|
@@ -24538,7 +24734,7 @@ function createGithubIssuesAdapter(options) {
|
|
|
24538
24734
|
if (pageUrl.pathname === base.pathname + "/milestones") return;
|
|
24539
24735
|
const match = /^\/repositories\/([1-9]\d*)\/(?:issues|milestones)$/.exec(pageUrl.pathname);
|
|
24540
24736
|
if (match === null) throw new AdapterError("transient", PAGINATION);
|
|
24541
|
-
repositoryId ??= parseWire(repositoryWire, (await request(root, signal)).value, MALFORMED$
|
|
24737
|
+
repositoryId ??= parseWire(repositoryWire$1, (await request(root, signal)).value, MALFORMED$2).id;
|
|
24542
24738
|
if (Number(match[1]) !== repositoryId) {
|
|
24543
24739
|
repositoryId = void 0;
|
|
24544
24740
|
throw new AdapterError("transient", PAGINATION);
|
|
@@ -24587,7 +24783,7 @@ function createGithubIssuesAdapter(options) {
|
|
|
24587
24783
|
if (error instanceof GithubIssuesHttpError && error.status === 404) throw new AdapterError("config", "GitHub Issues repository is unavailable");
|
|
24588
24784
|
throw error;
|
|
24589
24785
|
}
|
|
24590
|
-
const match = parseWire(z.array(milestoneWire), milestones, MALFORMED$
|
|
24786
|
+
const match = parseWire(z.array(milestoneWire), milestones, MALFORMED$2).find((entry) => entry.title === options.tracker.milestone);
|
|
24591
24787
|
if (match === void 0) throw new AdapterError("config", "Configured GitHub milestone is missing");
|
|
24592
24788
|
return match.number;
|
|
24593
24789
|
}
|
|
@@ -24616,7 +24812,7 @@ function createGithubIssuesAdapter(options) {
|
|
|
24616
24812
|
}
|
|
24617
24813
|
const facts = /* @__PURE__ */ new Map();
|
|
24618
24814
|
for (const value of listed) {
|
|
24619
|
-
const issue = parseWire(issueWire$1, value, MALFORMED$
|
|
24815
|
+
const issue = parseWire(issueWire$1, value, MALFORMED$2);
|
|
24620
24816
|
if (issue.pull_request !== void 0) continue;
|
|
24621
24817
|
facts.set(issue.number, normalize$1(issue, options.id, options.tracker.repo, true));
|
|
24622
24818
|
}
|
|
@@ -24626,7 +24822,7 @@ function createGithubIssuesAdapter(options) {
|
|
|
24626
24822
|
const issueNo = issueNumber(ref, options.tracker.repo);
|
|
24627
24823
|
let fact = facts.get(issueNo);
|
|
24628
24824
|
if (fact === void 0) try {
|
|
24629
|
-
const detail = parseWire(issueWire$1, (await request(`${root}/issues/${String(issueNo)}`, ctx.signal)).value, MALFORMED$
|
|
24825
|
+
const detail = parseWire(issueWire$1, (await request(`${root}/issues/${String(issueNo)}`, ctx.signal)).value, MALFORMED$2);
|
|
24630
24826
|
if (detail.pull_request !== void 0) {
|
|
24631
24827
|
entities.push({
|
|
24632
24828
|
ref,
|
|
@@ -24675,6 +24871,181 @@ function createGithubIssuesAdapter(options) {
|
|
|
24675
24871
|
}
|
|
24676
24872
|
};
|
|
24677
24873
|
}
|
|
24874
|
+
// ../adapters/src/github/projectMirror.ts
|
|
24875
|
+
/**
|
|
24876
|
+
* One read of the Project, its field and options, and the Project items of the repository's open
|
|
24877
|
+
* issues. The items are read through each issue's `projectItems` and matched to the Project by id
|
|
24878
|
+
* here: the Project's own `items` are never listed.
|
|
24879
|
+
*/
|
|
24880
|
+
const PROJECT_MIRROR_QUERY = "query ProjectMirror($owner: String!, $repo: String!, $projectOwner: String!, $number: Int!, $field: String!) { rateLimit { cost limit remaining resetAt } repositoryOwner(login: $projectOwner) { ... on ProjectV2Owner { projectV2(number: $number) { id title field(name: $field) { __typename ... on ProjectV2SingleSelectField { id options { id name } } } } } } repository(owner: $owner, name: $repo) { issues(first: 100, states: [OPEN]) { pageInfo { hasNextPage } nodes { number projectItems(first: 20, includeArchived: true) { pageInfo { hasNextPage } nodes { isArchived project { id } fieldValueByName(name: $field) { __typename ... on ProjectV2ItemFieldSingleSelectValue { optionId } } } } } } } }";
|
|
24881
|
+
const MALFORMED$1 = "Malformed GitHub Project response";
|
|
24882
|
+
const SINGLE_SELECT = "ProjectV2SingleSelectField";
|
|
24883
|
+
const SINGLE_SELECT_VALUE = "ProjectV2ItemFieldSingleSelectValue";
|
|
24884
|
+
const pageWire = z.object({ hasNextPage: z.boolean() });
|
|
24885
|
+
const ownerWire = z.object({ projectV2: z.object({
|
|
24886
|
+
id: z.string().min(1),
|
|
24887
|
+
title: z.string().min(1),
|
|
24888
|
+
field: z.object({
|
|
24889
|
+
__typename: z.string(),
|
|
24890
|
+
options: z.array(z.object({
|
|
24891
|
+
id: z.string().min(1),
|
|
24892
|
+
name: z.string()
|
|
24893
|
+
})).optional()
|
|
24894
|
+
}).nullable()
|
|
24895
|
+
}).nullish() }).nullable();
|
|
24896
|
+
const repositoryWire = z.object({ issues: z.object({
|
|
24897
|
+
pageInfo: pageWire,
|
|
24898
|
+
nodes: z.array(z.object({
|
|
24899
|
+
number: z.int().positive(),
|
|
24900
|
+
projectItems: z.object({
|
|
24901
|
+
pageInfo: pageWire,
|
|
24902
|
+
nodes: z.array(z.object({
|
|
24903
|
+
isArchived: z.boolean(),
|
|
24904
|
+
project: z.object({ id: z.string() }),
|
|
24905
|
+
fieldValueByName: z.object({
|
|
24906
|
+
__typename: z.string(),
|
|
24907
|
+
optionId: z.string().nullish()
|
|
24908
|
+
}).nullable()
|
|
24909
|
+
}).nullable())
|
|
24910
|
+
}).nullable()
|
|
24911
|
+
}))
|
|
24912
|
+
}) }).nullable();
|
|
24913
|
+
function failure(kind, code, message, options = {}) {
|
|
24914
|
+
return new AdapterError(kind, message, {
|
|
24915
|
+
...options,
|
|
24916
|
+
code
|
|
24917
|
+
});
|
|
24918
|
+
}
|
|
24919
|
+
function forbidden(target, cause) {
|
|
24920
|
+
const { owner, number } = target.mirror;
|
|
24921
|
+
return failure("auth", "mirror_project_forbidden", `GitHub Project ${owner}/${String(number)} was not found or is not readable: check the number and the read:project scope`, cause === void 0 ? {} : { cause });
|
|
24922
|
+
}
|
|
24923
|
+
function fieldNotFound(target) {
|
|
24924
|
+
const { owner, number, field, value } = target.mirror;
|
|
24925
|
+
return failure("config", "mirror_field_not_found", `GitHub Project ${owner}/${String(number)} has no single-select field ${field} with option ${value}`);
|
|
24926
|
+
}
|
|
24927
|
+
/** A client failure as the mirror reports it; an abort and a non-`AdapterError` pass through. */
|
|
24928
|
+
function coded(error, target, signal) {
|
|
24929
|
+
if (signal.aborted || !(error instanceof AdapterError) || error.code !== void 0) return error;
|
|
24930
|
+
if (error.kind === "auth") return forbidden(target, error);
|
|
24931
|
+
if (error.kind === "throttled") return failure("throttled", "mirror_rate_limited", error.message, {
|
|
24932
|
+
retryAt: error.retryAt,
|
|
24933
|
+
cause: error
|
|
24934
|
+
});
|
|
24935
|
+
return failure(error.kind, "mirror_read_failed", error.message, { cause: error });
|
|
24936
|
+
}
|
|
24937
|
+
/** The failure a GraphQL error means, by its path: the Project, its field, or anything else. */
|
|
24938
|
+
function graphFailure(errors, target) {
|
|
24939
|
+
const under = (error, ...path) => path.every((part, i) => error.path?.[i] === part);
|
|
24940
|
+
if (errors.some((error) => under(error, "repositoryOwner") && error.path?.[2] !== "field")) return forbidden(target);
|
|
24941
|
+
if (errors.some((error) => under(error, "repositoryOwner", "projectV2", "field"))) return fieldNotFound(target);
|
|
24942
|
+
if (errors.length > 0) return failure("transient", "mirror_read_failed", "GitHub Project read returned an error");
|
|
24943
|
+
return null;
|
|
24944
|
+
}
|
|
24945
|
+
/**
|
|
24946
|
+
* Reads the mirror once through `client`. `cachedOptionId` is the option id an earlier read
|
|
24947
|
+
* resolved; without it the configured value is resolved by name. Throws an `AdapterError` with a
|
|
24948
|
+
* mirror failure code for every failure but an abort, so nothing partial is ever returned.
|
|
24949
|
+
*/
|
|
24950
|
+
async function readMirrorWith(client, target, signal, cachedOptionId) {
|
|
24951
|
+
const [owner, repo] = target.repo.split("/");
|
|
24952
|
+
if (!owner || !repo) throw failure("config", "mirror_read_failed", "Invalid GitHub Issues repository");
|
|
24953
|
+
const { mirror } = target;
|
|
24954
|
+
try {
|
|
24955
|
+
const response = await client.query(PROJECT_MIRROR_QUERY, {
|
|
24956
|
+
owner,
|
|
24957
|
+
repo,
|
|
24958
|
+
projectOwner: mirror.owner,
|
|
24959
|
+
number: mirror.number,
|
|
24960
|
+
field: mirror.field
|
|
24961
|
+
}, signal);
|
|
24962
|
+
const failed = graphFailure(response.errors, target);
|
|
24963
|
+
if (failed !== null) throw failed;
|
|
24964
|
+
const project = parseWire(ownerWire, response.data["repositoryOwner"], MALFORMED$1, ["data", "repositoryOwner"])?.projectV2;
|
|
24965
|
+
if (project === null || project === void 0) throw forbidden(target);
|
|
24966
|
+
const options = project.field?.__typename === SINGLE_SELECT ? project.field.options : void 0;
|
|
24967
|
+
const optionId = cachedOptionId === void 0 ? options?.find((option) => option.name === mirror.value)?.id : options?.some((option) => option.id === cachedOptionId) === true ? cachedOptionId : void 0;
|
|
24968
|
+
if (optionId === void 0) throw fieldNotFound(target);
|
|
24969
|
+
const repository = parseWire(repositoryWire, response.data["repository"], MALFORMED$1, ["data", "repository"]);
|
|
24970
|
+
if (repository === null) throw failure("transient", "mirror_read_failed", "GitHub repository was not returned");
|
|
24971
|
+
const issues = repository.issues;
|
|
24972
|
+
const readiness = [];
|
|
24973
|
+
let incomplete = issues.pageInfo.hasNextPage;
|
|
24974
|
+
for (const issue of issues.nodes) {
|
|
24975
|
+
const items = issue.projectItems;
|
|
24976
|
+
if (items === null || items.nodes.includes(null)) throw failure("transient", "mirror_read_failed", "GitHub Project items were not returned");
|
|
24977
|
+
if (items.pageInfo.hasNextPage) incomplete = true;
|
|
24978
|
+
let ready = false;
|
|
24979
|
+
for (const item of items.nodes) {
|
|
24980
|
+
if (item === null || item.project.id !== project.id || item.isArchived) continue;
|
|
24981
|
+
const value = item.fieldValueByName;
|
|
24982
|
+
if (value === null) continue;
|
|
24983
|
+
if (value.__typename !== SINGLE_SELECT_VALUE) throw failure("transient", "mirror_read_failed", "GitHub Project item value is not a single-select value");
|
|
24984
|
+
if (!options?.some((option) => option.id === value.optionId)) throw failure("config", "mirror_field_not_found", `${target.repo}#${String(issue.number)}: its GitHub Project item has a ${mirror.field} option the field does not list; set its ${mirror.field} again in the Project`);
|
|
24985
|
+
if (value.optionId === optionId) ready = true;
|
|
24986
|
+
}
|
|
24987
|
+
readiness.push({
|
|
24988
|
+
key: `${target.repo}#${String(issue.number)}`,
|
|
24989
|
+
state: ready ? "ready" : "not_ready"
|
|
24990
|
+
});
|
|
24991
|
+
}
|
|
24992
|
+
if (incomplete) throw failure("transient", "mirror_snapshot_incomplete", "GitHub Project read did not fit one page");
|
|
24993
|
+
return {
|
|
24994
|
+
projectId: project.id,
|
|
24995
|
+
title: project.title,
|
|
24996
|
+
optionId,
|
|
24997
|
+
readiness,
|
|
24998
|
+
budget: response.budget
|
|
24999
|
+
};
|
|
25000
|
+
} catch (error) {
|
|
25001
|
+
throw coded(error, target, signal);
|
|
25002
|
+
}
|
|
25003
|
+
}
|
|
25004
|
+
/**
|
|
25005
|
+
* Reads the mirror once with `token`, for `board doctor`: the result, or an `AdapterError`
|
|
25006
|
+
* carrying its mirror failure code.
|
|
25007
|
+
*/
|
|
25008
|
+
function readProjectMirror(target, { token, now, fetch: fetcher, signal }) {
|
|
25009
|
+
return readMirrorWith(new GithubClient(token, now, fetcher), target, signal);
|
|
25010
|
+
}
|
|
25011
|
+
/**
|
|
25012
|
+
* A github-project source: each poll is one complete read of the mirror, or a failure. The
|
|
25013
|
+
* option id resolved by the first read is kept, so a renamed option still matches and a removed
|
|
25014
|
+
* one fails `mirror_field_not_found`.
|
|
25015
|
+
*/
|
|
25016
|
+
function createGithubProjectAdapter(options) {
|
|
25017
|
+
const client = new GithubClient(options.token, options.now, options.fetch);
|
|
25018
|
+
let optionId;
|
|
25019
|
+
return {
|
|
25020
|
+
id: options.id,
|
|
25021
|
+
intervalMs: options.intervalMs,
|
|
25022
|
+
takeUsage: () => client.takeUsage(),
|
|
25023
|
+
async poll(context) {
|
|
25024
|
+
const observedAt = new Date(options.now()).toISOString();
|
|
25025
|
+
try {
|
|
25026
|
+
const read = await readMirrorWith(client, options, context.signal, optionId);
|
|
25027
|
+
optionId = read.optionId;
|
|
25028
|
+
const usage = client.takeUsage();
|
|
25029
|
+
return {
|
|
25030
|
+
source: options.id,
|
|
25031
|
+
observedAt,
|
|
25032
|
+
complete: true,
|
|
25033
|
+
items: [],
|
|
25034
|
+
entities: [],
|
|
25035
|
+
mirror: {
|
|
25036
|
+
title: read.title,
|
|
25037
|
+
readiness: read.readiness
|
|
25038
|
+
},
|
|
25039
|
+
...usage === void 0 ? {} : { usage },
|
|
25040
|
+
budget: read.budget
|
|
25041
|
+
};
|
|
25042
|
+
} catch (error) {
|
|
25043
|
+
if (error instanceof AdapterError) error.usage = client.takeUsage();
|
|
25044
|
+
throw error;
|
|
25045
|
+
}
|
|
25046
|
+
}
|
|
25047
|
+
};
|
|
25048
|
+
}
|
|
24678
25049
|
// ../adapters/src/jira/jira.ts
|
|
24679
25050
|
const SEARCH_PAGE_LIMIT = 20;
|
|
24680
25051
|
const MAX_GET_SEARCH_URL_LENGTH = 2e3;
|
|
@@ -25191,6 +25562,7 @@ function runSource(entry, options, runnerStartMs, budgetWaits) {
|
|
|
25191
25562
|
let failures = 0;
|
|
25192
25563
|
let lastCompleteMs;
|
|
25193
25564
|
let errorBlind;
|
|
25565
|
+
let errorFailure;
|
|
25194
25566
|
let counts = /* @__PURE__ */ new Map();
|
|
25195
25567
|
let hydrated = false;
|
|
25196
25568
|
let gone = [];
|
|
@@ -25217,9 +25589,19 @@ function runSource(entry, options, runnerStartMs, budgetWaits) {
|
|
|
25217
25589
|
return {
|
|
25218
25590
|
...lastCompleteMs === void 0 ? {} : { lastCompleteAt: iso$1(lastCompleteMs) },
|
|
25219
25591
|
...blind === void 0 ? {} : { blind },
|
|
25592
|
+
...errorFailure === void 0 ? {} : { failure: errorFailure },
|
|
25220
25593
|
gone
|
|
25221
25594
|
};
|
|
25222
25595
|
}
|
|
25596
|
+
/** The failure a failed poll reports: the error's code or the entry's default, else none. */
|
|
25597
|
+
function failureOf(error, step) {
|
|
25598
|
+
const code = (error instanceof AdapterError ? error.code : void 0) ?? entry.defaultFailureCode;
|
|
25599
|
+
if (code === void 0) return void 0;
|
|
25600
|
+
return {
|
|
25601
|
+
code,
|
|
25602
|
+
message: error instanceof AdapterError ? error.message : `The ${step} step failed`
|
|
25603
|
+
};
|
|
25604
|
+
}
|
|
25223
25605
|
/** Appends the current state to the serial report chain; resolves when its step is done. */
|
|
25224
25606
|
let pendingPoints;
|
|
25225
25607
|
function report(usage, allowStopped = false) {
|
|
@@ -25346,6 +25728,7 @@ function runSource(entry, options, runnerStartMs, budgetWaits) {
|
|
|
25346
25728
|
code: issue.code,
|
|
25347
25729
|
message: issue.message
|
|
25348
25730
|
})));
|
|
25731
|
+
errorFailure = failureOf(error, "batch");
|
|
25349
25732
|
outcome = {
|
|
25350
25733
|
kind: "failed",
|
|
25351
25734
|
error
|
|
@@ -25377,6 +25760,7 @@ function runSource(entry, options, runnerStartMs, budgetWaits) {
|
|
|
25377
25760
|
gone = outcomes.gone;
|
|
25378
25761
|
lastCompleteMs = proposedLastCompleteMs;
|
|
25379
25762
|
errorBlind = void 0;
|
|
25763
|
+
errorFailure = void 0;
|
|
25380
25764
|
lastReported = JSON.stringify(proposedState);
|
|
25381
25765
|
});
|
|
25382
25766
|
reports = accepted.then(() => void 0, () => void 0);
|
|
@@ -25397,6 +25781,7 @@ function runSource(entry, options, runnerStartMs, budgetWaits) {
|
|
|
25397
25781
|
reason: error.kind,
|
|
25398
25782
|
message: error.message
|
|
25399
25783
|
};
|
|
25784
|
+
errorFailure = failureOf(error, step);
|
|
25400
25785
|
outcome = {
|
|
25401
25786
|
kind: "failed",
|
|
25402
25787
|
error
|
|
@@ -25983,11 +26368,11 @@ async function sampleLinkRules({ repo, login, tracker, link }, { token, now, fet
|
|
|
25983
26368
|
};
|
|
25984
26369
|
}
|
|
25985
26370
|
// ../adapters/src/index.ts
|
|
25986
|
-
function blindSource(id, intervalMs, message) {
|
|
26371
|
+
function blindSource(id, intervalMs, message, code) {
|
|
25987
26372
|
return {
|
|
25988
26373
|
id,
|
|
25989
26374
|
intervalMs,
|
|
25990
|
-
poll: () => Promise.reject(new AdapterError("config", message))
|
|
26375
|
+
poll: () => Promise.reject(new AdapterError("config", message, code === void 0 ? {} : { code }))
|
|
25991
26376
|
};
|
|
25992
26377
|
}
|
|
25993
26378
|
/** Starts polling each configured source. */
|
|
@@ -26027,6 +26412,21 @@ function startAdapters(config, core, options) {
|
|
|
26027
26412
|
}) : blindSource(id, intervalMs, "GitHub credential is missing"),
|
|
26028
26413
|
reserveRemaining: config.github.reserveRemaining
|
|
26029
26414
|
});
|
|
26415
|
+
const mirror = readyMirrorOf(project);
|
|
26416
|
+
const mirrorId = mirrorSourceId(project);
|
|
26417
|
+
if (mirror !== void 0 && mirrorId !== void 0) entries.push({
|
|
26418
|
+
adapter: githubToken ? createGithubProjectAdapter({
|
|
26419
|
+
id: mirrorId,
|
|
26420
|
+
repo: project.tracker.repo,
|
|
26421
|
+
mirror,
|
|
26422
|
+
token: githubToken,
|
|
26423
|
+
now: options.now,
|
|
26424
|
+
intervalMs,
|
|
26425
|
+
...options.fetch === void 0 ? {} : { fetch: options.fetch }
|
|
26426
|
+
}) : blindSource(mirrorId, intervalMs, "GitHub credential is missing", "mirror_project_forbidden"),
|
|
26427
|
+
reserveRemaining: 2 * config.github.reserveRemaining,
|
|
26428
|
+
defaultFailureCode: "mirror_read_failed"
|
|
26429
|
+
});
|
|
26030
26430
|
}
|
|
26031
26431
|
if (githubToken) entries.push(...githubSources(config, {
|
|
26032
26432
|
token: githubToken,
|
|
@@ -27945,6 +28345,83 @@ function reviewRuleCheck(outcomes) {
|
|
|
27945
28345
|
const tail = `${has("unfollowed") ? addTail : ""}${has("unread") ? REVIEW_RULE_READ_TAIL : ""}`;
|
|
27946
28346
|
return warning(id, fitFix([...problems, ...segments.filter((segment) => !segment.problem)], tail, `${String(problems.length)} repos have no review rule to follow or could not be read.${tail}`));
|
|
27947
28347
|
}
|
|
28348
|
+
const MIRROR_TOKEN_FIX = "Add GITHUB_TOKEN with the read:project scope to secrets.env, then rerun board doctor to read the GitHub Project each ready-for-dev column mirrors.";
|
|
28349
|
+
const MIRROR_UNREAD_FIX = "Rerun board doctor; if the GitHub Project still cannot be read in time, check the daemon log for the GitHub error.";
|
|
28350
|
+
/** The projects whose ready-for-dev column mirrors a GitHub Project, with their tracker repo. */
|
|
28351
|
+
function mirroredProjects(config) {
|
|
28352
|
+
return config.projects.flatMap((project) => {
|
|
28353
|
+
const mirror = readyMirrorOf(project);
|
|
28354
|
+
return mirror === void 0 || project.tracker.type !== "github-issues" ? [] : [{
|
|
28355
|
+
project,
|
|
28356
|
+
repo: project.tracker.repo,
|
|
28357
|
+
mirror
|
|
28358
|
+
}];
|
|
28359
|
+
});
|
|
28360
|
+
}
|
|
28361
|
+
function readMirrors(ctx, fetcher, deadlineMs, token) {
|
|
28362
|
+
return Promise.all(mirroredProjects(ctx.config).map(async (entry) => ({
|
|
28363
|
+
...entry,
|
|
28364
|
+
read: await deadlineCall(ctx, deadlineMs, "doctor.mirror", "GitHub Project mirror read failed", async (signal) => {
|
|
28365
|
+
try {
|
|
28366
|
+
return { found: await readProjectMirror({
|
|
28367
|
+
repo: entry.repo,
|
|
28368
|
+
mirror: entry.mirror
|
|
28369
|
+
}, {
|
|
28370
|
+
token,
|
|
28371
|
+
now: () => ctx.clock.now(),
|
|
28372
|
+
fetch: fetcher,
|
|
28373
|
+
signal
|
|
28374
|
+
}) };
|
|
28375
|
+
} catch (error) {
|
|
28376
|
+
if (!(error instanceof AdapterError) || error.code === void 0) throw error;
|
|
28377
|
+
return {
|
|
28378
|
+
code: error.code,
|
|
28379
|
+
message: error.message
|
|
28380
|
+
};
|
|
28381
|
+
}
|
|
28382
|
+
})
|
|
28383
|
+
})));
|
|
28384
|
+
}
|
|
28385
|
+
function mirrorSegment({ project, mirror, read }) {
|
|
28386
|
+
const where = `${project.id} ${mirror.project}`;
|
|
28387
|
+
if (read === null) return {
|
|
28388
|
+
problem: true,
|
|
28389
|
+
unmatched: false,
|
|
28390
|
+
cause: "unread",
|
|
28391
|
+
text: () => `${where}: could not read the Project`
|
|
28392
|
+
};
|
|
28393
|
+
if ("code" in read) {
|
|
28394
|
+
const detail = read.code === "mirror_field_not_found" ? `, field ${mirror.field} option ${mirror.value}` : "";
|
|
28395
|
+
return {
|
|
28396
|
+
problem: true,
|
|
28397
|
+
unmatched: false,
|
|
28398
|
+
cause: read.code,
|
|
28399
|
+
text: () => `${where}: ${read.code}${detail}`
|
|
28400
|
+
};
|
|
28401
|
+
}
|
|
28402
|
+
const title = branchText(read.found.title);
|
|
28403
|
+
return {
|
|
28404
|
+
problem: false,
|
|
28405
|
+
unmatched: false,
|
|
28406
|
+
cause: null,
|
|
28407
|
+
text: () => `${where} "${title}": field ${mirror.field}, option ${mirror.value}`
|
|
28408
|
+
};
|
|
28409
|
+
}
|
|
28410
|
+
function mirrorCheck(outcomes) {
|
|
28411
|
+
const id = "github.mirror";
|
|
28412
|
+
if (outcomes === null) return warning(id, MIRROR_TOKEN_FIX);
|
|
28413
|
+
const segments = outcomes.map(mirrorSegment);
|
|
28414
|
+
const problems = segments.filter((segment) => segment.problem);
|
|
28415
|
+
const first = problems[0]?.cause;
|
|
28416
|
+
if (first === void 0 || first === null) return {
|
|
28417
|
+
id,
|
|
28418
|
+
status: "pass",
|
|
28419
|
+
blocking: false,
|
|
28420
|
+
fix: fitFix(segments, "", `Read the GitHub Project of ${String(segments.length)} projects.`)
|
|
28421
|
+
};
|
|
28422
|
+
const tail = ` ${first === "unread" ? MIRROR_UNREAD_FIX : MIRROR_FAILURES[first].fix}`;
|
|
28423
|
+
return warning(id, fitFix([...problems, ...segments.filter((segment) => !segment.problem)], tail, `${String(problems.length)} mirrored GitHub Projects could not be read.${tail}`));
|
|
28424
|
+
}
|
|
27948
28425
|
const CURATOR_TAIL = "Start a Spur session of each curator with no live session.";
|
|
27949
28426
|
function curatorSessionsCheck(entries) {
|
|
27950
28427
|
const id = "curator.sessions";
|
|
@@ -28142,6 +28619,8 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch, { deadlineM
|
|
|
28142
28619
|
const ruled = ruledRepos(config).length > 0;
|
|
28143
28620
|
const ruleToken = secrets["GITHUB_TOKEN"];
|
|
28144
28621
|
const reviewRules = ruled && ruleToken !== void 0 ? readReviewRules(ctx, fetcher, deadlineMs, ruleToken) : null;
|
|
28622
|
+
const mirrored = mirroredProjects(config).length > 0;
|
|
28623
|
+
const mirrors = mirrored && ruleToken !== void 0 ? readMirrors(ctx, fetcher, deadlineMs, ruleToken) : null;
|
|
28145
28624
|
const missing = requiredSecretKeys(config).filter((name) => !secrets[name]);
|
|
28146
28625
|
checks.push(check("secrets", missing.length === 0, `Add ${missing.join(", ")} to the private secrets.env file.`));
|
|
28147
28626
|
const jiraEmail = secrets["JIRA_EMAIL"];
|
|
@@ -28163,6 +28642,7 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch, { deadlineM
|
|
|
28163
28642
|
checks.push(githubCheck(githubFindings));
|
|
28164
28643
|
checks.push(linkRulesCheck(await linkSamples));
|
|
28165
28644
|
if (ruled) checks.push(reviewRuleCheck(reviewRules === null ? null : await reviewRules));
|
|
28645
|
+
if (mirrored) checks.push(mirrorCheck(mirrors === null ? null : await mirrors));
|
|
28166
28646
|
const probe = spurSendRequest(config.adapters.spur.baseUrl, SPUR_PROBE_SESSION, "spur-board doctor probe");
|
|
28167
28647
|
const [spur, spurSend] = await Promise.all([request(ctx, fetcher, deadlineMs, "spur", new URL("sessions", apiBaseUrl(config.adapters.spur.baseUrl))), request(ctx, fetcher, deadlineMs, "spur.send", probe.url, probe.init)]);
|
|
28168
28648
|
checks.push(check("spur.api", spur?.ok === true, "Start or correct the configured Spur API."));
|