Skip to content

Merge feature/caps#4681

Merged
chrzaszcz merged 27 commits intomasterfrom
feature/caps
Mar 23, 2026
Merged

Merge feature/caps#4681
chrzaszcz merged 27 commits intomasterfrom
feature/caps

Conversation

@chrzaszcz
Copy link
Copy Markdown
Member

@chrzaszcz chrzaszcz commented Mar 23, 2026

Key assumptions:
- Capabilities are stored once for each entity.
- There are two mappings stored in CETS:
  1. hash -> features
     It is stored until the next downtime.
  2. jid -> features
     It is stored until the client disconnects, sends different caps
     or a presence without caps. Directed presence is always ignored.
- Capabilities are stored only for local users.
  This simplifies the implementation. PubSub supports only local users
  anyway. Previously, caps were stored for remote users, but the actual
  features were the ones of presence recipients instead of senders,
  so it was completely broken.
- When a hash of client's caps is not known, the server sends a disco request.
  For that client, caps will stay unknown until the response is received.
  This may cause a few requests to be sent after a cold start, but the caps
  will become known quickly, i.e. after the first response is
  received.
- The hash of the server disco info is stored only once per host type
  in order to avoid recomputation for each session. This is calculated
  lazily to avoid the case when some modules are not started yet,
  and features are incomplete. Additionally, the server now checks
  if the client asks for the correct hash when querying server caps.
- Include c2s data in caps_recognised
- Remove the obsolete get_pep_recipient and filter_pep_recipient
The approach was to minimise changes because of the upcoming
full rework of PubSub.

Main changes:
- Improve handling of module deps
- Store presence subscribers in Acc on user_send_iq.
  This Acc will be then used when the notifications are broadcasted.
- Read the caps of recipients using the new mod_caps API
  instead of using the obsolete foreign events.
- Test hash generation with the examples from XEP-0115.
- Test API and the backend module.
- Update config tests.
- Capture various caps use cases in disco_and_caps_SUITE.
  Some of them were untested and/or incorrectly handled before.
  Remove pep_caps_test from pep_SUITE because of duplication.
- Update native_bookmarks_test in pep_SUITE, because it had race
  conditions. New mod_caps is faster, triggering them way more often.
- Update tests in pep_SUITE after fixing the handling of
  unidirectional presence subscriptions.
- Update send_caps_after login_test. There is on race condition
  anymore, and this now also checks the unchanged caps.
- Export common caps helpers to caps_helper.
- It only supports CETS.
- It has different options now.
This is the first module not working with the mnesia internal
database, so test helpers needed extending to support providing global
options while testing host config.
- Introduce a new 'versions' option with a list of supported versions.
  XEP-0115 becomes v1, and XEP-0390 becomes v2.
- Add the corresponding caps features to disco responses.
- Fix the issue, where a query to an invalid node would still return
  the caps namespace.
- Advertise the corresponding server capabilities in stream features.
- Consume and verify the corresponding client capabilities.
- Attempt to request caps from the client in the order of configured
  versions.
- Pass the version to the hash generating API.
- Rework encoding to implement the common part only once.
- Add detailed description and comments on all protocol details.
- Try to support both XEPs whenever possible:
    v1: becomes more strict than before, but all within XEP-0115.
    v2: in line with XEP-0390 except some cases listed in 'moduledoc'.
- Support more hashing functions. Skip ones not supported in Erlang.
- Make the check for supported algorithms more robust,
  because some hashing algorithms are not supported e.g. in older
  LibreSSL versions.
- Add examples from XEP-0390; adjust the XEP-0115 ones for consistency
- Shuffle the complex responses more thoroughly to check sorting
- Perform hashing tests for both v1 and v2
- Test all supported hashing algorithms.
- Check the corner cases for v1 and v2, and document the tested
  behaviour with sources.
- Extract reusable helpers to escalus.
- Run caps tests in disco_and_caps_SUITE for v1 and v2.
  Both versions are enabled on the server (as by default),
  and the client decides which one to use.
- Check some previously missed corner cases:
  1) Ask for the server capabilities with a malformed/incorrect node
  2) Respond to the disco#info request with invalid elements
