Repository navigation
feat(producer): enforce expected output dimensions before capture - #7871
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 76e404710412045d94f50ea82a5cb1b647eacdbe.
compileStage.ts:417–420 checks the actual compiled output size after resolution scaling, before the probe/capture stage, and only then records confirmation. renderRequest.ts and the distributed synthetic-job path carry the same optional constraint; JSON/SSE completion and planV2WithPublisher.onPlanned forward the result without inventing it. The documentation correctly requires consumers to reject missing confirmation from older producers.
Checked that distributed encoding uses the same rounded authored-size × DPR calculation. The plan's existing width/height fields still mean authored CSS dimensions, whereas the new constraint means final output pixels. Omitting the constraint preserves the old path and emits no confirmation.
Validation: full bun run build passed. Gated Vitest on renderRequest.test.ts, server.referenceBackground.test.ts, and compileStage.test.ts: 70 passed. Removing only requireOutputDimensions(...) makes both mismatch regressions fail. After restoration, the compile suite plus reviewer probes gives 32 passed, including 1920×1080 → 3840×2160 scaling, rejecting an authored-size expectation after scaling, and an omitted constraint with no confirmation. Gated bun test packages/producer/src/services/distributed/planV2.test.ts: 71 passed (the initial Vitest invocation could not collect this Bun-only suite). An independent adversarial source pass found no blocker. No full video render or deployed service request was exercised.
Scope: audited the new helper, request adapters, compile stage and changed HTTP/planning functions; traced their orchestration and chunk-encoding consumers. This is not a fresh audit of every unrelated branch of the large rendering pipeline.
Need: yes · Size: ok · Reuse: shared compile stage and existing strictVariables confirmation path · Simpler: already minimal · Structure: fine (checked resolution resolver, request adapters, and planner callback; no split)
Risk: medium — new cross-process contract requires consumers to handle absent confirmation explicitly.
Verdict: APPROVE
Reasoning: The check enforces compiled output pixels at the shared boundary and preserves optional behavior for existing callers. The positive, negative and scaled controls support the contract.
— Rames
jrusso1020
left a comment
There was a problem hiding this comment.
APPROVE at c1725f70 (re-stamp of 76e40471)
- Merge commit parents are
76e40471(the approved head) and mainc8235f1. The PR's own diff is unchanged: the sorted +/- lines against each merge-base are identical, with the same 14 files and +243/-3. - Safe-error allowlist conflict: the merge adds only
OUTPUT_DIMENSIONS_MISMATCHrelative to main and onlyCOMPOSITION_TOO_LARGErelative to the approved head. Neither side lost an entry, and there are no duplicates. - A real
OutputDimensionsMismatcherror and a real oversized-HTML error both keep their codes throughextractSafeRenderErrorMetadata.COMPOSITION_TOO_LARGEalso keeps owner=user and its bytes/limit metadata. Removing either code from the set makes the tests fail. - Full build, then 86 focused tests passing (errorCode, sizeLimit, compileStage, renderRequest, referenceBackground, plus a probe).
- Both commits are verified.
Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅
Risk: low for this delta. It is a merge of main with a two-sided allowlist resolution, and the contract risk is unchanged from the prior approval.
— Rames
What
Add an optional
expectedOutputDimensionsrender contract. The producer rejects compiled output whose dimensions differ before browser probe/capture, and reportsoutputDimensionsCheckedonly when that check ran.Why
Service callers need a reliable way to enforce a previously selected output size. Request metadata alone is insufficient because the compiler derives canvas dimensions from the HTML and output resolution settings.
Related work
Standalone producer capability; downstream integrations must require explicit confirmation when using it with mixed producer versions.
How
Carry the constraint through HTTP, render-request adapters and distributed planning into the shared compile stage. Return the confirmation in blocking/SSE results and the distributed
onPlannedcallback. The option does not resize content; existing callers that omit it retain their behavior.Test plan
docs/packages/producer.mdx.