Q-W3 review follow-ups: golden hash literal test, CLAUDE.md wav_codec bullet, dead RecordedCapture field comment, makeUniqueTag residual note

This commit is contained in:
2026-07-29 11:28:55 -04:00
parent 09f7173db2
commit 8bc5aa1257
4 changed files with 36 additions and 2 deletions
+19 -1
View File
@@ -9,7 +9,9 @@
// extraction (whole / tail window / clamp / out-of-range); truncate plan (kept<all,
// no-op keep-all, kept==0, grow rejected) with exact size-field values; patchU32LE;
// buildFloat32Wav golden header + parse round-trip; hashBytes/hashWavContent
// determinism, metadata-skip, fallback, and domain separation.
// determinism, metadata-skip, fallback, and domain separation; a golden hash
// literal pinning exact hex output for a fixed input (guards persisted
// contentHash values against a silent feed-sequence drift).
#include "../src/core/capture/wav_codec.h"
@@ -576,6 +578,21 @@ static void testHashMatchesBuildOutput() {
CHECK(hashWavContent(wav) == hashWavContent(withMeta));
}
// Golden hash literal (review follow-up, Q-W3): the tests above prove format,
// determinism, and relational properties (equal/different) of hashBytes and
// hashWavContent, but none of them pins the actual output bytes — a feed-sequence
// change (e.g. dropping the 'W' domain-separation prefix, or reordering the
// fmt/data feed) would pass every test above while silently invalidating every
// contentHash already persisted in existing projects' BankIndex JSON. This test
// locks a fixed buildFloat32Wav input's hashes against exact hex literals
// captured from the current implementation, so any such drift fails loudly here.
static void testGoldenHashLiterals() {
const std::vector<double> pcm = {0.0, 0.5, -0.25, 1.0, -1.0, 0.125};
auto wav = buildFloat32Wav(2, 48000, 3, pcm);
CHECK(hashWavContent(wav) == "7ccf298c166a670a");
CHECK(hashBytes(wav.data(), wav.size()) == "68d8a193c958fd44");
}
int main() {
testParseCanonicalStereo();
testParseMonoAndLeadingChunk();
@@ -600,6 +617,7 @@ int main() {
testHashWavContentListMetaSkipped();
testHashWavContentDomainSeparationFromWholeFile();
testHashMatchesBuildOutput();
testGoldenHashLiterals();
if (g_fail == 0) std::printf("wav_codec: all tests passed\n");
else std::printf("wav_codec: %d CHECK(s) FAILED\n", g_fail);