From 84d970ceb73feb52a7413a3fd94f31b474d93c8c Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Sun, 15 Nov 2026 21:23:05 +0200 Subject: [PATCH 1/7] feat: receive status publications with explicit session context --- Cargo.lock | 21 +-- Cargo.toml | 14 +- README.md | 18 +++ docs/app-api.openapi.json | 34 ++++- .../polymorfa/signal/v1/signal_service.proto | 15 ++ src/delivery.rs | 1 + src/message.rs | 5 +- src/serve.rs | 101 +++++++++---- tests/prekey_upload_boundary.rs | 2 +- tests/service_boundary.rs | 135 ++++++++++++++++++ 10 files changed, 297 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2bcb787..a9a4649 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3245,7 +3245,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wacore" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=4b3b13cacd40a27573d0246386db553ef887539b#4b3b13cacd40a27573d0246386db553ef887539b" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" dependencies = [ "aes 0.9.3", "anyhow", @@ -3264,6 +3264,7 @@ dependencies = [ "event-listener", "fluent-uri", "futures", + "getrandom 0.4.3", "hashbrown 0.17.1", "hex", "hkdf 0.13.0", @@ -3293,7 +3294,7 @@ dependencies = [ [[package]] name = "wacore-appstate" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=4b3b13cacd40a27573d0246386db553ef887539b#4b3b13cacd40a27573d0246386db553ef887539b" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" dependencies = [ "anyhow", "buffa", @@ -3314,7 +3315,7 @@ dependencies = [ [[package]] name = "wacore-binary" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=4b3b13cacd40a27573d0246386db553ef887539b#4b3b13cacd40a27573d0246386db553ef887539b" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" dependencies = [ "bytes", "compact_str", @@ -3331,7 +3332,7 @@ dependencies = [ [[package]] name = "wacore-derive" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=4b3b13cacd40a27573d0246386db553ef887539b#4b3b13cacd40a27573d0246386db553ef887539b" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" dependencies = [ "proc-macro2", "quote", @@ -3341,7 +3342,7 @@ dependencies = [ [[package]] name = "wacore-libsignal" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=4b3b13cacd40a27573d0246386db553ef887539b#4b3b13cacd40a27573d0246386db553ef887539b" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" dependencies = [ "aes 0.9.3", "async-lock", @@ -3372,7 +3373,7 @@ dependencies = [ [[package]] name = "wacore-noise" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=4b3b13cacd40a27573d0246386db553ef887539b#4b3b13cacd40a27573d0246386db553ef887539b" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" dependencies = [ "anyhow", "buffa", @@ -3390,9 +3391,10 @@ dependencies = [ [[package]] name = "wacore-recordstore" version = "0.1.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=4b3b13cacd40a27573d0246386db553ef887539b#4b3b13cacd40a27573d0246386db553ef887539b" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" dependencies = [ "aes-gcm 0.11.1", + "async-lock", "async-trait", "bytes", "rand 0.10.3", @@ -3403,7 +3405,7 @@ dependencies = [ [[package]] name = "wacore-signal-ops" version = "0.1.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=4b3b13cacd40a27573d0246386db553ef887539b#4b3b13cacd40a27573d0246386db553ef887539b" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" dependencies = [ "anyhow", "async-lock", @@ -3411,6 +3413,7 @@ dependencies = [ "bytes", "hex", "rand 0.10.3", + "serde", "sha2 0.11.0", "thiserror", "wacore", @@ -3431,7 +3434,7 @@ dependencies = [ [[package]] name = "waproto" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=4b3b13cacd40a27573d0246386db553ef887539b#4b3b13cacd40a27573d0246386db553ef887539b" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" dependencies = [ "buffa", "buffa-build", diff --git a/Cargo.toml b/Cargo.toml index 224ef8d..c8bc109 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,11 +18,11 @@ path = "src/main.rs" [dependencies] # Signal core, pinned to polymorfa/whatsapp-rust branch polymorfa/recordstore. -wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "4b3b13cacd40a27573d0246386db553ef887539b" } -wacore-binary = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "4b3b13cacd40a27573d0246386db553ef887539b" } -wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "4b3b13cacd40a27573d0246386db553ef887539b" } -wacore-signal-ops = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "4b3b13cacd40a27573d0246386db553ef887539b" } -waproto = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "4b3b13cacd40a27573d0246386db553ef887539b" } +wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc" } +wacore-binary = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc" } +wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc" } +wacore-signal-ops = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc" } +waproto = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc" } aes-gcm = "0.10" anyhow = "1" @@ -55,7 +55,7 @@ protox = "0.9" [dev-dependencies] tokio = { version = "1", features = ["test-util"] } -wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "4b3b13cacd40a27573d0246386db553ef887539b", features = ["test-util"] } +wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc", features = ["test-util"] } rand10 = { package = "rand", version = "0.10" } -wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "4b3b13cacd40a27573d0246386db553ef887539b", features = ["conformance"] } +wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc", features = ["conformance"] } reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json", "stream"] } diff --git a/README.md b/README.md index ea0a3a8..15e3053 100644 --- a/README.md +++ b/README.md @@ -160,3 +160,21 @@ cargo build --release --locked Without the PostgreSQL variable, local tests explicitly report that PG conformance was not exercised. CI requires it. Tests exercise real SQLite and PostgreSQL store conformance; per-slot authentication; a fake Polymorfa WebSocket with Hello/Welcome/claims; actual two-device Signal encryption/decryption; signed webhook failure/ACK and SSE delivery; encrypted SendStanza; consent-off history; expiry, stale writes and crash replay; and the five-per-second ceiling. The transport peer is a fixture, not a real runner or WhatsApp account. Release still requires the pinned library producer to merge, backend/SDK/CLI/docs consumers to integrate on explicit revisions, real-account pairing/send/receive/media/history/group/retry acceptance, and the private AGPL/legal review plus owner publication approval. Repository visibility, package/image publication and production rollout controls remain unchanged by this implementation. The service adds no staff control authority; backend-owned eligibility and counts-only diagnostics stay in the Polymorfa control plane. + +## Receiving status publications + +`RunnerRequest.status_receive` is a distinct operation. Implement it before +accepting status publications: the nested `Receive` preserves origin, sender, +alternate identity and provider time; `status_kind` identifies personal, group +or channel scope. Apply `status_session` only to pairwise `pkmsg`/`msg` session +storage, keeping identity keys and prekeys shared. Sender keys retain their +existing group/sender scope. Keep phone-number to linked-identity migration, +identity replacement and session deletion consistent across both session stores. + +An older service must return `CODE_UNSUPPORTED` without decrypting, delivering +or changing a chat session. Do not fall back to `receive`. The response remains +`ServiceResponse.receive`; plaintext stays in the customer-owned service. +The receiver delivers `status.received` with `status_scope` and the existing shared +content fields. Group publications retain their full protobuf while text and +media use the wrapped publication content. Replies and mention notifications +remain messages. Local synthetic tests do not establish live rollout eligibility. diff --git a/docs/app-api.openapi.json b/docs/app-api.openapi.json index 7e3187a..789435f 100644 --- a/docs/app-api.openapi.json +++ b/docs/app-api.openapi.json @@ -374,6 +374,7 @@ "type": "string", "enum": [ "message", + "status.received", "history.sync" ] }, @@ -416,6 +417,15 @@ }, "history": { "$ref": "#/components/schemas/HistoryDescriptor" + }, + "status_scope": { + "type": "string", + "enum": [ + "personal", + "group", + "channel" + ], + "description": "Status publication audience. Absent for ordinary messages and history." } } }, @@ -462,16 +472,30 @@ "UnconfirmedSend": { "type": "object", "additionalProperties": false, - "required": ["error"], + "required": [ + "error" + ], "properties": { "error": { "type": "object", "additionalProperties": false, - "required": ["code", "message", "message_id"], + "required": [ + "code", + "message", + "message_id" + ], "properties": { - "code": { "type": "string", "const": "send_unconfirmed" }, - "message": { "type": "string" }, - "message_id": { "type": "string", "minLength": 1 } + "code": { + "type": "string", + "const": "send_unconfirmed" + }, + "message": { + "type": "string" + }, + "message_id": { + "type": "string", + "minLength": 1 + } } } } diff --git a/proto/polymorfa/signal/v1/signal_service.proto b/proto/polymorfa/signal/v1/signal_service.proto index 0f4e4ee..ae865f2 100644 --- a/proto/polymorfa/signal/v1/signal_service.proto +++ b/proto/polymorfa/signal/v1/signal_service.proto @@ -99,6 +99,8 @@ message RunnerRequest { Resend resend = 17; ForgetIdentity forget_identity = 18; MigratePnToLid migrate_pn_to_lid = 19; + // A distinct operation prevents old services from using the chat ratchet. + StatusReceive status_receive = 22; PreparePreKeyUpload prepare_pre_key_upload = 20; AcknowledgePreKeyUpload acknowledge_pre_key_upload = 21; } @@ -214,6 +216,19 @@ message Receive { string sender_alt = 9; } +// StatusReceive must be explicitly implemented. An unsupported service returns +// CODE_UNSUPPORTED without decrypting, delivering or mutating a chat session. +// The response uses ServiceResponse.receive and retains the no-plaintext contract. +message StatusReceive { + Receive payload = 1; + // "personal", "group" or "channel". This is publication provenance, + // never inferred from quoted content or a status mention notification. + string status_kind = 2; + // Use the sender's separate pairwise status session for pkmsg/msg only. + // Identity keys and prekeys remain shared. skmsg keeps its sender-key scope. + bool status_session = 3; +} + message ReceiveResult { bool already_delivered = 1; bool redelivered = 2; diff --git a/src/delivery.rs b/src/delivery.rs index 7fa6648..b4c4a1f 100644 --- a/src/delivery.rs +++ b/src/delivery.rs @@ -255,6 +255,7 @@ mod tests { Event { id: id.into(), kind: "message", + status_scope: None, session_id: "s".into(), chat: "c".into(), sender: "x".into(), diff --git a/src/message.rs b/src/message.rs index ab56364..e2e4ae6 100644 --- a/src/message.rs +++ b/src/message.rs @@ -21,10 +21,13 @@ pub struct Event { /// Stable across redeliveries of the same ciphertext; use it to /// deduplicate and to acknowledge. pub id: String, - /// `message` or `history.sync`. + /// `message`, `status.received` or `history.sync`. #[serde(rename = "type")] pub kind: &'static str, pub session_id: String, + /// Publication audience; replies and mentions remain ordinary messages. + #[serde(skip_serializing_if = "Option::is_none")] + pub status_scope: Option, pub chat: String, pub sender: String, #[serde(skip_serializing_if = "Option::is_none")] diff --git a/src/serve.rs b/src/serve.rs index bc60682..d020963 100644 --- a/src/serve.rs +++ b/src/serve.rs @@ -69,7 +69,30 @@ pub async fn handle( let fail = |e: OpsError| node.ops_error(session, &e); match op { Op::GetIdentity(_) => unreachable!("handled above"), - Op::Receive(receive) => self::receive(node, session, &ops, receive).await, + Op::Receive(receive) => self::receive(node, session, &ops, receive, None, false).await, + Op::StatusReceive(request) => { + let receive = request + .payload + .ok_or_else(|| invalid("status payload is required"))?; + let valid = match request.status_kind.as_str() { + "personal" => receive.chat == "status@broadcast", + "group" => receive.chat.ends_with("@g.us"), + "channel" => receive.chat.ends_with("@newsletter"), + _ => false, + }; + if !valid { + return Err(invalid("status scope does not match publication origin")); + } + self::receive( + node, + session, + &ops, + receive, + Some(&request.status_kind), + request.status_session, + ) + .await + } Op::GeneratePreKeys(request) => { let keys = ops.generate_prekeys(request.count).await.map_err(fail)?; respond(Out::PreKeys(PreKeys { @@ -236,6 +259,8 @@ async fn receive( session: &Arc, ops: &crate::node::Ops, receive: proto::Receive, + status_kind: Option<&str>, + status_session: bool, ) -> Result { let sender = jid(&receive.sender, "sender")?; let address = sender.to_protocol_address(); @@ -247,27 +272,30 @@ async fn receive( }; let padding_version = u8::try_from(receive.padding_version) .map_err(|_| invalid("padding_version out of range"))?; - let received = ops - .receive(ReceiveRequest { - chat: &receive.chat, - sender: &address, - kind, - ciphertext: &receive.ciphertext, - padding_version, - is_from_me: receive.is_from_me, - }) - .await - .map_err(|e| { - let error = receive_error(node, session, &e); - tracing::info!( - session = %session.id, - message_id = %receive.message_id, - kind = %receive.kind, - code = error.code_enum().as_str_name(), - "receive failed" - ); - error - })?; + let request = ReceiveRequest { + chat: &receive.chat, + sender: &address, + kind, + ciphertext: &receive.ciphertext, + padding_version, + is_from_me: receive.is_from_me, + }; + let result = if status_kind.is_some() { + ops.receive_status(request, status_session).await + } else { + ops.receive(request).await + }; + let received = result.map_err(|e| { + let error = receive_error(node, session, &e); + tracing::info!( + session = %session.id, + message_id = %receive.message_id, + kind = %receive.kind, + code = error.code_enum().as_str_name(), + "receive failed" + ); + error + })?; let message = match received { Received::AlreadyDelivered { receipt_key } => { let app_state_key_share = if node.cfg.share_app_state_keys && receive.is_from_me { @@ -305,7 +333,7 @@ async fn receive( } else { Vec::new() }; - if let Some(event) = event_for(node, session, &receive, &message) { + if let Some(event) = event_for(node, session, &receive, &message, status_kind) { let kind = event.kind; if let Err(e) = node.delivery.deliver(event).await { tracing::info!( @@ -351,15 +379,23 @@ fn event_for( session: &ActiveSession, receive: &proto::Receive, received: &wacore_signal_ops::ReceivedMessage, + status_kind: Option<&str>, ) -> Option { let content = &received.content; if content.is_skdm_only { return None; } + let status_kind = status_kind + .or_else(|| { + (receive.chat.ends_with("@g.us") && content.message.group_status_message_v2.is_set()) + .then_some("group") + }) + .or_else(|| (receive.chat == "status@broadcast").then_some("personal")); let base = |kind: &'static str| Event { id: received.receipt_key.clone(), kind, session_id: session.id.clone(), + status_scope: status_kind.map(str::to_owned), chat: receive.chat.clone(), sender: receive.sender.clone(), sender_alt: Some(receive.sender_alt.clone()).filter(|s| !s.is_empty()), @@ -423,9 +459,18 @@ fn event_for( } else { &content.message }; + let display_message = if status_kind == Some("group") { + wa_message + .group_status_message_v2 + .as_option() + .and_then(|wrapped| wrapped.message.as_option()) + .unwrap_or(wa_message) + } else { + wa_message + }; Some(Event { - text: message::text_of(wa_message), - media: message::media_of(wa_message), + text: message::text_of(display_message), + media: message::media_of(display_message), message_proto: base64_of(&message::encode(wa_message)), history: content .protocol_message @@ -433,7 +478,11 @@ fn event_for( .and_then(|p| p.history_sync_notification.as_ref()) .filter(|_| node.cfg.deliver_history && receive.is_from_me) .map(message::history_descriptor), - ..base("message") + ..base(if status_kind.is_some() { + "status.received" + } else { + "message" + }) }) } diff --git a/tests/prekey_upload_boundary.rs b/tests/prekey_upload_boundary.rs index 9da4b26..e50934e 100644 --- a/tests/prekey_upload_boundary.rs +++ b/tests/prekey_upload_boundary.rs @@ -300,7 +300,7 @@ async fn consume_pending( chat: "111@s.whatsapp.net".into(), sender: "111:1@s.whatsapp.net".into(), message_id: "upload-consumption".into(), - kind: encrypted.kind.wire().into(), + kind: encrypted.kind.as_str().into(), ciphertext: encrypted.ciphertext, padding_version: 2, is_from_me: false, diff --git a/tests/service_boundary.rs b/tests/service_boundary.rs index ab09d5f..a39fa79 100644 --- a/tests/service_boundary.rs +++ b/tests/service_boundary.rs @@ -1354,3 +1354,138 @@ async fn a_node_without_a_live_link_takes_no_leases() { assert!(node.session(SESSION).is_none()); node.shutdown().await; } + +#[tokio::test] +async fn encrypted_status_uses_scoped_session_and_separate_publication_event() { + let hub = Hub::start().await; + let records = Arc::new(MemoryRecordStore::new()); + let running = start(&hub, "node-status", Backend::Memory(records.clone()), false).await; + let generation = running.node.session(SESSION).unwrap().generation; + let mut receive = encrypted( + &hub, + "node-status", + &running, + wa::Message { + conversation: Some("application-private-text".into()), + ..Default::default() + }, + false, + ) + .await; + receive.chat = "status@broadcast".into(); + let invalid_scope = hub + .command( + "node-status", + generation, + Op::StatusReceive(proto::StatusReceive { + payload: Some(receive.clone()), + status_kind: "group".into(), + status_session: true, + }), + ) + .await; + assert!( + matches!(invalid_scope.body, Some(Body::Error(proto::Error {code, ..})) if code == proto::Code::InvalidArgument as i32) + ); + assert!( + records + .scan_keys(SESSION, Namespace::Session, "", None) + .await + .unwrap() + .is_empty() + ); + let client = reqwest::Client::new(); + let url = format!("http://{}", running.http_addr); + let mut stream = client + .get(format!("{url}/v1/events")) + .bearer_auth(APP_SECRET) + .send() + .await + .unwrap() + .bytes_stream(); + let command = hub.command( + "node-status", + generation, + Op::StatusReceive(proto::StatusReceive { + payload: Some(receive.clone()), + status_kind: "personal".into(), + status_session: true, + }), + ); + let app = async { + let event = next_event(&mut stream).await; + assert_eq!(event["text"], "application-private-text"); + assert_eq!(event["type"], "status.received"); + assert_eq!(event["status_scope"], "personal"); + assert!(!event["redelivered"].as_bool().unwrap()); + assert_eq!( + client + .post(format!( + "{url}/v1/events/{}/ack", + event["id"].as_str().unwrap() + )) + .bearer_auth(APP_SECRET) + .send() + .await + .unwrap() + .status(), + 204 + ); + event + }; + let (response, event) = tokio::join!(command, app); + assert!(matches!( + response.body, + Some(Body::ServiceResponse(proto::ServiceResponse { + result: Some(Out::Receive(proto::ReceiveResult { + already_delivered: false, + .. + })) + })) + )); + let again = hub + .command( + "node-status", + generation, + Op::StatusReceive(proto::StatusReceive { + payload: Some(receive), + status_kind: "personal".into(), + status_session: true, + }), + ) + .await; + assert!(matches!( + again.body, + Some(Body::ServiceResponse(proto::ServiceResponse { + result: Some(Out::Receive(proto::ReceiveResult { + already_delivered: true, + .. + })) + })) + )); + for ns in Namespace::ALL { + for key in records.scan_keys(SESSION, ns, "", None).await.unwrap() { + let value = records.get(SESSION, ns, &key).await.unwrap().unwrap(); + assert!( + !value + .windows(b"application-private-text".len()) + .any(|part| part == b"application-private-text") + ); + } + } + assert_eq!( + client + .post(format!( + "{url}/v1/events/{}/ack", + event["id"].as_str().unwrap() + )) + .bearer_auth(APP_SECRET) + .send() + .await + .unwrap() + .status(), + 404 + ); + drop(stream); + running.shutdown().await; +} From 1caf037b8b5640f1d94665dd4cd8a955496afca7 Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Sun, 15 Nov 2026 22:18:06 +0200 Subject: [PATCH 2/7] fix: return publication context for legacy group receipts --- Cargo.lock | 18 +-- Cargo.toml | 14 +- README.md | 5 + .../polymorfa/signal/v1/signal_service.proto | 2 + src/serve.rs | 40 ++++- tests/service_boundary.rs | 138 ++++++++++++++++++ 6 files changed, 194 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9a4649..a8106b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3245,7 +3245,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wacore" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" dependencies = [ "aes 0.9.3", "anyhow", @@ -3294,7 +3294,7 @@ dependencies = [ [[package]] name = "wacore-appstate" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" dependencies = [ "anyhow", "buffa", @@ -3315,7 +3315,7 @@ dependencies = [ [[package]] name = "wacore-binary" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" dependencies = [ "bytes", "compact_str", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "wacore-derive" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" dependencies = [ "proc-macro2", "quote", @@ -3342,7 +3342,7 @@ dependencies = [ [[package]] name = "wacore-libsignal" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" dependencies = [ "aes 0.9.3", "async-lock", @@ -3373,7 +3373,7 @@ dependencies = [ [[package]] name = "wacore-noise" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" dependencies = [ "anyhow", "buffa", @@ -3391,7 +3391,7 @@ dependencies = [ [[package]] name = "wacore-recordstore" version = "0.1.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" dependencies = [ "aes-gcm 0.11.1", "async-lock", @@ -3405,7 +3405,7 @@ dependencies = [ [[package]] name = "wacore-signal-ops" version = "0.1.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" dependencies = [ "anyhow", "async-lock", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "waproto" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=90df5a8728e23afe2331bf9c26a74f7318c5a8dc#90df5a8728e23afe2331bf9c26a74f7318c5a8dc" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" dependencies = [ "buffa", "buffa-build", diff --git a/Cargo.toml b/Cargo.toml index c8bc109..787a760 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,11 +18,11 @@ path = "src/main.rs" [dependencies] # Signal core, pinned to polymorfa/whatsapp-rust branch polymorfa/recordstore. -wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc" } -wacore-binary = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc" } -wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc" } -wacore-signal-ops = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc" } -waproto = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc" } +wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e" } +wacore-binary = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e" } +wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e" } +wacore-signal-ops = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e" } +waproto = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e" } aes-gcm = "0.10" anyhow = "1" @@ -55,7 +55,7 @@ protox = "0.9" [dev-dependencies] tokio = { version = "1", features = ["test-util"] } -wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc", features = ["test-util"] } +wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e", features = ["test-util"] } rand10 = { package = "rand", version = "0.10" } -wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "90df5a8728e23afe2331bf9c26a74f7318c5a8dc", features = ["conformance"] } +wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e", features = ["conformance"] } reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json", "stream"] } diff --git a/README.md b/README.md index 15e3053..4b4746b 100644 --- a/README.md +++ b/README.md @@ -178,3 +178,8 @@ The receiver delivers `status.received` with `status_scope` and the existing sha content fields. Group publications retain their full protobuf while text and media use the wrapped publication content. Replies and mention notifications remain messages. Local synthetic tests do not establish live rollout eligibility. + +Legacy group publication wrappers also return their classification for delivery +receipts, including after application acknowledgment. Delivered markers retain +only that classification, not plaintext. Empty markers written by older versions +have unknown classification; no sender or publication scope is guessed from them. diff --git a/proto/polymorfa/signal/v1/signal_service.proto b/proto/polymorfa/signal/v1/signal_service.proto index ae865f2..1012c51 100644 --- a/proto/polymorfa/signal/v1/signal_service.proto +++ b/proto/polymorfa/signal/v1/signal_service.proto @@ -230,6 +230,8 @@ message StatusReceive { } message ReceiveResult { + // Decrypted publication context for receipts. Empty when unknown. + string status_kind = 5; bool already_delivered = 1; bool redelivered = 2; bool sender_key_rejected = 3; diff --git a/src/serve.rs b/src/serve.rs index d020963..71736d1 100644 --- a/src/serve.rs +++ b/src/serve.rs @@ -297,7 +297,10 @@ async fn receive( error })?; let message = match received { - Received::AlreadyDelivered { receipt_key } => { + Received::AlreadyDelivered { + receipt_key, + group_status_wrapper, + } => { let app_state_key_share = if node.cfg.share_app_state_keys && receive.is_from_me { let cutoff = crate::node::now_ms() .saturating_sub(node.cfg.decrypt_buffer_retention.as_millis() as u64); @@ -315,6 +318,13 @@ async fn receive( )); } return respond(Out::Receive(ReceiveResult { + status_kind: publication_kind( + &receive, + status_kind, + group_status_wrapper == Some(true), + ) + .unwrap_or("") + .to_owned(), already_delivered: true, app_state_key_share, ..Default::default() @@ -323,6 +333,12 @@ async fn receive( Received::Message(message) => message, }; + let status_kind = publication_kind( + &receive, + status_kind, + message.content.message.group_status_message_v2.is_set(), + ); + // Explicit operator consent in addition to the pinned core own-device gate. let app_state_key_share = if node.cfg.share_app_state_keys && receive.is_from_me { message @@ -364,6 +380,7 @@ async fn receive( .await .map_err(|e| node.ops_error(session, &e))?; respond(Out::Receive(ReceiveResult { + status_kind: status_kind.unwrap_or("").to_owned(), already_delivered: false, redelivered: message.redelivered, sender_key_rejected: message.sender_key_rejected, @@ -374,6 +391,16 @@ async fn receive( /// The application event for a received message, or `None` when the /// message is protocol-only (sender keys, app-state keys, peer data /// operations) or is history and history delivery is off. +fn publication_kind<'a>( + receive: &proto::Receive, + explicit: Option<&'a str>, + group_wrapper: bool, +) -> Option<&'a str> { + explicit + .or_else(|| (receive.chat.ends_with("@g.us") && group_wrapper).then_some("group")) + .or_else(|| (receive.chat == "status@broadcast").then_some("personal")) +} + fn event_for( node: &Node, session: &ActiveSession, @@ -385,12 +412,11 @@ fn event_for( if content.is_skdm_only { return None; } - let status_kind = status_kind - .or_else(|| { - (receive.chat.ends_with("@g.us") && content.message.group_status_message_v2.is_set()) - .then_some("group") - }) - .or_else(|| (receive.chat == "status@broadcast").then_some("personal")); + let status_kind = publication_kind( + receive, + status_kind, + content.message.group_status_message_v2.is_set(), + ); let base = |kind: &'static str| Event { id: received.receipt_key.clone(), kind, diff --git a/tests/service_boundary.rs b/tests/service_boundary.rs index a39fa79..beb232b 100644 --- a/tests/service_boundary.rs +++ b/tests/service_boundary.rs @@ -1489,3 +1489,141 @@ async fn encrypted_status_uses_scoped_session_and_separate_publication_event() { drop(stream); running.shutdown().await; } + +#[tokio::test] +async fn legacy_group_publication_classification_survives_duplicate_delivery() { + let hub = Hub::start().await; + let records = Arc::new(MemoryRecordStore::new()); + let running = start( + &hub, + "node-legacy-group-status", + Backend::Memory(records.clone()), + false, + ) + .await; + let generation = running.node.session(SESSION).unwrap().generation; + let mut receive = encrypted( + &hub, + "node-legacy-group-status", + &running, + wa::Message { + group_status_message_v2: wa::message::FutureProofMessage { + message: wa::Message { + conversation: Some("application-private-text".into()), + ..Default::default() + } + .into(), + } + .into(), + ..Default::default() + }, + false, + ) + .await; + receive.chat = "120363000000001@g.us".into(); + let invalid_scope = hub + .command( + "node-legacy-group-status", + generation, + Op::StatusReceive(proto::StatusReceive { + payload: Some(receive.clone()), + status_kind: "personal".into(), + status_session: true, + }), + ) + .await; + assert!( + matches!(invalid_scope.body, Some(Body::Error(proto::Error {code, ..})) if code == proto::Code::InvalidArgument as i32) + ); + assert!( + records + .scan_keys(SESSION, Namespace::Session, "", None) + .await + .unwrap() + .is_empty() + ); + let client = reqwest::Client::new(); + let url = format!("http://{}", running.http_addr); + let mut stream = client + .get(format!("{url}/v1/events")) + .bearer_auth(APP_SECRET) + .send() + .await + .unwrap() + .bytes_stream(); + let command = hub.command( + "node-legacy-group-status", + generation, + Op::Receive(receive.clone()), + ); + let app = async { + let event = next_event(&mut stream).await; + assert_eq!(event["text"], "application-private-text"); + assert_eq!(event["type"], "status.received"); + assert_eq!(event["status_scope"], "group"); + assert!(!event["redelivered"].as_bool().unwrap()); + assert_eq!( + client + .post(format!( + "{url}/v1/events/{}/ack", + event["id"].as_str().unwrap() + )) + .bearer_auth(APP_SECRET) + .send() + .await + .unwrap() + .status(), + 204 + ); + event + }; + let (response, event) = tokio::join!(command, app); + assert!(matches!( + response.body, + Some(Body::ServiceResponse(proto::ServiceResponse { + result: Some(Out::Receive(proto::ReceiveResult { + already_delivered: false, + status_kind: ref classification, + .. + })) + })) if classification == "group" + )); + let again = hub + .command("node-legacy-group-status", generation, Op::Receive(receive)) + .await; + assert!(matches!( + again.body, + Some(Body::ServiceResponse(proto::ServiceResponse { + result: Some(Out::Receive(proto::ReceiveResult { + already_delivered: true, + status_kind: ref classification, + .. + })) + })) if classification == "group" + )); + for ns in Namespace::ALL { + for key in records.scan_keys(SESSION, ns, "", None).await.unwrap() { + let value = records.get(SESSION, ns, &key).await.unwrap().unwrap(); + assert!( + !value + .windows(b"application-private-text".len()) + .any(|part| part == b"application-private-text") + ); + } + } + assert_eq!( + client + .post(format!( + "{url}/v1/events/{}/ack", + event["id"].as_str().unwrap() + )) + .bearer_auth(APP_SECRET) + .send() + .await + .unwrap() + .status(), + 404 + ); + drop(stream); + running.shutdown().await; +} From b4e013ac8965e1202a5784c29a0c84c9c77c755b Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Mon, 16 Nov 2026 22:51:08 +0200 Subject: [PATCH 3/7] fix: adopt status identity cleanup and check pending-event sealing --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 14 +++++++------- tests/service_boundary.rs | 37 +++++++++++++++++-------------------- 3 files changed, 33 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a8106b1..9375f69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3245,7 +3245,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wacore" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" dependencies = [ "aes 0.9.3", "anyhow", @@ -3294,7 +3294,7 @@ dependencies = [ [[package]] name = "wacore-appstate" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" dependencies = [ "anyhow", "buffa", @@ -3315,7 +3315,7 @@ dependencies = [ [[package]] name = "wacore-binary" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" dependencies = [ "bytes", "compact_str", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "wacore-derive" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" dependencies = [ "proc-macro2", "quote", @@ -3342,7 +3342,7 @@ dependencies = [ [[package]] name = "wacore-libsignal" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" dependencies = [ "aes 0.9.3", "async-lock", @@ -3373,7 +3373,7 @@ dependencies = [ [[package]] name = "wacore-noise" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" dependencies = [ "anyhow", "buffa", @@ -3391,7 +3391,7 @@ dependencies = [ [[package]] name = "wacore-recordstore" version = "0.1.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" dependencies = [ "aes-gcm 0.11.1", "async-lock", @@ -3405,7 +3405,7 @@ dependencies = [ [[package]] name = "wacore-signal-ops" version = "0.1.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" dependencies = [ "anyhow", "async-lock", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "waproto" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=71525d8f0a4ada89560b95a9156b3d17d7d8414e#71525d8f0a4ada89560b95a9156b3d17d7d8414e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" dependencies = [ "buffa", "buffa-build", diff --git a/Cargo.toml b/Cargo.toml index 787a760..6942803 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,11 +18,11 @@ path = "src/main.rs" [dependencies] # Signal core, pinned to polymorfa/whatsapp-rust branch polymorfa/recordstore. -wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e" } -wacore-binary = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e" } -wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e" } -wacore-signal-ops = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e" } -waproto = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e" } +wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e" } +wacore-binary = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e" } +wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e" } +wacore-signal-ops = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e" } +waproto = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e" } aes-gcm = "0.10" anyhow = "1" @@ -55,7 +55,7 @@ protox = "0.9" [dev-dependencies] tokio = { version = "1", features = ["test-util"] } -wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e", features = ["test-util"] } +wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e", features = ["test-util"] } rand10 = { package = "rand", version = "0.10" } -wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "71525d8f0a4ada89560b95a9156b3d17d7d8414e", features = ["conformance"] } +wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e", features = ["conformance"] } reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json", "stream"] } diff --git a/tests/service_boundary.rs b/tests/service_boundary.rs index beb232b..252dc45 100644 --- a/tests/service_boundary.rs +++ b/tests/service_boundary.rs @@ -1418,6 +1418,7 @@ async fn encrypted_status_uses_scoped_session_and_separate_publication_event() { assert_eq!(event["type"], "status.received"); assert_eq!(event["status_scope"], "personal"); assert!(!event["redelivered"].as_bool().unwrap()); + assert_status_records_sealed(&records).await; assert_eq!( client .post(format!( @@ -1463,16 +1464,7 @@ async fn encrypted_status_uses_scoped_session_and_separate_publication_event() { })) })) )); - for ns in Namespace::ALL { - for key in records.scan_keys(SESSION, ns, "", None).await.unwrap() { - let value = records.get(SESSION, ns, &key).await.unwrap().unwrap(); - assert!( - !value - .windows(b"application-private-text".len()) - .any(|part| part == b"application-private-text") - ); - } - } + assert_status_records_sealed(&records).await; assert_eq!( client .post(format!( @@ -1562,6 +1554,7 @@ async fn legacy_group_publication_classification_survives_duplicate_delivery() { assert_eq!(event["type"], "status.received"); assert_eq!(event["status_scope"], "group"); assert!(!event["redelivered"].as_bool().unwrap()); + assert_status_records_sealed(&records).await; assert_eq!( client .post(format!( @@ -1601,16 +1594,7 @@ async fn legacy_group_publication_classification_survives_duplicate_delivery() { })) })) if classification == "group" )); - for ns in Namespace::ALL { - for key in records.scan_keys(SESSION, ns, "", None).await.unwrap() { - let value = records.get(SESSION, ns, &key).await.unwrap().unwrap(); - assert!( - !value - .windows(b"application-private-text".len()) - .any(|part| part == b"application-private-text") - ); - } - } + assert_status_records_sealed(&records).await; assert_eq!( client .post(format!( @@ -1627,3 +1611,16 @@ async fn legacy_group_publication_classification_survives_duplicate_delivery() { drop(stream); running.shutdown().await; } + +async fn assert_status_records_sealed(records: &MemoryRecordStore) { + for ns in Namespace::ALL { + for key in records.scan_keys(SESSION, ns, "", None).await.unwrap() { + let value = records.get(SESSION, ns, &key).await.unwrap().unwrap(); + assert!( + !value + .windows(b"application-private-text".len()) + .any(|part| part == b"application-private-text") + ); + } + } +} From a1b8b496be1bac273b5f43b04418f27f38b1d00e Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Mon, 16 Nov 2026 23:39:26 +0200 Subject: [PATCH 4/7] fix(signal): pin identity-aware sibling session retention --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9375f69..9f9b125 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3245,7 +3245,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wacore" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" dependencies = [ "aes 0.9.3", "anyhow", @@ -3294,7 +3294,7 @@ dependencies = [ [[package]] name = "wacore-appstate" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" dependencies = [ "anyhow", "buffa", @@ -3315,7 +3315,7 @@ dependencies = [ [[package]] name = "wacore-binary" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" dependencies = [ "bytes", "compact_str", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "wacore-derive" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" dependencies = [ "proc-macro2", "quote", @@ -3342,7 +3342,7 @@ dependencies = [ [[package]] name = "wacore-libsignal" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" dependencies = [ "aes 0.9.3", "async-lock", @@ -3373,7 +3373,7 @@ dependencies = [ [[package]] name = "wacore-noise" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" dependencies = [ "anyhow", "buffa", @@ -3391,7 +3391,7 @@ dependencies = [ [[package]] name = "wacore-recordstore" version = "0.1.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" dependencies = [ "aes-gcm 0.11.1", "async-lock", @@ -3405,7 +3405,7 @@ dependencies = [ [[package]] name = "wacore-signal-ops" version = "0.1.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" dependencies = [ "anyhow", "async-lock", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "waproto" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=88959324253b80f22e16d93039b61c437037bf6e#88959324253b80f22e16d93039b61c437037bf6e" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" dependencies = [ "buffa", "buffa-build", diff --git a/Cargo.toml b/Cargo.toml index 6942803..a6ee558 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,11 +18,11 @@ path = "src/main.rs" [dependencies] # Signal core, pinned to polymorfa/whatsapp-rust branch polymorfa/recordstore. -wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e" } -wacore-binary = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e" } -wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e" } -wacore-signal-ops = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e" } -waproto = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e" } +wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb" } +wacore-binary = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb" } +wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb" } +wacore-signal-ops = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb" } +waproto = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb" } aes-gcm = "0.10" anyhow = "1" @@ -55,7 +55,7 @@ protox = "0.9" [dev-dependencies] tokio = { version = "1", features = ["test-util"] } -wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e", features = ["test-util"] } +wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb", features = ["test-util"] } rand10 = { package = "rand", version = "0.10" } -wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "88959324253b80f22e16d93039b61c437037bf6e", features = ["conformance"] } +wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb", features = ["conformance"] } reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json", "stream"] } From 3615cec1b0d83395a928e996dca4d486c33e08a5 Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Tue, 17 Nov 2026 00:48:55 +0200 Subject: [PATCH 5/7] Pin shared bundle identity invalidation --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9f9b125..5c1ebf2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3245,7 +3245,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wacore" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" dependencies = [ "aes 0.9.3", "anyhow", @@ -3294,7 +3294,7 @@ dependencies = [ [[package]] name = "wacore-appstate" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" dependencies = [ "anyhow", "buffa", @@ -3315,7 +3315,7 @@ dependencies = [ [[package]] name = "wacore-binary" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" dependencies = [ "bytes", "compact_str", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "wacore-derive" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" dependencies = [ "proc-macro2", "quote", @@ -3342,7 +3342,7 @@ dependencies = [ [[package]] name = "wacore-libsignal" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" dependencies = [ "aes 0.9.3", "async-lock", @@ -3373,7 +3373,7 @@ dependencies = [ [[package]] name = "wacore-noise" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" dependencies = [ "anyhow", "buffa", @@ -3391,7 +3391,7 @@ dependencies = [ [[package]] name = "wacore-recordstore" version = "0.1.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" dependencies = [ "aes-gcm 0.11.1", "async-lock", @@ -3405,7 +3405,7 @@ dependencies = [ [[package]] name = "wacore-signal-ops" version = "0.1.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" dependencies = [ "anyhow", "async-lock", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "waproto" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=b342a36247a7a63f92023c83f0c3743b4c196bdb#b342a36247a7a63f92023c83f0c3743b4c196bdb" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" dependencies = [ "buffa", "buffa-build", diff --git a/Cargo.toml b/Cargo.toml index a6ee558..d9fa712 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,11 +18,11 @@ path = "src/main.rs" [dependencies] # Signal core, pinned to polymorfa/whatsapp-rust branch polymorfa/recordstore. -wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb" } -wacore-binary = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb" } -wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb" } -wacore-signal-ops = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb" } -waproto = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb" } +wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52" } +wacore-binary = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52" } +wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52" } +wacore-signal-ops = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52" } +waproto = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52" } aes-gcm = "0.10" anyhow = "1" @@ -55,7 +55,7 @@ protox = "0.9" [dev-dependencies] tokio = { version = "1", features = ["test-util"] } -wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb", features = ["test-util"] } +wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52", features = ["test-util"] } rand10 = { package = "rand", version = "0.10" } -wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "b342a36247a7a63f92023c83f0c3743b4c196bdb", features = ["conformance"] } +wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52", features = ["conformance"] } reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json", "stream"] } From 7fa64673d2943574c139917b0781032c1915b983 Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Tue, 17 Nov 2026 01:34:57 +0200 Subject: [PATCH 6/7] Pin atomic bundle finalization for Signal sends --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c1ebf2..b33c8f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3245,7 +3245,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wacore" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=7f84b42532acc90e58322f447c3026aebab812f1#7f84b42532acc90e58322f447c3026aebab812f1" dependencies = [ "aes 0.9.3", "anyhow", @@ -3294,7 +3294,7 @@ dependencies = [ [[package]] name = "wacore-appstate" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=7f84b42532acc90e58322f447c3026aebab812f1#7f84b42532acc90e58322f447c3026aebab812f1" dependencies = [ "anyhow", "buffa", @@ -3315,7 +3315,7 @@ dependencies = [ [[package]] name = "wacore-binary" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=7f84b42532acc90e58322f447c3026aebab812f1#7f84b42532acc90e58322f447c3026aebab812f1" dependencies = [ "bytes", "compact_str", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "wacore-derive" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=7f84b42532acc90e58322f447c3026aebab812f1#7f84b42532acc90e58322f447c3026aebab812f1" dependencies = [ "proc-macro2", "quote", @@ -3342,7 +3342,7 @@ dependencies = [ [[package]] name = "wacore-libsignal" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=7f84b42532acc90e58322f447c3026aebab812f1#7f84b42532acc90e58322f447c3026aebab812f1" dependencies = [ "aes 0.9.3", "async-lock", @@ -3373,7 +3373,7 @@ dependencies = [ [[package]] name = "wacore-noise" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=7f84b42532acc90e58322f447c3026aebab812f1#7f84b42532acc90e58322f447c3026aebab812f1" dependencies = [ "anyhow", "buffa", @@ -3391,7 +3391,7 @@ dependencies = [ [[package]] name = "wacore-recordstore" version = "0.1.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=7f84b42532acc90e58322f447c3026aebab812f1#7f84b42532acc90e58322f447c3026aebab812f1" dependencies = [ "aes-gcm 0.11.1", "async-lock", @@ -3405,7 +3405,7 @@ dependencies = [ [[package]] name = "wacore-signal-ops" version = "0.1.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=7f84b42532acc90e58322f447c3026aebab812f1#7f84b42532acc90e58322f447c3026aebab812f1" dependencies = [ "anyhow", "async-lock", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "waproto" version = "0.7.0" -source = "git+https://github.com/polymorfa/whatsapp-rust?rev=e1e3f17b0fae90c381143ef0be42c07c637dab52#e1e3f17b0fae90c381143ef0be42c07c637dab52" +source = "git+https://github.com/polymorfa/whatsapp-rust?rev=7f84b42532acc90e58322f447c3026aebab812f1#7f84b42532acc90e58322f447c3026aebab812f1" dependencies = [ "buffa", "buffa-build", diff --git a/Cargo.toml b/Cargo.toml index d9fa712..8a82e79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,11 +18,11 @@ path = "src/main.rs" [dependencies] # Signal core, pinned to polymorfa/whatsapp-rust branch polymorfa/recordstore. -wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52" } -wacore-binary = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52" } -wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52" } -wacore-signal-ops = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52" } -waproto = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52" } +wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "7f84b42532acc90e58322f447c3026aebab812f1" } +wacore-binary = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "7f84b42532acc90e58322f447c3026aebab812f1" } +wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "7f84b42532acc90e58322f447c3026aebab812f1" } +wacore-signal-ops = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "7f84b42532acc90e58322f447c3026aebab812f1" } +waproto = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "7f84b42532acc90e58322f447c3026aebab812f1" } aes-gcm = "0.10" anyhow = "1" @@ -55,7 +55,7 @@ protox = "0.9" [dev-dependencies] tokio = { version = "1", features = ["test-util"] } -wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52", features = ["test-util"] } +wacore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "7f84b42532acc90e58322f447c3026aebab812f1", features = ["test-util"] } rand10 = { package = "rand", version = "0.10" } -wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "e1e3f17b0fae90c381143ef0be42c07c637dab52", features = ["conformance"] } +wacore-recordstore = { git = "https://github.com/polymorfa/whatsapp-rust", rev = "7f84b42532acc90e58322f447c3026aebab812f1", features = ["conformance"] } reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json", "stream"] } From 09bee7f54f6607977dd9796de3addcfbfe38c806 Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Tue, 17 Nov 2026 06:01:02 +0200 Subject: [PATCH 7/7] Preserve lease refusal through finalization errors --- crates/signal-ops/src/error.rs | 18 +++++++++++++++--- crates/signal-ops/src/stores.rs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/crates/signal-ops/src/error.rs b/crates/signal-ops/src/error.rs index 5621210..9c67591 100644 --- a/crates/signal-ops/src/error.rs +++ b/crates/signal-ops/src/error.rs @@ -49,10 +49,22 @@ impl OpsError { pub fn is_fence_lost(&self) -> bool { match self { OpsError::Store(e) => state_is_refused(e), - OpsError::Signal(SignalProtocolError::BackendError(_, source)) => source - .downcast_ref::() - .is_some_and(state_is_refused), + OpsError::Signal(error) => signal_state_is_refused(error), _ => false, } } } + +fn signal_state_is_refused(error: &SignalProtocolError) -> bool { + let mut source: Option<&(dyn std::error::Error + 'static)> = Some(error); + while let Some(current) = source { + if current + .downcast_ref::() + .is_some_and(state_is_refused) + { + return true; + } + source = current.source(); + } + false +} diff --git a/crates/signal-ops/src/stores.rs b/crates/signal-ops/src/stores.rs index 286dbd5..3cfe863 100644 --- a/crates/signal-ops/src/stores.rs +++ b/crates/signal-ops/src/stores.rs @@ -528,4 +528,37 @@ mod tests { ); }); } + + #[test] + fn service_classification_keeps_the_actual_finalization_fence_cause() { + let lost = wacore_recordstore::FenceLost { + scope: "authored-finalization-source".into(), + generation: 7, + } + .into_store_error(); + let source = SignalProtocolError::BackendError("authored store", Box::new(lost)); + let error = crate::OpsError::Signal(SignalProtocolError::BackendError( + "session finalization", + Box::new(SharedFinalizationError(Arc::new(source))), + )); + assert!( + error.is_fence_lost(), + "service lost the fence refusal inside its finalization wrapper" + ); + } + + #[test] + fn service_classification_does_not_turn_finalization_io_into_fence_loss() { + let source = SignalProtocolError::BackendError( + "authored store", + Box::new(wacore::store::error::StoreError::Io(std::io::Error::other( + "authored ordinary I/O", + ))), + ); + let error = crate::OpsError::Signal(SignalProtocolError::BackendError( + "session finalization", + Box::new(SharedFinalizationError(Arc::new(source))), + )); + assert!(!error.is_fence_lost()); + } }