Skip to content

Fix incorrect handling of fresh clone - #362

Merged
rmunn merged 2 commits into
developfrom
bug/fix-incorrect-fresh-clone-handling
Oct 1, 2026
Merged

rmunn merged 2 commits into
developfrom
bug/fix-incorrect-fresh-clone-handling

Conversation

@rmunn

@rmunn rmunn commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

If a project's Mercurial repo has been deleted from webwork and LfMerge clones a fresh copy of the LexBox repo, the fresh copy may be at a different Mercurial revision than the one that LfMerge last synced from. If that happens, then our modifiedDate handling, which only checks if the FLEx modified date is different from the Mongo copy, can incorrectly flag a copy modified in FLEx as having been modified in LF, and therefore overwrite FLEx's newer data with LF's older data.

This has already happened to one project, and I had to roll back the Mercurial revision that LfMerge made, because it had replaced several hundred FLEx entries (modified in 2026) with stale LF entries last modified in 2024.

The code in this PR was created by Claude Opus 5.5 after examining the state of that particular project; I will be making a few changes in later commits, mostly to reduce the verbosity of the comments that Claude always includes. But the logic is correct, and should prevent this problem from happening again.

If a project's Mercurial repo has been deleted from webwork and LfMerge
clones a fresh copy of the LexBox repo, the fresh copy may be at a
different Mercurial revision than the one that LfMerge last synced from.
If that happens, then our modifiedDate handling, which only checks if
the FLEx modified date is *different* from the Mongo copy, can
incorrectly flag a copy modified in FLEx as having been modified in LF,
and therefore overwrite FLEx's *newer* data with LF's *older* data.

This has already happened to one project, and I had to roll back the
Mercurial revision that LfMerge made, because it had replaced several
hundred FLEx entries (modified in 2026) with stale LF entries last
modified in 2024.

The code in this commit was created by Claude Opus 5.5 after examining
the state of that particular project; I (Robin Munn) will be making a
few changes in later commits, mostly to reduce the verbosity of the
comments that Claude always includes. But the logic is correct, and
should prevent this problem from happening again.
@rmunn rmunn self-assigned this Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Test Results

    2 files    21 suites   4m 37s ⏱️
319 tests 297 ✔️ 22 💤 0 ❌
322 runs  300 ✔️ 22 💤 0 ❌

Results for commit 4f382fd.

♻️ This comment has been updated with latest results.

Tests now depend on LastSyncedDate being correct, since the Mongo->LCM
logic relies on it now in order to detect cases where FW work went on
while LF didn't know about it. So the test double needs to refresh its
LastSyncedDate value the same way that the real object does, in order
for the unit tests to be correctly simulating the real thing.
@rmunn
rmunn force-pushed the bug/fix-incorrect-fresh-clone-handling branch from 220792e to 4f382fd Compare October 1, 2026 06:21
@rmunn

rmunn commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Tests are confirming it works as expected. On a small test project, the LfMerge version currently in production would have replaced 77 FLEx entries that were newer than LF with the LF entries that had not actually been modified, but running an LfMerge built from this branch instead logged a message saying "77 entries in FLEx are newer than LF" and correctly replaced LF's older data with FLEx's newer data.

I'll try a couple more, but this LGTM.

@hahn-kev gave a verbal thumbs-up, so I will probably merge this bugfix into develop without waiting for a GitHub approval.

@rmunn
rmunn merged commit 5e388d7 into develop Oct 1, 2026
3 checks passed
@rmunn
rmunn deleted the bug/fix-incorrect-fresh-clone-handling branch October 1, 2026 08:45
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.

1 participant