Skip to content

perf(artwork): image links hold for three days and carry long cache headers - #5928

Open
darthShadow wants to merge 2 commits into
Silo-Server:mainfrom
darthShadow:perf/native-image-caching
Open

darthShadow wants to merge 2 commits into
Silo-Server:mainfrom
darthShadow:perf/native-image-caching

Conversation

@darthShadow

@darthShadow darthShadow commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none changed. Board read on 2026-12-06. The change reaches #193 S6, #194 A3 and #195 W5 (uploaded collection posters load and persist), #1155 C1 and #1156 C2 (chapter and marker images), #1210 C1 and C2 and #1211 C1 and C2 (chosen artwork persists and shows), and #1227 C1 and #1229 C1 (branding assets on versioned URLs). In each case the images still load; what changes is how long a link stays the same, the cache header, and how long a replaced copy is kept. These cases were not walked again by hand.

Other clients: Apple N/A (shows avatar_url and treats image URLs and the avatar ref as opaque); Android N/A (same; its avatar cache key, the URL without its query, now changes with each new upload, which is the intended result); Roku N/A (uses image URLs as given and reads no avatar ref); Web N/A (same as Apple; nothing new to configure)

Silo hands out image links that change far more often than the images do, and most image responses say nothing about how long to keep them. With signed S3 links, a catalog image gets a new URL at every UTC midnight, and avatars and other unversioned images get a new URL on every read. The stored objects carry no Cache-Control. So every app and browser that caches by URL downloads each visible image again at least once a day, and an install without a caching CDN serves every one of those downloads from its storage. Replaced collection images are deleted right after the change, so a client still holding the old link can no longer load it.

This change gives each kind of image one of two long cache headers and keeps a versioned image's link the same for three days on local and S3 storage, and on Cloudflare-token storage once its link lifetime is raised. Replaced images stay readable until every link handed out for them has expired. Objects stored before this change get the header through the signed link when the storage honors response-cache-control, which Silo checks for itself at start. On a lab pair of the base build and this change, both served the same four images at the first sample with the same storage traffic; an hour later, the base build's client asked for all four again (four 304s, four storage reads), and this change's client asked for none.

Approach

  • One owner for the values. internal/artworkkey holds them and the rules that pick them for a key: a 72-hour Window, a 6-hour Grace (the default of s3.metadata_presign_expiry), a 15-minute Short bucket, and two headers. Month, public, max-age=2592000, immutable, goes on catalog art (including local/ and nfo/) and new admin collection uploads. Week, private, max-age=604800, immutable, goes on versioned avatars, chapter and marker thumbnails, seek-preview sheets and new personal collection uploads. Every other key gets no long header, including a malformed key in a private namespace, which never falls through to Month. The signers, the S3 adapter, the local artwork route and the three routes that sent one year all read these values.
  • Links. A key whose bytes never change at that name keeps one URL for the Window on every replica and keeps working for the Grace after it: on the local signer, on SigV4 (X-Amz-Expires 280,800 s), and on Cloudflare token links once the token lifetime allows it (item 5 below). Library posters are rewritten in place, so they still get a fresh URL on every S3 and token read. Other unversioned keys stay stable within a 15-minute bucket.
  • Headers. The S3 adapter writes the header as object metadata on every upload path (Put, PutStream, PutStreamParts, CreateExclusive). Re-caching still skips identical bytes, so existing objects keep none. The local artwork route sends the header on 200 and 304.
  • Signed response override. On an artwork store that signs with SigV4, each replica checks at start, in the background, whether the storage answers response-cache-control with exactly the signed value: it writes one fixture and fetches a plain link and a Month and a Week override link. The first definitive result for the store's settings is recorded in the hidden row artwork.response_override_check, and every replica adopts it. After a pass, presigned artwork links carry the parameter, which gives the header to objects stored before this change. A failed or inconclusive check leaves it off; an inconclusive one retries hourly. There is no setting and no admin control.
  • Stable keys. Collection uploads now use the encoded-bytes revision that catalog art already uses (64 hex), moved to imageutil; existing catalog keys do not change. A new avatar upload is stored as original.<64 hex>.webp and w256.<64 hex>.webp, and the profile then points at the new original. Nothing is overwritten.
  • Retention. Replaced art waits 78 hours (the Window plus the default Grace) in the existing revision collector. Two new triggers queue a collection's displaced poster or backdrop in the transaction that replaces it, and only when it lies in that collection's own image directory; the handler's post-commit cleanup is gone. An upload reserves its exact object keys with the collector before writing, so an upload that dies before a row names it is collected later.
  • Grace default. s3.metadata_presign_expiry defaults to 6 h instead of 4 h, and a migration deletes a stored value of exactly 4h so existing installs follow the default.
  • No /api/v2 operation, field or schema changes (verify-apiv2-contract reports none). No new translation keys. Jellyfin library-poster redirects go through the same resolver, so the signing rules reach them; their response headers are left for a follow-up.

Changes outside the feature code:

  • Two migrations: 20261205194500_artwork_cache_windows.sql (the two 78-hour intervals and the collection triggers) and 20261205194600_artwork_cache_windows_drop_4h_grace.sql (the 4h row). They are separate because scripts/ci/migrationcheck refuses a file that holds both a $$ body and the text server_settings.
  • scripts/ci/db-contracts.txt gains 15 Postgres tests. TestDeleteAdminCollectionKeepsCollageForCollectorDB replaces TestDeleteAdminCollectionArtworkClearsReferenceWhenVariantDeleteFailsDB, since clearing collection artwork no longer deletes variants in the request.
  • //nolint:forbidigo on time.Sleep calls inside testing/synctest bubbles, where sleeping only advances the fake clock, and one //nolint:misspell on the test case name a_honours.

Other pull requests:

Needs maintainer approval

Item 1 adds a refusal. Items 2 to 10 answer requests differently or keep or delete data on a different schedule. Items 11 and 12 are questions.

  1. A collection upload is refused while its path is held. Uploading the same image bytes while the collector is deleting their old copy, or while another request is reserving the same path, answers 503 dependency_unavailable with Retry-After: 30 (the handler code is unavailable, the same answer as the existing busy-decoder 503). A collection upload with no reservation service wired fails with an internal error instead of writing unreserved objects; production wires one whenever there is a database. A database error during the reservation answers 500. The reservation waits at most 50 ms on another transaction: when its read finds no row for the path but another request is inserting one, or a collector worker takes the row between the read and the write, it answers the same 503 after 50 ms. So if the first upload's insert takes longer than 50 ms to commit, for example under synchronous replication, a concurrent upload of the same bytes gets the 503 where it used to wait and succeed. A collage build that finds its path held retries after the existing 10-minute collage retry. Why: without the reservation the collector can delete the image the collection now shows, and nothing would collect the objects of an upload that fails before its row is saved; the 50 ms bound keeps an upload from holding its database connection while it waits on another request's transaction. To approve: the 503, the 50 ms bound, and the refusal with no reservation service.
  2. Long cache headers on new images. S3 objects and the local route now send Month on catalog art and new admin collection uploads, and Week on versioned avatars, chapter and marker thumbnails, seek-preview sheets and new personal collection uploads. Before, S3 objects carried no header, and the local route sent private, max-age=<remaining>, immutable for revisioned keys and private, no-cache for the rest. Month is public, so any shared cache in front of Silo, including a CDN on an "Anyone with the link" bucket, may keep a catalog image for up to 30 days and serve it to anyone holding the URL, even after the link expires. Week responses never go to a shared cache. Why: clients and browsers reuse the bytes without asking again, which also helps installs with no CDN. To approve: both values, and public on catalog art and admin collection uploads.
  3. Three routes go from one year to the shared values. Offline-download artwork answers Week, private, max-age=604800, immutable, instead of one year. Branding assets on an exact content-version request and overlay images answer Month, public, max-age=2592000, immutable, instead of one year. Why: one set of values for every native image route. To approve: the shorter lifetimes.
  4. Signed link lifetimes and reuse. On local and SigV4 links, a versioned key keeps one URL for 72 hours instead of a UTC day, valid until 6 hours after its Window ends; a copied link works for at most 3 days 6 hours. Token links follow item 5. A versioned avatar on a private bucket goes from a fresh 15-minute link per read to the same 72-hour link. On SigV4 and token links, other unversioned keys (legacy avatars and catalog files, legacy chapter keys) get one URL per 15 minutes instead of a fresh URL per read. Library posters stay fresh per read. Why: a stable URL is what lets a client that caches by URL reuse the image. To approve: the longer life of a copied link, avatars included.
  5. The Cloudflare token window rule changes. The window is now the larger of "token lifetime minus Grace" and a quarter of the lifetime, capped at the Window. At the default 3-hour lifetime it stays 45 minutes. A lifetime under 8 hours leaves a link with less than the 6-hour Grace, and above 8 hours a link has at least 6 hours left rather than three quarters of the lifetime. To keep one URL for three days, an operator raises the Cloudflare rule's lifetime and then s3.public_token_ttl to 280,800 s; the user-manual issue covers the order. Why: with today's quarter rule a token link can never stay the same for the Window. To approve: the rule.
  6. The Grace default and the stored 4h row. s3.metadata_presign_expiry defaults to 6 h instead of 4 h, and the migration deletes a stored row whose value is exactly 4h, including one an admin chose on purpose: the two cannot be told apart. The longer default also reaches admin item-poster links, the local signer's default lifetime, presigned unversioned keys and the Jellyfin image cache bound, so each of those lasts up to 2 hours longer. With the setting at or below 15 minutes, a legacy private avatar link on S3 can live up to 15 minutes past its 15-minute lifetime. Why: the retention below assumes the default Grace, and an install that kept reading its seeded 4h row would never move. To approve: the new default and the row deletion.
  7. Replaced images are kept longer. Replaced catalog art and retired collages wait 78 hours instead of 24 hours. Replaced and cleared collection uploads in the collection's own image directory wait 78 hours instead of being deleted right after the change. A deleted collection's collages stay up to 78 hours, removed by the existing collector, instead of being deleted with the collection; its uploaded poster and backdrop are still deleted at once. A collage build or upload that dies before a row names it leaves its objects for 78 hours. A backup restore that changes a collection's poster or backdrop now queues the displaced image in the collection's own directory. Displaced chapter thumbnails and seek-preview sheets already follow the deadline of the last link issued for them, which is now up to 78 hours instead of about 4 hours and 28 hours. Revisions displaced before the upgrade keep their 24-hour deadline. The retention covers the default Grace only: a Grace above 6 hours, or a token lifetime above 3 days 6 hours, issues links that outlive it. Why: a link handed out before a replacement keeps working until it expires. To approve: the extra storage held for up to 78 hours.
  8. Avatars are versioned and old versions are kept. New uploads store the ref upload:profile-avatars/<user>/<profile>/original.<64 hex>.webp instead of .../original.webp. The ref is documented as opaque, but backup consumers and third-party clients that read it see the new shape. Replaced versions stay until the avatar is cleared, switched to a preset, or the profile is deleted, with no age or count limit. Each version is an original of up to 3840 px square (from an upload of up to 10 MiB) plus a 256 px variant, and any signed-in caller on the account can upload. Profile delete now also removes uploaded avatar files of a profile that ended on a preset. Clear, preset switch and profile delete run their cleanup with a 30-second deadline that a client disconnect does not cancel. Why: a new upload never overwrites the file a client is loading, and deleting the previous version at upload could remove the same bytes uploaded again concurrently. To approve: the ref shape and the unbounded version count.
  9. Presigned artwork links gain response-cache-control after a passed check. The parameter goes on every eligible key's link, so it repeats the stored header on new objects and replaces any header an operator set on Silo's artwork objects. Why: it gives the header to objects already in storage without rewriting them, and the link signer knows only the key, so telling old objects from new would take a storage call per link on the catalog read path. To approve: the parameter on every eligible link.
  10. The check's result is permanent until an operator clears it. A recorded pass or fail stays until someone deletes the artwork.response_override_check row and restarts every replica that serves direct artwork links; nothing re-checks on a timer. Only a conclusive answer is recorded: a 408, a 429, a 5xx, or a 4xx whose S3 error code the S3 client lists as a rate limit (such as Wasabi's 403 RequestRateLimitExceeded) records nothing, and the check runs again an hour later. The check reads up to 4 KiB of an answer to find that code, so a code past 4 KiB counts as a refusal. If the storage later starts refusing the parameter under the same settings, a stale pass breaks cold reads of every direct artwork link until that recovery, and links already handed out keep failing until they expire, up to 3 days 6 hours. A stale fail only keeps the gain off. A check costs up to 4 storage requests per settings change, plus one row read an hour while inconclusive, and a process killed mid-check can leave its fixture under .silo-artwork-override-check/ (storage moves skip that prefix). Why: a timed re-check would write a fixture on every interval, and replicas must agree to sign the same links. To approve: the permanent record and its manual recovery.
  11. Question: rewrite existing objects' metadata once? This change sets headers on new uploads only. Objects stored before it get the header through the override where the storage honors it, and keep none on token, public and override-refusing storage until they are written again. A one-time job could rewrite their metadata in place. I left it out; do you want it?
  12. Question: refuse s3.metadata_presign_expiry above 7 days? A SigV4 link cannot be valid longer than 7 days, and the admin settings accept any positive duration. Above 96 hours the Window already shortens by design. With this change a Grace above 7 days also breaks private avatar links: at 169 h the avatar link asks for X-Amz-Expires 608,400, over the 604,800 limit. Should the setting refuse such values?

