Repository navigation
fix(sync): watcher sweep reconciles a new committed change again (#163) - #164
Merged
Merged
Conversation
ViperJuice
marked this pull request as ready for review
November 22, 2026 02:31
#155 bound sweep drift to the commit it was computed against and refused it as `sweep_drift_stale` when the swept commit differed from either HEAD or the indexed commit. A commit the sweep finds at HEAD that nothing has indexed yet differs from the indexed commit by definition, so it was refused on every sweep and never reached the ordinary incremental sync the repair falls through to when HEAD has moved. Drop the swept-vs-indexed staleness condition. A sweep that saw the current HEAD now reaches the existing "not a targeted repair" branch, which runs the ordinary sync (indexed..HEAD change set) and never applies the sweep's path list to the older generation. HEAD moving after the sweep, or the published generation changing, is still refused. Adds a regression test for the branch and puts tests/test_v13_data_reconciliation.py in the protected agent gate. Fixes #163 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ViperJuice
force-pushed
the
t3/fix-sweep-commit-sync
branch
from
November 22, 2026 02:31
9c9572e to
65ba0de
Compare
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cause
#155 (e42c2c4) added a staleness check to
_repair_repository_drift_lockedthat refuses sweep drift assweep_drift_stalewhen the swept commit differs from either the current HEAD or the indexed commit (mcp_server/storage/git_index_manager.py:674-678on main):When the sweep finds a new commit at HEAD that nothing has indexed yet, the swept commit (= HEAD) differs from
last_indexed_commitby definition. So the repair refused it on every sweep and never reached the branch below it (current_commit != last_indexed_commit→ "not a targeted repair; running an ordinary sync"), which is exactly what the docstring says should happen when HEAD has moved. The failing test logged:The next sweep computed the same drift and was refused again, so the sweep stopped working as a backstop for missed commits.
Fix
Drop the swept-vs-indexed staleness condition (
git_index_manager.py:670-678). A sweep that saw the current HEAD now falls through to the existing ordinary-sync branch. That sync computes its ownindexed..HEADchange set through_get_changed_filesand ignores the sweep's path list.Why #155's guarantees still hold
current_commit == last_indexed_commit. A swept commit that isn't the indexed one only ever reaches the ordinary sync, which doesn't use the drift paths.observed_commit != current_commit) and the published generation changing (observed_index_path) are still refused assweep_drift_stale.test_sweep_drift_from_an_older_commit_is_not_applied_after_head_movesstill passes._full_index, so it proves the moved-HEAD case runs incrementally.reason="watcher sweep drift (…)".commit_movedrefusal. Not touched.git statuscleanliness gate is unchanged; the first half of the reconciliation test checks this.Tests
tests/test_issue_145_rebuild_decisions.py::test_sweep_of_an_unindexed_head_commit_runs_the_incremental_sync. The index is at commit A, HEAD is at commit B, and the sweep runs. It asserts an incremental sync of exactlychanged.py, no full rebuild,last_indexed_commit == B, nosweep_drift_stale, and a quiet second sweep. It fails with the fix reverted and passes with it.uv run --extra dev pytest tests/test_v13_data_reconciliation.py tests/test_issue_145_rebuild_decisions.py tests/test_watcher_sweep.py tests/test_sweeper_observability.py tests/test_branch_drift_rescan.py tests/test_watcher_multi_repo.py -n 2 --no-cov: 129 passed in 67 s.ruff checkandblack --checkon the changed files: clean.Agent gate
Added
tests/test_v13_data_reconciliation.pyto theagent-gate-locallist in theMakefile, whichmake agent-gateruns. Run serially as the gate runs it: 3/3 passes, 24 tests each, in 41.8 s, 45.3 s and 27.2 s on a shared host. That cost is fine for the gate.Fixes #163
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.