Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
89a3b4d
fix: decrypt personal and group status stanzas with isolated sessions
purpshell Nov 14, 2026
4812d1b
fix: preserve status receipt class for event routing
purpshell Nov 15, 2026
d364288
fix: clear both pairwise scopes when identity changes
purpshell Nov 15, 2026
27d3157
fix: keep group publication identity and receipt context across recei…
purpshell Nov 15, 2026
7359f0a
fix: retain status classification for duplicate receipts
purpshell Nov 16, 2026
5708d64
fix(receive): preserve delegated status handoff order
purpshell Nov 16, 2026
48af73e
prekeys: keep each bundle's device identity
purpshell Nov 16, 2026
4792d8d
remote signal: forward a pkmsg's device identity
purpshell Nov 16, 2026
e768ad8
Compose companion identity forwarding with status delivery
purpshell Nov 17, 2026
cb4fdba
fix(signal): reject sessions cached before identity resets
purpshell Nov 17, 2026
d5e902b
fix(signal): abort stale fan-out and retain nested guard owners
purpshell Nov 17, 2026
c2681a1
fix(signal): quarantine failed resets and bound reset history
purpshell Nov 17, 2026
67a8199
fix(signal): count only actual reset deletion failures
purpshell Nov 17, 2026
68e15b9
fix(signal): recover failed resets without losing identity
purpshell Nov 17, 2026
308ca14
fix(signal): retry pending deletion before session access
purpshell Nov 17, 2026
76026f8
fix(signal): reconcile pending resets before decryption transactions
purpshell Nov 17, 2026
55d6a8b
Keep the SQL identity cache inside its transaction boundary
purpshell Nov 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,29 @@ go get github.com/polymorfa/hypermeow@main
go mod tidy
```

## Receiving statuses

Personal and group `<status>` publications use encrypted message processing;
channel statuses keep their plaintext processing path. The original transport tag
is preserved for acknowledgments. `MessageInfo.StatusKind()` distinguishes
`personal`, `group` and `channel` publications from ordinary messages, status
mentions and replies. Group-status-v2 content is unwrapped while `RawMessage`
retains the original protobuf.

Pairwise status sessions are stored separately from chat sessions. Explicit
`meta session_scope="status"` is honored by default. Applications that consume
served AB props can install `Client.GetStatusSessionMode` before connecting to
supply `status_infra_1_1_session_split` (0 disabled, 1 receiver enabled, 2 sender
enabled, 3 forced). This receive change does not enable status publishing.

Custom `RemoteSignal` receivers must use `RemoteReceive.StatusSession` to select
the pairwise session and carry `StatusKind` into their application event. Sender
keys remain scoped to the group and sender, and private keys and plaintext stay
in the remote store. Upgrading this library alone does not upgrade a remote
receiver's protocol or storage. Legacy encrypted group publications also need
`RemoteReceiveResult.StatusKind` returned after decrypt and on duplicate delivery,
so the client can select the status receipt class without seeing plaintext.

## Newsletter observations

`NewsletterMessage.ViewCounts` preserves the reported view definitions, including
Expand Down Expand Up @@ -264,3 +287,57 @@ Disconnect and wait for owned work to settle before accepting replacement
connection authority. `FrameSocket.SetOnDisconnect` replaces the callback under the socket lock; assign
the legacy field only before connecting.
These additions are unreleased until their reviewed main commit is adopted.

Custom decrypted-event buffers should implement `store.EventBufferPublicationStore` to retain the group-publication flag while atomically deleting plaintext. The SQL store implements this with migration 21. Old processed rows and custom stores without this extension have unknown legacy classification; no status is inferred from a group chat alone.

## Recovering an interrupted identity reset

The local adapter deletes both chat and status session rows before removing their
shared identity. A failed session deletion therefore leaves the old identity in
place. Use `Device.DeleteIdentityAndSessions` when removing both; custom callers
must preserve that order and serialize other writers to the same backend.

Failed rows stay unavailable on the current Device until deletion succeeds.
Guarded session access retries deletion of its known pending key before using
any stored row. `Device.ReconcileSessionResets(ctx)` can also retry all tracked
failures after storage recovers. A reset that cannot retain all possible failures is refused before it
starts; it does not permanently disable the Device or discard unknown failures.
Admission retries at most two existing failures, while explicit reconciliation
can retry the full bounded set. Both reset history and tracked failures retain at
most 1,024 address entries. Pruning history invalidates older prefetched caches,
which must be loaded again.

These guards are per Device and are not cross-process fencing. A fresh adapter
retains the original identity for surviving rows after a failed library-managed
reset; this relies on backend deletion completion and ordering. Custom-store,
transaction, process-crash and previous-release state acceptance still need their
own evidence. Restarting is not a substitute for repairing a failed backend.

Pending recovery runs before buffered decryption opens its transaction. A previously failed
deletion is not reconciled by a write that can still roll back. SQLStore marks its
transaction callbacks and also detects transactions opened directly on its
underlying database. Custom transactional SessionStores must expose
`SessionTransactionState` or mark their contexts with `WithSessionTransaction`;
callbacks must forward that context. Saved buffered plaintext bypasses new
preparation and decryption. These are source contracts, not database/crash or
previous-release acceptance evidence.

SQL identity cache and transactions: use `SQLStore.DoDecryptionTxn` for identity
reads or writes inside a database transaction. It owns the commit/rollback boundary,
serializes identity-cache access for that device until completion, clears the
transaction's cache entries afterward and invalidates earlier identity-fetch tokens.
Nested calls with its callback context share that boundary. An externally opened
transaction cannot supply its eventual outcome, so identity operations and nested
`DoDecryptionTxn` calls in that context return `ErrUnmanagedIdentityTransaction`
before accessing the cache or running the callback. Phone-number to LID migration
also owns its transaction boundary and refuses to run inside an outer transaction.
Escaped callback contexts are
also rejected. This does not coordinate other SQLStore instances or processes that
write the same device rows; those require separate store ownership and admission.

The SQL rollback/replay regression uses a local SQLite database and authored opaque
session bytes, not real account traffic or decrypted Signal sessions. Run it with
CGO enabled: `CGO_ENABLED=1 go test ./store/sqlstore -run TestSQLIdentityRollbackReplay`.
The SQLite driver is a test-only import; the library still does not register a driver
for applications. Cache serialization and guest-session throughput need acceptance
on the composed native candidate before merge.
12 changes: 10 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ type Client struct {
// If false, decrypting a message from untrusted devices will fail.
AutoTrustIdentity bool

// GetStatusSessionMode supplies the served status_infra_1_1_session_split
// value. Install before Connect; the callback may read a synchronized cache.
// Without a callback, explicit status session metadata is honored, but a
// separate session is never forced on an unmarked status.
GetStatusSessionMode func() types.StatusSessionMode

// RawNodeHandler, if non-nil, is called for every inbound node
// after decoding but before standard dispatch. See [RawNodeHandler].
RawNodeHandler RawNodeHandler
Expand Down Expand Up @@ -1044,7 +1050,9 @@ func (cli *Client) handleFrame(ctx context.Context, data []byte, queue chan *waB
// [handleEncryptedMessage]'s own DisabledFeatures.Signal branch
// stays as a fallback for direct callers (DangerousInternals,
// `<appdata>`).
if node.Tag == "message" && cli.DisabledFeatures.Signal {
from, hasFrom := node.Attrs["from"].(types.JID)
encryptedStatus := node.Tag == "status" && hasFrom && (from == types.StatusBroadcastJID || from.Server == types.GroupServer)
if cli.DisabledFeatures.Signal && (node.Tag == "message" || encryptedStatus) {
info, err := cli.parseMessageInfo(node)
if err != nil {
cli.Log.Warnf("Failed to parse message for Signal-disabled handoff: %v", err)
Expand Down Expand Up @@ -1164,7 +1172,7 @@ func (cli *Client) defaultNodeHandlers() map[string]nodeHandler {
return map[string]nodeHandler{
"message": cli.handleEncryptedMessage,
"appdata": cli.handleEncryptedMessage,
"status": cli.handleUnencryptedMessage,
"status": cli.handleStatusMessage,
"receipt": cli.handleReceipt,
"call": cli.handleCallEvent,
"chatstate": cli.handleChatState,
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/beeper/argo-go v1.1.2
github.com/coder/websocket v1.8.15
github.com/google/uuid v1.6.0
github.com/mattn/go-sqlite3 v1.14.52
github.com/polymorfa/libsignal-protocol-go v0.2.3-0.20260806162910-a2adef2e8a11
github.com/rs/zerolog v1.35.1
go.mau.fi/util v0.11.0
Expand Down
28 changes: 24 additions & 4 deletions internals.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading