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

opened this

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.

Notes

opened this

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, in src/actions/upstream_follow.ts. The API and MCP both call it, so they answer the same.
  • repo: this is the followed upstream as host/path, for example example.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.ts now describes upstream.
  • Tests: test/repo-upstream-facts.test.ts covers 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

Closes #5868

commented

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, in src/actions/upstream_follow.ts. The API and MCP both call it, so they answer the same.
  • repo: this is the followed upstream as host/path, for example example.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.ts now describes upstream.
  • Tests: test/repo-upstream-facts.test.ts covers 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

commented

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 returns null unless canAdmin holds, which is the rule the /upstream route, follow_upstream, the settings card and the terminal's about screen already follow.
  • Test: test/repo-upstream-facts.test.ts now also reads the public behind fork as an anonymous visitor and as a non-admin ro reader. Both get upstream: null over the API, and the ro reader gets null over 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

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs