execution

Order of operations we actually used

  1. Pick the reference implementation. Rust first, because the type system catches the easiest mistakes (signed/unsigned, missing match arms) at compile time. Once 13 unit tests pass in Rust, freeze the golden hashes from the release build.
  2. Port to Go. Mirror the structure 1:1. The only language-shaped differences are: an explicit sort.Slice everywhere a Rust BTreeMap iteration is implicit, and fmt.Sprintf("t%d", n) in place of Rust's format!("t{}", n).
  3. Port to C++. Same structure again. Use std::map instead of std::unordered_map so iteration is sorted-by-key for free. Use std::ostringstream for the tag, never std::to_string with locale-aware formatting.
  4. Write the cross-language script last. Build all three CLI binaries, run both scenarios, assert pairwise equality and equality to the goldens.

Running it

$ cd db-15-sqlite-complete
$ bash scripts/verify.sh
=== Rust ===
... test result: ok. 13 passed; 0 failed
=== Go ===
ok      github.com/10xdev/dse/db15      ...
=== C++ ===
OK 13 tests
=== OK ===

$ bash scripts/cross_test.sh
=== scenario A: --seed 42 --ops 500 --keys 32 ===
  rust=e8ccacd39d8535c1ed101f0bc8b7a0799f56468a384da9284d4768cd8b3a3aab
  go  =e8ccacd39d8535c1ed101f0bc8b7a0799f56468a384da9284d4768cd8b3a3aab
  cpp =e8ccacd39d8535c1ed101f0bc8b7a0799f56468a384da9284d4768cd8b3a3aab
=== scenario B: --seed 7 --ops 2000 --keys 128 ===
  rust=dd1d6bb7fec1ffc9f71f01e75a58166b04517a669495af2aa2da432d4722db69
  go  =dd1d6bb7fec1ffc9f71f01e75a58166b04517a669495af2aa2da432d4722db69
  cpp =dd1d6bb7fec1ffc9f71f01e75a58166b04517a669495af2aa2da432d4722db69
=== ALL OK ===

Things that went wrong in development

  • First Go run produced a different hash for scenario A. Cause: ranging directly over c.secondary instead of collecting keys and calling sort.Strings. The fix is in src/go/sql15.go; see DumpSnapshot.
  • First C++ run also diverged. Cause: std::unordered_map instead of std::map. Same fix shape — switch container, or sort keys before iteration. We chose std::map for symmetry with Rust's BTreeMap.
  • A test asserted SHA256("abc") and failed. Typo in the expected hex string (extra 3, missing trailing d). The canonical value is ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad. Worth pinning a known SHA-256 vector in every cross-language lab.