cmd/server,cmd/client: entrypoints for running the KV server and client.store/: MVCC storage engine, OCC/TTL, and related tests.kv/: hybrid logical clock (HLC) utilities and KV interfaces.adapter/: protocol adapters (e.g., Redis), plus integration tests.jepsen/,jepsen/redis/: Jepsen test harnesses and workloads.proto/,distribution/,internal/: supporting protobufs, build assets, and shared helpers.
go test ./...— run unit/integration tests. If macOS sandbox blocks$GOCACHE, preferGOCACHE=$(pwd)/.cache GOTMPDIR=$(pwd)/.cache/tmp go test ./....GOCACHE=$(pwd)/.cache GOLANGCI_LINT_CACHE=$(pwd)/.golangci-cache golangci-lint run ./... --timeout=5m— full lint suite.HOME=$(pwd)/jepsen/tmp-home LEIN_HOME=$(pwd)/jepsen/.lein LEIN_JVM_OPTS="-Duser.home=$(pwd)/jepsen/tmp-home" /tmp/lein test(fromjepsen/orjepsen/redis/) — Jepsen tests.go run ./cmd/server/go run ./cmd/client— start server or CLI locally.
- Go code:
gofmt+ project lint rules (golangci-lint). Avoid adding//nolintunless absolutely required; prefer refactoring. - Naming: Go conventions (MixedCaps for exported identifiers, short receiver names). Filenames remain lowercase with underscores only where existing.
- Logging: use
slogwhere present; maintain structured keys (key,commit_ts, etc.).
- Unit tests co-located with packages (
*_test.go); prefer table-driven cases. - TTL/HLC behaviors live in
store/andkv/; add coverage when touching clocks, OCC, or replication logic. - Integration: run Jepsen suites after changes affecting replication, MVCC, or Redis adapter.
cd jepsen && HOME=$(pwd)/tmp-home LEIN_HOME=$(pwd)/.lein LEIN_JVM_OPTS="-Duser.home=$(pwd)/tmp-home" /tmp/lein testcd jepsen/redis && HOME=$(pwd)/../tmp-home LEIN_HOME=$(pwd)/../.lein LEIN_JVM_OPTS="-Duser.home=$(pwd)/../tmp-home" /tmp/lein test
- Messages: short imperative summary (e.g., “Add HLC TTL handling”). Include scope when helpful (
store:,adapter:). - Pull requests: describe behavior change, risk, and test evidence (
go test, lint, Jepsen). Add repro steps for bug fixes.
- Hybrid clock derives from wall-clock millis; keep system clock reasonably synchronized across nodes.
- Avoid leader-local timestamps in persistence; timestamp issuance should originate from the Raft leader to prevent skewed OCC decisions.