Dumping and loading artifacts¶
Portable dump packages preserve an artifact's identity, body digest, and complete
lineage. A package contains manifest.json and one body representation:
- A custom
payload/directory when the artifact'sdump()andload()hooks are implemented. - A lossless
body.datfallback otherwise.
Custom packages do not duplicate the body as body.dat.
from provium import dump_artifact, load_artifact
dump_artifact("model.pa", "model-dump/")
load_artifact("model-dump/", "restored.pa")
The default exact load reconstructs the body and rejects it if its SHA-256 digest
or length differs from the original. Exact imports preserve the original identity
and computational lineage. Dump and load events are appended to the package's
transfer log in manifest.json.
Custom representations¶
Artifact readers and writers can define a compact or human-editable representation:
class TextArtifact(Artifact[TextReader, TextWriter]):
reader = TextReader
writer = TextWriter
@classmethod
def dump(cls, reader: TextReader, destination: Path) -> None:
(destination / "text.txt").write_text(reader.read())
@classmethod
def load(cls, source: Path, writer: TextWriter) -> None:
writer.write((source / "text.txt").read_text())
The framework creates the payload directory, hashes every file, validates safe relative paths, and owns identity and provenance handling.
Use representation="custom" to require these hooks or representation="raw" to
force body.dat. "auto" is the default.
Loading modified content¶
Changed content is rejected by default. Explicit modes control its provenance:
derivedassigns a new identity and recordsprovium.loadwith the original artifact and lineage as its input.rootassigns a new identity, drops inherited lineage, and records a newprovium.unsafe-loadprovenance root.
Use inspect_dump() for package metadata and verify_dump() to validate its file
inventory without loading it.
The equivalent commands are: