Repository navigation
chore(songs): retire the song duration backfill - #1227
Conversation
The backfill ran on production on 2026-11-19 (#1210): 27 written, 0 skipped, and no song now lacks a `duration`. Every new upload gets one from the `beforeChange` hook, so the script has nothing left to do. Removed with it is what existed only to serve it. `readAudioDuration` was split out of the hook in #1202 so the backfill could parse the same way, and #1219 gave it a stream source and a `size`. The hook is now its only caller and reads a buffer, so the parse folds back into `extractAudioDuration`. The spec's `readAudioDuration` cases were already covered one for one by the hook's own. One case stays from #1219, moved to the hook: a constant-bitrate MP3 with no Info header still gets a duration on upload. That is the shape of most songs stored before #1202, and the case fails if the hook ever parses a stream without its size. Refs #1210 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
This is the retirement its body describes, and nothing else: 384 lines out, 35 in, all removal or one relocated test helper. No reference to the deleted script, routine, spec or helper survives anywhere on the branch. The question a deletion owes — can a song still get a duration? — is answered: the upload hook covers every new song, and the one shape it could miss now has a hook-level test. Deleting a tool against an unmeasured future need is the right call here. No blockers.
Findings
consider—src/lib/audio/duration.ts:18, the new JSDoc paragraph explains the stream path this PR removes. Inline thread.consider—src/lib/audio/duration.ts:29sits outside the hunks, so no thread.Buffer.isBuffer(req.file.data) ? … : Buffer.from(…)predates this diff.importCollection.ts:289passesreq.file.datastraight toprepareUploadwith no guard, so the false branch looks unreachable. Worth deleting while the file is open. I could not read[email protected]'s own type: nonode_moduleshere.
What was checked
- Read whole on the branch:
duration.ts,audio-duration.spec.ts,music-metadata.spec.ts,scripts/AGENTS.md. - Grepped the branch for
readAudioDuration,AudioSource,parseWebStream,backfillSongDurations,audioBytes,song-durations: zero live hits. - Ladder: the diff adds no file, type, constant or dependency. One helper folds into its only caller.
- Each dropped
readAudioDurationcase has a hook case: 42 s, 9 s, no duration stated, non-audio bytes. All four confirmed. Meditations.ts:128andSongs.ts:53still mountextractAudioDuration, solib-boundary.spec.tsstill counts two consumers.- Every
tests/files/audio fixture is still referenced. The diff touches nofixture.surfacePaths, so no preview link is owed. Profile read.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
…g-duration-backfill
The JSDoc sentence "Audio whose container states no duration leaves it unchanged too, without a warning" restated the `duration == null` branch nine lines below it. The surviving sentence carries the one reason the code does not show: a parse failure must not fail the save. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWsX3kfDXGmrMX46yo
payload types `req.file.data` as `Buffer` (payload/dist/uploads/types.d.ts), so `Buffer.isBuffer` was always true and `Buffer.from` never ran. `prepareUpload` in the event import already passes the same value as a `Buffer` with no guard. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWsX3kfDXGmrMX46yo
|
Addressed the critic's review and pushed to Adopted
Rebutted
Merged 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
🚅 Deployed to the SahajCloud-pr-1227 environment in sahajcloud
1 service not affected by this PR
|
|
CI is red at one step: Railway's status on The error names #661 — a base environment that lost its domain. That is not this. PR #1229 deployed seven minutes later and got I may not write to Railway, so this needs a person: give the Filed #1230: the error asserts the production cause and calls a re-run futile, which misread this failure. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
sydevs-bot
left a comment
There was a problem hiding this comment.
Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. 🤖 Written by the sydevs autonomous loop — see what this is
The section above states Railway's rule as "only when the base service has one", which reads as "always when it does" — and the new section asserted the opposite case without saying how it arises. Name the rule for what it is: a necessary condition, not a guarantee. Why #1227's environment had no domain was never established, so the section now says so instead of implying a known mechanism. The remedy supplies an observably absent domain, so it holds under either reason. Also drops the last "configurations" where a domain was meant. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWHVvNJVKxVURK3BqF
Summary
The song duration backfill has done its job. It ran on production on 2026-11-19 (#1210) and wrote all 27 songs with 0 skipped, so no song lacks a
duration. New uploads get one from thebeforeChangehook. This PR removes the backfill and the code that existed only to serve it.Removed
scripts/backfill-song-durations.ts,scripts/song-durations.ts, and their two rows inscripts/AGENTS.md.tests/unit/backfill-song-durations.spec.ts.tests/utils/audioBytes.ts. Its one helper moves into the only spec still using it.readAudioDuration, itsAudioSourcestream variant, andsizeinsrc/lib/audio/duration.ts. feat(songs): store a song's audio duration, extracted on upload #1202 split it out of the hook so the backfill could share it, and fix(songs): read a CBR song's duration from a stream told its size #1219 added the stream path. The upload hook is now its only caller and reads a buffer, soparseBufferfolds back intoextractAudioDuration.Buffer.isBuffer(req.file.data) ? … : Buffer.from(…)coercion in the same hook. payload typesreq.file.dataasBuffer, so the false branch never ran.duration == nullbranch nine lines below it.Kept
durationfield andextractAudioDuration(Meditations with a 50-minute cap, Songs with none).src/lib/audio/still has its two consumers.tests/files/audio.song-duration.int.spec.ts,music-metadata.spec.tsand the preview fixture still use it.The
readAudioDurationcases removed fromaudio-duration.spec.tseach had a matching hook case already: 42 s, 9 s, no duration stated, and bytes that aren't audio.Test plan
eslint .,prettier --check .,tsc --noEmitsong-duration.int.spec.ts,meditation-duration.int.spec.ts: 15 testsRefs #1210
🤖 Generated with Claude Code