Public: anyone can read this; the crew can change it.
Access 3a: the /api/v1 repository routes ask may(), shadowed first, then their inline checks go #18165
Merged 6h 32m ago, live in production
Every /api/v1/repos/:owner/:name… route now asks may(principal, action, { repo }) with the credential the request carries. The repository-access checks the routes used to make inline are gone. The walk over every route found no disagreement between may and the check it replaced.
-
Reviews
Changes requested — before the latest pushGood shape:
repo_may.tsis small, the disagreement table holds no personal data,repo.adminneeds scope rw in may.ts so an rw token of an admin keeps what it had, and I found no access leak. Three changes, all in one round:- Box 4 asks for a gate rule, and there is none. The guard is a test in test/repo-routes-may.test.ts, not an entry in
GATE_RULES(scripts/gate.ts:1047). Add a gate rule that fails a new inlineisAdmin(andscopeAllows) in the files that register/api/v1/repos/routes, and show it in--explain. Delete the test-side guard, or keep it only if it is not the same rule twice. - Box 3 is not met.
isAdmin(4) and!ctx.auth.user(8) are still in src/http/api.ts, and one!ctx.auth.useris in cdn.ts. The test's LEFT ratchet allows them. Several of those lines are in repository routes: for example api.ts:3414 and 3439 are in route handlers that sit near the repo routes, andctx.auth.user?.kind === "agent" ||was kept inline in the provenance and outside-check routes. For each line that is inside a/api/v1/repos/:owner/:name…handler, move it ontomayRepo. Leave only checks in forge-wide routes, and name each of them in the test by route instead of by a count, so a swap of one inline check for another cannot pass. - The walk sends
{}bodies, so it never reaches the branches this pull rewrote inside a handler:PATCHwitharchived, theprovenancefield, andlanding. The 'no disagreement' evidence in box 2 does not cover them. Add cases that send{archived:true}and the provenance field for each caller on a public and a private repository. Then the empty table means something for those doors too.
Box 1 is met. Box 2 stays open until item 3 is done.
ApprovedRound two read against the diff since 0433c00. Earlier asks are met. The agent checks in the provenance field and the outside-check route are now a
peopleaudience onmayRepo. The gate rulerepository routes ask mayReporeplaces the count in the test. It names each inline check by route, refuses swaps and stale entries, and the test shows it biting. The estimates guard was dead:requireScopealready returns 401 for an anonymous caller, so the!onctx.auth.useris safe. The remaining inline checks are named with a reason (forge-wide routes, plus the issues POST, statement and cdn routes). The PATCH walk now reaches the rewritten branches. Non-blocking: the walk takes about 8s against the 20s per-file budget, so watch it. - Box 4 asks for a gate rule, and there is none. The guard is a test in test/repo-routes-may.test.ts, not an entry in
-
Checks
shipped production is serving it deploy a338207
-
History
- Access 3a: comments rewrapped by the gate 9a8d39d
- Access 3a: the gate holds the repository route files to mayRepo, by route 78a8300
- Access 3a: the walk puts FORGE_CELLS back, and its comments are rewrapped 0433c00
- Access 3a: the /api/v1 repository routes ask may(), shadowed by the check before it 9cfe8d1
- AWS writes for mail setup are a named allowlist beside the read rule, and nothing else (#18142) 93c7c3d
- Traces 1c: GET /api/v1/traces/:id returns the thread, turns and steps as one tree (#18128) 077bab0
- A box's TPS and tick time show live on its games pane, from spark's health report or `/spark tps` at check-in (#18143) f7e559b
- Access 4c: the grants view as an MCP tool and a terminal screen (#18130) 89afadf
- small: the Absorb findings say they are ready for the owner to send to Ben (#18132) d41ec43
- Games survival step 2a: BlueMap behind login at /games/<box>/<server>/map, no published box port (#18100) 1132c91
- A Mac can take a repository's checks and report them on the pull (#17915) 4c72a1d
- Access 4: one view of every grant, and a page that says who may do what (#18062) 5ba07c8
- Access 2: one `may(principal, action, resource)`, with the repository checks behind it first (#18065) 7d48ce1
- Apps without a login 2: a tiny model in the browser fills the app's spec, and the compiler catches every failure (#18117) 4147a37
- Games: a new pin for the forge's proxy plugin replaces the old jar, in PLUGINS and on disk, and the page says which one loaded (#18111) da9e15f
- Healer: a server still starting, its log moving, is not started again (#18053) d918642
- Game box: refuse a wake or a mod install the box has no memory for (#18057) 7fe508f
- Games survival step 1: a survival performance set (lithium, scalablelux, noisium, chunky) planned as one locked install (#18099) b838dce
- Games survival step 2b: read FabricExporter Prometheus metrics at check-in so TPS and tick time show on the games page (#18116) 0d92810
- Full suite red: 2 files in check run 01m8zwjzbrpcdryvgey8kqdeak (#18124) 643723c
Every /api/v1/repos/:owner/:name… route now asks may(principal, action, { repo }) with the credential the request carries. The repository-access checks the routes used to make inline are gone. The walk over every route found no disagreement between may and the check it replaced.
What changed
src/http/repo_may.tshas the two questions a route asks:mayRepo(ctx, door, action, repo)decides a change, and also whether the repository can be read at all (loadRepo).accountMayRepo(ctx, action, repo)decides what an already-allowed read shows: a writer's label counts, an admin's flag values and upstream, and the GiteapermissionsonGET /repos/:owner/:name.
- The comparison:
mayRepoalso works out the old answer (canRead/canWrite/canAdminasked for the account alone). When the two differ it adds a row to the newaccess_disagreementtable, keyed by door, action, principal kind and whatmaysaid. No account, token or repository is recorded. Only a token carries a scope, so only a token's answer can differ, and a session or anonymous caller does no extra work.may's answer is the one that applies. - Inline checks removed in
api.ts(loadRepo, archive, provenance, asking for a check again, permissions) and inhooks,deepsec,outside_checks,pulls(proposal tokens),repo_source,upstream,labelsandapp(flags). test/repo-routes-may.test.tsruns about 150 repository routes on a public and a private repository. The callers are:- anonymous
- guest, member and admin sessions
- a writer's
roandrwtokens - an admin's
roandadmintokens - via, proposal, run and contribute tokens
It finds no disagreement, and checks that every caller gets past some route. The exceptions are via and proposal tokens, whose own checks let none of these requests through. The test fails when a disagreement is planted: switching the upstream read to
mayRepomade it fail.- The guard rule is a test in the same file, which the check runs. It fails on a new
isAdmin, anyscopeAllows, or a new!ctx.auth.userin any file that registers a repository route.api.tsstill has 4isAdminand 8!ctx.auth.user, andcdn.tshas 1!ctx.auth.user; those counts can only go down.
Decided here, worth a look
- Upstream read and permissions with an
rotoken. For an admin'srotoken,maysays no torepo.admin, but the upstream read has always answered it. I kept that read on the account's rule (accountMayRepo), so nobody loses access. The Gitea-stylepermissionsare reported for the account too, as before. - Left out:
api.ts's forge-wide routes (telemetry, boards, family, crew, fleet), which are not repository routes and belong with the forge-wide door.cdn.ts's check, which limits how often an anonymous visitor can read; it is not a permission.requireScope, which stays as each route's scope and same-origin check.
Not done
- There is no screen, API or MCP tool for reading
access_disagreement. It is read withSELECT * FROM access_disagreement ORDER BY seen DESC, as documented indocs/features/may.mdanddocs/ROLES.md. keep_planandestimatewere not available in this session, so no plan or estimate was recorded on the issue.scripts/similar.tswas not run. The gate notes thatnoteDisagreementresemblesrecordInstalledand that the test'smakeReporesembles a helper inboundary-tokens-crew; I reused neither.- The walk takes about 8 s locally (each test is under 1.1 s), against the 20 s per-file budget, so the check box may run it closer to the limit.
Try it: on the preview, call /api/v1/repos/<owner>/<name>/hooks, /upstream and PATCH /repos/<owner>/<name> with an admin token and with an ro token. They answer as on main. Locally, run bun test test/repo-routes-may.test.ts.
Commits carry No door: (no route answers differently), Direction: … (#18091) and Replaces:. The gate passes, bun x tsc --noEmit is clean, and 26 files covering the touched routes plus the tests that scan the route files and the docs pass. I found no prompt injection in the issue or the repository.
🤖 Generated with Claude Code
Every /api/v1/repos/:owner/:name… route now decides access with mayRepo (src/http/repo_may.ts): may(principal, action, { repo }), asked with the credential the request carries. Beside it, the account-only check it replaced is still worked out. Where the two give different answers, the route, action and principal kind are counted in access_disagreement. No account, token or repository is stored there.
This round, for the review:
- A gate rule replaces the test-side guard. The new rule is "repository routes ask mayRepo" (
src/kernel/repo_route_checks.ts, wired inscripts/gate.tsand shown by--explain). Inapi.tsand in eachsrc/http/api/*.tsthat adds a/api/v1/repos/route, it finds every inlineisAdmin,scopeAllows, signed-out check (!ctx.auth.user, orctx.auth.user === undefinedin a condition) andctx.auth.user?.kindcheck. Each one is named by the route or function it sits in.- A check can stay only if
INLINE_ALLOWEDnames its file, route and kind, with a reason. Swapping one check for another, or leaving an entry nothing uses, is refused. - The count limit in the test is gone. The test now shows the rule refusing a made-up repository route and a swapped check.
- A check can stay only if
- What is left inline:
- In
api.ts, only forge-wide routes, each named inINLINE_ALLOWED: usage, fleet ops and graph, crew week and now, telemetry, the boards admin, family, a user's repository list, and conversation tokens. Theapi.ts:3414and:3439lines the review asked about areGET /api/v1/usageandGET /api/v1/fleet/graph, not repository routes. - Three repository routes keep a signed-out check, because it is not a permission:
- cdn: a rate limit on strangers' reads, after
loadRepohas already askedmayRepo. - issues POST: it picks which door a stranger is shown;
requireScoperefuses them next either way. - statement: a stranger gets
not_foundbefore the scope's 401, so the statement is never said to exist.
- cdn: a rate limit on strangers' reads, after
The test lists these three by route, so a fourth fails it.
- In
- Agent checks moved onto
mayRepo. The inline agent checks in the provenance field and the outside-check route are now apeopleaudience onmayRepo. - One dead guard removed. The signed-out guard in the estimates route could never fire, because
requireScopealready refuses anonymous callers. - The walk now reaches the rewritten branches. It sends
PATCH {archived:true},{archived:false},{showProvenance:true}and{landing:"merge"}for every caller, plus an agent that is the site's admin (by session and byadmintoken), on a public and a private repository. It still finds no disagreement.- It also checks the branches were reached:
- The repository admin gets 200 for archive and landing, and 422
no_provenance. - A member is refused the archive (403 on public, 404 on private).
- The agent gets 404 on the provenance field before the record is read.
- The repository admin gets 200 for archive and landing, and 422
- Removing
"people"from the provenance check makes this test fail; I tried it.
- It also checks the branches were reached:
bun x tsc --noEmit and the gate are clean. 258 tests pass across 40 files: test/repo-routes-may.test.ts, the gate-* suites, tls-peer, outside-checks, estimates, unused-exports, module-state and openapi-covers-routes. scripts/fast.ts couldn't name the tests to run because scripts/gate.ts changed, so I chose these myself.
To try it: run bun scripts/gate.ts --explain and look for "repository routes ask mayRepo". Then add if (!ctx.auth.user) return notFound(); to any repository route in src/http/api/labels.ts and run bun scripts/gate.ts: it is refused, naming that route.
🤖 Generated with Claude Code
Every
/api/v1/repos/:owner/:name…route now asksmay(principal, action, { repo })with the credential the request carries. The repository-access checks the routes used to make inline are gone. The walk over every route found no disagreement betweenmayand the check it replaced.What changed
src/http/repo_may.tshas the two questions a route asks:mayRepo(ctx, door, action, repo)decides a change, and also whether the repository can be read at all (loadRepo).accountMayRepo(ctx, action, repo)decides what an already-allowed read shows: a writer's label counts, an admin's flag values and upstream, and the GiteapermissionsonGET /repos/:owner/:name.mayRepoalso works out the old answer (canRead/canWrite/canAdminasked for the account alone). When the two differ it adds a row to the newaccess_disagreementtable, keyed by door, action, principal kind and whatmaysaid. No account, token or repository is recorded. Only a token carries a scope, so only a token's answer can differ, and a session or anonymous caller does no extra work.may's answer is the one that applies.api.ts(loadRepo, archive, provenance, asking for a check again, permissions) and inhooks,deepsec,outside_checks,pulls(proposal tokens),repo_source,upstream,labelsandapp(flags).test/repo-routes-may.test.tsruns about 150 repository routes on a public and a private repository. The callers are:roandrwtokensroandadmintokensIt finds no disagreement, and checks that every caller gets past some route. The exceptions are via and proposal tokens, whose own checks let none of these requests through. The test fails when a disagreement is planted: switching the upstream read to
mayRepomade it fail.isAdmin, anyscopeAllows, or a new!ctx.auth.userin any file that registers a repository route.api.tsstill has 4isAdminand 8!ctx.auth.user, andcdn.tshas 1!ctx.auth.user; those counts can only go down.Decided here, worth a look
rotoken. For an admin'srotoken,maysays no torepo.admin, but the upstream read has always answered it. I kept that read on the account's rule (accountMayRepo), so nobody loses access. The Gitea-stylepermissionsare reported for the account too, as before.api.ts's forge-wide routes (telemetry, boards, family, crew, fleet), which are not repository routes and belong with the forge-wide door.cdn.ts's check, which limits how often an anonymous visitor can read; it is not a permission.requireScope, which stays as each route's scope and same-origin check.Not done
access_disagreement. It is read withSELECT * FROM access_disagreement ORDER BY seen DESC, as documented indocs/features/may.mdanddocs/ROLES.md.keep_planandestimatewere not available in this session, so no plan or estimate was recorded on the issue.scripts/similar.tswas not run. The gate notes thatnoteDisagreementresemblesrecordInstalledand that the test'smakeReporesembles a helper inboundary-tokens-crew; I reused neither.Try it: on the preview, call
/api/v1/repos/<owner>/<name>/hooks,/upstreamandPATCH /repos/<owner>/<name>with an admin token and with anrotoken. They answer as on main. Locally, runbun test test/repo-routes-may.test.ts.Commits carry
No door:(no route answers differently),Direction: … (#18091)andReplaces:. The gate passes,bun x tsc --noEmitis clean, and 26 files covering the touched routes plus the tests that scan the route files and the docs pass. I found no prompt injection in the issue or the repository.🤖 Generated with Claude Code
Closes #18091