Sidecar metadata for non-markdown items: XMP vs .md (research + grill) #412

Open
opened 2026-10-15 06:16:39 +00:00 by kayg · 2 comments
Owner

From #400 W21. Archive, Hide and later captions, places and tags need a place to live for items that can't hold frontmatter: photos, PDFs, other files, mail, transactions. Notes use frontmatter (archived: true, hidden: true).

kayg: "isn't .xmp a valid sidecar already? I mean i would love a .md instead because it's more readable but we should also follow conventions and standard wherever appropriate. let's research and think about this one more."

Research, citing sources:

  • XMP sidecars:
    • the spec (Adobe XMP Part 3, sidecar files);
    • naming, IMG_1234.xmp versus IMG_1234.jpg.xmp, and who uses which: Lightroom, darktable, digiKam, Capture One, Immich, PhotoPrism, Apple Photos export, exiftool;
    • which fields map to ours: dc:subject / lr:hierarchicalSubject for tags, dc:description for caption, xmp:Rating, xmp:Label, GPS for places;
    • whether a standard or common field exists for "archived" or "hidden" (e.g. digiKam's, Lightroom's reject flag, Immich's archived/visibility);
    • round-trip safety when other tools rewrite the XMP.
  • Embedded XMP in JPEG/HEIC/PDF, versus sidecars. Never modify originals (dedupe, hashing, ADR 0027/0028).
  • Markdown sidecars (IMG_1234.jpg.md): readability, prior art, and how other tools would treat them.
  • Hybrid: XMP for standard photo fields (interop with photo tools), plus our extra fields in XMP under a Calternal namespace; or .md for text-y things (captions) and XMP for the rest; or .md with an XMP export.
  • Mail and transactions: what the standard formats are (.eml/maildir; ledger/beancount/OFX), and where per-item flags live in each (maildir flags!).
  • Performance at 100k files: a sidecar per file doubles the file count; when should we create one lazily?

Output: a comparison table and a recommended design, with a numbered grill for kayg (each question with a recommended answer).

From #400 W21. Archive, Hide and later captions, places and tags need a place to live for items that can't hold frontmatter: photos, PDFs, other files, mail, transactions. Notes use frontmatter (`archived: true`, `hidden: true`). kayg: "isn't .xmp a valid sidecar already? I mean i would love a .md instead because it's more readable but we should also follow conventions and standard wherever appropriate. let's research and think about this one more." Research, citing sources: - **XMP sidecars:** - the spec (Adobe XMP Part 3, sidecar files); - naming, `IMG_1234.xmp` versus `IMG_1234.jpg.xmp`, and who uses which: Lightroom, darktable, digiKam, Capture One, Immich, PhotoPrism, Apple Photos export, exiftool; - which fields map to ours: dc:subject / lr:hierarchicalSubject for tags, dc:description for caption, xmp:Rating, xmp:Label, GPS for places; - whether a standard or common field exists for "archived" or "hidden" (e.g. digiKam's, Lightroom's reject flag, Immich's archived/visibility); - round-trip safety when other tools rewrite the XMP. - **Embedded XMP** in JPEG/HEIC/PDF, versus sidecars. Never modify originals (dedupe, hashing, ADR 0027/0028). - **Markdown sidecars** (`IMG_1234.jpg.md`): readability, prior art, and how other tools would treat them. - **Hybrid:** XMP for standard photo fields (interop with photo tools), plus our extra fields in XMP under a Calternal namespace; or `.md` for text-y things (captions) and XMP for the rest; or `.md` with an XMP export. - **Mail and transactions:** what the standard formats are (.eml/maildir; ledger/beancount/OFX), and where per-item flags live in each (maildir flags!). - **Performance at 100k files:** a sidecar per file doubles the file count; when should we create one lazily? Output: a comparison table and a recommended design, with a numbered grill for kayg (each question with a recommended answer).
Author
Owner

Research: where Archive, Hide, captions, places and tags live for things that aren't notes

Reference products are named only in these notes, never in the UI.

1. What we found

XMP sidecars are the standard, and the spec says how to name them, though only loosely.

  • Adobe's XMP spec, Part 3, prefers embedding. It allows a separate file when embedding is "not appropriate or possible". That file should be a complete XML document with a .xmp extension, and readers should "look in the same directory for a file with the same name as the main document but with an .xmp extension. (This is called a sidecar XMP file.)" (XMP Part 3, 2020, "External storage of metadata"; Adobe XMP specs). The spec never settles whether "the same name" includes the original extension (pixls.us thread).

  • Naming in practice:

    Tool Writes Reads
    Lightroom Classic IMG.xmp, and only for proprietary raw files. JPEG, TIFF, DNG and HEIC are modified in place (Adobe community, jkost) IMG.xmp
    Capture One IMG.xmp, shared by IMG.NEF and IMG.jpg (C1 support) IMG.xmp
    darktable IMG.jpg.xmp (and IMG_01.jpg.xmp for duplicates) both. It reads IMG.xmp but never writes to it (darktable manual)
    digiKam IMG.jpg.xmp by default. A "compatible with commercial programs" option switches it to IMG.xmp (digiKam docs) the form it's set to
    Immich IMG.jpg.xmp; writes merge into the existing file IMG.jpg.xmp first, then IMG.xmp (Immich docs)
    PhotoPrism no XMP writes. It keeps its own YAML sidecars both forms (PhotoPrism XMP)
    Apple Photos IMG.xmp, through "Export IPTC as XMP" (Apple) —
    exiftool whatever you pass; the usual form is %d%f.xmp = IMG.xmp (exiftool metafiles) any

    IMG.xmp collides when IMG.jpg and IMG.heic sit side by side (KDE bug 264007). IMG.jpg.xmp can't collide, and the newer open tools prefer it.

  • Standard fields that map to ours: tags → dc:subject, plus lr:hierarchicalSubject and digiKam:TagsList for nested tags. Caption → dc:description. Place → exif:GPSLatitude/exif:GPSLongitude. Rating → xmp:Rating (Immich reads and writes exactly this set). xmp:Label is free text, and the apps disagree on its values (XnView forum quoting the spec, Adobe community).

  • No standard field means "archived" or "hidden". The nearest are all reject or cull flags, which mean "bad shot, probably delete":

    • Bridge: xmp:Rating = -1 (Adobe community);
    • Lightroom Classic 13.2 and later: xmpDM:pick = -1/0/1, reported but not documented by Adobe (exiftool forum);
    • digiKam: digiKam:PickLabel 0–3, where 1 = rejected (exiv2).

    Immich has a real visibility: timeline | archive | hidden | locked (Immich CLI). It lives only in Immich's database and is not written to XMP. PhotoPrism's private and deleted live in its own YAML (PhotoPrism backups). Every tool that has the concept keeps it private, so we need our own namespace.

  • Round trips. Immich merges and keeps fields it doesn't know. exiftool reads unknown namespaces but only writes namespaces it has been told about, and bulk copies have mangled private namespaces before (exiftool XMP tags, exiftool forum). Expect another tool to rewrite the file now and then and to drop our fields on rare occasions.

Embedded XMP is ruled out. Writing XMP into a JPEG, HEIC or PDF changes the bytes. That breaks the blake3 hash and the reflink dedupe (0027), and it breaks "never rename or rewrite what you uploaded" (0028). Lightroom shows the side effects: rewritten files and changed file dates (Adobe community). A saved PDF even keeps the old packets behind the new one (Part 3, PDF section). We still read embedded XMP, EXIF and IPTC on import, read-only.

Markdown sidecars exist only as Obsidian plugins. These include Attachment Sidecar, Sidecars, Media Sidecar Tools and Local PDF Annotator (x.pdf.annotations.md). There's no spec. No photo tool reads them, and every markdown app (Obsidian, ours, editors) shows IMG_1234.jpg.md as a note, which clutters the user's notes. They are nicer to read.

Other options we looked at:

  • xattrs (user.xdg.tags) leave the original's bytes alone. But copies, zips, sync tools and backups drop them, and nobody can see them. That fails file over app.
  • Index-only storage (our index.db) is fast, but 0027 says the index can be rebuilt, so it can't be the source of truth.
  • One manifest per folder, like Picasa's .picasa.ini, means fewer files. But it isn't a standard, two writers can merge-conflict, and the metadata doesn't travel when a file is moved.

Mail and transactions already have their own conventions:

  • Maildir keeps flags in the filename: …:2,FS, where D is draft, F flagged, P passed, R replied, S seen and T trashed (Python mailbox docs on the maildir spec, cr.yp.to/proto/maildir.html). Dovecot maps keywords to the lowercase letters a–z through a dovecot-keywords file (Dovecot). Setting a flag renames the file but never touches its bytes, so hashing is safe. IMAP's convention for archiving is to move the message to the \Archive special-use folder (RFC 6154). notmuch keeps richer tags in its own database and syncs only the standard flags (muchsync man).
  • Beancount puts key: value metadata on any directive (keys are lowercase), plus #tags and ^links (Beancount syntax). Ledger uses ; :tag: and ; Key: value comments (ledger manual). OFX is a bank export with no user flags; FITID is only for dedupe (GnuCash list). The ledger file is text we own, so flags go inside it, the same way frontmatter goes in a note.

Performance at 100k files:

  • A sidecar for every file doubles the inode count. That's 100k extra files, about 400 MB at ext4's 4 KB per small file, and the watcher and rescans get twice the work.
  • Rescans are dominated by stat order. Sorting by inode is 4–10× faster on ext4 (Ts'o on lkml, benchmark).
  • Lazy sidecars are written only when someone sets a field. Most files never get one, so the cost scales with what people annotate, not with the size of the library. index.db mirrors the sidecars so lists and search never open XML. A rescan re-parses a sidecar only when its mtime or size changed.

2. Comparison

Standard Other tools read it Readable Original untouched Travels when moved outside the app Cost at 100k
Embedded XMP ✅ the spec's first choice ✅ everything meh ❌ breaks hash and dedupe ✅ none
XMP sidecar IMG.jpg.xmp ✅ spec plus open tools ✅ darktable, digiKam, Immich, PhotoPrism, exiftool ok (XML) ✅ ✅ if moved together lazy: small
XMP sidecar IMG.xmp ✅ Adobe and C1 style ✅ Lightroom, C1, and read by everyone ok ✅ ✅ lazy: small; collides on IMG.jpg/IMG.heic
.md sidecar IMG.jpg.md ❌ plugins only ❌ shows as a note elsewhere ✅ best ✅ ✅ lazy: small
.md plus XMP half ✅ ✅ ✅ ✅ 2 files per item; drift
xattrs freedesktop convention ❌ mostly ❌ invisible ✅ ❌ lost on copies and sync none
index.db only ❌ ❌ ❌ ✅ ❌ none; not durable (0027)
maildir flags (mail) ✅ ✅ every maildir client ✅ ✅ (rename only) ✅ none
inline beancount metadata (transactions) ✅ ✅ beancount, fava ✅ n/a, we own the text ✅ none

One rule: metadata goes where that format's own convention puts it, and the original's bytes are never touched.

  1. Notes use frontmatter, as now (archived: true, hidden: true).
  2. Photos, videos, PDFs and every other file get an XMP sidecar named <full name>.xmp (IMG_1234.jpg.xmp, Tax 2025.pdf.xmp).
    • On import we read IMG_1234.jpg.xmp, then IMG_1234.xmp, then embedded metadata, all read-only.
    • Standard fields hold the standard things:
      • tags → dc:subject + lr:hierarchicalSubject;
      • caption → dc:description;
      • place → exif:GPS*, plus photoshop:City/photoshop:Country for the name;
      • rating → xmp:Rating.
    • Our own fields go under a calternal: namespace (the URI is a placeholder until we pick a domain): calternal:archived, calternal:hidden, and calternal:id so we can re-pair a file moved outside the app. Reject flags are not used for these, because a reject means "bad shot", not "keep but put away".
    • Writes merge and keep every field we don't own. We write pretty-printed XML with one property per line, so a person can still read it.
    • Sidecars are lazy. We create one only when a field is set, and delete it when we created it and nothing of ours or anyone else's is left in it.
    • A sidecar moves, renames and goes to Trash with its file in the same journaled operation as 0023.
    • Dedupe ignores sidecars, because metadata belongs to a path, not to the content (two copies may carry different captions).
    • Sidecars never appear as items anywhere in the UI.
  3. Anything longer than a caption about a file (thoughts, a write-up) is an ordinary note that links to the file. That gives kayg markdown readability without inventing a .md sidecar format.
  4. Mail uses maildir:
    • Archive = move to the Archive folder (IMAP \Archive);
    • Hide = a maildir keyword, $Hidden, through the Dovecot-style keyword letter;
    • tags and captions on mail wait until mail exists; they need their own grill.
  5. Transactions live in a beancount file we own, so they carry inline metadata, archived: TRUE and hidden: TRUE, with tags as #tag.
  6. index.db mirrors all of this for speed and can always be rebuilt from the files.

Example sidecar:

<?xml version="1.0" encoding="UTF-8"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/">
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:calternal="https://kayg.org/ns/calternal/1.0/">
   <dc:description><rdf:Alt><rdf:li xml:lang="x-default">Sunset at Varkala</rdf:li></rdf:Alt></dc:description>
   <dc:subject><rdf:Bag><rdf:li>beach</rdf:li><rdf:li>kerala</rdf:li></rdf:Bag></dc:subject>
   <calternal:archived>True</calternal:archived>
  </rdf:Description>
 </rdf:RDF>
</x:xmpmeta>

4. Grill

X1. What format do photos and videos use for their metadata?
Recommended: an XMP sidecar. Why: it's the standard, and Immich, digiKam, darktable and Lightroom pick up our tags, captions and places for free.

X2. Do PDFs and other files use XMP too, or .md?
Recommended: XMP too, so there's one rule for every file. Why: XMP is format-neutral and is already PDF's own metadata format, while x.pdf.md would show up as a stray note in every markdown app.

X3. How do we name the sidecar?
Recommended: write IMG_1234.jpg.xmp; read that first, then IMG_1234.xmp. Why: the full name can't collide when IMG.jpg and IMG.heic sit side by side, and the open tools prefer it. Reading the short form still imports Lightroom and Capture One work.

X4. Where do Archive and Hide live inside the XMP?
Recommended: in our own namespace as calternal:archived and calternal:hidden, never in a reject or pick flag. Why: no standard field exists, and reject means "bad shot, delete me", the opposite of Archive's "keep but put away".

X5. Do captions, tags and places use the standard fields?
Recommended: yes.

  • dc:description for captions;
  • dc:subject and lr:hierarchicalSubject for tags;
  • exif:GPS* plus photoshop:City/photoshop:Country for places.

Why: that's what other tools read, and it's exactly the set Immich round-trips.

X6. When do we create a sidecar, and when do we delete it?
Recommended: create one lazily, on the first field that's set. Delete it when it's empty and we created it. It moves, renames and goes to Trash with its file. Why: at 100k files the cost follows what people annotate, and a file never loses its metadata.

X7. Where do longer thoughts about a file go?
Recommended: in a normal note that links to the file. There is no .md sidecar. Why: you get markdown readability with nothing new to invent, and the note shows up in search, links and daily notes like any other.

X8. Another tool rewrites a sidecar and drops our fields. Who wins?
Recommended: the file on disk wins. Our writes always merge and keep everyone else's fields. Why: file over app. The index can always be rebuilt, so it can never overrule the file.

X9. How do Archive and Hide work for mail?
Recommended: Archive moves the message to the Archive folder (IMAP \Archive). Hide sets a $Hidden maildir keyword. Why: every mail client already understands both, and the message bytes never change.

X10. How do Archive and Hide work for transactions?
Recommended: inline beancount metadata, archived: TRUE and hidden: TRUE, with #tags for tags. Why: the ledger is text we own, so the flags sit inside it, exactly like frontmatter in a note.

## Research: where Archive, Hide, captions, places and tags live for things that aren't notes Reference products are named only in these notes, never in the UI. ### 1. What we found **XMP sidecars are the standard, and the spec says how to name them, though only loosely.** - Adobe's XMP spec, Part 3, prefers *embedding*. It allows a separate file when embedding is "not appropriate or possible". That file should be a complete XML document with a `.xmp` extension, and readers should "look in the same directory for a file with the same name as the main document but with an .xmp extension. (This is called a sidecar XMP file.)" ([XMP Part 3, 2020, "External storage of metadata"](https://dl.photoprism.app/pdf/specifications/20120101-Adobe_XMP_Specification_Part_3.pdf); [Adobe XMP specs](https://developer.adobe.com/xmp/docs/xmp-specifications/)). The spec never settles whether "the same name" includes the original extension ([pixls.us thread](https://discuss.pixls.us/t/linux-applications-and-their-non-standard-xmp-sidecar-naming-convention/2688)). - **Naming in practice:** | Tool | Writes | Reads | |---|---|---| | Lightroom Classic | `IMG.xmp`, and only for proprietary raw files. JPEG, TIFF, DNG and HEIC are *modified in place* ([Adobe community](https://community.adobe.com/t5/lightroom-classic-discussions/dng-and-xmp/m-p/13586421/highlight/true), [jkost](https://jkost.com/blog/?p=22884)) | `IMG.xmp` | | Capture One | `IMG.xmp`, shared by `IMG.NEF` and `IMG.jpg` ([C1 support](https://support.captureone.com/hc/en-us/articles/30110560619165-Pairing-RAW-and-JPG-files-in-Capture-One)) | `IMG.xmp` | | darktable | `IMG.jpg.xmp` (and `IMG_01.jpg.xmp` for duplicates) | both. It reads `IMG.xmp` but never writes to it ([darktable manual](https://docs.darktable.org/usermanual/5.6/en/overview/sidecar-files/sidecar-import/)) | | digiKam | `IMG.jpg.xmp` by default. A "compatible with commercial programs" option switches it to `IMG.xmp` ([digiKam docs](https://docs.digikam.org/en/setup_application/metadata_settings.html)) | the form it's set to | | Immich | `IMG.jpg.xmp`; writes *merge* into the existing file | `IMG.jpg.xmp` first, then `IMG.xmp` ([Immich docs](https://docs.immich.app/features/xmp-sidecars)) | | PhotoPrism | no XMP writes. It keeps its own YAML sidecars | both forms ([PhotoPrism XMP](https://docs.photoprism.app/developer-guide/metadata/xmp/)) | | Apple Photos | `IMG.xmp`, through "Export IPTC as XMP" ([Apple](https://support.apple.com/en-kz/guide/photos/pht6e157c5f/3.0/mac)) | — | | exiftool | whatever you pass; the usual form is `%d%f.xmp` = `IMG.xmp` ([exiftool metafiles](https://exiftool.org/metafiles.html)) | any | `IMG.xmp` collides when `IMG.jpg` and `IMG.heic` sit side by side ([KDE bug 264007](https://bugs.kde.org/show_bug.cgi?id=264007)). `IMG.jpg.xmp` can't collide, and the newer open tools prefer it. - **Standard fields that map to ours:** tags → `dc:subject`, plus `lr:hierarchicalSubject` and `digiKam:TagsList` for nested tags. Caption → `dc:description`. Place → `exif:GPSLatitude`/`exif:GPSLongitude`. Rating → `xmp:Rating` (Immich reads and writes exactly this set). `xmp:Label` is free text, and the apps disagree on its values ([XnView forum quoting the spec](https://newsgroup.xnview.com/viewtopic.php?p=135149), [Adobe community](https://community.adobe.com/t5/bridge-discussions/labels-in-br-cc-2018-different-from-cs5-lr-classic-7-2/m-p/9668349/highlight/true)). - **No standard field means "archived" or "hidden".** The nearest are all *reject* or *cull* flags, which mean "bad shot, probably delete": - Bridge: `xmp:Rating = -1` ([Adobe community](https://community.adobe.com/t5/bridge-discussions/please-add-pick-flag-support-in-bridge/td-p/13104626)); - Lightroom Classic 13.2 and later: `xmpDM:pick = -1/0/1`, reported but not documented by Adobe ([exiftool forum](https://exiftool.org/forum/index.php?msg=85488)); - digiKam: `digiKam:PickLabel` 0–3, where 1 = rejected ([exiv2](https://exiv2.org/tags-xmp-digiKam.html)). Immich has a real `visibility`: `timeline | archive | hidden | locked` ([Immich CLI](https://docs.immich.app/features/command-line-interface)). It lives only in Immich's database and is *not* written to XMP. PhotoPrism's `private` and `deleted` live in its own YAML ([PhotoPrism backups](https://docs.photoprism.app/user-guide/backups/export/)). Every tool that has the concept keeps it private, so we need our own namespace. - **Round trips.** Immich merges and keeps fields it doesn't know. exiftool reads unknown namespaces but only *writes* namespaces it has been told about, and bulk copies have mangled private namespaces before ([exiftool XMP tags](https://exiftool.org/TagNames/XMP.html), [exiftool forum](https://exiftool.org/forum/index.php?msg=30900)). Expect another tool to rewrite the file now and then and to drop our fields on rare occasions. **Embedded XMP is ruled out.** Writing XMP into a JPEG, HEIC or PDF changes the bytes. That breaks the blake3 hash and the reflink dedupe ([0027](<docs/adr/0027-storage-files-and-dedupe.md>)), and it breaks "never rename or rewrite what you uploaded" ([0028](<docs/adr/0028-attachments-are-checked-before-they-are-trusted.md>)). Lightroom shows the side effects: rewritten files and changed file dates ([Adobe community](https://community.adobe.com/t5/lightroom-classic-discussions/enabling-quot-automatically-write-changes-to-xmp-quot-changes-orig-file-creation-modification-dates/m-p/12558644/highlight/true)). A saved PDF even keeps the old packets behind the new one (Part 3, PDF section). We still **read** embedded XMP, EXIF and IPTC on import, read-only. **Markdown sidecars exist only as Obsidian plugins.** These include [Attachment Sidecar](https://community.obsidian.md/plugins/attachment-sidecar), [Sidecars](https://www.obsidianstats.com/plugins/sidecars), [Media Sidecar Tools](https://community.obsidian.md/plugins/media-sidecar-tools) and [Local PDF Annotator](https://www.obsidianstats.com/plugins/local-pdf-annotator) (`x.pdf.annotations.md`). There's no spec. No photo tool reads them, and every markdown app (Obsidian, ours, editors) shows `IMG_1234.jpg.md` as a *note*, which clutters the user's notes. They are nicer to read. **Other options we looked at:** - **xattrs** (`user.xdg.tags`) leave the original's bytes alone. But copies, zips, sync tools and backups drop them, and nobody can see them. That fails file over app. - **Index-only** storage (our `index.db`) is fast, but [0027](<docs/adr/0027-storage-files-and-dedupe.md>) says the index can be rebuilt, so it can't be the source of truth. - **One manifest per folder**, like Picasa's `.picasa.ini`, means fewer files. But it isn't a standard, two writers can merge-conflict, and the metadata doesn't travel when a file is moved. **Mail and transactions already have their own conventions:** - **Maildir** keeps flags *in the filename*: `…:2,FS`, where D is draft, F flagged, P passed, R replied, S seen and T trashed ([Python mailbox docs on the maildir spec](https://edoras.sdsu.edu/doc/Python-Docs-2.5/lib/mailbox-maildirmessage.html), [cr.yp.to/proto/maildir.html](https://cr.yp.to/proto/maildir.html)). Dovecot maps keywords to the lowercase letters a–z through a `dovecot-keywords` file ([Dovecot](https://doc.dovecot.org/2.3/admin_manual/mailbox_formats/maildir/)). Setting a flag renames the file but never touches its bytes, so hashing is safe. IMAP's convention for archiving is to *move* the message to the `\Archive` special-use folder ([RFC 6154](https://www.rfc-editor.org/rfc/rfc6154)). notmuch keeps richer tags in its own database and syncs only the standard flags ([muchsync man](https://sources.debian.org/src/muchsync/7-1/muchsync.1.md)). - **Beancount** puts `key: value` metadata on any directive (keys are lowercase), plus `#tags` and `^links` ([Beancount syntax](https://beancount.github.io/docs/beancount_language_syntax/)). **Ledger** uses `; :tag:` and `; Key: value` comments ([ledger manual](https://ledger-cli.org/doc/ledger3.html)). **OFX** is a bank export with no user flags; `FITID` is only for dedupe ([GnuCash list](https://lists.gnucash.org/pipermail/gnucash-user/2010-August/035994.html)). The ledger file is text we own, so flags go **inside** it, the same way frontmatter goes in a note. **Performance at 100k files:** - A sidecar for *every* file doubles the inode count. That's 100k extra files, about 400 MB at ext4's 4 KB per small file, and the watcher and rescans get twice the work. - Rescans are dominated by `stat` order. Sorting by inode is 4–10× faster on ext4 ([Ts'o on lkml](https://lkml.iu.edu/hypermail/linux/kernel/1203.0/00223.html), [benchmark](https://lars.ingebrigtsen.no/?p=952)). - **Lazy sidecars** are written only when someone sets a field. Most files never get one, so the cost scales with what people annotate, not with the size of the library. `index.db` mirrors the sidecars so lists and search never open XML. A rescan re-parses a sidecar only when its mtime or size changed. ### 2. Comparison | | Standard | Other tools read it | Readable | Original untouched | Travels when moved outside the app | Cost at 100k | |---|---|---|---|---|---|---| | Embedded XMP | ✅ the spec's first choice | ✅ everything | meh | ❌ breaks hash and dedupe | ✅ | none | | **XMP sidecar `IMG.jpg.xmp`** | ✅ spec plus open tools | ✅ darktable, digiKam, Immich, PhotoPrism, exiftool | ok (XML) | ✅ | ✅ if moved together | lazy: small | | XMP sidecar `IMG.xmp` | ✅ Adobe and C1 style | ✅ Lightroom, C1, and read by everyone | ok | ✅ | ✅ | lazy: small; collides on `IMG.jpg`/`IMG.heic` | | `.md` sidecar `IMG.jpg.md` | ❌ plugins only | ❌ shows as a note elsewhere | ✅ best | ✅ | ✅ | lazy: small | | `.md` plus XMP | half | ✅ | ✅ | ✅ | ✅ | 2 files per item; drift | | xattrs | freedesktop convention | ❌ mostly | ❌ invisible | ✅ | ❌ lost on copies and sync | none | | `index.db` only | ❌ | ❌ | ❌ | ✅ | ❌ | none; not durable (0027) | | maildir flags (mail) | ✅ | ✅ every maildir client | ✅ | ✅ (rename only) | ✅ | none | | inline beancount metadata (transactions) | ✅ | ✅ beancount, fava | ✅ | n/a, we own the text | ✅ | none | ### 3. Recommended design **One rule: metadata goes where that format's own convention puts it, and the original's bytes are never touched.** 1. **Notes** use frontmatter, as now (`archived: true`, `hidden: true`). 2. **Photos, videos, PDFs and every other file** get an **XMP sidecar named `<full name>.xmp`** (`IMG_1234.jpg.xmp`, `Tax 2025.pdf.xmp`). - On import we read `IMG_1234.jpg.xmp`, then `IMG_1234.xmp`, then embedded metadata, all read-only. - Standard fields hold the standard things: - tags → `dc:subject` + `lr:hierarchicalSubject`; - caption → `dc:description`; - place → `exif:GPS*`, plus `photoshop:City`/`photoshop:Country` for the name; - rating → `xmp:Rating`. - Our own fields go under a **`calternal:` namespace** (the URI is a placeholder until we pick a domain): `calternal:archived`, `calternal:hidden`, and `calternal:id` so we can re-pair a file moved outside the app. Reject flags are **not** used for these, because a reject means "bad shot", not "keep but put away". - Writes **merge** and keep every field we don't own. We write pretty-printed XML with one property per line, so a person can still read it. - Sidecars are **lazy**. We create one only when a field is set, and delete it when we created it and nothing of ours or anyone else's is left in it. - A sidecar **moves, renames and goes to Trash with its file** in the same journaled operation as [0023](<docs/adr/0023-notes-are-flat-files-with-stable-ids.md>). - Dedupe ignores sidecars, because metadata belongs to a *path*, not to the content (two copies may carry different captions). - Sidecars never appear as items anywhere in the UI. 3. **Anything longer than a caption** about a file (thoughts, a write-up) is an ordinary **note that links to the file**. That gives kayg markdown readability without inventing a `.md` sidecar format. 4. **Mail** uses maildir: - **Archive** = move to the `Archive` folder (IMAP `\Archive`); - **Hide** = a maildir keyword, `$Hidden`, through the Dovecot-style keyword letter; - tags and captions on mail wait until mail exists; they need their own grill. 5. **Transactions** live in a beancount file we own, so they carry inline metadata, `archived: TRUE` and `hidden: TRUE`, with tags as `#tag`. 6. **`index.db`** mirrors all of this for speed and can always be rebuilt from the files. Example sidecar: ```xml <?xml version="1.0" encoding="UTF-8"?> <x:xmpmeta xmlns:x="adobe:ns:meta/"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:calternal="https://kayg.org/ns/calternal/1.0/"> <dc:description><rdf:Alt><rdf:li xml:lang="x-default">Sunset at Varkala</rdf:li></rdf:Alt></dc:description> <dc:subject><rdf:Bag><rdf:li>beach</rdf:li><rdf:li>kerala</rdf:li></rdf:Bag></dc:subject> <calternal:archived>True</calternal:archived> </rdf:Description> </rdf:RDF> </x:xmpmeta> ``` ### 4. Grill **X1. What format do photos and videos use for their metadata?** **Recommended: an XMP sidecar.** Why: it's the standard, and Immich, digiKam, darktable and Lightroom pick up our tags, captions and places for free. **X2. Do PDFs and other files use XMP too, or `.md`?** **Recommended: XMP too, so there's one rule for every file.** Why: XMP is format-neutral and is already PDF's own metadata format, while `x.pdf.md` would show up as a stray note in every markdown app. **X3. How do we name the sidecar?** **Recommended: write `IMG_1234.jpg.xmp`; read that first, then `IMG_1234.xmp`.** Why: the full name can't collide when `IMG.jpg` and `IMG.heic` sit side by side, and the open tools prefer it. Reading the short form still imports Lightroom and Capture One work. **X4. Where do Archive and Hide live inside the XMP?** **Recommended: in our own namespace as `calternal:archived` and `calternal:hidden`, never in a reject or pick flag.** Why: no standard field exists, and reject means "bad shot, delete me", the opposite of Archive's "keep but put away". **X5. Do captions, tags and places use the standard fields?** **Recommended: yes.** - `dc:description` for captions; - `dc:subject` and `lr:hierarchicalSubject` for tags; - `exif:GPS*` plus `photoshop:City`/`photoshop:Country` for places. Why: that's what other tools read, and it's exactly the set Immich round-trips. **X6. When do we create a sidecar, and when do we delete it?** **Recommended: create one lazily, on the first field that's set. Delete it when it's empty and we created it. It moves, renames and goes to Trash with its file.** Why: at 100k files the cost follows what people annotate, and a file never loses its metadata. **X7. Where do longer thoughts about a file go?** **Recommended: in a normal note that links to the file. There is no `.md` sidecar.** Why: you get markdown readability with nothing new to invent, and the note shows up in search, links and daily notes like any other. **X8. Another tool rewrites a sidecar and drops our fields. Who wins?** **Recommended: the file on disk wins. Our writes always merge and keep everyone else's fields.** Why: file over app. The index can always be rebuilt, so it can never overrule the file. **X9. How do Archive and Hide work for mail?** **Recommended: Archive moves the message to the `Archive` folder (IMAP `\Archive`). Hide sets a `$Hidden` maildir keyword.** Why: every mail client already understands both, and the message bytes never change. **X10. How do Archive and Hide work for transactions?** **Recommended: inline beancount metadata, `archived: TRUE` and `hidden: TRUE`, with `#tags` for tags.** Why: the ledger is text we own, so the flags sit inside it, exactly like frontmatter in a note.
Author
Owner

kayg's grill answers, 2026-10-15:

  • X1: agreed. kayg notes much of this was already decided in v0, so check the v0 archive's decisions when building.
  • X2, X3, X5, X6, X8, X10: agreed.
  • X4: kayg asked how it would work; explained in chat with an example XMP.
  • X7: yes. A note about a file must be interlinked in the UI so related things always surface: a file's preview and Info show the notes that link to it, and the note shows the file.
  • X9: agreed. kayg asked where the keyword lives; explained in chat (maildir filename flags plus the dovecot-keywords mapping, an IMAP keyword over the wire).
**kayg's grill answers, 2026-10-15:** - **X1:** agreed. kayg notes much of this was already decided in v0, so check the v0 archive's decisions when building. - **X2, X3, X5, X6, X8, X10:** agreed. - **X4:** kayg asked how it would work; explained in chat with an example XMP. - **X7:** yes. A note about a file must be interlinked in the UI so related things always surface: a file's preview and Info show the notes that link to it, and the note shows the file. - **X9:** agreed. kayg asked where the keyword lives; explained in chat (maildir filename flags plus the dovecot-keywords mapping, an IMAP keyword over the wire).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal#412
No description provided.