Skip to content

chore(songs): retire the song duration backfill - #1227

Merged
Ardnived merged 4 commits into
mainfrom
chore/1210-retire-song-duration-backfill
Nov 20, 2026
Merged

Ardnived merged 4 commits into
mainfrom
chore/1210-retire-song-duration-backfill

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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 the beforeChange hook. 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 in scripts/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, its AudioSource stream variant, and size in src/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, so parseBuffer folds back into extractAudioDuration.
  • The Buffer.isBuffer(req.file.data) ? … : Buffer.from(…) coercion in the same hook. payload types req.file.data as Buffer, so the false branch never ran.
  • A JSDoc sentence restating the duration == null branch nine lines below it.

Kept

The readAudioDuration cases removed from audio-duration.spec.ts each 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 --noEmit
  • Unit lane: 282 files, 3832 tests
  • song-duration.int.spec.ts, meditation-duration.int.spec.ts: 15 tests

Refs #1210

🤖 Generated with Claude Code

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]>
@sydevs-bot

sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running
CI fix 1

recent dispatches
  • 23:10Z fix-ci · attempt 1 · session · done
  • 23:10Z fix-ci · attempt 1 · session
  • 22:50Z address-review · attempt 1 · session · done
  • 22:50Z address-review · attempt 1 · session
  • 22:44Z review-pr · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 19, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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:29 sits outside the hunks, so no thread. Buffer.isBuffer(req.file.data) ? … : Buffer.from(…) predates this diff. importCollection.ts:289 passes req.file.data straight to prepareUpload with no guard, so the false branch looks unreachable. Worth deleting while the file is open. I could not read [email protected]'s own type: no node_modules here.

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 readAudioDuration case has a hook case: 42 s, 9 s, no duration stated, non-audio bytes. All four confirmed.
  • Meditations.ts:128 and Songs.ts:53 still mount extractAudioDuration, so lib-boundary.spec.ts still counts two consumers.
  • Every tests/files/ audio fixture is still referenced. The diff touches no fixture.surfacePaths, so no preview link is owed. Profile read.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/lib/audio/duration.ts Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 19, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 19, 2026
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
@sydevs-bot

Copy link
Copy Markdown
Contributor

Addressed the critic's review and pushed to claude/relay-1227-0f3c4ed.

Adopted

  • duration.ts:18 — cut the states no duration sentence, which restated the duration == null branch (02fcc21).
  • Review body, duration.ts:29 — dropped the Buffer.isBuffer ternary (0f3c4ed). payload types req.file.data as Buffer, and prepareUpload already passes it unguarded.

Rebutted

  • Same thread — kept the buffer paragraph. It fences a future stream read rather than describing the deleted one, and carries the #1210 breadcrumb docs/rules/code-comments.md protects.

Merged origin/main cleanly, no conflicts. Lean gate green, plus the two duration int specs.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@railway-app

railway-app Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-1227 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Nov 20, 2026 at 12:10 am UTC
1 service not affected by this PR
  • mailpit

@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1227 November 19, 2026 22:59 Destroyed
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 19, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 19, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor

CI is red at one step: Discover Railway preview URL. Lint, typecheck and all 1977 tests passed. Nothing in this branch is broken, and no change here can turn the check green.

Railway's status on 0f3c4ed reads a bare Success with no host, so the smoke lane had nothing to test.

The error names #661 — a base environment that lost its domain. That is not this. PR #1229 deployed seven minutes later and got sahajcloud-sahajcloud-pr-1229.up.railway.app, which answers 200 on /api/health. The same host spelled for 1227 answers 404. Production is fine; this PR's own preview environment has no generated domain.

I may not write to Railway, so this needs a person: give the SahajCloud service in the pr-1227 environment a Railway-provided domain on target port 8080, or delete the environment so Railway recreates it. Then re-run CI.

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 sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 19, 2026
@Ardnived
Ardnived enabled auto-merge November 19, 2026 23:29

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Ardnived
Ardnived added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit d32df4e Nov 20, 2026
17 of 19 checks passed
@Ardnived
Ardnived deleted the chore/1210-retire-song-duration-backfill branch November 20, 2026 00:21
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 20, 2026
sydevs-bot added a commit that referenced this pull request Nov 20, 2026
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

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-1227 — 0f3c4edf Deployed Nov 19, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants