Skip to content

app/: renderer API, bulk downloads, public gallery and retention (sc-8900) - #81

Merged
ndbroadbent merged 18 commits into
mainfrom
laravel-render
Dec 2, 2026
Merged

ndbroadbent merged 18 commits into
mainfrom
laravel-render

Conversation

@ndbroadbent

Copy link
Copy Markdown
Member

Ports the renderer API, bulk downloads, the public gallery and retention to the Laravel Rust app (sc-8900). Based on laravel-read.

Renderer API (/internal/renderer/…: metrics, claim, a render's uploads, complete)

  • Every route checks its token itself, whatever the Host header. The host routing gives unknown hosts every path, and a client picks its own Host. A test sends each route with no token under three hosts and gets 401s.
  • The metrics take their own token (METRICS_TOKEN; empty turns them off). The renderer token doesn't read metrics, and the metrics token doesn't claim renders.
  • Claiming orders by how many renders the project has rendering now, as today. Uploading and completing need the claim's own token (X-Render-Token).
  • Completing stores page texts by hash. It then queues ProcessBuild for the processing builds of the render's project (project_id), not by scanning source_fingerprint.

Bulk downloads (POST /api/v1/builds/{id or number}/downloads, GET /api/v1/downloads/{id})

  • Snapshots are read through effective_snapshots and pages through pages::of_many, so a build that reads groups from another build downloads them too.
  • The archive streams to the bucket as a multipart upload (new in BlobStore). It's built by the downloads.build job, and a download is reused within the hour.
  • JSON and filter behaviour are today's.

Public gallery (/g/<org>/<project>.json, /g/<org>/<project>/<path>)

  • Same publishing rules, cache headers, ETags, rate limit, and type-sniffing as today.
  • Credits: one gallery row per organization, project and UTC day, added to with an upsert on the unique index. Not one row per image.
  • Purges: a BuildChanged listener queues the gallery.purge job when Cloudflare is configured.

Retention (retention:prune, daily)

  • Keeps the builds a kept build reads groups from (build_groups.source_build_id) before keeping snapshots, renders and blobs from them.
  • Deletes texts older than 24 hours that no page row or kept render names.
  • Never deletes build, snapshot or page rows. A test checks that a holder's rows, and the reader's view of them, survive.
  • groups:check (nightly) fails when a sourced group resolves to no rows. /status reports the count as empty_groups.
  • Both run from the console schedule, with heartbeats VISUALCI_RETENTION_HEARTBEAT and VISUALCI_GROUPS_CHECK_HEARTBEAT. Expiry is the builds sweep that's already there.

Tests: tests/renderer.rs, tests/downloads.rs, tests/gallery.rs, tests/retention.rs. The full app suite passes with --locked on docspring-dev; clippy and fmt are clean.

Not ported: the email sweep from today's builds:expire (notify::deliver_pending), which belongs to the emails side.

@visualci-com

visualci-com Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

VisualCI

docspring/visualci · build #392 · 333 unchanged · no changes

This PR vs base: 22 changed, 2 added since #306, across 7 builds

Updated as builds change. Agents can review with VisualCI's MCP tools.

ndbroadbent added a commit that referenced this pull request Dec 2, 2026
… 2,000, bounded sizes, hex fingerprints, capped text) and takes only PNGs this render uploaded, proving an already stored one by uploading it to a key of its own; more than 5,000 uploads refused; claims match RENDERER_VERSION exactly, which is required; a render out of attempts fails at the next claim and its builds go on
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
…er project (a 429 past it), building claimed with one conditional update so it runs once, a 14-minute limit on writing the archive, and snapshot names that become the same path get their own directories (a_b, a_b~2)
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
…om Cloudflare's ranges (configurable), behind the cluster's trusted proxies; at most 50,000 credits per project a day; published galleries cached while their newest build and baseline stay the same; purges cover screenshots that dropped out, alert when they use up their tries (gallery_purges_failed in /status), and gallery::purge_project for turning a gallery off
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
…day keeps its overlay (diffs.used_at); registering renews a blob, which isn't marked for a day after; a marked blob something names again is kept; and no deleting mark outlives its run (cleared after each batch and at the start of a run)
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
…day keeps its overlay (diffs.used_at); registering renews a blob, which isn't marked for a day after; a marked blob something names again is kept; and no deleting mark outlives its run (cleared after each batch and at the start of a run)
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
… 2,000, bounded sizes, hex fingerprints, capped text) and takes only PNGs this render uploaded, proving an already stored one by uploading it to a key of its own; more than 5,000 uploads refused; claims match RENDERER_VERSION exactly, which is required; a render out of attempts fails at the next claim and its builds go on
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
…er project (a 429 past it), building claimed with one conditional update so it runs once, a 14-minute limit on writing the archive, and snapshot names that become the same path get their own directories (a_b, a_b~2)
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
…om Cloudflare's ranges (configurable), behind the cluster's trusted proxies; at most 50,000 credits per project a day; published galleries cached while their newest build and baseline stay the same; purges cover screenshots that dropped out, alert when they use up their tries (gallery_purges_failed in /status), and gallery::purge_project for turning a gallery off
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
…day keeps its overlay (diffs.used_at); registering renews a blob, which isn't marked for a day after; a marked blob something names again is kept; and no deleting mark outlives its run (cleared after each batch and at the start of a run)
@ndbroadbent
ndbroadbent force-pushed the laravel-render branch 2 times, most recently from 690255f to c1e784a Compare December 2, 2026 20:28
@ndbroadbent
ndbroadbent force-pushed the laravel-read branch 2 times, most recently from 3e184b9 to b00fdbd Compare December 2, 2026 20:52
@ndbroadbent
ndbroadbent changed the base branch from laravel-read to main December 2, 2026 21:02
…mpletion that wakes the project's waiting builds; every route checks its token whatever the Host
…ber}/downloads and GET /api/v1/downloads/{id}, read through effective_snapshots and pages::of_many; multipart uploads in the blob store
…om BuildChanged, and gallery credits as one row per project and day
…es unreferenced texts after a day) and the nightly check that no group resolves to no rows, as scheduled commands with heartbeats
…t; /status counts groups with no rows; downloads crop with mcp::images
… test's body on the heap; domain modules in order
…names (a build registering while a prune runs isn't in its keep sets), and an object whose blob row came back after the delete
… 2,000, bounded sizes, hex fingerprints, capped text) and takes only PNGs this render uploaded, proving an already stored one by uploading it to a key of its own; more than 5,000 uploads refused; claims match RENDERER_VERSION exactly, which is required; a render out of attempts fails at the next claim and its builds go on
…b is marked before its object goes and its row only while still marked, and registering it again clears the mark and asks for the file; reused renders' images and texts, and texts stored again, stay a day
…er project (a 429 past it), building claimed with one conditional update so it runs once, a 14-minute limit on writing the archive, and snapshot names that become the same path get their own directories (a_b, a_b~2)
…om Cloudflare's ranges (configurable), behind the cluster's trusted proxies; at most 50,000 credits per project a day; published galleries cached while their newest build and baseline stay the same; purges cover screenshots that dropped out, alert when they use up their tries (gallery_purges_failed in /status), and gallery::purge_project for turning a gallery off
…day keeps its overlay (diffs.used_at); registering renews a blob, which isn't marked for a day after; a marked blob something names again is kept; and no deleting mark outlives its run (cleared after each batch and at the start of a run)
… its own: a snapshot named like another's page (x/page-2) or file (x/head.png) is suffixed ~2
…mes as a page image, checked again under the row's lock
@ndbroadbent
ndbroadbent merged commit a320b2e into main Dec 2, 2026
11 checks passed
@ndbroadbent
ndbroadbent deleted the laravel-render branch December 2, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant