Skip to content

Releases

v0.5.0 — Production Hardening, Bounded Durability & Crash Recovery

Choose a tag to compare

@vubon vubon released this 21 Nov 05:15

[v0.5.0] — 2026-11-21

⚠️ Upgrade & Compatibility Notes

  • Upgrading from v0.4.0 (KDB\x05): Snapshots where all KV entries carry full key names load automatically and upgrade to Snapshot Format V7 (KDB\x07) on the next save.
  • Upgrading from v0.3.x or older (KDB\x02–KDB\x04): Legacy snapshots containing KV entries (kv_count > 0) are intentionally rejected at startup (SnapshotError::MissingKeyBytes) because pre-v0.4.0 snapshots persisted only one-way 64-bit hash digests without original key bytes. To enforce full key identity and eliminate silent hash-collision aliasing, migrate from a complete source or back up and start fresh (vector-only V2–V4 snapshots with 0 KV entries still load directly).
  • Legacy Snapshot + Non-Empty AOF: Pairing an uncheckpointed legacy snapshot with a non-empty AOF whose recovery base cannot be proven now fails fast with a migration error instead of risking silent state divergence.
  • Strict Protocol Bounds: Client commands exceeding 64 MiB total frame size, 2 MiB per bulk argument, or 65,536 arguments are now rejected upfront.

🛡️ Production Hardening, Bounded Durability & Crash Recovery (ADR 6)

  • Coordinated AOF Background Rewrite Engine (BGREWRITEAOF):

    • Implemented live, concurrent append-only log compaction via BGREWRITEAOF without stalling foreground client command processing.
    • Snapshot base capture under unified commit fence (durability::with_commit_fence) freezing KV entries, expiration deadlines, and vector graphs (HNSW and Flat).
    • Bounded in-memory delta buffer (64 MiB / 65,536 journal records) tracking mutating client operations during snapshot capture; cleanly cancels background rewrite if delta capacity exhausts.
    • Writer thread atomic cutover: flushes delta records, fsyncs replacement file, performs atomic rename over active journal, swaps file descriptors retaining write locks, and synchronizes parent directory (sync_directory).
    • Standalone log recovery through scan_base and streaming ChecksummedReader validating IEEE 802.3 CRC32 checksums before hydrating in-memory state.
  • Full Key Byte Identity & Snapshot Formats V6 / V7 (KDB\x06 / KDB\x07):

    • Enforced full byte-for-byte equality verification (entry.key() == key) during SwissTable probing, eliminating false-positive key hits across colliding hash fingerprints.
    • Slot-scoped overflow storage (slot_overflow_keys) mapping unique slot indices to heap-allocated key bytes for keys exceeding 40 bytes, preventing hash collisions from overwriting neighboring entries.
    • Snapshot Formats V6 (KDB\x06) & V7 (KDB\x07): Persists explicit key lengths and full key bytes for every KV entry alongside journal checkpoints and HNSW vector graphs (KDB\x07 is the canonical active format). Automatically upgrades named V5 snapshots while rejecting anonymous V2–V4 KV entries (MissingKeyBytes) to prevent silent key aliasing.
  • Bounded Connection Ingress & Frame Parser Caps:

    • Enforced strict 64 MiB ingress buffer capacity limits across epoll, io_uring, and TLS plaintext byte streams, proactively mitigating memory-exhaustion denial of service.
    • Introduced CommandFrameDecoder enforcing upfront protocol constraints: 64 MiB total command frame length, 2 MiB bulk argument cap, and 65,536 maximum argument count.
    • All parser pointer offsets and size computations use checked integer arithmetic (checked_add, checked_mul) preventing integer overflow exploits.
    • Frame boundary parser reset prevents deserialization state leakage across pipelined commands; isolated historical AOF replay via parse_command_frame_for_replay.
  • Atomic Two-Phase MSET (MSET):

    • Implemented strict two-phase commit (2PC) reservation and write execution across SwissTable shards.
    • Pre-allocates and reserves slots before mutation; rolls back cleanly upon arena exhaustion or validation failure, guaranteeing all-or-nothing atomicity with zero partial writes.
  • Bounded Durability Queue & Safe Checkpoint Recovery:

    • Dedicated background AOF writer thread consuming mutations over a bounded, lock-free ring channel.
    • Graceful server shutdown barrier draining pending write records prior to process exit.
    • Crash recovery guarantees: replays strictly the log suffix past the proven checkpoint sequence number, validating IEEE 802.3 CRC32 record checksums.
  • Slot Lifetime Synchronization & Cross-Worker Deallocation:

    • Expiration re-check in advance_expired_entries ensures live keys updated concurrently are never evicted prematurely.
    • Cross-worker deallocation inboxes prevent memory leaks and slot corruption during cross-thread frees.
    • Bounded timing wheel bucket sweeps prevent latency spikes during large forward clock jumps.

