Skip to content
Source
Sign inSign up
pingdotgg/t3code

refactor(source-control): add @t3tools/source-control-core #17573

Mergedjuliusmarmingemerged 4 commits intomain fromrefs/pull/17573/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Source control providers (GitHub, GitLab, Forgejo, Azure DevOps, Bitbucket) live inside apps/server and reach into its services directly, so adding one means editing files across the repo. This is the first layer of moving each provider into its own package, the way the agent providers moved into @t3tools/provider-*.

This layer adds @t3tools/source-control-core:

  • server/SourceControlHost is the narrow port a provider package may use (settings and the process runner), mirroring ProviderHost. ServerSourceControlHost implements it once. Git checkout operations join the port with the GitHub and Bitbucket layers, which are the ones that need them.
  • The SourceControlProvider and PullRequestProvider interfaces, discovery specs, the per-host SourceControlRateLimit, and the shared mergeMessage and pullRequestChecks helpers move unchanged. Their tests move with them.
  • Discovery now runs CLIs through the host port instead of VcsProcess, so the registry's R channel names SourceControlHost.

Behavior is unchanged: same messages, settings keys, and wire shapes. The service keys now match their module paths.

Next layers: one package per provider (Forgejo first, GitHub last), then client definitions, then removal of the leftover registries.

Verified with tsc (apps/server, source-control-core), knip, and 44 moved or touched test files (1224 tests).

Known gap, tracked in #17608: the moved discovery helpers, PullRequestService.withRateLimitBackoff, and GitHub's stack-action wiring still pass service instances as arguments or re-provide captured ones, which is against the Effect service convention. That predates this stack, and the move carried it over unchanged. The cleanup lands after the stack merges.

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

    1. juliusmarminge changed the title

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

    3. juliusmarminge added labelsmacroscope-review

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

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR introduces a new source-control package and host-service boundary while rewiring provider discovery and production server layers across many files. Although the moved logic is mostly unchanged and no defaults or static-analysis overrides were found, the shared runtime architecture warrants human review.

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

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire4.9 KiB5.0 KiB+23 B (+0.5%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB+23 B (+1.9%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.8 KiB20.9 KiB+41 B (+0.2%)29.3 KiB✅
      CodexLive turn messages12+1 (+100.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: 0e7abea · PR result: 2400cfa · 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.

    6. 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: 63e07b27-1bf5-4de1-9084-47e7969fa1d0

      📥 Commits

      Reviewing files that changed from the base of the PR and between 46be6115fbd9b684db64a9696e71428d6b9ccebc and 2400cfaf36dc93f42b58194e6ab8205fc4406f0a.


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

      📒 Files selected for processing (64)
      • apps/server/package.json
      • apps/server/scripts/evaluate-thread-titles.ts
      • apps/server/scripts/measure-pr-preview.ts
      • apps/server/src/git/GitManager.test.ts
      • apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts
      • apps/server/src/orchestration-v2/PullRequestSyncReactor.ts
      • apps/server/src/orchestration-v2/PullRequestWatchReactor.ts
      • apps/server/src/orchestration-v2/runtimeLayer.test.ts
      • apps/server/src/pullRequest/AzureDevOpsPullRequestCli.ts
      • apps/server/src/pullRequest/AzureDevOpsPullRequestProvider.ts
      • apps/server/src/pullRequest/BitbucketPullRequestApi.ts
      • apps/server/src/pullRequest/BitbucketPullRequestProvider.ts
      • apps/server/src/pullRequest/ForgejoPullRequestProvider.ts
      • apps/server/src/pullRequest/GitHubPullRequestApi.test.ts
      • apps/server/src/pullRequest/GitHubPullRequestApi.ts
      • apps/server/src/pullRequest/GitHubPullRequestProvider.ts
      • apps/server/src/pullRequest/GitLabPullRequestCli.ts
      • apps/server/src/pullRequest/GitLabPullRequestProvider.ts
      • apps/server/src/pullRequest/PullRequestProviderRateLimit.test.ts
      • apps/server/src/pullRequest/PullRequestProviderRegistry.ts
      • apps/server/src/pullRequest/PullRequestService.test.ts
      • apps/server/src/pullRequest/PullRequestService.ts
      • apps/server/src/pullRequest/bitbucketPullRequestJson.ts
      • apps/server/src/pullRequest/forgejoPullRequestJson.ts
      • apps/server/src/pullRequest/gitHubConditionalChecks.ts
      • apps/server/src/pullRequest/gitHubPullRequestJson.ts
      • apps/server/src/pullRequest/pullRequestViewedFiles.ts
      • apps/server/src/server.ts
      • apps/server/src/sourceControl/AzureDevOpsCli.ts
      • apps/server/src/sourceControl/AzureDevOpsSourceControlProvider.ts
      • apps/server/src/sourceControl/BitbucketApi.ts
      • apps/server/src/sourceControl/BitbucketSourceControlProvider.ts
      • apps/server/src/sourceControl/ForgejoCli.ts
      • apps/server/src/sourceControl/ForgejoSourceControlProvider.ts
      • apps/server/src/sourceControl/GitHubApi.test.ts
      • apps/server/src/sourceControl/GitHubApi.ts
      • apps/server/src/sourceControl/GitHubSourceControlProvider.ts
      • apps/server/src/sourceControl/GitLabCli.ts
      • apps/server/src/sourceControl/GitLabSourceControlProvider.ts
      • apps/server/src/sourceControl/ServerSourceControlHost.ts
      • apps/server/src/sourceControl/SourceControlDiscovery.test.ts
      • apps/server/src/sourceControl/SourceControlDiscovery.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/githubQuota.test.ts
      • apps/server/src/sourceControl/githubQuota.ts
      • apps/server/src/ws.ts
      • docs/internals/pull-request-file-revisions.md
      • package.json
      • packages/source-control-core/package.json
      • packages/source-control-core/src/server/PullRequestProvider.ts
      • packages/source-control-core/src/server/SourceControlHost.ts
      • packages/source-control-core/src/server/SourceControlProvider.test.ts
      • packages/source-control-core/src/server/SourceControlProvider.ts
      • packages/source-control-core/src/server/SourceControlRateLimit.test.ts
      • packages/source-control-core/src/server/SourceControlRateLimit.ts
      • packages/source-control-core/src/server/discovery.ts
      • packages/source-control-core/src/server/mergeMessage.test.ts
      • packages/source-control-core/src/server/mergeMessage.ts
      • packages/source-control-core/src/server/pullRequestChecks.test.ts
      • packages/source-control-core/src/server/pullRequestChecks.ts
      • packages/source-control-core/tsconfig.json
      • scripts/release-smoke.ts

      💤 Files with no reviewable changes (7)
      • packages/source-control-core/src/server/pullRequestChecks.test.ts
      • packages/source-control-core/src/server/SourceControlProvider.test.ts
      • packages/source-control-core/src/server/pullRequestChecks.ts
      • packages/source-control-core/src/server/mergeMessage.ts
      • packages/source-control-core/src/server/SourceControlRateLimit.test.ts
      • packages/source-control-core/src/server/mergeMessage.test.ts
      • packages/source-control-core/src/server/PullRequestProvider.ts

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



      📝 Walkthrough

      Walkthrough

      The pull request adds the @t3tools/source-control-core package and a shared source-control host contract. The server provides the host service and updates source-control discovery, provider, and pull-request code to import shared modules. The root Knip command adds packages/provider-grok to its workspace checks.

      Changes

      Source-control core extraction

      Layer / File(s)Summary
      Shared package contracts and exports
      packages/source-control-core/package.json, packages/source-control-core/src/server/*, packages/source-control-core/tsconfig.json, docs/internals/pull-request-file-revisions.md, scripts/release-smoke.ts
      Adds package exports and the SourceControlHost contract. Updates discovery process types and shared service identifiers. The release smoke fixture includes the package manifest, and the documentation link points to the shared provider contract.
      Server host and registry wiring
      apps/server/src/sourceControl/ServerSourceControlHost.ts, apps/server/src/sourceControl/SourceControlProviderRegistry.ts, apps/server/src/server.ts, apps/server/src/ws.ts, apps/server/src/sourceControl/SourceControlDiscovery.test.ts, apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts, apps/server/scripts/evaluate-thread-titles.ts
      Maps server settings and VCS process services to the shared host contract. Adds the host layer to provider registry setup and tests.
      Source-control consumers use shared modules
      apps/server/package.json, apps/server/src/sourceControl/*, apps/server/src/git/GitManager.test.ts, apps/server/scripts/measure-pr-preview.ts
      Updates source-control provider, discovery, and rate-limit imports to use the shared package.
      Pull-request consumers use shared modules
      apps/server/src/pullRequest/*, apps/server/src/orchestration-v2/*
      Updates pull-request provider, rate-limit, merge-message, and check imports to use shared package modules.

      Workspace check update

      Layer / File(s)Summary
      Knip workspace list
      package.json
      Adds packages/provider-grok to the workspaces checked by knip:check.

      Priority: ⬇️ Low

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

      Change: Refactor

      Sequence Diagram(s)

      sequenceDiagram
        participant ServerSettingsService
        participant VcsProcess
        participant ServerSourceControlHost
        participant SourceControlProviderRegistry
        ServerSettingsService->>ServerSourceControlHost: provide settings getter
        VcsProcess->>ServerSourceControlHost: provide process runner
        ServerSourceControlHost->>SourceControlProviderRegistry: provide SourceControlHost layer

      Suggested reviewers: maria-rcks


      Merge Risk: ⚪ Minimal · up to 2400c

      No actionable issue is established for this change; it is mergeable after normal checks.

      Pre-merge checks | Passed 3 | Failed 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Description checkWarningThe description explains the problem, implementation, behavior impact, verification, and known gap. It does not provide the required triaged issue or maintainer approval for the refactor scope.Add a link to the triaged issue or approval discussion, including the maintainer approval comment and confirmation of the direction and scope. Use explicit Problem, Change, Scope and approval, and Verification sections if needed.
      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Title checkPassedThe title clearly identifies the main change: adding the @t3tools/source-control-core package as a source-control refactor.
      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.


      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      📝 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.
    7. juliusmarminge merged this28f11ed

    8. juliusmarminge closed this

Sign in to join this conversation.