fix(email): serialize urgency checkpoint delivery - #5804
Open
RaresKeY wants to merge 7 commits into
Open
Conversation
RaresKeY
marked this pull request as ready for review
July 28, 2026 16:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This replaces #5655, which GitHub closed during the repository transfer and fork-network separation. The branch has been rebuilt on the current dev history; the implementation scope is unchanged.
Serialize overlapping email-urgency checkpoint decisions without moving async delivery onto a worker event loop. A cancellation-aware cross-process lock now orders the read/decision/publish sequence, while delivery continues on the application loop and checkpoint files are replaced atomically.
Checkpoint reconciliation is scoped to accounts fully covered by the current scan. Account-scoped or failed-account runs preserve unrelated successful delivery state instead of causing later duplicate notifications. Per-account generations also fence delivery and merge work from an older scan after a newer same-account checkpoint commits.
Target branch
dev, notmain.Linked Issue
Fixes #5645
Part of #5637
Type of Change
Checklist
dev.How to Test
Run:
Start two same-owner urgency actions together and verify the second observes the first checkpoint before deciding to deliver.
Cancel a run while it waits or delivers and verify it neither continues in a detached worker loop nor publishes a success checkpoint.
Run disjoint account-scoped scans and a failed-account scan; verify unrelated account checkpoints remain intact.
Poll browser notifications concurrently and verify an appended reminder is not discarded.
Exact-head validation passes 142 email, urgency, reminder, scheduler, and owner-scope tests, including active-account registration, authoritative cleanup fencing, newer-addition, newer-removal, partial/full, mixed-account, cancellation, and browser-queue orderings. The late-cleanup race also passes 20 consecutive isolated repetitions. Python compilation and diff checks pass.
Visual / UI changes — REQUIRED if you touched anything that renders
No visual or frontend files changed.