Re: [Jmap] Review: draft-murchison-jmap-sieve-01

Ricardo Signes <jmap.ietf@rjbs.manxome.org> Mon, 13 July 2020 20:10 UTC

Return-Path: <jmap.ietf@rjbs.manxome.org>
X-Original-To: jmap@ietfa.amsl.com
Delivered-To: jmap@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 6E9EA3A0805 for <jmap@ietfa.amsl.com>; Mon, 13 Jul 2020 13:10:00 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.019
X-Spam-Level:
X-Spam-Status: No, score=-2.019 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=manxome.org header.b=XaNgGID5; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=DanEfoOB
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7jyF_2yHmaOf for <jmap@ietfa.amsl.com>; Mon, 13 Jul 2020 13:09:58 -0700 (PDT)
Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 334343A081F for <jmap@ietf.org>; Mon, 13 Jul 2020 13:09:27 -0700 (PDT)
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 3D17B5C019D for <jmap@ietf.org>; Mon, 13 Jul 2020 16:09:27 -0400 (EDT)
Received: from imap35 ([10.202.2.85]) by compute2.internal (MEProxy); Mon, 13 Jul 2020 16:09:27 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manxome.org; h= mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type; s=fm3; bh=WFxo6G8wOzm8gMKLPISThZZez1myoUH VAb11H1exR7I=; b=XaNgGID56B/1m9zSmG5wUtzVZjN0GgtRAlj9M0WZKH8bWk0 eoZIs+voYgWqPA+oMYwaR1M4UYqupFbGDagc4uJU4r6gs/zJATDguxRIgDSL7Hfa kXWxw3tsAI98pKj8jICf53m4BUwMjCH+wwMep3LIkqhttrk5su1ByqE8BtMb3t4t GmLmIsYxWrkLPk7UOEf258srzJBWERbBZ+OS1nwNvaYt+1jIRzSFzg6F2c821JoL BmLqINVIcvKC2Y/ZZsmdcRdeOiRWqLi3XSWQUMyMYnZ3it2B0eV7dKbdZ3xP1Yoo M3cBAuJVqkdvMcueQ5e0FnzyBbaiMhf99sBUU1A==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=WFxo6G 8wOzm8gMKLPISThZZez1myoUHVAb11H1exR7I=; b=DanEfoOBriVcID+TfjwpTe 3BN2dIUsyayF97RORvQSIDwejL7072pKdP5T8TGVZOqhvzblvbcRpLFUfT6Uwo/9 loeSoSlKanLcRZ5sKbg+b1kneJdxCKvSBPLbrx+OPuYueAiGl08LJAZ2O8OH8bai vC/xdp7xayaNc5vEvAH8cOLkOAaNxlePUaxctiUk1Equ3w7wit9J6fYsi28q7x6T LIJtjZda+UUguBQYsUlfZDsKbDmpk0U6M5NSmGftUn+UavptueQuZArE9VSwmMVN 6VDVjZQwgHY7t3zDjwhC1dzaltuYRAsMynwbnjwCTUAlLsENtpiLBFwskTEQmhCg ==
X-ME-Sender: <xms:dr8MX6xMryz0hw8yofStlgRdOZWS4I7zzhMNchrrbIC0TuJDIpCkiw>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrvdekgddugeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsegrtd erreerreejnecuhfhrohhmpedftfhitggrrhguohcuufhighhnvghsfdcuoehjmhgrphdr ihgvthhfsehrjhgsshdrmhgrnhigohhmvgdrohhrgheqnecuggftrfgrthhtvghrnhepgf eggeegjeevffethfegveegtdelffeuieeijeetieeuteehffehffevvdeufeegnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhhmrghprdhivg htfhesrhhjsghsrdhmrghngihomhgvrdhorhhg
X-ME-Proxy: <xmx:dr8MX2RJDKQq3RJo9YQKiiSeo6Sx6T3zSl1ySU0mzcwEDXTiJp2wqg> <xmx:dr8MX8Vvuzo8PdHyeAZ3XFfnXdN6aV3XqFzRbFqKkTOppG6vrSRTZA> <xmx:dr8MXwgBuYzAqxe-sWufgUjHTa7U_M1KxkMVUAjoaM4ISS24mCg6TA> <xmx:d78MX0y0N_CyBBaVsCjQf0Op9FtWITOgA284egB0eloC5Pyb5h2EEQ>
Received: by mailuser.nyi.internal (Postfix, from userid 501) id D193114C013D; Mon, 13 Jul 2020 16:09:26 -0400 (EDT)
X-Mailer: MessagingEngine.com Webmail Interface
User-Agent: Cyrus-JMAP/3.3.0-dev0-613-g8a73ad6-fm-20200709.001-g8a73ad6e
Mime-Version: 1.0
Message-Id: <cffb80e8-f83e-4951-8dec-aa7a7cd5276e@www.fastmail.com>
In-Reply-To: <1a099401-bbb6-496f-836f-033a0274b74f@dogfood.fastmail.com>
References: <1a099401-bbb6-496f-836f-033a0274b74f@dogfood.fastmail.com>
Date: Mon, 13 Jul 2020 16:08:28 -0400
From: Ricardo Signes <jmap.ietf@rjbs.manxome.org>
To: jmap@ietf.org
Content-Type: multipart/alternative; boundary="109b55091dcb4be3abf8235c830aaa07"
Archived-At: <https://mailarchive.ietf.org/arch/msg/jmap/onuU2EvYZ9ODWjgx5khPaWiuBsk>
Subject: Re: [Jmap] Review: draft-murchison-jmap-sieve-01
X-BeenThere: jmap@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: JSON Message Access Protocol <jmap.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/jmap>, <mailto:jmap-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/jmap/>
List-Post: <mailto:jmap@ietf.org>
List-Help: <mailto:jmap-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/jmap>, <mailto:jmap-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 13 Jul 2020 20:10:00 -0000

