test(core): assert DeliveryEngine's queueing, merge, and delivery logic directly - #128
Merged
Merged
Conversation
…ic directly DeliveryEngine was previously exercised only indirectly through end-to-end room-send/state-sync integration tests, leaving many individual branches unobserved: version-gate boundaries in mergeRoom/applyStateSync/applyPatch, subscribedRooms union-vs-replace at equal versions, the queueDelivery and local-delivery dedup caps' exact eviction behaviour, timer-scheduled auto-mark-read (including the isShutDown races at both schedule and fire time), and applyStateSync's per-event-type replay rules. Split across two files (delivery-engine.test.ts and delivery-engine-delivery.test.ts) to stay under the repo's max-lines cap, each with its own copy of the shared DeliveryEngineDeps harness: the first covers presence/queueing/membership-merge/state-sync/patch-application, the second covers local-delivery/broadcast/notification/mark-read.
A scoped mutation run against the DI-based test suite surfaced nine survivors, two of which are genuine equivalents (documented below) and seven of which were real gaps: - queueDelivery's eviction cap and mergeMemberOps's stamp-comparison boundary are provably equivalent mutants: splice's own deleteCount computation and reassigning a Map entry to its own current value are both no-ops regardless of whether the mutated boundary operator fires, so no test can distinguish them from the original. - applyPatch(room_upsert) never had a same-version case: only strictly lower and strictly higher versions were tested, leaving the equal- version merge path (the only path the equality half of the version guard actually gates) unobserved. - fireLocalDelivery's already-read skip only ever ran a room_message through it, never a dm, leaving the dm half of that condition unobserved. - fireLocalDelivery's own scheduled mark-read timer had no test for the store shutting down between scheduling and firing (only the applyPatch(delivery) codepath's equivalent timer had one). - findMessageLocation's two internal lookups, and markRead's own separate lookup, were only ever exercised against single-message arrays, where a mutated always-true predicate is indistinguishable from a real id match. Rebalanced the split across both files afterward to stay under the repo's max-lines cap: deliver/drainDelivery and the onPatch-callback tests moved from delivery-engine-delivery.test.ts into delivery-engine.test.ts, which had more headroom.
… real equivalent applyPatch's agent_offline case had no test at all -- a full local mutation run against the current test suite surfaced it as a genuine survivor once the earlier gap-closing pass's own new coverage pushed enough of the file's other branches into range to actually reach it. Also documents (rather than chases) the two remaining survivors against queueDelivery's own length guard: both are provably equivalent, since Array.prototype.splice with a non-positive deleteCount is a no-op regardless of which operator or literal the guard condition uses.
…tants A fresh full mutation run against the current test suite confirms 97.79% (221/226 scoreable) with exactly four surviving locations, all provable equivalents rather than gaps: queueDelivery's length-guard boundary (already documented), mergeMemberOps' stamp-comparison boundary, the deliveryQueues-replay dedup set's unreachable fallback array, and applyPatch(agent_offline)'s redundant same-reference Map.set. Each is explained in place rather than chased with a contrived test.
Mearman
marked this pull request as ready for review
September 15, 2026 22:40
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🎉 This PR is included in version 2.21.18 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
Closes #106. Part of the mutation-testing epic tracked in #64.
Mutation score: 43.36% -> 97.79% (221/226 scoreable, verified with a full local Stryker run). The four remaining survivors are all provable equivalent mutants, documented in place rather than chased.
Test plan
pnpm typecheckpnpm lintpnpm test(673 passed)