Re: [dispatch] Proposal for Per Resource Events Protocol

Michael Toomim <toomim@gmail.com> Sun, 13 August 2023 05:11 UTC

Return-Path: <toomim@gmail.com>
X-Original-To: dispatch@ietfa.amsl.com
Delivered-To: dispatch@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id D3223C14CEFD for <dispatch@ietfa.amsl.com>; Sat, 12 Aug 2023 22:11:36 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.194
X-Spam-Level:
X-Spam-Status: No, score=-2.194 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, NICE_REPLY_A=-0.091, RCVD_IN_DNSWL_BLOCKED=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e8PTCUTmD-KC for <dispatch@ietfa.amsl.com>; Sat, 12 Aug 2023 22:11:33 -0700 (PDT)
Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 45559C14CEED for <dispatch@ietf.org>; Sat, 12 Aug 2023 22:11:33 -0700 (PDT)
Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bc0d39b52cso20239225ad.2 for <dispatch@ietf.org>; Sat, 12 Aug 2023 22:11:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691903492; x=1692508292; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=jYcPflMnMUOAy1MgBYRNkzm4lwZrA7iD2hPh8QW20r0=; b=UnJtUtOrUYGUj7NO0wOum4JsCnff6UsJyPwgX4A+rhSL/OR09Mui51PtSqa2FgDKm9 OaRwAUp1NxLBBVFYFXgVw4LPFhZLgPWino0Wu+VRxbCQEWNskUN/7mGNA5t1mdpq6VNZ YogeIF5WPZuqEPPWV4btgYqqBDB72ONDYnfhexpTo/r1W0MywRpwbsWjxrg4htQUkkxf kcrDrE1EOAR7fGm7/PPh+dlPhI0Cb+73tk0772XjLqhBiLc94msdJgTu3OiwZvcg04rs kVFnU6FMfeQEJ+x8uGdrI4N9BzBOGpKAVirj7p4z+dYnXM+8Ch5+2MZALOe8z45dKBgy 0Mvw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691903492; x=1692508292; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=jYcPflMnMUOAy1MgBYRNkzm4lwZrA7iD2hPh8QW20r0=; b=UAXSscAH9zDhlBJ7JxoRIaB0r87cpmybyI+wYl9kCogitPITb+ULmOPVxjzYMWYutE EBmXPNealjzlnS7iDQYbiSKKPpigSSpkvklQNc8B+egvv4W1W6N6zhb2F7cXvpce/PAo 7eHLc5lAHGof4Q4CHB6B2QtoQZdYlhtVy+XRUBsJIy8XI8zMx0DYqrj1dW7wzE6P5Hot Q9OxKEB2jHrCCcnhWu9WQuxZ16AKjcv2Z1kVtFCLgcu6uyyBHCIOsdTuHebpuJuOto2W SVVsXe21hIEjWew9rzzX0Jd9EN7/Jegk970b9ovJTf9G68xp43G++gey3NlBwArZ1H+r SsIg==
X-Gm-Message-State: AOJu0YyWN/u1N7jciKBoRGvugIu+dSdqxnPBwgR+/Dmjg5Z40HKnRwf9 92LQMgMG02GLSD63G0HFhDcp+js07A4=
X-Google-Smtp-Source: AGHT+IHa1AnBmcrtOvaro8NohxqV9hHO1BN07SGGN7pBQo8gAL0Rkz93G7YPjQgRDh4YVsiYpjTqCg==
X-Received: by 2002:a17:902:c14d:b0:1bc:73a6:8be6 with SMTP id 13-20020a170902c14d00b001bc73a68be6mr5043167plj.54.1691903492294; Sat, 12 Aug 2023 22:11:32 -0700 (PDT)
Received: from ?IPV6:2600:380:7030:69f1:f97e:308:8f68:544? ([2600:380:7030:69f1:f97e:308:8f68:544]) by smtp.gmail.com with ESMTPSA id i13-20020a170902eb4d00b001b04c2023e3sm2262323pli.218.2023.08.12.22.11.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 12 Aug 2023 22:11:31 -0700 (PDT)
Content-Type: multipart/alternative; boundary="------------7ur3iy7X86hH4qcK00x8oCVa"
Message-ID: <5ae3c5b6-d512-a961-51be-4cd919a6bcf4@gmail.com>
Date: Sat, 12 Aug 2023 22:11:29 -0700
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0
Content-Language: en-US
To: Rahul Gupta <cxres@protonmail.com>, "dispatch@ietf.org" <dispatch@ietf.org>
References: <878ralz3o1.fsf@hobgoblin.ariadne.com> <15c147ec-6628-6fc8-f31b-69d7269cb222@gmail.com> <SMMaN1Bg78cqanzppFhR0unkomG-MzlTY4noaVSCTyUpnBCwMyuzciRC3OnOQ5bi38DBLVvmUjzr05NREXES90ImoACH0-Ym0AOOZlXhd0I=@protonmail.com>
From: Michael Toomim <toomim@gmail.com>
In-Reply-To: <SMMaN1Bg78cqanzppFhR0unkomG-MzlTY4noaVSCTyUpnBCwMyuzciRC3OnOQ5bi38DBLVvmUjzr05NREXES90ImoACH0-Ym0AOOZlXhd0I=@protonmail.com>
Archived-At: <https://mailarchive.ietf.org/arch/msg/dispatch/vjWt4MRz60Dlfes5qAG7ZOeSx-E>
Subject: Re: [dispatch] Proposal for Per Resource Events Protocol
X-BeenThere: dispatch@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: DISPATCH Working Group Mail List <dispatch.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/dispatch>, <mailto:dispatch-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/dispatch/>
List-Post: <mailto:dispatch@ietf.org>
List-Help: <mailto:dispatch-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/dispatch>, <mailto:dispatch-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 13 Aug 2023 05:11:36 -0000

