This document is a comprehensive ChronosDB CLI and core protocol usage guide, modeled after Ocular's style (clear sections, choice exposition, and explicit examples).
ChronosDB provides:
- Write path fully consistent through Raft:
INSERT,UPDATE,DELETE
- Vector search and time-travel query path:
SELECT,GET,HISTORY,AS OF
- Native
RETURNING idon write operations with wire-flag support. - No implicit SQL translation in the client—command->opcodes are explicit.
cargo run --release -- --node-id 1 --addr 127.0.0.1:9000 --raft-port 20001 --control-port 20002 --bootstrapcargo run --bin chronos-cli -- --host 127.0.0.1:9000cat > script.sql <<'EOS'
INSERT INTO VECTORS VALUES ([0.1, 0.2, 0.3], "hello") RETURNING id;
SELECT FROM VECTORS WHERE VECTOR NEAR [0.1, 0.2, 0.3] LIMIT 5;
EOS
cargo run --bin chronos-cli -- --script script.sql --host 127.0.0.1:9000 --script-continue-on-errorINSERT INTO VECTORS VALUES ([0.1, 0.2, ...], "payload")
Inserts a new version record with vector and payload. Node auto-pads vectors shorter than 128 dims.
UPDATE VECTORS SET PAYLOAD="updated" WHERE ID='uuid'
Appends a new version with updated payload.
DELETE FROM VECTORS WHERE ID='uuid'
Soft delete (tombstone): history remains.
GET 'uuid'
Retrieves the latest payload for the given ID.
SELECT FROM VECTORS WHERE ID='uuid' AS OF 1670000000
Returns the version valid at the specified timestamp.
HISTORY 'uuid'
Returns full version timeline of the record.
SELECT FROM VECTORS WHERE VECTOR NEAR [0.1, 0.2, ...] LIMIT 5
Returns nearest records using HNSW index.
Write commands now support explicit RETURNING id in the query.
Example:
INSERT INTO VECTORS VALUES ([0.1, 0.2, ...], "payload") RETURNING id;
UPDATE VECTORS SET PAYLOAD="updated" WHERE ID='uuid' RETURNING id;
DELETE FROM VECTORS WHERE ID='uuid' RETURNING id;
- Request includes 1-byte flags:
0x01:RETURNING idrequested0x00: none
- Server response:
- 1-byte status (
0=OK,1=ERR) - 4-byte little-endian payload length
- binary payload (
UUIDwhen returning id)
- 1-byte status (
INSERT->OP_INSERT(0x01)GET->OP_GET(0x02)SEARCH->OP_SEARCH(0x03)HISTORY->OP_HISTORY(0x04)DELETE->OP_DELETE(0x05)UPDATE->OP_UPDATE(0x06)GET AS OF->OP_GET_AS_OF(0x07)
[flags=1][id=16][vector=128*4][payload...]
- GET/HISTORY/SEARCH etc uses its own body structures (see code).
Use --script-continue-on-error to keep processing on errors; each result contains success, exit_code, output, and error fields.
Raft Write Error: APIError(ForwardToLeader(...))means a follower received a write; retry with leader address.No record found valid at timemeans no version existed in the requested interval.
- expand support to
RETURNING payloadandRETURNING vector. - add configurable CLI autocompletion and explicit connection health checks.