Repository navigation
app/: snapshots by SHA-256 with the fingerprint optional; the server fingerprints new files; registration in a few queries (sc-8999) - #127
Merged
Conversation
…fingerprints new files; registration in a few queries (sc-8999)
Server side of sc-8999, deployable before any CLI change.
- POST /api/v1/builds/{id}/snapshots: `fingerprint` is optional. Published CLIs send it and it's used as before. Without
it, a snapshot takes the fingerprint stored on its blob (an image's pixel fingerprint, a PDF's renderer-reported one,
a text's SHA-256), and a file the server hasn't fingerprinted yet gets it during processing.
- Registration is one batch (`snapshots::register_all`): the blobs' upsert and one read back, one renders query (and
one noting those reused) for documents, and one snapshots upsert, whatever the number of snapshots. 8 queries for the
whole request with 10 known images or 100 (before: about 5 per snapshot). Within-request duplicates and conflicts
keep today's answers.
- Processing, outside any transaction under the build's lock: images without a fingerprint are decoded once per blob
(`blobs::image_info`, stored on the blob) and the snapshots updated in one statement, before comparison and groups.
`confirm_uploads` reads the build's blob rows in one query and asks the store only about unconfirmed files.
- PDFs: the renderer now reports `document_fingerprint` (visualci_core::pdf, computed in its sandbox) with the pages;
it's kept on the blob (`blobs.pdf_fingerprint`, new column, set once). A PDF sent without a fingerprint whose blob has
none is drawn under its file's hash, and that render moves to the fingerprint unless the project already has one
there. An older renderer that reports none leaves the file's hash as the fingerprint.
- A re-encoded file (same pixels or same drawing, new bytes) is uploaded once and kept as its own blob with the same
fingerprint, compares unchanged, and later runs match it by hash with no upload. Nothing is merged or deleted.
- POST /builds/{id}/groups takes `image_hash: sha256`: image entries then hash the file's SHA-256 on both sides, so the
CLI's large-suite path needn't decode either.
- MCP upload_snapshots registers through the same batch.
Docs: design.md (pipeline, source fingerprints, sandbox), design-storage.md (blobs), the API reference.
ndbroadbent
force-pushed
the
app-server-fingerprints
branch
from
December 3, 2026 10:27
5774efb to
395362c
Compare
ndbroadbent
added a commit
that referenced
this pull request
Dec 3, 2026
…LI 0.2.19 Images go to POST /snapshots with sha256 and no fingerprint; the server fingerprints files it doesn't have. The group check hashes image entries by file SHA-256 and sends image_hash: sha256. PDFs keep their fingerprint, since their bytes change every run while the drawing doesn't. Needs #127 live in production first.
ndbroadbent
added a commit
that referenced
this pull request
Dec 3, 2026
…LI 0.2.19 Images go to POST /snapshots with sha256 and no fingerprint; the server fingerprints files it doesn't have. The group check hashes image entries by file SHA-256 and sends image_hash: sha256. PDFs keep their fingerprint, since their bytes change every run while the drawing doesn't. Needs #127 live in production first.
ndbroadbent
added a commit
that referenced
this pull request
Dec 3, 2026
…ess (sc-8999) MCP's classify fingerprinted every uploaded file in the app process, PDFs included (lopdf on customer documents), though docs/design.md says customer PDFs are parsed only on the render node. It now works out only the kind, the content type and a text's SHA-256, and registers images and PDFs by their hash alone through #127's path: an image's pixel fingerprint is computed in processing, and a PDF takes the fingerprint its renderer reports once it's drawn. An undecodable image now fails its snapshot in processing ("the image couldn't be read") instead of failing the upload call.
ndbroadbent
added a commit
that referenced
this pull request
Dec 3, 2026
…ess (sc-8999) (#131) MCP's classify fingerprinted every uploaded file in the app process, PDFs included (lopdf on customer documents), though docs/design.md says customer PDFs are parsed only on the render node. It now works out only the kind, the content type and a text's SHA-256, and registers images and PDFs by their hash alone through #127's path: an image's pixel fingerprint is computed in processing, and a PDF takes the fingerprint its renderer reports once it's drawn. An undecodable image now fails its snapshot in processing ("the image couldn't be read") instead of failing the upload call.
ndbroadbent
added a commit
that referenced
this pull request
Dec 3, 2026
…LI 0.2.19 Images go to POST /snapshots with sha256 and no fingerprint; the server fingerprints files it doesn't have. The group check hashes image entries by file SHA-256 and sends image_hash: sha256. PDFs keep their fingerprint, since their bytes change every run while the drawing doesn't. Needs #127 live in production first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Server side of sc-8999: snapshots are registered by their file's SHA-256 with the fingerprint optional, the server fingerprints new files itself, and the "already known" path is a constant handful of queries. Deployable on its own; the CLI change that stops decoding is a separate PR that needs this one live first.
Backwards compatibility (must stay until the new CLI is released and the docs move)
Production's CI and customers run published CLIs that send
fingerprintfor every snapshot. The server accepts both shapes:fingerprintgiven: used exactly as today (snapshot rows, render lookup, groups). The golden files for the old path are unchanged.fingerprintabsent: taken from the blob if the server has computed it, else filled in during processing.POST /builds/{id}/groupslikewise keeps hashing image entries by pixel fingerprint unless the client sendsimage_hash: "sha256".Design
What the API accepts.
POST /api/v1/builds/{id}/snapshots: each snapshot needssha256(plus name, kind, size, content_type as before);fingerprintis optional and still validated as hex when present. Answer unchanged:upload_urlper snapshot,nullwhen the server has the file (or, for a PDF, a render of it).Where fingerprints are computed.
confirm_uploads, outside any transaction under the build's lock (processing::fill_image_fingerprints). Each blob withoutpixel_fingerprintis decoded once (blobs::image_info, which stores the fingerprint and size on the blob row in its own statement), then the build's snapshots get it in oneUPDATE ... FROM (VALUES ...). Same incompare_now(early comparisons). An undecodable file fails its snapshot ("the image couldn't be read"), as comparing it would have.document_fingerprint(visualci_core::pdf::fingerprint_bytes(..).document, exactly what the CLI computes) with the pages;renders::completestores it on the source blob (blobs.pdf_fingerprint, new nullable column, written once). A PDF sent without a fingerprint whose blob has none is queued under its file's hash (same bytes always draw the same); when the renderer reports the fingerprint, that render moves to it unless the project already has a render there. An older renderer that reports nothing leaves the file's hash as the snapshot's fingerprint (what the CLI gives a PDF it can't parse).Re-encoded files. Same pixels (or same drawing) in new bytes: unknown hash, so it's uploaded once and kept as its own blob under its own sha256, with the same fingerprint stored. It compares unchanged, and later runs match it by hash with no upload and no decode. Nothing is merged or deleted.
The known path.
snapshots::register_allregisters a request in one batch: blobs upsert + one read back (blobs::register_many), one renders query for documents with a fingerprint (+ onemark_all_usedwhen any are found), and one snapshots upsert withRETURNING name, platformto detect conflicts. Measured withdb::listenover the whole request (auth included): 8 queries for 10 known images and 8 for 100; before, about 5 per snapshot plus the fixed part. Duplicate names within one request keep today's semantics (same file = retry, other file = 409), and are checked before anything is written.confirm_uploads(processing) now reads the build's blob rows in one query and only asks the store about unconfirmed files. MCPupload_snapshotsgoes through the same batch.Also:
approved_elsewhereandinheritedignore empty fingerprints, so a snapshot whose file never arrived can't match another.Migration:
2026_12_03_000000_blob_pdf_fingerprints(ALTER TABLE blobs ADD COLUMN pdf_fingerprint text).Tests (app/tests/fingerprints.rs)
image_hash: sha256match by file hash; without it the same entries don't; an unknownimage_hashis refused.Gates on agents-build-1: app
cargo fmt --check,cargo clippy --locked --all-targets -- -D warnings,cargo test --locked(all pass, golden files unchanged); workspacecargo fmt --all --checkand clippy for visualci-renderer. Load test (20 unchanged builds of 331 text snapshots,tests/load.rs, same box): 22.6 s on this branch, 51.3 s on main (49aa4c1).Rollout
Deploy order: this PR (server + renderer image, which CI rebuilds since crates/visualci-renderer changed; the renderer version and render cache keys are unchanged). Then the CLI PR, whose CI visual job uploads to production with the CLI it builds, so it needs this live. After that CLI is released, the docs'
VISUALCI_VERSIONlines move in their own commit. The old (fingerprint-sending) path stays supported until then.Not changed: server/ (legacy Loco). MCP's
classifystill fingerprints uploaded files in-process (PDF parsing included); it could pass no fingerprint now and leave PDFs to the renderer, as a follow-up.Shortcut: sc-8999