Public: anyone can read this; the crew can change it.
A pull that fails a rule test on today's main still landed: the feature-notes index was red on main four times in an hour #12698
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/12656-a-pull-that-fails-a-rule-test-on-today-s → main 5 commits fork 2 threads · 2 unresolved
12 files
changed +142
−19
src/actions/pulls.ts +1
| @@ -571,6 +571,7 @@ export async function mergePull( | ||
| 571 | 571 | db: app.db, |
| 572 | 572 | requireReview: repo.requireReview, |
| 573 | 573 | requireChecks: repo.requireChecks && opts.pastGate !== true, |
| 574 | freshGreen: opts.pastGate !== true, | |
| 574 | 575 | // Only an app's first change, which the crew's gate decided (`crew/first_change.ts`); never a person's own call. |
| 575 | 576 | ...(opts.pastReviews === true && !repo.requireReview ? { pastReviews: true } : {}), |
| 576 | 577 | // A named team with a reviewer here reads this head first (#10080). |
src/checks/stale.ts +4
| @@ -5,6 +5,10 @@ | ||
| 5 | 5 | * read, is not called stale — the reading says only what it knows. |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | /** What a person is told when a green check of an older base holds a merge (#12656). */ | |
| 9 | export const CHECK_STALE_REFUSAL = | |
| 10 | "Its check ran on an older main: re-run the check, then merge. Nothing was merged."; | |
| 11 | ||
| 8 | 12 | export function checkStale( |
| 9 | 13 | run: { readonly baseOid: string } | null, |
| 10 | 14 | baseTip: string | undefined, |
src/core/pulls.ts +14 −7
| @@ -837,6 +837,13 @@ export interface ReviewGate { | ||
| 837 | 837 | * Read live inside the merge like the review verdict. @default false |
| 838 | 838 | */ |
| 839 | 839 | readonly requireChecks?: boolean; |
| 840 | /** | |
| 841 | * A green check of an older base holds the landing even where checks are | |
| 842 | * not required (#12656): what was checked is not the tree that lands, and a | |
| 843 | * rule main gained since would be broken by it. Not asked by the owner's | |
| 844 | * break-glass. @default false | |
| 845 | */ | |
| 846 | readonly freshGreen?: boolean; | |
| 840 | 847 | /** |
| 841 | 848 | * An app's first change lands on green whatever the reviewer asked |
| 842 | 849 | * (`crew/first_change.ts`): the verdict is not read. @default false |
| @@ -1139,6 +1146,8 @@ export type MergePullError = | ||
| 1139 | 1146 | | "review_required" |
| 1140 | 1147 | /** The repo requires a passing deploy of this head, and there is none yet. */ |
| 1141 | 1148 | | "checks_required" |
| 1149 | /** The head is green, but the check ran on an older base than main now is (#12656). */ | |
| 1150 | | "check_stale" | |
| 1142 | 1151 | /** A team the pull's issue names has a reviewer here and has not approved this head (#10080). */ |
| 1143 | 1152 | | { readonly kind: "team_review_required"; readonly teams: readonly string[] }; |
| 1144 | 1153 | |
| @@ -1250,13 +1259,11 @@ export async function mergePull( | ||
| 1250 | 1259 | // the proof a re-check would give (#3316). The head must still be green. |
| 1251 | 1260 | if (input.gate !== undefined) { |
| 1252 | 1261 | const check = checkSummary(input.gate.db, pull.id, status.headOid); |
| 1253 | if ( | |
| 1254 | checksHold( | |
| 1255 | input.gate.requireChecks === true, | |
| 1256 | check.state, | |
| 1257 | input.expect === undefined && checkStale(check.run, status.baseOid), | |
| 1258 | ) | |
| 1259 | ) | |
| 1262 | const stale = input.expect === undefined && checkStale(check.run, status.baseOid); | |
| 1263 | // A green of an older base is told apart from no green: re-run, not wait. | |
| 1264 | if (check.state === "ok" && stale && (input.gate.requireChecks === true || input.gate.freshGreen === true)) | |
outdated
A stale green returns the same checks_required as a missing check. Give the stale case its own reason so the person is told to re-run the check, not left guessing. |
||
| 1265 | return err("check_stale"); | |
| 1266 | if (checksHold(input.gate.requireChecks === true, check.state, stale)) | |
| 1260 | 1267 | return err("checks_required"); |
| 1261 | 1268 | } |
| 1262 | 1269 | // A kept fork lands its combined branch, brought up to the base first: |
src/fleet/verbs.ts +2
| @@ -11,6 +11,7 @@ | ||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | import { NOT_A_MEMBER } from "../core/roles.ts"; |
| 14 | import { CHECK_STALE_REFUSAL } from "../checks/stale.ts"; | |
| 14 | 15 | import { AGENT_NOT_ON_CREW } from "../actions/crew_limit_words.ts"; |
| 15 | 16 | import type { App } from "../app.ts"; |
| 16 | 17 | import { |
| @@ -124,6 +125,7 @@ const WORDS: Record<string, string> = { | ||
| 124 | 125 | assignee_cannot_read: "the assignee cannot read this repository", |
| 125 | 126 | agent_not_on_crew: AGENT_NOT_ON_CREW, |
| 126 | 127 | already_merged: "a merged pull stays closed", |
| 128 | check_stale: CHECK_STALE_REFUSAL, | |
| 127 | 129 | reason_required: "a bug closed without a fix says why: add a reason", |
| 128 | 130 | invalid_note: "a reason is one sentence of at most 300 characters", |
| 129 | 131 | finished: "already finished", |
src/http/api.ts +2 −1
| @@ -285,7 +285,7 @@ import { | ||
| 285 | 285 | type ListRunsOptions, |
| 286 | 286 | type Run, |
| 287 | 287 | } from "../core/runs.ts"; |
| 288 | import { checkStale } from "../checks/stale.ts"; | |
| 288 | import { CHECK_STALE_REFUSAL, checkStale } from "../checks/stale.ts"; | |
| 289 | 289 | import { resolveOid } from "../git/merge.ts"; |
| 290 | 290 | import { readForgeUsage, readUsage, usageDays, USAGE_DAYS_MAX } from "../actions/usage.ts"; |
| 291 | 291 | import { readReturns, reportSpend, RETURNS_DAYS } from "../actions/returns.ts"; |
| @@ -687,6 +687,7 @@ export function originAware(error: string, status = 422): Response { | ||
| 687 | 687 | 422, |
| 688 | 688 | "a bug closed without a fix says why: send `note` (one sentence, at most 300 characters)", |
| 689 | 689 | ); |
| 690 | if (error === "check_stale") return apiError("check_stale", 409, CHECK_STALE_REFUSAL); | |
| 690 | 691 | if (error === "planner_paused") return apiError("planner_paused", 409, PAUSE_REFUSAL); |
| 691 | 692 | if (error === "mirrored") |
| 692 | 693 | return apiError( |
src/http/respond.ts +1
| @@ -56,6 +56,7 @@ const HINTS_BY_CODE: Record<string, string> = { | ||
| 56 | 56 | held: "This pull is on hold: ask the person who placed the hold to release it, then repeat the call.", |
| 57 | 57 | review_required: "This pull needs an approving review first: ask a reviewer, read GET its reviews to see what is missing, then repeat the call.", |
| 58 | 58 | checks_required: "The pull's head needs a passing check or deploy first: push a fix or wait for the check, then repeat the call.", |
| 59 | check_stale: "The pull's check ran on an older main: re-run the check on the current head, then repeat the call.", | |
| 59 | 60 | invalid: "A field failed validation: fix the field the message names (see the route's body in GET /contract/openapi.json) and send the whole body again.", |
| 60 | 61 | not_admin: "This route is for administrators only: use an administrator's token; a different scope will not help.", |
| 61 | 62 | forbidden: "Your token's scope or your role on this resource does not allow this: a read-only (`ro`) token cannot write, so mint an `rw` token, or ask an owner for the role the message names.", |
src/tui/screens/common.ts +2
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | * of them. Nothing here knows about repos or issues — that is the point. |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | import { CHECK_STALE_REFUSAL } from "../../checks/stale.ts"; | |
| 10 | 11 | import { PASSWORD_TOO_LONG } from "../../core/hash-gate.ts"; |
| 11 | 12 | import { refusalText } from "../../http/refusal.ts"; |
| 12 | 13 | import { fullSentence, isFullError, noteFullHere } from "../../kernel/full_disk.ts"; |
| @@ -1059,6 +1060,7 @@ const MESSAGES: Record<string, string> = { | ||
| 1059 | 1060 | // Apps, runs and the crew (docs/APPS.md). `checks_required` is the merge |
| 1060 | 1061 | // gate refusing, so like `review_required` it names what to do about it. |
| 1061 | 1062 | checks_required: "this needs a passing deploy of its current head first", |
| 1063 | check_stale: CHECK_STALE_REFUSAL, | |
| 1062 | 1064 | invalid_slug: "a slug is lowercase letters, digits and single hyphens", |
| 1063 | 1065 | slug_taken: "that slug is taken by another app", |
| 1064 | 1066 | already_app: "this repository is already an app", |
src/web/pages/pull.ts +2 −1
| @@ -50,7 +50,7 @@ import { | ||
| 50 | 50 | import { isProposed, pullMayRun } from "../../core/pull_trust.ts"; |
| 51 | 51 | import { checkWords } from "../../checks/summary.ts"; |
| 52 | 52 | import { runningProgress } from "../../checks/progress.ts"; |
| 53 | import { checkStale, checksHold } from "../../checks/stale.ts"; | |
| 53 | import { CHECK_STALE_REFUSAL, checkStale, checksHold } from "../../checks/stale.ts"; | |
| 54 | 54 | import { checkSummary, type CheckSummary } from "../../core/runs.ts"; |
| 55 | 55 | import { |
| 56 | 56 | anchorKey, |
| @@ -1356,6 +1356,7 @@ export function mergeFailure(error: AccessError | MergePullError): string { | ||
| 1356 | 1356 | // dismissed a second later, or a reviewer asked for changes in between. |
| 1357 | 1357 | if (error === "review_required") |
| 1358 | 1358 | return "This pull request needs an approving review of its current head, and does not have one. Nothing was merged."; |
| 1359 | if (error === "check_stale") return CHECK_STALE_REFUSAL; | |
| 1359 | 1360 | if (error === "checks_required") |
| 1360 | 1361 | return "This pull request needs a passing deploy of its current head, and does not have one yet. Nothing was merged."; |
| 1361 | 1362 | if (error === "forbidden" || error === "unauthorized") |
test/landsim.test.ts +10
| @@ -44,6 +44,7 @@ import { | ||
| 44 | 44 | type Scenario, |
| 45 | 45 | type Violation, |
| 46 | 46 | type World, |
| 47 | ruleAfterCheck, | |
| 47 | 48 | } from "./support/landsim.ts"; |
| 48 | 49 | |
| 49 | 50 | /** |
| @@ -116,6 +117,15 @@ describe("the landing simulator", () => { | ||
| 116 | 117 | }); |
| 117 | 118 | }); |
| 118 | 119 | |
| 120 | // #12656: a green of an older base does not land on a main that gained a rule since, | |
| 121 | // whether or not the repository requires checks. | |
| 122 | test("a pull checked before main gained a rule is not landed on it (#12656)", async () => { | |
| 123 | const out = await runScenario(world, ruleAfterCheck()); | |
| 124 | expect(out.violations.map((v) => `${v.cls}: ${v.message}`)).toEqual([]); | |
| 125 | expect(out.landed).toBe(0); | |
| 126 | expect([...out.refusals.keys()]).toContain("land: check_stale"); | |
| 127 | }, 60_000); | |
| 128 | ||
| 119 | 129 | // #12104: when two changes add lines at the same place, a kept fork's landing keeps both sides. |
| 120 | 130 | test( |
| 121 | 131 | "two fork pulls that add lines at the end of one file both land, both sides present (#12104)", |
test/merge-stale-green.test.ts +36 −3
| @@ -12,6 +12,9 @@ import { getPull } from "../src/core/pulls.ts"; | ||
| 12 | 12 | import { getRepo } from "../src/core/repos.ts"; |
| 13 | 13 | import { getUserByName } from "../src/core/users.ts"; |
| 14 | 14 | import { mergeable } from "../src/git/merge.ts"; |
| 15 | import { errorText } from "../src/tui/screens/common.ts"; | |
| 16 | import { mergeFailure } from "../src/web/pages/pull.ts"; | |
| 17 | import { CHECK_STALE_REFUSAL } from "../src/checks/stale.ts"; | |
| 15 | 18 | import { repoDir } from "../src/git/repos.ts"; |
| 16 | 19 | |
| 17 | 20 | const gitEnv = gitClientEnv(); |
| @@ -133,7 +136,7 @@ test("the API merge refuses a green checked against an older base when checks ar | ||
| 133 | 136 | |
| 134 | 137 | const refused = await call("/pulls/1/merge", { method: "POST", body: "{}" }); |
| 135 | 138 | expect(refused.status).toBe(409); |
| 136 | expect(((await refused.json()) as any).error).toBe("checks_required"); | |
| 139 | expect(((await refused.json()) as any).error).toBe("check_stale"); | |
| 137 | 140 | |
| 138 | 141 | // A green against the current tip lands. |
| 139 | 142 | setRunBase(app.db, run.id, await gitOk(["rev-parse", "main"])); |
| @@ -217,7 +220,7 @@ test("the MCP merge tool refuses a green checked against an older base, and land | ||
| 217 | 220 | const tip = await moveMain("before-mcp.txt"); |
| 218 | 221 | |
| 219 | 222 | const refused = await mcpMerge(pull.number); |
| 220 | expect(refused.error).toStartWith("checks_required"); | |
| 223 | expect(refused.error).toContain("check ran on an older main: re-run the check"); | |
| 221 | 224 | expect(merged(pull.number)).toBeNull(); |
| 222 | 225 | expect(await gitOk(["ls-remote", "origin", "refs/heads/main"])).toStartWith(tip); |
| 223 | 226 | |
| @@ -240,7 +243,7 @@ test("the merge queue's gated landing (expect) is not held by a green on an olde | ||
| 240 | 243 | // The same pull, without the queue's guard, is still refused. |
| 241 | 244 | const held = await mergePull(app, dev, repo, p, "merge"); |
| 242 | 245 | expect(held.ok).toBe(false); |
| 243 | if (!held.ok) expect(held.error).toBe("checks_required"); | |
| 246 | if (!held.ok) expect(held.error).toBe("check_stale"); | |
| 244 | 247 | |
| 245 | 248 | const landed = await mergePull(app, dev, repo, p, "merge", { |
| 246 | 249 | baseOid: tip, |
| @@ -248,3 +251,33 @@ test("the merge queue's gated landing (expect) is not held by a green on an olde | ||
| 248 | 251 | }); |
| 249 | 252 | expect(landed.ok).toBe(true); |
| 250 | 253 | }); |
| 254 | ||
| 255 | test("a stale green is refused in words a person can act on, on the API, the page and the terminal", async () => { | |
| 256 | const pull = await greenPull("by-words"); | |
| 257 | await moveMain("before-words.txt"); | |
| 258 | ||
| 259 | const refused = await call(`/pulls/${pull.number}/merge`, { method: "POST", body: "{}" }); | |
| 260 | expect(refused.status).toBe(409); | |
| 261 | const body = (await refused.json()) as { error: string; message: string }; | |
| 262 | expect(body.error).toBe("check_stale"); | |
| 263 | expect(body.message).toBe(CHECK_STALE_REFUSAL); | |
| 264 | expect(CHECK_STALE_REFUSAL).toContain("ran on an older main: re-run the check, then merge"); | |
| 265 | ||
| 266 | expect(mergeFailure("check_stale")).toBe(CHECK_STALE_REFUSAL); | |
| 267 | expect(errorText("check_stale")).toBe(CHECK_STALE_REFUSAL); | |
| 268 | }); | |
| 269 | ||
| 270 | test("the owner's break-glass is not asked for a fresh green: a stale green still lands past the gate", async () => { | |
| 271 | const pull = await greenPull("by-glass"); | |
| 272 | await moveMain("before-glass.txt"); | |
| 273 | const repo = getRepo(app.db, "dev", "app")!; | |
| 274 | const p = getPull(app.db, repo.id, pull.number)!; | |
| 275 | const dev = getUserByName(app.db, "dev")!; | |
| 276 | ||
| 277 | const held = await mergePull(app, dev, repo, p, "merge"); | |
| 278 | expect(held.ok).toBe(false); | |
| 279 | if (!held.ok) expect(held.error).toBe("check_stale"); | |
| 280 | ||
| 281 | const glass = await mergePull(app, dev, repo, p, "merge", undefined, { pastGate: true }); | |
| 282 | expect(glass.ok).toBe(true); | |
| 283 | }); |
test/stale-green.test.ts +1 −1
| @@ -143,7 +143,7 @@ describe("stale greens land in one candidate", () => { | ||
| 143 | 143 | try { |
| 144 | 144 | const merged = await mergePull(app, alice, fresh(), pull, "squash"); |
| 145 | 145 | expect(merged.ok).toBe(false); |
| 146 | if (!merged.ok) expect(merged.error).toBe("checks_required"); | |
| 146 | if (!merged.ok) expect(merged.error).toBe("check_stale"); | |
| 147 | 147 | } finally { |
| 148 | 148 | app.db.query("UPDATE repo SET autonomy = 'autonomous' WHERE id = ?1").run(repo.id); |
| 149 | 149 | } |
test/support/landsim.ts +67 −6
| @@ -82,7 +82,8 @@ export type Edit = | ||
| 82 | 82 | | { k: "rename"; file: string; to: string } |
| 83 | 83 | | { k: "delete"; file: string } |
| 84 | 84 | | { k: "addfile"; file: string; tag: string; n: number } |
| 85 | | { k: "mode"; file: string }; | |
| 85 | | { k: "mode"; file: string } | |
| 86 | | { k: "write"; file: string; content: string }; | |
| 86 | 87 | |
| 87 | 88 | export interface PullSpec { |
| 88 | 89 | id: number; |
| @@ -113,6 +114,8 @@ export interface Scenario { | ||
| 113 | 114 | files: Record<string, string>; |
| 114 | 115 | pulls: PullSpec[]; |
| 115 | 116 | steps: Step[]; |
| 117 | /** The repository's `require_checks` (the default is on; production runs with it off). */ | |
| 118 | requireChecks?: boolean; | |
| 116 | 119 | } |
| 117 | 120 | |
| 118 | 121 | // --------------------------------------------------------------------------- |
| @@ -319,6 +322,8 @@ const editWords = (e: Edit): string => { | ||
| 319 | 322 | return `add ${e.file} with ${e.n} line(s) [${e.tag}]`; |
| 320 | 323 | case "mode": |
| 321 | 324 | return `chmod +x ${e.file}`; |
| 325 | case "write": | |
| 326 | return `write ${e.file}`; | |
| 322 | 327 | } |
| 323 | 328 | }; |
| 324 | 329 | |
| @@ -385,6 +390,11 @@ export function applyEdits(base: Tree, edits: readonly Edit[]): FileWrite[] { | ||
| 385 | 390 | const touched = new Set<string>(); |
| 386 | 391 | for (const e of edits) { |
| 387 | 392 | const f = cur.get(e.file); |
| 393 | if (e.k === "write") { | |
| 394 | cur.set(e.file, { content: e.content, mode: cur.get(e.file)?.mode ?? "100644" }); | |
| 395 | touched.add(e.file); | |
| 396 | continue; | |
| 397 | } | |
| 388 | 398 | if (e.k === "addfile") { |
| 389 | 399 | if (cur.has(e.file)) continue; |
| 390 | 400 | const lines = Array.from({ length: e.n }, (_, i) => |
| @@ -534,6 +544,22 @@ async function trackedLines(dir: string, rev: string): Promise<Set<string>> { | ||
| 534 | 544 | return out; |
| 535 | 545 | } |
| 536 | 546 | |
| 547 | /** | |
| 548 | * The always-run rule the simulator stands in for `test/feature-orphans.test.ts`: once a tree holds | |
| 549 | * `notes/INDEX.md`, every other `notes/*.md` is named in it. | |
| 550 | * The files that break it, none when it holds. | |
| 551 | */ | |
| 552 | export async function orphanNotes(dir: string, rev: string): Promise<string[]> { | |
| 553 | const tree = await readTree(dir, rev); | |
| 554 | const index = tree.get("notes/INDEX.md"); | |
| 555 | if (index === undefined) return []; | |
| 556 | return [...tree.keys()].filter((f) => /^notes\/[^/]+\.md$/.test(f) && f !== "notes/INDEX.md" && !index.content.includes(f.slice(6))); | |
| 557 | } | |
| 558 | ||
| 559 | /** What the stub check and gate judge a tree red for: conflict markers, or a rule it breaks. */ | |
| 560 | const isRed = async (dir: string, rev: string): Promise<boolean> => | |
| 561 | (await hasMarkers(dir, rev)) || (await orphanNotes(dir, rev)).length > 0; | |
| 562 | ||
| 537 | 563 | const hasMarkers = async (dir: string, rev: string): Promise<boolean> => |
| 538 | 564 | (await git(dir, ["grep", "-I", "-q", "-E", "^(<<<<<<<|>>>>>>>) ", rev, "--"])) |
| 539 | 565 | .code === 0; |
| @@ -800,7 +826,7 @@ export async function createWorld(): Promise<World> { | ||
| 800 | 826 | for (const l of chain.out.split("\n")) |
| 801 | 827 | if (/^[0-9a-f]{40}$/.test(l)) trees.add(l); |
| 802 | 828 | if (process.env["LANDSIM_DEBUG"]) console.log("GATE", commitOid, JSON.stringify(chain.out), chain.err); |
| 803 | const red = await hasMarkers(dir, commitOid); | |
| 829 | const red = await isRed(dir, commitOid); | |
| 804 | 830 | return red |
| 805 | 831 | ? { ok: false, error: "red", lines: ["(fail) conflict markers"] } |
| 806 | 832 | : { ok: true, error: "", lines: [] }; |
| @@ -896,9 +922,9 @@ export class Sim { | ||
| 896 | 922 | if (!made.ok) throw new Error(`createRepo: ${String(made.error)}`); |
| 897 | 923 | app.db |
| 898 | 924 | .query( |
| 899 | "UPDATE repo SET require_review = 1, require_checks = 1, autonomy = 'autonomous', autonomy_by = ?2 WHERE id = ?1", | |
| 925 | "UPDATE repo SET require_review = 1, require_checks = ?3, autonomy = 'autonomous', autonomy_by = ?2 WHERE id = ?1", | |
| 900 | 926 | ) |
| 901 | .run(made.value.id, world.alice.id); | |
| 927 | .run(made.value.id, world.alice.id, this.sc.requireChecks === false ? 0 : 1); | |
| 902 | 928 | this.repo = getRepoById(app.db, made.value.id)!; |
| 903 | 929 | this.dir = repoDir(app.reposRoot, this.repo.ownerName, this.repo.name); |
| 904 | 930 | const seeded = await commitToBranch(app, world.alice, this.repo, { |
| @@ -1144,6 +1170,11 @@ export class Sim { | ||
| 1144 | 1170 | return getPull(this.app.db, this.repo.id, st.number)!; |
| 1145 | 1171 | } |
| 1146 | 1172 | |
| 1173 | /** Whether `tip` is the commit a pull's landing made. */ | |
| 1174 | private pushedByLanding(tip: string): boolean { | |
| 1175 | return [...this.pulls.values()].some((st) => this.row(st).mergedOid === tip); | |
| 1176 | } | |
| 1177 | ||
| 1147 | 1178 | private isOpen(st: PullState): boolean { |
| 1148 | 1179 | const row = this.row(st); |
| 1149 | 1180 | return row.state === "open" && row.mergedAt === null; |
| @@ -1181,11 +1212,11 @@ export class Sim { | ||
| 1181 | 1212 | source = combined.oid; |
| 1182 | 1213 | builtOn = combined.baseOid === "" ? status.baseOid : combined.baseOid; |
| 1183 | 1214 | tree = (await git(this.dir, ["rev-parse", `${source}^{tree}`])).out.trim(); |
| 1184 | ok = !(await hasMarkers(this.dir, tree)); | |
| 1215 | ok = !(await isRed(this.dir, tree)); | |
| 1185 | 1216 | } else { |
| 1186 | 1217 | const merged = await mergeable(this.dir, status.baseOid, status.headOid); |
| 1187 | 1218 | tree = merged.ok ? merged.value.treeOid : ""; |
| 1188 | ok = merged.ok && !(await hasMarkers(this.dir, tree)); | |
| 1219 | ok = merged.ok && !(await isRed(this.dir, tree)); | |
| 1189 | 1220 | } |
| 1190 | 1221 | const run = createRun(app.db, { |
| 1191 | 1222 | repoId: this.repo.id, |
| @@ -1310,6 +1341,15 @@ export class Sim { | ||
| 1310 | 1341 | cls: "noMarkersInMain", |
| 1311 | 1342 | message: `main at ${tip.slice(0, 10)} holds conflict markers`, |
| 1312 | 1343 | }); |
| 1344 | // A landing must not turn main red on a rule it already had; | |
| 1345 | // a tip a person pushed that breaks one is theirs. | |
| 1346 | const orphans = await orphanNotes(this.dir, tip); | |
| 1347 | if (orphans.length > 0 && this.pushedByLanding(tip)) | |
| 1348 | this.violate({ | |
| 1349 | invariant: "ruleHoldsOnMain", | |
| 1350 | cls: "ruleHoldsOnMain", | |
| 1351 | message: `main at ${tip.slice(0, 10)} breaks the notes rule after a landing: ${orphans.join(", ")}`, | |
| 1352 | }); | |
| 1313 | 1353 | } |
| 1314 | 1354 | |
| 1315 | 1355 | private async auditLanding(st: PullState, row: Pull): Promise<void> { |
| @@ -1562,6 +1602,27 @@ export function additiveForkPair(): Scenario { | ||
| 1562 | 1602 | return pairScript(1, files, [mk(1), mk(2)]); |
| 1563 | 1603 | } |
| 1564 | 1604 | |
| 1605 | /** | |
| 1606 | * #12656: a pull is checked and approved while main has no rule; main then gains the rule | |
| 1607 | * (`notes/INDEX.md`, an index every note must be named in); the pull adds a note the index | |
| 1608 | * does not name. The forge's check is of the older base, and the repository does not require | |
| 1609 | * checks (production's setting): a person lands it, and main would be red on the rule. | |
| 1610 | */ | |
| 1611 | export function ruleAfterCheck(): Scenario { | |
| 1612 | const files = { "README.md": "# Project ~r0.h\n- item ~r0.0\n", "notes/a.md": "A note.\n" }; | |
| 1613 | const pulls: PullSpec[] = [ | |
| 1614 | { id: 1, who: "dave", fork: false, point: 0, edits: [{ k: "write", file: "notes/b.md", content: "Another note.\n" }] }, | |
| 1615 | ]; | |
| 1616 | const steps: Step[] = [ | |
| 1617 | { op: "open", p: 1 }, | |
| 1618 | { op: "check", p: 1 }, | |
| 1619 | { op: "approve", p: 1 }, | |
| 1620 | { op: "main", edits: [{ k: "write", file: "notes/INDEX.md", content: "- a.md\n" }] }, | |
| 1621 | { op: "land", p: 1, how: "squash" }, | |
| 1622 | ]; | |
| 1623 | return { seed: 12656, files, pulls, steps, requireChecks: false }; | |
| 1624 | } | |
| 1625 | ||
| 1565 | 1626 | function pairScript( |
| 1566 | 1627 | seed: number, |
| 1567 | 1628 | files: Record<string, string>, |
new above
offline
Test that pastGate === true leaves freshGreen false; nothing covers it now.