Public: anyone can read this; the crew can change it.
Access 3, infrastructure and clouds: the admin-only routes ask may() in shadow #18409
Merged 1h 6m ago, live in production
The infrastructure and cloud routes now check may() in shadow next to their existing admin check. The existing check still decides, so nobody's access changes. When the two answers differ, one row is written to accessdisagreement under infra .
-
Reviews
Changes requested — before the latest pushThe code change is right: the old answer still decides on every route, and the door names are per route. One fix is needed, in the tests.
- The last test in test/infra-routes-may.test.ts reads src/http/api/cloud.ts and src/http/infra_routes.ts as text and greps for strings. It would stay green if the call were dead code, so it proves no behaviour. The issue asks for a test per shape (admin, everyday person, agent token, anonymous) with a forced disagreement writing one row. For the cloud API, replace the grep with real requests through forgeHttp.
GET /api/v1/placeswith an adminrwtoken: 200 and no row.GET /api/v1/placeswith an agent token: 200 and no row.GET /api/v1/placeswith an adminrotoken: 200 and no row, because the refresh is skipped and may also says no.- If a disagreement can be forced on
infra places refreshorinfra cloud accounts(for example with a principal or scope that holds forge.administer differently from isAdmin), assert the single row under that door's name. If it cannot be forced through a request, testmayBesidewith those door names directly.
Drop the
not.toMatch(/!ctx\.auth\.user\??\.isAdmin\)/)assertion. It breaks on any reformatting and proves nothing. - Minor:
infraAdminwrapsmayBesideand throws its result away. CallmayBeside(ctx, ...)directly insideguardandinfraLive, as cloud.ts does, so the file has one way to ask.
No door and no feature doc are needed: nothing is shown to people.
ApprovedClean since my last round. guard() and infraLive now call mayBeside directly, the wrapper is gone, and the old admin answer still decides every response. The source-reading test is gone too, and the places and cloud doors are tested with real requests and a direct mayBeside call. No access changes. This only adds shadow asks, so there is no new door and no how-to to add.
Earlier asks: the single way to ask is met, and the removal of the source-text test is met.
Non-blocking: the infraLive check could reuse one local boolean instead of reading isAdmin twice.
- The last test in test/infra-routes-may.test.ts reads src/http/api/cloud.ts and src/http/infra_routes.ts as text and greps for strings. It would stay green if the call were dead code, so it proves no behaviour. The issue asks for a test per shape (admin, everyday person, agent token, anonymous) with a forced disagreement writing one row. For the cloud API, replace the grep with real requests through forgeHttp.
-
Checks
shipped production is serving it deploy 3d2fa7b
-
History
- Infra may shadow: real requests for the places catalog, a direct parting for the cloud doors; guard calls mayBeside itself 515fe11
- Rewrap comments (gate --fix) 2b77cb5
- Access 3, infrastructure and clouds: the admin-only routes ask may() in shadow (#18404) 36b0584
- 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
- /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 infrastructure and cloud routes now check may() in shadow next to their existing admin check. The existing check still decides, so nobody's access changes. When the two answers differ, one row is written to access_disagreement under infra <route>.
src/http/infra_routes.ts: the shared guard now takes the route's name:guard(ctx, "build"),"plan","apply","ending", … (13 routes). The/infra/livecheck goes through the same path, as doorinfra live. A small localinfraAdminpasses only the old boolean tomayBeside(ctx, "infra <route>", "forge.administer", old)and returns that old boolean. Anonymous visitors are still sent to sign in, and signed-in non-admins still get the not-found page.src/http/api/cloud.ts:GET /api/v1/cloud/accountsasks underinfra cloud accounts. The admin-only catalog refresh insideGET /api/v1/placesasks underinfra places refresh, using the old condition (admin and anrwtoken).test/infra-routes-may.test.tssends real requests throughforgeHttp. An admin, an everyday member, an agent's token and an anonymous visitor each get the same status as before, and none of them writes a row. The forced disagreement is an admin'srotoken on/infra/build: it still gets 200 and writes exactly one row (infra build,forge.administer,ro_token, may 0). That test fails without this change. A last test checks the source so the cloud doors can't slip back to a bare check.
Two things the test shows about the current behaviour:
/infra/*and/api/v1/cloud/accountsare marked admin inroute_marks, soadmin_gaterefuses an everyday account with 403 before these handlers run. The new check only ever sees admins, agents that get past the gate, and anonymous visitors.- The cloud routes can't produce a disagreement through a normal request: a token without
rwis refused before the admin check, and that matches whatmayrequires.
I reused mayBeside and added no grant table and no admin shortcut. The two commits carry a No door: line: nothing new is shown to people, so there is nothing to add to the terminal side or the how-to.
bun x tsc --noEmit, the gate (0 failing rules) and 22 related test files (infra, cloud accounts, places, admin gate, route marks, unused exports, duplicate imports, web pages) all pass, 235 tests in total. scripts/fast.ts named too many files to run, so I picked these myself. I did not keep a plan on the issue.
Try it on the preview: open /infra/build as the admin, then call it with the admin's ro token. It still returns 200, and one access_disagreement row appears under infra build.
🤖 Generated with Claude Code
The admin-only /infra routes and the two cloud API checks now also ask may() in shadow. The old admin check still decides every answer, and when may() disagrees, one row is written to access_disagreement under the route's own door name. Nobody's access changes.
src/http/infra_routes.ts:guard(ctx, route)callsmayBeside(ctx, "infra <route>", "forge.administer", old)itself. The old answer still decides: an anonymous visitor is sent to sign in, and a signed-in non-admin gets the not-found page.infraLivecallsmayBesidedirectly too, so the file has one way to ask, and the earlierinfraAdminwrapper is gone.src/http/api/cloud.ts:GET /api/v1/cloud/accountsasks underinfra cloud accounts. The admin-only catalog refresh inGET /api/v1/placesasks underinfra places refresh, using the old condition (an admin with anrwtoken).test/infra-routes-may.test.tssends real requests throughforgeHttpand checks both the status and the rows written:- An admin, an everyday member, an agent's token and an anonymous visitor each get their previous answer, and none of them writes a row.
/api/v1/placesanswers 200 with no row for an admin'srwtoken, an admin'srotoken and an agent's token.- An admin's
rotoken on/infra/buildstill gets 200 and writes exactly one row (infra build,forge.administer,ro_token,may0). - No request can force a disagreement on the two cloud doors: they already require an
rwtoken, and that is allmay()adds to the admin check. Those two door names are tested by callingmayBesidedirectly, each writing one row. - The test that read the source files as text is gone.
Everyday members never reach these handlers: /infra/*, /api/v1/cloud/accounts and /api/v1/places count as admin pages for that gate (admin_gate), and it refuses them with 403 first. That was already the case before this change.
I reused mayBeside; nothing new is exported. The commits say No door: because nothing shown to people changes.
The type check, the gate (0 failing rules) and 6 related test files (49 tests) pass. They cover the new test, infra pages, the places and cloud-accounts APIs, unused exports and duplicate imports. I didn't run the full suite; the forge runs it on the push.
To try it on the preview: GET /api/v1/places with an admin's ro token returns 200 and writes no row. Opening /infra/build with that same token returns 200 and writes one row under infra build.
🤖 Generated with Claude Code
The infrastructure and cloud routes now check
may()in shadow next to their existing admin check. The existing check still decides, so nobody's access changes. When the two answers differ, one row is written toaccess_disagreementunderinfra <route>.src/http/infra_routes.ts: the shared guard now takes the route's name:guard(ctx, "build"),"plan","apply","ending", … (13 routes). The/infra/livecheck goes through the same path, as doorinfra live. A small localinfraAdminpasses only the old boolean tomayBeside(ctx, "infra <route>", "forge.administer", old)and returns that old boolean. Anonymous visitors are still sent to sign in, and signed-in non-admins still get the not-found page.src/http/api/cloud.ts:GET /api/v1/cloud/accountsasks underinfra cloud accounts. The admin-only catalog refresh insideGET /api/v1/placesasks underinfra places refresh, using the old condition (admin and anrwtoken).test/infra-routes-may.test.tssends real requests throughforgeHttp. An admin, an everyday member, an agent's token and an anonymous visitor each get the same status as before, and none of them writes a row. The forced disagreement is an admin'srotoken on/infra/build: it still gets 200 and writes exactly one row (infra build,forge.administer,ro_token, may 0). That test fails without this change. A last test checks the source so the cloud doors can't slip back to a bare check.Two things the test shows about the current behaviour:
/infra/*and/api/v1/cloud/accountsare marked admin inroute_marks, soadmin_gaterefuses an everyday account with 403 before these handlers run. The new check only ever sees admins, agents that get past the gate, and anonymous visitors.rwis refused before the admin check, and that matches whatmayrequires.I reused
mayBesideand added no grant table and no admin shortcut. The two commits carry aNo door:line: nothing new is shown to people, so there is nothing to add to the terminal side or the how-to.bun x tsc --noEmit, the gate (0 failing rules) and 22 related test files (infra, cloud accounts, places, admin gate, route marks, unused exports, duplicate imports, web pages) all pass, 235 tests in total.scripts/fast.tsnamed too many files to run, so I picked these myself. I did not keep a plan on the issue.Try it on the preview: open
/infra/buildas the admin, then call it with the admin'srotoken. It still returns 200, and oneaccess_disagreementrow appears underinfra build.🤖 Generated with Claude Code
Closes #18404