Skip to content

fix(server): reuse Git index metadata during checkpoint capture - #10792

Open
im-kvijay wants to merge 1 commit into
pingdotgg:mainfrom
im-kvijay:fix/checkpoint-index-metadata
Open

fix(server): reuse Git index metadata during checkpoint capture#10792
im-kvijay wants to merge 1 commit into
pingdotgg:mainfrom
im-kvijay:fix/checkpoint-index-metadata

Conversation

@im-kvijay

@im-kvijay im-kvijay commented Sep 8, 2026

Copy link
Copy Markdown

What Changed

Checkpoint capture now seeds its private index from the workspace index and resets it to HEAD while retaining matching file metadata. The existing git add -A -- . then avoids rereading unchanged tracked files. The workspace index stays untouched.

Discard filesystem-monitor state during the reset. Fall back to the existing fresh-index path if copying or inspection fails, inspection is truncated, or assume-unchanged/skip-worktree flags remain.

Why

Starting with a fresh index throws away Git's stat cache on every capture. Reusing it reduces unnecessary work in large repositories while preserving scoped staging and snapshot contents.

Related to #3646; independent of the failed-write cleanup in #9809. Builds on the index-reuse approach explored in #8538, with a fresh-index fallback instead of normalizing special flags. Unlike #8301, this keeps native add -A staging rather than parsing changed paths. Discussion: #9808 (comment).

Validation

  • 38 tests pass across GitVcsDriver, CheckpointStore, and VcsProcess; server typecheck, targeted lint, and formatting pass.
  • The unchanged-file clean-filter regression fails on main and passes here. Tests cover two consecutive captures at root/nested directories, staged/unstaged/deleted/untracked files, special flags, split indexes, missing/corrupt indexes, and an unchanged workspace index.
  • Five paired complete captures on a 40,000-file fixture (10 modified, one untracked): median 242.5 ms → 74.1 ms (about 3.3× faster). Every paired snapshot tree matched and the workspace index remained byte-identical. Baseline: 061543e9e.

The 30-second timeout is unchanged. Large new or modified files still need hashing; this does not claim to resolve every timeout in #3646.

Checklist

  • This PR is small and focused
  • I explained what changed and why

Implemented and verified with GPT-6 Astra through the Codex harness.

Summary by CodeRabbit

  • Bug Fixes
    • Checkpoint capture now preserves existing file state more reliably, including staged, deleted, newly added, and specially tracked files.
    • Improved handling of missing or invalid Git index states, with graceful fallback behavior.
    • Avoided unnecessary filter processing for unchanged indexed files during checkpoint capture.
    • Checkpoint reuse now better preserves the original index across different repository configurations.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 8, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at e2e772f

Macroscope's review found this PR approvable — The change is a localized checkpoint-capture optimization with explicit fallback to the existing behavior and broad tests for Git index variants, filters, and scoped captures. It does not add a user-facing capability, alter schemas or defaults, or affect deployment, security, billing, or authentication.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 5e7309d2-1a06-4578-950f-230dc6f63c64

📥 Commits

Reviewing files that changed from the base of the PR and between 061543e and e2e772f.

📒 Files selected for processing (2)
  • apps/server/src/vcs/GitVcsDriver.test.ts
  • apps/server/src/vcs/GitVcsDriver.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

captureCheckpoint now reuses compatible Git index state before creating a checkpoint. Tests cover unchanged-file filters, repeated captures, index modes, staged work, and missing or invalid indexes.

Changes

Checkpoint capture

Layer / File(s) Summary
Working index reuse and fallback
apps/server/src/vcs/GitVcsDriver.ts
captureCheckpoint copies and resets the working index when possible. It falls back to rebuilding the temporary index when flags, truncation, or index errors prevent reuse.
Checkpoint preservation tests
apps/server/src/vcs/GitVcsDriver.test.ts
Tests verify filter avoidance, repeated checkpoint capture, index-mode handling, preservation of staged and special files, and fallback for missing or invalid indexes.

Priority: ➖ Normal — Schedule the Git checkpoint performance change because it reduces capture time in large repositories while preserving snapshot contents and workspace index state.

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

Merge Risk: ⚪ Minimal · up to e2e77

Checkpoint capture should become faster while preserving snapshot contents and the workspace index; the supplied validation shows no actionable merge-blocking risk.

Suggested reviewers: t3dotgg

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: reusing Git index metadata during checkpoint capture.
Description check ✅ Passed The description includes the required What Changed, Why, and Checklist sections. It explains the fallback behavior, validation results, performance impact, and confirms that the workspace index remain…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant