Repository navigation
fix(#6337): add SHA ancestry check to upgrade downgrade guard - #6338
Conversation
|
🤖 Finished Review · ✅ Success · Started 7:00 PM UTC · Completed 7:18 PM UTC Commit: |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
Looks good to me Previous runReviewFindingsLow
Labels: PR is a bug fix for SHA-pinned scaffold downgrade detection Previous run (2)ReviewFindingsMedium
Low
Labels: PR fixes the repos upgrade downgrade guard, which is part of the install/upgrade component |
|
/fs-fix - Rebase. Fix all the review issues, respond to and resolve all conversations, and fix the CI code coverage test. |
|
🤖 Finished Fix · ✅ Success · Started 7:22 PM UTC · Completed 7:34 PM UTC Commit: |
The semver downgrade guard in upgradeRepo() was gated on both refs being semver tags. When either ref is a SHA — the case for SHA-pinned repos and all GitLab repos — the guard was bypassed entirely, allowing silent downgrades. Add a CompareCommits method to the forge.Client interface that maps to the GitHub Compare API (and GitLab's equivalent). Use it in a new RefResolver.IsAncestor method to detect when the target SHA is an ancestor of the current SHA. The upgrade logic now checks SHA ancestry after the semver guard, skipping with the same "is a downgrade (use --force to allow)" message. API errors degrade gracefully — the upgrade proceeds if the comparison fails. Closes #6337
- Fix GitLab CompareCommits to properly detect "behind" status by adding a reverse comparison call when the forward comparison shows diffs but no commits, and update the doc comment to accurately describe the two-call behavior (api-contract finding) - Wrap error in RefResolver.IsAncestor with context for easier debugging (error-handling-idiom finding) - Add TestUpgrade_TagCurrentSHATargetDowngradeBlocked to cover the tag-current/SHA-target code path (test-coverage-gap finding) - Add unit tests for CompareCommits in fake, github, and gitlab packages to bring patch coverage above the 80% threshold Addresses review feedback on #6338
🔧 Fix agent — iteration 1 (human-triggered)Addressed all 3 review findings (api-contract, error-handling-idiom, test-coverage-gap) and fixed CI code coverage by adding unit tests for CompareCommits across all forge implementations. Rebased onto main. All functions in changed files show >=83% coverage, well above the 80% threshold. Fixed (7):
Tests: passedNext steps:
|
cda6ada to
6d066ea
Compare
|
🤖 Finished Review · ✅ Success · Started 7:36 PM UTC · Completed 7:49 PM UTC Commit: |
|
/fs-fix - Rebase. Fix all the review issues, respond to and resolve all conversations. |
|
🤖 Finished Fix · ✅ Success · Started 7:55 PM UTC · Completed 8:04 PM UTC Commit: |
- Fix GitLab CompareCommits to correctly detect diverged commits by always making both forward and reverse API calls when the forward call returns any diffs or commits. Previously, forward commits caused an early "ahead" return, masking truly diverged histories where both directions have unique commits. - Add test for diverged-with-commits-both-directions and update ahead test to verify both API calls are made. - Document SHA-based downgrade detection in repo-management guide, explaining that ancestry checking via the forge API covers SHA-pinned and mixed (SHA/tag) refs with graceful degradation on API errors. Addresses review feedback on #6338
🔧 Fix agent — iteration 2 (human-triggered)Addressed all 2 review findings (api-contract, incomplete-coverage). Fixed GitLab CompareCommits to correctly detect diverged commits by always making both forward and reverse API calls, added test coverage for the new behavior, and documented SHA-based downgrade detection in the repo-management guide. Fixed (3):
Tests: passedNext steps:
|
|
🤖 Review · ❌ Terminated · Started 8:06 PM UTC · Ended 8:20 PM UTC Commit: |
Site previewPreview: https://155822f5-site.fullsend-ai.workers.dev Commit: |
|
🤖 Finished Review · ✅ Success · Started 8:06 PM UTC · Completed 8:20 PM UTC Commit: |
|
🤖 Finished Retro · ❌ Failure · Started 8:50 PM UTC · Completed 8:50 PM UTC Commit: |
Summary
Add SHA-based downgrade detection to the
repos upgradecommand. The existing semver downgrade guard only applied when both the current and target refs were semver tags — SHA-pinned repos bypassed the guard entirely, allowing silent scaffold downgrades.Related Issue
Changes
CompareCommitsmethod toforge.Clientinterface with implementations for GitHub (REST compare API) and GitLab (repository compare endpoint)FakeClient.CommitAncestrymap for testing commit ancestry in the test doubleRefResolver.IsAncestormethod that usesCompareCommitsto check git ancestry onfullsend-ai/fullsendupgradeRepo()after the existing semver guard — resolves both refs to SHAs (if needed) and uses ancestry checking to detect downgrades--forceflag bypasses the SHA guard, matching the semver guard behaviorTesting
TestUpgrade_SHADowngradeBlocked— both refs are SHAs, target is ancestor → skipped with downgrade messageTestUpgrade_SHADowngradeForceAllowed—--forcebypasses SHA downgrade guardTestUpgrade_SHAUpgradeProceeds— target is descendant of current → upgrade proceedsTestUpgrade_SHADowngradeCompareErrorProceeds— API error degrades gracefully, upgrade proceedsTestUpgrade_SHACurrentTagTargetDowngradeBlocked— SHA current + tag target → tag resolved to SHA, downgrade detectedCloses #6337
Post-script verification
agent/6337-sha-downgrade-guard)9ecbd9b395b0e00a10f2a959b7e83503ff718bd1..HEAD)