Public: anyone can read this; the crew can change it.
A new inline isAdmin check in a moved door fails the gate #18410
Merged 2h 12m ago, live in production
A new test, test/door-inline-checks.test.ts, now fails when a moved door gets a new inline access check. It reads the repository route modules under src/http/api/ and every MCP file (src/http/mcp.ts and all of src/http/mcp/, including tools/). The existing MCP gate rule only reads mcp.ts and shared.ts.
-
Reviews
ApprovedApproved. The ratchet reads src/http/api repository routes and all of src/http/mcp*, flags only gate-shaped isAdmin, rw-scope and signed-out lines, keys the list by file and exact text, and fails on gone entries. Each finding names file, line and helper. ROLES.md has the one paragraph. The two measuring-test fixes are small and keep their limits. I did not run the suite myself. Two things to do next: (1) move the three signed-out lines in src/http/api (issues, statement, cdn) to one list, since they sit in both DOOR_LINES and src/kernel/repo_route_checks.ts; (2) start retiring the NOT_ONLY_HERE admin-tool lines so the list shrinks, and extend the scan to pages once #18401 lands.
-
Checks
shipped production is serving it deploy 55693b7
-
History
- Rewrap pull-pipe comment for the gate (#18406) 5399c97
- Two measuring tests time and weigh what they test, not their own GC or the shard's garbage (#18406) de96fc1
- design-lint prints the moved doors' inline checks beside its ratchets (#18406) c289c1a
- Rewrap door_checks comments for the gate (#18406) 3db4cee
- A new inline isAdmin, rw-scope or signed-out check in a moved door fails a ratchet test (#18406) d0b117e
- A tab-forge read-only link can be revoked by the person who made it (#18402) bfd96cb
- Access 3, web pages: every page that gates on isAdmin or sign-in also asks may(), counted beside the old check (#18400) 8f27ed4
- A tab-forge app leaves as one spec file and comes back in, with or without its records (#18399) 081ac9e
- A person shares one imported session by a link that hides what the forge redacts (#18391) 080d52c
- Full suite red: test/data-browser.test.ts (#18394) b4310c7
- Red after landing: #18373 broke test/data-browser.test.ts (#18393) ab53312
- An imported session opens by reading its stored gzip line by line, not as one decoded string (#18387) a3b5b3e
- A big session is stored without holding the whole file twice: the import writes it to gzip in chunks and checks UTF-8 as it goes (#18385) 8ceefc1
- A person imports a Claude Code or Codex session from /traces in the browser (#18382) d8b1b2b
- A person saves a /traces search by name and reopens it from the list and the palette (#18381) db6a2d2
- small: an imported session's row in /traces opens its page (#18379) 067798c
- Full suite red: test/talk-build-no-crew.test.ts (#18380) fc3efe0
- /traces narrows by the tool a run used and the file it touched, on the page, the API and the terminal (#18373) ee241ef
- An imported session's steps carry their tokens and the page shows them, where the file holds them (#18372) 5739158
- An imported session opens at /traces/<id> as the same tree and time strip a crew run has (#18366) 90fb1bc
A new test, test/door-inline-checks.test.ts, now fails when a moved door gets a new inline access check. It reads the repository route modules under src/http/api/ and every MCP file (src/http/mcp.ts and all of src/http/mcp/, including tools/). The existing MCP gate rule only reads mcp.ts and shared.ts. The gate picks the test up like any other test/*.test.ts, so scripts/gate.ts is unchanged.
What it flags: only lines that gate access:
- a refusal on
isAdmin(!user.isAdmin,isAdmin !== true, orisAdminin anif) - a
scopeAllows(…, "rw")write floor - a signed-out test (
!ctx.auth.user, orctx.auth.user === undefinedin a condition)
Each finding gives the file, line and helper to use instead: adminPage or mayBeside(…, "forge.administer", …) for an admin, mayBeside(…, "forge.write", …) (mayToolWrite in the MCP) for a write, signedInPage for an account.
What it leaves alone: a role passed on for display (familyView(app, user.isAdmin === true)), comment lines, and scopeAllows(…, "admin"). That last one is how far a token reaches, not a role, as the existing MCP rule already says.
The list: DOOR_LINES in src/design/door_checks.ts holds the 29 lines that stay today, each with a one-phrase reason. Entries are keyed by file and exact line text, so they survive line shifts. Each entry allows one line only, so a copy of a listed line elsewhere in the same file counts as new. An entry whose line is gone fails too, so the list only shrinks. The fixture tests check that a new check of each kind fails with the right helper named, that a copied line fails, and that a gone entry is named for deletion.
Also changed:
scripts/design-lint.tsprints the same findings inscanRatchets, so a builder sees them before pushing. This also gives the new exports a caller, which the dead-code test requires.docs/ROLES.mdhas one new paragraph, "Inline checks in a moved door", that sets out the rule.
Reused: tsSources and Source from src/design/ratchets.ts, the DOOR_FIX wording pattern from RATCHET_FIX, and the signed-out regex from src/kernel/repo_route_checks.ts.
Not done:
- The existing gate rules in
src/kernel/repo_route_checks.tsandsrc/kernel/mcp_door_checks.tsare untouched; they still guardsrc/http/api.tsandsrc/http/mcp.ts+src/http/mcp/shared.tson each commit. - The three signed-out lines in
src/http/api/(issues.ts,statement.ts,cdn.ts) are now listed both there and inDOOR_LINES. - Pages are not scanned yet; they follow once #18401 lands.
- No inline check was removed.
Checks run: bun scripts/gate.ts, bun x tsc --noEmit, bun scripts/design-lint.ts, and these tests, all passing: door-inline-checks, unused-exports, dup-imports, module-state, mcp-size, check-list, design-lint-ratchets, mcp-tools-may, repo-routes-may, roles, contain, guest-contribute, and the docs tests. scripts/fast.ts named 4045 test files, too many to run here, so I picked these. The forge runs the full check on the push.
To try it: add if (!user.isAdmin) return bad("forbidden", "x"); to any file under src/http/mcp/tools/, then run bun test test/door-inline-checks.test.ts or bun scripts/design-lint.ts. Both name the file, the line and adminPage.
🤖 Generated with Claude Code
A new inline check in a door that has moved off it now fails a ratchet test. That covers an isAdmin check, a read-write scope check or a signed-out check. The test is in test/door-inline-checks.test.ts. The rules and the list of moved doors are in src/design/door_checks.ts, and docs/ROLES.md explains them. bun scripts/design-lint.ts prints each moved door's inline-check count beside its other ratchets.
This push also fixes two tests that failed on this pull's check. Neither touches this change; both failed because of how they measure:
test/trace-imported-open.test.ts: the 500 ms timer around the parse also counted the test's ownBun.gc(true)calls, one every 500 lines. It failed 2 runs out of 3 locally. The time spent in those calls is now subtracted, and the 500 ms limit is unchanged.test/pull-pipe.test.ts: the 200 MB test read the process's memory use with garbage from earlier test files in the shard still around. It now forces a garbage collection before the starting reading and before the final one. The 32 MB and 64 MB limits are unchanged.
Locally, both files passed 4 runs out of 4 after the fix, and the gate and bun x tsc --noEmit are clean. test/data-browser.test.ts is red on main at 24f4503 as well, so it is left alone here.
To try it: bun test test/door-inline-checks.test.ts test/pull-pipe.test.ts test/trace-imported-open.test.ts, then bun scripts/design-lint.ts.
🤖 Generated with Claude Code
A new test,
test/door-inline-checks.test.ts, now fails when a moved door gets a new inline access check. It reads the repository route modules undersrc/http/api/and every MCP file (src/http/mcp.tsand all ofsrc/http/mcp/, includingtools/). The existing MCP gate rule only readsmcp.tsandshared.ts. The gate picks the test up like any othertest/*.test.ts, soscripts/gate.tsis unchanged.What it flags: only lines that gate access:
isAdmin(!user.isAdmin,isAdmin !== true, orisAdminin anif)scopeAllows(…, "rw")write floor!ctx.auth.user, orctx.auth.user === undefinedin a condition)Each finding gives the file, line and helper to use instead:
adminPageormayBeside(…, "forge.administer", …)for an admin,mayBeside(…, "forge.write", …)(mayToolWritein the MCP) for a write,signedInPagefor an account.What it leaves alone: a role passed on for display (
familyView(app, user.isAdmin === true)), comment lines, andscopeAllows(…, "admin"). That last one is how far a token reaches, not a role, as the existing MCP rule already says.The list:
DOOR_LINESinsrc/design/door_checks.tsholds the 29 lines that stay today, each with a one-phrase reason. Entries are keyed by file and exact line text, so they survive line shifts. Each entry allows one line only, so a copy of a listed line elsewhere in the same file counts as new. An entry whose line is gone fails too, so the list only shrinks. The fixture tests check that a new check of each kind fails with the right helper named, that a copied line fails, and that a gone entry is named for deletion.Also changed:
scripts/design-lint.tsprints the same findings inscanRatchets, so a builder sees them before pushing. This also gives the new exports a caller, which the dead-code test requires.docs/ROLES.mdhas one new paragraph, "Inline checks in a moved door", that sets out the rule.Reused:
tsSourcesandSourcefromsrc/design/ratchets.ts, theDOOR_FIXwording pattern fromRATCHET_FIX, and the signed-out regex fromsrc/kernel/repo_route_checks.ts.Not done:
src/kernel/repo_route_checks.tsandsrc/kernel/mcp_door_checks.tsare untouched; they still guardsrc/http/api.tsandsrc/http/mcp.ts+src/http/mcp/shared.tson each commit.src/http/api/(issues.ts,statement.ts,cdn.ts) are now listed both there and inDOOR_LINES.Checks run:
bun scripts/gate.ts,bun x tsc --noEmit,bun scripts/design-lint.ts, and these tests, all passing: door-inline-checks, unused-exports, dup-imports, module-state, mcp-size, check-list, design-lint-ratchets, mcp-tools-may, repo-routes-may, roles, contain, guest-contribute, and the docs tests.scripts/fast.tsnamed 4045 test files, too many to run here, so I picked these. The forge runs the full check on the push.To try it: add
if (!user.isAdmin) return bad("forbidden", "x");to any file undersrc/http/mcp/tools/, then runbun test test/door-inline-checks.test.tsorbun scripts/design-lint.ts. Both name the file, the line andadminPage.🤖 Generated with Claude Code
Closes #18406