Validation

  • Tests: unit tests check the class and URL window of each producer's real key shapes, one URL per Window on two resolver instances for the local, SigV4 and token signers (expiry at the Window end plus Grace; token windows at 10,800, 21,600, 21,601, 28,800 and 280,800 s), the header on each S3 write path against a recording httptest S3, the local route's headers on 200 and 304, and the moved revision function against a golden value. Postgres tests check the 78-hour queueing for displaced catalog art, replaced and cleared collection uploads and deleted collages, including concurrent replacements, a borrowed path left alone, a re-upload kept by the collector, an uncommitted upload collected, and the held reservation, including behind another request's uncommitted insert of the same path. Avatar tests cover version sequences, cleanup on clear and profile delete, and the display key. The override check runs against nine storage behaviors (honors both values, ignores, refuses with 400, adds its own header, rewrites only the Week value, stalls, answers 503, redirects, rate-limits with a 403), with publication through the key-locked settings update on Postgres and the hourly retry under a fake clock.
  • Red: the change was built in three parts, and each part's tests ran before its code. Part 1 (classifier, signers, headers, routes; on base cdf344f9d): the classifier test failed to compile on the names it adds, and the signer, header, route and default tests failed on their assertions. Part 2 (revisions, retention, avatars; on part 1): 19 test cases failed on their assertions, and the revision and reservation tests failed to compile. Part 3 (the override check; on part 2) only failed to compile, so its red evidence is a mutation: with the header comparison changed to accept any value, the "ignores" case fails and the "honors" case still passes. A second mutation, the collection triggers calling the generic displacement function, fails the borrowed-path test in all three subcases. Each fix from review had a red run first: an admin upload to a missing collection wrote objects without looking the collection up, the reservation waited for the collector's storage delete and for another transaction's row, a losing replica logged its own reason as published, a canceled clear left four avatar objects, and the check's failure log line had no reason. The fixes from CodeRabbit's review each had a red run on the first commit's (f40f27a0c) code: the new override case, a 403 with RequestRateLimitExceeded, recorded fail ("a provider throttle must be inconclusive"); the new reservation test waited 0.55 s against its 500 ms bound for another transaction's uncommitted insert; and with pool_max_conns=2 in the database URL, the concurrent poster replacement test as it stood hung until the 90 s test timeout. With the fix, the first two pass, and the capped-pool run fails both subtests at 30 s on their deadline instead of hanging; on the normal database URL the test passes.
  • Green: all pass.
  • Real path, on <lab-host> in disposable containers with MinIO RELEASE.2026-08-04T00-00-00Z, the base build first and this change upgraded over the same Postgres and buckets. The run's steps, as its log names them: R0 built both binaries and started the stores. R1 seeded three movies by a scan and, on the base build, uploaded a catalog poster and a collection poster (stored with no header). R2 uploaded a catalog poster on this change: the object and its link both answer public, max-age=2592000, immutable. R3: the check passed on MinIO and recorded one entry; the base-era object's link carries response-cache-control and answers the Month header; a second replica read the recorded entry, ran no check (no fixture write) and minted a byte-identical link. R4: a library poster replaced with a same-format file shows the new bytes on the next read, 1.2 s later. R5: after a collection poster replacement, the old link still loads and its collector row is due in exactly 280,800 s. R6, on local storage: the artwork route answers public, max-age=2592000, immutable, no-transform; the v2 listener has appended no-transform to every response with an ETag since before this change. R7: an avatar link on a private bucket is signed with X-Amz-Expires=280800 and answers private, max-age=604800, immutable.
  • Reuse, measured in real time on two lab stacks, base and this change, each with its own Postgres and MinIO, seeded the same way: a scripted client reads Home and the catalog list as the admin and fetches each image URL it has not seen, revalidates one it holds without a fresh max-age, and skips one still fresh. Results are under Evidence.
  • The full check list in CONTRIBUTING.md "Validate your change" passes on the first commit, f40f27a0c, rebased onto main 835131fe1 (the rebase had no conflicts; the checks ran again on the rebased tree), as it did before on base cdf344f9d: build, gofmt, go mod tidy -diff, vet, lint-changed (0 issues), lint-router-recovery, make test-go, test-db-pins with PostgreSQL 18 (all 1,373 pins), contract, generated-file, migration and hygiene checks, web install, lint, format, build, budget and tests (3,777 passed), verify-actionlint, verify-shellcheck and verify-prometheus-rules. The full list passes again with the review fix commit on top, against main 835131fe1: lint-changed and lint-router-recovery (0 issues each), make test-go, test-db-pins (all 1,393 pins), web tests (3,799 passed), and every other check named above. main has since moved two commits past 835131fe1; neither changes a file this pull request changes, and GitHub reports the branch mergeable.
  • Not covered: AWS S3, Backblaze B2 and Cloudflare R2 (only MinIO answered the override check); a Cloudflare token endpoint with its WAF rule, including the 280,800 s lifetime; the held 503 on a real path (Postgres tests only); a real provider's rate-limit answer (the test serves the code the S3 client's retry table lists for Wasabi); more than two replicas; no deployment ran this change.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-5928/

The page shows the real-path run's log and the reuse samples' counters for both stacks.

Build: this change on base cdf344f9d, and base cdf344f9d alone (the rebase onto 835131fe1 and the review fix commit were gated, not rerun on the lab stacks), each built in Linux containers on <lab-host> against PostgreSQL 18 and MinIO RELEASE.2026-08-04T00-00-00Z.

Reuse run: each stack shows the same 4 image URLs (Home sections plus the catalog list). Storage GETs and bytes are MinIO's getobject count and sent bytes across each sample. The first sample was at 2026-12-06 14:04 UTC and the second an hour later, both in one 72-hour Window. The day boundary passes with an injected clock: TestResolvedURLReuseAtMeasurementTimes samples start, +1 h, past the next UTC midnight and +2 days on two replicas in each signing mode and gets one URL per versioned key (the old one-day window gives three). A real-time sample past UTC midnight follows in a comment.

Sample Base: new URLs, client requests, storage GETs, bytes This change: new URLs, client requests, storage GETs, bytes
Start 4 new; 4 full GETs; 4 storage GETs; 7,990 bytes 4 new; 4 full GETs; 4 storage GETs; 7,990 bytes
Start + 1 h 0 new; 4 conditional GETs (4 answered 304); 4 storage GETs; 0 bytes 0 new; 0 requests (4 still fresh); 0 storage GETs; 0 bytes

