Repository navigation
feat(cli): record bounded previews for oversized evidence artifacts - #78
Merged
Merged
Conversation
Screenshots were going into evidence at full capture resolution, which is what a vision model pays for: its cost scales with pixel area, not file size. A 4K capture costs six times a 1568px one to read. Compression is the wrong lever and measurement says so. Against a 1280x800 and a 3840x2160 capture, re-encoding PNG through the image crate lands at 112-113% of the original, image-webp lossless at 111%, and JPEG q82 at 99% and 123% while also being lossy. libwebp does halve it, but it needs a C toolchain and breaks cargo check for x86_64-pc-windows-msvc, which this crate verifies. So keep the artifact byte-identical and derive a bounded preview instead. When a source exceeds 1568px on its longest edge it is downscaled with Lanczos3 and stored beside the original; the document records source dimensions and, when one exists, the preview's path, dimensions, bytes and digest. The report prefers the preview. Nothing is generated below the cap. Previews count against the total image budget so a run cannot evade the cap by producing many of them, and an aliased source still yields one artifact and one preview. The document version becomes 2, but the input contract does not move: the new fields are derived here, never submitted, so a v1 document still records and gets a v2 document back.
…view The report listed the preview's path, dimensions and digest in place of the original, so a reader of report.md alone could neither reach the primary evidence nor verify its hash. A derivative standing in for the thing it derives from defeats the point of an evidence document. List the full capture as the entry and nest the preview under it. Both carry their own dimensions, byte count and digest.
Rust 1.98 clippy flags `&a.sha256` inside format! as useless_borrows_in_formatting, and CI runs with -D warnings.
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.
Sixth and last PR of the #64 stack, on top of #70.
Why
Screenshots went into evidence at full capture resolution. That is what a vision model pays for: cost scales with pixel area, not file size, so a 4K capture costs about six times a 1568px one to read. It also makes plain evidence folders heavy.
Compression was measured and rejected
Against a 1280x800 and a 3840x2160 capture:
cargo checkforx86_64-pc-windows-msvc, which CI verifiesNothing pure-Rust makes the files smaller, and the token cost would not have moved anyway.
What ships instead
The artifact stays byte-identical, and a bounded preview is derived beside it.
Verification
cargo test -p pickforge-cli: all green locally after rebasing onto main.