Report a two-lefts stereo collision instead of welding it silently (#11) - #45
Merged
Conversation
Closes #11. extract_volume collected each mono sample into a dict keyed by the filesystem name and paired stereo halves from that dict. A name is not unique on these filesystems, so where two distinct entries shared one name the second overwrote the first *before* find_pairs ran -- and its conservative "two lefts, no pair" guard, which exists precisely to refuse this, never saw the collision. The result was a stereo WAV welded from whichever same-named -L was walked last, reported as an ordinary Joined: the silent, unrecoverable wrong join ADR-0007 keeps the mono originals as insurance against. Carry each sample through find_pairs as an opaque payload beside its name, so no sample is ever collapsed and the guard sees the true multiset. find_pairs now returns a Pairing of clean matches plus the bases it refused, and extract yields a Skipped with a reason for each -- the same way it surfaces every other ambiguity it will not guess. The name-based join lookup is gone; a matched pair hands back the two sample objects directly. Not reachable on any disc in the collection today (ISO 9660 reads unique Joliet names per ADR-0019), but File.name has no uniqueness guarantee on the AKAI, E-mu or Roland backends, so it was latent. Adds the first test of what extraction does with two entries sharing a name. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11.
What was wrong
extract_volumecollected each mono sample intoparsed[entry.name] = sampleand then paired stereo halves withfind_pairs(list(parsed)). That made the filesystem name both the pairing input and the join lookup key — and a name is not unique on these filesystems.Where a backend yielded two distinct entries under one name, the second silently overwrote the first in that dict before
find_pairsran.find_pairsis deliberately conservative and refuses to pair a base that has two lefts — that guard exists precisely to catch this — but the dict collapse happened one step upstream of it, so the guard never saw two lefts. The pairing then welded whichever same-named-Lwas walked last to the-Rand reported it as an ordinaryJoined, with nothing saying a choice had been made.That is the exact failure ADR-0007 keeps the mono originals as insurance against: a wrong pairing is silent, produces a stereo file with two unrelated sounds in it, and — for a user who trusts the joined file — is found only in a DAW, weeks later.
How likely it is
Not reachable on any disc in the collection today. ISO 9660 now reads its unique Joliet names (ADR-0019), which closes the one path that previously produced colliding names, and its
.EBLshort names carried no-L/-Rmarker in any case. ButFile.namehas no uniqueness guarantee on the AKAI, E-mu or Roland backends, and a non-Joliet disc with colliding short names and a side marker would hit it. Latent, the same way #10's collision was before.EBLsupport was on the horizon.The fix
Carry each sample through
find_pairsas an opaque payload beside its name, rather than looking it up afterward by a name a second entry may share.extract_volumeaccumulates mono samples into an orderedlist[(name, sample)], not a name-keyed dict. Nothing can be dropped before the pairing sees it. This removes the collapse at its source.find_pairstakeslist[(name, payload)]and returns aPairing: the clean 1-1 matches (eachPairnow carrying the two sample objects, not names) and the bases it refused. Only the name drives the match, so it stays a pure name heuristic; the payload just rides along.interleaveis unchanged.Ambiguous, andextractturns each into aSkippedwith a reason. That matches howextractalready surfaces every other ambiguity it will not resolve on its own. A lone half with no opposite is still silently left as a mono sample, exactly as before.The name-based join lookup (
parsed[pair.left]) is gone entirely, which is what made this more than a one-liner.What this does not claim
Skipped(both mono halves still on disk) instead of a silent wrong join.Tests
Adds the first test anywhere of what extraction does with two entries sharing a name — the issue's
KICK -L / KICK -L / KICK -Rrepro, end to end against a synthetic AKAI disc: noJoinedis produced, aSkippedfor baseKICKnames the ambiguity, both lefts and the right are on disk (KICK -L.wav,KICK -L_2.wav,KICK -R.wav), and nostereo/directory is created. Thefind_pairsunit tests move to the new(name, payload)contract, and the two "ambiguous names are left alone" cases now assert the refusal is reported, not merely dropped.Verify
All four pass.
🤖 Generated with Claude Code