Skip to content
Source
Sign inSign up
pingdotgg/t3code

refactor(source-control): Bitbucket lives in @t3tools/source-control-bitbucket #17597

Mergedjuliusmarmingemerged 2 commits intot3/source-control-gitlab fromrefs/pull/17597/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

This is the fifth layer of moving each source control host into its own package. It stacks on #17594.

Bitbucket support moves into @t3tools/source-control-bitbucket, one subpath per module:

  • the REST client (BitbucketApi)
  • the repository provider
  • the pull request API and provider
  • the JSON decoding

Its driver joins BUILT_IN_SOURCE_CONTROL_DRIVERS. Neither registry, server.ts, nor ws.ts names Bitbucket any more. GitHub is the only host left in the server.

SourceControlHost gains a git facet. Bitbucket is the first host that needs git directly: it finds its repository from the checkout's remotes and checks out pull requests with plain git. The facet holds only the operations that requires:

  • readConfigValue, resolvePrimaryRemoteName, ensureRemote
  • listLocalBranchNames, fetchRemoteBranch, fetchRemoteTrackingBranch, setBranchUpstream, switchRef
  • remotes

remotes has two stages: resolving the repository and listing its remotes. That keeps BitbucketRepositoryVcsResolveError and BitbucketRepositoryRemotesListError distinct, so its error messages are unchanged. The server implements the facet with GitVcsDriver and VcsDriverRegistry. TestSourceControlHost fails any git call a test did not supply.

The BitbucketApi test stays in apps/server. It runs the real ServerSourceControlHost with mocked git services and asserts which of them the API calls. The other Bitbucket tests move with their code, with only imports and wiring changed.

Verified with:

  • tsc (apps/server and the packages)
  • knip
  • a frozen-lockfile install
  • release smoke
  • 59 test files (1405 tests)

