fix(git-sync): measure ahead_working against the agent's own branch (#2105) - #3025
Merged
Merged
Conversation
…2105) `_dual_ahead_behind_payload` measured the working tuple against `origin/<current_branch>` only for `trinity/*` branches. Every other branch got the `origin/main` counts under the working label. The fleet audit reads `ahead_working` as unpushed commits, so a fleet renamed to `asus/*` reported ~9,000 unpushed commits while the true gap was 0. - The working tuple uses `origin/<current_branch>` whatever the branch is named. - With no upstream (never pushed, detached HEAD), `ahead_working` counts the commits no remote holds, and `behind_working` is null. - A count that can't be computed is null, never 0. This covers the main tuple on a `master` repo with no `main`, which read 0 ahead for 7 days while one commit sat unpushed. The backend already stores null as 0, and the UI checks `> 0`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…mechanical, per the merge-train note on the PR `ahead` aliases the main tuple, which this PR makes None on a repo with no `main`; `None == 0` is false, so a clean `master` repo flipped from "Synced" to "Changes pending". Restores dev's behaviour on that line. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
|
merge-train: pushed two commits to this branch (mechanical, no change to the fix's intent):
Follow-up for you, not a blocker: should Riding the current merge train. |
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.
Summary
_dual_ahead_behind_payload(agent server,docker/base-image/agent_server/routers/git.py) measured the working tuple againstorigin/<current_branch>only fortrinity/*branches. Every other branch got theorigin/maincounts under theahead_working/behind_workinglabel.fleet_audit_servicereadsahead_workingas unpushed commits, so a fleet renamed toasus/*reported ~9,000 unpushed commits while the true gap was 0.origin/<current_branch>whatever the branch is named. The prefix gate is gone.ahead_workingcounts the commits that no remote holds (rev-list HEAD --not --remotes), andbehind_workingisnull. A detached HEAD is never compared withorigin/HEAD, because that is the default branch, not the agent's.null, never 0. This is the second field report on the issue: amasterrepo with nomainread 0 ahead for 7 days while one commit sat unpushed. Now the working tuple reports 1, and the main tuple (plus the legacyahead/behindaliases) isnullrather than a believable 0. Consumers are already null-safe:sync_health_service._coerce_counterstoresnullas 0, and the UI checks> 0or|| 0._compute_ahead_behind(the conflict classifier's best-effort(0, 0)) is unchanged.This unblocks the numbers that trinity-enterprise#706 (divergence age) and #707 (sync surfaces) key on.
Tests
tests/unit/test_git_status_dual_ahead_behind.py: 5 new tests over real git repos:asus/*branch far from main reports 0 unpushedtrinity/*branchmasterrepo with nomaintrinity/*branchMutation check: with the pre-fix function restored, 5 of 12 go red.
Related suites: 197 passed (sync health, fleet audit, sync state, bug: git auto-gc can never complete inside agent containers — unbounded, silent workspace .git bloat (273GB observed; 97%-garbage repos) #1595/bug: git-sync agent workspaces grow unboundedly — auto-committed data churn bloats .git (44GB observed on one agent) #1596 signals, git status / bug(sync-health): the 60s poller takes .git/index.lock ~2×/min in every agent workspace and orphans a 0-byte lock on churn — silent commit failures fleet-wide #2742).
Live check inside a running agent container on the local instance. I loaded the patched module beside the installed one; the running server was not modified. It ran read-only against the real workspace, and against throwaway repos for the rename case. Fields are [ahead_main, behind_main, ahead_working, behind_working]:
main[0,0,0,0][0,0,0,0]asus/*pushed, in sync[5,0,5,0][5,0,0,0]asus/*+ 1 unpushed[6,0,6,0][6,0,1,0][6,0,6,0][6,0,1,null]Notes
feature-flows/git-sync-health.mdare updated.sync_status: "pending_sync"on in-sync workspaces, andgit_syncreturningfiles_changed: 0for committed-but-unpushed work.dev, and fix(git-sync): auto-sync heartbeat fetches and rebases before push; refuses on a shared source-mode branch (#3011) #3016 / feat(git-sync): an agent created as an agent owns its repository (trinity-enterprise#705) #3020 / feat(git-sync): the container pulls origin on its own (trinity-enterprise#703) #3021 don't touch this function.Fixes #2105
🤖 Generated with Claude Code