Skip to content

tests: port carbon classification and settle waits from Python carbon… - #555

Merged
vitalyster merged 6 commits into
masterfrom
carbon-test-review
Oct 15, 2026
Merged

vitalyster merged 6 commits into
masterfrom
carbon-test-review

Conversation

@vitalyster

Copy link
Copy Markdown
Collaborator

…s test

Classify carbons by kind, sender and body as carbons.py did, fail on unexpected carbons or plain messages, and wait for a settle period before exact counts so late duplicates are caught. Responder count and gateway-mode carbons are not covered yet.

@vitalyster
vitalyster force-pushed the carbon-test-review branch 7 times, most recently from 453defc to f0857a7 Compare October 15, 2026 12:53
vitalyster and others added 4 commits October 15, 2026 15:55
An incoming legacy message goes to the resource that replied last, or to
the highest-priority resource before any resource has replied.

In server mode the transport also copies the message to every other
resource as a XEP-0280 <received> carbon. In gateway mode the XMPP server
makes those copies itself, because the message passes through it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALrWqtcsbL3cuX4sC5yrmS
In gateway mode a carbon of a message the account sent from another legacy
client must come from the user's bare JID, which a component cannot send
from. The transport asks the server to send it through a XEP-0356
<privilege> wrapper, but always used urn:xmpp:privilege:1. Prosody's
mod_privilege only accepts urn:xmpp:privilege:2, so those carbons were
dropped and never reached the user's XMPP clients.

Parse both namespaces, remember the one the server announces its
permissions in, and send the wrapper in it. Until the announcement
arrives, use urn:xmpp:privilege:2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALrWqtcsbL3cuX4sC5yrmS
A message the account sent from another legacy client was forwarded in its
<sent> carbon as coming from the last-replied resource, or from a made-up
"bot" resource when there was none. No XMPP resource sent it, so use the
user's bare JID instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALrWqtcsbL3cuX4sC5yrmS
ForwardIQHandler is added after Swift's internal handlers, so it saw the
replies to the backend's own requests (disco, caps) first and relayed
them to the transport. The transport sent them on as IQ errors without a
recipient; Prosody rejected the stanza, raised an error in its component
handler and dropped the stream, so every stanza after it was lost,
including the carbon copies.

Relay only replies to IQs the backend sent on behalf of the user. In
gateway mode, also make the transport drop backend IQs without a valid
recipient. In server mode an IQ without 'to' is a valid server-directed
IQ and is left alone.
vitalyster and others added 2 commits October 15, 2026 16:15
Server mode: a legacy message goes only to the last-replied resource and
every other resource gets exactly one <received> carbon.

Gateway mode: run the transport as a Prosody component with the swiften
backend logged in as responder@localhost/Spectrum, with three XMPP
resources of the same user. Check the same rules and that the copies
follow the last-replied resource when another resource replies. Then send
the transport a message the account sent from another legacy client
(carbon=true) and check that every resource gets exactly one <sent>
carbon from the user's bare JID through the XEP-0356 privilege wrapper,
and that the legacy contact does not get it again. Prosody enables
mod_privilege for the transport, and the test data gets an offline
storage directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALrWqtcsbL3cuX4sC5yrmS
Start Prosody with tests/libpurple_jabber/prosody.cfg.lua instead of the
Slack test config, because it defines the gateway component and its
XEP-0356 privileges. Make the mounted test data writable for the
container user, so Prosody can write its offline storage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALrWqtcsbL3cuX4sC5yrmS
@vitalyster
vitalyster merged commit 90e11f0 into master Oct 15, 2026
8 checks passed
@vitalyster
vitalyster deleted the carbon-test-review branch October 15, 2026 13:16
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.

1 participant