Skip to content

✅ test(sink/git): lock REL-06 ls-remote fail-safe (REL-06-FUP) - #188

Merged
konih merged 1 commit into
mainfrom
test/rel-06-fup-ls-remote-error
Aug 3, 2026
Merged

konih merged 1 commit into
mainfrom
test/rel-06-fup-ls-remote-error

Conversation

@konih

@konih konih commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Lane: REL-06-FUP (P2, test-only)

Locks the REL-06 git-sink fail-safe with the missing regression test the REL-06 reviewer flagged.

Background

REL-06 (PR #173) fixed a warm-mirror git sink that reported Synced=true while a commit was stranded unpushed. syncCLIWorkdir now checks remoteHasLocalHead via git ls-remote and is FAIL-SAFE: on an ls-remote failure it ABORTS (returns a non-nil error) rather than reporting false-synced. That error path was guaranteed only by trivial error propagation and was not directly tested.

What this adds

TestSyncCLIWorkdir_abortsOnLsRemoteFailure in internal/sink/git/export_ahead_test.go. Test-only; no production change.

The harness commits a stranded snapshot (local ahead of remote, tree clean) and splits the origin's URLs so the failure is isolated to the read path:

  • remote.origin.url -> a nonexistent bare (git ls-remote exits 128, so the read fails)
  • remote.origin.pushurl -> the real bare (a push, if reached, would succeed)

Asserts the fail-safe holds:

  1. syncCLIWorkdir returns a non-nil error wrapped from the git ls-remote failure.
  2. The remote is still at C0 -- no stranded snapshot was delivered.

RED-meaningful

The url/pushurl split makes it discriminating. A regression that swallows the ls-remote error (returns not-synced instead of propagating) falls through and pushes to the valid pushurl, advancing the remote and returning nil. Demonstrated locally by temporarily changing remoteHasLocalHead to return false, nil on ls-remote failure: the test fails on syncCLIWorkdir() = nil, want ls-remote failure to abort. Reverted; production code is unchanged.

Gate matrix (all green)

  • go build ./... - pass
  • go vet ./... - pass
  • task lint - 0 issues; arch-lint OK
  • task test - pass
  • task verify - ok
  • task coverage - internal/ coverage 86.6% (floor 85%)

Hermetic: no network; local bare repos and a nonexistent file:// path only.

Copilot AI review requested due to automatic review settings August 3, 2026 18:13

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

Adds a targeted regression test to pin the REL-06 “fail-safe” behavior in the git CLI sink: when git ls-remote cannot reach the remote, syncCLIWorkdir must abort with an error (rather than incorrectly reporting synced or pushing a stranded local commit).

Changes:

  • Introduces TestSyncCLIWorkdir_abortsOnLsRemoteFailure to assert non-nil error propagation from ls-remote failures.
  • Uses a remote.origin.url vs remote.origin.pushurl split to ensure the failure is isolated to the read/verification path while a push would still succeed in a regression.
  • Verifies the remote HEAD remains unchanged (no accidental delivery) when the sync aborts.

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

@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@konih
konih merged commit 8334dc2 into main Aug 3, 2026
29 of 31 checks passed
@konih
konih deleted the test/rel-06-fup-ls-remote-error branch August 3, 2026 18:25
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