Skip to content

Add fetch-replay regression tests for diverged/disconnected checkpoint metadata#1260

Open
Soph wants to merge 3 commits into
config-permfrom
soph/checkpoint-ref-sync-tests
Open

Add fetch-replay regression tests for diverged/disconnected checkpoint metadata#1260
Soph wants to merge 3 commits into
config-permfrom
soph/checkpoint-ref-sync-tests

Conversation

@Soph
Copy link
Copy Markdown
Collaborator

@Soph Soph commented May 25, 2026

Summary

Adds 7 new tests covering the FetchMetadataBranch behavior introduced by PR #1252 and the in-flight replay work in PR #1251 (config-perm). Pairs with the existing fast-forward / no-rewind contract tests in checkpoint_remote_test.go.

Tests

cmd/entire/cli/strategy/replay_disconnected_test.go (Groups A + E)

Test Status on main What it locks
TestFetchMetadataBranch_DivergedLocal_ReplaysOntoRemote FAIL Local A→B, origin A→C → after fetch local must reach C with B's tree applied. Reproduces the gap PR #1252 left open.
TestFetchMetadataBranch_DisconnectedEmptyRoot_FiltersOrphan FAIL Disconnected local rooted at an empty-tree "orphan-bug" commit; the empty root must be filtered before replay. (Review finding C1.)
TestFetchMetadataBranch_DisconnectedMultiCommit_PreservesAllLocalData FAIL 3-commit local chain + disconnected remote — all 3 local files AND the remote tip must be reachable. (Review finding M1.)
TestFetchMetadataBranch_ShallowClone_RefusesReplayAcrossBoundary PASS Shallow boundary hides ancestry — fetch must not silently merge unrelated histories. Permits either "error" or "no-op preserve" as safe outcomes.
TestFetchMetadataBranch_ShallowBoundary_ErrorIsActionable SKIP When the shallow case surfaces an error, it must mention doctor / --unshallow (review M3). Skips on main because the preserve-on-divergence path returns no error.

cmd/entire/cli/integration_test/diverged_replay_test.go (Groups C + D)

Test Status on main What it locks
TestResume_StaleLocalMetadata_RemoteHasNewerCheckpoint PASS End-to-end PR #1252 reproducer via real CLI binary + bare remote: stale local metadata branch + advanced origin → entire session resume <branch> must not say "session log not available". Catches wiring regressions the unit test would miss.
TestPushAfterDiverged_NoDoubleReplayCommits PASS After divergence-then-push, the merged metadata branch must have exactly 3 commits (root + A + B rebased), not 4. Guards against the architectural concern from review finding H1 (double-replay if both SafelyAdvanceLocalRef and ReconcileDisconnectedMetadataBranch cherry-pick the same commits).

Expected outcome once #1251 merges

Test After #1251 (as written) After #1251 with review M3 follow-up
DivergedLocal_ReplaysOntoRemote PASS PASS
DisconnectedEmptyRoot_FiltersOrphan still FAIL#1251 doesn't yet filter empty-tree orphan roots from replayDisconnectedLocalRef. This test holds review C1 open until fixed. PASS
DisconnectedMultiCommit_PreservesAllLocalData PASS PASS
ShallowClone_RefusesReplayAcrossBoundary PASS (the historyReachesShallowBoundary guard refuses replay, which the test accepts as a safe outcome) PASS
ShallowBoundary_ErrorIsActionable FAIL — the current errNoMergeBase error message is the exact wording review M3 flagged as not actionable ("reachable shallow history prevents proving refs are disconnected"); the test asserts the user-facing string mentions doctor / --unshallow / fetch --depth. PASS

In other words: landing #1251 as-is turns 2 RED → GREEN and exposes 2 NEW RED that correspond to the C1 + M3 review findings. The two new reds are the forcing function for the follow-up fixes.

Why three tests fail on main today

This branch is off origin/main. PR #1252 is merged but PR #1251 is not — those three RED tests document behavior introduced by #1251 (replay local commits when fetch finds a diverged remote). They serve as an executable specification: GREEN when #1251 lands, RED until then. The SKIP test will start running after #1251 and gate on review M3 wording.

