Skip to main content

docs/protocol/fixtures.md

# Protocol fixtures

QuackDB keeps cross-implementation binary fixtures under `test/fixtures/quack_ts/`.

The core fixtures are generated by the independent `quack-ts` implementation and assert byte-for-byte compatibility for scalar and nested `DataChunk` and `AppendRequest` encoding. Extra decode fixtures cover protocol values that are awkward to construct in broad fixtures or need targeted regression coverage.

## Current fixtures

- `data_chunk_scalar.bin` — scalar values including integer, varchar, boolean, decimal, date, time, timestamp, timestamptz, and blob.
- `data_chunk_nested.bin` — list, struct, array, and map values.
- `append_request_scalar.bin` — append request wrapping the scalar chunk.
- `append_request_nested.bin` — append request wrapping the nested chunk.
- `data_chunk_bignum_extra.bin` — zero, large positive, and large negative `BIGNUM` values.
- `data_chunk_temporal_extra.bin` — `TIME_NS`, `TIMESTAMP_NS`, `TIME WITH TIME ZONE`, and `INTERVAL`.
- `data_chunk_spatial_extra.bin` — WKB-compatible `GEOMETRY`.
- `data_chunk_nested_nulls_extra.bin` — null-heavy nested list, struct, and map values.

## Malformed fixtures

Malformed fixtures are QuackDB-owned negative-test payloads, not quack-ts conformance fixtures. They are intentionally invalid protocol messages used to verify that the decoder rejects corrupt input with a structured `QuackDB.Error` instead of crashing or silently returning the wrong value.

`test/fixtures/quackdb_malformed/data_chunk_bignum_bad_size.bin` contains a wrapped `DataChunk` with one `BIGNUM` value. DuckDB encodes `BIGNUM` values in a string-like payload where the first bytes describe how many magnitude bytes follow. This fixture claims a two-byte magnitude but only includes one byte, so decoding must fail with `:invalid_bignum`.

`test/fixtures/quackdb_malformed/data_chunk_extra_vector.bin` contains a wrapped `DataChunk` that declares zero logical types but encodes one `INTEGER` vector. This violates the chunk invariant before the vector can be paired with a logical type, so decoding must fail with `:data_chunk_type_mismatch`.

`test/fixtures/quackdb_malformed/data_chunk_missing_vector.bin` contains a structurally complete wrapped `DataChunk` that declares one `INTEGER` logical type but encodes zero vectors. This violates the chunk invariant that the logical type count and vector count match, so decoding must fail with `:data_chunk_type_mismatch`.

## Backlog

- Additional malformed vector bodies for unsupported compressed vector encodings.
- Unsupported logical type metadata fixtures for custom/extension types once DuckDB exposes stable payloads.
- FSST vector fixtures once DuckDB Quack serializes compressed FSST vectors instead of flattening them.