At the start sample, the base build's 4 responses carried no Cache-Control, and this change's 4 responses carried public, max-age=2592000, immutable (the override check passed on that stack, so the older objects carry it too).

Real-path run, trimmed:

R2 ok object_cache_control='public, max-age=2592000, immutable' link_cache_control='public, max-age=2592000, immutable'
R3 ok outcome=pass row_entries=1 replica2=recorded replica2_putobject=0 replica_links_identical=yes base_era_link_cache_control='public, max-age=2592000, immutable' override_in_link=yes
R4 ok link_changed=yes
R5 ok old_link_loads=200 not_before_in=280800s (want 280800s)
R7 ok expires=280800 content_type=image/webp cache_control='private, max-age=604800, immutable'
R6 ok backend=local cache_control='public, max-age=2592000, immutable, no-transform'

The run ended with its pass line and exit 0. R6 prints after R7 because the local stack starts after the S3 stack stops.

Risks

  • Upgrade: the migration replaces two trigger functions, adds two triggers (which briefly locks library_collections and user_personal_collections against writes) and deletes the 4h row. Rolling upgrade: old replicas write objects without the header, and those stay header-less unless the override reaches them. Rollback: the Down migration restores the 24-hour intervals and drops the triggers; the deleted 4h row is not recreated, which the old code reads as its 4 h default anyway.
  • Storage: replaced art and avatar versions take more space, as in items 7 and 8.
  • Shared caches: Month responses are public. An install with a CDN in front of its artwork bucket may start caching new catalog uploads for up to 30 days (item 2).
  • A storage that changes how it treats response-cache-control after a pass breaks direct artwork links until an operator clears the row and restarts every replica (item 10).
  • The 78-hour retention relies on fix(artwork): keep the storage sweep from deleting artwork being re-cached #5916; until it merges, the daily storage sweep can delete a replaced catalog image early.
  • Nearby, not changed here: admin account deletion (DeleteAdminAccount) removes the account's collection images but not its profiles' avatar objects, a leak that versioned avatars make larger with each upload. The backup and storage-transition code keeps its own copies of the image prefixes. Check connection's .silo-admin-connection-check/ prefix is not excluded from storage moves. A clear or preset switch racing an upload can still delete the winning upload's objects, as before this change. The override record treats a value it cannot parse as empty and then writes only its own entry, so a later release that changes the record's shape would lose its entries on a downgrade.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: T3 Code running Claude Code and Codex
  • Tool(s): Claude Code, Codex
  • Model(s): claude-opus-5-5, claude-sonnet-5-5, gpt-6.2-sol
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: Claude Opus 5.5 and GPT-6.2 Sol explored the design in a blind pair, and Claude Opus 5.5 wrote it. Both reviewed the draft, and GPT-6.2 Sol audited a later revision. The audit found that replicas could record different check results and sign different links, that a token rule changed the URL every second just above a 6-hour lifetime, and that a storage could keep public while rewriting private, so the check now tests both values; the design fixed each. Claude Opus 5.5 wrote the spec, and Claude Opus 5.5 and GPT-6.2 Sol reviewed it. They found that deleting a collection removed its collages at once, that the collection triggers would queue a path the row had borrowed from another surface, that a second production handler had no reservation service, and that a held upload answered 500 instead of 503; the spec fixed each. Claude Sonnet 5.5 wrote the code, the tests, the fixes and the lab scripts. A Claude Sonnet 5.5 verifier checked each part; it found that an admin collection upload for a missing collection wrote and reserved objects before answering 404, docs that contradicted the code, and a check failure logged without its reason, all fixed. Claude Opus 5.5 and GPT-6.2 Sol then reviewed the whole change and proved findings with lab runs. GPT-6.2 Sol found that the reservation waited on the collector's storage delete before answering 503, that a losing replica logged its own reason as published, and that a canceled avatar clear could leave every version; all are fixed. It also found that a Grace above 7 days breaks private avatar links, which item 12 discloses. Claude Opus 5.5 found the unbounded avatar version count, disclosed in item 8, the account-delete leak listed under Risks, gaps in this restriction list, and no real-path step for the private avatar bucket, now step R7 of that run. A Claude Sonnet 5.5 verifier rechecked the fixes and found no defect. Claude Opus 5.5 checked open pull requests for overlap (fix(artwork): keep the storage sweep from deleting artwork being re-cached #5916, feat(admin): read any account's personal collections and write them onto a profile #5711, fix(artwork): sweep every prefix the artwork GC tracks #5914) and drafted this description and the commit message. CodeRabbit's review found that a provider's 403 rate limit recorded a permanent fail, that the reservation could still wait on another request's uncommitted insert, that a test could hang on a small connection pool, and that the images API doc gave admin poster links one lifetime where the code has two. Claude Opus 5.5 triaged it, Claude Sonnet 5.5 wrote the fixes, a Claude Sonnet 5.5 verifier rechecked them with extra edge cases and found no defect, and Claude Opus 5.5 drafted the replies and the fix commit's message.

…eaders

Image links changed far more often than the images: a versioned image
got a new URL at every UTC midnight, and on S3 every other image got a
new URL on each read, with no Cache-Control on the stored objects. Every
client that caches by URL downloaded each image again at least daily.

internal/artworkkey now owns the caching values and the rules that pick
them for a key: a 72-hour Window, a 6-hour Grace (the default of
s3.metadata_presign_expiry), a 15-minute Short bucket, and two headers.
Catalog art and new admin collection uploads get
"public, max-age=2592000, immutable"; versioned avatars, chapter and
marker thumbnails, seek-preview sheets and new personal collection
uploads get "private, max-age=604800, immutable"; any other key gets
none. A key whose bytes never change at that name keeps one URL for the
Window on every replica and works for the Grace after it, on the local
signer, on SigV4, and on Cloudflare token links whose lifetime allows
it. Library posters, rewritten in place, still get a fresh S3 and
token URL on every read.

The S3 adapter writes the header as object metadata on every upload
path, and the local artwork route sends it. Offline-download artwork,
branding and overlay images move from one year to these values.

On a SigV4 artwork store, each replica checks at start, in the
background, whether the storage returns response-cache-control with
exactly the signed value. The first definitive result for the store's
settings is recorded in the hidden artwork.response_override_check row
through UpdateValueAtomic, and every replica adopts it. After a pass,
presigned artwork links carry the parameter, which gives the header to
objects stored before this change. An inconclusive check records
nothing and retries hourly.