On Wed, Jul 8, 2020, at 8:22 AM, Bron Gondwana wrote:
> *Open issues:*
> 
> /set#create should fail if there's already a script with the same name. The JMAP request can include a "destroy" for the ID of the old script, or it can issue an "update" on the Id of the script with the same name to replace the content.

Well, you already know this doesn't get me what I want, but I have a suggestion. :-) First, my complaints:

This leads to more HTTP transactions than is otherwise necessary.

Say that from a position of ignorance of the remote state, I want to set my active Sieve script to the document S. This requires this set of interactions:

• HTTP request 1: SieveScript/get
• locally extract the id of the active script
• HTTP request 2: SieveScript/set { update: { activeId: { script: $NEW, isActive: true } } }

This is an extra round trip. (So the re-set of isActive at the end is to avoid a race. An ifInState would also do the trick.)

This would not be required in managesieve, where by convention the client could control the script name and know that a PUTSCRIPT for the conventional name would update the active script. The shift from client-controlled keys (script names) to server-controlled keys (JMAP ids) eliminates the possibility for this kind of convention. 

You suggest that the client can perform either a destroy-and-create or an update but I think that *only the update-based operation is safe*. Consider:

• client does a SieveScript/get and determines the active id script is "123"
• client issues SieveScript/set { destroy => [ "123" ], create => { newScript => { …something invalid… } } }

Because the create and destroy may be applied independently, the user could end up with no active script at all. This is too bad, because otherwise you could provide SieveScript/query (which would need to be invented), backreference the results for (filter:{isActive:true} OR name:NameWeWant) in a destroy, and create the replacement in the same breath, which would be safe. 

*I suggest instead*:

1. We drop isActive as a property from SieveScript.
2. We create a new type, SieveConfig
3. SieveConfig has exactly one instance per account, with the fixed id "singleton"
4. The SieveScriptConfig object has one property, activeScriptId, which is either a script id or null
5. If no "name" is provided, the server will provide a guaranteed unique name.

To replace the active Sieve script in the blind, you do this:

SieveScript/set { create: { newScript: { content: "..." } } }
SieveConfig/set { update: { "singleton": { activeScriptId: "#newScript" } } }

This is guaranteed safe. The worst case is that you end up with a uniquely-named script that is not, in fact, active.

We probably also need:

6. If the active script is deleted, the SieveScriptActive activeScriptId becomes null.

Alternatively, it could be illegal to destroy the active script.

*As for everything else…*

I agreed with all the rest of your points.

If we add SieveScript/query as you suggest, then this pair of methods would get tacked onto my couplet above:

SieveScript/query { filter: { isActive: false } }, A
SieveScript/set { "#destroy": { backreference-to-A-list } }

-- 
rjbs