Skip to content

refactor: persistence snapshot reads and mention filtering [WPB-8645] - #4177

Open
MohamadJaara wants to merge 4 commits into
developfrom
mo/refactor/persistence-snapshot-reads
Open

refactor: persistence snapshot reads and mention filtering [WPB-8645]#4177
MohamadJaara wants to merge 4 commits into
developfrom
mo/refactor/persistence-snapshot-reads

Conversation

@MohamadJaara

@MohamadJaara MohamadJaara commented Jun 1, 2026

Copy link
Copy Markdown
Member

https://wearezeta.atlassian.net/browse/WPB-8645

Why

Kalium-owned per-key FlowCache can make correctness-sensitive reads depend on replayed observation state. This PR removes that shared cache layer from persistence and adds narrow snapshot reads for fresh database decisions.

It also exposes member mention filtering so app-side callers can reuse an already observed member list without collecting the members flow again.

What changed

  • Removed FlowCache and its database-builder wiring.
  • Added narrow DAO snapshot APIs for team lookup, conversation last-read date, member admin checks, member count aggregates, and direct member reads.
  • Updated correctness-sensitive repository/use-case paths to use snapshot reads instead of .first() on observed flows.
  • Extracted MembersToMentionUseCase.filterConversationMembers(...) for app-side member snapshot reuse.
  • Added/updated DAO and use-case regression coverage for fresh snapshot reads.

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Test Results

39 tests   39 ✅  5s ⏱️
 4 suites   0 💤
 4 files     0 ❌

Results for commit a599388.

♻️ This comment has been updated with latest results.

@codecov-commenter

codecov-commenter commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.94937% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.53%. Comparing base (48a7574) to head (a599388).
⚠️ Report is 66 commits behind head on develop.

Files with missing lines Patch % Lines
.../logic/data/conversation/ConversationRepository.kt 27.77% 13 Missing ⚠️
.../com/wire/kalium/logic/data/call/CallRepository.kt 71.42% 1 Missing and 1 partial ⚠️
...gic/sync/receiver/handler/CallingMessageHandler.kt 60.00% 0 Missing and 2 partials ⚠️
...lin/com/wire/kalium/persistence/dao/UserDAOImpl.kt 85.71% 0 Missing and 1 partial ⚠️
...reateAndPersistRecentlyEndedCallMetadataUseCase.kt 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #4177      +/-   ##
=============================================
- Coverage      61.55%   61.53%   -0.02%     
- Complexity      4082     4089       +7     
=============================================
  Files           2104     2105       +1     
  Lines          69424    69463      +39     
  Branches        6842     6844       +2     
=============================================
+ Hits           42733    42746      +13     
- Misses         23938    23962      +24     
- Partials        2753     2755       +2     
Files with missing lines Coverage Δ
.../kotlin/com/wire/kalium/persistence/dao/UserDAO.kt 97.24% <ø> (ø)
...um/persistence/dao/conversation/ConversationDAO.kt 85.71% <ø> (ø)
...ersistence/dao/conversation/ConversationDAOImpl.kt 79.94% <100.00%> (ø)
...om/wire/kalium/persistence/dao/member/MemberDAO.kt 79.81% <100.00%> (+6.89%) ⬆️
.../wire/kalium/persistence/db/UserDatabaseBuilder.kt 89.01% <100.00%> (-0.55%) ⬇️
...lium/logic/feature/call/ShouldRemoteMuteChecker.kt 100.00% <100.00%> (+14.28%) ⬆️
.../conversation/UpdateConversationReadDateUseCase.kt 91.80% <100.00%> (ø)
...essage/confirmation/ConfirmationDeliveryHandler.kt 75.55% <100.00%> (ø)
...lin/com/wire/kalium/persistence/dao/UserDAOImpl.kt 58.00% <85.71%> (-0.36%) ⬇️
...reateAndPersistRecentlyEndedCallMetadataUseCase.kt 74.35% <85.71%> (-4.22%) ⬇️
... and 3 more

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7242b3d...a599388. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MohamadJaara
MohamadJaara marked this pull request as ready for review June 1, 2026 09:53
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchmo/refactor/persistence-snapshot-reads
Testbedubuntu-latest

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymicroseconds (µs)
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInFiles📈 view plot
⚠️ NO THRESHOLD
885.71 µs
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInMemory📈 view plot
⚠️ NO THRESHOLD
349,378.99 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.inboxPagingDeepPageBenchmark📈 view plot
⚠️ NO THRESHOLD
127,755.91 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.inboxPagingFirstPageBenchmark📈 view plot
⚠️ NO THRESHOLD
121,821.49 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.localMarkAsReadBenchmark📈 view plot
⚠️ NO THRESHOLD
3,273.46 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.messagePagingDeepPageBenchmark📈 view plot
⚠️ NO THRESHOLD
27,081.33 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.messagePagingFirstPageBenchmark📈 view plot
⚠️ NO THRESHOLD
11,222.24 µs
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.messageInsertionBenchmark📈 view plot
⚠️ NO THRESHOLD
1,218,356.84 µs
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.queryMessagesBenchmark📈 view plot
⚠️ NO THRESHOLD
20,744.22 µs
🐰 View full continuous benchmarking report in Bencher

@MohamadJaara MohamadJaara changed the title refactor: replace persistence flow cache with snapshot reads refactor: persistence snapshot reads and mention filtering Jun 5, 2026
@MohamadJaara MohamadJaara changed the title refactor: persistence snapshot reads and mention filtering refactor: persistence snapshot reads and mention filtering [WPB-8645] Jun 5, 2026
@MohamadJaara
MohamadJaara requested review from Garzas and yamilmedina and removed request for yamilmedina June 5, 2026 08:44
@MohamadJaara
MohamadJaara force-pushed the mo/refactor/persistence-snapshot-reads branch 2 times, most recently from c3097d4 to 900781e Compare June 9, 2026 15:44
@MohamadJaara
MohamadJaara force-pushed the mo/refactor/persistence-snapshot-reads branch from 900781e to 1bb7f9f Compare June 23, 2026 15:20
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branch${GITHUB_HEAD_REF}
Testbedubuntu-latest

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymicroseconds (µs)
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInFiles📈 view plot
⚠️ NO THRESHOLD
875.35 µs
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInMemory📈 view plot
⚠️ NO THRESHOLD
335,840.30 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.inboxPagingDeepPageBenchmark📈 view plot
⚠️ NO THRESHOLD
131,916.47 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.inboxPagingFirstPageBenchmark📈 view plot
⚠️ NO THRESHOLD
128,242.83 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.localMarkAsReadBenchmark📈 view plot
⚠️ NO THRESHOLD
3,474.96 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.messagePagingDeepPageBenchmark📈 view plot
⚠️ NO THRESHOLD
36,792.16 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.messagePagingFirstPageBenchmark📈 view plot
⚠️ NO THRESHOLD
21,644.81 µs
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.messageInsertionBenchmark📈 view plot
⚠️ NO THRESHOLD
1,254,198.81 µs
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.queryMessagesBenchmark📈 view plot
⚠️ NO THRESHOLD
19,904.19 µs
🐰 View full continuous benchmarking report in Bencher

@MohamadJaara MohamadJaara added the internal-only for internal only changes that should not effect consumers of the SDK label Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal-only for internal only changes that should not effect consumers of the SDK 🚨 Potential breaking changes 👕 size: XL type: refactoring 🛠

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants