Skip to content

Repository files navigation

Sailbox Redis in Rust

This repository contains a small Redis-compatible in-memory server written in Rust. It was implemented by Sailbox worker agents using Sail inference against a curated behavior corpus, with the agent prompts and ledgers preserved for auditability.

The implementation is intentionally focused on core Redis behavior rather than full Redis coverage. It supports RESP over TCP, inline commands, and common string, key, expiry, hash, list, set, and sorted-set commands.

NOTE: this repo is to demonstrate how Sailboxes can be used for long-running agent workflows. None of the code here has been reviewed by a human and nothing here should be used for a production service.

Implemented Surface

  • Connection protocol: RESP arrays, bulk strings, simple strings, integers, errors, nil values, and inline commands.
  • Core commands: PING, ECHO, SET, GET, DEL, EXISTS, TYPE, FLUSHDB.
  • Numeric commands: INCR, DECR.
  • Expiry commands: TTL, PTTL, SET EX, SET PX, lazy expiry.
  • Hash commands: HSET, HGET, HLEN.
  • List commands: LPUSH, RPUSH, LPOP, RPOP, LLEN.
  • Set commands: SADD, SREM, SISMEMBER, SCARD.
  • Sorted-set commands: ZADD, ZSCORE, ZCARD.

Repository Layout

  • src/: Redis server, RESP codec, command dispatcher, and in-memory store.
  • tests/: integration and command-dispatch tests.
  • tools/corpus_runner.py: black-box corpus test runner against a live server.
  • tools/perf_smoke.py: performance smoke checks with relaxed regression gates.
  • redis_corpus/: curated behavior corpus and provenance notes.
  • AGENTS.md, agents/, assignments/: agent instructions and task specs.
  • ledgers/: agent/coordinator run ledgers from the implementation process.

Requirements

  • Rust stable toolchain with Cargo.
  • Python 3 for the corpus and performance scripts.
  • Optional: redis-cli for an interactive Redis-style REPL.

Install Rust with rustup if needed:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal

Run The Server

Start the Redis-compatible server:

cargo run --release

By default it listens on 127.0.0.1:6379. To use another port:

PORT=6380 cargo run --release

Use A Redis REPL

With the server running, connect using redis-cli:

redis-cli -p 6379

Example session:

127.0.0.1:6379> PING
PONG
127.0.0.1:6379> SET greeting hello
OK
127.0.0.1:6379> GET greeting
"hello"
127.0.0.1:6379> HSET user:1 name Ada visits 3
(integer) 2
127.0.0.1:6379> HGET user:1 name
"Ada"
127.0.0.1:6379> LPUSH queue a b c
(integer) 3
127.0.0.1:6379> RPOP queue
"a"

If redis-cli is not installed, you can still smoke test with Python:

python3 - <<'PY'
import socket

with socket.create_connection(("127.0.0.1", 6379)) as s:
    s.sendall(b"*1\r\n$4\r\nPING\r\n")
    print(s.recv(1024).decode(), end="")
PY

Run Tests

Run the Rust validation suite:

cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test

Run the corpus tests against a live server:

cargo run --release

In another terminal:

python3 tools/corpus_runner.py

Run the performance smoke checks:

python3 tools/perf_smoke.py

The performance script is intended to catch large regressions, not minor machine to machine timing variation.

One-Shot Local Check

This approximates the validation used by the agent harness:

cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test
cargo build --release
PORT=6379 target/release/sailbox-redis &
server_pid=$!
trap 'kill "$server_pid" 2>/dev/null || true' EXIT
sleep 1
python3 tools/corpus_runner.py
python3 tools/perf_smoke.py

Corpus Provenance

The corpus is a hand-curated behavior specification for this project. It was not generated from Redis, Valkey, Dragonfly, KeyDB, Garnet, Redict, or other Redis-compatible source trees. See redis_corpus/provenance.json for details.

Agent Artifacts

The ledgers/, agents/, and assignments/ directories are preserved so the implementation process can be reviewed. They are not required to run the server, but they document which agent assignments ran, what was merged, and what repairs were attempted.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages