Skip to content

Resource Provenance (Audit)

Aaron Coburn edited this page May 26, 2020 · 9 revisions

Trellis keeps an audit record of all changes to a resource (create, update and delete) by adding provenance triples declaring which agent made changes to a resource at what time. These triples are not part of the default resource representation, but they can be requested with Prefer headers.

Prefer: return=representation; include="http://www.trellisldp.org/ns/trellis#PreferAudit"

These triples are read-only: there is no way to change or manipulate them. Blank nodes are used to reference the activity resources. An example resource with audit triples may look like this:

@prefix as:  <https://www.w3.org/ns/activitystreams#> .
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .
@prefix prov:  <http://www.w3.org/ns/prov#> .
@prefix dc:  <http://purl.org/dc/terms/> .

<https://example.com/container/resource>
        dc:title     "Resource"@eng ;
        dc:publisher <https://example.com/> .

<https://example.com/container/resource>
        prov:wasGeneratedBy  _:b0 .

_:b0    rdf:type                prov:Activity ;
        rdf:type                as:Create ;
        prov:wasAssociatedWith  <https://example.com/users/1> ;
        prov:atTime             "2017-10-23T19:23:00.512Z"^^xsd:dateTime .
            
<https://example.com/container/resource>
        prov:wasGeneratedBy  _:b1 .

_:b1    rdf:type                prov:Activity ;
        rdf:type                as:Update ;
        prov:wasAssociatedWith  <https://example.com/users/2> ;
        prov:atTime             "2017-10-23T19:39:54.435Z"^^xsd:dateTime .

<https://example.com/container/resource>
        prov:wasGeneratedBy  _:b2 .

_:b2    rdf:type                prov:Activity ;
        rdf:type                as:Update ;
        prov:wasAssociatedWith  <https://example.com/users/1> ;
        prov:atTime             "2017-10-23T19:48:16.076Z"^^xsd:dateTime .

If a client is interested in knowing exactly what was changed with each revision, it is possible to combine the data here with the available Mementos advertised in the response headers, comparing the differences between versions.

Clone this wiki locally