Skip to content

Converge the Git layer onto upstream's driver, GitManager, and broadcaster - #105

Merged
henrychu04 merged 4 commits into
coder-onlyfrom
t3code/converge-upstream-git-core
Oct 6, 2026
Merged

henrychu04 merged 4 commits into
coder-onlyfrom
t3code/converge-upstream-git-core

Conversation

@henrychu04

@henrychu04 henrychu04 commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

The workspace helper runs where upstream's server runs, so there is no Coder-boundary reason for the fork to replace upstream's Git core. Because it did, every upstream fix in this area had to be found and re-ported by hand, and some were missed. This PR restores upstream's implementations from 024d49520e and keeps only the documented Coder seams.

Restored from upstream:

  • vcs/GitVcsDriver.ts and vcs/GitVcsDriverCore.ts, which replace the fork-written makeLocalGitService. Metrics and span events are stripped.
  • git/GitManager.ts and git/GitWorkflowService.ts, which replace the fork's ~1,600-line GitWorkflowService.
  • vcs/VcsStatusBroadcaster.ts, which replaces coderVcsStatus.ts.
  • git/remoteRefs.ts.
  • VcsProcess concurrency.

Coder seams, each marked Coder: in the code and listed in docs/internals/coder-only.md under "Upstream seams":

  • Driver:
    • moveWorktree, used when a thread branch rename also moves its worktree folder;
    • refStatusLocal, a branch read that never rewrites the real index;
    • 32 MiB typed review expansion;
    • single-source review;
    • bounded t3.json reads;
    • the "T3 Coder" checkpoint commit identity.
  • GitManager:
    • a provider write-access check before any MR action, so nothing is committed or pushed when writes are blocked;
    • GitLab MR templates;
    • refs/merge-requests/<n>/head fetches.
  • Broadcaster:
    • the subscribeVcsRefStatus stream;
    • per-project auto-pull;
    • a BackgroundPolicy stand-in that only polls while a status subscription is open;
    • the fetch interval from the existing setting.

Also in this PR:

  • ThreadSettlementReactor, ThreadPullRequestReactor, and storageCleanup now use GitManager, as upstream does.
  • Upstream's includeBranch commit-and-branch generation is ported, so feature branches get generated names again.
  • isProviderAvailable, getChangeRequestTerminologyForKind, isSshRemoteUrl, and the provider-aware resolveSourceControlWriterModelSelection are re-exported, as upstream exports them.

Behavior changes kept for upstream parity:

  • If an MR branch has unpushed commits and no worktree attached, preparing an MR thread can overwrite those commits.
  • Auto-pull no longer re-checks ahead/behind under the removed per-checkout mutation lock.
  • Hook tracing keeps upstream's parser. With Git 2.54 the immediate hook-exit event can be ignored, but upstream's GitManager still emits its fallback completion event after a successful commit; timing and duration can differ.
  • Status streams send local status first, then remote.
  • create_pr skips the push when the branch is already up to date.
  • New worktrees run upstream's git submodule update --init, which may fetch submodules from the network.

Phase (d), converging coderWs.ts onto upstream's ws.ts handlers, will follow as a separate stacked PR.

coder-only at c646aed1cd is merged into this branch. The conflicts preserve #104's repository-identity refresh after publish and settlement behavior alongside the restored upstream Git services. The stale coderVcsStatus.test.ts entry is removed, and the merged tree is verified.

Follow-up verification also ports upstream's Codex includeBranch test and disables detached Git auto-maintenance in temporary test repositories, preventing the ENOTEMPTY cleanup race without changing production Git behavior. A live GitLab run found that the Coder write probe needed glab api --include: GitLab can reject missing MR fields with HTTP 400 before checking the impossible project ID, and response headers supply the required GitLab fingerprint. The classifier still rejects generic proxy responses; a regression test covers this real response.

Testing

  • All typechecks pass: server, helper, web, gateway, contracts, shared, client-runtime, coder-cli.
  • Final pnpm test:server: 185 files, 2,133 tests passing, including the write-probe regression.
  • pnpm build passes.
  • Upstream's ported tests run with seam-only adaptations: GitVcsDriverCore.test.ts, GitVcsDriver.test.ts, GitManager.test.ts (GitLab replaces gh), GitWorkflowService.test.ts, and VcsStatusBroadcaster.test.ts.
  • A differential end-to-end harness drove the real helper over stdio against real git and scripted glab, claude, and ssh, comparing this branch with the original fork. Every remaining difference is intentional upstream behavior. The harness caught two bugs, both fixed here: the missing includeBranch support and a write check that only ran for remotes detected as GitLab.
  • Live integration passed through the real loopback gateway and Coder CLI into a Linux x86-64 workspace helper, using real Git, glab 1.120.0, and an isolated GitLab CE instance: discovery, write probe, feature-branch generation, commit/push, MR creation and lookup/status, checkout of a deleted-source-branch MR at its saved head, pull, ref streaming/listing, and single-source review. Only text generation was scripted. The temporary test token was revoked and both isolated test services stopped.
  • Focused final suites: 357 Git/VCS tests and 49 source-control tests pass. Server, helper, web, contracts, and shared typechecks pass after the write-probe fix.

…aster

Restore upstream GitVcsDriverCore, GitVcsDriver, GitManager, GitWorkflowService,
VcsStatusBroadcaster, and remoteRefs from 024d495, keeping only the Coder
seams documented in docs/internals/coder-only.md:

- worktree moves, index-preserving ref reads, 32 MiB typed review expansion,
  single-source review, bounded t3.json reads, and checkpoint identity
- GitLab-only process classification and the write-probe hook
- a provider write-access gate before any MR action, GitLab MR templates, and
  refs/merge-requests head fetches
- the sidebar ref stream, per-project auto-pull, and a demand-only
  BackgroundPolicy stand-in

Replace coderVcsStatus with the broadcaster, move the MR reactors and storage
cleanup onto GitManager, port upstream includeBranch commit/branch generation,
and re-export the upstream shared helpers GitManager uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 50ec58e7-ed19-4f11-b1bb-cfd11d27acba
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

henrychu04 and others added 3 commits October 5, 2026 21:34
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the overlap with #104: keep the broadcaster-based status wiring in
coderWs and add #104's repository-identity refresh after publishing, ahead of
the (now detached, as upstream) status refresh. Move the reworked settlement
tests onto GitManager. Disable Git's detached auto-maintenance in the shared
test Git config so it cannot race scoped temp-repo cleanup (ENOTEMPTY), and
point the branch-MR discovery doc at GitManager's cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@henrychu04
henrychu04 merged commit 9cae1a8 into coder-only Oct 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant