Skip to content

Commit f15ef13

Browse files
facontidavideclaude
andcommitted
refactor(decode): address review — trim test sweep, guard --hash
From /pr-review + /simplify: - Reduce the differential test's random sweep 1M -> 200k. The 1/2-byte fast paths are already proven exhaustively and the 3+ byte path is original code, so the sweep is supplementary; this keeps the ASan/Debug ctest ~1s. - Reject --hash without --decode-replay. The fingerprint pass lives inside the decode-replay block, so --hash alone silently printed nothing — a footgun for a correctness gate. Now errors clearly. ctest green; decoded-output fingerprint unchanged (0x75b0cc1fbc0457e9). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8e2d726 commit f15ef13

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

cloudini_lib/test/test_field_encoders.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,11 @@ TEST(FieldEncoders, DecodeVarintMatchesOracleExhaustiveAndRandom) {
257257

258258
// Randomized sweep over the general (3+ byte) path and all truncation
259259
// lengths, including malformed all-continuation and overflow-edge varints.
260+
// The 1- and 2-byte fast paths are already proven exhaustively above and the
261+
// 3+ byte path is the original code verbatim, so this sweep is supplementary
262+
// coverage of the interior; 200k keeps the ASan/Debug ctest run fast.
260263
std::mt19937_64 rng(0xC10D1217ULL);
261-
for (int iter = 0; iter < 1'000'000; ++iter) {
264+
for (int iter = 0; iter < 200'000; ++iter) {
262265
const size_t len = 1 + (rng() % 12); // up to 12 bytes (varint64 worst case is 10)
263266
for (size_t i = 0; i < len; ++i) {
264267
// Bias toward continuation bytes so we exercise long/overflowing varints.

cloudini_lib/tools/src/mcap_codec_benchmark.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,12 @@ int main(int argc, char** argv) {
290290
std::cerr << "Error: --decode-replay requires --mode so the in-memory replay stays bounded\n";
291291
return 1;
292292
}
293+
if (do_hash && !decode_replay) {
294+
// The fingerprint pass lives inside the decode-replay block, so without it
295+
// --hash would silently print nothing — a footgun for a correctness gate.
296+
std::cerr << "Error: --hash requires --decode-replay (and --mode)\n";
297+
return 1;
298+
}
293299

294300
if (!std::filesystem::exists(input_file)) {
295301
std::cerr << "Error: file does not exist: " << input_file << "\n";

0 commit comments

Comments
 (0)