v0.4.0 — Keyspace Cursor & Pattern Scanning (SCAN, HSCAN)

Choose a tag to compare

@vubon vubon released this 08 Nov 07:05

[v0.4.0] — 2026-11-08

🔍 Keyspace Cursor & Pattern Scanning (SCAN, HSCAN)

  • Stateless Bit-Reversed Cursor Over SwissTable Shards:
    • Implemented SCAN <cursor> [MATCH pattern] [COUNT count] [TYPE type] across 256 independent SwissTable shards.
    • Implemented home-bucket bit-reversed iteration (next_bit_reversed_cursor) over probe chains originating at h1(key_hash, cap) == home_bucket, mathematically guaranteeing zero skipped keys across open-addressing table growth (grow), shrink-on-delete (shrink), and tombstone back-shift compaction (compact_one_group).
    • Bit-packed 53-bit cursor ((local_cursor << 8) | shard_idx) guarantees lossless roundtrips in JavaScript/JSON runtimes (< Number.MAX_SAFE_INTEGER).
    • Amortized shard lock acquisition: batches up to 256 home buckets per read lock acquisition, with bounded per-call step (MAX_BUCKETS_PER_STEP = 4096).
    • Empty database fast-path: checks shard.is_empty() across all 256 shards in $\mathcal{O}(1)$ and returns cursor "0" in a single network round-trip.
  • Single-Pass Hash Scanning (HSCAN):
    • Implemented HSCAN <key> <cursor> [MATCH pattern] [COUNT count] reading bounded in-slot Megaslab frames ($\le 4\text{ KB}$, $\le 128$ field-value pairs) in a single pass.
  • 40-Byte Inline SSO & Zero-Bloat Key Storage:
    • Replaced 42 bytes of unused padding in HashEntry (_pad: [u8; 42]) with key_len: u16 and inline_key: [u8; 40].
    • Preserved exact 64-byte L1 CPU cache-line alignment (size_of::<HashEntry>() == 64) and size_of::<TableEntry>() <= 24, resulting in 0 bytes of memory bloat per slot across all 256 shards.
    • Keys $\le 40$ bytes are stored 100% inline with zero heap allocations on the write hot-path.
    • Keys $&gt; 40$ bytes store their 40-byte prefix inline in L1 cache and full key bytes in shard-local SwissTable::overflow_keys: HashMap<u64, Box<[u8]>>, leaving Megaslab value slots 100% unmodified.
  • Zero-Allocation Glob Pattern Matching Engine:
    • Fast iterative byte-level glob matcher supporting wildcards (*, ?), character classes ([abc], [a-z]), negation ([^abc], [!abc]), and escape sequences (\x).
    • Single-star backtrack anchor preventing exponential ReDoS backtrack vulnerabilities (CVE-2022-36021).
    • CompiledPattern literal-prefix fast-path evaluates and rejects non-matching keys directly from the 40-byte L1 prefix before ever accessing overflow_keys.
  • Snapshot Format V5 (KDB\x05):
    • Introduced Snapshot V5 format persisting [key_len: u16][key_bytes] alongside each KV payload.
    • Full backward compatibility: seamlessly loads legacy V2, V3, and V4 snapshots without keys (key_len = 0), logging a warning and lazily upgrading them on write (SET, HSET, EXPIRE, PERSIST) or AOF recovery.
    • Added anonymous_keys:<count> metric to INFO command.
  • Protocol Error Handling & Wire Framing Decoupling:
    • Added parse_command_frame to cleanly decouple wire transport framing from command argument validation.
    • Semantic command errors (InvalidCursor, SyntaxError, WrongArgumentCount, PatternTooLong) consume the frame, return -ERR ...\r\n to the client, and keep the TCP connection alive.
  • Compaction & AOF Rewrite Integrity:
    • Fixed BGREWRITEAOF in kachedb-server to serialize VALUE_TYPE_HASH entries using HashSlotFrame::encode_pairs as AofOp::HSet (rather than string Set), and emit follow-up AofOp::Expire frames when expire_at > 0.
  • CLI & Benchmarking Tools:
    • Updated kachedb-cli snapshot-info forensic inspector to recognize and validate KDB\x05 plaintext and encrypted snapshots.
    • Added --command SCAN support to the native kachedb-bench harness.
  • Python Client SDK (kachedb):
    • Added native scan() and hscan() methods with MATCH, COUNT, and TYPE filtering to KacheClient.
    • Added Pythonic generators scan_iter() and hscan_iter() for seamless multi-page iteration.
    • Added unit test suite covering mock wire payloads and live client round-trips against KacheDB daemon.

