Skip to content

🐛 fix(sink/git): push stranded commit so warm-mirror can't report Synced=true unpushed (REL-06) - #173

Merged
konih merged 1 commit into
mainfrom
fix/rel-06-git-ahead-push
Aug 3, 2026
Merged

konih merged 1 commit into
mainfrom
fix/rel-06-git-ahead-push

Conversation

@konih

@konih konih commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Audit finding REL-06 (P2; P1 for engine: cli) — silent data non-delivery.

Bug: the warm-mirror git-CLI export path reported Synced=true when the local branch was AHEAD of origin/<pushBranch> (a committed-but-unpushed snapshot stranded). Root cause: the clean check compared working-tree vs HEAD, not local vs remote.

Fix: on a clean tree, syncCLIWorkdir now consults the remote via remoteHasLocalHead (ls-remote refs/heads/<pushBranch> vs local HEAD) and only returns success without pushing when the remote already holds the local HEAD; otherwise it pushes the stranded commit. Fail-safe: any ls-remote/rev-parse error aborts the export rather than falsely reporting synced. Dirty/hot path unchanged (exactly one push per path).

TDD: TestSyncCLIWorkdir_pushesStrandedCommitWhenTreeClean (fails on revert) + TestSyncCLIWorkdir_noPushWhenRemoteAlreadyHasHead. Gates green (test/vet/fmt/lint/build).

Independent review: APPROVE, no P0/P1 — traced all Synced=true paths, confirmed fail-safe. P2 follow-up (non-blocking): add an explicit ls-remote-failure error-path test.

Disjoint from all other lanes (sink/git only).

…-mirror can't report Synced=true with an unpushed commit (REL-06)
Copilot AI review requested due to automatic review settings August 3, 2026 12:18
@konih
konih merged commit 81d0500 into main Aug 3, 2026
23 checks passed
@konih
konih deleted the fix/rel-06-git-ahead-push branch August 3, 2026 12:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes REL-06 in the git CLI export path by ensuring “Synced=true” is only reported when the remote actually contains the local HEAD, preventing silent non-delivery when a warm mirror has a committed-but-unpushed snapshot.

Changes:

  • Refactors CLI export syncing into syncCLIWorkdir, adding a remote-vs-local HEAD check on clean trees and pushing stranded commits when needed.
  • Introduces remoteHasLocalHead (via git ls-remote + rev-parse) to validate remote state fail-safe before skipping push.
  • Adds TDD coverage for both the stranded-commit push and the “already synced => no push” behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
internal/sink/git/export_file.go Adds syncCLIWorkdir to prevent false “synced” results by validating remote state and pushing stranded commits when necessary.
internal/sink/git/export_ahead_test.go Adds regression tests reproducing REL-06 and proving the “no push when already synced” gate.
internal/sink/git/exec_git.go Adds remoteHasLocalHead and remoteSHAFromLsRemote to query remote refs directly via ls-remote.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +298 to +309
func remoteSHAFromLsRemote(out string) string {
line := strings.TrimSpace(out)
if line == "" {
return ""
}

if idx := strings.IndexAny(line, " \t"); idx >= 0 {
return line[:idx]
}

return line
}
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.33333% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/sink/git/exec_git.go 54.16% 6 Missing and 5 partials ⚠️
internal/sink/git/export_file.go 66.66% 2 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
78.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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.

2 participants