Subject: Re: [Cbor] eliding CBOR diagnostic notation binary contents

From: Carsten Bormann <[email-masked]>
Date: Sat, 12 Mar 2022 21:46:10 +0100

>> Actually processing elisions should be a special flag.  That should
>> address your concern.
> 
> Yes, that works for me.

In cbor-diagnostic, this flag is now “-ah”.

$ gem install cbor-elision

$ echo "h'...4711...'" | diag2pretty.rb -ah
d9 0378       # tag(888)
   83         # array(3)
      d9 0378 # tag(888)
         f6   # primitive(22)
      42      # bytes(2)
         4711 # "G\u0011"
      d9 0378 # tag(888)
         f6   # primitive(22)

$ echo "h'...4711...'" | diag2diag.rb -ah
888([888(null), h'4711', 888(null)])

Not sure this will be the final structure we use for that, but at least there is something to play with now.

Grüße, Carsten

---

From: Michael Richardson <[email-masked]>
Date: Sun, 13 Mar 2022 17:29:29 -0400

> In cbor-diagnostic, this flag is now “-ah”.

Cool.

    > $ echo "h'...4711...'" | diag2pretty.rb -ah

The direction I really want to automate is cbor2pretty, when generating examples.
There are some ways in which I can see doing this:
  1) some option which just elides any bstr longer than X.
  2) some option which elides based upon some other (content-relevant) tag.
  3) some option which takes some kind of CBOR-PATH to specify what to elide.

I think that "CBOR-PATH" is not yet a thing, but I think I've heard you talk
about how we can essentially use JSONPATH to do this?

--
Michael Richardson <[email-masked]>   . o O ( IPv6 IøT consulting )
           Sandelman Software Works Inc, Ottawa and Worldwide

---

From: Carsten Bormann <[email-masked]>
Date: Mon, 14 Mar 2022 11:27:14 +0100

> On 2022-03-13, at 22:29, Michael Richardson <[email-masked]> wrote:
> 
> Signed PGP part
> 

Are you sure about cbor2pretty (annotated hexdump) vs. cbor2diag?

A hexdump is much harder to have elisions that you can read in again:
The length information implicitly conveyed by the syntactic structure of diagnostic mode is missing.
So you don’t know how many bytes the elision is supposed to cover.
(Unless you start parsing the annotations…)

> about how we can essentially use JSONPATH to do this?

Also, it might be useful to mix in a CDDL spec and build a path based on the parse tree.

CBOR-Path should be able to handle all of these, but it still needs to be invented (after JSONPath is done, presumably).

Grüße, Carsten

---

From: Michael Richardson <[email-masked]>
Date: Mon, 14 Mar 2022 12:02:17 -0400

> Are you sure about cbor2pretty (annotated hexdump) vs. cbor2diag?

Uhm.  Both probably.  I'm often confused about which one is which :-)
I find myself using pretty often because it is easy to load them up as
reference values for unit test cases.

    > (Unless you start parsing the annotations…)

Agreed, but for showing some things the hexdump is necessary, but it is not
useful to show long sequences like signatures or embedded payloads.

    > Also, it might be useful to mix in a CDDL spec and build a path based on the parse tree.

yes, this would certainly be interesting: ".elidable" or some such attribute.

    > CBOR-Path should be able to handle all of these, but it still needs to
    > be invented (after JSONPath is done, presumably).

I am blissfully ignorant of JSONPath situation.

What do we do in the meantime?  I think that generating (diag format)
examples is the killer-app here.  Maybe even to the point where kramdown
should have some "```` foobar" for doing this.
I guess the CDDL matching part maybe.  I suppose this also validates the CBOR
against the CDDL along the way, which is a win, except when it's a pain.