Repository navigation
fix(cli): the audio caches never write or read through links in .hyperframes - #7825
Conversation
…rframes The read-audio cache, its stems, mix and descriptions, and the audio-kind cache now use only real folders under the project's .hyperframes. A link or a file in place of a cache folder stops the write with a clear message. Every cache file is written to an exclusive temp file with a random name and renamed into place, so a link at a temp or final name is replaced, never written through. ffmpeg writes the voice-free mix into a private staging folder. Stem downloads use the new downloadToFile replaceLink option. Cached files are read only when they are plain files, and a stem list may only name files in its own folder.
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 5cd975b772450b2debf92b031a3c48c52280f166.
The writes reuse the shared atomic-file helpers, and the new planted-link regression tests exercise the real reader/download paths.
Important — incomplete cache-directory validation on reads: packages/cli/src/audio/analysis/kindCache.ts:75 validates the entry itself but does not validate its parent cache directories. A pre-existing directory link is still accepted on this read path, contrary to this change's stated scope. Apply the real-directory check to the complete cache directory chain before reading, and add regression coverage for .hyperframes and audio-kind. This is part of the targeted fix, despite also being present on the base.
Pre-existing follow-up: packages/cli/src/audio/read/describe.ts:170–186 does not anchor directory identity across awaited work. Stronger containment needs a separate design, such as private cache storage. The blocker above concerns static directory validation; concurrent directory replacement is a separate follow-up.
Validation: bun run build passed; gated CLI audio/download suite: 204 passed, 1 skipped. Restoring the five changed production files from the merge base made all nine new link cases fail. Separate local probes confirm the directory-read gap and the pre-existing asynchronous containment limitation. Windows junction behavior was inspected, not executed. Desktop release/pin and launcher validation remain outside this CLI patch.
Need: yes · Size: ok · Reuse: shared atomic-file and readPlainFile helpers · Simpler: already focused · Structure: fine (checked projectRecords and atomicFile; no split)
Risk: medium — filesystem writes run outside the agent sandbox.
— Rames Jusso (pr-review)
Verdict: REQUEST CHANGES
Reasoning: The static directory-link read path is still open in the cache this PR explicitly hardens. Validate those ancestors on reads and pin the behavior with a regression test.
readKindCache now checks that .hyperframes and audio-kind are real folders before it reads an entry, as writeKindCache already does before it writes one.
The replaceLink test now reads the file's bytes and lstat result once each, so no read follows a check on the same path.
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 6945818d702e7e8c49499cb90f897cb62ec6c09f, delta from 5cd975b772450b2debf92b031a3c48c52280f166.
My earlier blocker is fixed: readKindCache checks both cache-directory levels before reading. The added regression has valid cached data behind each directory link and a successful ordinary-file control. The last commit changes only the download test's read/stat assertions; runtime code is unchanged by that commit.
Validation: full build passed; gated audio/download tests: 205 passed, 1 skipped, plus both original reviewer ancestor-link probes passed. Reverting the read guard makes the new committed case and both probes fail; restoring it passes all three. The previously noted concurrent-directory replacement limitation and Desktop release/pin/launcher integration remain separate follow-ups. No Windows host or packaged Desktop run was performed.
Need: yes · Size: ok · Reuse: existing isRealFolder helper · Simpler: already minimal · Structure: fine (checked makeRealFolder/readPlainFile; no split)
Risk: medium — filesystem access outside the agent sandbox.
— Rames Jusso (pr-review)
Verdict: APPROVE
Reasoning: Both static ancestor-link read cases from my change request are now refused, with effective regression coverage and a focused test-only final commit.
jrusso1020
left a comment
There was a problem hiding this comment.
Re-approving at 24f23d7. The only change since my approval at 6945818d is a merge of main at bcf3d177 (the #7829 merge commit). All 10 PR files have byte-identical blobs and the same +/- counts against their merge bases before and after, so the PR's own code is unchanged, and main touched none of these files in between.
* chore: release v0.9.54 * chore: release v0.9.54 notes include heygen-com#7827, heygen-com#7825, heygen-com#7845, heygen-com#7848 and heygen-com#7849 * chore: release v0.9.54 notes include heygen-com#7853 * chore: release v0.9.54 notes include heygen-com#7851 and heygen-com#7855
What
The audio caches in a project's
.hyperframes/no longer write or read through links. This covershyperframes audio --read(its entries, stems, voice-free mix and descriptions in.hyperframes/read-audio) and the film queries' kind cache in.hyperframes/audio-kind.Why
A project can hold links that someone else planted, for example in a cloned repo or in files a tool wrote. Before this change, the cache writes followed them:
<entry>.<pid>.tmpand then renamed, so a link at that temp name had its target overwritten.-ytono-vocals.wav.<pid>.tmp.wav, which had the same problem.<name>.audiopoints to, andstems.jsonwas written through a link at its name.<id>.txt.tmp, and a link at<id>.txtwas read back as the answer.mkdir -paccepted a link in place of.hyperframes,read-audio,stems/<hash>,describeoraudio-kind, so every cache file landed in the folder the link points to.So running the audio reader on such a project could overwrite or create files outside it.
Related work
None open. This follows the same rule as the history lock records in #7821: a link is replaced, never written through.
How
replaceFileAtomically: an exclusive temp file with a random name, renamed into place. A link at the final name is replaced, not written through.createStagingDir, and the result is renamed into place.downloadToFiletakes a newreplaceLink: trueoption, which the stem downloads use. Without it,cloud getstill writes through a link the user names, as before.readPlainFile. A stem list may only name files in its own folder.Nothing changes for a project without links. The cache stays where it was, and cached results are still reused.
Test plan
New tests plant links before a read and check that every link target is unchanged:
read.test.ts: links at the entry's temp and final names; a link in place of.hyperframesand ofread-audio; links atvocals.audioandstems.jsonduring a stem download; a linked stems folder, and a stem list that names../paths; a link at the mix's old temp name.describe.test.ts: cached answers replaced by links to an outside file, and a link in place ofdescribe.kindCache.test.ts: a link at an entry, and a link in place ofaudio-kind.download.test.ts:replaceLinkreplaces an output link and does not copy the target's mode.All 9 new tests fail on
mainand pass here. They are skipped on Windows, where making a link needs extra rights.npx vitest run src/audio src/cloud/download.test.tsinpackages/clipasses (205 tests), andtsc --noEmit, oxlint, oxfmt, fallow and the comment ratchet are clean.