Public: anyone can read this; the crew can change it.
Access 3, web pages: every page that gates on isAdmin or sign-in also asks may(), counted beside the old check #18400
Merged 1h 24m ago, live in production
Web pages now ask may() in shadow next to their old sign-in and admin checks. The old check still decides, so nobody's access changes. This covers the two common gate shapes.
-
Reviews
Changes requested — before the latest pushSecurity review: no new access path and no leak. The old check still decides, the row names no account, token or repository, and the upsert is bounded. Changes needed:
- (Medium, fix first) Every GET page asks
forge.write. A read-only token can read these pages, butmaysaysforge.writeis rw-only. So each read-only-token page view records a falseweb <page>disagreement. The count is meant to show that moving the door changes nobody's access, and this noise buries any real disagreement. Pick the action by what the gate guards. Useforge.readfor GET pages. Useforge.writeonly for POST handlers that write. The new test builds on the wrong premise: it expects a row for anrotoken on a signed-in page, so it locks in the noise. Change it. - (Medium) Box 1 is not met. The pull says about 48 admin gates are untouched. Examples:
features.tsrequireAdmin,backupsDrill's inline isAdmin, and the?.isAdmingates. The follow-up issue #18401 is open, so these are left for later rather than ruled out. The box says each web page that gates is covered. - (Low)
domainsCardin backups.ts is a render helper, not a gate. It is called inside a page that has already passed the gate, so it counts the same disagreement twice per request. Revert it to the plainctx.auth.usercheck. - (Low) Both doors: the pull changes the web pages and adds no
src/tui/change. SayNo door: <why>in a commit line, or the gate will refuse it.
The may.md paragraph (box 4) and the single shared recorder (box 2) are fine.
ApprovedEarlier asks met: the read/write split in signedInPage (an ro token reading its own page is no parting), the admin gates of other shapes, and the quiet write for the count, which has a test that fails without it. The old check still decides everywhere and no access changes. Security: the rows name no account, token or repository.
Non-blocking: (1) an anonymous GET to any signed-in page now writes one sqlite row per hit (an upsert). It is bounded in rows but not in writes, so a crawler turns reads into writes. Consider a once-per-door-per-minute memory guard, or skipping the anonymous read parting once it has been seen. (2) Gates still unwrapped: maintenance_budgets.ts:44 (a POST that turns non-admins away), forge-template-setting.ts:21 and board.ts:430,647. Put them in #18401. (3) access_disagreement.ts: the quietly() body is mis-indented. may.md has an oddly wrapped line.
Box 1 is left only because of those few remaining gates.
- (Medium, fix first) Every GET page asks
-
Checks
shipped production is serving it deploy fea5438
-
History
- Disagreement counts are written quietly, so a shadowed page visit does not turn cached tags (#18395) 430b524
- Pages ask may() by what the request does, and every admin gate asks it (#18395) e897829
- One mayBeside for every door asked in shadow: the MCP write floor and the web pages share it (#18395) 353f27b
- Web pages ask may() in shadow beside their isAdmin and sign-in gates (#18395) a1c7272
- 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
- /traces lists Talk and imported traces with a kind facet, and the terminal's kind key is tested (#18365) c5e780a
- Issues: a route to assign an issue to a person or an agent (#18285) 69ce311
- The loopback-only look test stops failing checks: the missing prerequisite is named and provided, or the check skips by name (#18362) be7c1a3
- A Codex rollout file imports as a trace, beside Claude Code sessions (#18360) 8900ff3
3 earlier comments
Web pages now ask may() in shadow next to their old sign-in and admin checks. The old check still decides, so nobody's access changes. This covers the two common gate shapes. About 48 admin gates written other ways are not done yet: they are in follow-up issue #18401.
What changed
src/http/may_beside.ts: one function,mayBeside(ctx, door, action, old). It asksmayfor the request's credential and writes oneaccess_disagreementrow when the answer differs fromold, using the existingnoteDisagreement.mayToolWrite(src/http/mcp/tool_may.ts) now calls it too, so the MCP door and the web pages use the same code; the gate had flagged the two as near-duplicates.src/http/page_may.ts:adminPage(ctx, page, old)asksforge.administer.signedInPage(ctx, page)asksforge.write, which every account has and anonymous does not. It also narrowsctx.auth.userto defined for the code after it.- Both return the old answer, not
may's.
src/web/pages: in 77 pages, everyif (!ctx.auth.user) return …andif (!ctx.auth.user.isAdmin) return …now goes through these helpers. Each records under the doorweb <module>, e.g.web maintenanceorweb account. That names the page's file, not its URL path, because some URL paths contain repository names. No account, token or repository is recorded.docs/features/may.md: new paragraph, "The web pages ask it".
Not done, in #18401
- Admin gates of other shapes are untouched:
if (!user?.isAdmin),isAdmin !== true || kind === "agent",isAdminPerson, and the gates ineveryday.ts. Wrapping them the same mechanical way would break TypeScript's narrowing, so each needs a hand edit. - No inline check was deleted, as the issue asked.
Tests
test/web-pages-may.test.ts, one case per kind of page:- Admin-only: the admin's session agrees and writes no row. The admin's
rotoken parts onforge.administerand writes one row, but is still let in. - Signed-in: a session and an
rwtoken agree. Anrotoken parts onforge.writeand writes one row. - Anonymous: both answers turn it away, with no row. An old gate deliberately set to let it in writes one row.
- Admin-only: the admin's session agrees and writes no row. The admin's
bun x tsc --noEmit,bun scripts/gate.ts --explain(0 fail),bun scripts/design-lint.ts, and 61 test files pass (383 tests, 0 fail). Those files includemcp-size,mcp-tools-may,repo-routes-may,unused-exports,dup-imports,doorless,page-budget*,route-marks*, and the account, people, backups and maintenance pages.scripts/fast.tsnamed 2,943 files for this diff, too many to run here; the forge runs the full check on push.
Try it: on the preview, open /maintenance as the admin and /account signed in. Both answer as before, and SELECT * FROM access_disagreement WHERE door LIKE 'web %' stays empty for a browser session.
[{"go":"/maintenance","look":"the page as the admin","expect":"renders as before"},{"go":"/account","look":"signed out","expect":"sends you to sign in, as before"}]
🤖 Generated with Claude Code
Web pages now ask may() in shadow beside every check they gate on, whether that check is isAdmin or sign-in. The old check still decides, so nobody's access changes. Where the two answers differ, one row is counted in access_disagreement under web <page>. The row records the action and the kind of principal (session, ro token, anonymous and so on). It names no account, token or repository.
The sign-in check asks by what the request does (src/http/page_may.ts). GET and HEAD ask forge.read, and writes ask forge.write. An ro token reading its own page is no longer counted, and an ro token that posts still is. The test that expected a row for an ro read is now two tests, one for reads and one for writes.
Disagreement: an anonymous GET to a page that needs sign-in now records a difference on forge.read, because may lets anyone read and the page lets in only accounts. That difference is real: it shows forge.read is too wide for these pages. It costs one bounded row per page. I count it instead of skipping anonymous visitors. No current action means "any account, any token scope". Adding one changes the can lists in the API and the terminal, so it belongs in its own change.
The admin checks the first pass missed now ask forge.administer. These include:
features,subscriptionsandpacks-settings(each through itsrequireAdmin)backupsDrill,backupsLive,forges,forge_machine,forge_upgradeandforge_move_inbilling,admin-limits,boards*,flows-all,packs,visitors,economics,flow,teams,data,runners,telemetry,trusted,advisories,org,app_templates,crew-settings,connectionsandclient_cloud- the studio pages:
home,home_archive,keeper_row,crew_key,crew_budgetsandcrew_fallback settings/devices,settings/plansandrequests_card
Where the user may be missing, the check tests for undefined first. may also refuses an anonymous visitor forge.administer, so no row is lost.
Deliberately left as they were:
everydayToAdmin: it checks another account (adminOf(daily)), not the person asking.repo.tsisAdmin(ctx, repo): a repository's admin, which the repo routes already cover.- Checks that only change what a page shows (the admin links in
changelog,pricing,accountand so on): they turn nobody away.
Smaller fixes:
domainsCardinbackups.tsis back to the plainctx.auth.usercheck, with a test that it does not askmayagain.- The commit carries
No door:: this is shadow counting only, so the terminal has nothing new to show. docs/features/may.mdsays which action each kind of request asks.
Checks: tsc, design-lint, bun scripts/gate.ts --explain and test/web-pages-may.test.ts pass. --fix had nothing to commit. scripts/fast.ts named 3,002 files, too many to run, so I ran 265 files covering the touched pages, may, and the duplicate-import, dead-code and first-view-budget rules. Three tests failed there:
test/attention-stamped.test.ts(the first-view budget for/changelog): failed under load and passed when run alone.- The data-browser masking test: it was already red on main (#18393/#18394).
- The 200 MB child-process memory test: it is not touched by this change.
[{"go":"/settings/features","look":"the page as the admin","expect":"renders as before; no access change"},
{"go":"/settings/backups","look":"the failure-domains card","expect":"shown as before for a signed-in admin"}]
🤖 Generated with Claude Code
Web pages now check may() in shadow next to their old gates (#18395). Admin-only pages ask forge.administer. Pages that need an account ask by what the request does: a read (GET or HEAD) asks forge.read, anything else asks forge.write. The old gate still makes the decision. When may() gives a different answer, http/page_may.ts adds one row to access_disagreement under the door web <page>. The MCP write floor and the web pages share one helper for this (http/may_beside.ts). Nobody's access changes.
The last commit fixes the red check. Writing a disagreement row moved the forge's write clock (core/write_clock.ts), and the /explore.json etag is built from that clock. A GET to a gated page could therefore land between another page's GET and HEAD and change its etag. That is what the HEAD sweep caught. noteDisagreement now writes its count with quietly, the same way other usage counts are written, so it no longer moves the clock. A new test in test/web-pages-may.test.ts checks that counting a disagreement leaves the clock unchanged; it fails without the fix.
Worth a look:
src/core/access_disagreement.ts: the quiet write.src/http/page_may.ts: the read/write split for pages that need an account.
Checked locally: the type check and the gate pass. test/head-options-sweep.test.ts, test/web-pages-may.test.ts and the tests that use the write clock or the disagreement table pass (87 tests). The full suite reaches about 3,000 files, which is too broad to run here, so it is left to the forge's check.
[{"go":"/maintenance","look":"the page as the admin","expect":"it renders as before; a non-admin is still turned away"},
{"go":"/explore.json","look":"the ETag header on GET and on HEAD","expect":"the same tag, even after visiting a signed-in page while signed out in between"}]
🤖 Generated with Claude Code
Left #18395 open: 1 unticked item remain (Each web page whose handler checks isAdmin, scopeAllows or !ctx.auth.user also computes may(principal, action, resource) and, where the two answers part, records one access_disagreement row (door web <route>, action, principal kind; no account, token or repository named). The old check still decides; no person's access changes.).
Web pages now ask
may()in shadow next to their old sign-in and admin checks. The old check still decides, so nobody's access changes. This covers the two common gate shapes. About 48 admin gates written other ways are not done yet: they are in follow-up issue #18401.What changed
src/http/may_beside.ts: one function,mayBeside(ctx, door, action, old). It asksmayfor the request's credential and writes oneaccess_disagreementrow when the answer differs fromold, using the existingnoteDisagreement.mayToolWrite(src/http/mcp/tool_may.ts) now calls it too, so the MCP door and the web pages use the same code; the gate had flagged the two as near-duplicates.src/http/page_may.ts:adminPage(ctx, page, old)asksforge.administer.signedInPage(ctx, page)asksforge.write, which every account has and anonymous does not. It also narrowsctx.auth.userto defined for the code after it.may's.src/web/pages: in 77 pages, everyif (!ctx.auth.user) return …andif (!ctx.auth.user.isAdmin) return …now goes through these helpers. Each records under the doorweb <module>, e.g.web maintenanceorweb account. That names the page's file, not its URL path, because some URL paths contain repository names. No account, token or repository is recorded.docs/features/may.md: new paragraph, "The web pages ask it".Not done, in #18401
if (!user?.isAdmin),isAdmin !== true || kind === "agent",isAdminPerson, and the gates ineveryday.ts. Wrapping them the same mechanical way would break TypeScript's narrowing, so each needs a hand edit.Tests
test/web-pages-may.test.ts, one case per kind of page:rotoken parts onforge.administerand writes one row, but is still let in.rwtoken agree. Anrotoken parts onforge.writeand writes one row.bun x tsc --noEmit,bun scripts/gate.ts --explain(0 fail),bun scripts/design-lint.ts, and 61 test files pass (383 tests, 0 fail). Those files includemcp-size,mcp-tools-may,repo-routes-may,unused-exports,dup-imports,doorless,page-budget*,route-marks*, and the account, people, backups and maintenance pages.scripts/fast.tsnamed 2,943 files for this diff, too many to run here; the forge runs the full check on push.Try it: on the preview, open
/maintenanceas the admin and/accountsigned in. Both answer as before, andSELECT * FROM access_disagreement WHERE door LIKE 'web %'stays empty for a browser session.🤖 Generated with Claude Code
Closes #18395