Public: anyone can read this; the crew can change it.
The gate asks a feature pull which open issue it serves, and nothing about the pipeline or its size (#16249) #16390
Check · Review · Land · Live done — Landed and live in production.
fix/gate-no-cap → main 0 commits
8 files
changed +79
−168
AGENTS.md +1
| @@ -6,6 +6,7 @@ Read the guide first, in this order: `docs/guide-what-a-forge-is.md`, `docs/guid | ||
| 6 | 6 | |
| 7 | 7 | A maintenance duty is a file in `src/maintain/duties/` that exports `duty`; `src/maintain/registry.ts` builds the roster from that directory, never edit a list by hand (#14355, `test/duty-roster.test.ts`). |
| 8 | 8 | |
| 9 | A pull that adds a feature file (a page, a screen, a how-to, a new module, vendored code) names the issue it serves as `#123` in a commit message; the gate refuses one that names none, and counts nothing else: whether the pull is whole and single-purpose is the reviewer's judgment, asking for a split only when each part could be used alone. | |
| 9 | 10 | README.md is capped: a new feature's how-to goes in `docs/features/<name>.md`, not a new README section. |
| 10 | 11 | A pull that adds a page (`src/web/pages/*.ts`) also adds a terminal screen under `src/tui/screens/` that another module imports (its palette entry) and a `docs/features/<name>.md`, or a commit line `No door: <why>`; a new `src/web/render/*.ts`, `src/web/studio/*.ts` or `src/actions/*.ts` is asked for the screen alone, and a new feature module under `src/` in a pull that edits an existing page is asked for both, and a pull that edits an existing page (or any shared `src/web/` file, #13376: a new feature module wired into it is asked for both) changes something under `src/tui/` and a `docs/features/*.md` too (#13196); an edited API route, MCP tool or `src/actions/*.ts` changes something under `src/tui/` too (#14040); a new `src/http/api/*.ts` or `src/http/mcp/tools/*.ts` is asked for the screen, and a new module wired into `src/http/server.ts` for both (#14320); `bun scripts/gate.ts` refuses it otherwise ("both doors", #10628). |
| 11 | 12 | Both doors are also read from the tree (#14289): `test/doorless.test.ts` fails on a page in `src/web/pages/` with no terminal door unless `scripts/doorless-allow.json` lists it (the list only shrinks; `bun scripts/doorless.ts --write` prunes). A page has a door when `src/tui/` or `src/actions/` imports it, a screen is named for it, or a features doc naming the page file names `src/tui/` too. |
docs/features/forge-it.md +1 −1
| @@ -15,4 +15,4 @@ A **Forge it** button (rocket icon, outline weight, so it is not mistaken for Fo | ||
| 15 | 15 | |
| 16 | 16 | Not here: a hosted child's crew runner (#4416), arriving signed in with no claim form (#2928), choosing a template (#7534, #7535). |
| 17 | 17 | |
| 18 | Direction: this is a feature ahead of the pipeline-first order only in being a small door onto the spawn path that already exists; it adds no pipeline code. The owner asked for it on #7642. | |
| 18 | Direction: a small door onto the spawn path that already exists. The owner asked for it on #7642. |
docs/features/own-source.md +4 −5
| @@ -46,9 +46,8 @@ finishes an unfinished run, leaves a person's repo alone, and is a recorded | ||
| 46 | 46 | one-shot; adoption seats the crew with copied roles and keeps an earlier |
| 47 | 47 | `forgeRepo`. |
| 48 | 48 | |
| 49 | ## Why it goes before the pipeline list | |
| 49 | ## Why it matters | |
| 50 | 50 | |
| 51 | A forge that cannot be worked on from inside cannot take part in the pipeline | |
| 52 | list (#6534, #6611, ...): those items are changes to the child's own code, and | |
| 53 | each needs a repository on the child to land in and an upstream to send back | |
| 54 | to. This is the ground they stand on. | |
| 51 | A forge that cannot be worked on from inside cannot take part in changes to | |
| 52 | its own code: each needs a repository on the child to land in and an upstream | |
| 53 | to send back to. This is the ground they stand on. |
docs/features/similar.md +1 −1
| @@ -25,4 +25,4 @@ commit. Three of the 14 added a helper that already existed in another shape: `a | ||
| 25 | 25 | Two more (`daeFromText`, `readDae`) followed `src/web/render/obj.ts` by design. Scores under 0.8 were noise. |
| 26 | 26 | |
| 27 | 27 | The trial is 14 commits by hand, fewer than the 20 the issue asked for, and is a sample, not a measurement of review |
| 28 | round-trips saved. It is not tied to the pipeline items; the pull says so. | |
| 28 | round-trips saved. |
scripts/gate.ts +3 −3
| @@ -899,8 +899,8 @@ export function numstatLines(raw: string): Map<string, number> { | ||
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | /** |
| 902 | * A pull that adds a feature without touching the pipeline says why (#11036). | |
| 903 | * `run` is the git runner; a test hands one in that fails `--numstat` alone. | |
| 902 | * A pull that adds a feature names the issue it serves (#16249). `run` is the git runner; a test | |
| 903 | * hands one in that fails `--numstat` alone. | |
| 904 | 904 | */ |
| 905 | 905 | export async function directionRefusal(cwd: string = process.cwd(), run: typeof git = git): Promise<string[]> { |
| 906 | 906 | const { parseNameStatus } = await import("../src/kernel/pin_edits.ts"); |
| @@ -914,7 +914,7 @@ export async function directionRefusal(cwd: string = process.cwd(), run: typeof | ||
| 914 | 914 | const log = run(["log", "--format=%B%x00", `${base}..${judgedHead(cwd)}`], cwd); |
| 915 | 915 | if (!diff.ok || !log.ok) return []; |
| 916 | 916 | const stat = run(["diff", "--numstat", "-z", "-M", `${base}..${judgedHead(cwd)}`], cwd); |
| 917 | if (!stat.ok) return [`rule "pipeline first": could not read the pull's line counts (git diff --numstat failed), so redesigns cannot be checked`]; | |
| 917 | if (!stat.ok) return [`rule "name the issue": could not read the pull's line counts (git diff --numstat failed), so redesigns cannot be checked`]; | |
| 918 | 918 | return directionProblems(parseNameStatus(diff.out), log.out.split("\0").map((m) => m.trim()).filter(Boolean), numstatLines(stat.out)); |
| 919 | 919 | } |
| 920 | 920 |
src/kernel/direction.ts +33 −77
| @@ -1,53 +1,24 @@ | ||
| 1 | 1 | /** |
| 2 | * Four reviews in a week said "pipeline first, before any feature" (#11036). | |
| 3 | * A pull that adds a feature surface — a page (`src/web/pages/*.ts`), a | |
| 4 | * terminal screen (`src/tui/`) or a how-to (`docs/features/*.md`) — and | |
| 5 | * touches no pipeline code (`scripts/`, `src/flow/`, `src/nightly/`, | |
| 6 | * `src/checks/`, `forge.json`) must say why it goes ahead of the pipeline | |
| 7 | * items, as `Direction: <why>` in a commit message. | |
| 2 | * A pull that adds a feature surface — a page (`src/web/pages/*.ts`), a terminal screen | |
| 3 | * (`src/tui/`), a how-to (`docs/features/*.md`), a new module under `src/` or vendored code — names | |
| 4 | * the issue it serves, as `#123` in a commit message (#16249). Reviewers | |
| 5 | * said "say which issue it serves" (#14293) and still do; they judge size and single purpose by the | |
| 6 | * direction's words (whole: can a person use it now? split only when each part could be used | |
| 7 | * alone), not by a count, and the gate counts nothing and keeps no list of issues. | |
| 8 | 8 | * |
| 9 | * Vendored code is a feature too (#13748): four reviews (#10317, #11263, | |
| 10 | * #12444, #13651) asked for the same direction, and #10317 added about 90k | |
| 11 | * lines of vendored code that no page or screen path caught. A file added | |
| 12 | * under a `vendor/` directory counts once per directory. | |
| 13 | * | |
| 14 | * The waiver names the issue it serves, as `#123` (#14293): five reviews (#11151, #12111, #13859, | |
| 15 | * #14116, #14171) asked for it. | |
| 16 | * | |
| 17 | * Four more reviews (#11289, #11696, #12177, #12307) accepted that waiver and | |
| 18 | * still said "keep it small and single-purpose" (#12363). So the waiver buys | |
| 19 | * a small pull only: at most `MAX_FEATURES` added feature files and | |
| 20 | * `MAX_FILES` changed files in all. | |
| 9 | * Vendored code is a feature too (#13748): a file added under a `vendor/` directory counts once | |
| 10 | * per directory. | |
| 21 | 11 | */ |
| 22 | 12 | |
| 23 | 13 | import type { Change } from "./pin_edits.ts"; |
| 24 | 14 | |
| 25 | 15 | const FEATURE = /^(src\/web\/pages\/[^/]+\.ts|src\/tui\/.+\.ts|docs\/features\/[^/]+\.md)$/; |
| 26 | 16 | /** |
| 27 | * Added, not edited: a new module a feature reaches people by (#14287). Five reviews (#10916, | |
| 28 | * #10979, #11165, #11715, #13992) asked "why does this go ahead of the pipeline" of pulls that | |
| 29 | * added an action, a core module or an HTTP route and no page; four more (#11887, #12378, #13347, | |
| 30 | * #14131) asked it of a pull whose new module sat elsewhere (`src/maintain/duties/`): any added | |
| 31 | * `.ts` module under `src/` is a feature now, wherever it lives (#14290). | |
| 17 | * Added, not edited: a new module a feature reaches people by (#14287): any added `.ts` module | |
| 18 | * under `src/` is a feature, wherever it lives (#14290). | |
| 32 | 19 | */ |
| 33 | 20 | const NEW_MODULE = /^src\/(?!core\/migrations\/).+\.ts$/; |
| 34 | 21 | const VENDORED = /^(.*\/)?vendor\//; |
| 35 | const PIPELINE = /^(scripts\/|src\/flow\/|src\/nightly\/|src\/checks\/|forge\.json$)/; | |
| 36 | /** A feature pull that goes ahead of the pipeline: one page and its how-to. */ | |
| 37 | export const MAX_FEATURES = 2; | |
| 38 | export const MAX_FILES = 20; | |
| 39 | const WAIVER = /^Direction:[ \t]*\S[^\n]{9,}/im; | |
| 40 | /** | |
| 41 | * The issue the waiver serves, as `#123` (#14293): five reviews said "say which issue it serves". | |
| 42 | */ | |
| 43 | const ISSUE = /#\d+/; | |
| 44 | /** | |
| 45 | * The owner's pipeline items, in order. Five more reviews (#13496, #13931, #13951, #14661, #15095) | |
| 46 | * asked "say why it goes ahead of #6534, #6611 ...": a waiver names at least one it goes ahead of | |
| 47 | * (#15415). Change this list when the owner's order changes. | |
| 48 | */ | |
| 49 | export const PIPELINE_ITEMS = [6534, 6611, 5276, 3316, 6217, 6428, 1242, 1073] as const; | |
| 50 | const itemNamed = (w: string) => [...w.matchAll(/#(\d+)/g)].some((m) => (PIPELINE_ITEMS as readonly number[]).includes(Number(m[1]))); | |
| 51 | 22 | |
| 52 | 23 | /** |
| 53 | 24 | * A redesign edits a page rather than adding one (#10380): an existing |
| @@ -55,50 +26,35 @@ const itemNamed = (w: string) => [...w.matchAll(/#(\d+)/g)].some((m) => (PIPELIN | ||
| 55 | 26 | */ |
| 56 | 27 | export const REDESIGN_LINES = 150; |
| 57 | 28 | |
| 29 | /** The feature files a range adds (or redesigns, given `lines`: changed lines per path). */ | |
| 30 | export function featuresOf(changes: readonly Change[], lines: ReadonlyMap<string, number> = new Map()): string[] { | |
| 31 | const vendored = changes | |
| 32 | .filter((c) => c.status.startsWith("A") && VENDORED.test(c.path)) | |
| 33 | .map((c) => `${VENDORED.exec(c.path)?.[0]}`); | |
| 34 | return [ | |
| 35 | ...changes | |
| 36 | .filter((c) => (FEATURE.test(c.path) || (c.status.startsWith("A") && NEW_MODULE.test(c.path))) && (c.status.startsWith("A") || (lines.get(c.path) ?? 0) >= REDESIGN_LINES)) | |
| 37 | .map((c) => c.path), | |
| 38 | ...new Set(vendored), | |
| 39 | ]; | |
| 40 | } | |
| 41 | ||
| 42 | /** Every `#123` the messages name, once each. */ | |
| 43 | export const issuesNamed = (messages: readonly string[]): number[] => [ | |
| 44 | ...new Set(messages.flatMap((m) => [...m.matchAll(/#(\d+)/g)].map((x) => Number(x[1])))), | |
| 45 | ]; | |
| 46 | ||
| 58 | 47 | /** |
| 59 | * One line per problem: none unless a feature is added (or a page redesigned, | |
| 60 | * given `lines`: changed lines per path) with no pipeline change and no | |
| 61 | * Direction line. | |
| 48 | * One line per problem: none unless a feature is added (or a page redesigned) and no commit message | |
| 49 | * names an issue. | |
| 62 | 50 | */ |
| 63 | 51 | export function directionProblems( |
| 64 | 52 | changes: readonly Change[], |
| 65 | 53 | messages: readonly string[], |
| 66 | 54 | lines: ReadonlyMap<string, number> = new Map(), |
| 67 | 55 | ): string[] { |
| 68 | const vendored = changes | |
| 69 | .filter((c) => c.status.startsWith("A") && VENDORED.test(c.path)) | |
| 70 | .map((c) => `${VENDORED.exec(c.path)?.[0]}`); | |
| 71 | const features = [ | |
| 72 | ...changes | |
| 73 | .filter((c) => (FEATURE.test(c.path) || (c.status.startsWith("A") && (NEW_MODULE.test(c.path)))) && (c.status.startsWith("A") || (lines.get(c.path) ?? 0) >= REDESIGN_LINES)) | |
| 74 | .map((c) => c.path), | |
| 75 | ...new Set(vendored), | |
| 76 | ]; | |
| 77 | if (features.length === 0) return []; | |
| 78 | if (changes.some((c) => PIPELINE.test(c.path))) return []; | |
| 79 | const waivers = messages.flatMap((m) => m.match(new RegExp(WAIVER.source, "gim")) ?? []); | |
| 80 | if (waivers.length === 0) return [problem(features)]; | |
| 81 | if (!waivers.some((w) => ISSUE.test(w))) | |
| 82 | return [ | |
| 83 | `rule "name the issue": the Direction line says why this feature goes ahead of the pipeline but not which issue it serves; add its number, as "Direction: <why> (#123)"`, | |
| 84 | ]; | |
| 85 | if (!waivers.some(itemNamed)) | |
| 86 | return [ | |
| 87 | `rule "name what it goes ahead of": the Direction line does not name a pipeline item; say which it goes ahead of, as "Direction: <why> (#123), ahead of #${PIPELINE_ITEMS[0]}" (the items: ${PIPELINE_ITEMS.map((n) => "#" + n).join(", ")})`, | |
| 88 | ]; | |
| 89 | const big: string[] = []; | |
| 90 | if (features.length > MAX_FEATURES) | |
| 91 | big.push(`it adds ${features.length} feature files (at most ${MAX_FEATURES})`); | |
| 92 | if (changes.length > MAX_FILES) big.push(`it changes ${changes.length} files (at most ${MAX_FILES})`); | |
| 93 | if (big.length === 0) return []; | |
| 94 | return [ | |
| 95 | `rule "small and single-purpose": a feature that goes ahead of the pipeline stays small, and ${big.join(" and ")}; split it into pulls of one purpose each, or change the pipeline`, | |
| 96 | ]; | |
| 97 | } | |
| 98 | ||
| 99 | function problem(features: readonly string[]): string { | |
| 56 | const features = featuresOf(changes, lines); | |
| 57 | if (features.length === 0 || issuesNamed(messages).length > 0) return []; | |
| 100 | 58 | const shown = features.slice(0, 3).join(", ") + (features.length > 3 ? ` and ${features.length - 3} more` : ""); |
| 101 | return ( | |
| 102 | `rule "pipeline first": this pull adds a feature (${shown}) and no pipeline change (scripts/, src/flow/, src/nightly/, src/checks/, forge.json); change the pipeline, or put a "Direction: <why this goes ahead of the pipeline items> (#issue)" line (10+ characters, naming the issue it serves) in a commit message` | |
| 103 | ); | |
| 59 | return [`rule "name the issue": this pull adds a feature (${shown}) and no commit message names the issue it serves; add its number, as "Direction: <why> (#123)"`]; | |
| 104 | 60 | } |
test/direction-refusal.test.ts +12 −13
| @@ -45,28 +45,27 @@ const gateMain = (cwd: string, base: string) => { | ||
| 45 | 45 | return r.stderr.toString(); |
| 46 | 46 | }; |
| 47 | 47 | |
| 48 | test("a range that adds a page alone is refused; a Direction line in its message waives it", async () => { | |
| 48 | test("a range that adds a page alone is refused; naming an issue passes", async () => { | |
| 49 | 49 | const { dir, base } = repo("page"); |
| 50 | 50 | put(dir, "src/web/pages/machines.ts", "x"); |
| 51 | 51 | run(dir, "add", "-A"); |
| 52 | 52 | run(dir, "commit", "-qm", "Add machines"); |
| 53 | 53 | const out = await withBase(base, () => directionRefusal(dir)); |
| 54 | 54 | expect(out).toHaveLength(1); |
| 55 | expect(out[0]).toContain('rule "pipeline first"'); | |
| 55 | expect(out[0]).toContain('rule "name the issue"'); | |
| 56 | 56 | // the gate's own entry point runs the rule, so removing its call goes red |
| 57 | expect(gateMain(dir, base)).toContain('rule "pipeline first"'); | |
| 57 | expect(gateMain(dir, base)).toContain('rule "name the issue"'); | |
| 58 | 58 | |
| 59 | run(dir, "commit", "-q", "--allow-empty", "-m", "Waive\n\nDirection: a small door onto the spawn path, owner asked on #7642, ahead of #6534"); | |
| 59 | run(dir, "commit", "-q", "--allow-empty", "-m", "Waive\n\nDirection: a small door onto the spawn path (#7642)"); | |
| 60 | 60 | expect(await withBase(base, () => directionRefusal(dir))).toEqual([]); |
| 61 | expect(gateMain(dir, base)).not.toContain('rule "pipeline first"'); | |
| 62 | 61 | }); |
| 63 | 62 | |
| 64 | test("a range that adds the page with a pipeline change passes", async () => { | |
| 65 | const { dir, base } = repo("pipe"); | |
| 66 | put(dir, "src/web/pages/machines.ts", "x"); | |
| 67 | put(dir, "scripts/lint.ts", "x"); | |
| 63 | test("a range that adds many feature files and changes many files passes with an issue named", async () => { | |
| 64 | const { dir, base } = repo("wide"); | |
| 65 | for (let i = 0; i < 4; i++) put(dir, `src/web/pages/p${i}.ts`, "x"); | |
| 66 | for (let i = 0; i < 30; i++) put(dir, `src/core/m${i}.ts`, "x"); | |
| 68 | 67 | run(dir, "add", "-A"); |
| 69 | run(dir, "commit", "-qm", "Add machines"); | |
| 68 | run(dir, "commit", "-qm", "A whole feature (#7642)"); | |
| 70 | 69 | expect(await withBase(base, () => directionRefusal(dir))).toEqual([]); |
| 71 | 70 | }); |
| 72 | 71 | |
| @@ -83,9 +82,9 @@ test("rewriting an existing page by 150+ lines is refused; a small edit passes", | ||
| 83 | 82 | run(dir, "commit", "-qm", "Redesign"); |
| 84 | 83 | const out = await withBase(start, () => directionRefusal(dir)); |
| 85 | 84 | expect(out).toHaveLength(1); |
| 86 | expect(out[0]).toContain('rule "pipeline first"'); | |
| 85 | expect(out[0]).toContain('rule "name the issue"'); | |
| 87 | 86 | expect(out[0]).toContain("src/web/pages/home.ts"); |
| 88 | expect(gateMain(dir, start)).toContain('rule "pipeline first"'); | |
| 87 | expect(gateMain(dir, start)).toContain('rule "name the issue"'); | |
| 89 | 88 | |
| 90 | 89 | const small = repo("small-edit"); |
| 91 | 90 | put(small.dir, "src/web/pages/home.ts", bigPage("a")); |
| @@ -134,6 +133,6 @@ test("a failing git diff --numstat refuses the pull rather than skipping the red | ||
| 134 | 133 | }; |
| 135 | 134 | const out = await withBase(base, () => directionRefusal(dir, git)); |
| 136 | 135 | expect(out).toHaveLength(1); |
| 137 | expect(out[0]).toContain('rule "pipeline first"'); | |
| 136 | expect(out[0]).toContain('rule "name the issue"'); | |
| 138 | 137 | expect(out[0]).toContain("line counts"); |
| 139 | 138 | }); |
test/direction.test.ts +24 −68
| @@ -1,25 +1,32 @@ | ||
| 1 | 1 | import { expect, test } from "bun:test"; |
| 2 | import { directionProblems } from "../src/kernel/direction.ts"; | |
| 2 | import { directionProblems, issuesNamed } from "../src/kernel/direction.ts"; | |
| 3 | 3 | |
| 4 | 4 | const ch = (status: string, path: string) => ({ status, path }); |
| 5 | 5 | const page = ch("A", "src/web/pages/machines.ts"); |
| 6 | 6 | |
| 7 | test("a new feature with no pipeline change is refused, naming the rule", () => { | |
| 7 | test("a new feature that names no issue is refused in one line, naming the rule", () => { | |
| 8 | 8 | const out = directionProblems([page], ["Add machines"]); |
| 9 | 9 | expect(out).toHaveLength(1); |
| 10 | expect(out[0]).toContain('rule "pipeline first"'); | |
| 10 | expect(out[0]).toContain('rule "name the issue"'); | |
| 11 | 11 | expect(out[0]).toContain("src/web/pages/machines.ts"); |
| 12 | expect(out[0]).toContain('"Direction: <why'); | |
| 13 | 12 | }); |
| 14 | 13 | |
| 15 | test("a pipeline change, or a Direction line of 10+ characters, passes", () => { | |
| 16 | expect(directionProblems([page, ch("M", "scripts/gate.ts")], [])).toEqual([]); | |
| 17 | expect(directionProblems([page], ["x\n\nDirection: a small door onto the spawn path, owner asked on #7642, ahead of #6534"])).toEqual([]); | |
| 18 | expect(directionProblems([page], ["Direction: no"])).toHaveLength(1); | |
| 14 | test("a feature that names an issue passes, wherever the number sits", () => { | |
| 15 | expect(directionProblems([page], ["Direction: a small door onto the spawn path (#7642)"])).toEqual([]); | |
| 16 | expect(directionProblems([page], ["Closes #7642"])).toEqual([]); | |
| 17 | expect(directionProblems([page], ["Add machines", "Fix #7642"])).toEqual([]); | |
| 18 | }); | |
| 19 | ||
| 20 | test("nothing is counted: any number of feature files and changed files passes with an issue named", () => { | |
| 21 | const pages = ["a", "b", "c", "d"].map((n) => ch("A", `src/web/pages/${n}.ts`)); | |
| 22 | const many = [...pages, ...Array.from({ length: 40 }, (_, i) => ch("M", `src/core/m${i}.ts`))]; | |
| 23 | expect(directionProblems(many, ["Whole page and its how-to (#10262)"])).toEqual([]); | |
| 19 | 24 | }); |
| 20 | 25 | |
| 21 | 26 | test("edits and non-feature files are never asked", () => { |
| 22 | 27 | expect(directionProblems([ch("M", "src/web/pages/machines.ts"), ch("M", "src/core/x.ts")], [])).toEqual([]); |
| 28 | expect(directionProblems([ch("A", "test/x.test.ts")], [])).toEqual([]); | |
| 29 | expect(directionProblems([ch("A", "src/core/migrations/0003-c.ts")], [])).toEqual([]); | |
| 23 | 30 | expect(directionProblems([ch("A", "docs/features/x.md")], [])).toHaveLength(1); |
| 24 | 31 | }); |
| 25 | 32 | |
| @@ -27,84 +34,33 @@ test("a redesign — an existing page with 150+ changed lines — is a feature; | ||
| 27 | 34 | const edit = ch("M", "src/web/pages/machines.ts"); |
| 28 | 35 | const out = directionProblems([edit], ["Redesign"], new Map([[edit.path, 150]])); |
| 29 | 36 | expect(out).toHaveLength(1); |
| 30 | expect(out[0]).toContain('rule "pipeline first"'); | |
| 37 | expect(out[0]).toContain('rule "name the issue"'); | |
| 31 | 38 | expect(directionProblems([edit], [], new Map([[edit.path, 149]]))).toEqual([]); |
| 32 | expect(directionProblems([edit], ["Direction: owner asked for the redesign on #10299, ahead of #6534"], new Map([[edit.path, 400]]))).toEqual([]); | |
| 33 | expect(directionProblems([edit, ch("M", "scripts/gate.ts")], [], new Map([[edit.path, 400]]))).toEqual([]); | |
| 39 | expect(directionProblems([edit], ["Redesign (#10299)"], new Map([[edit.path, 400]]))).toEqual([]); | |
| 34 | 40 | }); |
| 35 | 41 | |
| 36 | test("the reason must sit on the Direction line itself, not a later paragraph", () => { | |
| 37 | expect(directionProblems([page], ["Direction:\n\nsome later paragraph of text"])).toHaveLength(1); | |
| 38 | }); | |
| 39 | ||
| 40 | test("a waived feature pull stays small and single-purpose, naming the rule", () => { | |
| 41 | const why = ["Direction: a small door onto the spawn path, owner asked on #7642, ahead of #6534"]; | |
| 42 | const pages = ["a", "b", "c"].map((n) => ch("A", `src/web/pages/${n}.ts`)); | |
| 43 | const many = pages.slice(0, 1).concat(Array.from({ length: 20 }, (_, i) => ch("M", `src/core/m${i}.ts`))); | |
| 44 | expect(directionProblems([page, ch("A", "docs/features/x.md")], why)).toEqual([]); | |
| 45 | const wide = directionProblems(pages, why); | |
| 46 | expect(wide).toHaveLength(1); | |
| 47 | expect(wide[0]).toContain('rule "small and single-purpose"'); | |
| 48 | expect(wide[0]).toContain("3 feature files"); | |
| 49 | expect(directionProblems(many, why)[0]).toContain("changes 21 files"); | |
| 50 | expect(directionProblems([...many, ch("M", "scripts/gate.ts")], why)).toEqual([]); | |
| 51 | }); | |
| 52 | ||
| 53 | test("vendored code added under vendor/ is a feature, once per directory, naming the rule (#13748)", () => { | |
| 42 | test("vendored code added under vendor/ is a feature, once per directory (#13748)", () => { | |
| 54 | 43 | const vendored = [ |
| 55 | 44 | ch("A", "src/web/render/vendor/three/build/three.core.js"), |
| 56 | 45 | ch("A", "src/web/render/vendor/three/build/three.module.js"), |
| 57 | 46 | ]; |
| 58 | 47 | const out = directionProblems(vendored, ["Render STL"]); |
| 59 | 48 | expect(out).toHaveLength(1); |
| 60 | expect(out[0]).toContain('rule "pipeline first"'); | |
| 61 | 49 | expect(out[0]).toContain("src/web/render/vendor/"); |
| 62 | 50 | expect(out[0]).not.toContain("and 1 more"); |
| 63 | expect(directionProblems(vendored, ["Direction: the owner asked for 3D files on #10317, ahead of #6534"])).toEqual([]); | |
| 64 | expect(directionProblems([...vendored, ch("M", "scripts/gate.ts")], [])).toEqual([]); | |
| 65 | 51 | expect(directionProblems([ch("M", "src/web/render/vendor/three/README.md")], [])).toEqual([]); |
| 66 | 52 | }); |
| 67 | 53 | |
| 68 | test("a new action, core module or route is a feature too, naming the rule (#14287)", () => { | |
| 69 | for (const path of ["src/actions/statement_csv.ts", "src/core/x.ts", "src/http/statement.ts"]) { | |
| 54 | test("a new action, core module, route or duty is a feature (#14287, #14290)", () => { | |
| 55 | for (const path of ["src/actions/statement_csv.ts", "src/core/x.ts", "src/http/statement.ts", "src/maintain/duties/x.ts", "src/crew/needs.ts"]) { | |
| 70 | 56 | const out = directionProblems([ch("A", path)], ["Add it"]); |
| 71 | 57 | expect(out).toHaveLength(1); |
| 72 | expect(out[0]).toContain('rule "pipeline first"'); | |
| 73 | expect(out[0]).toContain(path); | |
| 74 | expect(directionProblems([ch("A", path)], ["Direction: owner asked for it on #7642, ahead of #6534"])).toEqual([]); | |
| 75 | } | |
| 76 | // Editing one, or editing a script beside a new one, is not asked. | |
| 77 | expect(directionProblems([ch("M", "src/core/x.ts")], [])).toEqual([]); | |
| 78 | expect(directionProblems([ch("A", "src/core/x.ts"), ch("M", "scripts/gate.ts")], [])).toEqual([]); | |
| 79 | expect(directionProblems([ch("A", "src/core/x.ts"), ch("A", "src/checks/y.ts")], [])).toEqual([]); | |
| 80 | }); | |
| 81 | ||
| 82 | test("a Direction line that names no issue is refused by name (#14293)", () => { | |
| 83 | const out = directionProblems([page], ["Direction: a small door onto the spawn path, owner asked"]); | |
| 84 | expect(out).toHaveLength(1); | |
| 85 | expect(out[0]).toContain('rule "name the issue"'); | |
| 86 | expect(directionProblems([page], ["Direction: a small door onto the spawn path (#7642) ahead of #6611"])).toEqual([]); | |
| 87 | // an issue number elsewhere in the message is not the waiver's | |
| 88 | expect(directionProblems([page], ["Closes #7642\n\nDirection: a small door onto the spawn path"])).toHaveLength(1); | |
| 89 | }); | |
| 90 | ||
| 91 | test("a new module in any src/ directory is a feature too, naming the rule (#14290)", () => { | |
| 92 | for (const path of ["src/maintain/duties/merged_branches.ts", "src/crew/needs.ts", "src/web/render/x.ts"]) { | |
| 93 | const out = directionProblems([ch("A", path)], ["Add it"]); | |
| 94 | expect(out).toHaveLength(1); | |
| 95 | expect(out[0]).toContain('rule "pipeline first"'); | |
| 96 | 58 | expect(out[0]).toContain(path); |
| 97 | 59 | } |
| 98 | expect(directionProblems([ch("A", "src/maintain/duties/x.ts")], ["Direction: owner asked for it on #13347, ahead of #6534"])).toEqual([]); | |
| 99 | expect(directionProblems([ch("M", "src/maintain/duties/x.ts")], [])).toEqual([]); | |
| 100 | expect(directionProblems([ch("A", "test/x.test.ts")], [])).toEqual([]); | |
| 101 | expect(directionProblems([ch("A", "src/core/migrations/0003-c.ts")], [])).toEqual([]); | |
| 60 | // A pipeline change no longer waives it. | |
| 61 | expect(directionProblems([ch("A", "src/core/x.ts"), ch("M", "scripts/gate.ts")], [])).toHaveLength(1); | |
| 102 | 62 | }); |
| 103 | 63 | |
| 104 | test("a Direction line that names no pipeline item it goes ahead of is refused by name (#15415)", () => { | |
| 105 | const out = directionProblems([page], ["Direction: a small door onto the spawn path (#7642)"]); | |
| 106 | expect(out).toHaveLength(1); | |
| 107 | expect(out[0]).toContain('rule "name what it goes ahead of"'); | |
| 108 | expect(out[0]).toContain("#6534"); | |
| 109 | expect(directionProblems([page], ["Direction: a small door onto the spawn path (#7642), ahead of #1073"])).toEqual([]); | |
| 64 | test("issuesNamed lists each number once", () => { | |
| 65 | expect(issuesNamed(["Fix #12 and #13", "also #12"])).toEqual([12, 13]); | |
| 110 | 66 | }); |
new above
offline