feat(media): a local library of uploads — media ls with names, media link; canonical grant encoding

The relay never knows names and a link is printed once, so a lost link
made an owned film unreachable. media put now appends each upload and its
grant to $XDG_CONFIG_HOME/shade/media-library.jsonl (0600, one JSON line
per change: concurrent uploads cannot lose entries, a torn line costs only
itself). media ls names uploads from it; media link <name|id> prints the
link again; media rm forgets it.

encodeGrant now writes meta in canonical (validateMeta) order, so one
grant is always one link; media.json vectors regenerated (album and
subtitle vectors only), Kotlin 82/0.

Verified: 82 TS tests (library: fold, find, 0600, torn line, 200
concurrent appends, stable encoding); CLI put → ls → link gives back the
identical link.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-10-18 22:08:22 +02:00
parent d784e47ab3
commit 01f8471fb5
8 changed files with 269 additions and 25 deletions

View File

@@ -62,6 +62,13 @@ The owner key (who may upload, delete and open live channels) is created the fir
time it is needed, under `$XDG_CONFIG_HOME/shade/media-owner.key` (mode 0600).
`shade media whoami` prints its public half.
The relay knows ids and sizes, never names, and a link is printed once. So `media put`
also writes every upload, with its grant, to `$XDG_CONFIG_HOME/shade/media-library.jsonl`
(mode 0600: a grant is a key). `shade media ls` names your uploads from it, and
`shade media link <name or id>` prints a link again. The file is append-only, one JSON
line per change, so two uploads at once cannot lose each other's entries. A grant
always encodes to the same link: its meta is written in canonical order.
### In the Shade container
```