Skip to main content

Module stamp

Module stamp 

Source
Expand description

The stamp a document carries when it leaves home.

An export — a .json written out, the metadata on a PDF — says which rev of which document it is a copy of, so a file that has travelled can be read back to where it came from:

{
  "stamp": { "rev": 12, "state": "<blake3 of revs/000012.json.gz>",
             "provenance": { "document": "motor-controller", … } },
  "version": 3,
  …the document…
}

The stamp is the first field so a reader takes it off the front; the document’s own fields follow flattened beside it, so the file is a document like any other and the command line can open one (ignoring the stamp) with no second shape to support.

Provenance is advisory throughout — it is never folded and never written into the importing document’s log. A container’s revs carry no stamp: inside a container the manifest says where every rev came from.

Structs§

Header 🔒
Enough of the file to read its stamp. Deserializing this builds a stamp and nothing else — serde skips every other field rather than modelling it, so asking where a file came from never parses the drawing in it.
Provenance
Where an export came from. Advisory throughout: it is never folded, never written into the importing document’s log, and a file that carries none is read exactly as one that does.
Source
What an exporting session knows about itself. The rev is deliberately absent: it is the stamp’s own, so Stamp::from is the single place the two are joined and they cannot disagree.
Stamp
Which rev a projection was written from. Both halves matter: the rev orders it against the history, and state — the blake3 of that rev’s own file, the one state digest this format has — says the document at that rev was this one. Stamp::provenance joins them on an artifact that left home, and only there.
Stamped 🔒
The file, as written: the stamp, then the document flattened beside it.

Functions§

export_text
document flattened under a stamp saying where it came from.
exported_stamp_in
Whether text is a flattened document carrying a stamp — what a document that left home has and a hand-written one does not.