v0.6.404: branding and legal links (#1109), sharing e-mails (#1103), document thumbnails with PDFium (#1101) #1146

Merged
Cordy merged 144 commits from b4v07 into main 2026-11-09 04:14:02 +00:00
Owner

Batch 4 of v0.7 (b4v07).

  • #1109: admin Branding and legal tab (logo light/dark, icon, default accent, imprint/privacy links, credit toggle removable on every tier), SVG allow-list sanitiser, /branding/ and /auth/branding, branded sign-in page and 404, brand mail footer.
  • #1103: four bell kinds plus e-mails (shared with you, added to a space, files arrived, link ending), Daily/Weekly summaries, Send a link by e-mail with domain list and limits, Stop page with RFC 8058 one-click, Notifications page, admin policy box with an instance-wide switch for the optional e-mails, outbox priority.
  • #1101: PDFium (go-pdfium on wazero) server-side PDF thumbnails in a per-render sandbox, office embedded pictures, sealed caches, Previews admin tab; pdf.js removed; chart memory 512Mi with GOMEMLIMIT (chart 0.7.0).

Reviews: W1-W3 wave reviews, fix rounds fx1-fx3, whole-branch final review per feature with adversarial probes, final fix round fx4, release round fx5 (Nikola's decisions of 2026-11-09). Strings approved 2026-11-08/09. Local verification at 934cbd81: go build/vet/gofmt clean; internal/api and cmd/cairnd full; all touched packages; deploy, audit, webcheck, config; web suite 2288/2288; all 64 a11y files ok.

Batch 4 of v0.7 (b4v07). - #1109: admin Branding and legal tab (logo light/dark, icon, default accent, imprint/privacy links, credit toggle removable on every tier), SVG allow-list sanitiser, /branding/ and /auth/branding, branded sign-in page and 404, brand mail footer. - #1103: four bell kinds plus e-mails (shared with you, added to a space, files arrived, link ending), Daily/Weekly summaries, Send a link by e-mail with domain list and limits, Stop page with RFC 8058 one-click, Notifications page, admin policy box with an instance-wide switch for the optional e-mails, outbox priority. - #1101: PDFium (go-pdfium on wazero) server-side PDF thumbnails in a per-render sandbox, office embedded pictures, sealed caches, Previews admin tab; pdf.js removed; chart memory 512Mi with GOMEMLIMIT (chart 0.7.0). Reviews: W1-W3 wave reviews, fix rounds fx1-fx3, whole-branch final review per feature with adversarial probes, final fix round fx4, release round fx5 (Nikola's decisions of 2026-11-09). Strings approved 2026-11-08/09. Local verification at 934cbd81: go build/vet/gofmt clean; internal/api and cmd/cairnd full; all touched packages; deploy, audit, webcheck, config; web suite 2288/2288; all 64 a11y files ok.
Cordy added 134 commits 2026-11-09 01:09:10 +00:00
internal/preview gains Cache (CPV1 entries: header length, JSON header,
body; sealed with age to an in-memory X25519 identity on encrypted
instances, plain otherwise), bound to the file name, an in-memory path
index for Drop (path and path/..., never a sibling), LRU eviction to
MaxBytes, a 30-day Sweep, and VersionKey (backend path, item id,
length-prefixed fields). The converter keeps its PDFs in a Cache;
DecodeImage is split from caching. Call sites in internal/api and
cmd/cairnd updated minimally (the caches are sealed when
storage.encryption.enabled).
internal/preview/pdfium renders page 1 of a PDF with go-pdfium v1.21.4
(webassembly backend, wazero v1.12.0) under the decided sandbox rule:
fresh module instance per render (ReuseWorkers false, MaxTotal 1),
nothing mounted (non-nil empty FSConfig), output discarded, 128 MiB
linear memory, 10 s per render with close-on-context-done and Kill,
wazero's compiler only (an engine check at New turns PDF off instead of
falling back to the interpreter), lazy single-flight compile under its
own 120 s limit, a watchdog that retires a module stuck 5 s past its
deadline and stops PDF rendering at 2 stuck renders, idle close after
10 min and recycle after 500 renders. internal/preview gains the
sentinel errors and the PDFRenderer interface.

go.mod/go.sum: scratch/b7e/backlog/gap-v07/pdfium-gomod.diff applied;
the go tool then moved wazero to the direct block (imported directly).
No other version changed. Builds offline with the repo go.mod.

Memory (U2), linux/arm64 sandbox (4 CPU, 3.9 GB), measured in-process
with VmHWM (reset per step via clear_refs) and runtime.MemStats; no
cgroup limit could be applied (no write access to /sys/fs/cgroup, no
systemd user bus, no container runtime). Idle test process 9.7 MB RSS.
  compile + first small render: peak 335 MB (GOMEMLIMIT off),
    308 MB with GOMEMLIMIT=100MiB (live heap, the GC cannot lower it)
  compiled module resident after GC: 55 MB (+45 MB); after close 25 MB
  30 MB PDF (5 noise JPEGs), linear memory 127 MiB (the cap):
    peak 516-595 MB (GOMEMLIMIT off), 304 MB with GOMEMLIMIT=100MiB
  6000x4000 JPEG page: linear memory 51 MiB (PDFium decodes downscaled)
Verdict: growth over idle is above 150 MiB (about +300 MB for the compile
and for a render at the cap even with GOMEMLIMIT); inside a 256Mi limit
the first compile would be OOM-killed. amd64 not measured here.
Test binary (go test -c, linux/arm64): 19.5 MB vs 12.9 MB for
internal/preview (+6.7 MB).
T-S2: OpenCache at start touches only ^[0-9a-f]{32}<ext>$, its own
cpv-<digits><ext>.tmp files and v0.6.403's tmb-/conv-<digits> temp
files; a foreign report.pdf in the folder stays.
T-N1: a compound file under an OOXML name is password-protected only
when its directory holds EncryptionInfo and EncryptedPackage (bounded
directory walk, loops end it); anything else is unreadable.
preview.MemLimit: the lowest cgroup v2 memory.max / v1
memory.limit_in_bytes on the process's cgroup path, 0 when unlimited or
unknown (t5 reports it as memLimit).
T-S1: guardReader runs each Read/Seek of the source in a worker
goroutine and waits for the answer or for close; close sets an atomic
flag and never waits; bytes arriving after close are dropped (read into
the worker's buffer, copied into module memory only while open). The
guard is cut at the render deadline, so a render waiting on a stalled
source returns with ErrTimeLimit soon after the deadline and is not
counted as stuck (TestFirstPageStallingSourceFX1T).
T-N2: render and compile errors keep their first line (wasm errors
append the module's stack trace).
T-N3: comment at slot: one render at a time is also a confidentiality
rule (go-pdfium's process-wide reader table).
Addendum (refined): Config.CompileCacheDir enables wazero's compilation
cache in a pod-local folder; used only when it is a real folder owned by
the process user with no group/other write (every entry too), else WARN
"preview: pdf compile cache off" (reason relative, build-info, create,
not-a-directory, owner, permissions, clear) and compile in memory. A
marker (go-pdfium and wazero version + go.sum hash from
debug.ReadBuildInfo, GOOS/GOARCH) empties the folder on mismatch;
leftover *.tmp go. A compile error with the cache deletes the folder,
WARN "preview: pdf compile cache failed, compiling without it", retries
once without it (cache off for the process); only that failure marks
the renderer unavailable. One cache per compiled module, closed after
its pool, never while a render the watchdog gave up on runs on it.
INFO "preview: pdf renderer compiled" gains cache=on|off.

Measured (linux/arm64 sandbox, 4 CPU; amd64 not available here),
TestCompileCachePeakFX1T, three runs:
  cold compile + small render: 1324-1338 ms, peak VmHWM 352-360 MB
  warm compile from the cache + render: 44-47 ms, peak VmHWM 60-62 MB
  after close + GC: RSS 24 MB
  compiled module on disk: 22,336,237 bytes
The PDF renderer's compilation cache folder: absent = /tmp/cairn-pdfium
(the chart's /tmp emptyDir), "" = off, otherwise an absolute path (a
relative one refuses the load: it would follow the working directory,
which may be the data volume). PreviewConfig.PDFCompileCache() reads it;
t6 passes it to pdfium.Config.CompileCacheDir. Documented in
configuration-reference.md (key table, a paragraph, the local-paths
table).
preview.Service: cache first (a picture or a note answers without opening
the source), single flight per version key, PDF gate (1 + 8 waiting, 20 s)
and converter gate (1 + 2) with a 60 s converter backoff, notes for
password/unreadable/none and a 24 h thumb-timeout note, embedded office
pictures through DecodeImage (24 MP), the converter only with the switch
or for=pane, the source opened under a context cancelled when the render
step returns. audit.WithThumbnailRead notes via=thumbnail kind=<kind>.
GET /api/v1/thumb and /thumb/caps over the Service: scoped Stat first,
checks before the ETag, VersionKey(backend, item id, ...), no marks, no
Recents, SVG/HEIC/AVIF pass-through under the sandbox headers, no path in
any answer. /api/v1/preview/pdf keyed by the backend path and item id,
502 without the converter's text.
The optional notices (share-received, space-added, link-ending) go to a
per-process worker (1,024) that reads the prefs record fresh and queues
with Prio sharing; SendLink queues one link-sent record per address with
the key part sealed (link-key, aad the record id); PreviewLink renders
without queueing (meta CSP, data: logo, dummy b1/u1 tokens, #...);
SharingPass on the sender lease holder mails upload batches (Mailed with
the seen batch) and the daily and weekly summaries. Sharing messages:
From {sender} via {instance}, Reply-To the person, List-Unsubscribe on
optional kinds over https with the host punycoded, the brand logo as an
inline part; link-mail-failed bell for given-up link e-mails; audit Path
the sender for link-sent; HeldBack WARN every 10 minutes.
- cmd/cairnd/previews1101.go: wirePreviews1101 (converter, thumbnail
  cache sized by preview.thumbCacheMB / CAIRN_PREVIEW_THUMB_CACHE_MB,
  PDFium renderer with the S2.2 limits and the pod-local compile cache,
  Service, PreviewsAdmin probe/cache/PDF state, journal drops, hourly
  sweep); main.go calls it and stops it at shutdown
- internal/changes: Journal.Observe, called outside the lock
- internal/config: PreviewConfig.ThumbCacheMB; reference row
- internal/preview: Thumber removed; the renderer no longer logs the
  time limit (the Service logs it with the key)
E-B1: noticeMail and uploadBatch read the prefs record with Ensure, so
a queued mail's Stop link always finds the account by id.
E-S1: SenderName breaks every "=?"; mail.phrase Q-encodes any phrase
holding "=?".
E-N1: each sharing worker job runs under a 30 s context.
E-N2: no merge of this instance's in-memory mutes into bellMuted.
FR pubUnsubEndingBody: "l'un de vos liens" (approved 2026-11-08).
- Service.open wraps the source in an error recorder (first non-EOF
  error of Read, ReadAt or Seek); firstPage and makeOffice return that
  error and store nothing (no note, no picture of a partial read)
- one test PDFiumMayRun (switch on and renderer usable) at the four
  Service sites and the route's PDF and converter cases: thumb-off
- TestServiceSourceErrorNotStored1101, TestServiceConverterPDFOff1101,
  a converter row in TestThumbSwitchOffBeforeETag1101
Account settings › Notifications becomes its own rail entry after
Preferences (#account/notifications; the card leaves Preferences, its ids
kept): a Bell and an E-mail column, the Sharing group of the four kinds,
every other row bell only with a dash named Not sent by e-mail, How often
as a radio group with its legend, the zone and the address, the Turned off
from an e-mail line and the row highlighted from ?row=<kind>. Each switch
PUTs only what changed (muted for a bell, mailMuted for an e-mail switch,
every for How often; fx2 E-N2) and draws the answer, keeping the focus.

The bell draws share-received, space-added, link-uploads, link-ending and
link-mail-failed (frame 7) with their actions; the feed's dir is a folder
only when it is true. #loc:<path>?share opens the share pane after
resolving.

Plan b4v07 task e12; spec 12.3, 12.4; strings of A.1 after
notifPrefSpaceReqD.
Basic settings gains a third APG tab, Branding and legal (frames A1 to
A3): the instance name moved from General (counted in characters after
NFC, no maxlength), logo, dark logo and browser icon uploaded on choose
or drop, imprint and privacy addresses (read-only when pinned), the
default accent as a radiogroup, the credit switch, a live preview and
its own Save (the main settings form). A named image this instance
cannot resolve ({id, missing}) shows empty and its id goes back in the
PUT until removed (fx2 B-S1). The Overview gains the Imprint and privacy
row (A4); the watermark preview names the address without a name (A5).
Existing tests changed for the third tab and the A.1 strings.
Share pane: the line under the add row (shareNotifyHint, tied to Add),
the status of a grant and, for a group over 500 (the grant's notify),
the amber line with its size under the new row; the Members dialog's
line (memberNotifyHint), not for directory spaces. Both only with a
mail server.

Send by e-mail beside Copy link and on the creation result while
me.mail.sendLinks: one panel at a time under its row, To with chips
(comma, Enter, Tab, paste; Backspace; refused chips named and marked),
the message with its counter, the language, the password line, what
the e-mail holds, Preview on its own route in an iframe with an empty
sandbox, today's addresses left. Every refusal of the send route has
its key (incl. 503 state-unreadable and 403 not-your-share); a key
link without its key opens the #1140 panel.

Link editor: E-mail me when files arrive (on for Upload only, off for
both; disabled with its reason and a link to the settings while
link-uploads is muted or How often is Never), the end reminder line;
notifyUploads sent only when changed; errNotifyNeedsUpload.

links1140copy.test.js: the A.3 key scan skips the e11 block, which
plan-1103 places after linkMakeNewHint (inside the #1140 block).
S1 General's Save sends the name and branding as the server has them; a
Save re-bases only its own .bspane (plus fields outside the tabs), so the
other tab's unsaved edits stay counted. S2 Not set chip: --ink-2 text,
amber icon, contrast pair. S3 preview: dark surfaces use the dark logo
first. Webcheck: brlbl spans, file inputs aria-labelledby. N3 N4 N5 N6 N7.
B1: linkResultShow rebinds the result's Send by e-mail (mailSendResult(made));
Add another link and shareFormPrep reset it (mailSendResult(null)).
S3: Escape in the Preview dialog stops at the dialog (native cancel kept).
S4: {contact} from me.mail.replyName (absent = ""), else
branding.displayName, else the instance name; {instance} from
branding.displayName first.
S5: bellUploads1 for one file (new string, EN/DE/FR/IT for approval).
N1 iframe title set by id via t(); N2 the Copy link no-key panel closes
an open Send panel; N3 notification switch PUTs serialised, the body
made from the previous answer; N4 shareGroupKind dropped; N5 no
upload-mail checkbox before the prefs for accounts without e-mail.
B1: thumbFetch(url, signal, kind) makes a blob: URL only for a rendered
image/jpeg answer (thumbBlobOK, pure). SVG, HEIC and AVIF (and any other
type) are read to the end into the HTTP cache and shown from the route
URL, which answers attachment + sandbox CSP + nosniff, so opening the
picture in a tab of its own downloads it instead of running an SVG's
script in the app origin. Tiles and the pane own and revoke only blob
URLs. Route test: every pass-through type, asked as an image or by
navigation, carries the sandbox headers; revalidation is a 304.
S1: thumbCapsReset() after a 200 of pvaSave; the decode test runs once.
N1: thumbReady waits for the converter format list when tiles convert.
N2 hidden tile description; N3 span instead of div/pre in the hero
button; N4 closeDetails releases the hero; N5 SETTINGS_FORM_KEYS.previews
(settings742 t12: seven forms); N6 thumbGoneSeen forgets the fired view
when another view renders; N7 no literal U+2014 in thumbs1101.test.js.
web/test/a11y/thumbs1101.test.js: a grid with a rendered PDF page, an
SVG on its white plate (route URL, never an SVG blob), a photo with the
checkbox halo, reasons as tooltip and hidden description, type badges;
axe clean in light and dark. contrast.test.js: the badge 4.5:1 on its
fill and the checked box 3:1 on its halo over a white or black picture
in every theme and accent. The halo goes from 75% to 85% --surface: at
75% the checked box fell to 2.28 to 2.96 in 10 theme/accent pairs.
Merge branch 'b4v07-fx4t' into b4v07
Some checks failed
ci / test-and-build (pull_request) Failing after 1m58s
e1d040c89c
Cordy changed title from WIP: v0.6.404: branding and legal links (#1109), sharing e-mails (#1103), document thumbnails with PDFium (#1101) to v0.6.404: branding and legal links (#1109), sharing e-mails (#1103), document thumbnails with PDFium (#1101) 2026-11-09 03:57:46 +00:00
fx6t: compile cache marker by WASM sha256, no build-info dependency (#1101)
All checks were successful
ci / test-and-build (pull_request) Successful in 4m42s
aa330df7dc
CI's Go 1.26 test binary has no go-pdfium or wazero in its build
information, so the cache turned off (reason=build-info) and every
compile-cache test failed. Marker version 2 records the sha256 of the
WASM bytes compiled (Config.WASM, else go-pdfium's embedded module via
linkname), the go-pdfium and wazero path/version/sum lines ("<path>
unknown" when absent), GOOS/GOARCH and runtime.Version(). The build-info
source is injectable (Renderer.buildInfo).
Cordy merged commit 6a086e92f7 into main 2026-11-09 04:14:02 +00:00
Sign in to join this conversation.
No reviewers
No labels
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: Cordy/Cairn#1146
No description provided.