subconsciousnetwork / noosphere

Noosphere is a protocol for thought; let's discover it together!
Apache License 2.0
667 stars 40 forks source link

Block layout decoder #38

Open cdata opened 2 years ago

cdata commented 2 years ago

In time Noosphere will gain support for arbitrary content types. One way we imagine achieving this is through support of arbitrary content-defined decoders for the body layout of a Memo.

The idea would look something like this:

  1. Reader looks up some content by slashlink, receives the corresponding CID and resolves a Memo from it
  2. Memo has one of A) a well-known content-type (e.g., JSON, Subtext) or B) a Decoder header whose value is a CID
  3. The body content is then decoded....
    • If A) then decoding is baked-in to the Noosphere library
    • If B) then a WASM module is resolved from the Decoder CID
      • This module would have a standard interface and would be able to incrementally decode the layout of the body as a byte stream

It's likely that Autocodecs would be well-suited for this use case: https://www.youtube.com/watch?v=nCYj0LghbpI

khinsen commented 2 years ago

Sounds good, but: decode to what? What's the supposedly universal representation that decoders are expected to produce?

cdata commented 2 years ago

Yah, good point: we don't need to force everything to converge on a One True Format.

For any given content type, there can be many decoders. The most important thing is that at least one of them produces a content type that is legible to the client.

In the early days, we can support decoders that produce Subtext blocks as an output. In time, Subconscious will support native rendering for structured data formats like JSON and media formats like images - decoders that produce these outputs may also be leveraged.

There will probably be some well-known default decoders for various common type->type conversions. And, the content can suggest specific ones in its headers.