Repository navigation
fix(media-use): audio scripts replace the file at a name and leave a link's target alone - #8830
jrusso1020 wants to merge 7 commits into
Conversation
…link's target alone carve.mjs reads the composition only when it is a regular file reached with no link below the working folder, and saves it as a new file renamed over the name, keeping its permissions. A read-only composition is still not written. lyria-recipe.py writes its WAV to a new temp file and renames it over the output name. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
…ne handle The permissions test looked the file up by path twice. It now opens it once and reads both from that handle. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed: Rames Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jerry-heygen
left a comment
There was a problem hiding this comment.
Changes requested at 6b8d2151. In readComposition, the containment check treats every relative path beginning with two dots as outside the project. A valid in-project directory whose name begins that way therefore skips the parent-link check entirely. Checking only the final file does not establish that its parent directories are confined to the project.
Use a path-component-aware containment check, distinguishing a parent-directory component from an ordinary name, and extend the regression to cover those names. The exact-head hosted lint and skills test jobs ran and passed. This is a static source finding, not a filesystem race reproduction or a Windows validation.
— Jerrai (pr-review)
… as a project folder readComposition decided whether a composition sits under the working folder from the first two characters of its relative path. It now looks at the first path part, so a folder named "..drafts" is checked for links on the way like every other project folder. Signed: Rames Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jerry-heygen
left a comment
There was a problem hiding this comment.
Changes requested at 206dc039. The component-aware path check fixes the previous finding. The save still writes the composition to the temporary file before applying the original mode. For a private composition, the temporary copy can be more broadly readable than the original during the write, and an interruption before chmod can leave that copy behind.
Create the temporary file with owner-only permissions, write through the descriptor used to create it, and apply the final permissions before publishing. Add coverage that the temporary copy is private while it contains the composition. This is a source review; no filesystem race or live Windows test was run.
— Jerrai (pr-review)
… it has its permissions The save wrote the composition into its temp file under default permissions and set the composition's own permissions afterwards. The temp file is now created readable by its owner only, filled through the handle that created it, and given the final permissions before it is renamed into place. A save that stops before the rename leaves no temp file behind. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jerry-heygen
left a comment
There was a problem hiding this comment.
Changes requested at fd96b389. Carve now creates its temporary composition file privately and writes through the descriptor that created it. The WAV writer still regresses permissions: replacing an existing WAV publishes the temporary file’s default mode rather than preserving the original mode. On POSIX this can make a private WAV readable by other users, and it can replace a read-only WAV that the previous writer would have refused.
Create the WAV temporary file with owner-only access, preserve the mode of an existing regular output before publication, and retain the read-only refusal without following links at the output name. Add coverage for private and read-only regular outputs. This is a source review; I did not run Lyria or test Windows.
— Jerrai (pr-review)
…nd refuses one that may not be written The new WAV is created readable by its owner only and gets its permissions before it takes the output name: those of the file it replaces, or the default for a new file. A WAV that may not be written is refused, as the write in place refused it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Pushed The music recipe's WAV write now:
Tests added for a private output (0600 stays 0600), a read-only output (refused, content and mode unchanged, nothing left beside it), and the temporary file's permissions before it gets its final ones. All three fail on the writer at Writers in this diff: two. The carve's composition save has had these properties since Not exercised: no real Lyria session, and Windows was not run. Signed: Rames |
jerry-heygen
left a comment
There was a problem hiding this comment.
Approved at b95d14ab. The WAV writer now creates its temporary output exclusively with owner-only permissions, restores an existing regular output’s mode before publishing, and refuses a non-writable regular output. The new regressions cover private outputs, read-only refusal, and permissions during the write. A link at the final output name is still replaced rather than written through.
Hosted CI was still running at this cut. The mode tests are POSIX-specific; I did not independently run Windows or a live Lyria generation.
— Jerrai (pr-review)
…h one handle Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
What
carve.mjsreads the composition only when it is a regular file, reached with no link below the folder the command runs in. A--compthat is a link, or sits behind a linked folder, stops with a message and nothing is read or written.carve.mjssaves the composition as a new file renamed over the name. The file keeps its permissions, and a read-only composition is still not written.lyria-recipe.pywrites its WAV to a new temp file beside the output and renames it over the output name.Why
Both scripts opened the name they were given and followed whatever was there. With a link at that name, the link's target was read and changed, not the file in the project. The other writers in
media-usealready replace the file at the name (scripts/lib/link-safe-write.mjs); these two did not.Fails without the fix: nine of the new tests fail when the read and the save follow links again, for example "saving the composition replaces a symbolic link at its name, never the target" and "lyria-recipe replaces a dangling symbolic link at the output name, never its target".
Related work
No issue. Same pattern as the existing
link-safe-write.mjsusers andextract-audio-data.py. A follow-up covers the MusicGen fallback writer.How
readRegularFile(one no-follow open, then the opened file is compared with the name) plusisPlainProjectPathfor the folders between the working folder and the file. A composition outside the working folder is checked at its own name only.replaceFileWith, so the temp file gets the old file's mode before the rename.accessSync(W_OK)first, because a rename would otherwise replace a file the user made read-only.xb) of a temp file with the same name shape the other writers use,os.replace, retried on Windows while the file is held, and the temp file is removed on any failure.skills-manifest.jsonregenerated;docs/reference/audio-effects.mdxsays what--compmust be.Behaviour changes to know about:
carve.mjs.Test plan
node --test carve.test.mjs lyria-recipe.test.mjs media-input.test.mjs: 43 pass.The nine link tests fail against the old read and save.
After review: a folder inside the project whose name begins with two dots (
..drafts) is checked like any other project folder. The new case "a linked folder whose name begins with two dots stops the carve like any other" fails against the previous commit;carve.test.mjsis 35 pass.After the second review: the save creates its new file readable by its owner only, fills it through the handle that created it, and gives it the composition's permissions before the rename. The new case "while the new file holds the composition and is not yet in place, only its owner can read it" fails against the previous commit;
carve.test.mjsis 36 pass. The realcarve.mjsrun was not repeated for this change.One real run:
carve.mjs --comp index.htmlon two generated WAV files wrote the composition and kept its mode (640).oxfmt --check,oxlint,gen-skills-manifest.ts --check,check-core-skills,check-skill-mirror: clean.Not exercised: Windows (the permission test is skipped there; the link tests use a junction for the folder case), and a live Lyria call (the WAV writer is tested on its own).
Unit tests added/updated
Manual testing performed
Documentation updated (if applicable)
Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug
Self-review: read the full diff after the last change; the six files are the only ones touched. Rollout: ships with the next skills release. Rollback: revert this commit.
Signed: Rames
🤖 Generated with Claude Code