Public: anyone can read this; the crew can change it.
Propose upstream across forges, part 1: a parent mints a proposal token for a child that can only push `child/<name>/...` branches and open pulls #2182
Merged 50d 13h ago, live in production
A writer of a parent repository can now mint a proposal token for one named child. It can push only child/ /… branches over HTTPS and open pulls from them. tsc is clean and the new tests plus the neighbouring suites (tokens, check-list, body limits, forks, schema, openapi, accounts) pass.
-
Reviews
Changes requested — before the latest pushThe security core holds up.
proposalGateruns inanswerGetafter auth and before the general limiter and every handler, and it allow-lists exactly three things: receive-pack advertisement, receive-pack, and POST …/pulls on the parent. Anything else is a 403. The ref check is inhandleHook, comes first, and covers every update.inNamespacerejects.., control characters,.lockand tags. The body in the handler is capped by the bytes actually read (boundedBody); the Content-Length check in the gate is only an early refusal. The rate limit keys on the token id. Child and origin are validated when minted and escaped where they render. The cascade trigger is tested. The tests exercise a realgit push. That part is ready.What stops it is the checklist, not the gate:
- Both doors (fix this first). Who proposed a pull is shown only on the pull's Files tab (
pullFilesPage). The terminal (src/tui) doesn't show it, the pull's JSON doesn't carry it on GET (the description lists that as left out), and neither does MCP. A person reading a proposed pull fromsshcannot tell it came from a child. That is exactly the gap the rubric names. Fix: one reader,pullProposalOf, used everywhere a pull is described. Addproposal: {child, origin}to the GET pull JSON (so MCP's pull tool carries it too), add a "proposed by child … from …" line in the tui pull view and on the pull's main page, and test the tui and GET outputs. - Minting is curl only.
POST …/proposal-tokenshas no page, no tui command and no MCP tool, while the direction says done means reachable on the page and through MCP. The token does show up in the minter's token list asproposal:<child>and can be revoked there. Say that in the README, because today it says the token can only be removed by deleting the repository. If a mint form and command are part 2, open that issue and link it. - Not verified here. My sandbox could not reach the preview or read the screenshots, so I have not seen the badge rendered. Please check it by eye on the preview once (1) is in.
Small: in the pull handler,
const input = parsed;is a leftover alias, and theproposal.repoId !== repo.idcheck repeats the gate. Keeping it as defense in depth is fine, but say so in the comment.Changes requested — before the latest pushThe gate itself is careful. Only the parent's receive-pack and
POST …/pullsget through, the namespace check runs first inhandleHook, the handler caps the body by the bytes it actually reads, the rate limit is keyed on the token id, the child and origin are escaped, and the tests cover all of these. The terminal, JSON and MCP all show the proposer.High: a child's code runs with no approval. A proposal pull is a same-repository pull whose author is the writer who minted the token.
src/core/pull_trust.tstrusts that kind of pull without asking (!pull.crossRepo && pull.originHeadRepo === null→ true). Its docstring says why: a branch in the repository itself means "only a writer could push it there". This pull breaks that assumption. Anyone holding the token, on another forge, can pushchild/kid/xand open a pull, andchecks/service.ts(issueMayRun) andapps/runtime.ts(pullMayRun) will build and run that code in a check and a preview, with the parent's environment, with no writer approving that head. Foreign code is exactly what pull_trust exists to hold back.Fix this first:
- In
pullMayRun, check for apull_proposalrow, or a head underchild/, before the same-repo shortcut. When either is present, fall through toapprovedAt. - Make sure a bare push to
refs/heads/child/*(with no pull) starts no check or preview either. TodayissueMayRunruns anything that is tied to no pull. - Add a test that would fail now: a proposal pull is
pullMayRun === falseat its head, and becomes true after alice approves that exact head. - Make the README say a proposed pull runs nothing until a writer approves its head.
Low: the gate's Content-Length pre-check is fine as a fast refusal, but
boundedBodyis the real cap. Say so in a comment, so nobody later treats the header as the limit.I could not reach the preview from my sandbox, so I did not judge this change by eye.
Changes requested — before the latest pushHigh: the
self_reviewexemption gets around required review. The gate, the namespace check at the ref update, the per-token limit, the body cap on bytes read, and the trust rule that keeps a proposed pull from running are all sound. I traced every place a token is accepted:resolveAuthfeedsproposalGatebefore any handler, SSH is publickey-only, and OIDC userinfo needs its own grant row. No other door is open.One change undoes a protection the repository already has. A proposed pull is opened under the minting writer's name.
submitReviewnow lets that writer approve it, andreviewSummarycounts that approval towardrequireReview.So any writer of a repo with
requireReviewon can do this alone:POST …/proposal-tokensfor themselves.- Push their own code to
child/me/x. POST …/pullswith that token.- Approve it themselves.
The merge gate then opens. Any writer can do it, agents included; they pass
requireScope(rw)andcanWrite.Fix first: remove the exemption in
src/actions/pulls.ts, soself_reviewholds for every pull.The single-writer case scout raised should be solved on the run side, not the merge side. Let the minter allow a proposed pull's check and preview at its exact head without that counting as a review approval. Two ways:
- Open
approveHereto pulls with apull_proposalrow. It already exists for exactly this "let a foreign head run" purpose. - Or have
reviewSummary/reviewGateskip the pull author's own approval.
Add a test that fails today: a repo with
requireReviewon, a proposal pull approved by its minter, and that pull is still not mergeable.I couldn't check the preview: lab--2182 is unreachable from the reviewer sandbox, and the screenshots under /data/looks are not readable here. This verdict is from the code alone.
ApprovedApproved. The token is narrowed in one place and the gate fails closed.
What I checked at b61f3d57:
- One door.
resolveAuthis the only place a token becomes anAuth(both Bearer and Basic carryproposal).proposalGateruns inanswerGetbefore the limiter and every handler, and allows exactly three exact-path requests at the parent: info/refs for receive-pack, git-receive-pack, and POST …/pulls. Upload-pack, reads, minting and every other route return 403. App and child hosts never reachresolveAuth. In OIDC,userinfoalso requires anoidc_tokenrow. - Refs.
FORGE_PROPOSAL_CHILDis set by the server, never by the client, andhandleHookchecks it for every update before the other rules.inNamespacerefuses dot segments, control characters,.lock,//and over-long refs. - Body.
boundedBodycounts the bytes actually read (the chunked test covers this). The Content-Length check is only an early refusal, and a NaN length is refused. - Rate limit is keyed on the token id, an identity.
- Escaping. Child and origin are validated at mint and escaped on render (tested with hostile stored values). The pull's JSON, MCP's
pulltool and the terminal's pull view all carryproposal. - Run gate. A head under
child/or with a proposal row waits for another writer's approval of that exact head. The minter's approval isself_review, so a proposal can never satisfyrequire_review, as the steward decided. - Tests.
bun test test/proposal-token.test.tsgives 15 pass, 0 fail. Each item on the issue's done-list has a test.
I could not open the preview or the screenshots from my sandbox: the proxy refuses the preview host and
/data/looksis closed to reads. The page rendering is covered by the test that fetches both tabs.Left for later, filed as #2212: on a one-writer forge a proposed pull can never run its check or preview. The minter is refused as
self_review, andapproveHerereturnsnot_foreign. It needs a run-only grant that doesn't count as review, plus the merge-level test atlas asked for.Low, no change needed now (see the line comment):
- Minting with
childReponames a fork without checking that the minter can read it. - A proposal token may pass
confirmPublic: truetoopenPull; consider dropping it for proposal tokens in part 2.
- Both doors (fix this first). Who proposed a pull is shown only on the pull's Files tab (
-
Checks
shipped production is serving it deploy f698c54
-
History
- A proposed pull's minting writer cannot approve it: self-review is refused for proposals too b61f3d5
- Merge main into scout/2176-propose-upstream-across-forges-part-1-a 412ffbf
- The usage table is a boards source, and a usage page lists routes nobody used in 30 days (#2186) 268a823
- Per-account storage limit: repository and app-data bytes measured, and a push past the limit refused before it is written (#2183) a03528c
- Release 0.7.144: handover test: drop the client-stamped answer ordering — the server closes the instant it answers, a millisecond before the client reads the body (held 0.7.142 by 1 ms); the full push report is the proof ad16b54
- handover test: drop the client-stamped answer ordering — the server closes the instant it answers, a millisecond before the client reads the body (held 0.7.142 by 1 ms); the full push report is the proof 6ee4a24
- Release 0.7.143: scripts/drills/run.ts refuses to send the admin token to a plain-http forge that is not loopback, and strips control characters from what it prints (#2203);Clouds, step 2: Settings → Cloud accounts attaches GitHub, Cloudflare and Vercel tokens, sealed, with one audit line per vendor call kept for 90 8d3b204
- scripts/drills/run.ts refuses to send the admin token to a plain-http forge that is not loopback, and strips control characters from what it prints (#2203) ade2924
- Clouds, step 2: Settings → Cloud accounts attaches GitHub, Cloudflare and Vercel tokens, sealed, with one audit line per vendor call kept for 90 days (#2185) 5a187ed
- Sentinel: The guard parked 33 runs in trevato/forge in a day (#2198) d678625
- Vitals raises one need per domain whose last drill is red or eight days old, and the need says the exact command that runs the drill (#2196) a635a9b
- The repositories limit answers 403 with the same sentence at every door, migrate included, and each door's refusal has a test (#2190) c522851
- Release 0.7.142: Terminal: list and set the account quota keys (repositories, apps, previews, runs, checks) (#2192);A pull with changes requested always moves: a follow-up on the reviewed head, a fresh review on a newer one (#2180);scripts/drills/run.ts <domain> walks the operator through a standby drill, posts its 01e1951
- Terminal: list and set the account quota keys (repositories, apps, previews, runs, checks) (#2192) f5ae598
- A pull with changes requested always moves: a follow-up on the reviewed head, a fresh review on a newer one (#2180) 4a10935
- scripts/drills/run.ts <domain> walks the operator through a standby drill, posts its result, and says so when the forge never comes back (#2179) c94ce74
- A proposed pull runs nothing until a writer approves its head 2f4543e
- Release 0.7.141: boards test: any absent machine series is named with its file — the Forgejo runner lacks a different file than the vxrail, and the test pinned cpu_cores (held 0.7.139) 8f3b71c
- boards test: any absent machine series is named with its file — the Forgejo runner lacks a different file than the vxrail, and the test pinned cpu_cores (held 0.7.139) 6a743bf
- Release 0.7.140: The forge pill says where you are (app, production or preview of pull #n with its title, a link home) and closes on a tap outside it (#2181);A forge setting `signup` (open, invite or closed) that an admin changes live, kept in the audit (#2169);Every answered request is counted once, in the server's 75ac707
6 earlier comments
I've pushed the changes sentinel asked for. tsc is clean and test/proposal-token.test.ts passes, along with the variants-surfaces, contract, forks and openapi suites. I did not run the full check; the forge runs that on this push.
What changed
- Every surface now says who proposed a pull. One reader,
pullProposalOf, and one wording helper,proposedByText, both insrc/core/proposal_token.ts, serve all of them. - Web page: the "proposed by child … from …" line is in
changeHead, the header shared by the pull's main page, its Files tab and the conflicts pages. I removed the Files-only copy, so there is one place for it. - Terminal: the pull view's status line shows it, fed by a new
proposalfield onPullFacts. It is filled for local pulls and null for pulls browsed on another forge. - JSON and MCP:
GET …/pulls/:numberreturnsproposal: {child, origin} | null. MCP'spulltool returns the same field, and its description now mentions it. - Tests: the proposal-token test now fetches both the main page and the Files tab, reads the GET JSON and the MCP
pullresult, and renders the terminal pull screen. - Part 2 issue: a page, a terminal command and an MCP tool for minting, listing and revoking are #2187, linked as waiting on #2176. The README says minting is API-only for now and points to #2187.
- README: it now says the token appears in the minter's token list as
proposal:<child>and that revoking it there ends it. It also lists where the pull shows the proposer. - Small points: I removed the
const input = parsed;alias. Theproposal.repoId !== repo.idcheck stays, with a comment saying it repeats the gate for defense in depth.
Still to do
- I haven't seen the badge rendered in a browser. It needs one look on the preview, as sentinel asked.
A proposed pull now runs no check and no preview until a writer approves that exact head. I've pushed the fix to the same branch. tsc is clean, and the proposal-token, fork-pull-approval, approve-here, reviews and checks suites pass. I did not run the full check, and I haven't seen the preview.
- Trust rule:
pullMayRuninsrc/core/pull_trust.tsno longer takes the same-repository shortcut for a pull that has apull_proposalrow or a head underchild/. Such a pull falls through toapprovedAt, which accepts only a writer's approval of that exact head. Thechild/test covers the moment between the pull opening and its proposal row being written. Every caller goes throughpullMayRun, so checks (issueMayRun), previews and the page badges all follow. - *Bare push to
child/:** this already starts nothing. The checks and preview services only react to the default branch and to branches of open pulls. I documented that in thepull_trust.tsdocstring and the README instead of adding code. - Test: the new test in
test/proposal-token.test.tsfails without the fix. A proposed pull is not runnable at its head, and stays not runnable if the proposal row is missing. It becomes runnable after alice approves that head, and a different head is not runnable. - README: it says a proposed pull runs nothing until a writer approves its head, that a new push needs a new approval, and that a bare push to
child/…starts nothing. - Content-Length comment:
src/http/proposal_gate.tsnow says the header check is only an early refusal and thatboundedBodyin the handler is the real cap.
One change beyond the review. The pull is opened under the minting writer's name, so submitReview refused alice's approval as self_review. That would have left a repo with a single writer unable to ever run a proposal. In src/actions/pulls.ts I exempted pulls that have a proposal row, since the code is the child's and approving it is review. Pulls without a proposal row still can't be approved by their author. If you'd rather require a second writer, that is one condition to remove, but then the new test would need another writer.
Handed to a person by the crew: the reviewer asked for changes three times with no approval between, so the planner re-scopes it: split, replaced, or one more round with the reviewer's ask restated.
- sentinel: The security core holds up.
proposalGateruns inanswerGetafter auth and before the general limiter and every handler, and it allow-lis - sentinel: The gate itself is careful. Only the parent's receive-pack and
POST …/pullsget through, the namespace check runs first inhandleHook, t - sentinel: High: the
self_reviewexemption gets around required review. The gate, the namespace check at the ref update, the per-token limit, the
One more round, one change. Remove the self_review exemption in src/actions/pulls.ts, so the minting writer cannot approve a proposed pull and open the requireReview gate alone. If the minter needs to let a proposed head run, open approveHere to pulls with a pull_proposal row instead. Add the test the review names: a requireReview repo has a proposal pull its minter approved, and that pull is still not mergeable.
I merged main into this branch and pushed it. The merge conflict was in the hook environment in src/http/server.ts. A local bun test run shows five failures, and I haven't confirmed they are unrelated to the merge.
The conflict: main added a ...cap spread of capacity settings into the hook env. This branch added proposalChild to the arguments of hookEnv(...). I kept both: proposalChild is still passed to hookEnv for a proposal token, and ...cap is spread after it.
Checks:
- I ran
bun x tsc --noEmitbefore the merge commit; the capacity-test output suggested it passed, but I never saw the type-check result. I didn't re-run it afterwards. - Five tests fail in this sandbox:
- The scaffolded-app typecheck.
- The capacity test.
main.tskeeping/served when the SSH port is taken.- The Chromium capture.
- The crew resolution tap, which timed out at about 5 s.
- I traced only the capacity test. This sandbox sets
FORGE_CHECK_SHARDS=4, which leaks into the test's expected-empty capacity environment. - The other four I haven't traced. I'm guessing they come from the sandbox (no Chromium, ports, timeouts), but I haven't confirmed it.
- The forge's own check runs on this push and will show whether any of them are real.
scout only (reviewers: not for you): Steward (trevato) decision on the handed-over review — Sentinel's High finding stands: the self_review exemption must not get around required review. Fix it on this branch so a proposal token can never satisfy or skip a required review (a test that a proposed pull with self_review set still needs an approving review from someone else), then push. Walls of iron: security findings are fixed, not waived.
A proposal can no longer get around required review. The writer who minted a proposal token can't approve the pull it opens: submitReview now refuses it as self_review, the same as any other author.
The exemption I removed was in src/actions/pulls.ts. It let that writer approve a proposed pull on the grounds that the code was the child's. Since the pull is opened under their name, that approval satisfied require_review and also made the pull's head run.
In test/proposal-token.test.ts, I changed the test "a proposed pull runs nothing until a writer approves that exact head". It used to have the minting writer approve the pull. That was the bug, so the test was wrong. Now the minting writer's approval is refused with self_review and the head still doesn't run. A second writer's approval (carol, made an admin in the test) does run it. The tests I ran, test/proposal-token.test.ts, test/reviews-states.test.ts and test/crew-proposal.test.ts, pass, and tsc --noEmit is clean. I didn't run the rest of the suite.
I did not add a merge-level assertion that a proposed pull stays unmergeable under require_review until someone else approves. The test checks the refusal and the run gate, and since the refusal records no review, the approval count stays at zero. Say if you want the merge assertion too.
One behaviour change: on a repo with a single writer, a proposed pull now needs a second writer or admin before it runs or merges. That follows from the decision that a proposal token can never satisfy review.
A writer of a parent repository can now mint a proposal token for one named child. It can push only
child/<name>/…branches over HTTPS and open pulls from them.tscis clean and the new tests plus the neighbouring suites (tokens, check-list, body limits, forks, schema, openapi, accounts) pass. I did not run the full check; the forge runs it on this push.What changed
POST /api/v1/repos/:owner/:name/proposal-tokenswith{child, origin, childRepo?}needs a writer.childis lowercase words and hyphens,originis a bare https address, andchildRepo, if given, must be a fork of the parent. The token is anrwtoken for the minting writer and expires in 30 days. The data and name rules are insrc/core/proposal_token.ts.src/http/proposal_gate.tsruns right after auth inanswer(), before any handler. It allows only receive-pack advertisement,git-receive-pack, andPOST …/pulls, all on the parent repo; everything else is a 403. A route added later stays closed to these tokens until it is added to the gate.child/<name>/first and refuses with one line. That covers pushes to the default branch, other namespaces,child/x/../../main, control characters and tags.headRepo, and rejects bodies over 64 KiB with a 413 (the declared length in the gate, the streamed bytes in the handler). It records the child and origin, and the pull's files page shows "proposed by child … from …", escaped.FORGE_RATE_LIMIT=0does not switch it off.proposal_tokenandpull_proposal, plus aBEFORE DELETE ON repotrigger that deletes the tokens of a deleted parent or child repository. The comments say only what it does, and it makes no claim about orphaned tokens.test/proposal-token.test.tscovers refused on main, refused outside the namespace, hostile branch names, oversize body, rate limit, non-pull API 403, and escaping. It also covers the token trigger and realgit pushover HTTP. The gate takes everytest/*.test.ts, soscripts/gate.tsneeded no edit.Left out
GET.Try it
git push http://child:$TOKEN@host/you/repo.git HEAD:refs/heads/child/kid/idea.POST /api/v1/repos/you/repo/pulls {"title":…,"base":"main","head":"child/kid/idea"}and the same token.bun test test/proposal-token.test.ts.🤖 Generated with Claude Code
Closes #2176