v0.3.2 — Container Restart Persistence Fix & Deterministic XXH3 Hasher

Choose a tag to compare

@vubon vubon released this 06 Nov 18:03

[v0.3.2] — 2026-11-07

🐛 Bug Fixes & Persistence Reliability

  • Zero KV Data Loss on Container Restarts (dump.kdb):
    • Fixed a shutdown ordering race where worker threads dropped their thread-local SlabPool arenas upon exiting their event loop before the snapshot worker could capture state. Dropping pools unregistered MegaslabArenas from GLOBAL_ARENAS, causing resolve_slot_ptr() to return None and overwriting dump.kdb with 0 KV keys.
    • Introduced ShutdownBarrier in kachedb-net, ensuring worker threads pause after halting network event loops while keeping their memory pools fully allocated and registered.
    • The main server thread now deterministically halts connection dispatch, signals background workers, performs the final shutdown snapshot, and only then releases worker threads for orderly memory reclamation.
  • Cross-Process Deterministic Key Hashing (kachedb-hash):
    • Switched hash_key in SwissTable from per-process randomized AHasher::default() to xxhash_rust::xxh3::xxh3_64.
    • Guarantees that key hashes saved in dump.kdb remain 100% deterministic and reachable across server and container restarts across all CPU architectures.
    • Added deterministic hash stability regression tests in crates/kachedb-hash.
  • Dynamic Version Metadata & Python Bindings:
    • Synchronized HELLO, INFO, and daemon startup logs to compile-time env!("CARGO_PKG_VERSION").
    • Bumped Python bindings in bindings/python to 0.3.2.

v0.3.1 — Python SDK Redis Hash Methods & Array Support

Choose a tag to compare

@vubon vubon released this 04 Oct 17:18

[v0.3.1] — 2026-10-05

🐍 Python SDK Redis Hash Methods & Array Parsing

  • Redis Hash Commands in KacheClient (bindings/python):
    • Added native hash methods: hset (with single-pair and dict mapping support), hget, hdel, hexists, hlen, and hgetall.
    • Implemented recursive RESP array (*) decoding in _read_response().
    • Added mock socket unit tests and live hash roundtrip tests in test_client.py.

⚙️ CI & CLI Enhancements

  • Toolchain Determinism: Pinned workspace and CI Rust toolchain to 1.97.1 via rust-toolchain.toml and GitHub Actions workflows.
  • One-Shot CLI Execution: Added kachedb-cli -p <PORT> <COMMAND> [ARGS...] for one-shot command execution and Docker healthchecks.

v0.3.0 — Redis Hash Primitives & Sub-25ns In-Slot Directory

Choose a tag to compare

@vubon vubon released this 04 Oct 16:42

📦 Redis Hash Primitives (HSET, HGET, HDEL, HEXISTS, HLEN, HGETALL)

  • Strict O(1) In-Slot Open-Addressing Directory:
    • Implemented in-slot open-addressing directory packed directly inside pre-allocated 64-byte aligned Megaslab slots, eliminating pointer fragmentation and cache misses.
    • Achieved sub-25 ns point lookups (HGET, HEXISTS) resolving within a single L1 CPU cache line.
    • Zero heap allocation on the hot path for requests with $\le 8$ field-value pairs (SmallVec stack buffer).
  • Megaslab App-Cache Slot Isolation:
    • Hashes strictly reside in AppSmall (128 B), AppMedium (512 B), or AppLarge (4 KB) slots, completely isolated from tensor slab pools.
    • Automatic slot resizing and pair relocation as fields grow, capped at 4096 bytes per hash key.
  • Strict Type Guards & SwissTable Type Tag:
    • Added value_type tag (VALUE_TYPE_HASH = 1, VALUE_TYPE_STRING = 0) to HashEntry SwissTable metadata.
    • Added type guards across all string commands (GET, APPEND, STRLEN, INCR, DECR, INCRBY, DECRBY) returning -WRONGTYPE Operation against a key holding the wrong kind of value.
    • Updated TYPE command to return hash, string, vector, or none. MGET returns nil for non-string keys.
  • ACID Persistence & Snapshot Format V4 (KDB\x04):
    • AOF Logging: Hash mutations logged as logical pairs with opcodes 0x07 (HSet) and 0x08 (HDel), ensuring deterministic append-only journal replay.
    • Snapshot Format V4: Introduced KDB\x04 format with typed record headers (RecordType = 0x01 for Hash) supporting both plaintext and hardware-accelerated encrypted snapshots (AES-256-GCM / ChaCha20-Poly1305) with seamless backward-compatibility for legacy KDB\x02 and KDB\x03 formats.

