Skip to content

feat(orb): initiate APR repo transfer to a customer account - #7655

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
glorydavid03023:feat/apr-repo-transfer
Jul 21, 2026
Merged

feat(orb): initiate APR repo transfer to a customer account#7655
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
glorydavid03023:feat/apr-repo-transfer

Conversation

@glorydavid03023

Copy link
Copy Markdown
Contributor

Closes #7638

Summary

Implements #7590's decision that an APR (auto-provisioned) repo — created under a loopover-controlled GitHub org (#7637) — can later be transferred, on explicit customer request, to the customer's own account, using GitHub's standard repository-transfer flow.

Adds initiateAprRepoTransfer(env, installationId, repoFullName, newOwner) in src/orb/apr-repo-transfer.ts. It mints the App installation token (the same token source as APR repo creation) and calls GitHub's POST /repos/{owner}/{repo}/transfer with new_owner.

Correctly models an asynchronous, acceptance-gated transfer

GitHub transfers do not complete synchronously — the recipient must accept via a confirmation email within a time window. So a successful API response means the transfer was initiated, not completed. The return type encodes exactly that distinction, and the function carries a doc comment stating it explicitly, so anything built on top never mistakes acceptance-pending for done:

export type AprRepoTransferResult =
  | { initiated: true; status: number; newFullName: string | null }
  | { initiated: false; status: number; error: string };

A total function — errors come back, they don't throw

An API error is returned as a structured { initiated: false, status, error } rather than thrown, so callers branch on the result instead of wrapping every call in try/catch:

  • target account doesn't exist → 422
  • caller lacks admin access to the repo → 403

Scope

