Skip to content

Design of resource metadata editing #1027

Closed

Description

@woutslabbinck

In response to the comment of @RubenVerborgh in #942, this issue is about how to edit the metadata of a resource.

Editing metadata with HTTP PUT

Currently it is possible to edit metadata by executing a PUT request and adding the metadata triples in the Link headers:

PUT / HTTP/1.1
Host: localhost:3000
Content-Type: text/turtle
Link: <http://www.w3.org/ns/pim/space#Storage>; rel="type", <http://localhost:3000/inbox> ; rel=<http://www.w3.org/ns/ldp#inbox>

...

Which will result in the .meta file:

<http://localhost:3000/> a <http://www.w3.org/ns/pim/space#Storage>.
<http://localhost:3000/> <http://www.w3.org/ns/ldp#inbox> <http://localhost:3000/inbox>.

When doing this approach you MUST add all metadata quads in the Link header, otherwise those are lost which might result in the CSS or applications not working as intended.
Note: this only works for a limited amount of predicates, which have to be manually placed in https://github.com/solid/community-server/blob/2e4589938f4475a1a776dbc82ca4fd1501360764/config/ldp/metadata-parser/parsers/link.json
List of predicates that can be placed in rel:

  • "type"
  • <http://www.w3.org/ns/ldp#inbox>

Exposing the .meta resources

A second approach is exposing the all the .meta resources. With this approach it is possible to edit the metadata as RDF resources directly.
The editing can then either be done with a PUT (replacing the whole .meta resource) or a PATCH (editing the .meta resource with an application/sparql-update)

Activity

  1. RubenVerborgh commented on Oct 26, 2021

    @RubenVerborgh
    Member

    Note: this only works for a limited amount of predicates, which have to be manually placed in https://github.com/solid/community-server/blob/2e4589938f4475a1a776dbc82ca4fd1501360764/config/ldp/metadata-parser/parsers/link.json
    List of predicates that can be placed in rel:

    I just want to note that this is by design; because the client might have other reasons for adding Link headers.
    In other words: the request containing Link headers in a PUT/POST by itself is not a sign that the server should attach them to the resource.

    However, some operations need to happen simultaneously; i.e., when creating a container, the appropriate Link headers have to be set during that creation and cannot be amended later through other actions (such as .meta).


    In terms of approaches, I myself have always favored quad-based representations with a dedicated metadata graph, as we have done for the design of Triple Pattern Fragments. But we currently do not have wider support for this, even though it would address the simultaneity requirement.

  2. jvherweg commented on Oct 26, 2021

    @jvherweg
    Member

    Some issues when you can directly edit the .meta resource:

    There is some metadata we don't want users to edit: it should not be possible to edit if a resource is a container and if it is a storage to give some examples. So we would potentially need a list of protected triples and prevent those from changing. We could also have 2 separate metadata files, where only one can be accessed and which is linked through the describedby relation.

    Another issue is that in general Solid exposes metadata through HTTP headers when doing a GET/HEAD request. This does not always provide enough information on what someone would have to edit in a metadata resource to change that header. E.g. if there is a header Link: <https://example.com>; rel="linkedResource", how would someone know what triple needs to change in the metadata resource to update the value there? It is helped that many link relationships are URIs (such as http://www.w3.org/ns/ldp#inbox above) which could be used as predicates.

    All of the above is also only about Link headers, do we also care about other headers? Because Link headers require a URI as value which might limit options in case there is metadata that uses Literals.

    Not that I have a better solution atm but we would have to keep those in mind when implementing.

    Another issue is of course that this would be a specific implementation for CSS which is going to be annoying for app developers if it is different everywhere.

  3. RubenVerborgh commented on Oct 26, 2021

    @RubenVerborgh
    Member

    There is some metadata we don't want users to edit

    I think we should protect those; just like we protect container listings.

    All of the above is also only about Link headers, do we also care about other headers?

    I personally don't; although maybe some RDF could translate into non-Link headers.

    Another issue is of course that this would be a specific implementation for CSS which is going to be annoying for app developers if it is different everywhere.

    I think this belongs in an experimental module of CSS, not in the main code. And if we are happy with the way it works, we should propose it to the spec. This is one of the important functions of CSS: informing the spec through open implementation.

  4. jvherweg commented on Oct 28, 2021

    @jvherweg
    Member

    Some more musings. I tried to have nice headers this time.

    Discovery

    We have to make sure there is a way to discover the metadata document from a resource URL, even if it does not exist yet, so the client knows where to write for new metadata. Perhaps we can use the describedby link header similarly to how the acl link header works? That is, always have a value there, even if the document does not exist yet.

    PUT behaviour

    Currently when doing a PUT request on a resource it gets overwritten completely. This includes the metadata. Question is if we still want this or do we want to provide a way to overwrite metadata without touching (user-added?) metadata. It might be annoying that an inbox header of a resource gets lost simply because a small modification was made to a file. On the other hand, when creating a new resource with PUT it is currently expected that the metadata headers get copied to the resource.

    Data accessors

    Besides how clients interact with the metadata resources, we also have to think how we are going to store them in the backend. Currently metadata and data are tied closely together everywhere: Representations contain both, and the write functions of DataAccessors also expect both a data stream and a RepresentationMetadata object (only the latter for containers). The DataAccessor can then choose how that metadata is stored. The store calling the accessor has no idea how this is done. Current implementations:

    • File: Append .meta to the file name that is used to store data. Also remove metadata that is stored by the file system (date last modified, content-type, container/resource types).
    • Sparql: Use a new metadata URI (meta:$RESOURCE_ID) as a subject for all the metadata that needs to be stored.
    • Memory: Store the metadata object in memory.

    One solution is to let a ResourceStore handle the updating of the metadata so the accessors are not aware anything changed here. In case of a request on the .meta resource this store would then request the metadata object on the subject resource and serialize it, after which it can be interpreted as any other resource. One issue here is that this would cause our meta resource to have metadata on its own, which the file data accessor would write to a .meta.meta file.

    Another solution could be to update the DataAccessor interface to also have a writeMetadata function. Currently the only way to write metadata for a document is to also include the data stream. The DataAccessorBasedStore could then use that function when the incoming identifier is a metadata identifier. Would be another relevant point for #998.

    SPARQL backends

    As mentioned above, we store metadata using the URI meta:$RESOURCE_ID. We did this so we never had to worry about having to prevent users from writing to a resource ending with .meta. But perhaps we want to change this after this change so people are not confused where the metadata is stored when they query their SPARQL store directly. This would break all current implementations with a SPARQL store though.

  5. RubenVerborgh commented on Nov 3, 2021

    @RubenVerborgh
    Member

    @woutslabbinck Does the above provide you with enough information to start implementing this in an external module?

    An example of a recently created external module: https://github.com/RubenVerborgh/solid-metadata-extender

  6. woutslabbinck commented on Nov 4, 2021

    @woutslabbinck
    MemberAuthor

    After an offline discussion, I propose to implement the following solution were proposed to allow reading and writing (editing) metadata.

    Discovery

    HTTP GET/HEAD to an LDP Resource MUST result in a Link header : link: <resourceURI.meta>;rel="describedBy", indicating the location of the metadata (even when the .meta resource does not exist) .

    PUT behaviour

    Currently, PUT overwrites a resource completely. However, sometimes it is preferred that all the metadata is preserved

    Proposed solution

    Have a Link header that indicates that the metadata should be preserved: link: <resourceURI.meta>; rel="preserve"

    When this link is in the metadata, setPresentation in the DataAccessorBasedStore MUST keep the old metadata.

    This means that if this link header is not added, all the metadata will be over written. Thus PUT requests MUST be handled with care.

    Note: This preserve rel does not exist yet and is just used to let the CSS know metadata should be kept as is during a PUT request.

    Data accessors

    The current DataAccessor interface does not support writing metadata (standalone).

    The following interface makes editing metadata possible. Using the interface it is possible to write to .meta files directly without the possibility to create .meta.meta files.

    export interface DataAccessor {
      canHandle: (representation: Representation) => Promise<void>;
      getData: (identifier: ResourceIdentifier) => Promise<Guarded<Readable>>;
      getMetadata: (identifier: ResourceIdentifier) => Promise<RepresentationMetadata>;
      getChildren: (identifier: ResourceIdentifier) => AsyncIterableIterator<RepresentationMetadata>;
      writeDocument: (identifier: ResourceIdentifier, data: Guarded<Readable>, metadata: RepresentationMetadata) => Promise<void>;
      writeContainer: (identifier: ResourceIdentifier, metadata: RepresentationMetadata) => Promise<void>;
      writeMetadata: (identifier: ResourceIdentifier, data: Guarded<Readable>) => Promise<void>;
      deleteResource: (identifier: ResourceIdentifier) => Promise<void>;
    }

    Changes:

    • Introduction of writeMetadata: A method that makes it possible to write metadata
    • Allowing on a higher level to interact (HTTP GET, HTTP PUT) with .meta files

    Changes required in the FileDataAccessor

    Method Required changes
    canHandle /
    getData /
    getMetadata /
    getChildren /
    writeDocument /
    writeContainer /
    writeMetadata Does a check to only allow quad representation
    Transform internal quads to turtle, as is currently present in the file based style
    await this.writeDataFile(link.filePath, tranformedData);
    deleteResource /

    Changes required in the InMemoryDataAccessor

    Method Required changes
    canHandle /
    getData /
    getMetadata /
    getChildren /
    writeDocument /
    writeContainer /
    writeMetadata Does a check to only allow quad representation
    Transform internal quads to turtle, as is currently present in the file based style
    Create a ResourceIdentifier of the resource (remove .meta from the path) and add the data to the entry (just like in writeDocument)
    deleteResource /

    Changes required in the SparqlDataAccessor

    Currently, I don't really know what has to be changed here. Does it actually have to be changed? The way I understand is that if changes are made, all current implementations with a SPARQL store would break.

  7. jvherweg commented on Nov 8, 2021

    @jvherweg
    Member

    Have a Link header that indicates that the metadata should be preserved: link: <resourceURI.meta>; rel="preserve"

    My only worry about this is that it might cause confusion that the metadata URI has to be added to the header. What is the behaviour if another URI is used there? This is very minor though and can always be changed later.

    The main issue is probably going to be that nobody will be aware that this is a feature that can be used.

      writeDocument: (identifier: ResourceIdentifier, data: Guarded<Readable>, metadata: RepresentationMetadata) => Promise<void>;

    Could we make metadata an optional parameter here? That way we can indicate if metadata should be overwritten or not (when using the preserve header).

      getMetadata: (identifier: ResourceIdentifier) => Promise<RepresentationMetadata>;
      writeMetadata: (identifier: ResourceIdentifier, data: Guarded<Readable>) => Promise<void>;

    It's somewhat inconsistent that one function here returns a metadata object, and the other one takes as input a data stream. Either they both should use a RepresentationMetadata object or a stream.

    Changes required in the InMemoryDataAccessor

    ...
    writeMetadata Does a check to only allow quad representation
    Transform internal quads to turtle, as is currently present in the file based style

    Why do we need turtle here?

    Changes required in the SparqlDataAccessor

    Currently, I don't really know what has to be changed here. Does it actually have to be changed? The way I understand is that if changes are made, all current implementations with a SPARQL store would break.

    They would, but question is if it might still be interesting to do. It would make the URIs more consistent. It might be confusing to users that the metadata uri is http://localhost:3000/resource.meta but it is stored in the SPARQL store as meta:http://localhost:3000/resource. Perhaps the data accessor could take something as input to define how the internal metadata URIs need to be generated so we can be backwards compatible. But preferable we don't have options only for backwards compatibility since that can make things quite ugly quite fast.

    Other comments/questions

    I am interested in knowing which changes will be required in the DataAccessorBasedStore to support this new behaviour since most changes might be required there. Specifically when doing a GET/PUT/POST targeting either a standard resource or a meta resource, how are the data accessor functions going to be called in each case? How are we going to prevent certain metadata triples to be changed? Etc.

    We probably don't want .meta.meta resources, but perhaps we do want to store certain metadata for .meta resources such as last modified date, unless we use the same value as the subject resource there.

    I'm also interested in what the advantage is of this solution compared to the other suggested solution of generalizing the interface to something like the following interface (vague concept since we would have to think about the function signatures):

    export interface DataAccessor {
      canHandle: (representation: Representation) => Promise<void>;
      getData: (identifier: ResourceIdentifier) => Promise<Guarded<Readable>>;
      getMetadata: (identifier: ResourceIdentifier) => Promise<RepresentationMetadata>;
      getChildren: (identifier: ResourceIdentifier) => AsyncIterableIterator<RepresentationMetadata>;
      writeResource: (identifier: ResourceIdentifier, data: Guarded<Readable>, metadata: RepresentationMetadata) => Promise<void>;
      deleteResource: (identifier: ResourceIdentifier) => Promise<void>;
    }

    Where the same functions are used for writing metadata and resources. I don't have a preference either way (yet? :D), but we should make sure the chosen solution is best to tackle all the possible problems.

  8. changed the title [-]How to edit a resource's metadata[/-] [+]Add support for editing resource metadata[/+] on Dec 1, 2021
  9. woutslabbinck commented on Dec 8, 2021

    @woutslabbinck
    MemberAuthor

    After an offline discussion with Joachim, I can now make an analysis and proposal of how metadata can work in the CSS.

    First I'll talk about reading metadata and explain the different approaches, then I'll talk about writing metadata and do the same.

    Reading metadata

    Return everything

    There are two approaches, one is that when sending a GET request to a metadata file of resource foo (e.g. example.org/foo.meta) all metadata that belongs to a resource is returned.

    This includes for resources the time that it was last modified (dc:modified), the type (rdf:type) and the content-type (text/turtle).

    Return metadata file

    A second approach would be that only a part of the metadata contents is returned.
    More specifically, in this approach, everything that is in the metadata file (.meta) will be returned.

    Writing metadata

    The first thing I want to mention is that POSTing metadata semantically does not make sense.
    As metadata is auxiliary data that belongs to a resource, it would not make sense to create metadata without it corresponding to a resource.
    Another way to look at it is the fact that whenever you create a resource (either by PUT or POST) metadata is generated anyway, thus if metadata already is present, you only can update it and not create it.

    Therefore my suggestion is that on a POST request, no metadata can be created.

    Now that this is out of the way, I see three approaches for updating metadata

    1. PUT request with all the metadata in it
    2. PUT request without certain predicates (like ldp:contains), indicating that only parts of the total metadata are added
    3. editing metadata using a PATCH request

    PUT everything

    In this case, when executing a PUT on the metadata of the resource, everything has to be added in the body of the request.

    Let's take as an example that you would want to indicate in an ldp:container (located at example.org/) that one of its resources (also a container, located at example.org/1636985640000/) is now an ldp:inbox.

    The metadata contents before the PUT request would be:

    @prefix acl: <http://www.w3.org/ns/auth/acl#> .
    @prefix dc: <http://purl.org/dc/terms/> .
    @prefix ldp: <http://www.w3.org/ns/ldp#> .
    @prefix posix: <http://www.w3.org/ns/posix/stat#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    
    <example.org/> rdf:type ldp:BasicContainer, ldp:Container, ldp:Resource ;
        dc:modified "2021-12-03T09:24:19.000Z"^^xsd:dateTime ;
        acl:accessControl <example.org/.acl> ;
        ldp:contains <example.org/1636985640000/> ;
        posix:mtime 1638523459 .
    
    <example.org/1636985640000/> rdf:type ldp:BasicContainer, ldp:Container, ldp:Resource ;
        dc:modified "2021-11-29T16:11:43.000Z"^^xsd:dateTime ;
        posix:mtime 1638202303 .

    The PUT request would then be the following

    PUT /.meta HTTP/1.1
    Host: example.org
    Content-Type: text/turtle
    Link: <http://www.w3.org/ns/ldp#Container>; rel="type"
    
    @prefix acl: <http://www.w3.org/ns/auth/acl#> .
    @prefix dc: <http://purl.org/dc/terms/> .
    @prefix ldp: <http://www.w3.org/ns/ldp#> .
    @prefix posix: <http://www.w3.org/ns/posix/stat#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    
    <example.org/> rdf:type ldp:BasicContainer, ldp:Container, ldp:Resource ;
        dc:modified "2021-12-03T09:24:19.000Z"^^xsd:dateTime ;
        acl:accessControl <example.org/.acl> ;
        ldp:contains <example.org/1636985640000/> ;
        ldp:inbox <example.org/1636985640000/> ;
        posix:mtime 1638523459 .
    
    <example.org/1636985640000/> rdf:type ldp:BasicContainer, ldp:Container, ldp:Resource ;
        dc:modified "2021-11-29T16:11:43.000Z"^^xsd:dateTime ;
        posix:mtime 1638202303 .

    However, a big problem arises when in the meantime a new resource was created in example.org/

    The metadata would then be the following:

    @prefix acl: <http://www.w3.org/ns/auth/acl#> .
    @prefix dc: <http://purl.org/dc/terms/> .
    @prefix ldp: <http://www.w3.org/ns/ldp#> .
    @prefix posix: <http://www.w3.org/ns/posix/stat#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    
    <example.org/> rdf:type ldp:BasicContainer, ldp:Container, ldp:Resource ;
        dc:modified "2021-12-03T09:24:19.000Z"^^xsd:dateTime ;
        acl:accessControl <example.org/.acl> ;
        ldp:contains <example.org/1636985640000/>, <example/foo.ttl> ;
        posix:mtime 1638523459 .
    
    <example.org/1636985640000/> rdf:type ldp:BasicContainer, ldp:Container, ldp:Resource ;
        dc:modified "2021-11-29T16:11:43.000Z"^^xsd:dateTime ;
        posix:mtime 1638202303 .
    
    <example.org/foo> ldp:Resource ;
        dc:modified "2021-12-06T14:04:28.000Z"^^xsd:dateTime ;
        posix:mtime 1638799468 .

    This means that an update metadata request would generate invalid metadata about the ldp container example.org/.

    Hence, the strategy where everything is added in the body with a metadata PUT request has flaws by design.

    PUT partial

    Luckily this can be overcome when certain parts of the metadata are omitted when editing the metadata with a PUT request.

    For example, metadata about the structure of the resource can be left out of the request. This way, an invalid state like in the previous section will not happen.

    However, both the server and the client MUST then know what can be edited by a PUT request and what metadata is maintained by the server.

    Metadata triples like <example.org/> rdf:type ldp:BasicContainer or <example.org/> ldp:contains <example.org/1636985640000/> ; can then no longer appear in a PUT request body.

    This way of using PUT, however, is not actually a PUT anymore.
    A PUT request normally replaces the content completely, yet when doing it partial, not everything is replaced.

    If PUT acts as just patching the metadata, it might be better to just use PATCH as a way to update the metadata of a resource.

    PATCH

    Since often metadata only needs a partial update. It seems appropriate to use a PATCH request for this matter.

    But unlike PUT partial, where there might be confusion on what should be in the body (as in PUT partial everything in the body will replace the current contents of the .meta file), in PATCH there must only be content of what has to be changed.

    When trying to add a triple like indicating a container is an inbox, it would be the following request:

    PATCH /.meta HTTP/1.1
    Host: example.org
    Content-Type: application/sparql-update
    
    INSERT DATA { <example.org/> <http://www.w3.org/ns/ldp#inbox> <example.org/1636985640000/>}

    And if you want to delete that triple, the DELETE operation is used.

    PATCH /.meta HTTP/1.1
    Host: example.org
    Content-Type: application/sparql-update
    
    DELETE DATA { <example.org/> <http://www.w3.org/ns/ldp#inbox> <example.org/1636985640000/>}

    Using PATCH to only update a part of the metadata is way more clear to a client. This is because, unlike PUT, only the contents that have to be changed are sent as a request.

    A downside to using a SPARQL UPDATE query might be that it requires the client to be more advanced. But when a client is trying to update metadata, there is a high probability that he/she is already quite knowledgable about SPARQL.

    Deleting metadata

    Just like that it does not make sense to POST metadata, it does not make sense to delete all the metadata. As the metadata belongs to a resource. When a resource gets deleted, the metadata itself obviously is deleted as well.

    Proposed solution

    Now that the different options of the behaviour of reading and updating metadata are laid out, I will propose which way I would want it to work with the CSS.

    For reading the metadata with an HTTP GET .meta, I propose that the response is that only the contents of that file are returned.

    When updating metadata, I propose to use HTTP PATCH with a SPARQL UPDATE query. This way it is clear to both the client and server what has to be changed in the .meta file.

    Both POST and DELETE would be invalid requests to .meta files as they do not make much sense. And finally, because PATCH is chosen as a way to update, PUT requests would then also be invalid.

    As a final remark, I also agree that it should not be possible to create .meta.meta files, but information of the metadata files should just be stored in the .meta file with accompanying triples.

  10. RubenVerborgh commented on Dec 8, 2021

    @RubenVerborgh
    Member

    Great, agree with the approach!


    As a final remark, I also agree that it should not be possible to create .meta.meta files, but information of the metadata files should just be stored in the .meta file with accompanying triples.

    Yes, similar to how the ACL of /foo is /foo.acl, but the ACL of /foo.acl is /foo.acl.

  11. changed the title [-]Add support for editing resource metadata[/-] [+]Design of resource metadata editing[/+] on Dec 8, 2021
  12. jvherweg commented on Jan 26, 2022

    @jvherweg
    Member

    Addendums after some discussions:

    Currently, when PUTting to a container on CSS, the input body is interpreted as metadata that should be assigned to the container. To be consistent with the suggestion above, we would no longer allow this and only allow creating containers by doing an empty PUT to the target.

    It is also possible right now to assign certain metadata entries to a resource during a PUT using Link headers. Such as the inbox header. This behaviour would then have to disappear after this metadata change. Only headers that are defined in the Solid spec should be interpreted for input (such as defining a resource as a container on creation).

    The above would make it so PATCH becomes the only way to create/edit metadata on a resource. There is a bug right now where it is possible to mark certain resources as pim:Storage using one of the 2 options above, which is something that we don't want and will be resolved by resolving this issue.

  13. woutslabbinck commented on Jan 27, 2022

    @woutslabbinck
    MemberAuthor

    After some discussions, a decision was made that on a PUT request to an existing LDPC results into throwing an HTTP Conflict Error (409) as it makes no sense to reset the metadata using PUT (which is the current behavior after the above comment).

    Two reasons were taken into account for this decision:

    1. The metadata can be reset anyway using PATCH queries to the container. Thus no functionality is lost.
    2. Otherwise, it would have been possible to reset an LDPC which was a pim:Storage, which as a result could break the pod and applications that were using the pod
  14. adlerfaulkner commented on Mar 11, 2022

    @adlerfaulkner
    Member

    The Solid protocol states:

    When a PUT or PATCH method request targets an auxiliary resource, the server MUST create or update it.

    Wouldn't this be in conflict with that?

    as it makes no sense to reset the metadata using PUT


    Also on a more general note, this was probably decided on by all you long ago, but based on the Solid protocol's concept of Auxiliary resources why are access controls treated differently from metadata? Why would DataAccessors have a getMetadata and a writeMetadata but not a getAcl and writeAcl allowing each DataAccessor to implement it differently?

    As noted above about how each DataAccessor can choose how metadata is stored, why are they not given the same choice for the storage of acl? I would think the same would go for shape constraints, provenance, etc. I'd think there are two strict choices on architecture:

    1. DataAccessors are only responsible for storing data at each URI regardless of what that URI "means" within CSS or Solid
    2. DataAccessors have their own implementations for storing resources, metadata, acl, shape contraints, etc. and something outside them (seemingly DataAccessorBasedStore) is responsible for routing URIs to the correct methods.

    Correct me if I'm wrong, but it feels like CSS is somewhere inbetween this right now where each DataAccessor has it's own implementation of the storage of metadata which follows achitecture#2 but doesn't have the equivalent for acl. All acl logic is in WebAclReader which uses getRepresentation of the DataAccessorBasedStore to get the data at the acl URI following achitecture#1.

    Is this a helpful way to think about things or I am just pointing out the obvious choices you've made? This line of thought feels related to #998.

  15. jvherweg commented on Mar 14, 2022

    @jvherweg
    Member

    The Solid protocol states:

    When a PUT or PATCH method request targets an auxiliary resource, the server MUST create or update it.

    Wouldn't this be in conflict with that?

    as it makes no sense to reset the metadata using PUT

    We could allow PUT if it contains exactly the same values for all triples that are not allowed to be changed, but in practice I don't think this would ever be very useful. But we might make this change in the future if required.

    You raise some interesting points so I'm going to cover some thoughts about metadata in general and how CSS handles it. But in summary, your point 2 will never happen as that breaks the modularity of the server and goes against the idea that DataAccessors remain as simple as possible for adding new backends. Point 1 was considered for this issue, but there are some annoying edge case issues there. But we might still get there in the future (I actually hope we do).

    It is important to note that every resource has metadata. This includes metadata such as its type (container or not), it's content-type, last modified date, etc. Since every resource has metadata the choice was originally made to let DataAccessors handle how they store it. For the FileDataAccessor is is necessary that it knows the content-type of the incoming data, otherwise it does not know which file extension to use to store the data under. This is one of those edge cases mentioned above. We could choose to no longer use the file extension for that and always write to a .meta file, but that would go against expected file behaviour for a solid server so for now we have decided to follow that expectation. There might also be some other cases I'm not thinking of right now. But I do agree there's something to be said for no longer letting the DataAccessor be aware of these differences.

    All of the above to say that even before this issue the server already had metadata. The way of exposing the metadata for now was quite strict: only through the link headers as required by the spec. The 2 disadvantages with that are that every time new metadata needs to be exposed, this needs to be added to the Components.js configuration, and that the only way to modify it is by doing a PUT with specific link headers. This is why we are investigating exposing the metadata through what is described as a "description resource". I make the explicit difference here because it is never said that the description resource should contain all the data. Currently there is no clear delimitation of which metadata needs to be in there and which not, so we just decided for now to expose all metadata through this description resource.

    Acl and description resources are configured mostly the same in the server, they both make use of the auxiliary resource. The main difference is how they are handled in the end. For the description resource we now still depend on the tight coupling between metadata and data, which is why they're tied together in the DataAccessor, but even if that would go away there is still going to be a tighter coupling there then between acl and the resource. It should easily be possible to enable a different authorization method, but metadata is always going to be present.

    This reply ended up being a bit longer than expected (and less structured than it should be probably 😅), but the entire metadata discussion is quite interesting and there are many ways to go with it. This is just the way we have decided for now in an attempt to have a consistent solution. But this might change if the spec disagrees and goes another route.

  16. adlerfaulkner commented on Mar 16, 2022

    @adlerfaulkner
    Member

    Right, given that metadata and resources are one-to-one, it makes sense to have the DataAccessor "know" about and decide how to store metadata. On the opposite side of the spectrum there is a lot of logic about acls which don't match up "per-resource" and wouldn't make sense in a DataAcessor. However, every resource CAN have one acl auxiliary resource which makes me think it could be given the same treatment as metadata in the DataAccessor with the exception that it can be undefined for a resource and with the actual acl logic (recursive stuff & interpretation in WebAclReader) outside of the DataAccessor.

    It should easily be possible to enable a different authorization method

    What would be an example of this?

  17. jvherweg commented on Mar 17, 2022

    @jvherweg
    Member

    However, every resource CAN have one acl auxiliary resource which makes me think it could be given the same treatment as metadata in the DataAccessor

    The problem with this is that it would suddenly create a tight coupling between the backend and the authorization, which currently are 2 mostly independent systems. And it would require changes to the DataAccessor to change something in the authorization.

    The original architecture for the CSS actually didn't even have DataAccessor. The deepest backend class was the ResourceStore. DataAccessor was added because we realized most of the Solid requirements could be fulfilled independent of the backend. The DataAccessor interface would then only contain the bare essentials that are necessary for a backend to store and retrieve data without having to be aware of (most of) the Solid situation. Adding acl related functions to that interface would go against that idea and make us lose the advantages we gained.

    with the exception that it can be undefined for a resource and with the actual acl logic (recursive stuff & interpretation in WebAclReader) outside of the DataAccessor.

    What exactly would be the advantages you see from making this change? Because those are pretty much the only things that we do with acl resources. Besides that they are mostly just like any other resource.

    Note that if you really want to you can have your DataAccessor handle acl resources differently, just check if the incoming data targets such a resource. I wouldn't recommend it though because of the tight coupling.

    It should easily be possible to enable a different authorization method

    What would be an example of this?

    The theory is that it doesn't matter, we simply want to be flexible so if someone wants to try creating a Solid server with a new authorization scheme they just invented they have the opportunity to do that without having to rewrite the entire server. In practice a lot of work has already been done on ACP, which will at some point be integrated into the server.

  18. adlerfaulkner commented on Mar 17, 2022

    @adlerfaulkner
    Member

    with the exception that it can be undefined for a resource and with the actual acl logic (recursive stuff & interpretation in WebAclReader) outside of the DataAccessor.

    What exactly would be the advantages you see from making this change?

    Note that if you really want to you can have your DataAccessor handle acl resources differently, just check if the incoming data targets such a resource. I wouldn't recommend it though because of the tight coupling.

    Yes, this decision is what I was puzzled over when implementing a new DataAccessor with a graph database. The two options are:

    1. the implementation would not decide for itself how to store & relate acl and just implement the container paradigm as necessary by LDP/ the DataAccessor interface. This may make querying the graph database less intuitive because queries have to be written with CSS specific knowledge that acl are nodes that have a uri property ending with.acl.
    2. the implementaion would decide to store and relate acls differently from normal resources however the developer chooses but to do so it would have to parse the .acl extension on every writeDocument, getData, etc. to see if we were talking about an acl resource and act accordingly.

    As context, my consideration here is largely based on the idea of adding another query interface on top of the graph database that maintains the rules of the acls but allows for easier & fast querying for data across resources and across containers. Thus, having more leeway over the strucutre of the data will allow for more "graph intuitive" queries. It's a tradeoff, as you increase how much you transform the structure of the data away from the CSS conventions and into some other "graph" conventions, you also have to increase how much parsing and logic is baked into the DataAccessor.

    The same might go for someone implementing a postgresql DataAccessor. What if, for their use case, it made sense to have a table for acls and another table for regular resources. They would have to parse the .acl extension and write to the correct table accordingly. Maybe that's not such a huge problem but that's the consideration.

  19. jvherweg commented on Mar 18, 2022

    @jvherweg
    Member

    As context, my consideration here is largely based on the idea of adding another query interface on top of the graph database that maintains the rules of the acls but allows for easier & fast querying for data across resources and across containers.

    So the main issue is how to support a new query interface on the server besides the standard Solid LDP API. I would suggest opening a new discussion specifically about this if you want to continue since this is getting a bit off-topic for this issue, but I can tell you that this is something that we are also interested in and are planning to do research on at some point. How to handle authorization there is indeed one of the big issues, but I don't think the answer is letting the DataAccessor handle everything internally.

    What if, for their use case, it made sense to have a table for acls and another table for regular resources.

    Then they would need a separate solution as the DataAccessor is created to not know about such things. They could for example use a RoutingResourceStore to direct certain resources to different backends (see example in config/sparql-file-storage.json), or even set up a different HTTP handler for such resources (which we do when you want to enable acl on the IDP APIs, although we do use the same backend there)

  20. jvherweg commented on Aug 8, 2022

    @jvherweg
    Member

    Done in #1188

  21. added a commit that references this issue on Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions