Public: anyone can read this; the crew can change it.
Sentinel: The lane has stopped: nothing has merged and nothing said so #16648
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/16637-sentinel-the-lane-has-stopped-nothing-ha → main 0 commits fork
7 files
changed +91
−8
docs/OPERATING.md +1 −1
Diff not shown — a line 2,622 characters wide (limit 2,000). +1 −1
View filesrc/checks/culprit.ts +12 −1
| @@ -5,7 +5,8 @@ | ||
| 5 | 5 | * at a time — each step a run of only those files, in the verification |
| 6 | 6 | * lane — until one commit is left. That commit is the culprit: the landed |
| 7 | 7 | * pull it is gets its revert proposed (a person lands it, as every revert), |
| 8 | * a push no pull carried gets one issue. A red whose files were already red | |
| 8 | * a push no pull carried — or a pull that added a migration, whose revert | |
| 9 | * the gate refuses (`pinned_landing.ts`) — gets one issue. A red whose files were already red | |
| 9 | 10 | * at the verification before it was named there and starts nothing. |
| 10 | 11 | * |
| 11 | 12 | * A later green verification that ran every file such an issue names |
| @@ -25,6 +26,7 @@ import { getUserById } from "../core/users.ts"; | ||
| 25 | 26 | import { runGit } from "../git/env.ts"; |
| 26 | 27 | import { isSafeOid } from "../git/guard.ts"; |
| 27 | 28 | import { repoDir } from "../git/repos.ts"; |
| 29 | import { noRevertWhy, pinsLandedBy } from "./pinned_landing.ts"; | |
| 28 | 30 | import { everReverted } from "./revert_red.ts"; |
| 29 | 31 | import { |
| 30 | 32 | BISECT_ENV, |
| @@ -149,6 +151,15 @@ async function name(app: App, repo: Repo, red: Run, culprit: string, green: stri | ||
| 149 | 151 | const pull = landingOf(app, repo, culprit); |
| 150 | 152 | if (pull !== undefined) { |
| 151 | 153 | if (everReverted(app, pull.id)) return `culprit #${pull.number} (${short(culprit)}): its revert was already proposed`; |
| 154 | const pins = await pinsLandedBy(app, repo, culprit); | |
| 155 | if (pins.length > 0) | |
| 156 | return `culprit #${pull.number} (${short(culprit)}), no revert: ${fileOnce( | |
| 157 | app, | |
| 158 | repo, | |
| 159 | `${TITLE_PREFIX}#${pull.number} broke ${files[0] ?? "main"}`, | |
| 160 | `${FILED_BY}\n\n#${pull.number} (${short(culprit)}) broke ${redSays(red)} — ${how}. ` + | |
| 161 | `${noRevertWhy(pins)}.\n\nFiles: ${files.join(", ")}`, | |
| 162 | )}`; | |
| 152 | 163 | const owner = getUserById(app.db, repo.ownerId); |
| 153 | 164 | const body = |
| 154 | 165 | `Reverts #${pull.number}: verifying main after landing found it broke ${redSays(red)} — ${how}.\n\n` + |
src/checks/pinned_landing.ts added +30
| @@ -0,0 +1,30 @@ | ||
| 1 | /** | |
| 2 | * A landing whose revert cannot land (#16637). A pull that added a | |
| 3 | * migration added its pin, and a migration on main is history: the gate | |
| 4 | * refuses any pull that deletes a pin. So the forge never proposes the | |
| 5 | * revert of such a pull on its own (`culprit.ts`, `revert_red.ts`) — it | |
| 6 | * would open a pull that is red before it runs, and every open pull's | |
| 7 | * lane would carry it. The break is fixed forward instead. | |
| 8 | */ | |
| 9 | ||
| 10 | import type { App } from "../app.ts"; | |
| 11 | import type { Repo } from "../core/repos.ts"; | |
| 12 | import { runGit } from "../git/env.ts"; | |
| 13 | import { isSafeOid } from "../git/guard.ts"; | |
| 14 | import { repoDir } from "../git/repos.ts"; | |
| 15 | import { addedPins, parseNameStatus } from "../kernel/pin_edits.ts"; | |
| 16 | ||
| 17 | /** The pins landing `oid` added against its first parent; empty when none or git cannot say. */ | |
| 18 | export async function pinsLandedBy(app: App, repo: Repo, oid: string): Promise<string[]> { | |
| 19 | if (!isSafeOid(oid)) return []; | |
| 20 | const diff = await runGit( | |
| 21 | ["diff", "--name-status", "--no-renames", `${oid}^1`, oid, "--", "src/core/migration-pins/"], | |
| 22 | { cwd: repoDir(app.reposRoot, repo.ownerName, repo.name) }, | |
| 23 | ); | |
| 24 | return diff.ok ? addedPins(parseNameStatus(diff.value)) : []; | |
| 25 | } | |
| 26 | ||
| 27 | /** Why the forge proposes no revert of a landing that added `pins`, in a sentence. */ | |
| 28 | export const noRevertWhy = (pins: readonly string[]): string => | |
| 29 | `it added ${pins.map((p) => `\`${p}\``).join(", ")}, and a migration on main is history: ` + | |
| 30 | "its revert would delete the pin, which the gate refuses, so the forge proposes no revert. Fix it forward"; |
src/checks/revert_red.ts +6 −2
| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | * proposes the revert of that pull: one pull, `revertsPullId` set, titled |
| 5 | 5 | * for the pull it takes back and naming the failing test. It is only ever |
| 6 | 6 | * proposed — a person lands it. A red that spans more than one landing (or a |
| 7 | * push no pull carried) is the alarm's, not this module's, and a landing | |
| 8 | * already reverted, open or shipped or closed, is never proposed twice. | |
| 7 | * push no pull carried, or a pull that added a migration: `pinned_landing.ts`) | |
| 8 | * is the alarm's, not this module's, and a landing already reverted, open or | |
| 9 | * shipped or closed, is never proposed twice. | |
| 9 | 10 | */ |
| 10 | 11 | |
| 11 | 12 | import type { App } from "../app.ts"; |
| @@ -17,6 +18,7 @@ import { getUserById } from "../core/users.ts"; | ||
| 17 | 18 | import { runGit } from "../git/env.ts"; |
| 18 | 19 | import { repoDir } from "../git/repos.ts"; |
| 19 | 20 | import { isSafeOid } from "../git/guard.ts"; |
| 21 | import { pinsLandedBy } from "./pinned_landing.ts"; | |
| 20 | 22 | import { manifestError, redMain, type RedMain } from "./red_main.ts"; |
| 21 | 23 | |
| 22 | 24 | /** The reds being answered now: a check finishing twice at once proposes once. */ |
| @@ -94,6 +96,8 @@ export async function proposeRevert(app: App, repoId: string): Promise<Pull | un | ||
| 94 | 96 | const landed = await soleLanding(app, red, green); |
| 95 | 97 | if (landed === undefined || everReverted(app, landed.id)) return undefined; |
| 96 | 98 | const repo = getRepoById(app.db, repoId); |
| 99 | // A revert that deletes a migration pin is red before it runs: the alarm's, not a pull's. | |
| 100 | if (repo !== undefined && (await pinsLandedBy(app, repo, landed.mergedOid ?? "")).length > 0) return undefined; | |
| 97 | 101 | const owner = repo === undefined ? undefined : getUserById(app.db, repo.ownerId); |
| 98 | 102 | if (repo === undefined || owner === undefined || getIssueById(app.db, landed.id) === undefined) |
| 99 | 103 | return undefined; |
src/kernel/pin_edits.ts +10
| @@ -79,3 +79,13 @@ export function tipEdits( | ||
| 79 | 79 | touched(path), |
| 80 | 80 | ); |
| 81 | 81 | } |
| 82 | ||
| 83 | /** | |
| 84 | * The migration pins `changes` adds (#16637): what a revert of that change | |
| 85 | * would delete, and the gate refuses a pull that deletes a pin on main. | |
| 86 | */ | |
| 87 | export function addedPins(changes: readonly Change[]): string[] { | |
| 88 | return changes | |
| 89 | .filter(({ status, path }) => path.startsWith(PINS) && path.endsWith(".pin") && (status.startsWith("A") || status.startsWith("C"))) | |
| 90 | .map(({ path }) => path); | |
| 91 | } |
test/revert-red.test.ts +10 −2
| @@ -24,12 +24,12 @@ describe("a red main after one landing proposes its revert", () => { | ||
| 24 | 24 | let alice: User; |
| 25 | 25 | let repo: Repo; |
| 26 | 26 | |
| 27 | const land = async (branch: string, content: string): Promise<Pull> => { | |
| 27 | const land = async (branch: string, content: string, more: { path: string; content: string }[] = []): Promise<Pull> => { | |
| 28 | 28 | await commitToBranch(app, alice, repo, { |
| 29 | 29 | branch, |
| 30 | 30 | base: "main", |
| 31 | 31 | message: branch, |
| 32 | files: [{ path: "code.txt", content }], | |
| 32 | files: [{ path: "code.txt", content }, ...more], | |
| 33 | 33 | }); |
| 34 | 34 | const opened = await openPull(app, alice, repo, { |
| 35 | 35 | title: `Change ${branch}`, |
| @@ -128,6 +128,14 @@ describe("a red main after one landing proposes its revert", () => { | ||
| 128 | 128 | expect(reverts()).toHaveLength(0); |
| 129 | 129 | }); |
| 130 | 130 | |
| 131 | test("a landing that added a migration pin opens none: its revert would delete the pin (#16637)", async () => { | |
| 132 | await mainCheck("ok"); | |
| 133 | await land("one", "beta\n", [{ path: "src/core/migration-pins/20261128100000-walks.pin", content: "abc\n" }]); | |
| 134 | await mainCheck("failed", ["parses the thing"]); | |
| 135 | expect(await proposeRevert(app, repo.id)).toBeUndefined(); | |
| 136 | expect(reverts()).toHaveLength(0); | |
| 137 | }); | |
| 138 | ||
| 131 | 139 | test("a green main opens none", async () => { |
| 132 | 140 | await mainCheck("ok"); |
| 133 | 141 | await land("one", "beta\n"); |
test/verify-after-landing.test.ts +22 −2
| @@ -155,12 +155,12 @@ describe("a red verification names its culprit", () => { | ||
| 155 | 155 | const tip = async (): Promise<string> => |
| 156 | 156 | (await resolveOid(repoDir(app.reposRoot, repo.ownerName, repo.name), "refs/heads/main")) ?? ""; |
| 157 | 157 | |
| 158 | const land = async (branch: string): Promise<Pull> => { | |
| 158 | const land = async (branch: string, more: { path: string; content: string }[] = []): Promise<Pull> => { | |
| 159 | 159 | await commitToBranch(app, alice, repo, { |
| 160 | 160 | branch, |
| 161 | 161 | base: "main", |
| 162 | 162 | message: branch, |
| 163 | files: [{ path: `${branch}.txt`, content: `${branch}\n` }], | |
| 163 | files: [{ path: `${branch}.txt`, content: `${branch}\n` }, ...more], | |
| 164 | 164 | }); |
| 165 | 165 | const opened = await openPull(app, alice, repo, { title: `Change ${branch}`, baseBranch: "main", headBranch: branch }); |
| 166 | 166 | if (!opened.ok) throw new Error(JSON.stringify(opened.error)); |
| @@ -252,6 +252,26 @@ describe("a red verification names its culprit", () => { | ||
| 252 | 252 | expect(listPulls(app.db, repo.id, { state: "all" }).filter((p) => p.revertsPullId !== null)).toHaveLength(1); |
| 253 | 253 | }); |
| 254 | 254 | |
| 255 | test("a culprit that added a migration pin is named in one issue, not a revert the gate refuses (#16637)", async () => { | |
| 256 | await verification("ok"); | |
| 257 | const pin = "src/core/migration-pins/20261128100000-walks.pin"; | |
| 258 | const pulls = [await land("one"), await land("two", [{ path: pin, content: "abc\n" }])]; | |
| 259 | const oids = [await tip()]; | |
| 260 | const red = await verification("failed"); | |
| 261 | const { lines } = await bisect(red, oids[0]!, oids); | |
| 262 | expect(lines.at(-1)).toContain(`culprit #${pulls[1]!.number}`); | |
| 263 | expect(lines.at(-1)).toContain("no revert"); | |
| 264 | expect(listPulls(app.db, repo.id, { state: "all" }).filter((p) => p.revertsPullId !== null)).toHaveLength(0); | |
| 265 | const issues = app.db | |
| 266 | .query<{ title: string; body: string }, [string]>("SELECT title, body FROM issue WHERE repo_id = ?1 AND kind = 'issue'") | |
| 267 | .all(repo.id); | |
| 268 | expect(issues).toHaveLength(1); | |
| 269 | expect(issues[0]!.title).toBe(`Red after landing: #${pulls[1]!.number} broke ${FILE}`); | |
| 270 | expect(issues[0]!.body).toContain(pin); | |
| 271 | expect(issues[0]!.body).toContain("Fix it forward"); | |
| 272 | expect(issues[0]!.body).toEndWith(`Files: ${FILE}`); | |
| 273 | }); | |
| 274 | ||
| 255 | 275 | test("a push no pull carried is named in one issue", async () => { |
| 256 | 276 | await verification("ok"); |
| 257 | 277 | await commitToBranch(app, alice, repo, { branch: "main", message: "direct", files: [{ path: "b.txt", content: "b\n" }] }); |
new above
offline