Collection uploads use the encoded-bytes revision catalog art uses,
moved to imageutil. Avatar uploads are stored under a content-hash name
and overwrite nothing. Replaced art waits 78 hours in the revision
collector. New triggers queue a collection's displaced poster or
backdrop, only from its own image directory, in the transaction that
replaces it, and an upload reserves its exact keys with the collector
(catalog.ArtworkReservations) before writing. A migration deletes a
stored s3.metadata_presign_expiry of exactly 4h so installs follow the
new 6h default.

Changed answers:

- A collection upload whose path the collector holds, or another
  request is reserving, answers 503 with Retry-After: 30. With no
  reservation service wired, a collection upload fails instead of
  writing unreserved objects.
- Offline-download artwork answers the one-week private header, and
  branding and overlay images the 30-day public one, instead of one
  year. The local route answers the classified header instead of
  private max-age or no-cache.
- A versioned key's link holds 72 hours instead of a UTC day, private
  avatars included (before: a fresh 15-minute link per read). Other
  unversioned SigV4 and token links hold 15 minutes instead of one per
  read. The token window is the larger of the lifetime minus Grace and
  a quarter of the lifetime, capped at the Window.
- s3.metadata_presign_expiry defaults to 6h, and a stored 4h is
  deleted, including one an admin chose.
- Replaced catalog art and collages wait 78 hours instead of 24.
  Replaced and cleared collection uploads wait 78 hours instead of
  being deleted at once; a deleted collection's collages go to the
  collector, its uploads are still deleted at once.
- New avatar refs read
  upload:profile-avatars/<user>/<profile>/original.<64 hex>.webp.
  Old versions stay until the avatar is cleared, switched to a preset,
  or the profile is deleted, and profile delete removes the avatar
  prefix whatever the final ref is.
- After a passed check, presigned artwork links carry
  response-cache-control, replacing any header stored on the object.
  The recorded result stays until an operator deletes the row and
  restarts every replica.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Codex (gpt-6.2-sol) <noreply@openai.com>
Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
@silo-triage silo-triage Bot added the size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. label Dec 6, 2026
@silo-kody

silo-kody Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The PR adds shared artwork URL-window and cache policies, extends collection-artwork retention and upload reservations, stores avatars under revision-specific keys, and adds a background check for S3 response-cache-control overrides.

Changes: Artwork lifecycle and delivery