Exactly the initiation call, per the issue. Out of scope (explicitly, per #7638): detecting when a pending transfer is accepted or expires, any customer-facing UI, and the policy of when a transfer should be offered. No repo-creation or provisioning logic here.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves — see the closing reference at the top of this body.

Validation

  • git diff --check
  • npm run typecheck (zero new errors vs base)
  • npm run test:coverage locally; codecov/patch ≥99% of changed lines AND branches
  • npm run ui:openapi:check
  • npm run docs:drift-check
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

Patch coverage: 100% (7/7 executable changed lines, every branch). The GitHub API is fully mocked — no live transfer calls — per the issue's test requirement.

Tests (test/unit/orb-apr-repo-transfer.test.ts): a successful 202 initiation asserting the endpoint, POST method, Bearer auth, and { new_owner } body plus the pending destination path; a 202 with an empty/unparseable body (initiated, destination unknown); a 2xx body omitting full_name (null destination); a 422 target-not-found and a 403 no-admin error — each handled without an unhandled exception, the 403 exercising the empty-body fallback message.

If any required check was skipped, explain why:

  • None skipped.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed. The installation token is mocked to an opaque string in tests — no key material of any kind appears in the diff.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. The 422 and 403 error paths are the negative-path tests for this GitHub App write.
  • API/OpenAPI/MCP behavior is updated and tested where needed (no OpenAPI surface — this is an internal orb function; ui:openapi:check confirms no drift).
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section. Not applicable — backend function only.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

Not applicable — this is a single backend function plus its unit tests. No UI, frontend, docs, or extension surface is touched.

Notes

  • The token is deliberately mocked to a bare opaque string in tests; there is intentionally no PEM/private-key-shaped text anywhere in the diff.
  • newFullName is surfaced from GitHub's response as the pending destination path — informational only, since the move is not yet final when the call returns.

…d#7638)

Implements JSONbored#7590's decision that an APR (auto-provisioned) repo, created under a loopover-controlled
org, can later be transferred to the customer's own account via GitHub's standard repository-transfer
flow.

Adds initiateAprRepoTransfer(env, installationId, repoFullName, newOwner): it mints the App
installation token (same source as APR repo creation, JSONbored#7637) and calls
POST /repos/{owner}/{repo}/transfer with new_owner. GitHub transfers are asynchronous and
acceptance-gated -- the recipient must accept via a confirmation email -- so the function and its
return type model a successful call as "transfer INITIATED, not complete", documented explicitly so
nothing built on top mistakes acceptance for completion.

Scope is exactly the initiation call: detecting acceptance/expiry, any customer UI, and the policy of
when a transfer is offered are out of scope (separate follow-ons). It is a total function -- an API
error (target account doesn't exist -> 422; caller lacks admin -> 403) comes back as a structured
`{ initiated: false, status, error }` rather than throwing -- so callers branch instead of catch.

Tests (mocked GitHub API, no live calls): a successful 202 initiation with the pending destination
path; a 202 with an empty/omitted body (initiated, destination unknown); a 422 target-not-found and a
403 no-admin error, each handled without an unhandled exception, the 403 exercising the empty-body
fallback message. The installation token is mocked to an opaque string -- no key material appears in
the diff.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.50%. Comparing base (3629080) to head (96fe457).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7655      +/-   ##
==========================================
- Coverage   88.51%   88.50%   -0.02%     
==========================================
  Files         724      725       +1     
  Lines       76020    76027       +7     
  Branches    22629    22630       +1     
==========================================
- Hits        67291    67287       -4     
- Misses       7681     7688       +7     
- Partials     1048     1052       +4     
Flag Coverage Δ
shard-1 36.36% <0.00%> (+0.65%) ⬆️
shard-2 35.65% <100.00%> (+2.67%) ⬆️
shard-3 31.34% <0.00%> (+2.69%) ⬆️
shard-4 38.95% <0.00%> (-1.67%) ⬇️
shard-5 31.88% <0.00%> (-2.12%) ⬇️
shard-6 33.87% <0.00%> (-2.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/orb/apr-repo-transfer.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 21, 2026
@loopover-orb

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-21 06:59:19 UTC

2 files · 1 AI reviewer · no blockers · CI pending · unknown

⏸️ Suggested Action - Manual Review

Review summary
Adds a single, well-scoped `initiateAprRepoTransfer` function that POSTs to GitHub's repo-transfer endpoint using the existing installation-token pattern, and correctly models the async/acceptance-gated nature of GitHub transfers via a discriminated `AprRepoTransferResult` type instead of a boolean. Error paths return structured failures rather than throwing, and the tests cover the success, empty-body, missing-field, 422, and 403 cases against the real fetch call shape (URL, method, auth header, body). This is a clean, narrowly-scoped initiation-only change with no provisioning or UI creep, matching the stated issue scope.

Nits — 5 non-blocking
  • The 200-char truncation of the error detail body (apr-repo-transfer.ts:48) could cut off structured JSON mid-token, making `error` invalid JSON for callers that try to re-parse it — worth a comment noting it's meant as a human-readable fallback, not machine-parseable.
  • No validation that `newOwner`/`repoFullName` are non-empty before hitting the network; GitHub will reject malformed input anyway, but a quick guard would save a wasted API/token-mint round trip.
  • `api.github.com` is hardcoded here as it is in the rest of the GitHub client code in this repo, so it's consistent, but worth confirming there's no existing constant/helper for the base URL that this should reuse instead of a literal.
  • Consider extracting the GitHub API base URL into a shared constant if one doesn't already exist in src/github/client.ts, for consistency with other GitHub calls.
  • If a caller ever needs to distinguish 'invalid target account' (422) from 'no admin access' (403) programmatically rather than by inspecting `error` text, consider adding a narrower error code/kind field in a follow-up.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7638
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 208 registered-repo PR(s), 121 merged, 15 issue(s).
Contributor context ✅ Confirmed Gittensor contributor glorydavid03023; Gittensor profile; 208 PR(s), 15 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Review context
  • Author: glorydavid03023
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 208 PR(s), 15 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement APR repo-transfer-to-customer initiation via GitHub's transfer API

1 participant