Rahul:

> *Michael, would you be open to 15-20 minute call? I can both explain 
> myself and understand from you how Braid works a bit better.*
Yes, definitely! It's a pleasure to meet you! I spoke with Tim 
Berners-Lee this summer, and he got me excited to integrate Braid 
subscriptions with Solid as well. Let's definitely set up a call and 
make some stuff work!

>> It's not clear to me how Per-Resource Events differs from SSE, for 
>> example.
>>
> In SSE, you dedicate a resource as endpoint for notifications.
>
I agree that it's better to use a single endpoint for state and its 
notifications. Braid-HTTP does this too. However, to be fair to SSE, it 
/does/ support a single URL for both state and its updates. SSE requests 
are distinguished by the `Accept: text/event-stream` header, which means 
you can overload every URL in your app with an SSE notification stream 
for it by looking for that header.

On the other hand, SSE /does/ require two requests per resource here— 
one to GET the resource, and another one to get the updates. It's nice 
to reduce this to a single request, and Braid-HTTP does this too.

You can see an example Braid-HTTP request in the Subscriptions section 
here: 
https://datatracker.ietf.org/doc/html/draft-toomim-httpbis-braid-http#section-3

First it returns the current state of the resource, and then the 
connection is left open, and it streams updates to the resource that 
have occurred since it was first returned.

>> Braid supports per-resource events that describe *mutations to 
>> state.* I would be curious to learn if you have use-cases for events 
>> beyond mutations to state.
>>
> I am not exactly sure of what you mean by "mutations of state", but 
> messages are sent in PREP typically when an HTTP operation occurs, 
> like PUT or POST (these can be redefined for a media-type, see 
> Appendix A). For example, POST might not change the current resource, 
> but create another resource. Still, a notification might be sent for 
> the resource/URI where POST was done.

Here's what I mean by "mutations of state":

    Backgorund: REST stands for REpresentational State Transfer. Each
    URL has state. When the state of a URL changes, that is a mutation
    of state.

Now, there's a hierarchy of specificity that an HTTP event stream 
specification might operate at:

 1. Byte stream: A stream of bytes to be parsed (e.g. TCP)
 2. Event stream: A stream of discrete separate events, possibly with
    event IDs (e.g. SSE, WebSocket)
 3. Pub/sub stream: A stream of pub events that can be subscribed to
 4. Mutations: Subscribing specifically to changes to the resource's
    state (e.g. Braid-HTTP)
 5. Formatted mutations: Subscribing to mutations expressed in a
    particular change format (e.g. Braid-HTTP w/ Range Patch)

Braid-HTTP is specifically designed to express levels 4 and 5: mutations 
to state. These are by far the most common use-case for event streams, 
and it's important to have a standard for them. Otherwise, we end up 
with a standard that's not very useful for interoperability in real web 
apps. MNot describes some of this here 
<https://www.mnot.net/blog/2022/02/20/websockets>.

I've been curious if PREP is trying to address any use-cases for event 
streams /beyond/ mutations of state. If not, then we should merge our 
efforts (and I'll advocate for operating at level 5). If so, I'd love to 
hear what the use-case is, to know what Braid-HTTP isn't handling.

Any PUT request /is/ a mutation of state. A POST request usually creates 
or mutates state, and you can subscribe to the resulting mutation with 
Braid-HTTP, too. So I suspect that we are tackling the same use-cases.

I am very glad that we're getting connected. Thanks a bunch of taking 
initiative on this important work!

Michael