Skip to content

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

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

refactor: persistence snapshot reads and mention filtering [WPB-8645]#4177
MohamadJaara wants to merge 2 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

0 tests   - 5 737   0 ✅  - 5 594   0s ⏱️ - 4m 20s
0 suites  -   878   0 💤  -   143 
0 files    -   878   0 ❌ ±    0 

Results for commit 900781e. ± Comparison against base commit 2ca7e8e.

♻️ This comment has been updated with latest results.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 61.59%. Comparing base (2f37b63) to head (03514a2).

Files with missing lines Patch % Lines
...lin/com/wire/kalium/persistence/dao/UserDAOImpl.kt 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #4177      +/-   ##
=============================================
- Coverage      61.60%   61.59%   -0.01%     
- Complexity      4033     4040       +7     
=============================================
  Files           2076     2077       +1     
  Lines          67813    67838      +25     
  Branches        6703     6703              
=============================================
+ Hits           41775    41788      +13     
- Misses         23369    23380      +11     
- Partials        2669     2670       +1     
Files with missing lines Coverage Δ
...com/wire/kalium/persistence/dao/MetadataDAOImpl.kt 84.84% <100.00%> (ø)
.../kotlin/com/wire/kalium/persistence/dao/UserDAO.kt 97.24% <ø> (ø)
...um/persistence/dao/conversation/ConversationDAO.kt 85.71% <ø> (ø)
...ersistence/dao/conversation/ConversationDAOImpl.kt 80.80% <100.00%> (ø)
...om/wire/kalium/persistence/dao/member/MemberDAO.kt 77.98% <100.00%> (+7.14%) ⬆️
.../wire/kalium/persistence/db/UserDatabaseBuilder.kt 78.68% <100.00%> (-1.00%) ⬇️
...lin/com/wire/kalium/persistence/dao/UserDAOImpl.kt 58.36% <85.71%> (-0.36%) ⬇️

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f37b63...03514a2. 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 from d4c0199 to 1b613b6 Compare June 5, 2026 09:43
@MohamadJaara MohamadJaara force-pushed the mo/refactor/persistence-snapshot-reads branch from c3097d4 to 900781e Compare June 9, 2026 15:44
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants