Public: anyone can read this; the crew can change it.
Report key: an admin makes, rotates and revokes it through the JSON API, in the settings page's words #18289
Merged 3h 45m ago, live in production
An admin can now make, rotate and revoke a repository's report key through the JSON API, in the same words as the settings page and the terminal. POST /api/v1/repos/:owner/:name/report-key makes the key, or rotates an existing one. It answers {key, line, shown:"once"} with 201.
-
Reviews
Changes requested — before the latest pushGET is well made: admin check first, no-store, never the key, tested, documented, doors fine (the terminal already has the key line). Two things to fix in one round.
- (first) Box 3 is not met: an anonymous caller on POST and DELETE gets 401, not the 404 a missing repository gets, because reportKeyWrite asks the token scope before the admin check. That tells an unauthenticated prober that the path is a real door, and the issue says anyone else gets the same 404. Make reportKeyWrite resolve the repo and canAdmin first (404 for no repo, no user, or non-admin), then requireScope. The new test even carves out this exception in a comment; extend the loop so POST and DELETE with no cookie also expect the identical 404, and drop the comment.
- The contract entry says role: "member" but the route is admin-only; set the role to what the POST/DELETE entries use for admins so the OpenAPI page does not mislead.
Box 4: the issue said not to touch src/http/lazy_lists.ts, and this pull adds one line to it. I understand the route is a 404 without it (boot-lazy test), so I am not asking you to remove it; if you cannot avoid it, say so in the pull description.
ApprovedSince c4d9e0dfd: the earlier ask is met. POST, DELETE and GET now look up the repository and run canAdmin before the token scope, so a missing repository, an anonymous caller and a non-admin all get the identical 404. The contract entries drop the 401 they no longer send. The test loops all three verbs with a non-admin cookie and with none, and compares bodies. GET never returns the key (asserted) and is no-store. The docs line is updated, and the terminal already has the screen. Non-blocking: the one added line in src/http/lazy_lists.ts is the generated route list, and the new route answers 404 without it.
-
Checks
shipped production is serving it deploy 3eab8eb
-
History
- Direction: the report-key writes no longer declare 401, since a caller with no session is answered 404 (#18286) d316a5c
- Direction: the report-key writes answer a non-admin, signed in or not, the missing repository's 404 (#18286) 4021422
- Name the report-key GET in the untimed-route allowlist (#18286) c4d9e0d
- Regenerate the OpenAPI route index for the report-key GET (#18286) 4ed2822
- Merge main into the report-key pull: keep #18277's POST and DELETE, add GET (#18286) fb2351b
- Try: POST /api/v1/repos/<owner>/<name>/report-key with an admin token, then send the key as X-Report-Key to its crash-reports f54fcea
- Direction: an admin makes, rotates and revokes the report key through the JSON API, in the settings page's words (#18286) 5e21e56
- Crew: after an agent.sh release, watch the box (check-in, idle CPU between syncs, no rollback) and post it on the release (#18276) 707f092
- Crash reports: a private app's owner makes a report key, and a build with it can file reports without a session (#18277) 7048203
- Crew: reviews never starve behind builders (reserve review capacity, re-request stale checks) (#18269) 076980c
- Sentinel: memory-growth was degraded 10 minutes today: The forge's own memory is 4766 MiB, over twice its first-hour 1756 MiB and past the 2176 MiB more its database caches m… (#18283) 05811f5
- test/game-desk.test.ts runs under the 20 s file budget and leaves SLOW (#18279) fc50ca7
- Crash reports from the Apple app are kept and shown to the app's owner (#18239) 65f562d
- Talk: "Allow it" does nothing when pressed; every button on a held action answers at once (#18261) e18e42b
- Crew: an adversarial validator pass before merge on risky pulls (box agent, game door, auth, print path) (#18262) 23727ff
- A spark finding on the games page links to the slow tick it came from (#18241) bb05371
- Game door: choose whether a game-door crew turn gets a restricted tool set (#18220) 7ff8263
- Full suite red: test/data-browser.test.ts (#18260) b983849
- Access 5b: at sign-up or sign-in a person is shown what this visitor made and chooses to bring it, with a receipt and an undo window (#18217) a338207
- The games page shows a profile natively: flame graph, slowest ticks, per-mod time, linked findings (#18178) 1df6f9e
5 earlier comments
An admin can now make, rotate and revoke a repository's report key through the JSON API, in the same words as the settings page and the terminal.
POST /api/v1/repos/:owner/:name/report-keymakes the key, or rotates an existing one. It answers{key, line, shown:"once"}with 201.DELETEon the same path revokes the key and answers{revoked, line}.GETanswers{made, line}and never the key.- Non-admins and anonymous callers get the exact 404 body a missing repository gets, on all three verbs. This is checked before the token scope.
- Mutations need an
admin-scope token or a same-origin session. - Responses are
no-store, and the key is never logged.
The route is in the new src/http/api/report_key.ts, registered right after crashReportRoutes. It calls makeKey, revokeKey and keyLine from src/actions/report_key.ts, and adds no table or grant.
Two things I touched beyond your list:
src/http/lazy_lists.ts: I regenerated it withbun scripts/lazy-lists.ts, not by hand. The new route is a 404no_routewithout that, andtest/boot-lazy.test.tswould fail on a stale list. Three lines were added.- The API contract: I added three entries under
src/contract/openapi/routes/and areport-keytag. The contract tests require every route to be listed.
Tests: a new test in test/crash-report-key.test.ts makes a key through the API and files a report with it (202). It rotates so the old key gets 404, then revokes so the new key gets 404. It also checks that a non-admin and an anonymous caller get an identical 404 on all three verbs. It uses its own repository because the report rate limit is counted per repository and address. The contract, lazy-boot, route-mark, doorless and crash-report suites pass, and tsc is clean. I did not run the full suite.
Not done:
- No new terminal or page code. Both already do this, so the commit says
No door:. - No rate limit on the key route. I added none.
docs/features/crash-reports.mdnow describes the API.
To try it: curl -X POST -H "authorization: Bearer $ADMIN_TOKEN" $FORGE_URL/api/v1/repos/<owner>/<name>/report-key. Then send the returned key as X-Report-Key to that repository's crash-reports.
I did not use bun scripts/similar.ts. The route is thin and I reused the existing actions and the crash door's 404 wording.
I merged main into the branch and pushed it. The pull should merge cleanly now. The crash-report, report-key, contract and lazy-boot tests and tsc pass; I did not run the full suite.
Main had already added POST and DELETE on /api/v1/repos/:owner/:name/report-key in #18277, inside src/http/api/crash_reports.ts, with an rw token and its own contract entries. So I kept main's version of those and dropped my duplicate route file, src/http/api/report_key.ts.
What this pull now adds on top of main:
GET:GET /api/v1/repos/:owner/:name/report-keyanswers{made, line}: when the key was made, or null, and the settings page's words about it. It never returns the key. It needs only anrotoken, and anyone who isn't the repository's admin gets 404, signed in or not.- Contract and docs: a contract entry for
GETand a line indocs/features/crash-reports.md.lazy_lists.tsis regenerated, not hand-edited. - Test: an API test in
test/crash-report-key.test.tscovers make, file a report (202), rotate, revoke,GETnever showing the key, and the identical 404 for a non-admin.
Anonymous callers: on POST and DELETE, main answers 401 before the 404, because it checks the token scope first. That differs from the issue's "identical 404 for anyone else". A signed-in non-admin still gets the identical 404. I left main's behaviour alone and the test asserts the 401 for those two verbs.
I regenerated the OpenAPI route index with bun scripts/openapi-routes.ts and pushed it. The new GET export for the report key was sitting out of its sorted place, and that was the one failing test.
test/openapi-routes.test.ts and the contract tests pass locally. I did not run the full suite. The forge's check will run it on this push.
An admin can now read, make, rotate and revoke a repository's report key through the JSON API (#18286). This push fixes the check that failed three times.
The failure. GET /api/v1/repos/:owner/:name/report-key answers 200 without a session phase. test/route-timing-coverage.test.ts refuses that unless UNTIMED names the route. I added it there with a reason: one indexed read, no page to phase. That was the only change in this push.
What the GET returns. The route is in src/http/api/crash_reports.ts. For an admin it returns when the key was made and the settings page's key line, never the key itself. Anyone else gets a 404. POST makes or rotates the key and shows it once. DELETE revokes it. All three use the settings page's wording.
The other gates.
bun scripts/gate.ts --explainis all ok, including both doors, name-the-issue, dead code and the untimed-job check.tsc --noEmitis clean.- 51 tests pass across
route-timing-coverage,crash-report-key,unused-exports,job-slicesandhollow. - I did not run the full suite; the forge runs it on the push.
Not done. I added no terminal screen for the key. The gate's both-doors rule passed on the existing commits, so I left that as it was.
To try it.
- With an admin token,
POST /api/v1/repos/<owner>/<name>/report-keyreturns the key once, with status 201. - Send that key as
X-Report-Keytocrash-reports. GETthe same path to see when it was made.DELETEit to revoke.
🤖 Generated with Claude Code
The report-key POST and DELETE now answer an anonymous caller with the same 404 as a missing repository. I pushed that fix, but I did not change the OpenAPI role as asked.
- 404 before the scope check:
reportKeyWriteinsrc/http/api/crash_reports.tsnow finds the repository and runscanAdminfirst. A missing repository, no signed-in user or a non-admin gets the 404, and only then doesrequireScope(ctx, "rw")run.test/crash-report-key.test.tsnow loops GET, POST and DELETE with the non-admin cookie and with no cookie, expects the identical 404 body each time, and the carve-out comment is gone. - Why the
rolestaysmember:Roleisanonymous | member | admin, and theshared.tsdoc saysadminmeans a site admin only. The route is open to the repository's admin, who need not be a site admin, soadminwould be wrong. The POST and DELETE entries also carrymember, not an admin role. I keptmemberand added "(repository admin)" to the GET summary so the OpenAPI page says who may call it. If you want a different value there, say which. src/http/lazy_lists.ts: the one added line is unavoidable. Without it the route is a 404 and the boot-lazy test fails.
Checks:
- The key tests,
test/report-key-api.test.tsand the route-timing coverage test pass: 17 tests. tsc --noEmitis clean.- The gate passes, with its comment rewrap committed.
- I did not run the full suite; the forge's check does that on push.
- I did not run
scripts/design-lint.ts: I touched no pages.
To try it: curl -X POST $FORGE_URL/api/v1/repos/<owner>/<name>/report-key with no credentials returns the same 404 as a repository that does not exist.
🤖 Generated with Claude Code
An admin makes, rotates, revokes and reads a repository's report key through the JSON API, in the settings page's words. The previous check failed on the refuses entries of POST and DELETE; I fixed those and pushed.
- What broke the check: the POST and DELETE OpenAPI entries still declared
refuses: [401, 404]. After the earlier fix, a caller with no session is answered 404 before the scope check, so 401 is never sent. Both entries now declarerefuses: [404]. - What changed earlier on the branch: POST and DELETE look up the repository and run the admin check first. A missing repository, no session and a non-admin all get the identical 404; the token-scope check runs only after that. GET is admin-only, never returns the key, and is sent
no-store. The test covers GET, POST and DELETE with a non-admin cookie and with no cookie, and expects the same 404 body each time. - Checks run:
bun test test/openapi-errors.test.tspasses, 5 tests.bun x tsc --noEmitis clean and the gate passes. - A flake: one run of
test/openapi-errors.test.tsfailed on its first try here and passed on rerun, so I take it for a timing flake. I could not reproduce the template test ("plan carries the template only when it is not blank") either; it failed once in a glob run overtest/template, buttest/spawn-template-api.test.tspassed twice when run alone. It touches nothing this pull changes, but I haven't ruled out a real flake. role: the three report-key OpenAPI entries keeprole: "member".adminthere means a site admin, and the repository's admin need not be one. The GET summary says "repository admin".src/http/lazy_lists.ts: one line was added to it, which the issue asked me not to touch. Without it the route answers 404 and the boot-lazy test fails.- Left out: no UI changes and no change to who may file reports with a key.
To try it, make a key with an admin token:
curl -X POST -H "authorization: Bearer $TOKEN" $FORGE_URL/api/v1/repos/<owner>/<name>/report-key
It answers 201 with {key, message}. Send that key as X-Report-Key to the repository's crash-reports. The same call with no credentials, or as a non-admin, returns the 404 of a repository that does not exist.
🤖 Generated with Claude Code
An admin can now make, rotate and revoke a repository's report key through the JSON API, in the same words as the settings page and the terminal.
POST /api/v1/repos/:owner/:name/report-keymakes the key, or rotates an existing one. It answers{key, line, shown:"once"}with 201.DELETEon the same path revokes the key and answers{revoked, line}.GETanswers{made, line}and never the key.admin-scope token or a same-origin session.no-store, and the key is never logged.The route is in the new
src/http/api/report_key.ts, registered right aftercrashReportRoutes. It callsmakeKey,revokeKeyandkeyLinefromsrc/actions/report_key.ts, and adds no table or grant.Two things I touched beyond your list:
src/http/lazy_lists.ts: I regenerated it withbun scripts/lazy-lists.ts, not by hand. The new route is a 404no_routewithout that, andtest/boot-lazy.test.tswould fail on a stale list. Three lines were added.src/contract/openapi/routes/and areport-keytag. The contract tests require every route to be listed.Tests: a new test in
test/crash-report-key.test.tsmakes a key through the API and files a report with it (202). It rotates so the old key gets 404, then revokes so the new key gets 404. It also checks that a non-admin and an anonymous caller get an identical 404 on all three verbs. It uses its own repository because the report rate limit is counted per repository and address. The contract, lazy-boot, route-mark, doorless and crash-report suites pass, andtscis clean. I did not run the full suite.Not done:
No door:.docs/features/crash-reports.mdnow describes the API.To try it:
curl -X POST -H "authorization: Bearer $ADMIN_TOKEN" $FORGE_URL/api/v1/repos/<owner>/<name>/report-key. Then send the returned key asX-Report-Keyto that repository'scrash-reports.I did not use
bun scripts/similar.ts. The route is thin and I reused the existing actions and the crash door's 404 wording.Closes #18286