Skip to content

Fix crashes in patch merging#64

Merged
DRMacIver merged 4 commits intomainfrom
DRMacIver/fix-merge-crashes
Apr 10, 2026
Merged

Fix crashes in patch merging#64
DRMacIver merged 4 commits intomainfrom
DRMacIver/fix-merge-crashes

Conversation

@DRMacIver
Copy link
Copy Markdown
Owner

If patches came in while we were merging, we would sometimes run into problems where we successfully merged more than to_merge worth of patches and kept going. This would trigger some internal assertions.

The fix is just to not try to do that and to only ever merge as many patches as we intended to at the start. There are some slight inefficiencies here, but I struggle to imagine they'll ever matter in practice.

Fixes #63

DRMacIver and others added 4 commits April 10, 2026 11:17
Add tests that trigger the AssertionError in can_merge reported in #63.

The root cause is that find_large_integer assumes can_merge is monotonic,
but it's not when the interestingness test is non-deterministic (as with
real subprocess tests). The mechanism:

1. can_merge(to_merge) evaluates is_interesting -> False (cached)
2. Successful intermediate merges during find_large_integer clear the cache
3. Re-evaluation of the same content returns True (non-determinism)
4. find_large_integer probes past to_merge, hitting the assertion

Two tests added:
- Hypothesis property test: generates random configs with a flaky
  is_interesting function that simulates non-deterministic subprocess
  behavior (~50% first-call failure, always-pass on re-evaluation)
- Concrete test: iterates seeds with autojump_clock to reliably trigger
  the assertion in a deterministic scheduling environment

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
@DRMacIver DRMacIver merged commit 8902f05 into main Apr 10, 2026
@DRMacIver DRMacIver deleted the DRMacIver/fix-merge-crashes branch April 10, 2026 10:58
@DRMacIver DRMacIver mentioned this pull request Apr 10, 2026
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.

AssertionError in patching.py line 83, in can_merge

1 participant