package main import ( "os" "path/filepath" "regexp" "strings" "testing" ) // RULE: the WhatsApp helper sends only text and replies the owner typed, and only from send.go — never a reaction, a read receipt, an edit, a deletion, a presence or a typing state; its one other send is a history request to the account's own phone. // The owner ruled the first version read-only (note 7767ed9c): a linked device that sends acts in his name, and WhatsApp bans numbers that act like bots. // Owner priority, Oct 2026, narrowed it: Cotton sends the text and replies the owner typed, through SendMessage in send.go alone. // Linking is no send: the passkey answer and its confirmation (Nov 2026) go to WhatsApp's server during a pairing, from pairing.go alone. // Owner, FEEDBACK-3 (23 Nov 2026): he uses WhatsApp completely from inside Comms, so send_kinds.go also sends his pictures, videos, voice notes, documents, reactions, edits, deletes, polls and votes, each by his own tap; nothing else in the helper sends. // Owner, FEEDBACK-3 (23 Nov 2026): a file WhatsApp's servers no longer hold is asked of his own phone again, from reupload.go alone (a media retry receipt goes to his own devices, never to the other person). // Owner, 24 Nov 2026 (CONTRACT "Blocking a WhatsApp sender, deleting a WhatsApp chat"): source_acts.go alone blocks // and unblocks a person (UpdateBlocklist) and deletes a person's chat for him (SendAppState, with BuildDeleteChat the // only patch built anywhere). Still forbidden everywhere: archive, pin, mute, mark read or played, star, labels, // privacy settings, presence, status, and every group act. // Owner rule, 7 Oct 2026: sending is proven only on synthetic households, the simulator and a fake helper — never his account, a real contact, the real data folder or the real helper on his Mac; he tests it himself on a build. func TestHelperNeverSends(t *testing.T) { forbidden := regexp.MustCompile(`\.(Send[A-Za-z]*|MarkRead|RevokeMessage|BuildRevoke|BuildEdit|BuildReaction|BuildPollVote|SubscribePresence|SetStatusMessage|SetGroup[A-Za-z]*|JoinGroup[A-Za-z]*|LeaveGroup|CreateGroup|UpdateGroupParticipants|SetDisappearingTimer|UpdateBlocklist|SendAppState|SetPrivacySetting)\(`) files, err := filepath.Glob("*.go") if err != nil { t.Fatal(err) } for _, f := range files { if strings.HasSuffix(f, "_test.go") { continue } src, err := os.ReadFile(f) if err != nil { t.Fatal(err) } for i, line := range strings.Split(string(src), "\n") { for _, m := range forbidden.FindAllStringSubmatch(line, -1) { switch { case m[1] == "SendPeerMessage": if !strings.Contains(line, "BuildHistorySyncRequest") { t.Errorf("%s:%d: SendPeerMessage may carry only a history request: %s", f, i+1, strings.TrimSpace(line)) } case m[1] == "SendMessage" && (f == "send.go" || f == "send_kinds.go"): case (m[1] == "BuildReaction" || m[1] == "BuildEdit" || m[1] == "BuildRevoke" || m[1] == "BuildPollVote") && f == "send_kinds.go": case m[1] == "SendMediaRetryReceipt" && f == "reupload.go": case (m[1] == "SendPasskeyResponse" || m[1] == "SendPasskeyConfirmation") && f == "pairing.go": case (m[1] == "UpdateBlocklist" || m[1] == "SendAppState") && f == "source_acts.go": case m[1] == "Send" && f == "server.go" && strings.Contains(line, "h.Send("): // dispatch calling Hub.Send in send.go case m[1] == "SendKind" && f == "server.go" && strings.Contains(line, "h.SendKind("): // dispatch calling Hub.SendKind in send_kinds.go default: t.Errorf("%s:%d: the helper sends only the owner's text, from send.go; %s acts in the owner's name: %s", f, i+1, m[1], strings.TrimSpace(line)) } } // One app-state patch is built anywhere: a person's chat deleted for him (source_acts.go). for _, m := range patches.FindAllStringSubmatch(line, -1) { if m[1] != "DeleteChat" || f != "source_acts.go" { t.Errorf("%s:%d: the helper changes WhatsApp's state only to delete a chat for him, from source_acts.go; appstate.Build%s does more: %s", f, i+1, m[1], strings.TrimSpace(line)) } } } } } // Every builder of WhatsApp's app state (archive, pin, mute, mark read, star, labels, settings, delete chat). var patches = regexp.MustCompile(`appstate\.Build([A-Za-z]+)\(`)