LionWeb-io / lionweb-repository

Reference implementation of LionWeb repository
Apache License 2.0
2 stars 1 forks source link

How to deal with Empty References in Stored and Retrieved Chunks #20

Open joswarmer opened 8 months ago

joswarmer commented 8 months ago

In The serialization specification it says:

So so can get the following (incomplete for shortness) piece of JSON to be stored:

{
     "id": "ID-1"
      "references": [
             {
               "reference": { "language": "L", "version": "1", "key": "R-1" }
               "targets": [ "ID-ANY" ]
             }
      ]
}

Assume we get the following json to store next:

{
     "id": "ID-1"
      "references": [ ]
}

We must accept this, and since the node does not have any references in the chunk, the reference to "ID-ANY". needs to be removed.

In the repo this leads to questions.

Doing a retrieve of node " after the second store above: can result in the references section as either:

{ 
    "references": []
}

or

{
    "references": [ 
    {
    "language": {"L", "version": "1", "key": "R-1" },
    "targets":[] 
    } 
]
}

Leading to different JSON chunks to be retrieved.

Especially in a repo that does not know the language this can be subtly different.

The question is: what should/must a repo return when a reference has empty targets. Nota that the answer might be different for a repo that does know the language versus a repo that does not know the language.

dslmeinte commented 8 months ago

I read the spec. as: if we include a particular reference feature in a node's serialization, then we must state targets = [], but that doesn't mean we have to include { reference: <meta-pointer>, targets: [] } in a node's serialization – in particular not if we don't know the language at that time. If we do know the language, it's helpful to include it.

joswarmer commented 8 months ago

So the repo can give either of the two as a result.

joswarmer commented 8 months ago

but that doesn't mean we have to include { reference: <meta-pointer>, targets: [] } in

My question is not whether we have to include it, that is clear, the question is whether we should do this or not, especially if the repo does not know the language. If we do include it, we show the fact that this node was stored with such a reference in the past (otherwise we would know this reference at all). This means that the answer to the client exposes some indirect information.

enikao commented 8 months ago

From a spec point of view, it would be valid to have the empty targets only if we've seen them before. However, this makes it hard to test (as it depends on other tests executed before). So from a practical point of view, I'd always include it for a repo that knows the language, and never include it for repos without language knowledge.