Public: anyone can read this; the crew can change it.
Losing the runner slows the gate and never blocks a release of a fix #16838
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/1196-losing-the-runner-slows-the-gate-and-nev → main 0 commits fork 3 threads · 3 unresolved
23 files
changed +814
−29
- docs/APPS.md
- docs/features/runner-not-answering.md
- src/actions/merge_words.ts
- src/actions/pulls.ts
- src/checks/bypass.ts
- src/checks/lane_state.ts
- src/checks/service.ts
- src/checks/silence.ts
- src/core/pulls.ts
- src/core/runs.ts
- src/fleet/verbs.ts
- src/http/api.ts
- src/http/api/pulls.ts
- src/kernel/vitals.ts
- src/tui/screens/common.ts
- src/tui/screens/pull.ts
- src/web/pages/pull.ts
- src/web/studio/words.ts
- test/api-forge-view.test.ts
- test/refusals-lead-somewhere.test.ts
- test/runner-doors.test.ts
- test/runner-silent.test.ts
- test/vitals.test.ts
docs/APPS.md +8
| @@ -189,6 +189,14 @@ Under the box, four starter sentences are plain links (no script): | ||
| 189 | 189 | queues on the assignment. |
| 190 | 190 | - **Every deploy is a run**, and the run is the check on the pull. Turn on |
| 191 | 191 | **require checks** and a pull cannot merge until its head is green. |
| 192 | If the runner makes no progress for 10 minutes (nothing running, nothing | |
| 193 | started or finished) the queued checks settle as cancelled, "the runner is | |
| 194 | not answering" — never red — and vitals says so. Someone with admin can then | |
| 195 | land the pull with a reason of 8–500 characters: the **Land past the gate** | |
| 196 | form on the pull page, `L` in the terminal, or | |
| 197 | `checksUnavailable` (1–500) on the JSON merge route. A check the lane holds on | |
| 198 | purpose (disk, memory, a red main, a deploy running) is never called silent. The reason is posted on the | |
| 199 | pull. A red check is never waived. | |
| 192 | 200 | - **A production deploy records the merged pulls it carries**: one `git |
| 193 | 201 | rev-list` of the deployed commit when the run finishes. The run page says |
| 194 | 202 | "Carries #3, #5" and `GET /api/v1/repos/:owner/:name/runs/:id` has `carries`. |
docs/features/runner-not-answering.md added +19
| @@ -0,0 +1,19 @@ | ||
| 1 | --- | |
| 2 | topic: Ship and undo | |
| 3 | row: The runner is not answering: landing a fix past a check that never started | |
| 4 | --- | |
| 5 | # The runner is not answering | |
| 6 | ||
| 7 | This page is for people who land pulls and for site admins. When the forge cannot start checks (the cell is gone, the machine is out of memory, the queue does not move), a pull that fixes something must still be landable. | |
| 8 | ||
| 9 | If the runner makes no progress for 10 minutes (nothing running, nothing started or finished), the checks still queued settle as cancelled with the summary "the runner is not answering". They are never red. A check the lane waits on for a reason of its own is left queued, not settled: a full disk, memory near its limit, an account at its limit, a red main, a crew run, a merge-queue gate, a later start time, or a deploy running. Vitals lists it as a need for the hour after, and the pull says "The runner is not answering, so this head was never checked." | |
| 10 | ||
| 11 | ## Landing past it | |
| 12 | ||
| 13 | Someone with admin on the repository can land the pull with a reason of 8 to 500 characters. The reason is posted on the pull. It is the same way past the gate that a stopped landing opens (a pull's page says which case it is), and it lands as a squash. | |
| 14 | ||
| 15 | - **Web:** the **Land past the gate** form on the pull's merge box. | |
| 16 | - **Terminal:** `L` on the pull screen asks for the reason, then confirms. | |
| 17 | - **API:** `POST /api/v1/repos/:owner/:name/pulls/:number/merge` with `checksUnavailable` set to the reason. | |
| 18 | ||
| 19 | A red check is never waived by this: it is refused as before. A missing or running check is refused too; only the runner's silence can be waived. |
src/actions/merge_words.ts +1
| @@ -67,6 +67,7 @@ export function mergeFailure(error: AccessError | MergePullError): string { | ||
| 67 | 67 | if (error === "review_required") |
| 68 | 68 | return "This pull request needs an approving review of its current head, and does not have one. Nothing was merged."; |
| 69 | 69 | if (error === "check_stale") return CHECK_STALE_REFUSAL; |
| 70 | if (error === "waiver_needs_reason") return "Landing past an unanswered check needs a reason of 1-500 characters. Nothing was merged."; | |
| 70 | 71 | if (error === "draft") return DRAFT_REFUSAL; |
| 71 | 72 | if (error === "checks_required") |
| 72 | 73 | return "This pull request needs a passing deploy of its current head, and does not have one yet. Nothing was merged."; |
src/actions/pulls.ts +25 −2
| @@ -103,7 +103,8 @@ import { | ||
| 103 | 103 | requireWriter, |
| 104 | 104 | type AccessError, |
| 105 | 105 | } from "./access.ts"; |
| 106 | import { canWrite } from "../core/repos.ts"; | |
| 106 | import { canAdmin, canWrite } from "../core/repos.ts"; | |
| 107 | import { checkSummary, RUNNER_SILENT_SUMMARY, runnerSilent } from "../core/runs.ts"; | |
| 107 | 108 | import { canVerdict } from "../core/verdict.ts"; |
| 108 | 109 | import { refreshPullHead as refreshHead } from "../core/following.ts"; |
| 109 | 110 | import { getOriginRepo } from "../core/origins.ts"; |
| @@ -532,13 +533,23 @@ export async function mergePull( | ||
| 532 | 533 | /** The merge queue's guard: land only onto this base, as this tree (#2036). */ |
| 533 | 534 | expect?: LandingExpect, |
| 534 | 535 | /** `pastGate`: the owner's break-glass (`checks/bypass.ts`) skips the checks and team requirements. */ |
| 535 | opts: { readonly pastGate?: boolean; readonly pastReviews?: boolean } = {}, | |
| 536 | opts: { | |
| 537 | readonly pastGate?: boolean; | |
| 538 | readonly pastReviews?: boolean; | |
| 539 | /** An admin's reason for landing past a check the runner never answered. */ | |
| 540 | readonly waiver?: string; | |
| 541 | } = {}, | |
| 536 | 542 | ): Promise< |
| 537 | 543 | Result<{ mergeOid: string; carried: boolean }, AccessError | MergePullError> |
| 538 | 544 | > { |
| 539 | 545 | const writer = requireWriter(app, actor, repo); |
| 540 | 546 | if (!writer.ok) return writer; |
| 541 | 547 | if (pull.repoId !== repo.id) return err("not_found"); |
| 548 | const reason = opts.waiver?.trim(); | |
| 549 | if (opts.waiver !== undefined) { | |
| 550 | if (!canAdmin(app.db, repo, writer.value)) return err("forbidden"); | |
| 551 | if (!reason || reason.length > 500) return err("waiver_needs_reason"); | |
| 552 | } | |
| 542 | 553 | // Rule 1 in docs/APPS.md: the crew proposes, a person lands. An agent on |
| 543 | 554 | // the crew can write the repository and still may not merge into it. |
| 544 | 555 | if (writer.value.kind === "agent") return err("forbidden"); |
| @@ -611,6 +622,7 @@ export async function mergePull( | ||
| 611 | 622 | requireReview: reviewsDemanded(app.db, repo), |
| 612 | 623 | requireChecks: repo.requireChecks && opts.pastGate !== true, |
| 613 | 624 | freshGreen: opts.pastGate !== true, |
| 625 | waiveUnavailable: reason !== undefined, | |
| 614 | 626 | // Only an app's first change, which the crew's gate decided (`crew/first_change.ts`); never a person's own call. |
| 615 | 627 | ...(opts.pastReviews === true && !repo.requireReview ? { pastReviews: true } : {}), |
| 616 | 628 | // A named team with a reviewer here reads this head first (#10080). |
| @@ -649,6 +661,17 @@ export async function mergePull( | ||
| 649 | 661 | strategy, |
| 650 | 662 | by: writer.value.id, |
| 651 | 663 | }); |
| 664 | // Landing past an unavailable check leaves its reason on the pull. | |
| 665 | if (reason !== undefined) { | |
| 666 | const head = getPull(app.db, repo.id, pull.number)?.headOid ?? pull.headOid; | |
| 667 | const latest = checkSummary(app.db, pull.id, head).run; | |
| 668 | if (latest !== null && runnerSilent(latest)) | |
| 669 | addIssueComment(app.db, { | |
| 670 | issueId: pull.id, | |
| 671 | authorId: writer.value.id, | |
| 672 | body: `Landed with the check unavailable (${RUNNER_SILENT_SUMMARY}). Reason: ${reason}`, | |
| 673 | }); | |
| 674 | } | |
| 652 | 675 | // What came of the decision to show it, when there was one. |
| 653 | 676 | resolveOpen(app.db, pull.id, "land", "shipped"); |
| 654 | 677 | app.bus.append({ |
src/checks/bypass.ts +22 −6
| @@ -17,6 +17,7 @@ import type { User } from "../core/users.ts"; | ||
| 17 | 17 | import { getIssueById } from "../core/issues.ts"; |
| 18 | 18 | import { err, ok, type Result } from "../kernel/result.ts"; |
| 19 | 19 | import { ownLandingStopped } from "./gate_stopped.ts"; |
| 20 | import { checkSummary, runnerSilent } from "../core/runs.ts"; | |
| 20 | 21 | |
| 21 | 22 | export const MIN_REASON = 8; |
| 22 | 23 | export const MAX_REASON = 500; |
| @@ -34,13 +35,25 @@ export function cleanReason(text: string): string | undefined { | ||
| 34 | 35 | return reason.length < MIN_REASON || reason.length > MAX_REASON ? undefined : reason; |
| 35 | 36 | } |
| 36 | 37 | |
| 37 | /** Whether this person may be offered the break-glass on this repository right now. */ | |
| 38 | export function bypassOffered(app: App, actor: User | undefined, repo: Repo): boolean { | |
| 38 | /** | |
| 39 | * Whether the check of this pull's head is one the runner never answered | |
| 40 | * (`RUNNER_SILENT_SUMMARY`): the one other case that opens the way past. | |
| 41 | */ | |
| 42 | export function checkUnavailable(app: App, pull: Pull): boolean { | |
| 43 | const run = checkSummary(app.db, pull.id, pull.headOid).run; | |
| 44 | return run !== null && runnerSilent(run); | |
| 45 | } | |
| 46 | ||
| 47 | /** | |
| 48 | * Whether this person may be offered the way past the gate on this pull right | |
| 49 | * now: landing has stopped, or the head's check was never answered. | |
| 50 | */ | |
| 51 | export function bypassOffered(app: App, actor: User | undefined, repo: Repo, pull: Pull): boolean { | |
| 39 | 52 | return ( |
| 40 | 53 | actor !== undefined && |
| 41 | 54 | actor.kind !== "agent" && |
| 42 | 55 | canAdmin(app.db, repo, actor) && |
| 43 | ownLandingStopped(app.db, repo) !== undefined | |
| 56 | (ownLandingStopped(app.db, repo) !== undefined || checkUnavailable(app, pull)) | |
| 44 | 57 | ); |
| 45 | 58 | } |
| 46 | 59 | |
| @@ -48,7 +61,7 @@ export function bypassOffered(app: App, actor: User | undefined, repo: Repo): bo | ||
| 48 | 61 | export function bypassRefusal(app: App, actor: User | undefined, repo: Repo, pull: Pull): BypassError | undefined { |
| 49 | 62 | if (actor === undefined || actor.kind === "agent" || !canAdmin(app.db, repo, actor)) return { kind: "forbidden" }; |
| 50 | 63 | if (pull.repoId !== repo.id) return { kind: "not_found" }; |
| 51 | if (ownLandingStopped(app.db, repo) === undefined) return { kind: "not_stopped" }; | |
| 64 | if (ownLandingStopped(app.db, repo) === undefined && !checkUnavailable(app, pull)) return { kind: "not_stopped" }; | |
| 52 | 65 | return undefined; |
| 53 | 66 | } |
| 54 | 67 | |
| @@ -69,9 +82,12 @@ export async function landPastGate( | ||
| 69 | 82 | if (refused !== undefined || actor === undefined) return err(refused ?? { kind: "forbidden" }); |
| 70 | 83 | const reason = cleanReason(reasonText)!; |
| 71 | 84 | const issue = getIssueById(app.db, pull.id); |
| 72 | if (issue !== undefined) | |
| 85 | // Landing stopped: the whole gate is passed. Otherwise only the check the runner never | |
| 86 | // answered is, and `mergePull` leaves that reason on the pull itself. | |
| 87 | const stopped = ownLandingStopped(app.db, repo) !== undefined; | |
| 88 | if (stopped && issue !== undefined) | |
| 73 | 89 | addComment(app, actor, repo, issue, `Landing past the gate, by @${actor.username}: ${reason}`); |
| 74 | const merged = await mergePull(app, actor, repo, pull, "squash", undefined, { pastGate: true }); | |
| 90 | const merged = await mergePull(app, actor, repo, pull, "squash", undefined, stopped ? { pastGate: true } : { waiver: reason }); | |
| 75 | 91 | if (!merged.ok) { |
| 76 | 92 | if (issue !== undefined) addComment(app, actor, repo, issue, "That did not land: the merge was refused, and nothing changed."); |
| 77 | 93 | return err({ kind: "merge", error: merged.error }); |
src/checks/lane_state.ts +6 −1
| @@ -3,7 +3,7 @@ import type { App } from "../app.ts"; | ||
| 3 | 3 | import { holdClock } from "../core/one_core.ts"; |
| 4 | 4 | import type { Pull } from "../core/pulls.ts"; |
| 5 | 5 | import type { Repo } from "../core/repos.ts"; |
| 6 | import type { Run } from "../core/runs.ts"; | |
| 6 | import type { Run, silenceUnstartedChecks } from "../core/runs.ts"; | |
| 7 | 7 | import { Gate } from "../git/env.ts"; |
| 8 | 8 | import { runStep } from "../apps/process.ts"; |
| 9 | 9 | import type { DeepsecDeps } from "./deepsec_step.ts"; |
| @@ -95,6 +95,11 @@ export interface ChecksOptions { | ||
| 95 | 95 | /** Test seams: how long a held pull check waits at most, and the clock it is judged by. */ |
| 96 | 96 | readonly holdMaxMs?: number | undefined; |
| 97 | 97 | readonly holdNow?: (() => number) | undefined; |
| 98 | /** | |
| 99 | * Test seam: the sweep that settles checks the runner never took up. @default | |
| 100 | * silenceUnstartedChecks | |
| 101 | */ | |
| 102 | readonly silence?: typeof silenceUnstartedChecks | undefined; | |
| 98 | 103 | } |
| 99 | 104 | /** A gate's answer from the lane: `interrupted` is no verdict (#3155). */ |
| 100 | 105 | export interface GateDone { |
src/checks/service.ts +10 −1
| @@ -26,6 +26,7 @@ import { placementFromEnv } from "./placement.ts"; | ||
| 26 | 26 | import { capacity, PULL_RESERVE, slotted, type ChecksHandle, type ChecksOptions, type LaneState } from "./lane_state.ts"; |
| 27 | 27 | import { makeLocalRunner } from "./local_runner.ts"; |
| 28 | 28 | import { sweepSoon } from "./sweep.ts"; |
| 29 | import { silenceTick } from "./silence.ts"; | |
| 29 | 30 | import { request } from "./request.ts"; |
| 30 | 31 | import { schedule } from "./scheduler.ts"; |
| 31 | 32 | import { askVerifications, catchUp } from "./verify_lane.ts"; |
| @@ -118,8 +119,16 @@ export function startChecks(app: App, options: ChecksOptions): ChecksHandle { | ||
| 118 | 119 | // A hosted child's lane runs on its parent's thread: its ticks are named for it |
| 119 | 120 | // (`perf/child_time.ts`). |
| 120 | 121 | const owner = options.label === undefined ? undefined : childLabel(options.label); |
| 122 | // A check that waited past the bound without a runner taking it up is said | |
| 123 | // to be unavailable, never red (`RUNNER_SILENT_SUMMARY`). It rides the same | |
| 124 | // named tick as the schedule. | |
| 125 | const tick = () => { | |
| 126 | lane.schedule(); | |
| 127 | silenceTick(lane); | |
| 128 | }; | |
| 121 | 129 | const timer = setInterval(() => { |
| 122 | if (!lane.stopped) during("lane", lane.schedule, owner, app); | |
| 130 | if (lane.stopped) return; | |
| 131 | during("lane", tick, owner, app); | |
| 123 | 132 | }, options.tickMs ?? TICK_MS); |
| 124 | 133 | // Main is verified after landing on a schedule, when the forge says how often. |
| 125 | 134 | const sweeper = |
src/checks/silence.ts added +37
| @@ -0,0 +1,37 @@ | ||
| 1 | /** | |
| 2 | * The lane's call on a silent runner. A queued check is only called | |
| 3 | * unavailable when nothing explains the wait: a full disk, a tight memory, | |
| 4 | * an account at its limit, a red main, a crew run, a merge-queue gate, a | |
| 5 | * later start time or a running deploy each say why it waits, and none of | |
| 6 | * them is the runner being gone (#1196). | |
| 7 | */ | |
| 8 | ||
| 9 | import { activeCrewRuns, crewHoldsCore, forgeCpus } from "../core/one_core.ts"; | |
| 10 | import { silenceUnstartedChecks, type Run } from "../core/runs.ts"; | |
| 11 | import { usedRefusal } from "../apps/disk_guard.ts"; | |
| 12 | import { memoryHold } from "../runs/memory_hold.ts"; | |
| 13 | import { appendRunLog } from "../runs/log.ts"; | |
| 14 | import { heldByRed, redMain } from "./red_main.ts"; | |
| 15 | import { gatesInFlight } from "./queue.ts"; | |
| 16 | import { slotted, type LaneState } from "./lane_state.ts"; | |
| 17 | ||
| 18 | /** Whether the lane is waiting on purpose to start `run`, at `now`. */ | |
| 19 | export function heldOnPurpose(lane: LaneState, run: Run, now: number): boolean { | |
| 20 | const { app, options } = lane; | |
| 21 | if (lane.waiting.has(run.id) || lane.diskWaiting.has(run.id) || lane.memoryWaiting.has(run.id)) return true; | |
| 22 | if (lane.holding > 0 || gatesInFlight() > 0) return true; | |
| 23 | if (run.notBefore !== null && Date.parse(run.notBefore) > now) return true; | |
| 24 | if (usedRefusal(app.config.dataDir) !== undefined) return true; | |
| 25 | if (memoryHold(slotted(lane), options.pressure) !== undefined) return true; | |
| 26 | if (heldByRed(run, redMain(app.db, run.repoId), options.redHoldMs ?? 0, now)) return true; | |
| 27 | const crew = crewHoldsCore((options.cpus ?? forgeCpus)(), options.activeCrewRuns ?? (() => activeCrewRuns(app.db))); | |
| 28 | return crew && run.issueId !== null; | |
| 29 | } | |
| 30 | ||
| 31 | /** One sweep: settle what waited with no explanation, and say so in each log. */ | |
| 32 | export function silenceTick(lane: LaneState, now: number = Date.now()): void { | |
| 33 | const sweep = lane.options.silence ?? silenceUnstartedChecks; | |
| 34 | const inFlight = new Set(lane.inFlight.keys()); | |
| 35 | for (const run of sweep(lane.app.db, now, inFlight, (queued) => heldOnPurpose(lane, queued, now))) | |
| 36 | appendRunLog(lane.app.config.dataDir, run.id, run.summary); | |
| 37 | } |
src/core/pulls.ts +22 −3
| @@ -47,7 +47,7 @@ import { | ||
| 47 | 47 | } from "./issues.ts"; |
| 48 | 48 | import { approvalRecord, listReviews, reviewSummary, type ApprovalRecord } from "./reviews.ts"; |
| 49 | 49 | import { checkStale, checksHold } from "../checks/stale.ts"; |
| 50 | import { checkSummary } from "./runs.ts"; | |
| 50 | import { checkSummary, runnerSilent } from "./runs.ts"; | |
| 51 | 51 | import { writeStamp } from "./write_clock.ts"; |
| 52 | 52 | import { isDeleting } from "./repo_deleting.ts"; |
| 53 | 53 | |
| @@ -854,6 +854,11 @@ export interface ReviewGate { | ||
| 854 | 854 | * Read live inside the merge like the review verdict. @default false |
| 855 | 855 | */ |
| 856 | 856 | readonly requireChecks?: boolean; |
| 857 | /** | |
| 858 | * A person with admin has vouched for landing past a check the runner never | |
| 859 | * answered. Waives only that; a red or missing check still refuses. | |
| 860 | */ | |
| 861 | readonly waiveUnavailable?: boolean; | |
| 857 | 862 | /** |
| 858 | 863 | * A green check of an older base holds the landing even where checks are |
| 859 | 864 | * not required (#12656): what was checked is not the tree that lands, and a |
| @@ -1175,6 +1180,16 @@ export interface Guarded { | ||
| 1175 | 1180 | readonly why: string; |
| 1176 | 1181 | } |
| 1177 | 1182 | |
| 1183 | /** | |
| 1184 | * Whether the required check at this head allows landing: green, or the runner never answered and | |
| 1185 | * an admin waived it. | |
| 1186 | */ | |
| 1187 | export function checkAllows(gate: ReviewGate, headOid: string, pullId: string): boolean { | |
| 1188 | const summary = checkSummary(gate.db, pullId, headOid); | |
| 1189 | if (summary.state === "ok") return true; | |
| 1190 | return gate.waiveUnavailable === true && summary.run !== null && runnerSilent(summary.run); | |
| 1191 | } | |
| 1192 | ||
| 1178 | 1193 | export type MergePullError = |
| 1179 | 1194 | | MergeError |
| 1180 | 1195 | /** |
| @@ -1190,6 +1205,8 @@ export type MergePullError = | ||
| 1190 | 1205 | | "review_required" |
| 1191 | 1206 | /** The repo requires a passing deploy of this head, and there is none yet. */ |
| 1192 | 1207 | | "checks_required" |
| 1208 | /** Landing past an unavailable check needs a reason, and admin. */ | |
| 1209 | | "waiver_needs_reason" | |
| 1193 | 1210 | /** The head is green, but the check ran on an older base than main now is (#12656). */ |
| 1194 | 1211 | | "check_stale" |
| 1195 | 1212 | /** A team the pull's issue names has a reviewer here and has not approved this head (#10080). */ |
| @@ -1253,7 +1270,7 @@ export async function mergePull( | ||
| 1253 | 1270 | return err("review_required"); |
| 1254 | 1271 | if ( |
| 1255 | 1272 | input.gate?.requireChecks === true && |
| 1256 | checkSummary(input.gate.db, pull.id, there.headOid).state !== "ok" | |
| 1273 | !checkAllows(input.gate, there.headOid, pull.id) | |
| 1257 | 1274 | ) |
| 1258 | 1275 | return err("checks_required"); |
| 1259 | 1276 | if (!there.mergeable) |
| @@ -1310,7 +1327,9 @@ export async function mergePull( | ||
| 1310 | 1327 | // A green of an older base is told apart from no green: re-run, not wait. |
| 1311 | 1328 | if (check.state === "ok" && stale && (input.gate.requireChecks === true || input.gate.freshGreen === true)) |
| 1312 | 1329 | return err("check_stale"); |
| 1313 | if (checksHold(input.gate.requireChecks === true, check.state, stale)) | |
| 1330 | const waived = | |
| 1331 | input.gate.waiveUnavailable === true && check.run !== null && runnerSilent(check.run); | |
| 1332 | if (!waived && checksHold(input.gate.requireChecks === true, check.state, stale)) | |
| 1314 | 1333 | return err("checks_required"); |
| 1315 | 1334 | } |
| 1316 | 1335 | // A kept fork lands its combined branch, brought up to the base first: |
src/core/runs.ts +57
| @@ -652,6 +652,63 @@ export function failAbandonedRuns( | ||
| 652 | 652 | .run(cutoff, JSON.stringify(kinds)).changes; |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | /** | |
| 656 | * What a check that never started says: the runner did not take it up in | |
| 657 | * `RUNNER_WAIT_MAX_MS`. Not a verdict on the change — never red — and the | |
| 658 | * one string by which a person with admin may land past it (`mergePull`). | |
| 659 | */ | |
| 660 | export const RUNNER_SILENT_SUMMARY = "the runner is not answering"; | |
| 661 | ||
| 662 | /** How long a check may sit queued before the runner is called silent. */ | |
| 663 | export const RUNNER_WAIT_MAX_MS = 10 * 60_000; | |
| 664 | ||
| 665 | /** Whether this run is a check the runner never answered. */ | |
| 666 | export const runnerSilent = (run: Run): boolean => | |
| 667 | run.kind === "check" && | |
| 668 | run.state === "cancelled" && | |
| 669 | run.summary === RUNNER_SILENT_SUMMARY; | |
| 670 | ||
| 671 | /** | |
| 672 | * Settle the queued checks as unavailable (cancelled, saying so) when the | |
| 673 | * runner has made no progress: nothing in flight (`inFlight`, or running in | |
| 674 | * the table) and no check started or finished since `RUNNER_WAIT_MAX_MS` | |
| 675 | * ago, while the oldest queued one is older than that. A check waiting | |
A held lane (disk, budget, pause: |
||
| 676 | * behind a working runner is only waiting, so how long one check has waited | |
| 677 | * is never the test. Returns the runs it settled. | |
| 678 | */ | |
| 679 | export function silenceUnstartedChecks( | |
| 680 | db: Database, | |
| 681 | now: number, | |
| 682 | inFlight: ReadonlySet<string> = new Set(), | |
| 683 | /** A queued check the lane waits on for a reason of its own: never called silent. */ | |
| 684 | held: (run: Run) => boolean = () => false, | |
| 685 | ): Run[] { | |
| 686 | if (inFlight.size > 0) return []; | |
| 687 | const cutoff = new Date(now - RUNNER_WAIT_MAX_MS).toISOString(); | |
| 688 | const alive = db | |
| 689 | .query<{ n: number }, [string]>( | |
| 690 | `SELECT COUNT(*) AS n FROM run WHERE (kind = 'check' AND ( | |
| 691 | state = 'running' OR started_at >= ?1 | |
| 692 | OR (started_at IS NOT NULL AND finished_at >= ?1))) | |
| 693 | OR (kind = 'deploy' AND state = 'running')`, | |
| 694 | ) | |
| 695 | .get(cutoff); | |
| 696 | if (alive === null || alive.n > 0) return []; | |
| 697 | const out: Run[] = []; | |
| 698 | for (const row of db | |
| 699 | .query< | |
| 700 | { id: string }, | |
| 701 | [string] | |
| 702 | >("SELECT id FROM run WHERE kind = 'check' AND state = 'queued' AND created_at < ?1") | |
| 703 | .all(cutoff)) { | |
| 704 | const queued = getRun(db, row.id); | |
| 705 | if (queued === undefined || held(queued)) continue; | |
| 706 | const done = cancelRun(db, row.id, RUNNER_SILENT_SUMMARY); | |
| 707 | if (done) out.push(done); | |
| 708 | } | |
| 709 | return out; | |
| 710 | } | |
| 711 | ||
| 655 | 712 | /** What a check the forge's own restart cut off says as it is queued again. */ |
| 656 | 713 | export const REQUEUED_SUMMARY = "interrupted by a restart; queued again"; |
| 657 | 714 |
src/fleet/verbs.ts +1
| @@ -128,6 +128,7 @@ const WORDS: Record<string, string> = { | ||
| 128 | 128 | already_merged: "a merged pull stays closed", |
| 129 | 129 | check_stale: CHECK_STALE_REFUSAL, |
| 130 | 130 | draft: DRAFT_REFUSAL, |
| 131 | waiver_needs_reason: "landing past an unanswered check needs a reason of 1-500 characters", | |
| 131 | 132 | reason_required: "a bug closed without a fix says why: add a reason", |
| 132 | 133 | invalid_note: "a reason is one sentence of at most 300 characters", |
| 133 | 134 | finished: "already finished", |
src/http/api.ts +2
| @@ -676,6 +676,8 @@ export function originAware(error: string, status = 422): Response { | ||
| 676 | 676 | "a bug closed without a fix says why: send `note` (one sentence, at most 300 characters)", |
| 677 | 677 | ); |
| 678 | 678 | if (error === "check_stale") return apiError("check_stale", 409, CHECK_STALE_REFUSAL); |
| 679 | if (error === "waiver_needs_reason") | |
| 680 | return apiError("waiver_needs_reason", 422, "`checksUnavailable` is the reason for landing past an unanswered check: 1 to 500 characters"); | |
| 679 | 681 | if (error === "draft") return apiError("draft", 409, DRAFT_REFUSAL); |
| 680 | 682 | if (error === "planner_paused") return apiError("planner_paused", 409, PAUSE_REFUSAL); |
| 681 | 683 | if (error === "planner_ceiling") return apiError("planner_ceiling", 409, CEILING_REFUSAL); |
src/http/api/pulls.ts +2
| @@ -570,6 +570,8 @@ export function pullRoutes(router: Router<Handler>): void { | ||
| 570 | 570 | found.repo, |
| 571 | 571 | found.pull, |
| 572 | 572 | strategy, |
| 573 | undefined, | |
| 574 | typeof input.checksUnavailable === "string" ? { waiver: input.checksUnavailable } : {}, | |
| 573 | 575 | ); |
| 574 | 576 | if (!merged.ok) { |
| 575 | 577 | if (typeof merged.error !== "string") |
src/kernel/vitals.ts +18
| @@ -25,6 +25,7 @@ import { | ||
| 25 | 25 | listRunning, |
| 26 | 26 | queueDepth, |
| 27 | 27 | queuedApart, |
| 28 | RUNNER_SILENT_SUMMARY, | |
| 28 | 29 | } from "../core/runs.ts"; |
| 29 | 30 | import { HOLD_WORDS, heldRuns, lastHeldAt, type HoldCause } from "../runs/held.ts"; |
| 30 | 31 | import { STALE_AFTER_MS } from "../runs/lease.ts"; |
| @@ -615,6 +616,23 @@ export function vitals(input: VitalsInput): Vitals { | ||
| 615 | 616 | } |
| 616 | 617 | } |
| 617 | 618 | |
| 619 | // Checks the runner never took up settled as unavailable, not red (`silenceUnstartedChecks`): | |
| 620 | // said here for the hour after, so a fix that waits on one is not read as a bad change. | |
| 621 | const silent = input.db | |
| 622 | .query<{ n: number; since: string | null }, [string, string]>( | |
| 623 | `SELECT COUNT(*) AS n, MIN(finished_at) AS since FROM run | |
| 624 | WHERE kind = 'check' AND state = 'cancelled' AND summary = ?1 AND finished_at > ?2`, | |
| 625 | ) | |
| 626 | .get(RUNNER_SILENT_SUMMARY, new Date(now - 3_600_000).toISOString()); | |
| 627 | if (silent !== null && silent.n > 0) | |
| 628 | need( | |
| 629 | "todo", | |
| 630 | "runner:silent", | |
| 631 | `The runner is not answering: ${silent.n} check${silent.n === 1 ? "" : "s"} could not start.`, | |
| 632 | silent.since ?? undefined, | |
| 633 | "/settings/capacity", | |
| 634 | ); | |
| 635 | ||
| 618 | 636 | const stuck: Vitals["stuck"] = []; |
| 619 | 637 | for (const { run, repo, issue } of running) { |
| 620 | 638 | const started = new Date(run.startedAt ?? run.createdAt).getTime(); |
src/tui/screens/common.ts +1
| @@ -1067,6 +1067,7 @@ const MESSAGES: Record<string, string> = { | ||
| 1067 | 1067 | // Apps, runs and the crew (docs/APPS.md). `checks_required` is the merge |
| 1068 | 1068 | // gate refusing, so like `review_required` it names what to do about it. |
| 1069 | 1069 | checks_required: "this needs a passing deploy of its current head first", |
| 1070 | waiver_needs_reason: "landing past an unanswered check needs a reason (1-500 characters)", | |
| 1070 | 1071 | check_stale: CHECK_STALE_REFUSAL, |
| 1071 | 1072 | draft: DRAFT_REFUSAL, |
| 1072 | 1073 | not_draft: "this pull is not a draft", |
src/tui/screens/pull.ts +13 −5
| @@ -52,7 +52,7 @@ import { | ||
| 52 | 52 | } from "../../actions/pulls.ts"; |
| 53 | 53 | import { holdPull, releasePull } from "../../actions/holds.ts"; |
| 54 | 54 | import { getHold, type Hold } from "../../core/holds.ts"; |
| 55 | import { bypassOffered, cleanReason, landPastGate } from "../../checks/bypass.ts"; | |
| 55 | import { bypassOffered, checkUnavailable, cleanReason, landPastGate } from "../../checks/bypass.ts"; | |
| 56 | 56 | import { revertPull } from "../../actions/revert.ts"; |
| 57 | 57 | import { landSlice, sliceChoices } from "../../actions/pull_slices.ts"; |
| 58 | 58 | import { takeBackWords } from "../../actions/revert_words.ts"; |
| @@ -95,7 +95,7 @@ import { reviewWords } from "../../actions/review_words.ts"; | ||
| 95 | 95 | import { verdictOf, type Verdict } from "../../web/pages/pull-verdict.ts"; |
| 96 | 96 | import { wallOf, wallPlain, type Wall } from "../../contract/policy.ts"; |
| 97 | 97 | import { changedSentences } from "../../core/pulls.ts"; |
| 98 | import { checkSummary, type CheckSummary } from "../../core/runs.ts"; | |
| 98 | import { checkSummary, runnerSilent, type CheckSummary } from "../../core/runs.ts"; | |
| 99 | 99 | import { err, ok } from "../../kernel/result.ts"; |
| 100 | 100 | import { getUsersByIds } from "../../core/users.ts"; |
| 101 | 101 | import { |
| @@ -984,20 +984,26 @@ export function pullScreen( | ||
| 984 | 984 | }; |
| 985 | 985 | |
| 986 | 986 | const mayLandPast = (): boolean => { |
| 987 | if (repo === undefined || !bypassOffered(f.app, f.user, repo)) return false; | |
| 987 | if (repo === undefined) return false; | |
| 988 | 988 | const row = getPull(f.db, repo.id, number); |
| 989 | return row !== undefined && row.mergedAt === null && detail?.issue.state === "open"; | |
| 989 | return ( | |
| 990 | row !== undefined && | |
| 991 | bypassOffered(f.app, f.user, repo, row) && | |
| 992 | row.mergedAt === null && | |
| 993 | detail?.issue.state === "open" | |
| 994 | ); | |
| 990 | 995 | }; |
| 991 | 996 | |
| 992 | 997 | /** `L` — a reason, then a plan to confirm, then the landing; `landPastGate` decides. */ |
| 993 | 998 | const landPast = (): void => { |
| 994 | 999 | if (repo === undefined) return; |
| 995 | 1000 | const target = repo; |
| 1001 | const row0 = getPull(f.db, target.id, number); | |
| 996 | 1002 | ctx.push( |
| 997 | 1003 | promptScreen(ctx, screen, { |
| 998 | 1004 | title: `Land #${number} past the gate`, |
| 999 | 1005 | label: "Why this lands without its checks", |
| 1000 | hint: "Landing has stopped. 8 to 500 characters; it goes on the pull's trail.", | |
| 1006 | hint: `${row0 !== undefined && checkUnavailable(f.app, row0) ? "The runner never answered this head's check." : "Landing has stopped."} 8 to 500 characters; it goes on the pull's trail.`, | |
| 1001 | 1007 | onSubmit: (value) => { |
| 1002 | 1008 | const reason = cleanReason(value); |
| 1003 | 1009 | if (reason === undefined) return "Say why in 8 to 500 characters."; |
| @@ -2029,6 +2035,8 @@ function checksLine( | ||
| 2029 | 2035 | export function checksRefusal(check: CheckSummary, old = false): string { |
| 2030 | 2036 | if (old && check.state === "ok") |
| 2031 | 2037 | return "checked against an older base; press C to check again"; |
| 2038 | if (check.run !== null && runnerSilent(check.run)) | |
| 2039 | return "the runner is not answering, so this head was never checked; an admin can land it past with L and a reason"; | |
| 2032 | 2040 | switch (check.state) { |
| 2033 | 2041 | case "failed": |
| 2034 | 2042 | return `the ${check.run?.kind === "check" ? "check" : "deploy"} of this head failed${check.run?.summary ? `: ${oneLine(check.run.summary)}` : ""}`; |
src/web/pages/pull.ts +10 −5
| @@ -58,7 +58,7 @@ import { runningProgress } from "../../checks/progress.ts"; | ||
| 58 | 58 | import { checkStale, checksHold } from "../../checks/stale.ts"; |
| 59 | 59 | import { isDraft, isTalkDraft, TALK_DRAFT, TALK_DRAFT_LINE } from "../../core/pulls.ts"; |
| 60 | 60 | import { appsRuntime } from "../../apps/runtime.ts"; |
| 61 | import { checkSummary, type CheckSummary } from "../../core/runs.ts"; | |
| 61 | import { checkSummary, runnerSilent, type CheckSummary } from "../../core/runs.ts"; | |
| 62 | 62 | import { |
| 63 | 63 | anchorKey, |
| 64 | 64 | byAnchor, |
| @@ -71,7 +71,7 @@ import { | ||
| 71 | 71 | import { getUsersByIds } from "../../core/users.ts"; |
| 72 | 72 | import { canAdmin, canWrite, getRepoById, type Repo } from "../../core/repos.ts"; |
| 73 | 73 | import { canVerdict } from "../../core/verdict.ts"; |
| 74 | import { bypassOffered, landPastGate, type BypassError } from "../../checks/bypass.ts"; | |
| 74 | import { bypassOffered, checkUnavailable, landPastGate, type BypassError } from "../../checks/bypass.ts"; | |
| 75 | 75 | import { commitLog, readerFor } from "../../git/read.ts"; |
| 76 | 76 | import { wallOf } from "../../contract/policy.ts"; |
| 77 | 77 | import type { Ctx } from "../../http/context.ts"; |
| @@ -769,6 +769,9 @@ function mergeBox( | ||
| 769 | 769 | : check.state === "running" || check.state === "queued" |
| 770 | 770 | ? html`This head is still deploying. The merge unlocks when the check |
| 771 | 771 | passes.` |
| 772 | : check.run !== null && runnerSilent(check.run) | |
| 773 | ? html`The runner is not answering, so this head was never | |
| 774 | checked. A person with admin can land it with a reason.` | |
| 772 | 775 | : check.state === "cancelled" |
| 773 | 776 | ? html`The deploy of this head was cancelled. Redeploy the preview, |
| 774 | 777 | or push again.` |
| @@ -786,12 +789,14 @@ function mergeBox( | ||
| 786 | 789 | disabled: true, |
| 787 | 790 | title: "A passing deploy of this head is required first", |
| 788 | 791 | })}${when( |
| 789 | bypassOffered(ctx.app, ctx.auth.user, repo), | |
| 792 | bypassOffered(ctx.app, ctx.auth.user, repo, pull), | |
| 790 | 793 | () => html`<form method="post" action="${thread}/land-past"> |
| 791 | 794 | ${formField({ |
| 792 | 795 | name: "reason", |
| 793 | 796 | label: "Land past the gate", |
| 794 | hint: "Landing has stopped. Say why this pull lands without its checks; it goes on the pull's trail. Review and conflicts still count.", | |
| 797 | hint: checkUnavailable(ctx.app, pull) | |
| 798 | ? "The runner never answered this head's check. Say why it lands without one; it goes on the pull's trail. Review and conflicts still count." | |
| 799 | : "Landing has stopped. Say why this pull lands without its checks; it goes on the pull's trail. Review and conflicts still count.", | |
| 795 | 800 | required: true, |
| 796 | 801 | minlength: 8, |
| 797 | 802 | maxlength: 500, |
| @@ -1801,7 +1806,7 @@ function bypassWords(e: BypassError): string { | ||
| 1801 | 1806 | case "reason": |
| 1802 | 1807 | return "Say why in 8 to 500 characters: it goes on the pull's trail."; |
| 1803 | 1808 | case "not_stopped": |
| 1804 | return "Landing has not stopped, so there is no way past the gate: wait for the checks."; | |
| 1809 | return "Landing has not stopped and the runner answered, so there is no way past the gate: wait for the checks."; | |
| 1805 | 1810 | case "merge": |
| 1806 | 1811 | return `Not landed: ${mergeFailure(e.error)}`; |
| 1807 | 1812 | default: |
src/web/studio/words.ts +9 −1
| @@ -36,6 +36,8 @@ import { | ||
| 36 | 36 | import { |
| 37 | 37 | checkSummary, |
| 38 | 38 | checksForHeads, |
| 39 | RUNNER_SILENT_SUMMARY, | |
| 40 | runnerSilent, | |
| 39 | 41 | STOPPED_SUMMARY, |
| 40 | 42 | type CheckDetail, |
| 41 | 43 | type CheckSummary, |
| @@ -340,7 +342,13 @@ function checkRunWord(check: CheckSummary): { word: Word; note: string } { | ||
| 340 | 342 | if (check.state === "queued") |
| 341 | 343 | return { word: "working", note: "queued to check" }; |
| 342 | 344 | if (check.state === "cancelled") |
| 343 | return { word: "stopped", note: "the check was cancelled" }; | |
| 345 | return { | |
| 346 | word: "stopped", | |
| 347 | note: | |
| 348 | check.run !== null && runnerSilent(check.run) | |
| 349 | ? RUNNER_SILENT_SUMMARY | |
| 350 | : "the check was cancelled", | |
| 351 | }; | |
| 344 | 352 | return { word: "waiting", note: "no deploy of this head yet" }; |
| 345 | 353 | } |
| 346 | 354 |
test/api-forge-view.test.ts +4 −4
| @@ -159,10 +159,10 @@ describe("the forge view over the API", () => { | ||
| 159 | 159 | expect(view.apps.length).toBeLessThanOrEqual(VIEW_APPS); |
| 160 | 160 | expect(view.runs.filter((r) => r.run !== null).length).toBeLessThanOrEqual(50); |
| 161 | 161 | // 120 apps, 960 runs. `mayReadRuns` (shared with /crew/now) reads two |
| 162 | // rows per app today, 21 fixed reads (one is the cloud watch, #16329) before the crew sentences | |
| 163 | // and 3 for them (running work, queued runs, open pulls); anything beyond that, or a read per | |
| 164 | // run, fails. | |
| 165 | expect(selects.length).toBeLessThanOrEqual(2 * APPS + 24); | |
| 162 | // rows per app today, 22 fixed reads (one is the cloud watch, #16329, one the silent-runner | |
| 163 | // count, #1196) before the crew sentences and 3 for them (running work, queued runs, open | |
| 164 | // pulls); anything beyond that, or a read per run, fails. | |
| 165 | expect(selects.length).toBeLessThanOrEqual(2 * APPS + 25); | |
| 166 | 166 | }); |
| 167 | 167 | |
| 168 | 168 | test("foundry has a door only for an app an admin or an admin's org owns", async () => { |
test/refusals-lead-somewhere.test.ts +1
| @@ -44,6 +44,7 @@ const TERMINAL: Readonly<Record<string, string>> = { | ||
| 44 | 44 | "src/crew/bets.ts\tlower the share, or ask a site admin to raise your grant": "The way out itself, shared by the refusal and the card's note beside the share control; the grant is the owner's to raise.", |
| 45 | 45 | "src/web/pages/passkeys.ts\tAsk a site admin of this forge to help": "The reader is signed out and has no account to ask as; the sentence is the recovery page's only way through on a forge that sends no mail.", |
| 46 | 46 | "src/actions/allocation.ts\tRaising the weekly allocation above what it holds": "The forge owner's grant is the ceiling, and the owner is the one who raises it; an admin is told so, and may lower the allocation themselves.", |
| 47 | "src/tui/screens/pull.ts\tthe runner is not answering, so this head was never checked": "It names the key and the reason that land it past (L), the terminal's own control for an admin; a reader who cannot sees the same fact.", | |
| 47 | 48 | "src/actions/spawn.ts\t${name} is already claimed; ask its owner to": "The owner is of another forge (the hosted one), which this forge cannot ask on anyone's behalf.", |
| 48 | 49 | }; |
| 49 | 50 |
test/runner-doors.test.ts added +298
| @@ -0,0 +1,298 @@ | ||
| 1 | /** | |
| 2 | * Landing past a runner that never answered, through each door: the pull | |
| 3 | * page form, the API's `checksUnavailable`, and `m` in the terminal. Only an | |
| 4 | * admin may, with a reason; a writer who is not an admin may not, whatever | |
| 5 | * they send. | |
| 6 | */ | |
| 7 | ||
| 8 | import { signInCookie } from "./helpers/studio-signin"; | |
| 9 | import { createToken } from "../src/core/tokens.ts"; | |
| 10 | import { pollUntil } from "./helpers/poll.ts"; | |
| 11 | import { fixtureSlot } from "./helpers/slot.ts"; | |
| 12 | import { seedAdmin } from "./helpers/admin.ts"; | |
| 13 | import { proveAll } from "./helpers/verified.ts"; | |
| 14 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 15 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 16 | import { tmpdir } from "node:os"; | |
| 17 | import { join } from "node:path"; | |
| 18 | import { addTeamMember, createOrg, createTeam } from "../src/core/orgs.ts"; | |
| 19 | import { openPull } from "../src/actions/pulls.ts"; | |
| 20 | import { | |
| 21 | commitToBranch, | |
| 22 | createRepo, | |
| 23 | updateRepoSettings, | |
| 24 | } from "../src/actions/repos.ts"; | |
| 25 | import { signUp } from "../src/actions/users.ts"; | |
| 26 | import { createApp, type App as Forge } from "../src/app.ts"; | |
| 27 | import { listComments } from "../src/core/issues.ts"; | |
| 28 | import { getPull } from "../src/core/pulls.ts"; | |
| 29 | import type { Repo } from "../src/core/repos.ts"; | |
| 30 | import { | |
| 31 | createRun, | |
| 32 | RUNNER_SILENT_SUMMARY, | |
| 33 | RUNNER_WAIT_MAX_MS, | |
| 34 | silenceUnstartedChecks, | |
| 35 | } from "../src/core/runs.ts"; | |
| 36 | import type { User } from "../src/core/users.ts"; | |
| 37 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 38 | import type { App } from "../src/tui/app/app.ts"; | |
| 39 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 40 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; | |
| 41 | import { quietLogs } from "./helpers/globals.ts"; | |
| 42 | import { settleApp } from "./helpers/tui.ts"; | |
| 43 | ||
| 44 | quietLogs(); | |
| 45 | ||
| 46 | const PASSWORD = "a-good-passphrase"; | |
| 47 | let dataDir: string; | |
| 48 | let forge: Forge; | |
| 49 | let servers: Servers; | |
| 50 | let alice: User; // owns the org: admin | |
| 51 | let bob: User; // writes through a team: not admin | |
| 52 | let repo: Repo; | |
| 53 | let n = 0; | |
| 54 | ||
| 55 | /** A pull whose only check sat queued until the runner was called silent. */ | |
| 56 | async function silentPull(): Promise<{ number: number; id: string }> { | |
| 57 | const branch = `fix-${++n}`; | |
| 58 | const made = await commitToBranch(forge, alice, repo, { | |
| 59 | branch, | |
| 60 | message: branch, | |
| 61 | files: [{ path: `${branch}.txt`, content: "x\n" }], | |
| 62 | }); | |
| 63 | if (!made.ok) throw new Error(JSON.stringify(made.error)); | |
| 64 | const opened = await openPull(forge, alice, repo, { | |
| 65 | title: `Pull ${branch}`, | |
| 66 | baseBranch: "main", | |
| 67 | headBranch: branch, | |
| 68 | }); | |
| 69 | if (!opened.ok) throw new Error(JSON.stringify(opened.error)); | |
| 70 | createRun(forge.db, { | |
| 71 | repoId: repo.id, | |
| 72 | kind: "check", | |
| 73 | env: "pull", | |
| 74 | commitOid: made.value.commitOid, | |
| 75 | reason: "push", | |
| 76 | issueId: opened.value.id, | |
| 77 | }); | |
| 78 | const settled = silenceUnstartedChecks( | |
| 79 | forge.db, | |
| 80 | Date.now() + RUNNER_WAIT_MAX_MS + 1000, | |
| 81 | ); | |
| 82 | expect(settled.length).toBeGreaterThan(0); | |
| 83 | return { number: opened.value.number, id: opened.value.id }; | |
| 84 | } | |
| 85 | ||
| 86 | const merged = (number: number) => | |
| 87 | getPull(forge.db, repo.id, number)?.mergedAt != null; | |
| 88 | ||
| 89 | const signIn = (username: string): Promise<string> => | |
| 90 | signInCookie(servers.url, username, PASSWORD); | |
| 91 | ||
| 92 | const mint = async (username: string): Promise<string> => | |
| 93 | createToken(forge.db, (username === "alice" ? alice : bob).id, "t", "rw").token; | |
| 94 | ||
| 95 | const pagePath = (number: number) => `/acme/lighthouse/pulls/${number}`; | |
| 96 | ||
| 97 | beforeAll(async () => { | |
| 98 | dataDir = await mkdtemp(join(tmpdir(), "forge-doors-")); | |
| 99 | forge = createApp({ dataDir, port: 0 }); | |
| 100 | servers = await serve(forge); | |
| 101 | const one = await seedAdmin(forge, { username: "alice", email: "[email protected]", password: PASSWORD }); | |
| 102 | const two = await signUp(forge, { | |
| 103 | username: "bob", | |
| 104 | email: "[email protected]", | |
| 105 | password: PASSWORD, | |
| 106 | }, { slot: fixtureSlot(forge) }); | |
| 107 | if (!one.ok || !two.ok) throw new Error("signup failed"); | |
| 108 | alice = one.value; | |
| 109 | bob = two.value; | |
| 110 | proveAll(forge); | |
| 111 | const org = createOrg(forge.db, "acme", alice.id); | |
| 112 | if (!org.ok) throw new Error("org failed"); | |
| 113 | const team = createTeam(forge.db, org.value.id, "writers", "write"); | |
| 114 | if (!team.ok) throw new Error("team failed"); | |
| 115 | addTeamMember(forge.db, team.value, bob.id); | |
| 116 | const made = await createRepo(forge, alice, { | |
| 117 | owner: "acme", | |
| 118 | name: "lighthouse", | |
| 119 | visibility: "public", | |
| 120 | }); | |
| 121 | if (!made.ok) throw new Error(`repo failed: ${JSON.stringify(made.error)}`); | |
| 122 | repo = made.value; | |
| 123 | await commitToBranch(forge, alice, repo, { | |
| 124 | message: "seed", | |
| 125 | files: [{ path: "README.md", content: "hi\n" }], | |
| 126 | }); | |
| 127 | await updateRepoSettings(forge, alice, repo, { requireChecks: true }); | |
| 128 | repo = { ...repo, requireChecks: true }; | |
| 129 | }, 60_000); | |
| 130 | ||
| 131 | afterAll(async () => { | |
| 132 | servers?.stop(); | |
| 133 | forge.close(); | |
| 134 | await rm(dataDir, { recursive: true, force: true }); | |
| 135 | }); | |
| 136 | ||
| 137 | test("the page offers the one land-past form to an admin only, and lands the pull on POST", async () => { | |
| 138 | const { number, id } = await silentPull(); | |
| 139 | const aliceCookie = await signIn("alice"); | |
| 140 | const bobCookie = await signIn("bob"); | |
| 141 | ||
| 142 | const adminPage = await ( | |
| 143 | await fetch(servers.url + pagePath(number) + "/files", { | |
| 144 | headers: { cookie: aliceCookie }, | |
| 145 | }) | |
| 146 | ).text(); | |
| 147 | expect(adminPage).toContain(`${pagePath(number)}/land-past`); | |
| 148 | expect(adminPage).toContain("The runner never answered this head"); | |
| 149 | expect(adminPage).not.toContain('name="waive"'); | |
| 150 | expect(adminPage.split("/land-past").length).toBe(2); | |
| 151 | ||
| 152 | const writerPage = await ( | |
| 153 | await fetch(servers.url + pagePath(number) + "/files", { | |
| 154 | headers: { cookie: bobCookie }, | |
| 155 | }) | |
| 156 | ).text(); | |
| 157 | expect(writerPage).not.toContain("/land-past"); | |
| 158 | ||
| 159 | // The change page says the runner is silent, not that the check was cancelled. | |
| 160 | const change = await ( | |
| 161 | await fetch(servers.url + pagePath(number), { | |
| 162 | headers: { cookie: aliceCookie }, | |
| 163 | }) | |
| 164 | ).text(); | |
| 165 | expect(change).toContain("the runner is not answering"); | |
| 166 | expect(change).not.toContain("the check was cancelled"); | |
| 167 | ||
| 168 | // A writer who is not an admin posts the form by hand: refused. | |
| 169 | const post = (cookie: string, fields: Record<string, string>) => | |
| 170 | fetch(servers.url + `${pagePath(number)}/land-past`, { | |
| 171 | method: "POST", | |
| 172 | headers: { cookie }, | |
| 173 | body: new URLSearchParams(fields), | |
| 174 | redirect: "manual", | |
| 175 | }); | |
| 176 | await post(bobCookie, { reason: "let me in, please" }); | |
| 177 | expect(merged(number)).toBe(false); | |
| 178 | ||
| 179 | // An admin without a reason: refused. | |
| 180 | await post(aliceCookie, { reason: " " }); | |
| 181 | expect(merged(number)).toBe(false); | |
| 182 | ||
| 183 | const landed = await post(aliceCookie, { reason: "runner is down" }); | |
| 184 | expect(landed.status).toBe(303); | |
| 185 | expect(merged(number)).toBe(true); | |
| 186 | const said = listComments(forge.db, id).map((c) => c.body).join("\n"); | |
| 187 | expect(said).toContain("runner is down"); | |
| 188 | expect(said).toContain(RUNNER_SILENT_SUMMARY); | |
| 189 | }); | |
| 190 | ||
| 191 | test("the API refuses checksUnavailable from a writer who is not an admin, and takes it from an admin", async () => { | |
| 192 | const { number } = await silentPull(); | |
| 193 | const bobToken = await mint("bob"); | |
| 194 | const aliceToken = await mint("alice"); | |
| 195 | const url = `${servers.url}/api/v1/repos/acme/lighthouse/pulls/${number}/merge`; | |
| 196 | const call = (token: string, body: unknown) => | |
| 197 | fetch(url, { | |
| 198 | method: "POST", | |
| 199 | headers: { | |
| 200 | authorization: `Bearer ${token}`, | |
| 201 | "content-type": "application/json", | |
| 202 | }, | |
| 203 | body: JSON.stringify(body), | |
| 204 | }); | |
| 205 | ||
| 206 | const refused = await call(bobToken, { checksUnavailable: "please" }); | |
| 207 | expect(refused.ok).toBe(false); | |
| 208 | expect(await refused.text()).toContain("forbidden"); | |
| 209 | expect(merged(number)).toBe(false); | |
| 210 | ||
| 211 | const bare = await call(aliceToken, { checksUnavailable: " " }); | |
| 212 | expect(bare.ok).toBe(false); | |
| 213 | expect(await bare.text()).toContain("waiver_needs_reason"); | |
| 214 | expect(merged(number)).toBe(false); | |
| 215 | ||
| 216 | const landed = await call(aliceToken, { checksUnavailable: "runner down" }); | |
| 217 | expect(landed.status).toBe(200); | |
| 218 | expect(merged(number)).toBe(true); | |
| 219 | }); | |
| 220 | ||
| 221 | function boot(user: User): { app: App; stop(): void } { | |
| 222 | const terminal = headlessTerminal(140, 44); | |
| 223 | const { app } = createForgeApp( | |
| 224 | forge, | |
| 225 | { | |
| 226 | sshUsername: user.username, | |
| 227 | remoteAddress: "127.0.0.1", | |
| 228 | fingerprint: `SHA256:${user.username}`, | |
| 229 | user, | |
| 230 | }, | |
| 231 | { terminal, exitHooks: false }, | |
| 232 | ); | |
| 233 | app.start(); | |
| 234 | return { app, stop: () => app.stop() }; | |
| 235 | } | |
| 236 | ||
| 237 | async function until(app: App, what: string): Promise<void> { | |
| 238 | await pollUntil(async () => { | |
| 239 | await settleApp(app); | |
| 240 | return app.screen.toText().includes(what); | |
| 241 | }, `${what}:\n${app.screen.toText()}`); | |
| 242 | } | |
| 243 | ||
| 244 | async function press(app: App, ...keys: string[]): Promise<void> { | |
| 245 | for (const key of keys) { | |
| 246 | app.dispatch({ type: "key", key, ctrl: false, alt: false, shift: false }); | |
| 247 | await settleApp(app); | |
| 248 | } | |
| 249 | } | |
| 250 | ||
| 251 | async function openPullScreen(app: App, title: string): Promise<void> { | |
| 252 | await until(app, "acme/lighthouse"); | |
| 253 | await press(app, "enter"); | |
| 254 | await until(app, "README"); | |
| 255 | await press(app, "p"); | |
| 256 | await until(app, title); | |
| 257 | await press(app, "enter"); | |
| 258 | await until(app, "#"); | |
| 259 | } | |
| 260 | ||
| 261 | test("in the terminal, L on a runner-silent check asks an admin for a reason and lands it; a non-admin writer is not offered it", async () => { | |
| 262 | const { number, id } = await silentPull(); | |
| 263 | const title = `Pull fix-${n}`; | |
| 264 | ||
| 265 | const writer = boot(bob); | |
| 266 | try { | |
| 267 | await openPullScreen(writer.app, title); | |
| 268 | await press(writer.app, "m"); | |
| 269 | expect(writer.app.screen.toText()).toContain("the runner is not answering"); | |
| 270 | await press(writer.app, "L"); | |
| 271 | expect(writer.app.screen.toText()).not.toContain("past the gate"); | |
| 272 | expect(merged(number)).toBe(false); | |
| 273 | } finally { | |
| 274 | writer.stop(); | |
| 275 | } | |
| 276 | ||
| 277 | const admin = boot(alice); | |
| 278 | try { | |
| 279 | await openPullScreen(admin.app, title); | |
| 280 | await press(admin.app, "L"); | |
| 281 | await until(admin.app, `Land #${number} past the gate`); | |
| 282 | expect(admin.app.screen.toText()).toContain("never answered"); | |
| 283 | // A reason too short is refused where it is typed, as the page refuses it. | |
| 284 | for (const ch of "down") await press(admin.app, ch); | |
| 285 | await press(admin.app, "enter"); | |
| 286 | expect(admin.app.screen.toText()).toContain("8 to 500"); | |
| 287 | expect(merged(number)).toBe(false); | |
| 288 | for (const ch of " runner down") await press(admin.app, ch); | |
| 289 | await press(admin.app, "enter"); | |
| 290 | await until(admin.app, "Reason: down runner down"); | |
| 291 | await press(admin.app, "right", "enter"); | |
| 292 | await pollUntil(async () => merged(number), "landed"); | |
| 293 | const said = listComments(forge.db, id).map((c) => c.body).join("\n"); | |
| 294 | expect(said).toContain("runner down"); | |
| 295 | } finally { | |
| 296 | admin.stop(); | |
| 297 | } | |
| 298 | }, 90_000); |
test/runner-silent.test.ts added +246
| @@ -0,0 +1,246 @@ | ||
| 1 | /** | |
| 2 | * Losing the runner: a check that never starts says "the runner is not | |
| 3 | * answering" — never red — vitals names it, and a person with admin may land | |
| 4 | * past it with a reason on the pull. A red check is still refused. | |
| 5 | */ | |
| 6 | ||
| 7 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 8 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 9 | import { tmpdir } from "node:os"; | |
| 10 | import { join } from "node:path"; | |
| 11 | import { createApp, type App } from "../src/app.ts"; | |
| 12 | import { mergePull, openPull } from "../src/actions/pulls.ts"; | |
| 13 | import { | |
| 14 | commitToBranch, | |
| 15 | createRepo, | |
| 16 | updateRepoSettings, | |
| 17 | } from "../src/actions/repos.ts"; | |
| 18 | import { getPull } from "../src/core/pulls.ts"; | |
| 19 | import { listComments } from "../src/core/issues.ts"; | |
| 20 | import type { Repo } from "../src/core/repos.ts"; | |
| 21 | import { | |
| 22 | claimRun, | |
| 23 | createRun, | |
| 24 | finishRun, | |
| 25 | getRun, | |
| 26 | RUNNER_SILENT_SUMMARY, | |
| 27 | RUNNER_WAIT_MAX_MS, | |
| 28 | runnerSilent, | |
| 29 | silenceUnstartedChecks, | |
| 30 | } from "../src/core/runs.ts"; | |
| 31 | import { createUser, type User } from "../src/core/users.ts"; | |
| 32 | import { vitals } from "../src/kernel/vitals.ts"; | |
| 33 | import { startChecks } from "../src/checks/service.ts"; | |
| 34 | import { readRunLog } from "../src/runs/log.ts"; | |
| 35 | import { pollUntil } from "./helpers/poll.ts"; | |
| 36 | ||
| 37 | const roomy = () => ({ freeBytes: 95, totalBytes: 100 }); | |
| 38 | /** The number of checks vitals says could not start; 0 when it says nothing. */ | |
| 39 | const silentSaid = (db: App["db"], dir: string, now?: number): number => { | |
| 40 | const read = vitals({ db, signals: app.signals, dataDir: dir, disk: roomy, ...(now === undefined ? {} : { now }) }); | |
| 41 | const m = /(\d+) checks? could not start/.exec(read.needs.join(" ")); | |
| 42 | return m === null ? 0 : Number(m[1]); | |
| 43 | }; | |
| 44 | ||
| 45 | let dataDir: string; | |
| 46 | let app: App; | |
| 47 | let alice: User; | |
| 48 | let repo: Repo; | |
| 49 | ||
| 50 | async function pullAt(branch: string) { | |
| 51 | const made = await commitToBranch(app, alice, repo, { | |
| 52 | branch, | |
| 53 | message: branch, | |
| 54 | files: [{ path: `${branch}.txt`, content: "x\n" }], | |
| 55 | }); | |
| 56 | if (!made.ok) throw new Error(JSON.stringify(made.error)); | |
| 57 | const opened = await openPull(app, alice, repo, { | |
| 58 | title: branch, | |
| 59 | baseBranch: "main", | |
| 60 | headBranch: branch, | |
| 61 | }); | |
| 62 | if (!opened.ok) throw new Error(JSON.stringify(opened.error)); | |
| 63 | return { pull: opened.value, head: made.value.commitOid }; | |
| 64 | } | |
| 65 | ||
| 66 | const queue = (pullId: string, head: string) => | |
| 67 | createRun(app.db, { | |
| 68 | repoId: repo.id, | |
| 69 | kind: "check", | |
| 70 | env: "pull", | |
| 71 | commitOid: head, | |
| 72 | reason: "push", | |
| 73 | issueId: pullId, | |
| 74 | }); | |
| 75 | ||
| 76 | beforeAll(async () => { | |
| 77 | dataDir = await mkdtemp(join(tmpdir(), "forge-runner-")); | |
| 78 | app = createApp({ dataDir, port: 0 }); | |
| 79 | const a = await createUser(app.db, { | |
| 80 | origin: "seed", | |
| 81 | trusted: true, | |
| 82 | username: "alice", | |
| 83 | email: "[email protected]", | |
| 84 | password: "a-good-passphrase", | |
| 85 | adminIfFirst: true, | |
| 86 | }); | |
| 87 | if (!a.ok) throw new Error(a.error); | |
| 88 | alice = a.value; | |
| 89 | const made = await createRepo(app, alice, { name: "lib", visibility: "public" }); | |
| 90 | if (!made.ok) throw new Error(String(made.error)); | |
| 91 | repo = made.value; | |
| 92 | const seeded = await commitToBranch(app, alice, repo, { | |
| 93 | message: "seed", | |
| 94 | files: [{ path: "README.md", content: "hi\n" }], | |
| 95 | }); | |
| 96 | if (!seeded.ok) throw new Error(JSON.stringify(seeded.error)); | |
| 97 | await updateRepoSettings(app, alice, repo, { requireChecks: true }); | |
| 98 | repo = { ...repo, requireChecks: true }; | |
| 99 | }); | |
| 100 | ||
| 101 | afterAll(async () => { | |
| 102 | app.close(); | |
| 103 | await rm(dataDir, { recursive: true, force: true }); | |
| 104 | }); | |
| 105 | ||
| 106 | test("with no runner, an old queued check is unavailable, never red; vitals names it; an admin lands it with a reason; red is still refused", async () => { | |
| 107 | const { pull, head } = await pullAt("fix"); | |
| 108 | const run = queue(pull.id, head); | |
| 109 | ||
| 110 | // Not yet past the bound: still waiting, nothing said. | |
| 111 | const now = Date.now(); | |
| 112 | expect(silenceUnstartedChecks(app.db, now)).toHaveLength(0); | |
| 113 | expect(silentSaid(app.db, dataDir, now)).toBe(0); | |
| 114 | ||
| 115 | // Past it, with nothing starting it: unavailable. | |
| 116 | const later = now + RUNNER_WAIT_MAX_MS + 1000; | |
| 117 | expect(silenceUnstartedChecks(app.db, later)).toHaveLength(1); | |
| 118 | const silent = getRun(app.db, run.id)!; | |
| 119 | expect(silent.state).toBe("cancelled"); | |
| 120 | expect(silent.state).not.toBe("failed"); | |
| 121 | expect(silent.summary).toBe(RUNNER_SILENT_SUMMARY); | |
| 122 | expect(runnerSilent(silent)).toBe(true); | |
| 123 | ||
| 124 | const v = vitals({ db: app.db, signals: app.signals, dataDir, disk: roomy, now: later }); | |
| 125 | // A todo, not a break: the forge serves, and the check is not red. | |
| 126 | expect(v.ok).toBe(true); | |
| 127 | expect(v.todo.join(" ")).toContain("could not start"); | |
| 128 | expect(silentSaid(app.db, dataDir, later)).toBe(1); | |
| 129 | expect(v.needs.join(" ")).toContain("The runner is not answering"); | |
| 130 | ||
| 131 | // Without a waiver the gate still holds; a waiver needs a reason. | |
| 132 | const plain = await mergePull(app, alice, repo, pull, "merge"); | |
| 133 | expect(plain).toEqual({ ok: false, error: "checks_required" }); | |
| 134 | const bare = await mergePull(app, alice, repo, pull, "merge", undefined, { waiver: " " }); | |
| 135 | expect(bare).toEqual({ ok: false, error: "waiver_needs_reason" }); | |
| 136 | expect(getPull(app.db, repo.id, pull.number)?.mergedAt).toBeNull(); | |
| 137 | ||
| 138 | const landed = await mergePull(app, alice, repo, pull, "merge", undefined, { waiver: "runner down, fix is trivial" }); | |
| 139 | expect(landed.ok).toBe(true); | |
| 140 | expect(getPull(app.db, repo.id, pull.number)?.mergedAt).not.toBeNull(); | |
| 141 | const said = listComments(app.db, pull.id).map((c) => c.body).join("\n"); | |
| 142 | expect(said).toContain("runner down, fix is trivial"); | |
| 143 | expect(said).toContain(RUNNER_SILENT_SUMMARY); | |
| 144 | ||
| 145 | // A red check is refused whatever the reason. | |
| 146 | const red = await pullAt("broken"); | |
| 147 | const failing = queue(red.pull.id, red.head); | |
| 148 | claimRun(app.db, failing.id); | |
| 149 | finishRun(app.db, failing.id, { state: "failed", summary: "check failed: 1 of 3 tests" }); | |
| 150 | const refused = await mergePull(app, alice, repo, red.pull, "merge", undefined, { waiver: "just land it" }); | |
| 151 | expect(refused).toEqual({ ok: false, error: "checks_required" }); | |
| 152 | expect(getPull(app.db, repo.id, red.pull.number)?.mergedAt).toBeNull(); | |
| 153 | }); | |
| 154 | ||
| 155 | test("a runner that is busy is not silent: a running or just-finished check keeps the queue waiting", async () => { | |
| 156 | // The first test's settled run is still inside the hour; only new ones count. | |
| 157 | const before = silentSaid(app.db, dataDir); | |
| 158 | const a = await pullAt("busy-a"); | |
| 159 | const b = await pullAt("busy-b"); | |
| 160 | const working = queue(a.pull.id, a.head); | |
| 161 | const waiting = queue(b.pull.id, b.head); | |
| 162 | claimRun(app.db, working.id); | |
| 163 | const later = Date.now() + RUNNER_WAIT_MAX_MS + 1000; | |
| 164 | ||
| 165 | // Running now: the old queued check is only waiting its turn, and vitals | |
| 166 | // does not call the runner down while it works. | |
| 167 | expect(silentSaid(app.db, dataDir, later)).toBe(before); | |
| 168 | expect(silenceUnstartedChecks(app.db, later)).toHaveLength(0); | |
| 169 | // The forge is starting one in memory: same. | |
| 170 | expect(silenceUnstartedChecks(app.db, later, new Set([working.id]))).toHaveLength(0); | |
| 171 | expect(getRun(app.db, waiting.id)!.state).toBe("queued"); | |
| 172 | ||
| 173 | // Just finished (inside the window): still progress. | |
| 174 | finishRun(app.db, working.id, { state: "ok", summary: "passed" }); | |
| 175 | expect(silenceUnstartedChecks(app.db, Date.now() + 60_000)).toHaveLength(0); | |
| 176 | expect(getRun(app.db, waiting.id)!.state).toBe("queued"); | |
| 177 | ||
| 178 | // Nothing started or finished for the whole window: now it is silent. | |
| 179 | expect(silenceUnstartedChecks(app.db, Date.now() + 2 * RUNNER_WAIT_MAX_MS)).toHaveLength(1); | |
| 180 | expect(runnerSilent(getRun(app.db, waiting.id)!)).toBe(true); | |
| 181 | }); | |
| 182 | ||
| 183 | test("a check the lane waits on for a reason of its own is never called silent; only an unexplained wait is", async () => { | |
| 184 | const a = await pullAt("held-a"); | |
| 185 | const b = await pullAt("held-b"); | |
| 186 | const later = Date.now() + 3 * RUNNER_WAIT_MAX_MS; | |
| 187 | const inAnHour = new Date(Date.now() + 3_600_000).toISOString(); | |
| 188 | const queuedLater = (pullId: string, head: string) => | |
| 189 | createRun(app.db, { repoId: repo.id, kind: "check", env: "pull", commitOid: head, reason: "push", issueId: pullId, notBefore: inAnHour }); | |
| 190 | const delayed = queuedLater(a.pull.id, a.head); | |
| 191 | const plain = queue(b.pull.id, b.head); | |
| 192 | claimRun(app.db, plain.id); | |
| 193 | finishRun(app.db, plain.id, { state: "ok", summary: "passed" }); | |
| 194 | const unexplained = queue(b.pull.id, b.head); | |
| 195 | ||
| 196 | // A held check is skipped by the sweep; the unexplained one is settled. | |
| 197 | const swept = silenceUnstartedChecks(app.db, later, new Set(), (run) => run.id === delayed.id); | |
| 198 | expect(swept.map((r) => r.id)).toEqual([unexplained.id]); | |
| 199 | expect(getRun(app.db, delayed.id)!.state).toBe("queued"); | |
| 200 | ||
| 201 | // A deploy running keeps the lane busy: nothing is called silent. | |
| 202 | const c = await pullAt("held-c"); | |
| 203 | const waiting = queue(c.pull.id, c.head); | |
| 204 | const deploy = createRun(app.db, { repoId: repo.id, kind: "deploy", env: "pull", commitOid: c.head, reason: "push" }); | |
| 205 | claimRun(app.db, deploy.id); | |
| 206 | expect(silenceUnstartedChecks(app.db, later + 3 * RUNNER_WAIT_MAX_MS)).toHaveLength(0); | |
| 207 | expect(getRun(app.db, waiting.id)!.state).toBe("queued"); | |
| 208 | finishRun(app.db, deploy.id, { state: "ok", summary: "deployed" }); | |
| 209 | }); | |
| 210 | ||
| 211 | test("the lane's own tick runs the sweep: take the runner away and a delayed check settles, written in its log; a held one does not", async () => { | |
| 212 | const a = await pullAt("tick-a"); | |
| 213 | const inAnHour = new Date(Date.now() + 3_600_000).toISOString(); | |
| 214 | const delayed = createRun(app.db, { repoId: repo.id, kind: "check", env: "pull", commitOid: a.head, reason: "push", issueId: a.pull.id, notBefore: inAnHour }); | |
| 215 | const far = () => Date.now() + 3 * RUNNER_WAIT_MAX_MS; | |
| 216 | const seen: ReadonlySet<string>[] = []; | |
| 217 | ||
| 218 | // The lane's own judgement: a check that is not to start for an hour is held, so it stays queued. | |
| 219 | let lane = startChecks(app, { | |
| 220 | forgeUrl: "http://127.0.0.1:9", | |
| 221 | tickMs: 20, | |
| 222 | silence: (db, _now, inFlight, held) => { | |
| 223 | seen.push(inFlight ?? new Set()); | |
| 224 | return silenceUnstartedChecks(db, far(), inFlight ?? new Set(), held ?? (() => false)); | |
| 225 | }, | |
| 226 | }); | |
| 227 | try { | |
| 228 | await pollUntil(() => seen.length >= 3, "the tick calls the sweep"); | |
| 229 | expect(getRun(app.db, delayed.id)!.state).toBe("queued"); | |
| 230 | } finally { | |
| 231 | await lane.stop(); | |
| 232 | } | |
| 233 | ||
| 234 | // Past that judgement (a stand-in that holds nothing): the tick settles it and logs why. | |
| 235 | lane = startChecks(app, { | |
| 236 | forgeUrl: "http://127.0.0.1:9", | |
| 237 | tickMs: 20, | |
| 238 | silence: (db, _now, inFlight) => silenceUnstartedChecks(db, far(), inFlight ?? new Set(), () => false), | |
| 239 | }); | |
| 240 | try { | |
| 241 | await pollUntil(() => runnerSilent(getRun(app.db, delayed.id)!), "the tick settles the check as silent"); | |
| 242 | expect(readRunLog(dataDir, delayed.id).lines.join("\n") ).toContain(RUNNER_SILENT_SUMMARY); | |
| 243 | } finally { | |
| 244 | await lane.stop(); | |
| 245 | } | |
| 246 | }); |
test/vitals.test.ts +2 −1
| @@ -187,7 +187,8 @@ test("the number of queries does not grow with runs", () => { | ||
| 187 | 187 | // hourly cloud watch's readings, one row an account (#16329). And, once per distinct owner of a |
| 188 | 188 | // queued check, the concurrent-checks limit the scheduler asks (#5130): its stored value, then |
| 189 | 189 | // whether the owner is a newcomer; two for this fixture's one owner, however many checks. |
| 190 | expect(before).toBe(15); | |
| 190 | // And the one read that names a runner that stopped answering. | |
| 191 | expect(before).toBe(16); | |
| 191 | 192 | }); |
| 192 | 193 | |
| 193 | 194 | test("errors are counted, bounded, redacted, and a burst is said", async () => { |
new above
offline
This tick is the only thing that makes the feature happen in production, and no test covers it. The tests call
silenceUnstartedChecksdirectly with a shifted clock. Add a test that runs the lane with no runner and sees the queued check settle.