What this PR does NOT cover

  • Group B (PR Fix resume when local metadata branch is stale + preserve diverged refs #1252 fast-forward contract): already covered by TestFetchMetadataBranch_{FetchesAndCreatesLocalBranch,UpdatesExistingLocalBranch,DoesNotRewindLocalAhead} in checkpoint_remote_test.go.
  • V2 metadata fetch after shallow refresh (commit e0834e9766 on config-perm): V2 write paths are being deprecated (Remove checkpoints v2 write paths #1249 removed the v2 settings, recent commits removed write/dual-write paths). Adding a test that exercises soon-to-be-removed code wasn't worth the cost.
  • TestConcurrentPush_SecondPusherRebasesAndRetries already covers the basic concurrent-push case; TestPushAfterDiverged_NoDoubleReplayCommits adds a commit-count assertion on top.

Test plan

🤖 Generated with Claude Code

Soph and others added 2 commits May 25, 2026 11:26
…branches

Adds FetchMetadataBranch test cases for scenarios beyond the existing
fast-forward / no-rewind contract:

- diverged local (sibling commits sharing a base)
- disconnected local with empty-tree orphan root (review C1)
- disconnected local with a multi-commit chain (review M1)
- shallow-clone divergence that must not silently merge
- shallow-boundary error wording (review M3)

Three of these (DivergedLocal_ReplaysOntoRemote,
DisconnectedEmptyRoot_FiltersOrphan,
DisconnectedMultiCommit_PreservesAllLocalData) fail against the current
main contract (PR #1252 preserves but does not replay diverged refs) and
are intended as an executable specification of the in-flight replay
work in the config-perm branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 9ff7f60c868d
Two CLI-level integration tests covering the cross-machine scenarios
the strategy-package tests don't reach:

TestResume_StaleLocalMetadata_RemoteHasNewerCheckpoint reproduces the
PR #1252 user-visible bug end-to-end via the real CLI binary: when the
local entire/checkpoints/v1 ref is behind refs/remotes/origin/... after
another machine pushed, `entire session resume <branch>` printed
"session log not available" for the newer checkpoint. The unit-level
TestResumeFromCurrentBranch_FastForwardsStaleLocalMetadata covers the
same path with a direct function call; this one catches wiring
regressions the unit test would miss.

TestPushAfterDiverged_NoDoubleReplayCommits guards against the
architectural concern raised in the config-perm review (finding H1):
if both fetchMetadataFromOrigin -> SafelyAdvanceLocalRef AND
pushCheckpointBranch -> ReconcileDisconnectedMetadataBranch run during
a single push retry, the merged history could contain a replayed
commit twice. Asserts exactly 3 commits on the metadata branch after
the divergence-then-push flow (root + A + B rebased); a double-replay
would produce 4.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 68e22cb66b76
@Soph Soph requested a review from a team as a code owner May 25, 2026 09:29
Copilot AI review requested due to automatic review settings May 25, 2026 09:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds regression coverage around fetching and reconciling the entire/checkpoints/v1 metadata branch when local and remote histories diverge or are disconnected, including shallow-history safety cases and end-to-end CLI validation for stale local metadata scenarios.

Changes:

  • Adds a new strategy-level test suite specifying replay/merge behavior for diverged/disconnected metadata refs (including empty-tree orphan filtering and shallow-boundary safety).
  • Adds new integration tests covering entire session resume with stale local metadata vs. advanced origin, and guarding against “double replay” commit duplication after diverged push retries.

Reviewed changes

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

File Description
cmd/entire/cli/strategy/replay_disconnected_test.go New unit tests specifying fetch/replay behavior for diverged, disconnected, and shallow metadata branch scenarios.
cmd/entire/cli/integration_test/diverged_replay_test.go New integration tests for stale-local-metadata resume and commit-count regression after diverged push retries.

Comment on lines +19 to +23
// Several of these tests document behavior introduced by the in-flight
// "replay local checkpoints when fetch finds a diverged remote" work and will
// fail against the current main contract (which preserves but does not replay
// diverged local refs). That is intentional -- they serve as an executable
// specification of the target behavior.
@Soph Soph changed the base branch from main to config-perm May 25, 2026 09:39
The "K" shorthand wasn't a standard convention — just disambiguation
from A/B/C used elsewhere. Spell out "first checkpoint" / "second
checkpoint" in both variable names and comments so the scenario reads
without needing a key.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 91ff5ce70013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants