ProvenanceBase.jl

Lightweight base package for provenance data "providers" and "consumers".
Author PumasAI
Popularity
0 Stars
Updated Last
5 Months Ago
Started In
October 2020

ProvenanceBase

Lightweight base package for provenance data "providers" and "consumers".

Producers

Packages with types that would like to provide custom provenance data for their types should extend the provenance function for their types.

using ProvenanceBase

struct MyType
    # ...
end

ProvenanceBase.provenance(t::MyType) = (my = "provenance", data = "!")

The provenance method must return a NamedTuple containing the associated provenance data.

Consumers

Packages that wish to consume provenance data from other providers should extend signature and provide a subtype of AbstractSignature to "sign" the consumed provenance data:

using ProvenanceBase, Serialization, SHA

struct CustomSignature <: ProvenanceBase.AbstractSignature
    str::String
end

function ProvenanceBase.signature(::Type{CustomSignature}, object, timestamp, data)
    io = IOBuffer()
    serialize(io, (object, timestamp, data))
    return CustomSignature(bytes2hex(sha2_256(seekstart(io))))
end

Whether the "signing" is a strong cryptographic signature or a simple content hash is up to the package extending signature.

Provenance Data

Time-stamped provenance data associated with a particular object can be generated by calling Provenance(object) or Provenance(object, T) where T is your custom subtype of AbstractSignature.