MIM-2647 Entity Capabilities 2.0 (XEP-0390)
MIM-2652 Document the migration for mod_caps
- Fix the hash namespace, and update its name to make it more obvious
  it is version 2
- Drop support for shake* algorithms not mentioned in XEP-0414
- Drop support for MD5 algorithm, which is a 'MUST NOT' in XEP-0414
- Advertise hash features as required by XEP-0300 section 5 Ex. 2
Align mod_caps hashing with XEP-0300 and XEP-0414
@mongoose-im
Copy link
Copy Markdown
Collaborator

mongoose-im commented Mar 23, 2026

CircleCI results for 70ae6f9


elasticsearch_and_cassandra_latest / elasticsearch_and_cassandra_mnesia / 70ae6f9
Status: 🟢 Passed
Reports root/ big
OK: 672 / Failed: 0 / User-skipped: 83 / Auto-skipped: 0


small_tests_legacy / small_tests / 70ae6f9
Reports root / small


small_tests_latest / small_tests / 70ae6f9
Reports root / small


small_tests_latest_arm64 / small_tests / 70ae6f9
Reports root / small


ldap_mnesia_legacy / ldap_mnesia / 70ae6f9
Status: 🟢 Passed
Reports root/ big
OK: 2261 / Failed: 0 / User-skipped: 1472 / Auto-skipped: 0


ldap_mnesia_latest / ldap_mnesia / 70ae6f9
Status: 🟢 Passed
Reports root/ big
OK: 2261 / Failed: 0 / User-skipped: 1472 / Auto-skipped: 0


internal_mnesia_latest / internal_mnesia / 70ae6f9
Status: 🟢 Passed
Reports root/ big
OK: 28 / Failed: 0 / User-skipped: 0 / Auto-skipped: 0


dynamic_domains_mysql_redis_latest / mysql_redis / 70ae6f9
Status: 🟢 Passed
Reports root/ big
OK: 5145 / Failed: 0 / User-skipped: 245 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_legacy / pgsql_mnesia / 70ae6f9
Status: 🟢 Passed
Reports root/ big
OK: 5181 / Failed: 0 / User-skipped: 209 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_latest / pgsql_mnesia / 70ae6f9
Status: 🟢 Passed
Reports root/ big
OK: 5181 / Failed: 0 / User-skipped: 209 / Auto-skipped: 0


pgsql_cets_latest / pgsql_cets / 70ae6f9
Status: 🟢 Passed
Reports root/ big
OK: 5315 / Failed: 0 / User-skipped: 203 / Auto-skipped: 0


pgsql_mnesia_legacy / pgsql_mnesia / 70ae6f9
Status: 🟢 Passed
Reports root/ big
OK: 5498 / Failed: 0 / User-skipped: 263 / Auto-skipped: 0


pgsql_mnesia_latest / pgsql_mnesia / 70ae6f9
Status: 🟢 Passed
Reports root/ big
OK: 5498 / Failed: 0 / User-skipped: 263 / Auto-skipped: 0


cockroachdb_cets_latest / cockroachdb_cets / 70ae6f9
Status: 🟢 Passed
Reports root/ big
OK: 5315 / Failed: 0 / User-skipped: 203 / Auto-skipped: 0


mysql_redis_latest / mysql_redis / 70ae6f9
Status: 🟢 Passed
Reports root/ big
OK: 5491 / Failed: 0 / User-skipped: 270 / Auto-skipped: 0

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 96.47887% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.76%. Comparing base (0d291bb) to head (70ae6f9).
⚠️ Report is 32 commits behind head on master.

Files with missing lines Patch % Lines
src/pubsub/mod_pubsub.erl 87.50% 7 Missing ⚠️
src/caps/mod_caps.erl 97.65% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4681      +/-   ##
==========================================
+ Coverage   85.70%   85.76%   +0.06%     
==========================================
  Files         551      551              
  Lines       33195    33166      -29     
==========================================
- Hits        28449    28445       -4     
+ Misses       4746     4721      -25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@chrzaszcz chrzaszcz marked this pull request as ready for review March 23, 2026 09:25
@chrzaszcz chrzaszcz merged commit 0fe477d into master Mar 23, 2026
4 checks passed
@chrzaszcz chrzaszcz deleted the feature/caps branch March 23, 2026 10:48
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.

3 participants