🤖 Generated with Claude Code — Claude Opus 5.5 in T3 Code

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This relocates Bitbucket support while changing shared source-control host contracts, provider-driver registration, layer construction, and credential access boundaries. The behavior is intended to remain equivalent, but the cross-cutting infrastructure refactor warrants human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—5.0 KiB—6.8 KiB✅
      CodexThread snapshot wire—3.8 KiB—4.9 KiB✅
      CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      CodexLive turn WebSocket decoded—20.9 KiB—29.3 KiB✅
      CodexLive turn messages—2—8✅
      ClaudeTotal thread wire—5.0 KiB—6.8 KiB✅
      ClaudeThread snapshot wire—3.8 KiB—4.9 KiB✅
      ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      ClaudeLive turn WebSocket decoded—21.2 KiB—29.3 KiB✅
      ClaudeLive turn messages—2—8✅

      Baseline: unavailable · PR result: db90eb5 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    5. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: 622bc15b-5c4b-4eb8-81c7-49d91a42054b

      📥 Commits

      Reviewing files that changed from the base of the PR and between b108c251b38292982175658c60ea7172f5423ebf and db90eb506efd5e6c992b42a4b5c383d329f38d56.


      ⛔ Files ignored due to path filters (1)
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

      📒 Files selected for processing (32)
      • apps/server/package.json
      • apps/server/scripts/evaluate-thread-titles.ts
      • apps/server/src/pullRequest/PullRequestProviderRateLimit.test.ts
      • apps/server/src/pullRequest/PullRequestProviderRegistry.ts
      • apps/server/src/server.ts
      • apps/server/src/sourceControl/BitbucketApi.test.ts
      • apps/server/src/sourceControl/ServerSourceControlHost.ts
      • apps/server/src/sourceControl/SourceControlDiscovery.test.ts
      • apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts
      • apps/server/src/sourceControl/SourceControlProviderRegistry.ts
      • apps/server/src/sourceControl/SourceControlRepositoryService.test.ts
      • apps/server/src/sourceControl/SourceControlRepositoryService.ts
      • apps/server/src/sourceControl/builtInDrivers.ts
      • apps/server/src/ws.ts
      • docs/internals/pull-request-file-revisions.md
      • package.json
      • packages/source-control-bitbucket/package.json
      • packages/source-control-bitbucket/src/server/BitbucketApi.ts
      • packages/source-control-bitbucket/src/server/BitbucketPullRequestApi.test.ts
      • packages/source-control-bitbucket/src/server/BitbucketPullRequestApi.ts
      • packages/source-control-bitbucket/src/server/BitbucketPullRequestProvider.test.ts
      • packages/source-control-bitbucket/src/server/BitbucketPullRequestProvider.ts
      • packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.test.ts
      • packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.ts
      • packages/source-control-bitbucket/src/server/bitbucketPullRequestJson.test.ts
      • packages/source-control-bitbucket/src/server/bitbucketPullRequestJson.ts
      • packages/source-control-bitbucket/src/server/bitbucketPullRequests.ts
      • packages/source-control-bitbucket/src/server/driver.ts
      • packages/source-control-bitbucket/tsconfig.json
      • packages/source-control-core/src/server/SourceControlHost.ts
      • packages/source-control-testing/src/TestSourceControlHost.ts
      • scripts/release-smoke.ts

      💤 Files with no reviewable changes (8)
      • packages/source-control-bitbucket/src/server/bitbucketPullRequestJson.test.ts
      • packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.test.ts
      • packages/source-control-bitbucket/src/server/bitbucketPullRequests.ts
      • apps/server/src/ws.ts
      • packages/source-control-bitbucket/src/server/BitbucketPullRequestProvider.ts
      • packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.ts
      • packages/source-control-bitbucket/src/server/bitbucketPullRequestJson.ts
      • apps/server/src/sourceControl/SourceControlProviderRegistry.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.



      📝 Walkthrough

      Walkthrough

      The change moves Bitbucket source-control and pull-request components into a dedicated workspace package, registers its driver with built-in drivers, and routes provider Git operations through an expanded SourceControlHost interface. Server wiring and tests use the package exports, and the test host supports explicit Git-operation overrides.

      Changes

      Bitbucket source-control package integration

      Layer / File(s)Summary
      SourceControlHost Git interface
      packages/source-control-core/src/server/SourceControlHost.ts, apps/server/src/sourceControl/ServerSourceControlHost.ts, packages/source-control-testing/src/TestSourceControlHost.ts, related tests
      SourceControlHost adds Git-operation contracts. The server host delegates these operations to the Git driver and resolves the VCS driver for remote listing. The test host accepts optional Git-operation overrides and fails on unexpected calls.
      Bitbucket package and driver
      packages/source-control-bitbucket/*, apps/server/package.json, apps/server/src/sourceControl/BitbucketApi.test.ts, scripts/release-smoke.ts
      A new workspace package exports Bitbucket server modules and defines a Bitbucket driver. BitbucketApi uses SourceControlHost for settings and Git access, including remote discovery. Package tests and release-smoke workspace files are updated.
      Server driver registration
      apps/server/src/sourceControl/builtInDrivers.ts, apps/server/src/sourceControl/SourceControlProviderRegistry.ts, apps/server/src/pullRequest/PullRequestProviderRegistry.ts, apps/server/src/server.ts, apps/server/src/ws.ts, apps/server/src/sourceControl/SourceControlRepositoryService.ts, related tests, apps/server/scripts/evaluate-thread-titles.ts, docs/internals/pull-request-file-revisions.md
      Bitbucket joins the built-in driver registrations. Direct Bitbucket provider construction and API-layer wiring are removed from the server registries. Server code and tests resolve Bitbucket modules through package exports.

      Priority: ➖ Normal

      Estimated code review effort: 3 (Moderate) | ~25 minutes

      Change: Refactor


      Merge Risk: ⚪ Minimal · up to db90e

      This refactor moves Bitbucket support into its own package and registers it through the built-in drivers. No concrete merge-blocking risk was identified in the supplied changes.

      Pre-merge checks | Passed 4
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Title checkPassedThe title clearly and concisely describes the main change: moving Bitbucket support into the dedicated source-control package.
      Description checkPassedThe description clearly explains the problem, implementation, affected components, and verification results. It does not include an explicit Scope and approval section or approval link, but the remain…


      ✨ Finishing Touches 💡 1
      🛠️ Fix failing CI checks 💡
      • Commit to this branch
      • Create a new PR

      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR

      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR


      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Comment `@coderabbitai help` to get the list of available commands.
    6. juliusmarminge merged this8d1858d

    7. juliusmarminge closed this

Sign in to join this conversation.