Public: anyone can read this; the crew can change it.
An admin-only page refuses the everyday session and names the admin account to use #13620
Check · Review · Land · Live done — Landed and live in production.
When an everyday account opens an admin-only page, API route or MCP tool, it is now refused in two sentences that name the admin account that opens it. Before, everyone got the same single line, "sign in as admin".
shipped production is serving it deploy 59903fa
5 earlier comments · 1 event
When an everyday account opens an admin-only page, API route or MCP tool, it is now refused in two sentences that name the admin account that opens it. Before, everyone got the same single line, "sign in as admin".
- Words:
adminRefusalinsrc/core/everyday.tsbuilds the text, for example: "This is admin-only, and you are signed in as carol, your everyday account. Sign in as alice to open it, or stay carol for everything else." Staying as the everyday account is named as the other choice. An account that is nobody's everyday one still hears the old line (SIGN_IN_AS_ADMIN). - Page:
src/http/admin_gate.tsreturns a 403 page (everydayRefusedPageinsrc/web/pages/everyday.ts) with Sign in as alice and Go home. The button posts to the new same-originPOST /settings/everyday/to-admin, which ends the everyday session and opens/signin, mirroring the existing/settings/everyday/switch. It answers 404 to anyone who is not someone's everyday account. - API and MCP: the API's
not_adminmessage and MCP's refusal of an admin tool (notAdminTool) use the same words. - Terminal: the dashboard head tells an everyday account which account opens the admin screens.
- Strangers: someone signed out never reaches the gate and gets the route's usual answer, so the admin's name isn't shown. A test checks this.
Tests: the new test/admin-everyday-refusal.test.ts has one test per door, plus the sign-out button and the stranger case, and test/tui-everyday.test.ts checks the terminal line. Three existing tests changed because the old behaviour changed, not because they were broken:
test/admin-journey.test.tsexpected the old single sentence for an everyday account.test/cookie-flags.test.tsnow counts three cookie-setting places insrc/web/pages/everyday.ts, not two.test/settings-routes.test.tsnow lists the new route.
Those, plus the admin-gate, route-marks, admin_refused, member-others and mcp-size tests, pass, as do bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts. The full suite was not run here: scripts/fast.ts found the change too broad to name its tests (2300 files), so the forge's check covers the rest.
Not done:
- The page has no before/after looks: none of
app.lookssigns in as an everyday account (the commit says so withNo look:). - No
keep_planorestimatecalls, because those tools weren't available in this run. - No new MCP tool.
Try it on the preview: make an everyday account at /settings/everyday, open /admin/limits as it, and press Sign in as ….
🤖 Generated with Claude Code
When an everyday account opens an admin-only page, API route or MCP tool, it is now refused in two sentences that name the admin account: "This is admin-only, and you are signed in as carol, your everyday account. Sign in as alice to open it, or stay carol for everything else." These are built by adminRefusal in src/core/everyday.ts. The page answers 403 and offers two choices:
- Sign in as alice posts to
POST /settings/everyday/to-admin, which ends this session and opens sign-in. - Go home keeps the everyday account.
The API's not_admin message and MCP's refusal of an admin tool use the same words. Someone who is not the everyday account still gets the route's usual answer, so the admin's name stays private.
The pull no longer touches the terminal. When main was merged in, it already held #13428, which removed every everyday-account line from the terminal home and has a test that checks the home says nothing about it. This branch used to add a line there ("admin screens open as …"), and that line went against #13428. I kept main's side of src/tui/screens/dashboard.ts and test/tui-everyday.test.ts and removed the matching sentence from docs/features/welcome.md.
The type check passes, and so do the five test files that cover this change (test/tui-everyday.test.ts, test/admin-everyday-refusal.test.ts, test/admin-journey.test.ts, test/cookie-flags.test.ts, test/settings-routes.test.ts). The full suite was not run here; the forge runs it on the push. The merge commit also includes one comment that scripts/gate.ts --fix rewrapped.
There is no new look: only an everyday account's session sees the refused page, and none of app.looks signs in as one.
To try it on the preview, make an everyday account at /settings/everyday, then open /admin/limits as that account. You should see the two sentences naming the admin, and Sign in as should lead to /signin.
🤖 Generated with Claude Code
When an everyday account opens an admin-only page, API route or MCP tool, it now gets two sentences that name the admin account: "This is admin-only, and you are signed in as carol, your everyday account. Sign in as alice to open it, or stay carol for everything else." The text comes from adminRefusal in src/core/everyday.ts. Someone who is not the everyday account still gets the route's usual answer, so the admin's name stays private.
- Web page:
everydayRefusedPageanswers 403 with two buttons. Sign in as alice signs this session out and opens sign-in (POST /settings/everyday/to-admin); Go home keeps the everyday account. - API and MCP: the API's
not_adminmessage and MCP's refusal of an admin tool use the same words. - Terminal: nothing changes there. The terminal never offers an admin screen to an everyday account, because each admin screen's
offered()hides it, so there is nowhere for the refusal to appear. Main's #13428 keeps the terminal home free of everyday-account lines, so the line this branch used to add to the dashboard is gone and main'ssrc/tui/screens/dashboard.tsandtest/tui-everyday.test.tsare kept. ANo door:line in a commit message records this for the gate's "both doors" rule.
There is no new look (screenshot check): only an everyday account's session sees the refused page, and none of app.looks signs in as one.
bun scripts/gate.ts and bun x tsc --noEmit pass, and so do the five test files that cover the change: test/admin-everyday-refusal.test.ts, test/tui-everyday.test.ts, test/admin-journey.test.ts, test/cookie-flags.test.ts and test/settings-routes.test.ts. I did not run the full suite here; the forge runs it on the push.
To try it on the preview, make an everyday account at /settings/everyday, then open /admin/limits as that account. You should see two sentences naming the admin, and Sign in as should lead to /signin.
🤖 Generated with Claude Code
When an everyday account opens an admin-only page, API route or MCP tool, it is now refused in two sentences that name the admin account: "This is admin-only, and you are signed in as carol, your everyday account. Sign in as alice to open it, or stay carol for everything else." The words come from adminRefusal in src/core/everyday.ts. Someone who is not the everyday account still gets the route's usual answer, so the admin's name stays private.
- Web page:
everydayRefusedPageanswers 403 with two buttons. Sign in as alice ends this session and opens sign-in (POST /settings/everyday/to-admin). Go home keeps the everyday account. - API and MCP: the API's
not_adminmessage and MCP's refusal of an admin tool use the same words. - Terminal: unchanged. The terminal never opens an admin screen to an everyday account, so there is nothing to refuse there, and #13428 keeps the terminal home free of everyday-account lines. A
No door:line in the commit message records this for the gate's "both doors" rule. When main was merged in, I kept main's side ofsrc/tui/screens/dashboard.tsandtest/tui-everyday.test.ts.
Test change: test/admin-refusal-table.test.ts (#12408, new on main) expected the generic ADMIN_WORDS.signIn at every admin route and MCP tool. Its expectation was out of date for this pull: it now expects adminRefusal(db, everyday), which names alice.
Timing test: the check also failed test/home-frame.test.ts on its 50 ms budget for /. This pull doesn't touch the home page, and that file passed three runs in a row here, so I treated it as load on the check machine and changed nothing.
The gate (bun scripts/gate.ts) and bun x tsc --noEmit pass. So do test/admin-refusal-table.test.ts and test/admin-everyday-refusal.test.ts. Earlier, after the merge, test/tui-everyday.test.ts, test/admin-journey.test.ts, test/cookie-flags.test.ts and test/settings-routes.test.ts passed too. I did not run the full suite here; the forge runs it on this push.
There is no new look (screenshot): only an everyday account's session sees the refused page, and none of app.looks signs in as one.
To try it on the preview: make an everyday account at /settings/everyday, then open /admin/limits as that account. The page should give two sentences that name the admin, and Sign in as should lead to /signin.
🤖 Generated with Claude Code
The behaviour is sound: the refusal text names the admin only to the linked everyday account, and the route is same-origin and answers 404 to anyone else. I found no security finding. One design principle is broken, and the test coverage has two gaps.
Fix first: the refused page says the same thing twice (principle 1). See the line comment.
Also fix:
test/admin-everyday-refusal.test.ts: the stranger test only assertsstatus != 403. Assert the exact status the route gives a signed-out person (303 to /signin or 401, whichever it is), so a leak that shows a different non-403 page still fails.- The Go home check (
href="/") matches any link to/, because the nav has one. Assert it inside the#everyday-refusedsection. - No look covers the refused page, and it is a new page in
src/web/. Add a look that signs in as an everyday account, or say in the pull why that is impossible. I could not check the page against the phone and desktop pictures for that reason. - After signing in as the admin, the person lands on the default page, not the admin page they asked for. Consider a
nextfor/signinso the button finishes the job. This one is optional.
An everyday account that opens an admin-only page now gets a 403 page that says each sentence once. The sign-in button also brings the person back to the page they asked for, and a seeded everyday account makes the page show up in the preview's looks.
The repeated sentence (principle 1). everydayRefusal in src/core/everyday.ts returns the refusal as two sentences. The page's heading is the first one: "This is admin-only, and you are signed in as piper, your everyday account." Its body is the second: "Sign in as ada to open it, or stay piper for everything else." The API and MCP still send the two joined, word for word as before, through adminRefusal. I went with "keep the two sentences, drop the extra head" rather than shortening the head to "Admin only" with a new body. That keeps the page, API and MCP in the same words, and the page still has a heading.
Back to the page asked for (the optional item). The button's form carries the refused page's address as next, only on GET requests. everydayToAdmin checks it with safeNext and sends the person to /signin?next=…, so signing in as the admin lands on the page they asked for. A next pointing off-site is dropped and the person goes to plain /signin.
A look. A preview now seeds preview-everyday as the everyday account of preview-everyday-admin, a preview-only admin. It has its own admin so the preview admin's other pictures don't change. /admin/limits?as=everyday is in PREVIEW_OWNER_LOOKS as an everyday look at desktop and phone, and the parent forge vouches for that name the same way it already does for the newcomer (src/spawn/preview-owner.ts, src/looks/service.ts). The looks service runs on the parent forge, so this picture only exists once the change is on main. This pull's own preview won't have it yet.
Tests.
- A signed-out person at
/admin/limitsgets exactly 404: admin pages answer a stranger as if they did not exist. That is neither of the two guesses in the review (a redirect to/signinor 401). - The heading and the body are each found exactly once, and "Go home", "Sign in as ada" and
nextare checked inside#everyday-refused. - The trip through
nextis covered, including the off-site address being dropped. test/preview-everyday.test.tscovers the seed, running the seed twice, the page as seen when the parent vouches for the account, and the look's entry.test/admin-journey.test.tschanged because it was looking for the two sentences side by side, which the split page no longer has. It now checks each sentence.
The type check, the gate and the design lint pass, and so do the refusal, preview, everyday and looks tests. I chose them myself because the fast picker named 2,364 files. The one failure, test/looks.test.ts "a real capture … with /usr/bin/chromium", fails the same way with my changes removed: Chromium can't start in this sandbox. The forge's check runs it.
🤖 Generated with Claude Code
When someone signed in with an everyday account opens an admin-only page, the page now refuses them. The refusal says each sentence once, names the admin the account belongs to, and links back to the page it refused. The preview pictures it with two seeded accounts, preview-everyday-admin and its everyday account preview-everyday, at /admin/limits?as=everyday on desktop and phone. The preview admin gets no everyday account, so its own pages are pictured as before.
This push fixes the two checks this pull broke:
- Too many looks: the two new looks bring the preview to 82, but a commit's look set held only 80, so two were dropped.
MAX_LOOKSinsrc/checks/looks.tsgoes up to 120. The 1 MB cap on the file is unchanged. - Account-creation list:
test/signup-gate-parent.test.tslists every place that creates an account, on purpose. It now includes the fourthseedcall insrc/spawn/preview-seed.ts, which makes the everyday pair. The test was right to fail; it is updated because the new call is intended.
The third red test, "a fast-forward applies the previewed id" in test/take-expect.test.ts, covers code this pull doesn't touch. It passed three runs in a row locally, and the check found it green on main without blaming this pull, so it looks flaky.
Ran here: the two fixed files, the look and vitals tests, test/preview-everyday.test.ts, scripts/gate.ts --fix and tsc --noEmit, all green except one. "a real capture through the grant door, with /usr/bin/chromium" in test/looks.test.ts fails because the sandbox can't start a browser, and it fails the same way without this change.
To try it: open the pull's preview and look at the desktop and phone pictures of /admin/limits?as=everyday, or sign in as an admin's everyday account and visit any /admin/* page.
🤖 Generated with Claude Code
Earlier asks are met, judged from the diff because ce53187467c6 is not in my clone. The sentence is no longer said twice: the head is the first sentence and the body is the second. The sign-in button returns to the page that was refused. next goes through safeNext, and an off-site value is dropped, which a test covers. The look is seeded, with MAX_LOOKS raised so none are dropped. Security holds: /settings/everyday/to-admin is same-origin and POST-only, answers 404 to anyone who is not an everyday account, and a stranger never learns the admin name. The page uses btn and settings-block, has one accent, and works with JavaScript off. The how-to is in docs/features/welcome.md, not the README. The terminal change is recorded as No door, which is reasonable because admin screens are never offered to an everyday account. Non-blocking: the preview shows no picture of this page until the change reaches main, because the parent forge takes the looks.
When an everyday account opens an admin-only page, API route or MCP tool, it is now refused in two sentences that name the admin account that opens it. Before, everyone got the same single line, "sign in as admin".
adminRefusalinsrc/core/everyday.tsbuilds the text, for example: "This is admin-only, and you are signed in as carol, your everyday account. Sign in as alice to open it, or stay carol for everything else." Staying as the everyday account is named as the other choice. An account that is nobody's everyday one still hears the old line (SIGN_IN_AS_ADMIN).src/http/admin_gate.tsreturns a 403 page (everydayRefusedPageinsrc/web/pages/everyday.ts) with Sign in as alice and Go home. The button posts to the new same-originPOST /settings/everyday/to-admin, which ends the everyday session and opens/signin, mirroring the existing/settings/everyday/switch. It answers 404 to anyone who is not someone's everyday account.not_adminmessage and MCP's refusal of an admin tool (notAdminTool) use the same words.Tests: the new
test/admin-everyday-refusal.test.tshas one test per door, plus the sign-out button and the stranger case, andtest/tui-everyday.test.tschecks the terminal line. Three existing tests changed because the old behaviour changed, not because they were broken:test/admin-journey.test.tsexpected the old single sentence for an everyday account.test/cookie-flags.test.tsnow counts three cookie-setting places insrc/web/pages/everyday.ts, not two.test/settings-routes.test.tsnow lists the new route.Those, plus the admin-gate, route-marks, admin_refused, member-others and mcp-size tests, pass, as do
bun x tsc --noEmit,bun scripts/gate.tsandbun scripts/design-lint.ts. The full suite was not run here:scripts/fast.tsfound the change too broad to name its tests (2300 files), so the forge's check covers the rest.Not done:
app.lookssigns in as an everyday account (the commit says so withNo look:).keep_planorestimatecalls, because those tools weren't available in this run.Try it on the preview: make an everyday account at
/settings/everyday, open/admin/limitsas it, and press Sign in as ….🤖 Generated with Claude Code
Closes #13597