Re: [Cbor] Record proposal

Carsten Bormann <cabo@tzi.org> Thu, 02 December 2021 07:35 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 9E2CC3A0C38 for <cbor@ietfa.amsl.com>; Wed, 1 Dec 2021 23:35:33 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
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 hoTvmrYOiP5x for <cbor@ietfa.amsl.com>; Wed, 1 Dec 2021 23:35:29 -0800 (PST)
Received: from gabriel-smtp.zfn.uni-bremen.de (gabriel-smtp.zfn.uni-bremen.de [IPv6:2001:638:708:32::15]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id E41173A0C39 for <cbor@ietf.org>; Wed, 1 Dec 2021 23:35:26 -0800 (PST)
Received: from smtpclient.apple (p5089a436.dip0.t-ipconnect.de [80.137.164.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-smtp.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4J4SRG517fz2yHr; Thu, 2 Dec 2021 08:35:22 +0100 (CET)
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <CAM70yxDJFiv=skuU4=vkos9Zk1JpqQ+6xGGDFj6+Tb6gqCdKFg@mail.gmail.com>
Date: Thu, 2 Dec 2021 08:35:22 +0100
Cc: Kris Zyp <kriszyp@gmail.com>, =?utf-8?Q?Christian_Ams=C3=BCss?= <christian@amsuess.com>, "cbor@ietf.org" <cbor@ietf.org>
Content-Transfer-Encoding: quoted-printable
Message-Id: <7AF3052A-3B03-4F8A-988D-9F7228001C91@tzi.org>
References: <CAEs2a6vNhrHhaiPUNtbJ68WYfbrprETPr+kmWNJgNXMSawyBig@mail.gmail.com> <E3F121DA-95EE-43C6-BC72-E3763C034944@tzi.org> <CAEs2a6uZrT9FFP6qa+hPV2sYO0y+xJJmLaF-pPoynE2vqspfBg@mail.gmail.com> <CAEs2a6uHyvvghAMCN=UmhpJMoiES7zoPmGi-bATZWXgjA068Mg@mail.gmail.com> <YY0B4YxuMuw20umu@hephaistos.amsuess.com> <CAEs2a6utA=GQSx2Ln=5wnoNdS6z+0ExdCcfNXG6cAg=1MxnT=w@mail.gmail.com> <901541DC-A520-44CD-AA8D-F2CE77F03FA0@tzi.org> <CAEs2a6sZd4s-DJ3R_M4BLwO12s8i2AGfv0yXCaWdy+baOuAEqw@mail.gmail.com> <8CA1A63D-70B5-4109-ABE7-9CF9197F0375@tzi.org> <CAEs2a6uTKJ1DOTjREjKaRSY6kNAHSof97OoRAZbjDWOazLQC+A@mail.gmail.com> <CAEs2a6tY02haauD4OL18fp15Zet2bqkq+xVzEvAEiK5cvTpy2w@mail.gmail.com> <5C7719D8-8DCB-41BE-9111-882A02D43506@tzi.org> <CAEs2a6vVL9_wvrbwske80m5P5Y1xKw6_ecitDL9uybf2TsvWHw@mail.gmail.com> <CAEs2a6tW7K71wKfK-EerdntmyTppqDrz=Fjb7BfADXAkH5N3gA@mail.gmail.com> <CAM70yxB_YaRWccUk_UfLgxwd1gSUNxkDmaWfh-15wEiXsVe9Ng@mail.gmail.com> <CAEs2a6s3=jSb2N7+JHntApW9PWgBCUxV5TP5ej7vLfuR4T6fug@mail.gmail.com> <CAM70yxDJFiv=skuU4=vkos9Zk1JpqQ+6xGGDFj6+Tb6gqCdKFg@mail.gmail.com>
To: Emile Cormier <emile.cormier.jr@gmail.com>
X-Mailer: Apple Mail (2.3654.120.0.1.13)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/O5z0gTMOwtj6jBQRlq0Jm88WEjw>
Subject: Re: [Cbor] Record proposal
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 02 Dec 2021 07:35:34 -0000

On 2. Dec 2021, at 07:18, Emile Cormier <emile.cormier.jr@gmail.com> wrote:
> 
> On Thu, Dec 2, 2021 at 1:34 AM Kris Zyp <kriszyp@gmail.com> wrote:
> I certainly empathize with the idea of keeping tags as conceptually distinct in terms of just adding some extra non-transformational semantic description to the underlying CBOR data structure. However, there is a wide range of "meanings" in tags, and realistically, with many, or even most tags, you can't really "make sense" of a payload without the "semantic meaning"; the meaning is what provides the direction for how to make sense of the data. For many tags, something needs to understand the data beyond just a raw CBOR structure.
> 
> 
> But it should be possible for applications to agree in advance on the meaning of the data and still be able to interpret it in the absence of tags.

I do not agree that this is a worthwhile goal.
Ensuring this causes gymnastics that simply does not provide that much benefit.

> This practice of embedding an extra number via a tag range is ruining this ability for applications to agree in advance on the meaning of the data in the absence of tags.

There is no rule that CBOR data need to make sense after removal of tags.

For instance, in YANG-CBOR [1], tag 47 means that a given map key is an absolute SID, not a relative SID delta.
An implementation that discards these tags is not going to work very well.

[1]: https://www.ietf.org/archive/id/draft-ietf-core-yang-cbor-17.html
[2]: https://www.ietf.org/archive/id/draft-ietf-core-yang-cbor-17.html#sid

> Your proposed tag range of 57344 - 57599 could simply be replaced by a single tag followed by an array of size 2.

Yes.  Encoding this needs some additional bytes.

> In section 3.4 of the spec, it says: "If a tag requires further structure to its content, this structure is provided by the enclosed data item." (emphasis mine). This clause is being violated by tags that rely on tag range to convey additional data.

No, a tag that expresses information in its tag number simply may not "require further structure to its content”, so the cited statement of fact simply doesn’t apply.

> Without the semantic meaning, there isn't data loss; raw CBOR structures could always be transcoded to JSON or anything else (with conventions for tags and such)

That doesn’t work in general: An array with two elements could be a valid data item as well, so you get ambiguity.
Tags provide with a clean way to extend the data model.

I think you are better off accepting that the CBOR generic data model is a superset of that of JSON.

> Well, that's the problem: there is no convention for tags in JSON. A CBOR-to-JSON converter now needs to understand your record set tags, and generate a modified structure for JSON that contains the record IDs that would otherwise be lost.

Generic CBOR-to-JSON converters very well can be designed so they are round-trippable without information loss (*).
It’s just a bit ugly.

> This practice of using a tag range to avoid the few measly bytes of a two-element tuple is making it so that once an application adopts these tags, it can never switch to another encoding other than CBOR.

I don’t know why it would want to, but it can, see above.

> I'm afraid CBOR can no longer be considered as the binary equivalent of JSON plus byte arrays.

It never was!
A simplistic view of its generic data model is JSON plus bytes plus extensibility via tags.

> Instead of tags enhancing data with semantic meaning hints, it's effectively extending the number of data types.

Yes!

> This is what I've realized with signed CBOR bignums which also rely on tag ranges (a range of two): they are now a new data type that my decoder needs to interpret if I don't want the application layer to be concerned with tags.

Handling tags inside generic codecs is definitely one implementation strategy; it requires the tagged information to be representable by platform types (which often is not a problem for bignums).  I’m not sure how a platform type for Kris’ records would look like; I’m sure one can be defined in many platforms.

Grüße, Carsten

(*): E.g., see https://github.com/cabo/cbor-diag/blob/master/lib/cbor-transform-j.rb
This isn’t perfect (it would also need code to handle certain strings to obtain full data transparency), but it was good enough for one application.