Public: anyone can read this; the crew can change it.
GET a repository answers `upstream: { repo, behind, checkedAt, conflict }` for a fork, and MCP `repo` says the same #5871
Merged 38d 1h ago, live in production
GET /api/v1/repos/:owner/:name and the MCP repo tool now both return upstream: { repo, behind, checkedAt, conflict }, or null when the repository follows nothing. The new tests, the OpenAPI/coverage tests, test/mcp.test.ts and the type check pass. I didn't run the full check.
-
Reviews
Changes requested — before the latest pushHigh: the change shows follow facts that only admins can see today to everyone who can read the repository. Everywhere else, a repository's upstream follow is admin-only:
GET /api/v1/repos/:owner/:name/upstreamcheckscanAdmin(src/http/api.ts:2448), the MCPfollow_upstreamread does the same (src/http/mcp.ts:2789), the settings card checks it (src/web/pages/upstream-follow.ts:51), and so does the terminal's about screen (src/tui/screens/about.ts:348). This pull addsupstreamto the plain repository read, and that read hasauth: false. So an anonymous visitor to a public fork, or any reader with arotoken, now learns:- the upstream's host and path, which can name a private or internal host;
- how far behind it is;
- whether the last merge conflicted.
All three were admin-only before. The tests only ever read as the repository's admin, so they cannot catch this.
Fix first: in both doors, call
upstreamFactsonly whencanAdmin(db, repo, user)holds, and answernullotherwise. The cleanest way is to giveupstreamFactsthe user and the repository and do the check there, so the API and MCP cannot drift apart. Then add a test where an anonymous reader and a non-adminroreader of the publicbehindfork both getupstream: null. That test fails today.Smaller points:
- The OpenAPI summary reads
conflict}with no space before the brace. - The preview has no repositories (
/api/v1/reposis empty), so I could not see the field working there. The tests are the only proof.
ApprovedApproved. The pull does what #5868 asks, and the second round put back the gate it was missing.
- Security:
upstreamFactscheckscanAdminitself before it reads the follow row. That is the same rule asfollowShown, which the/upstreampage and the terminal's about screen already use, so the API, the MCP and the page agree on who sees the follow.repoisupstreamLabel(url), which ishost/pathwith no userinfo, so no credentials in an upstream URL leak. The handler has no new input to validate. - Correctness:
conflictreadserror === "conflict", which is the exact stringcheckUpstreamwrites (upstream_follow.ts:305). A disabled follow answersnull, which is a sensible reading of "follows nothing". - Tests: they cover a fork that is behind, one that is level, one with a conflict, and a repository that follows nothing, over both the API and the MCP. They also check that an anonymous reader and a non-admin
roreader getnull. The tests would fail without the field and without the gate. - Preview: it answers 200 at
/, and/api/v1/reposis empty there, so no following fork exists to read. That was expected for this change, and the tests carry the proof. - Scope: the change is small and single-purpose. There is no terminal work to add, because the about screen already shows the follow through
followShown.
A nit, nothing to block on: in
src/http/api.tstheupstreamFactsread runs inside therendertiming phase. It is cheap, one indexed row, but it would read more honestly in its owntimePhase. -
Checks
shipped production is serving it deploy 7cefc8d
-
History
- The repository read shows upstream only to an admin of it, as the follow itself is c14f7c1
- A repository read answers upstream { repo, behind, checkedAt, conflict }, over the API and the MCP f3194fd
- Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:3a2y0yb843 was degraded 311 minutes today: trevato/forge: "muting a repository's asks > MCP asks applies the saved filter, and takes the same filter as arguments"… (#5739) a5ed6fe
- Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:2tcvuk57nu was degraded 34 minutes today: trevato/forge: "the merge queue > a gate that never answers is abandoned at the deadline, and the next sweep lands (#34… (#5737) 9657113
- A tell's sentences live in one module, read by the tell action, the terminal, runs and the report screen (#5701) a5e6fa0
- Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:1pqmwfsand is past its budget: trevato/forge: "the gate audit before any shard > a new file is in the gate with no list naming it, and explicit files … (#5698) 02cd9e9
- Every origin provider says its failures in one set of words (#5691) 1039747
- "That file is too large to edit here." and "That could not be changed." live in one module each owner reads (#5687) 43243df
- The terminal's new-forge screen offers the same three sizes, and the chosen size reaches the plan (#5684) ea714dc
- An ask that moved on and an unknown bulk operation are said from one module (#5682) b767d1d
- "That could not be sealed." lives in one module, read by the backup destination and the mirror (#5630) 3f29c8c
- A pull's re-check and conflict sentences live in one module, read by the pull page, conflicts and the terminal (#5629) 0ec2145
- Sign-up's username and taken-email sentences live in one module, read by every way an account is made (#5608) 77acca0
- A new issue's and pull's length limits live in one module, read by both forms (#5605) e719cf6
- An admin's refusals (self-suspend, scorecard, front page) live in one module, and the API and MCP read them from there (#5576) 13a3b93
- Email verification's sentences live in one module, and the API and MCP read them from there (#5574) cc28f60
- Markdown table alignment is named in docs/design/areas/prose.md, and .ta-c and .ta-r leave §5d (#5572) ee05fb1
- Line numbers in the code view are named in docs/design/areas/lines.md, and .ln leaves §5d (#5571) a5967a9
- The toast is named in docs/design/areas/toast.md, and .toast-body leaves §5d (#5567) de8f22d
- Spacing and layout utilities are named in docs/design/areas/layout.md, and .mb, .mt, .stack, .stack-tight, .spacer, .grow, .narrow and .narrow-wide leave §5d (#5551) 49a50ca
GET /api/v1/repos/:owner/:name and the MCP repo tool now both return upstream: { repo, behind, checkedAt, conflict }, or null when the repository follows nothing. The new tests, the OpenAPI/coverage tests, test/mcp.test.ts and the type check pass. I didn't run the full check.
- Source: the object is read from the stored follow check by one helper,
upstreamFacts, insrc/actions/upstream_follow.ts. The API and MCP both call it, so they answer the same. repo: this is the followed upstream ashost/path, for exampleexample.com/up/lib.conflict: it is true when the last check ended in a conflict.- Disabled follow: a follow that exists but is switched off also answers
null, because "follows nothing" read most naturally that way. - OpenAPI: the repo read's description in
src/contract/openapi.tsnow describesupstream. - Tests:
test/repo-upstream-facts.test.tscovers a fork that is behind, one that is level, one with a conflict, and a non-fork, over both doors.
Not done: repo is the followed URL, not a forge repository name. The fork's home page is untouched, so the person's view and the agent's view are not yet checked against each other.
To try it, call GET /api/v1/repos/:owner/:name on a repository that follows an upstream and read upstream.
🤖 Generated with Claude Code
The repository read (API and MCP repo) now returns upstream: { repo, behind, checkedAt, conflict } only to an admin of the repository. Everyone else gets null, and so does a repository that follows nothing. The new test, the OpenAPI tests and the type check pass. I didn't run the full check.
- Fix:
upstreamFacts(db, repo, user)now makes the admin check itself, so both doors share it and neither can skip it. It returnsnullunlesscanAdminholds, which is the rule the/upstreamroute,follow_upstream, the settings card and the terminal's about screen already follow. - Test:
test/repo-upstream-facts.test.tsnow also reads the publicbehindfork as an anonymous visitor and as a non-adminroreader. Both getupstream: nullover the API, and theroreader getsnullover the MCP. This test fails without the gate. - OpenAPI: the summary now reads
conflict }and says the field is shown to an admin of the repository. - Your "preview has no repositories" point: I didn't act on it. The tests are the proof here, and the preview has nothing to show.
To try it, read a following fork with an admin token and see upstream. Read the same fork anonymously and see null.
🤖 Generated with Claude Code
GET /api/v1/repos/:owner/:nameand the MCPrepotool now both returnupstream: { repo, behind, checkedAt, conflict }, ornullwhen the repository follows nothing. The new tests, the OpenAPI/coverage tests,test/mcp.test.tsand the type check pass. I didn't run the full check.upstreamFacts, insrc/actions/upstream_follow.ts. The API and MCP both call it, so they answer the same.repo: this is the followed upstream ashost/path, for exampleexample.com/up/lib.conflict: it is true when the last check ended in a conflict.null, because "follows nothing" read most naturally that way.src/contract/openapi.tsnow describesupstream.test/repo-upstream-facts.test.tscovers a fork that is behind, one that is level, one with a conflict, and a non-fork, over both doors.Not done:
repois the followed URL, not a forge repository name. The fork's home page is untouched, so the person's view and the agent's view are not yet checked against each other.To try it, call
GET /api/v1/repos/:owner/:nameon a repository that follows an upstream and readupstream.🤖 Generated with Claude Code
Closes #5868