From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796453794; b=rBNTizdk305kH0hCbtjVyu7EjZtwY1WADBZhR5kULg/VPtrvi6WqnywOxJ80B9dYXEus UqxtQVd1djhLALwI4+R6l2VJVmAQ2Uv8S+pacectWlzKzrRe9B2KhYNL7sW/hLMmv53QY Q+2AJnHMNqfkEtwhdUN24/wED1JuXGWW6UVhbFdF3F/TaSqXIiAVXpiv9f+JU7IiViivf 6+tZYJztZcCk+bQN/CaB2OpDEZ155r2fMYAJRv9GGhQ6fQ2joi6BWH+Y99yp8q7k+e0xW RjlTrc5DLi2hASmEvHTnCcofGCS6ghFejsb5C8WGiMDCmI2TWgUUarW01zZboLnIZRA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796453794; h=Received:Delivered-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received: Received:From:Subject:Date:Message-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer; bh=RVp4pgycWkv1/eRZ37rMAMvSlI9hm9Y1WIQ8GKHAndw=; b=rTG+j5SHuIKyd48+pGq2KbJsByBWMybnHMGeIM/WdZkfGQNqp5DMf15rNEi0uOO3+bK4 mO4L4GexG/I8BZeuXtkYe3zRUj+j0hnNWE/d09qC//6P2CFszDiF/obsuhPXTo9lGyrHk 14lnVT6sbARGLBWBdKXCDxw6vu2c8USdWsJgyw1TK9eWObILbjWN+Kz04Yu9Tb658KzN0 Skn26TkWZs0Zu8P6rkCNA8Ev3fjfpgzv+YeFpZiSR/thI5q/dDE6yDAFzKcMMFTsGsPsg +Xhryvi1PIGKssOFyKLv6DH43nQqwoAoCOMwrBsHhCgd8P4PxZ2cLMIIcAoaHANk7kQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Zy9Mybvt; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8B4F606A322 for ; Sat, 5 Dec 2026 06:56:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Zy9Mybvt Received: by smtp.kernel.org (Postfix) id AA5391F00A07; Sat, 5 Dec 2026 06:56:34 +0000 (UTC) Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=74.125.82.53 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796453794; b=sDAXGcQLtbl85JWGFVE0aiPtkc4GdD16QVaUhdUftO4iU4M1Lt8tw1WDkbxvOvc2WEpn DKAgLvnXvOQFssHKa4W6n6ba9I3r4UQ5m9dSo8mzPRmbKp6TzXms9qL3zd1/kl11oezvQ LJThBnqE03m7HW6lIWhJ6ALN+AzRA5iRWG28ZWtC2PNe5pl5obSS5iFUy7/zqeobkreVP l1kZ+Vu6WDNlk9CfJ+7e+IHFgUtJG69uJxcC31Vb4kzLU4gJ3M9RGCevs30hcbZ/ybLSt dyEUCGAwDHaxVxZie4IX6IGVpLLGi6i+Yfnbckcyb5633JfCLk10z0Hv8l9PusbhPtA== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796453794; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:Subject:Date: Message-Id:MIME-Version:Content-Type:Content-Transfer-Encoding: X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer; bh=RVp4pgycWkv1/eRZ37rMAMvSlI9hm9Y1WIQ8GKHAndw=; b=rsryS6DJ5ZQRQL6L3hRFzJHLVfSmYw/E32Lw2dcWbiXWXMV0mbl8pde5XmnFAnqadPKT yqiPDNctB0DdObCYr1Es861/GzsE1Wk9ZTtKBHb439tqmURhQRrqMVapyVoHN4GrcEpU7 lRQgKEtiZ3qF75dVGuYSUKoWnu5eAXAog/vCTmy6w6u58mNRDNj57y42sc0AmbTAfcWnO qRjXCZEyeozvqj070Tb72fxZ6b7V9jhDNj3k9zrO5IXbPuuX5yEqMKr3UiIf5FWHtAhin yChTMYCwXv8iPOvBN9lJyQqApssdLvdShUr+5FaJpZLNxl27G0J+Q+UL4Uy8i9IpCXA== ARC-Authentication-Results: i=1; smtp.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Zy9Mybvt; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.remote-ip=74.125.82.53 Received: from mail-dl1-f53.google.com (mail-dl1-f53.google.com [74.125.82.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 077001F0092B for ; Sat, 5 Dec 2026 06:56:33 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Zy9Mybvt DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.kernel.org 077001F0092B Authentication-Results: smtp.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-dl1-f53.google.com with SMTP id a92af1059eb24-1b546061d58so3896511c88.1 for ; Fri, 04 Dec 2026 22:56:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796453793; x=1797058593; darn=kernel.org; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=RVp4pgycWkv1/eRZ37rMAMvSlI9hm9Y1WIQ8GKHAndw=; b=Zy9MybvttGh3UqB4FZ1uwZq2O1XwFa4i9Y5fjIkb0pZH1fzqtQMIihiDVlWlB/ns88 uudaU0XnzlJB44qgSPMpHdqS3hDJtkLI/8xijeO+AEcOYUZb5jFPiYgzxNA+7Xnt+TIS jhL0/ybrX279UoNmBa+yC6QSrydOYhxZxu4NdeqQnARlKZ+uKIYMF5zwVjGRTAncS+7J +b/7LA85gAMI6wWLbSJPu+M48BRUUwtnvR5uHRN1KkEyEb96rFXQd48tQ59ZaOSoJ5Q+ n5Bv2UoasIx0iLSdnTkJyLEt/TuEXnrUK478xbfgTzAaPttjaCwVf2fit1U2XYBxJGy8 sjbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796453793; x=1797058593; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=RVp4pgycWkv1/eRZ37rMAMvSlI9hm9Y1WIQ8GKHAndw=; b=jvfGP2pryHt7iBrD3goOiqmMf65vkchNCLxcxFRWXNP/1xeN2NtuPuygmT3oXiIpLN 1tCYLrl/upEC5cMyBY9LDf24E9mGyk1fI1CBsZwk1jwXq0DQixkaIGEw3WCrn6DJnTEq w0rhX+S7wmIppJ7fdVEUTPBsIPCXuORg2vi9Pd0FWYdl9GhJBjUSghuCwQAYFRUAUSp3 WMgRz/0nD0B4EMKKyHk0dI2Wsy6D4vi9zEtD/1N0l6+NTt2xQZltdZYHBJ5ey1cyDSnw r2ZzFlzzUsoi5/N7mi25kTS9S0aHLFHGNER+kCQ+cnl0PFMJ/BfyTkt0KIc3x/s0Ft2a eZ0A== X-Gm-Message-State: APuU4Z+QGYPBUKx89ALGttZNvzhprNVqTngM59jRZElj7h6LdrfymJie jonhsaGHAWmGJauV7PEp1GtEm5CH1+ouliNL18TPwDFfcoPBV7kw0+mF X-Gm-Gg: AZFdTZcPlBgBW9U3hxnFJh4WwC+/MvkyJRzx/7YotoMM3mP/v3QXU1u3TN2wcTbzxTF AIyHJGmN+EU/mNEzdGVthG9S5zOwSvb82U+yu1/iZJ7M94vxTNFaLmfDpjvCFnIrz03v4/LvAwv bjpWymE6yydE5uVvritORbclYt23q5zQCYWg4Luf/4Mhjtk+eshTFtmozVDBdO7Wro8mhH3Ve2x poE2uvDNcVFT3C5a1pwIhkp1RoSG7Eu3ooRGJ5Y208b7XCgUJks8fGFarEzDmIOFEp3+8PnnqAS 1TNbZeIoK/NFr/tlkQDqKY4CMPuAJVe+dYrr/CgSI9jLmeEwQ3lm3Mp3x7XIDpRJSFZ3rYMeLro g51Xd1m7ZNH17011xpkfS1AFFgz4Nm0EIdIcp91bAXqCzbJQxUD5DkoEaryAiOKQWtdfFDPqLOy m+yZKzxf0WekZN+hKp+McXelc9q+MiIyn4guGpOy4jpLKezOszR48ybahfEk4+qgZiFm+JxsaV1 rQpULm9fxl/qpUFBPHECOuk2QjB5Orlpz3VL7XXjm34a+R2aTEeJw1BmI4/ppgBctaEAbB/rduD 21EOJV/N0SIbzzi+cNMaXNP2U7WDifqJcEfH4NbkE/LNNaPZeb/u1E//5ew9olgzdgrudaxwxyK 0IW+ZVGAYFel+h+/k0g== X-Received: by 2002:a05:701b:270d:b0:1b5:32d7:7d73 with SMTP id a92af1059eb24-1b5d710bb33mr4515068c88.30.1796453793021; Fri, 04 Dec 2026 22:56:33 -0800 (PST) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:17a1:4895:5021:5d36]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d642de41sm12389873c88.3.2026.12.04.22.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:56:32 -0800 (PST) From: Dmitry Torokhov Subject: [PATCH kgl 0/4] Add conditional initial-arrival delivery rules Date: Fri, 04 Dec 2026 22:56:15 -0800 Message-Id: <20261204-delivery-rules-v1-0-80af76016200@gmail.com> X-Mailing-List: tools@linux.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAI+1E2sC/yWM0QqCQBQFf0XOcwuu1Qr9SvSg69FuLRb3qhTiv 7fV4wzMrDCq0HAqVigXMXmMGfyuQLw240AnXWZUZRW8L4PrmGShvp3OiebCIdY9fdvs6yNy9FT 28voNz7gPCZe/tLm9MU7fFbbtA/ot55p3AAAA X-Change-ID: 20261106-delivery-rules-64c7fe1ba375 To: "Kernel.org Tools" Cc: Konstantin Ryabitsev X-Mailer: b4 0.17-dev This series adds conditional initial-arrival delivery rules, intra-pull message deduplication for Gmail and JMAP, and Gmail OAuth scope upgrade handling. Cross-posted patches and delayed list copies currently re-apply every configured label on import, resurrecting already archived or read messages in Gmail and JMAP. To preserve user triage state while keeping literal delivery labels working without extra lookups, targets now accept initial labels applied only when a Message-ID does not already exist account-wide. The series is organized in four patches: - Require a terminal on standard input for interactive authentication to prevent background timers or cron jobs from hanging on missing tokens. - Defer Gmail OAuth credential loading until message delivery and isolate target authentication and configuration failures across pull, retries, and digests, avoiding premature network operations and browser prompts during configuration startup. - Add initial_labels support to Gmail and JMAP targets with intra-pull caching, avoiding duplicate uploads and handling Gmail scope upgrades. - Add conditional initial-arrival delivery rules matching messages against address, subject, and arbitrary header criteria. Signed-off-by: Dmitry Torokhov --- Dmitry Torokhov (4): Disable interactive OAuth flows when stdin is not a terminal Defer Gmail OAuth loading until delivery and isolate target failures Add initial_labels, intra-pull dedup cache, and Gmail scope upgrades Add conditional initial-arrival delivery rules docs/configuration.rst | 82 +++- korgalore-example.toml | 5 + man/korgalore.toml.5 | 31 +- src/korgalore/__init__.py | 4 + src/korgalore/cli.py | 685 +++++++++++++++++++++++++--------- src/korgalore/dummy_target.py | 2 + src/korgalore/gmail_target.py | 310 ++++++++++++++- src/korgalore/google_creds.py | 232 ++++++++---- src/korgalore/gui.py | 53 ++- src/korgalore/imap_target.py | 7 + src/korgalore/jmap_target.py | 190 +++++++++- src/korgalore/maildir_target.py | 2 + src/korgalore/pi_feed.py | 42 +++ src/korgalore/pipe_target.py | 2 + src/korgalore/rules.py | 312 ++++++++++++++++ tests/test_cli_deliveries.py | 173 ++++++++- tests/test_cli_misc.py | 196 +++++++++- tests/test_digest_cli.py | 62 +++ tests/test_gmail_target.py | 321 +++++++++++++++- tests/test_google_creds.py | 321 ++++++++++++++-- tests/test_gui.py | 90 +++++ tests/test_imap_target.py | 19 + tests/test_jmap_target.py | 162 ++++++++ tests/test_pi_feed.py | 36 ++ tests/test_pull.py | 390 ++++++++++++++++++- tests/test_rules.py | 222 +++++++++++ tests/test_tracked_thread_delivery.py | 162 +++++++- 27 files changed, 3775 insertions(+), 338 deletions(-) --- base-commit: 6e2383fec5fbbc39fa93a528ebae77468b2a78a9 change-id: 20261106-delivery-rules-64c7fe1ba375 Thanks. -- Dmitry