fix(server): stage only changed checkpoint paths - #8301
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 585a2f8. Configure here.
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This production bug fix changes the checkpoint-capture pipeline for every Git workspace, replacing full staging with autonomous status-based path selection and adding shared binary process plumbing. The behavior is well tested, but the runtime gate and cross-cutting implementation create enough staging and correctness risk to warrant human review. You can add or adjust custom eligibility rules. Learn more. |

What Changed
git statususing the real index.--pathspec-from-file.status -zoutput through pathspec stdin, including non-UTF-8 names.Why
Checkpoint capture currently builds a temporary index with
git add -A -- .. On repositories with hundreds of thousands of tracked files, that can exceed the 30-second process timeout even when only a few files changed. The missing checkpoint then prevents Latest turn diffs and summaries from loading.This change keeps the checkpoint content equivalent while limiting temporary-index staging to the paths Git already reports as changed.
Related to #3646. This PR targets large repositories with a small changed-file set. It does not claim to add failure backoff, temporary-pack cleanup, or handling for a single oversized untracked file.
Testing
vp test run apps/server/src/stream/collectUint8StreamText.test.ts apps/server/src/processRunner.test.ts apps/server/src/vcs/VcsProcess.test.ts apps/server/src/vcs/GitVcsDriver.test.tsvp lint --report-unused-disable-directives apps/server/src/vcs/GitVcsDriver.ts apps/server/src/vcs/GitVcsDriver.test.tsvp run --filter t3 typecheckgit diff --check upstream/main...HEADChecklist
Note
Medium Risk
Changes core checkpoint staging and relies on porcelain v1 byte parsing; a format mismatch could miss paths until the slower
add -Afallback runs.Overview
Checkpoint capture no longer runs
git add -A -- .on the temporary index for every capture. It runs a scoped, NUL-delimitedgit status --porcelain=v1 -z(withGIT_OPTIONAL_LOCKS=0), parses changed paths from the raw status bytes, and stages only those paths viagit add --literal-pathspecs … --pathspec-from-file=-from the repository root. Repositories withoutHEADseed the temp index withread-tree --empty. If status output is truncated or raw bytes are missing, behavior falls back to the previous scopedgit add -A -- ..Process I/O gains optional binary-safe plumbing:
stdincan beUint8Array,captureStdoutBytesreturnsstdoutBytesalongside decoded text (withstdoutInvalidUtf8), wired throughVcsProcess,processRunner, andcollectUint8StreamTextso NUL-delimited git output and pathspec stdin stay lossless.New unit and integration tests cover raw byte round-trips, exact git commands for checkpoint staging (including invalid-UTF-8 paths), and that scoped checkpoints match the working tree without mutating the real index.
Reviewed by Cursor Bugbot for commit 0f8cb9a. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
captureCheckpointto stage only changed paths via binary-safe pathspecscaptureCheckpointin GitVcsDriver.ts to rungit status --porcelain=v1 -zwithcaptureStdoutBytes, parse the raw bytes into a NUL-delimited pathspec, and feed it togit add --pathspec-from-file=- --pathspec-file-nulagainst a temp index — so only changed paths are staged instead ofgit add -AparseCheckpointStatusPathspecto extract NUL-terminated paths from porcelain status bytes, handling files with spaces or invalid UTF-8Uint8Arraystdin andcaptureStdoutBytesthroughVcsProcessandProcessRunnerso raw bytes flow end-to-end without UTF-8 corruptionresolveRepositoryRootto run the pathspec-basedgit addat the repo root so paths resolve correctlycaptureCheckpointfalls back togit add -A -- .in the scoped cwd when status output is truncated or raw bytes are unavailable; reviewers should confirm the fallback inGitVcsDriver.captureCheckpointpreserves prior behavior under large diffsMacroscope summarized 0f8cb9a.