refactor(source-control): add @t3tools/source-control-core #17573
main fromrefs/pull/17573/head·merged by juliusmarminge View on GitHubSource 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/SourceControlHostis the narrow port a provider package may use (settings and the process runner), mirroringProviderHost.ServerSourceControlHostimplements it once. Git checkout operations join the port with the GitHub and Bitbucket layers, which are the ones that need them.- The
SourceControlProviderandPullRequestProviderinterfaces, discovery specs, the per-hostSourceControlRateLimit, and the sharedmergeMessageandpullRequestCheckshelpers move unchanged. Their tests move with them. - Discovery now runs CLIs through the host port instead of
VcsProcess, so the registry'sRchannel namesSourceControlHost.
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
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge added labelsmacroscope-review
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 4.9 KiB 5.0 KiB +23 B (+0.5%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB +23 B (+1.9%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.8 KiB 20.9 KiB +41 B (+0.2%) 29.3 KiB ✅ Codex Live turn messages 1 2 +1 (+100.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅ Claude Live turn messages 2 2 0 (0.0%) 8 ✅ Baseline:
0e7abea· PR result:2400cfa· Source CI: successScenario 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.
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.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (64)
apps/server/package.jsonapps/server/scripts/evaluate-thread-titles.tsapps/server/scripts/measure-pr-preview.tsapps/server/src/git/GitManager.test.tsapps/server/src/orchestration-v2/PullRequestSyncReactor.test.tsapps/server/src/orchestration-v2/PullRequestSyncReactor.tsapps/server/src/orchestration-v2/PullRequestWatchReactor.tsapps/server/src/orchestration-v2/runtimeLayer.test.tsapps/server/src/pullRequest/AzureDevOpsPullRequestCli.tsapps/server/src/pullRequest/AzureDevOpsPullRequestProvider.tsapps/server/src/pullRequest/BitbucketPullRequestApi.tsapps/server/src/pullRequest/BitbucketPullRequestProvider.tsapps/server/src/pullRequest/ForgejoPullRequestProvider.tsapps/server/src/pullRequest/GitHubPullRequestApi.test.tsapps/server/src/pullRequest/GitHubPullRequestApi.tsapps/server/src/pullRequest/GitHubPullRequestProvider.tsapps/server/src/pullRequest/GitLabPullRequestCli.tsapps/server/src/pullRequest/GitLabPullRequestProvider.tsapps/server/src/pullRequest/PullRequestProviderRateLimit.test.tsapps/server/src/pullRequest/PullRequestProviderRegistry.tsapps/server/src/pullRequest/PullRequestService.test.tsapps/server/src/pullRequest/PullRequestService.tsapps/server/src/pullRequest/bitbucketPullRequestJson.tsapps/server/src/pullRequest/forgejoPullRequestJson.tsapps/server/src/pullRequest/gitHubConditionalChecks.tsapps/server/src/pullRequest/gitHubPullRequestJson.tsapps/server/src/pullRequest/pullRequestViewedFiles.tsapps/server/src/server.tsapps/server/src/sourceControl/AzureDevOpsCli.tsapps/server/src/sourceControl/AzureDevOpsSourceControlProvider.tsapps/server/src/sourceControl/BitbucketApi.tsapps/server/src/sourceControl/BitbucketSourceControlProvider.tsapps/server/src/sourceControl/ForgejoCli.tsapps/server/src/sourceControl/ForgejoSourceControlProvider.tsapps/server/src/sourceControl/GitHubApi.test.tsapps/server/src/sourceControl/GitHubApi.tsapps/server/src/sourceControl/GitHubSourceControlProvider.tsapps/server/src/sourceControl/GitLabCli.tsapps/server/src/sourceControl/GitLabSourceControlProvider.tsapps/server/src/sourceControl/ServerSourceControlHost.tsapps/server/src/sourceControl/SourceControlDiscovery.test.tsapps/server/src/sourceControl/SourceControlDiscovery.tsapps/server/src/sourceControl/SourceControlProviderRegistry.test.tsapps/server/src/sourceControl/SourceControlProviderRegistry.tsapps/server/src/sourceControl/SourceControlRepositoryService.test.tsapps/server/src/sourceControl/githubQuota.test.tsapps/server/src/sourceControl/githubQuota.tsapps/server/src/ws.tsdocs/internals/pull-request-file-revisions.mdpackage.jsonpackages/source-control-core/package.jsonpackages/source-control-core/src/server/PullRequestProvider.tspackages/source-control-core/src/server/SourceControlHost.tspackages/source-control-core/src/server/SourceControlProvider.test.tspackages/source-control-core/src/server/SourceControlProvider.tspackages/source-control-core/src/server/SourceControlRateLimit.test.tspackages/source-control-core/src/server/SourceControlRateLimit.tspackages/source-control-core/src/server/discovery.tspackages/source-control-core/src/server/mergeMessage.test.tspackages/source-control-core/src/server/mergeMessage.tspackages/source-control-core/src/server/pullRequestChecks.test.tspackages/source-control-core/src/server/pullRequestChecks.tspackages/source-control-core/tsconfig.jsonscripts/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-corepackage 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 addspackages/provider-grokto 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.tsAdds package exports and the SourceControlHostcontract. 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.tsMaps 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.tsUpdates 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.jsonAdds packages/provider-grokto the workspaces checked byknip: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 layerSuggested reviewers:
maria-rcks
Merge Risk: ⚪ Minimal · up to
2400cNo actionable issue is established for this change; it is mergeable after normal checks.
Pre-merge checks |
3 | 1❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Description check The 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 name Status Explanation Title check The title clearly identifies the main change: adding the @t3tools/source-control-corepackage as a source-control refactor.Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check 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.juliusmarminge merged this28f11ed
juliusmarminge closed this
Sign in to join this conversation.
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).