Public: anyone can read this; the crew can change it.

Sentinel: The lane has stopped: nothing has merged and nothing said so #16648

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/16637-sentinel-the-lane-has-stopped-nothing-ha → main 0 commits fork

  • Merged. mason/16637-sentinel-the-lane-has-stopped-nothing-ha was merged into main as 1821b44.

Review

Sign in to review this change.
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 file
src/checks/culprit.ts +12 −1
@@ -5,7 +5,8 @@
55 * at a time — each step a run of only those files, in the verification
66 * lane — until one commit is left. That commit is the culprit: the landed
77 * 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
910 * at the verification before it was named there and starts nothing.
1011 *
1112 * A later green verification that ran every file such an issue names
@@ -25,6 +26,7 @@ import { getUserById } from "../core/users.ts";
2526 import { runGit } from "../git/env.ts";
2627 import { isSafeOid } from "../git/guard.ts";
2728 import { repoDir } from "../git/repos.ts";
29 import { noRevertWhy, pinsLandedBy } from "./pinned_landing.ts";
2830 import { everReverted } from "./revert_red.ts";
2931 import {
3032 BISECT_ENV,
@@ -149,6 +151,15 @@ async function name(app: App, repo: Repo, red: Run, culprit: string, green: stri
149151 const pull = landingOf(app, repo, culprit);
150152 if (pull !== undefined) {
151153 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 )}`;
152163 const owner = getUserById(app.db, repo.ownerId);
153164 const body =
154165 `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 @@
44 * proposes the revert of that pull: one pull, `revertsPullId` set, titled
55 * for the pull it takes back and naming the failing test. It is only ever
66 * 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.
910 */
1011
1112 import type { App } from "../app.ts";
@@ -17,6 +18,7 @@ import { getUserById } from "../core/users.ts";
1718 import { runGit } from "../git/env.ts";
1819 import { repoDir } from "../git/repos.ts";
1920 import { isSafeOid } from "../git/guard.ts";
21 import { pinsLandedBy } from "./pinned_landing.ts";
2022 import { manifestError, redMain, type RedMain } from "./red_main.ts";
2123
2224 /** 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
9496 const landed = await soleLanding(app, red, green);
9597 if (landed === undefined || everReverted(app, landed.id)) return undefined;
9698 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;
97101 const owner = repo === undefined ? undefined : getUserById(app.db, repo.ownerId);
98102 if (repo === undefined || owner === undefined || getIssueById(app.db, landed.id) === undefined)
99103 return undefined;
src/kernel/pin_edits.ts +10
@@ -79,3 +79,13 @@ export function tipEdits(
7979 touched(path),
8080 );
8181 }
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", () => {
2424 let alice: User;
2525 let repo: Repo;
2626
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> => {
2828 await commitToBranch(app, alice, repo, {
2929 branch,
3030 base: "main",
3131 message: branch,
32 files: [{ path: "code.txt", content }],
32 files: [{ path: "code.txt", content }, ...more],
3333 });
3434 const opened = await openPull(app, alice, repo, {
3535 title: `Change ${branch}`,
@@ -128,6 +128,14 @@ describe("a red main after one landing proposes its revert", () => {
128128 expect(reverts()).toHaveLength(0);
129129 });
130130
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
131139 test("a green main opens none", async () => {
132140 await mainCheck("ok");
133141 await land("one", "beta\n");
test/verify-after-landing.test.ts +22 −2
@@ -155,12 +155,12 @@ describe("a red verification names its culprit", () => {
155155 const tip = async (): Promise<string> =>
156156 (await resolveOid(repoDir(app.reposRoot, repo.ownerName, repo.name), "refs/heads/main")) ?? "";
157157
158 const land = async (branch: string): Promise<Pull> => {
158 const land = async (branch: string, more: { path: string; content: string }[] = []): Promise<Pull> => {
159159 await commitToBranch(app, alice, repo, {
160160 branch,
161161 base: "main",
162162 message: branch,
163 files: [{ path: `${branch}.txt`, content: `${branch}\n` }],
163 files: [{ path: `${branch}.txt`, content: `${branch}\n` }, ...more],
164164 });
165165 const opened = await openPull(app, alice, repo, { title: `Change ${branch}`, baseBranch: "main", headBranch: branch });
166166 if (!opened.ok) throw new Error(JSON.stringify(opened.error));
@@ -252,6 +252,26 @@ describe("a red verification names its culprit", () => {
252252 expect(listPulls(app.db, repo.id, { state: "all" }).filter((p) => p.revertsPullId !== null)).toHaveLength(1);
253253 });
254254
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
255275 test("a push no pull carried is named in one issue", async () => {
256276 await verification("ok");
257277 await commitToBranch(app, alice, repo, { branch: "main", message: "direct", files: [{ path: "b.txt", content: "b\n" }] });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs