Repository navigation
fix(cli): the project server leaves out pictures the run itself saved - #9086
miguel-heygen wants to merge 13 commits into
Conversation
terencecho
left a comment
There was a problem hiding this comment.
Changes requested at e058db00.
- [P1] Authorize and serve the same open file.
packages/cli/src/utils/staticProjectServer.ts:419checks a pathname and opens it separately for the response. If the file changes during that request, the identity checked can differ from the file served. Check the identity on the handle used for the response. The current overwrite test covers sequential requests. - [P2] Handle lookup errors in the request.
packages/cli/src/utils/savedThisRun.ts:7can throw on filesystem errors such as an inaccessible file. Once an output has been registered, that exception can leave the request unanswered and exit the CLI. Handle lookup failures without serving an unverified file or crashing the command.
The Linux CLI build, five focused tests, and the existing Chromium keyframes filmstrip test passed. The findings are from source inspection. #9079 is approved and remains open. The stacked head has no Linux CLI or Windows CI result, so those checks are still needed on the retargeted head.
— tai (automated review)
…ips-this-runs-pictures # Conflicts: # packages/cli/src/commands/motionShot.ts # packages/cli/src/utils/screenshotsOutsidePage.chromium.test.ts
Edit accuracy: accurate 275 (base branch 273), smooth 55 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
|
Answering the review at e058db0; new head 4e525e6, now on main with main merged in (#9079 landed, so the diff is this change only).
Run at bce0595, which differs from this head only in one test: lint, format, tsc, the Fallow audit, pre-push and the CLI tests that cover a changed file, all green except Windows CI at 4b58b8b had one red row, the P1 one: the simulated overwrite was not answered with a picture. I read that as Windows refusing to replace the open file; the row now records whether the overwrite was refused and expects the project's own picture either way. I have not run it on Windows outside CI. |
terencecho
left a comment
There was a problem hiding this comment.
The direct-file path now checks and serves the same handle, and the targeted lookup and open failure tests pass. The proxy path still needs the same guarantees.
- P2 — Bind proxy generation to the authorized source. In
packages/cli/src/utils/staticProjectServer.ts:352, the codec probe, transcode, and final authorization can observe different file versions. Keep one authorized source identity through the pipeline, or use an approved immutable input for both the probe and transcode. - P2 — Check the opened proxy copy before streaming. In
packages/cli/src/utils/staticProjectServer.ts:312, apply the saved-file and regular-file checks to the opened copy itself before serving it. The source check covers a different file.
41 targeted tests passed on Linux. The proxy findings are from source inspection. Real transcoding and other platforms were unverified locally. The PR now targets main and the CLI and Windows checks are running.
— tai (automated review)
…le it was made from
|
Answering the review at 4e525e6; new head da46a6e. Both findings were right. The first one was worse than a late check. With real ffmpeg, on 4e525e6: a clip is replaced while its copy is made, the response is 404, but the copy stays in the cache under the original's key. With the original back in place, the next request got the other picture.
What changes for every user of the pipeline (Studio preview, Nine new rows. "keeps no copy made while the file was moved away and back, and makes the next one", "neither copies nor serves a file in any state but the one the caller checked", "does not join a copy being made from another state of the file", "does not file a finished copy under a file that changed while its content was read", "makes every piece again once the file was moved away and back", "copies only the file it checked, when another takes its name during the codec probe" and the two "answers a copy that is ..." rows each failed on 4e525e6's code, run before the interface was simplified. "does not serve a finished copy for a file that changed while it was looked up" was added after that and was shown red by removing its check. Thirteen deliberate breaks each turn a row red; so do the ten earlier ones that still apply (the eleventh is now one of the thirteen). Real transcoding, through the real server with a 40 s ProRes clip, read back as colours: untouched, 200 and the right picture; replaced by a file this run saved, 502, no copy left, then the right picture once the original is back; moved away and back, 502, no copy left, then the right picture. The built CLI was probed again with this code: no page loads a saved picture, and every picture is still saved. Run at da46a6e: lint, format, tsc in both packages, the Fallow audit, pre-push, the named tests three times, and the tests that cover a changed file, green except Package size: this head packs to 787,454 bytes unpacked with the CI command; the limit with its 1% tolerance is 787,524. No budget was raised. Windows, which the previous comment left unconfirmed: CI at 4e525e6 passed, and on a Windows 11 machine replacing an open file is refused (EPERM). There, on macOS and on Linux, moving a file away and back changes its version, and the path and the handle report the same one. Not proven: the copy rows on Windows outside CI, Studio's preview in a browser, and a change within the filesystem's own time tick (a few milliseconds on Linux), which no version of this kind can see. |
|
New head 11d1b07: one test edited, no source change since da46a6e. Windows CI at da46a6e had one red row, the new "copies only the file it checked, when another takes its name during the codec probe". Its mocked probe replaced the clip synchronously, while the server still held the handle it had checked, and Windows refuses that. The row now replaces it one step later, after the handle is closed. Refusing the replacement on Linux in the same way gives the same assertion failure with da46a6e's test and passes with this one. It passed three times here, and still fails when the server does not pass the checked file on. Not run on Windows outside CI. Correction to the previous comment: it lists Windows as unproven for the copy rows "outside CI"; inside CI this row had not passed yet either. |
terencecho
left a comment
There was a problem hiding this comment.
The test now waits for the checked handle to close. The opened-copy checks also reject saved pictures and directories. Two source-identity issues remain.
- P2 — Keep the verified source through the proxy pipeline. At
packages/studio-server/src/helpers/proxyTranscoder.ts:1185, FFmpeg still opens a pathname independently of the verified source. The later check guards publication, but the probe, hash, and encoder still lack a shared source. Use the verified handle or one verified immutable input throughout. - P2 — Include the verified source version in fast cache lookups. At
packages/studio-server/src/helpers/proxyCacheKey.ts:31, the key uses pathname, modification time, and size for source identity. A same-size replacement with a preserved timestamp can receive the previous file’s proxy. Include the verified version before accepting a fast hit.
39 targeted tests passed on Linux. The two findings are from source inspection. Real FFmpeg and local Windows execution were unverified. Windows verification and the Linux CLI shards passed in CI.
— tai (automated review)
|
Both points are fixed at c26b775 (main merged in first, at 3247ab9).
fails without the fix:
Costs and limits:
|
What
The server that loads a project for
snapshot,keyframes --shot,checkand the other page commands no longer serves pictures the same run saved into the project folder.Why
snapshot -o <a folder in the project>andkeyframes --shot <a file in the project>save their pictures while the composition is still open. The project server then served them as if they were the project's own assets, so a page could load the run's output while the run was still making it. What a frame shows must not depend on frames saved before it.Related work
Stacked on #9079, which touches the same lines of
motionShot.ts.How
utils/savedThisRun.tsremembers each file the process saved, by device, inode and birth time rather than by path. A link, another letter case or a later file at the same path is told apart correctly.writeCaptureFileSync(frames, crops, reference frames, contact sheets) and the onesaveShotinmotionShot.ts. Saving and remembering are one synchronous step, so no request is answered between them.staticProjectServer.tsleaves such a file out, next to the rule that leaves out.hyperframes.Every command that loads a page and saves a picture, run through the built CLI on main (ef1d5db) with a page that keeps asking for the files:
snapshot -o outsnapshot -o out --zoomkeyframes --shotcompare --out(saved after its pages close)check --snapshots(saved under.hyperframes)snapshotwith no-osaves under.hyperframes, which the server already left out.grade-compareloads a temporary folder of its own, read and not run.A picture that an earlier run left in the project is an ordinary project file, and still served: compositions use such files as assets.
Test plan
fails without the fix:
packages/cli/src/utils/savedThisRun.test.ts("never serves a picture this run saved into the project", "refuses the picture under any other name for the same file", "stops serving an asset once this run saves its picture over it"). The other two rows pin what must still be served: "keeps serving every file this run did not save" and "serves a file another program puts where this run saved one". The filmstrip row ofscreenshotsOutsidePage.chromium.test.tsnow also asserts that the shot is remembered.