Proposal: Adopt State Synchronization into HTTPbis

Michael Toomim <toomim@gmail.com> Wed, 01 November 2023 02:11 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=ietf.org@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 4E938C151093 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Tue, 31 Oct 2023 19:11:21 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.754
X-Spam-Level:
X-Spam-Status: No, score=-7.754 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HTML_MESSAGE=0.001, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=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, WEIRD_PORT=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 0WMOw5G0msCA for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Tue, 31 Oct 2023 19:11:15 -0700 (PDT)
Received: from lyra.w3.org (lyra.w3.org [128.30.52.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 84610C151090 for <httpbisa-archive-bis2Juki@ietf.org>; Tue, 31 Oct 2023 19:11:14 -0700 (PDT)
Received: from lists by lyra.w3.org with local (Exim 4.94.2) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1qy0eE-0001ML-4b for ietf-http-wg-dist@listhub.w3.org; Wed, 01 Nov 2023 02:07:58 +0000
Resent-Date: Wed, 01 Nov 2023 02:07:58 +0000
Resent-Message-Id: <E1qy0eE-0001ML-4b@lyra.w3.org>
Received: from mimas.w3.org ([128.30.52.79]) by lyra.w3.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <toomim@gmail.com>) id 1qy0eC-0001LK-4K for ietf-http-wg@listhub.w3.org; Wed, 01 Nov 2023 02:07:56 +0000
Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by mimas.w3.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from <toomim@gmail.com>) id 1qy0eA-000ae9-82 for ietf-http-wg@w3.org; Wed, 01 Nov 2023 02:07:55 +0000
Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-2802e5ae23bso3204599a91.2 for <ietf-http-wg@w3.org>; Tue, 31 Oct 2023 19:07:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698804469; x=1699409269; darn=w3.org; h=to:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=mrf8CM72QpbOWn3QteDsi+bll7WsJb5G1nujsVpJzmk=; b=SSdcV2grgSL4Qrgi1ehG1mfaf+fTL9lX6Hi5YatuPgXeQlnWnU/6CH+GTIBGuh9wnm WKBkVRGzjrQbZHjYiOyGp0gCIn20kHN7G6ymUg2oxiKKqFawTYyfXYJytNSiFTKmEB8M KegLegFWu0B1Jge/PkohrlHIMWuV7hJTuJNeEP2Ui2mB+6SqD00o7NsJCn1iflpU1FTm bziLKzxvjU2VTPMapyrXzNyOeBlyn+PcCG163t1dmQPDQVWItPoDTQpOMagePYuCNpf3 Ey08pCRRl+EZcRCVHB3lllZcO51RL9T89WuhjhoRbB+rxfUFednogdUjbnkUrq03uGK8 kKqg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698804469; x=1699409269; h=to:date:message-id:subject:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=mrf8CM72QpbOWn3QteDsi+bll7WsJb5G1nujsVpJzmk=; b=aeF/ph8kRztF6azGRuNZHlM9E88Ulc2sBOqRH2JsDz0Oj7xx+zsHjmGRxfnpOKX/Ry Xa+w6ttgGaJOiAONU8PoD7M91cgtGJ5QFBguQWOLi5s6g+/tH8dJtSKHDfKXuo5TuWLD HVgwdhOo8mQFucc7rI/+NU+qVpHW87zR4GesDSt+q/AxjWzqynrKbPfMX/ZVsndxATw9 3mwpj6BuPuf97JsNzWtCARPlPO+RrKHAHrOAHdrOlhORPwsQQaML6n2N49GjUpBerHGo nly+HDqQhfXCHMY+u9tqN+vNNS/fZwlgqEHlBuime7+qflntcX8Hsnvr1on5FBU9tnA8 EiGw==
X-Gm-Message-State: AOJu0Yzz1LbnKE/o/OCmQpJq82f70SFrdAI8JCjCKlAsV8+mcDoFETJU HFljAX9X0MRWAqjQFRf6CcF1jCDLcP8=
X-Google-Smtp-Source: AGHT+IFBFdm8uNoQqs7VbcSs589nyluGewjKADWGd97NVB8gNQwepJ/8eknKbi6KqrUDlozklBLlcQ==
X-Received: by 2002:a17:90a:35b:b0:280:111:ef0b with SMTP id 27-20020a17090a035b00b002800111ef0bmr11147368pjf.48.1698804468885; Tue, 31 Oct 2023 19:07:48 -0700 (PDT)
Received: from smtpclient.apple (c-73-15-7-9.hsd1.ca.comcast.net. [73.15.7.9]) by smtp.gmail.com with ESMTPSA id ip3-20020a17090b314300b0027d157e686asm1653737pjb.49.2023.10.31.19.07.47 for <ietf-http-wg@w3.org> (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Oct 2023 19:07:48 -0700 (PDT)
From: Michael Toomim <toomim@gmail.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_38C9C65A-434E-43B1-8298-CF24080B5B42"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Message-Id: <2F6DB48A-D17C-47DF-B1BC-EAC0791D23AE@gmail.com>
Date: Tue, 31 Oct 2023 19:07:46 -0700
To: ietf-http-wg@w3.org
X-Mailer: Apple Mail (2.3696.120.41.1.1)
Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=toomim@gmail.com; helo=mail-pj1-x102d.google.com
X-W3C-Hub-DKIM-Status: validation passed: (address=toomim@gmail.com domain=gmail.com), signature is good
X-W3C-Hub-Spam-Status: No, score=-4.1
X-W3C-Hub-Spam-Report: 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, W3C_AA=-1, W3C_WL=-1, WEIRD_PORT=0.001
X-W3C-Scan-Sig: mimas.w3.org 1qy0eA-000ae9-82 a7f7b0b3dc07964c61cadc875fa9b471
X-Original-To: ietf-http-wg@w3.org
Subject: Proposal: Adopt State Synchronization into HTTPbis
Archived-At: <https://www.w3.org/mid/2F6DB48A-D17C-47DF-B1BC-EAC0791D23AE@gmail.com>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/51545
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <https://www.w3.org/email/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

At IETF 118 I will present a proposal to adopt State Synchronization work into HTTPbis:

Braid-HTTP: https://datatracker.ietf.org/doc/html/draft-toomim-httpbis-braid-http [1]

HTTP currently provides State *Transfer* of a document between client and server. This made sense in 1992 when the web was mostly static, and pages were written by hand. Caching was simple. However, today's pages are dynamic, use Javascript and Ajax, and users expect realtime updates. Today's web needs robust State *Synchronization*; not just Transfer.

We have an opportunity to add State Synchronization to the WWW in a robust & general way. Four simple extensions (below) transform HTTP into a general-purpose State Synchronization protocol—keeping simple cases simple, while also enabling the most advanced distributed synchronization (OT and CRDT) algorithms. These support multiple writers, making simultaneous edits, over arbitrary network conditions (offline or online), while guaranteeing consistency with peer-to-peer merge-semantics. HTTP can become a general-purpose Distributed State Abstraction: a protocol that guarantees your local cache of state is always editable, and always up-to-date.

We first discussed this idea at IETF 104 and 105 in Prague and Montreal. It received great enthusiasm and feedback, which was incorporated into draft 02 in March 2020. We tested this draft extensively over the past few years in the braid.org group, against a variety of algorithms, apps, and browsers, and last week we published draft 03, which I feel confident is a general and performant approach to state synchronization, supporting every known CRDT and OT algorithm (!), and fitting easily into today's web.

But adopting this won't be a monolithic project like WebRTC. The approach we propose is actually to spiff up three aspects of existing HTTP:

	1. Subscriptions (sse)
	2. Version History (etag, max-age)
	3. Patch Formats (PATCH)

...and then to tie them together with one new concept:

	 4. the Merge-Type header

The first three improvements will be useful on their own. In fact, there are already efforts underway to improve them:
*Subscriptions* are being proposed in PREP [2] and Mercure [3] to address limitations in SSE and WebSub.
*Patch Formats* are being extended for Byte-Range-Patch [4], which needs a generalized Content-Range header.
Resumeable Uploads [5] needs to send a series of *Patches* (called parts), until the *Version* on the server is complete.
HTTP Cache Invalidation API [6] proposes a standard for servers to push updates to the CDNs that *Subscribe* to their state.
These improvements are needed for State Synchronization too. By adopting the higher-level goal of State Synchronization, we gain a unified perspective, to generalize these disparate efforts into a more powerful and elegant HTTP. We will address the above use-cases, and enable a broad array of new ones.

We verified this framework with a number of implementations in the braid.org group over the last few years. 

	- Protocol implementations: braid-http [7], braid-protocol [8], wai-braid [9]
	- Algorithm integrations: sync9 [10], diamond-types [11], automerge/yjs [12], sharedb [13], shelf [14]
	- Browser extension: braid-chrome [15]
	- Applications: PeeryView.org [16], Simple Braid Chat [17], Braid Wiki [18]
	- Developer APIs: statebus [19], redwood [20]

I'm making a demo video to make these more concrete. It will appear on this thread soon.

Separately, I am IETF-Dispatching the idea of forming a general State Synchronization group. (Email thread here. <https://mailarchive.ietf.org/arch/msg/dispatch/wCrAiHwWvlK9netFi71nz3FF7Aw/>) I believe the Braid-HTTP draft is ready for standardization, but this general group could take on any further issues that are too abstract for HTTPbis.

In summary, I am proposing that HTTPbis adopt the general goal of supporting State *Synchronization* (not just Transfer) in HTTP, which entails making general extensions for (1) Subscriptions, (2) Version History, and (3) Patch Formats, and then offering a (4) Merge-Type to tie it all together. These will make for a very powerful upgrade.

I kindly request feedback on this idea! See the draft [1] for details.

Michael

References:
[1] https://datatracker.ietf.org/doc/html/draft-toomim-httpbis-braid-http
[2] https://datatracker.ietf.org/doc/draft-gupta-httpbis-per-resource-events
[3] https://datatracker.ietf.org/doc/draft-dunglas-mercure/
[4] https://datatracker.ietf.org/meeting/117/materials/slides-117-httpapi-byte-range-patch-00
[5] https://datatracker.ietf.org/doc/draft-ietf-httpbis-resumable-upload/
[6] https://datatracker.ietf.org/doc/draft-nottingham-http-invalidation/
[7] https://www.npmjs.com/package/braid-http
[8] https://github.com/josephg/braid-protocol
[9] https://github.com/braid-org/wai-braid
[10] https://braid.org/sync9
[11] https://github.com/josephg/diamond-types
[12] https://braid.org/automerge
[13] https://braid.org/demo/interoperate
[14] https://braid.org/algorithms/shelf
[15] https://github.com/braid-org/braid-chrome
[16] https://peeryview.org/about
[17] Simple Braid Chat: http://invisible.college:3007
[18] Antimatter Wiki: https://github.com/braid-org/braidjs/tree/master/antimatter_wiki and https://wickie.invisible.college
[19] https://stateb.us/
[20] https://github.com/brynbellomy/redwood