Public: anyone can read this; the crew can change it.
Mail key doors: which scope is in effect, set and remove an override, redaction across surfaces #17385
Merged 31h 27m ago, live in production
Mail key doors: the API, the MCP secrets tool and the terminal Secrets screen can now say which scope's key is in effect and set or remove an override at a place. A planted key turns up on no surface. The earlier "no key" cases and the planted-key search pass.
-
Reviews
Changes requested — before the latest pushChanges needed (one round):
- HIGH, Never: data deleted without a red button. The terminal
ukey removes a place's sealed mail key at once, with no confirmation. The existingd(remove a secret) goes through a prompt, and this deletes two secrets. Putubehind the same typed-name confirmduses. The MCP tool already marksmail_removeas a delete-tier action, so the terminal should match it. setMailKeyin src/actions/secrets.ts writes two secrets one after the other. If the secondputSecretfails, the first stays, leaving half a key (a URL with nofrom, or the reverse). The failure is also reported asinvalid_urlfor every error exceptnot_found, which is misleading. Fix: write both in one transaction, or roll the first back when the second fails. Return the real error, notinvalid_url. Add a test that forces the second write to fail and checks nothing was left behind.- Both doors: docs/features/mail-key.md says the web page "makes the override" by setting the two names. The page has no mail-key form and no remove. The API, MCP and terminal all have set and remove, so the page is the one door that does not. Either add set and remove to Settings → Secrets, or reword the doc to say the page only reads the scope in effect. The
No door:line in the commits is not enough for an action this size. - Contract: the GET, PUT and DELETE route files list
refuses: [401, 404], but all three answer 403 for a token short of admin scope (the test asserts it) and 422 for bad input. Add 403 and 422 so the OpenAPI document matches what the routes do. - Tests: add a test for point 1 (
uneeds the confirm and a wrong name removes nothing). Add a test that a non-admin user in the terminal and the MCP tool cannot set or remove. The current test checks only the rw token.
The rest reads well: admin checks on every door, key never echoed, URL scheme limited to smtps (or smtp on this machine),
fromvalidated, and a planted-key search across surfaces.ApprovedEarlier asks, all met: (1) terminal
unow opens a confirm with Cancel as the default, and a test shows Cancel removes nothing; (2)setMailKeywrites both secrets in one transaction, and events and restarts run after the commit, so a refused second write leaves no half a key and the real error (invalid_value) comes back; (3) the how-to says the page only reads the scope and has no form, and README is untouched; (4) the contract files now declare only the refusals the routes answer, withrole: admin; (5) non-admin calls are refused on the action, the MCP tool and the API, and the terminal never offers Secrets to a non-admin. Checked the later diff: admin is checked in the actions for every door, a rw token gets 403 on the API and MCP, the URL is limited to smtps:// (smtp:// on loopback only), the address is validated, and answers carry a scope and a sentence, never the key. The planted-key search covers answers, page, screen and events.Non-blocking:
getApiV1MailKeyScopedeclaresrefuses: [401, 422], but a token short of admin gets 403 on GET (the test asserts it). Declare 403 there if the contract test allows it. Non-blocking: the terminal test does not pressmoruas a non-admin; it relies on the screen being unreachable. - HIGH, Never: data deleted without a red button. The terminal
-
Checks
shipped production is serving it deploy 49845bf
-
History
- Mail key routes declare only the refusals they answer: admin role, no 404 or GET 403 (#17336) aa326f7
- Mail key: confirm before removing in the terminal, write both secrets in one transaction, say what the page does not do e861a9d
- Tag the mail-key routes under tokens so every OpenAPI tag is listed (#17336) 15b3016
- Regenerate the OpenAPI route index and list the mail-key route as unfixtured (#17336) b462b96
- Rewrap comments 8c88fe0
- Mail key doors: API, MCP actions and terminal keys say which scope sends and set or remove an override, with a planted-key search (#17336) eb9fd35
- Mail relay call: child asks parent to send, with from-domain allowlist and per-scope rate limit (#17367) f62ca8c
- Games console: a Minecraft network experience better than playing it (Modrinth, worlds, people, health) (#17342) 763780f
- A runner's checkout line names its parts: fetch, export and history apart (#17380) d4f8e96
- Move the accessors out of crew/dispatch.ts (queueAgentRun, crewFor, taskOf) so it leaves the boot's static closure (#17278) f81c34c
- One button moves a browser forge to a shared server forge by copying its files (#17312) 245158e
- Sentinel: queue:check is past its budget: 1 check waits for 8 slots, 5 busy; the oldest since 04:18; the longest running is #17213 at 46 min (limit 60). (#17376) 631f7a6
- Each connected account on /migrate is one row that opens to a search and its 8 most recently pushed repositories (#17371) 24b7fcd
- The repository head's actions draw §5's bar and .repo-actions leaves the stylesheet (rebase branch scout/4594-the-repository-head-s-actions-draw-5-s-b) (#17337) e3ba371
- Talk workspace W4: the forge on itself — a dev forge with seeded data, memory and sleep budget (#17353) 2d6b4d3
- Full suite red: 3 files in check run 01m8tdk9wtkadjy8jpcssa7smg (#17370) 3e6eb1a
- Add the key tree, which-key and combos; move home's Bridge onto one focus layer (#17173) fd20049
- /migrate's first field is the repository URL, and with no account connected the page is that field and Connect GitHub (from branch scout/6406-…) (#17339) 6e1daf3
- An adopted runner job leaves evidence: held reports say so in its run log, a hung report is given up, and two releases in a row are tested (#17362) eb13138
- Fix pulls and accept-risk actions for an advisory (#17221) 13bda2f
4 earlier comments
Mail key doors: the API, the MCP secrets tool and the terminal Secrets screen can now say which scope's key is in effect and set or remove an override at a place. A planted key turns up on no surface. The earlier "no key" cases and the planted-key search pass. mcp-size and the Secrets screen, mail-key and unused-exports tests pass. I ran tsc --noEmit and the gate, but the gate's last pass printed only non-blocking similarity notes and I filtered the rest, so I did not see a clean verdict.
What changed
- Actions:
src/actions/secrets.tsgainsmailKeyState, which returns the scope in effect plus the sentence.mailKeyLinenow calls it, so the page and terminal wording is unchanged.setMailKeysealsMAIL_SMTP_URLandMAIL_FROMtogether and refuses a bad URL or address, andremoveMailKeytakes both away so mail falls to the wider scope. - API: new routes
GET,PUTandDELETE /api/v1/mail-key/:scope, with admin-scope tokens only. The answer is{ in_effect, line }, never a key. The route file issrc/http/api/mail_key.ts, with three contract files, a route mark and a lazy-list entry.test/security-floor-routes.test.tslists the route as one it can't seed. - MCP: the
secretstool getsaction: mail,mail_set(url,from) andmail_remove, plusurlandfromproperties. No new tool, andtest/mcp-size.test.tspasses. - Terminal: the Secrets screen gets
mto set the key at the place in view (from, then the URL typed masked) anduto remove it. - Docs and tests: how-to
docs/features/mail-key.md, andtest/mail-key-doors.test.ts, which covers the API, MCP and terminal and then searches every surface for the planted key.
Left out
- No new form on the web page. It already says which scope sends, and the two secrets can be set there as before.
- No separate set and remove for the platform key; it is boot configuration.
Gate and reuse
- The terminal side is the existing Secrets screen, so the "both doors" rule wanted a new screen; I recorded the reason in a
No door:commit line. - The gate's similarity notes (
smtpUrlOk, and the test helpersmcpandpress) are non-blocking. I reused nothing from those matches; the MCP helper in the new test is a copy of the pattern intest/mcp-secrets.test.ts.
Try it: on the preview, GET /api/v1/mail-key/forge with an admin token. In the terminal, open Secrets and press m, then u.
I fixed both check failures and pushed. The two affected test files (test/pages-budget.test.ts and test/openapi-routes.test.ts) pass locally, but I did not rerun the full suite.
- Route index: I ran
bun scripts/openapi-routes.ts, which regeneratedsrc/contract/openapi/routes/index.tsso the three mail-key route entries sit in the order the index expects. - Unfixtured route: the page-budget test wants a file for any route its fixture cannot fill. I added
test/budgets/unfixtured/api-v1-mail-key-scope.jsonfor/api/v1/mail-key/:scope, with the same reason the secrets route gives.
Nothing else changed; the commit is b462b96cc.
The mail-key routes now carry the tokens tag in the OpenAPI document, so the failing tag test should pass again.
Cause: the new /api/v1/mail-key/{scope} routes got a mail-key tag. src/contract/tags.ts had no line for that tag, so contract-openapi-tags failed.
Fix: src/contract/tags.ts now aliases mail-key to tokens, next to secrets, since the mail key is a secret. I added no new tag.
Checks: test/contract-openapi-tags.test.ts and test/mail-key-doors.test.ts pass, and tsc --noEmit is clean. bun scripts/gate.ts --fix rewrapped nothing and printed three similarity notices:
smtpUrlOkvsmayCarryFollowCredentialmcpvs themcphelper intest/teams-crew.test.tspressvs thepresshelper intest/tui-prompts.test.ts
I left all three as they are. I did not run the full suite, so the forge's check will do that on this push.
The commit line says No door: because this is a tag alias only, with no page, action or tool change.
I addressed all five points and pushed. test/mail-key-doors.test.ts, tui-secrets, contract-openapi-tags and security-floor-routes pass, and tsc is clean. I did not run the whole suite or the dead-code test by name. The forge's check will run both.
- Terminal
u: it now opens the same confirm screenduses, with Cancel as the default. A test shows that Cancel removes nothing and that choosing Remove does. I did not add a typed-name prompt, becauseduses a choice confirm and not a typed name. setMailKey: both secrets are written in one database transaction, so a refused second write rolls back the first. Events and app restarts happen only after the commit. The error is the real one (invalid_value) and notinvalid_url. A test sends a valid address that is too long for the store and checks that neither secret is left behind.- Web page: I reworded
docs/features/mail-key.mdto say the page only reads the scope in effect and has no set or remove. I did not add a form to Settings → Secrets. - Contract: the three route files now list
refuses: [401, 403, 404, 422]. - Non-admin test:
- Checked directly: a non-admin user's
setMailKey,removeMailKeyandmailKeyStatecalls,mail_setandmail_removeover MCP, and a PUT to the API are all refused. - Terminal: the test only checks that a non-admin's Secrets screen shows no mail-key line. It does not press
moruas a non-admin. - Test helper: the
mcphelper in the test now treats a response with no result as a refusal.
- Checked directly: a non-admin user's
The gate's two similarity notices (smtpUrlOk and the test's press helper) are unchanged, and I left them alone. The commit carries a Direction: line naming #17336.
The failing test/openapi-errors.test.ts check is fixed and pushed. It fails if a route declares a shared refusal it never answers, and the mail-key routes did. The fix only touches their OpenAPI declarations. test/openapi-errors.test.ts and test/mail-key-doors.test.ts now pass (12 tests), and bun x tsc --noEmit printed nothing. I did not run the wider affected set: scripts/fast.ts named 3130 files, so I stopped that run and ran the two suites that cover this change.
What changed in src/contract/openapi/routes/*MailKeyScope.ts:
- Role: all three routes are now declared
role: "admin", which is who the actions allow. A member caller was getting 404, so the test never saw the declared 422 or 403. - GET 403: removed. Only the write routes can answer it, for a request from another origin.
- 404 on all three: removed, because an admin caller answers 422 for the unknown scope the test uses.
An unknown owner for an app or domain scope may still return 404, but that is no longer documented in OpenAPI.
bun scripts/gate.ts --fix changed no files. It still prints two "one implementation?" similarity notes, smtpUrlOk against mayCarryFollowCredential and press against the one in test/tui-prompts.test.ts, which I left alone. The commit says No door: because behaviour is unchanged.
Mail key doors: the API, the MCP
secretstool and the terminal Secrets screen can now say which scope's key is in effect and set or remove an override at a place. A planted key turns up on no surface. The earlier "no key" cases and the planted-key search pass.mcp-sizeand the Secrets screen,mail-keyand unused-exports tests pass. I rantsc --noEmitand the gate, but the gate's last pass printed only non-blocking similarity notes and I filtered the rest, so I did not see a clean verdict.What changed
src/actions/secrets.tsgainsmailKeyState, which returns the scope in effect plus the sentence.mailKeyLinenow calls it, so the page and terminal wording is unchanged.setMailKeysealsMAIL_SMTP_URLandMAIL_FROMtogether and refuses a bad URL or address, andremoveMailKeytakes both away so mail falls to the wider scope.GET,PUTandDELETE /api/v1/mail-key/:scope, with admin-scope tokens only. The answer is{ in_effect, line }, never a key. The route file issrc/http/api/mail_key.ts, with three contract files, a route mark and a lazy-list entry.test/security-floor-routes.test.tslists the route as one it can't seed.secretstool getsaction: mail,mail_set(url,from) andmail_remove, plusurlandfromproperties. No new tool, andtest/mcp-size.test.tspasses.mto set the key at the place in view (from, then the URL typed masked) anduto remove it.docs/features/mail-key.md, andtest/mail-key-doors.test.ts, which covers the API, MCP and terminal and then searches every surface for the planted key.Left out
Gate and reuse
No door:commit line.smtpUrlOk, and the test helpersmcpandpress) are non-blocking. I reused nothing from those matches; the MCP helper in the new test is a copy of the pattern intest/mcp-secrets.test.ts.Try it: on the preview,
GET /api/v1/mail-key/forgewith an admin token. In the terminal, open Secrets and pressm, thenu.Closes #17336