Public: anyone can read this; the crew can change it.
Automate a review finding as a lint or test: Both doors: nothing in src/tui/ for the archive or for sending a patch. Add a sc #14371
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/14320-automate-a-review-finding-as-a-lint-or-t → main 2 commits fork
3 files
changed +26
−3
AGENTS.md +1 −1
| @@ -5,9 +5,9 @@ Read `CLAUDE.md` first: it is the rulebook for agents editing this repo. | ||
| 5 | 5 | Read the guide first, in this order: `docs/guide-what-a-forge-is.md`, `docs/guide-first-app.md`, `docs/guide-tell-the-crew.md`, `docs/guide-ship-and-undo.md`, `docs/guide-your-apps.md`, `docs/guide-hosting.md`, `docs/guide-own-ai.md`, `docs/guide-agents.md`, `docs/guide-backups-moving.md`, `docs/guide-settings.md`, `docs/guide-when-wrong.md`. That is the spine (ordered in `src/view/guide.ts`, served at `/docs` with search, listed first by /llms.txt): eleven pages, each at most 300 words and 60 lines, every command, path and link in them checked by `test/guide.test.ts`. A feature's `docs/features/<name>.md` is its reference; open it with front matter `topic:` and `row:` (#14248), which builds its row in `docs/features/README.md`, the index every spine page links; never edit that list by hand (`test/feature-orphans.test.ts`). |
| 6 | 6 | |
| 7 | 7 | README.md is capped: a new feature's how-to goes in `docs/features/<name>.md`, not a new README section. |
| 8 | 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). | |
| 8 | 9 | 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. |
| 9 | 10 | |
| 10 | 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); `bun scripts/gate.ts` refuses it otherwise ("both doors", #10628). | |
| 11 | 11 | A pull that changes `src/web/` (a `.ts` or `.css`) names, in a commit line `Looks: <path>`, the page of `app.looks` in forge.json whose before/after pictures show it, or says `No look: <why>`; `bun scripts/gate.ts` refuses it otherwise ("before/after looks", #12362). |
| 12 | 12 | An update pull (upstream's main merged into a fork, #13751) is a merge commit named `Take updates from <upstream>` whose second parent is upstream's main: the tip or an ancestor of `FORGE_CHECK_UPSTREAM`, `origin/upstream-main` or `upstream/main`. The name alone is not trusted; when the second parent cannot be verified the pull is judged whole. A verified update is judged by its first side (`HEAD^1`, the fork's own work) for the Try line, both doors, pipeline-first, the added-lines rules, the README cap and the dependency rule; the tests still run whole. |
| 13 | 13 |
src/kernel/both_doors.ts +9 −2
| @@ -36,12 +36,19 @@ | ||
| 36 | 36 | * `src/actions/*.ts`. Such an edit is a door too: it changes something under `src/tui/` (the |
| 37 | 37 | * how-to is not asked), and a new feature module wired into it is asked for the screen and the |
| 38 | 38 | * how-to, or `No door:` says why. |
| 39 | * | |
| 40 | * Four more (#14320: #11849, #11901, #12566, #12953) found two walks: a route module wired | |
| 41 | * only into `src/http/server.ts` (the archive, #11849), which no edited-API path marked, and a | |
| 42 | * new tool or route file under `src/http/api/` or `src/http/mcp/tools/`. The first now counts | |
| 43 | * as wiring (a bare edit to server.ts still asks nothing); the second is a surface like an | |
| 44 | * action, asked for the screen. | |
| 39 | 45 | */ |
| 40 | 46 | |
| 41 | 47 | import type { Change } from "./pin_edits.ts"; |
| 42 | 48 | |
| 43 | 49 | const PAGE = /^src\/web\/pages\/[^/]+\.ts$/; |
| 44 | const SURFACE = /^src\/(web\/(render|studio)|actions)\/[^/]+\.ts$/; | |
| 50 | const SURFACE = /^src\/(web\/(render|studio)|actions|http\/api|http\/mcp\/tools)\/[^/]+\.ts$/; | |
| 51 | const ROUTE_WIRING = /^src\/http\/server\.ts$/; | |
| 45 | 52 | const EDITED_PAGE = PAGE; |
| 46 | 53 | const EDITED_API = /^src\/(http\/api\.ts|http\/api\/[^/]+\.ts|http\/mcp\/.+\.ts|actions\/[^/]+\.ts)$/; |
| 47 | 54 | const EDITED_WEB = /^src\/web\/(?!pages\/)(?:[^/]+\/)*[^/]+\.ts$/; |
| @@ -66,7 +73,7 @@ export function bothDoorsProblems( | ||
| 66 | 73 | ): string[] { |
| 67 | 74 | const pages = added(changes, PAGE); |
| 68 | 75 | const surfaces = added(changes, SURFACE); |
| 69 | const wired = changes.some((c) => c.status.startsWith("M") && (EDITED_PAGE.test(c.path) || EDITED_WEB.test(c.path) || EDITED_API.test(c.path))); | |
| 76 | const wired = changes.some((c) => c.status.startsWith("M") && (EDITED_PAGE.test(c.path) || EDITED_WEB.test(c.path) || EDITED_API.test(c.path) || ROUTE_WIRING.test(c.path))); | |
| 70 | 77 | const modules = wired && pages.length === 0 ? added(changes, FEATURE_MODULE) : []; |
| 71 | 78 | const featured = modules.length > 0; |
| 72 | 79 | const waived = messages.some((m) => WAIVER.test(m)); |
test/both-doors.test.ts +16
| @@ -112,3 +112,19 @@ test("a new module wired into an API route or MCP tool needs both doors (#14040) | ||
| 112 | 112 | ]); |
| 113 | 113 | expect(bothDoorsProblems([route, mod, ch("A", "src/tui/screens/t.ts"), ch("A", "docs/features/t.md")], [], () => true)).toEqual([]); |
| 114 | 114 | }); |
| 115 | ||
| 116 | test("a route module wired into server.ts, or a new api or mcp tool file, needs a terminal screen (#14320)", () => { | |
| 117 | const server = ch("M", "src/http/server.ts"); | |
| 118 | const mod = ch("A", "src/http/archive.ts"); | |
| 119 | expect(bothDoorsProblems([server, mod], [], () => true)).toEqual([ | |
| 120 | `rule "both doors": this pull adds src/http/archive.ts but no ${TUI} and no ${DOCS}${tail}`, | |
| 121 | ]); | |
| 122 | expect(bothDoorsProblems([server, mod, ch("A", "src/tui/screens/a.ts"), ch("A", "docs/features/a.md")], [], () => true)).toEqual([]); | |
| 123 | expect(bothDoorsProblems([server, mod], ["No door: a cache helper with nothing to show"], () => true)).toEqual([]); | |
| 124 | // a bare edit to server.ts asks nothing | |
| 125 | expect(bothDoorsProblems([server], [], () => true)).toEqual([]); | |
| 126 | for (const f of ["src/http/api/admin_asks.ts", "src/http/mcp/tools/send_patch.ts"]) { | |
| 127 | expect(bothDoorsProblems([ch("A", f)], [], () => true)).toEqual([`rule "both doors": this pull adds ${f} but no ${TUI}${tail}`]); | |
| 128 | expect(bothDoorsProblems([ch("A", f), ch("A", "src/tui/screens/s.ts")], [], () => true)).toEqual([]); | |
| 129 | } | |
| 130 | }); |
new above
offline