Layer / File(s) Summary
Artwork key, URL, and cache policies
internal/artworkkey/*, internal/artworkurl/*, internal/s3client/*, internal/blobstore/*, internal/apiv2/*, internal/config/*, internal/downloads/*, internal/chapterthumbs/*, internal/trickplay/*, internal/imageutil/*, internal/imagecache/*, internal/metadata/image_resolver_test.go, internal/backup/restoreset_read_test.go, internal/jellycompat/*, docs/architecture/blob-storage.md, docs/architecture/trickplay.md, docs/images-api.md, docs/collections-api.md
Shared key parsers define URL windows and cache classes. S3 writes and artwork responses apply the matching cache policy. Signing defaults use six-hour grace and 72-hour windows for eligible keys.
Collection artwork reservations and retention
internal/catalog/*, internal/api/handlers/collection_artwork.go, internal/api/handlers/collections.go, internal/api/handlers/admin_collections_service.go, internal/api/handlers/library_collections.go, internal/api/handlers/user_collection_imports.go, internal/api/router.go, migrations/sql/20261205194500_artwork_cache_windows.sql, internal/metadata/*artwork*test.go, internal/api/handlers/collection*test.go, scripts/ci/db-contracts.txt, docs/architecture/backups.md, docs/architecture/collection-posters.md, docs/collections-api.md, docs/architecture/blob-storage.md
Collection uploads reserve exact variant keys before writing and return a retryable unavailable response when a collector holds a path. Displaced artwork is queued for collection after 78 hours. Collection deletion removes poster and backdrop objects immediately and leaves collages for the collector.
Versioned avatar storage and cleanup
internal/api/handlers/profile_avatars.go, internal/api/handlers/profiles.go, internal/api/router.go, internal/userstore/avatar.go, internal/api/handlers/profile_avatar*test.go, internal/userstore/avatar_test.go
Avatar uploads use revision-specific original and w256 keys. Profile references and URL resolution support versioned keys, and cleanup removes avatar objects after clearing or deleting a profile.
S3 response-cache-control override
internal/s3client/response_override.go, internal/s3client/client.go, internal/blobstore/response_override.go, internal/blobstore/s3.go, internal/blobstore/response_override*test.go, internal/blobstore/export_test.go, internal/api/handlers/admin.go, cmd/silo/main.go, internal/storagetransition/service.go, docs/architecture/blob-storage.md, scripts/ci/db-contracts.txt
A background worker checks plain and cache-override signed links, then stores a result by storage fingerprint. Eligible SigV4 links use the override only after a passing result. Missing settings and inconclusive checks leave it disabled.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant CollectionUploadHandler
  participant ArtworkReservations
  participant CollectionDatabase
  participant BlobStore
  CollectionUploadHandler->>ArtworkReservations: Reserve revision variant keys
  ArtworkReservations->>CollectionDatabase: Record reservation
  ArtworkReservations-->>CollectionUploadHandler: Reservation result
  CollectionUploadHandler->>BlobStore: Write variants after reservation
  CollectionUploadHandler->>CollectionDatabase: Update collection image path
Loading
sequenceDiagram
  participant S3Client
  participant ResponseOverrideWorker
  participant SettingsRepository
  participant ObjectStorage
  S3Client->>ResponseOverrideWorker: Start with override disabled
  ResponseOverrideWorker->>SettingsRepository: Read result for storage fingerprint
  SettingsRepository-->>ResponseOverrideWorker: Existing result or no result
  ResponseOverrideWorker->>ObjectStorage: Write fixture and fetch signed links
  ObjectStorage-->>ResponseOverrideWorker: Return status, body, and headers
  ResponseOverrideWorker->>SettingsRepository: Publish conclusive result
  ResponseOverrideWorker->>S3Client: Set override from recorded result
Loading

Possibly related issues

  • Silo-Server/silo-server#5781: The PR changes collection-artwork reservation and replacement-cleanup behavior related to the reported races. Whether it fully resolves the issue is not established.

Suggested reviewers: quick104, blurbery, rhainland

Merge Risk: Moderate · up to 53395

Replaced catalog images can be deleted before their documented 78-hour retention ends until the dependent sweep change merges, which can break still-valid image links. Merge only after that dependency lands, and fix the admin poster documentation for legacy cached posters.

Security architecture risk: Moderate · up to 53395

Longer-lived links and immutable caching are intentional, but not every cleanup path honors the longer lifetime. Silo can also report an avatar cleared while its previous versions remain readable through valid links, or ask a client to retry a collection edit after part of that edit has already committed.

This update could not fully reassess the architecture findings from the earlier review.

Architecture findings

  • Minor · reliability · observed: The scheduled artwork sweep can remove displaced catalog art while a default-lifetime link still works. The migration gives the revision collector a 78-hour deadline, but on an ordinary sweep page the sweep deletes an unreferenced object once its modification age reaches 24 hours, regardless of when the reference was lost. It checks the GC schedule only on anomalous pages, where it leaves the page to GC or stops. This does not apply to collection-upload prefixes.
  • Minor · security · observed: Clearing an uploaded avatar or switching it to a preset commits the new profile state before deleting the old objects. If deletion fails or the process stops after commit, a retry sees the same empty or preset reference as a completed cleanup and does not retry the deletion. Cleanup now survives request cancellation, and deleting the profile attempts the whole prefix regardless of its final reference, but both are best-effort. The merge base could leave one stable object set; this PR can leave the profile's revision history readable to holders of still-valid links.
  • Minor · security · observed: The grace migration deletes every stored value exactly equal to 4h, including an operator's deliberate choice. The new signer falls back to six hours until the operator reapplies the setting. The down migration does not recreate the row; the old binary's four-hour fallback neither restores the explicit setting nor changes links already issued.
  • Minor · architecture · inferred: A combined personal collection edit can commit metadata, including a rename, before the new reservation refuses its poster write. The refusal correctly prevents object writes, but the retryable response does not undo the metadata update or the rename side effects. The merge base already allowed storage failures after commit; this PR adds a refusal on normal database or collector contention. Clients using revision checks may need to reload and reconcile the committed edit before retrying the poster.
  • Minor · security · inferred: An avatar upload can leave a partially written or complete revision in storage without ever publishing its profile reference. If the profile had no uploaded avatar, clearing it skips prefix cleanup even when storage is healthy. A later qualifying clear or profile deletion can remove the objects, but a failed upload itself does not schedule recovery. Distinct failed uploads can now accumulate distinct revisions rather than reusing the merge base's fixed set of keys.

View findings in the submitted review

Security review details

Security Blast Radius

  • inferred — A copied versioned avatar link can authorize cold reads of that revision for much longer than under the merge-base short avatar TTL, provided the object remains present. The link identifies one object, not the profile prefix or a bucket listing. A private cache may retain already-fetched bytes beyond origin expiry; the private directive is not a revocation control.

Security Findings and Attack Paths

  • inferred — A recipient who already holds an unexpired avatar link can continue reading the stored revision after a clear reports success if prefix deletion failed. This does not require bucket credentials, but it does require possession of the link and a surviving object. An upload that never published a reference is a separate storage-retention issue, not evidence that a link to that revision was issued.

Trust Boundaries and Controls

  • observed — The S3 worker signs both allowed header values through the production signer, then fetches the fixture without additional credentials or redirects. The first recorded outcome for the fingerprint controls signing; rate limits and inconclusive results do not enable the override. Public and token signing ignore the override option.

Public contracts

  • observed — Revisioned links can be reused for a 72-hour issuance window, with a six-hour default grace. A held collection upload path is reported as unavailable with a 30-second retry hint. The S3 throttle classifier export shares error classification with the compatibility worker; it does not itself grant request or storage authority.

Dependencies

  • inferred — The signed S3 override relies on the provider treating production artwork like the probe fixture. The check verifies two exact headers on successful fixture GETs; it does not establish equivalent behavior for object-specific policies or range and conditional responses.

Service and deployment topology

  • observed — The compatibility worker runs for SigV4 S3 assets delivery, not public or token delivery. Avatars remain in the operational store: private S3 when configured, or signed delivery from the local root. An S3 deployment with only the public artwork bucket does not enable avatar uploads.

Data and control flow

  • observed — Collection handlers derive variant keys from encoded bytes, commit the reservation, write the variants, and then publish the reference. The collector checks live references under its queue-row lock before deleting; a referenced, untombstoned revision is parked instead.

Resilience and Maintainability Implications

  • observed — A held reservation prevents variant writes, and an interrupted upload that committed a reservation leaves exact keys for the collector. Neither guarantee makes the surrounding collection edit atomic: metadata can already be committed when the poster is refused. Separately, the 78-hour collector deadline is not enforced by the ordinary catalog sweep.
  • observed — Avatar cleanup has its own 30-second deadline, so disconnecting is no longer enough to cancel an attempted deletion. There is still no durable cleanup obligation for clear or preset changes: after a failed attempt, repeating the same request cannot distinguish incomplete cleanup from success.
  • inferred — Rolling back to the merge-base collection writer can restore immediate replacement cleanup while links minted by the new release remain valid. A binary rollback is therefore not a rollback of the link contract; the operator must account for outstanding links before restoring the shorter cleanup behavior.

Hardening Proposals

  • proposed — Make every catalog deletion path honor the same retention deadline. For avatars, track unpublished writes and post-clear deletion as durable, retryable work scoped to specific revisions so a delayed retry cannot delete a newly published avatar.

Rollout and rollback

  • observed — After the store opens, Silo's background worker adopts a compatibility result for the configured S3 fingerprint or tests the signed response before enabling the override. Missing or inconclusive results leave plain signing available and do not block readiness or a storage transition. If the provider changes behavior under the same fingerprint, the operator must clear the recorded result and restart the signing replicas; that does not repair links already handed out. The transition copy excludes probe fixtures.
  • observed — Cloudflare's WAF enforces the actual token lifetime; Silo uses its configured lifetime to choose timestamps. To get the full 72-hour reuse window at the documented default grace without exceeding the 78-hour retention, the operator must align Silo and the WAF at 280,800 seconds. Silo's SigV4 check does not verify that alignment.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "perf(artwork): image links hold for three days and carry long cache headers" matches the main changes in the changeset. The raw summary shows a 72-hour Window for revisioned artwork links, …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is detailed and directly related to the changeset. It explains the goal of extending stable image-link windows and adding long cache headers, the approach across artworkkey, the S3 ada…
Full details: Title check

Explanation

The title "perf(artwork): image links hold for three days and carry long cache headers" matches the main changes in the changeset. The raw summary shows a 72-hour Window for revisioned artwork links, long Cache-Control headers via artworkkey constants, and related retention changes. It is concise, single-sentence, and specific. Minor note: the title does not mention the retention, avatar versioning, or response-override check, but that is expected for a title.

Full details: Description check

Explanation

The description is detailed and directly related to the changeset. It explains the goal of extending stable image-link windows and adding long cache headers, the approach across artworkkey, the S3 adapter, signers, retention triggers, avatar versioning, and the response-override check. It also lists the migrations, test coverage, validation, and risks, which match the raw summary of changed files.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added enhancement New feature or request go Pull requests that update go code needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. priority: P2 Limited scope, workaround exists, or polish labels Dec 6, 2026
Comment thread internal/artworkkey/cache.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments

Major 1
  1. Protect displaced artwork from the daily sweep.
Minor 9
  1. Keep replaced artwork until configured links expire.
  2. Document the two admin poster link lifetimes separately.
  3. Make the insert conflict path non-blocking too.
  4. Give the concurrency test enough connections and a bounded wait.
  5. Protect later uploads from detached cleanup.
  6. A throttled override GET can disable the override permanently.
  7. Do not tell clients to repeat createCollection after a held poster.
  8. The scheduled artwork sweep can remove displaced catalog revisions before the new 78-hour deadline, even at the default grace. For an object already past the sweep’s 24-hour age floor, loss of the catalog reference is enough for deletion on an ordinary page; the GC schedule is consulted only on anomalous pages, where the sweep either leaves the page to GC or stops. The sweep predates this PR, but its unchanged deletion rule now defeats the longer validity promised to holders of newly issued links. This is distinct from the documented limitation for custom lifetimes above 78 hours and does not apply to collection-upload prefixes.
  9. A clear can report success after committing an empty avatar reference even if deleting the stored objects fails. A subsequent clear sees the same empty state as a completed cleanup and skips the prefix deletion. A switch from an uploaded avatar to a preset has the same post-commit failure gap. Profile deletion does attempt the whole prefix regardless of the final reference, but only when the profile is deleted, and its storage error is also logged rather than retried. The merge base had the clear ordering with one stable object set; the PR increases the residual exposure to the profile’s stored revision history, including versions reachable through still-valid links.
Trivial 1
  1. The migration deletes every stored value exactly equal to 4h, not just rows seeded with the old default. An operator who deliberately selected that value loses the explicit grace policy and the new signer uses six hours until the operator reapplies it. Rolling back to the old binary restores its four-hour fallback, not the explicit setting or the expiry of links already issued.
Nitpick 1
  1. Move the operator recovery procedure to the user manual.
    docs/architecture/blob-storage.md, lines 630–635 · 📐 Maintainability & Code Quality · ⚡ Quick win
    These lines instruct operators to delete a settings row and restart replicas. Keep the stale-result behavior here, but move the recovery steps to the user manual. This keeps the procedure in the documentation maintained for operators.
    As per coding guidelines, “Guides for installing, configuring, operating, or troubleshooting Silo belong in the user manual.”
    Source: Coding guidelines
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fafa1ec0-fd6a-41f0-acec-b0c009ebcd79
Commits

Reviewing files that changed from the base of the PR and between 835131f and f40f27a.

Files selected for processing: 70

  • cmd/silo/main.go
  • docs/architecture/backups.md
  • docs/architecture/blob-storage.md
  • docs/architecture/collection-posters.md
  • docs/architecture/trickplay.md
  • docs/collections-api.md
  • docs/images-api.md
  • internal/api/handlers/admin.go
  • internal/api/handlers/admin_collections_service.go
  • internal/api/handlers/admin_collections_service_test.go
  • internal/api/handlers/collection_artwork.go
  • internal/api/handlers/collection_artwork_test.go
  • internal/api/handlers/collection_delete_retention_db_test.go
  • internal/api/handlers/collections.go
  • internal/api/handlers/collections_lifecycle_service.go
  • internal/api/handlers/libraries_service.go
  • internal/api/handlers/library_collections.go
  • internal/api/handlers/profile_avatar_storage_test.go
  • internal/api/handlers/profile_avatar_versions_test.go
  • internal/api/handlers/profile_avatars.go
  • internal/api/handlers/profiles.go
  • internal/api/handlers/user_collection_imports.go
  • internal/api/router.go
  • internal/apiv2/artwork.go
  • internal/apiv2/artwork_test.go
  • internal/apiv2/branding.go
  • internal/apiv2/branding_test.go
  • internal/apiv2/overlay_images.go
  • internal/artworkkey/cache.go
  • internal/artworkkey/cache_test.go
  • internal/artworkurl/artworkurl.go
  • internal/artworkurl/artworkurl_test.go
  • internal/artworkurl/reuse_test.go
  • internal/backup/restoreset_read_test.go
  • internal/blobstore/exclusive.go
  • internal/blobstore/export_test.go
  • internal/blobstore/response_override.go
  • internal/blobstore/response_override_db_test.go
  • internal/blobstore/response_override_test.go
  • internal/blobstore/s3.go
  • internal/blobstore/s3_test.go
  • internal/catalog/artwork_reservations.go
  • internal/catalog/artwork_selection.go
  • internal/catalog/collection_collages.go
  • internal/chapterthumbs/blobgc.go
  • internal/chapterthumbs/blobgc_keys_test.go
  • internal/chapterthumbs/originals_cleanup.go
  • internal/config/admin_settings.go
  • internal/config/config.go
  • internal/config/db_loader.go
  • internal/config/db_loader_test.go
  • internal/downloads/offline.go
  • internal/downloads/offline_artwork_test.go
  • internal/imagecache/imagecache.go
  • internal/imageutil/revision.go
  • internal/imageutil/variants_test.go
  • internal/jellycompat/user_avatar_versioned_test.go
  • internal/metadata/artwork_reservation_db_test.go
  • internal/metadata/artwork_retention_db_test.go
  • internal/metadata/image_resolver_test.go
  • internal/s3client/client.go
  • internal/s3client/presign_window_test.go
  • internal/s3client/response_override.go
  • internal/storagetransition/service.go
  • internal/trickplay/manifest.go
  • internal/userstore/avatar.go
  • internal/userstore/avatar_test.go
  • migrations/sql/20261205194500_artwork_cache_windows.sql
  • migrations/sql/20261205194600_artwork_cache_windows_drop_4h_grace.sql
  • scripts/ci/db-contracts.txt
Files with no reviewable changes: 1

  • internal/api/handlers/admin_collections_service_test.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Comment on lines +517 to +520
**Replaced art outlives its links.** Artwork a row stops naming waits in the
revision collector for `artworkkey.ReplacedRetention` (78 hours: the Window plus
the default Grace) before the collector may delete it, so a link issued before
the replacement keeps working until it expires. This holds at the default Grace;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Data Integrity & Integration · Heavy lift

Protect displaced artwork from the daily sweep.

If a catalog object is older than 24 hours when it is replaced, the daily sweep can delete it before its 78-hour retention deadline. On a page with fewer than 50 parsed objects, the sweep does not check the revision collector's schedule. A still-valid link can then return a missing-object response.

Make the sweep preserve displaced artwork until its retention deadline before relying on this guarantee.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, and this PR depends on #5916 for exactly this. The daily storage sweep deletes an unreferenced object older than 24 hours without reading the collector's deadline, so it can remove a replaced catalog image inside the 78 hours. #5916 moves the sweep's delete under the collector's row locks and skips any revision whose row has not_before in the future. Every displaced catalog revision has that row, because the trigger writes it with now plus 78 hours, so the guard holds on every page, not only the lopsided ones. The PR body says this PR should merge after #5916, and I'll rebase onto it when it lands. On that rebase I'll also add the deadline to the sweep paragraph in docs/architecture/blob-storage.md.

🤖 Claude Code (claude-opus-5-5)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Analysis chain

Script executed:

#!/bin/bash
set -u
echo '=== Pull request #5916 ==='
gh api repos/Silo-Server/silo-server/pulls/5916 --jq '{state,merged,merged_at,title,base:.base.ref,head:.head.sha,body}' || true
echo '=== Pull request #5928 ==='
gh api repos/Silo-Server/silo-server/pulls/5928 --jq '{state,merged,base:.base.ref,head:.head.sha,body}' || true
echo '=== Current revision ==='
git rev-parse HEAD
echo '=== Current artwork sweep symbols ==='
rg -n -C 3 'artwork_revision_gc_candidates|not_before|sweepArtwork|SweepArtwork|parsedObjects' internal/metadata -g '*artwork*' | head -230
echo '=== Reconcile file outline ==='
ast-grep outline internal/metadata/artwork_reconcile.go --items all --type function --match '[Ss]weep|[Aa]rtwork'
echo '=== Pull request #5916 relevant file changes ==='
gh api --paginate repos/Silo-Server/silo-server/pulls/5916/files --jq '.[] | select(.filename | test("artwork|sweep|gc"; "i")) | {filename,status,patch}' || true

Length of output: 72441


@darthShadow Thanks for identifying the dependency. At the time of the check, #5916 was still open. Its current patch checks not_before under the revision row lock.

I’m not marking this finding addressed yet. After #5916 merges and this PR is rebased, please verify that the sweep preserves an object older than 24 hours while its collector deadline is in the future, including on a small page.


📝 Learnings were not changed: only organization members or users with write access to this repository can add or remove learnings.

You are interacting with an AI system.

Comment thread docs/collections-api.md Resolved
Comment thread docs/images-api.md Resolved
Short = 15 * time.Minute
// ReplacedRetention is how long replaced art stays in storage: every link
// to it has expired by then.
ReplacedRetention = Window + DefaultGrace

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Heavy lift

Keep replaced artwork until configured links expire.

With s3.metadata_presign_expiry set to 24h, a versioned URL signed at a window boundary lasts 96 hours. If the image is replaced one hour later, cleanup can delete it at hour 79 while the URL is still valid. A cold read of that URL can then fail.

Make replacement retention cover the longest issued URL lifetime. Account for configured grace periods and Cloudflare token TTLs, including the SQL cleanup deadlines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, and it's the documented limit of this PR: retention covers links issued at the default 6-hour grace, and a longer grace or a token lifetime above 3 days 6 hours issues links that can outlive it. docs/architecture/blob-storage.md and item 7 under "Needs maintainer approval" say so, and the earlier cache.go thread covers the same point. Following the configured grace would mean the collector adding the excess at delete time, since the triggers can't read the setting, or refusing larger values. That's a maintainer call; question 12 in the PR body asks about a cap.

🤖 Claude Code (claude-opus-5-5)

Comment thread internal/blobstore/response_override.go Resolved
A storage that rate limits with a 4xx, such as Wasabi's 403
RequestRateLimitExceeded, made the response override check record a
permanent fail, which kept the cache header off until an operator
cleared the row. The check now reads up to 4 KiB of each answer, takes
the S3 error code from it, and treats a code the S3 client lists as a
throttle as inconclusive, so it retries an hour later as a 429 does.
s3client.IsThrottleCode holds that list for both the SDK retryer and
the check.

Reserve could still wait on another request's uncommitted insert of
the same new path, which its NOWAIT read cannot see. The insert now
runs under a transaction-local 50 ms lock_timeout, and a lock it cannot
take in that time answers held, so the upload gets the same 503 and
the same 30-second Retry-After as any other held path where it used to
wait.

The concurrent poster replacement test runs under a 30-second context,
so a database URL with a small pool fails instead of hanging. The
images API doc states the cached-art and getItemPoster link lifetimes
separately, the collections doc limits the held-path 503 to
uploadCollectionPoster, and the blob storage doc keeps the override
recovery behavior without the operator steps.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
@silo-kody

silo-kody Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments

Minor 3
  1. Document the legacy cached-poster lifetime.
  2. A combined personal collection edit can commit metadata, including a rename, before the new reservation refuses its poster write. The refusal correctly prevents object writes, but the retryable response does not undo the metadata update or the rename side effects. The merge base already allowed storage failures after commit; this PR adds a refusal on normal database or collector contention. Clients using revision checks may need to reload and reconcile the committed edit before retrying the poster.
  3. An avatar upload can leave a partially written or complete revision in storage without ever publishing its profile reference. If the profile had no uploaded avatar, clearing it skips prefix cleanup even when storage is healthy. A later qualifying clear or profile deletion can remove the objects, but a failed upload itself does not schedule recovery. Distinct failed uploads can now accumulate distinct revisions rather than reusing the merge base's fixed set of keys.
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5f006598-9a26-4047-8b36-1bf365ddabce
Commits

Reviewing files that changed from the base of the PR and between f40f27a and 533953a.

Files selected for processing: 10

  • docs/architecture/blob-storage.md
  • docs/collections-api.md
  • docs/images-api.md
  • internal/blobstore/response_override.go
  • internal/blobstore/response_override_test.go
  • internal/catalog/artwork_reservations.go
  • internal/metadata/artwork_reservation_db_test.go
  • internal/metadata/artwork_retention_db_test.go
  • internal/s3client/retry.go
  • scripts/ci/db-contracts.txt

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Comment thread docs/images-api.md
Comment on lines +305 to +306
needs no credentials. A link to cached art follows the rule for revisioned
artwork above: it changes every 72 hours and works for up to 3 days 6 hours

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Document the legacy cached-poster lifetime.

An admin poster can use a legacy unversioned key. Its link changes every 15 minutes, not every 72 hours, and lasts up to 6 hours 15 minutes at the default lifetime. Document this case separately from revisioned cached art.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. priority: P2 Limited scope, workaround exists, or polish size/XXXL 3000+ added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant