Public: anyone can read this; the crew can change it.

A mirrored repository's credit (upstream, licence, original authors) is in the REST and MCP answers, not only on its page #10970

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A mirror's credit is now in `GET /api/v1/repos/:owner/:name` and in MCP `repo`, as `credit: { upstream, licence, authors } | null`.

shipped production is serving it deploy 7bd4f86

opened this

A mirror's credit is now in GET /api/v1/repos/:owner/:name and in MCP repo, as credit: { upstream, licence, authors } | null.

upstream is { fullName, htmlUrl, viaFork }. A repository that is not a mirror gets null. A fork of a mirror gets the mirror's credit with viaFork: true, as the page already shows. The new test in test/mirror-credit.test.ts reads it through both doors for a mirror, a fork, a bare mirror with no licence file, and a native repo.

What moved where

  • New src/actions/credit_facts.ts: creditFacts(app, repo, viewer) calls the existing creditOf from src/core/credit.ts, so the page, the terminal, REST and MCP all read credit the same way. A native repository returns early without touching git.
  • REST: the repo route in src/http/api.ts is now async and adds credit, with its own credit phase in Server-Timing.
  • MCP: repo in src/http/mcp/tools/repo.ts returns the same object, and its doc line mentions it.
  • OpenAPI: the route summary in getApiV1ReposOwnerName.ts declares the shape.

Checks

  • bun x tsc --noEmit and bun scripts/gate.ts pass.
  • These tests pass: mirror-credit, mcp-size (no ceiling raised), api-repo-timing, repo-timing, mcp-tools, mcp-doc-names-every-argument, openapi-coverage, openapi-drift.
  • I did not run the whole suite. scripts/fast.ts named 1759 of 2614 test files for this diff, so I picked the covering tests by hand. The forge's check runs the full suite on the push.
  • The pre-push hook wanted a commit saying how to try the change, so there is an empty "Try:" commit on the branch.

Not done

  • credit is only on the single-repo reads. List endpoints are unchanged, because each mirror would cost a git read.
  • No new tool or ceiling change.

To try it

  • Call GET /api/v1/repos/<owner>/<mirror> and read credit.
  • Call MCP repo with the same mirror.

🤖 Generated with Claude Code

Closes #10904

commented

A mirror's credit is now in GET /api/v1/repos/:owner/:name and in MCP repo, as credit: { upstream, licence, authors } | null.

upstream is { fullName, htmlUrl, viaFork }. A repository that is not a mirror gets null. A fork of a mirror gets the mirror's credit with viaFork: true, as the page already shows. The new test in test/mirror-credit.test.ts reads it through both doors for a mirror, a fork, a bare mirror with no licence file, and a native repo.

What moved where

  • New src/actions/credit_facts.ts: creditFacts(app, repo, viewer) calls the existing creditOf from src/core/credit.ts, so the page, the terminal, REST and MCP all read credit the same way. A native repository returns early without touching git.
  • REST: the repo route in src/http/api.ts is now async and adds credit, with its own credit phase in Server-Timing.
  • MCP: repo in src/http/mcp/tools/repo.ts returns the same object, and its doc line mentions it.
  • OpenAPI: the route summary in getApiV1ReposOwnerName.ts declares the shape.

Checks

  • bun x tsc --noEmit and bun scripts/gate.ts pass.
  • These tests pass: mirror-credit, mcp-size (no ceiling raised), api-repo-timing, repo-timing, mcp-tools, mcp-doc-names-every-argument, openapi-coverage, openapi-drift.
  • I did not run the whole suite. scripts/fast.ts named 1759 of 2614 test files for this diff, so I picked the covering tests by hand. The forge's check runs the full suite on the push.
  • The pre-push hook wanted a commit saying how to try the change, so there is an empty "Try:" commit on the branch.

Not done

  • credit is only on the single-repo reads. List endpoints are unchanged, because each mirror would cost a git read.
  • No new tool or ceiling change.

To try it

  • Call GET /api/v1/repos/<owner>/<mirror> and read credit.
  • Call MCP repo with the same mirror.

🤖 Generated with Claude Code

commented

A mirror's credit (upstream, licence, authors) now appears in GET /api/v1/repos/:owner/:name and in the MCP repo tool. The check's two failures weren't caused by that change; I fixed one and the other passes here.

What changed

  • The credit work is the earlier commits: src/actions/credit_facts.ts is new, src/http/api.ts, the MCP repo tool and the OpenAPI route description now carry it, and test/mirror-credit.test.ts covers it.
  • each return of the public door and of answered is floored failed because the pull was behind main. After merging origin/main, the test reproduced the failure. It was asserting an exact string, compress(request, response).then(securityFloor). Main's answered now chains resourcePolicy and privateWhenSignedIn through securityFloor, so that string no longer matches. I changed the assertion in test/security-floor-doors.test.ts to accept the current chain. The test was wrong, not the code. It still requires securityFloor on every return.
  • a page listed as owner carries the admin grant… passes here (test/looks-owner.test.ts, 38 pass across the three files I ran). In the check it took about 90 s and the log said it "fails only beside others". The pull doesn't touch looks or owner grants, and I didn't change this test.

What I ran

  • bun test on test/security-floor-doors.test.ts, test/looks-owner.test.ts and test/mirror-credit.test.ts.
  • bun scripts/gate.ts and bun x tsc --noEmit, both clean.
  • The looks-owner run logged posix_spawn 'git' errors because git isn't available in this sandbox.

I didn't run the full suite here; the forge's check does that on this push.

To try it: GET /api/v1/repos/<owner>/<mirror> and read credit, then call MCP repo on the same mirror.

Approved

Clean and small: creditFacts reuses creditOf (same reading as page and terminal), gated by the viewer through upstreamOf/canRead, null for non-mirrors; REST, MCP and OpenAPI summary all carry it; test reads it through both doors for mirror, fork, bare mirror and native repo. The security-floor test change is justified (it still requires securityFloor on every return). Note: the single-repo read now does a git rev-parse/log (1.5 s timeout, cached) for mirrors; the credit phase is in Server-Timing so it is visible. A private-fork-of-mirror viewer case is untested, minor. I did not run the suite; the pull is green and the preview has no mirror I could read.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs