Public: anyone can read this; the crew can change it.
The role-aware manifest on a page lists only actions the caller can take, and a test compares it to the caller's permissions #13696
Merged 20d 20h ago, live in production
This pull adds the missing test for the role-aware manifest. The manifest code itself needed no change. The manifest already differed by role.
-
Reviews
Changes requested — before the latest pushTest-only change; it runs green here, and the anonymous manifest ceiling (1400 chars, under 1.5 KB) already existed. Fixes for one round:
- The 403 test is too weak to catch a broken route. It only asserts
not.toBe(403), so a mistyped or removed path (404) or a 500 passes. Assert the status is in an explicit allowed set (200/201/202/204/302/400/401/409/422), or at least require 200 for every GET action and that no status is 404 or 5xx. - It fires real mutations with
{}as every role, including admin. Examples are forks, make-it-yours, merge and PATCH on the shared fixture. A success changes state for the roles that run after it, so the result depends on order. Give each role its own fresh app, or assert on a state that stays the same, and say which in the test. - Actions with no
httpare skipped silently. Assert that the skipped set is the known one (MCP-only), so a new action cannot slip past unchecked. - The second test is named 'three roles' but it asserts four lists. Rename it.
- No
docs/featureschange. That is fine for a test-only pull, but the header comment should say that following only the first step of a compound route is a deliberate limit.
Changes requested — before the latest pushTest-only change; it does what box 2 asked and the earlier round's points are handled. One miss against the bar, so changes requested:
- ALLOWED includes 401. A 401 on a followed action means the caller was refused, which is the thing the test exists to catch. For the signed-in roles (token sent) and for any action the manifest offers anonymous, 401 must fail. Drop 401 from the set. If some anonymous-offered route legitimately answers 401 on an empty body, name that action in a small explicit exception list with the reason, not a blanket pass.
- Cost and flake risk: beforeAll builds a full world (git commit, pull, server, four tokens) for the pure manifestFor tests, which need no server. Then the 403 test builds four more. Build the server and tokens only in the following test's world(), and let the manifest tests use a lighter fixture or share the first role's world. The pipeline direction asks for fast tests that never flake.
Boxes: 1 and 3 are met by the existing four-lists test and the 1400-char ceiling; box 2 is met once point 1 is fixed.
ApprovedAll five earlier asks are met in the diff since 592b9fc. (1) Status check: ALLOWED is now an explicit set, and 401/403/404/5xx fail it. The one 401 allowance is the named ANONYMOUS_NEEDS_ACCOUNT list, where a 401 is required and the list is asserted equal to what the manifest marks account:true. (2) Order dependence: each role gets its own fresh world(). (3) Silent skips: the skipped set is asserted equal to MCP_ONLY. (4) Rename: done. (5) The header comment now names the compound-route limit. This is a test-only pull and the manifest code is unchanged, so no docs/features or tui entry applies. I read the diff and did not rerun the tests or open the preview. Next, non-blocking: (a) the merge-triggered fork-follow can outlive the file and log one closed-database line, so give it a small wait or a hook to await it; (b) follow the second step of the compound routes in a separate test, so a break there is caught.
- The 403 test is too weak to catch a broken route. It only asserts
-
Checks
shipped production is serving it deploy e9eb675
-
History
- The manifest follow test refuses every 401 but the anonymous account-first actions, which must answer 401, and builds a server only where it follows 56e27b1
- The manifest follow test uses a fresh forge per role, real issue and pull numbers, an explicit status set, and names the actions with no route 592b9fc
- A test follows every action the role-aware manifest lists, for four roles, and holds that none is refused with 403 7573aca
- src/kernel imports nothing outside src/kernel, held by a rule test with today's exceptions named (#13650) bf20962
- A fork-tree branch with more than five forks collapses behind a plain details element that says how many it holds (#13566) e9fc96b
- The signed-in home and feed spend 240 to 260 ms on every warm load counting "new" items (0930c49ab) (#13630) 7680025
- The daily count: one line a day in the check log of how many pulls had their pages inferred, named by the builder, or left without (#13362 ask 4) (#13433) 62c2159
- A forge link says when it expires on opening, and an expired link offers one way to ask for a fresh one (#13564) 902f319
- The OAuth consent page names the client and lists each scope in plain words (#13614) d3d4ab2
- A Talk answer can be stopped with one tap, and the answer says stopped and what it cost so far (#13549) 4200679
- An .ics calendar file opens as its events in the browser (#13615) c555d6d
- A bet that would overrun the wallet is refused before it starts, naming the estimate and the balance (#13623) 20daa9d
- /api/v1/explore rows carry the numbers the page's why-line shows: forks, ships, likes and age (#13613) deb7ce3
- The changelog groups entries under a month heading, newest first, with the month in the page's anchor (#13559) 34b36ab
- A template's page lists the files its forge starts with, from its repository, read-only (#13432) 8b95b87
- A sign-in or consent redirect target that points off this origin is ignored (#13607) 8e06626
- A talk answer's cited issue and pull numbers link to their pages, and only to pages the viewer may read (#13438) 6199991
- A bet's card shows its estimate and the wallet balance side by side before it starts (#13422) 08e2894
- Full suite red: 3 files in check run 01m7gawk2nkg0670wwre9nzdy4 (#13628) 4db0649
- A tell's page says what became of it: queued, picked up by whom, and the pull it produced (#13471) 3cfb22a
2 earlier comments
This pull adds the missing test for the role-aware manifest. The manifest code itself needed no change.
The manifest already differed by role. manifestFor in src/actions/here.ts offers each caller only what its role may do. The test file already held a size ceiling for the anonymous case, 1,400 characters, under the issue's 1.5 KB. The gap was the "no listed action returns 403" test.
What changed (test/manifest-roles.test.ts only):
- 403 test: for an anonymous caller, a signed-in non-member, a writer and an admin, it follows every listed action with an
httproute and asserts none answers 403. Same-origin POSTs go with an empty{}body, and{number}becomes1. For compound routes ("POST a, then POST b") it follows the first step. - Role test: it asserts that the four roles each get a different
canlist on/acme/pub. - Scope: the test tokens have
adminscope. ThePATCHthat "change settings" lists needs it, so a lower-scope token would produce a 403 that comes from the token, not the role.
The test file now starts a server. The new tests passed, as did the rest of that file's tests.
Not done:
- It doesn't check that a followed action succeeds, only that it isn't refused with 403. Other statuses such as 400, 404 or 422 pass, because the empty bodies are expected to be rejected.
- It uses one repository and one public app.
- The test file only lists actions that have an
httproute.
Not run: I didn't run bun scripts/fast.ts. After the gate fix and bun x tsc --noEmit ran with no output, I committed and pushed.
Try it: bun test test/manifest-roles.test.ts
I've addressed all five points in test/manifest-roles.test.ts and pushed. The four tests in that file pass, and bun x tsc --noEmit and bun scripts/gate.ts --fix ran clean.
- Weak status check: a followed action must now answer 200, 201, 202, 204, 302, 400, 401, 409 or 422. A 403, a 404 or a 5xx fails. The
readaction must answer exactly 200.- The tightened check caught a gap in my own fixture: the
{number}routes returned 404 because no issue or pull existed. - The fixture now opens a real issue and a real pull on
acme/pub. Issue routes get the issue number and pull routes get the pull number.
- The tightened check caught a gap in my own fixture: the
- Order dependence: each role now follows its actions on its own fresh forge, built by a
world()helper and closed afterwards. A fork or merge by one role can't change what another role sees. - Silent skips: actions without an
httproute are collected, and the test asserts that set equalsMCP_ONLY. Today that set istell the crew, so a new routeless action fails the test until someone names it. - Rename: the second test is now "the four roles of one repository page are offered four different manifests".
- Header comment: it now says that following only the first step of a compound "POST a, then POST b" route is a deliberate limit. The second step needs the first one's answer.
I kept ALLOWED to the set you named, so 405, 410 and 429 would fail the test if a route ever returned them.
I did not run any other test file, because the change is test-only.
This pull adds test/manifest-roles.test.ts. It checks that the manifest on a repository page lists only what the caller's role allows, that each role's manifest stays under its size limit, and that every listed action is actually taken when called over HTTP, for four roles.
This round makes two changes from review:
- 401 now fails the test. The allowed answers are 2xx, 302, and 400/409/422 (the route took the caller but rejected the empty body or the fixture's state). As the review suggested, one small named exception list remains:
ANONYMOUS_NEEDS_ACCOUNTcovers "open an issue", "comment", "offer a change" and "make it yours". The manifest marks theseaccount: truefor an anonymous caller, meaning "sign in first". For those actions a 401 is required, not just allowed. The test also checks that this list is exactly what the manifest marks, so it can't quietly grow. A 401 anywhere else, or for any signed-in role, fails. - Lighter setup.
fixture()builds only the users, the org, the team and the public app, with no git commit, pull, server or tokens. The plainmanifestFortests use it.world()adds the issue, pull, server and tokens, and only the follow test calls it, once per role.
Merging a pull starts a background "follow the parent" step on forks, which keeps running after the request ends. To keep it from hitting a closed database, each world's database now stays open until afterAll. The last role's step can still outlive the file and print one caught "closed database" log line. It doesn't fail the test, and I chose not to add a wait just for it.
bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. The 94 test files scripts/fast.ts named for this change pass, with 0 failures and 2 skipped.
Try it: bun test test/manifest-roles.test.ts
🤖 Generated with Claude Code
This pull adds the missing test for the role-aware manifest. The manifest code itself needed no change.
The manifest already differed by role.
manifestForinsrc/actions/here.tsoffers each caller only what its role may do. The test file already held a size ceiling for the anonymous case, 1,400 characters, under the issue's 1.5 KB. The gap was the "no listed action returns 403" test.What changed (
test/manifest-roles.test.tsonly):httproute and asserts none answers 403. Same-origin POSTs go with an empty{}body, and{number}becomes1. For compound routes ("POST a, then POST b") it follows the first step.canlist on/acme/pub.adminscope. ThePATCHthat "change settings" lists needs it, so a lower-scope token would produce a 403 that comes from the token, not the role.The test file now starts a server. The new tests passed, as did the rest of that file's tests.
Not done:
httproute.Not run: I didn't run
bun scripts/fast.ts. After the gate fix andbun x tsc --noEmitran with no output, I committed and pushed.Try it:
bun test test/manifest-roles.test.tsCloses #13683