🛠️ Architecture & Tooling Modularization

  • Modularization of kachedb-net/src/connection/:
    • Refactored monolithic 3,300-line connection.rs into domain-specific command handler submodules: strings.rs, hashes.rs, vectors.rs, expiry.rs, admin.rs, mod.rs, and isolated tests.rs.
  • Modularization of kachedb-cli:
    • Restructured CLI into dedicated submodules: repl.rs (interactive terminal, quoted tokenizer, pretty-printer), snapshot.rs (forensic inspector supporting V2, V3, and V4 snapshots with CRC32 verification), bench.rs (pipelined throughput benchmark), and main.rs (clean CLI argument parsing with one-shot execution support like kachedb-cli -p 6379 ping).
    • Documented Hash, Admin, and Vector Index commands in interactive help reference card.
  • Benchmarking Engine (kachedb-bench & run_benchmark.sh):
    • Expanded native kachedb-bench harness with --command hset, hget, and hmix operations, pipelining, and high-resolution latency histograms.
    • Updated docker/run_benchmark.sh with automated versioned report generation (benchmark_comparison_results_<version>_hash.md).
  • CI & Toolchain Determinism:
    • Pinned repository and CI Rust toolchain to 1.97.1 via rust-toolchain.toml and GitHub Actions workflows.

v0.2.0: Snapshot Encryption-at-Rest & Hybrid Context Engine

Choose a tag to compare

@vubon vubon released this 27 Sep 06:49

🔐 Snapshot Encryption-at-Rest (dump.kdb)

  • Hardware-Accelerated Streaming AEAD Encryption:
    • Implemented zero-overhead snapshot encryption using AES-256-GCM (AES-NI / ARMv8 Crypto Extensions) and ChaCha20-Poly1305 streaming AEAD fallback.
    • Zero hot-path overhead: in-memory SwissTable lookups and SIMD vector dot products operate on plaintext in memory; encryption and decryption stream through 64 KiB buffers out-of-band during background snapshot disk writes and boot hydration.
    • Per-chunk 96-bit nonces ($Nonce_i = MasterNonce \oplus i$) and index-bound AAD ($AAD = i$) prevent chunk reordering, substitution, or truncation.
  • Wire Format KDB\x03 & Seamless Backward Compatibility:
    • Added KDB\x03 wire format containing 32-byte HKDF salt, 12-byte master nonce, encrypted 64 KiB chunks, and EOF sentinel 0u32 before the IEEE 802.3 CRC32 trailer.
    • Automatically loads unencrypted legacy KDB\x02 and unencrypted KDB\x03 snapshots with zero key prompts or configuration.
  • Key Ingestion & Zeroization:
    • Supports 32-byte raw binary master key files (snapshot-encryption-key-file), 64-character hex keys, or passphrases derived with HKDF-SHA256 (snapshot-encryption-key).
    • Volatile memory zeroization upon drop (std::ptr::write_volatile).
  • Offline Snapshot Diagnostics (kachedb-cli):
    • Added kachedb-cli snapshot-info <FILE.kdb> subcommand to inspect format version, timestamp, encryption status, cipher suite, salt, master nonce, and verify full CRC32 checksum integrity.

🧠 Hybrid Context Engine & Vector Upgrades

  • 64-Bit Tag Bitmask Pre-Filtering:
    • High-speed bitwise pre-filtering skipping irrelevant vectors before SIMD dot product computation.
  • Hierarchical Document Chunking & Parent Pointers:
    • Added parent_key linkage in vector entries to seamlessly retrieve full parent context documents from SwissTable.
  • Automatic Multi-Core Auto-Parallelism:
    • Setting workers 0 in kachedb.conf automatically detects available physical/logical CPU cores.
  • Antigravity IDE Integration Guide:
    • Added comprehensive guide and production-tested .agents/AGENTS.md rule template (docs/guides/agentic-ide-integration.md) for configuring KacheDB as an autonomous persistent memory layer for Antigravity IDE coding agents.