Chronos DB 0.1.1
Merge policies: agents merge on their own within rules, the rest wait for a person
Merge policies: agents merge on their own within rules, the rest wait for a person
CREATE / ALTER / DROP MERGE POLICYwithmax_rows,max_deletes,tables,review_tables,schemaandoverwrite, andALTER AGENT ... SET (policy = ...). The rules are checked inside the merge, on the rows it applies, under its locks, so what is checked is what merges. A refused merge keeps its world and waits inSHOW REVIEWSfor a person to merge or drop it.- Over MCP:
merge_policies,check_merge_policy(try rules on a branch's real changes),set_merge_policy,drop_merge_policy,reviews; in safe mode the agent drafts rules and gets the SQL for a person to run. An agent under a policy changes main only by merging, and may notUNDO MERGEorUNDO AGENT. See docs/guides/merge-policies.md.
Correctness, measured: SQLite's sqllogictest over the Postgres protocol
- 622 files, 5,675,180 records, the same runner on Chronos DB and Postgres 17: Chronos passes 99.912%, Postgres 99.796%, and there's no record Postgres answers right and Chronos wrong. The 63 that fail only on Chronos are division by zero beside a NULL constant. Method, gaps and results: BENCHMARKS.md §13 and
bench/slt. What the run found is fixed: - String literals are read as the type they meet when the statement is planned, as Postgres does:
'hello' = int_col,x IN (1, 'hello'),'hello' IN (SELECT x ...)andSET x = 'hello'fail with 22P02 even when no row is compared or changed (they were only checked row by row, so an empty table let them pass). - A column set twice in one
SETis 42601,multiple assignments to same column. - Aggregates take
ALL, the default, as insum(ALL x)andstring_agg(ALL s, ',')(it was a syntax error). - An
ORorANDinside each of many nested parentheses, as generated queries write them, is counted by the tree it makes: each such level counted 16 toward the limit of 400, so(a OR (a OR (...)))was refused (54001) at 25 levels; now it's about 3 a level, and 60 levels run. - Parenthesized joins in FROM:
FROM (a JOIN b ON ...),((a CROSS JOIN b)), and after an inner or cross joina JOIN (b JOIN c ON ...) ON ...(it was a syntax error,expected SELECT); one after an outer join or USING, or with an alias of its own, is refused (0A000) for now. Both found by SQLite's sqllogictest.
SQL
- A
WITHquery used more than once is computed once, as in Postgres: every use reads the same rows, sonextval()orrandom()in it gives one value to all its uses. INSERT INTO t VALUES (1)into a wider table fills the first columns and gives the rest their defaults (serials included), as Postgres does.
Fixes from the fourth code review
- A
COPY FROM STDINwhose client sends nothing forCHRONOS_COPY_IDLE(60 s) is dropped and undone, instead of holding its world's writers for good; one huge CopyData message is read a part at a time. - After a power cut, a page left half-written at the end of the pack is checked before it's taken as stored, and written again whole.
- A big statement committed by its log note is reported done even if the rest of that checkpoint fails (retried later), so a client isn't told to insert twice.
- Replaying history (
UNDO,AS OF,HISTORY) errors when a log segment it needs was cleaned up, instead of replaying without it. UNDO MERGEandUNDO AGENTneed the right to write the world they change, asRESTOREdoes.
Integer keys in number order
- Tables made from now on store an integer primary key in number order, so a range of ids is one read of the tree:
WHERE id > 1000no longer scans the table, andBETWEENno longer looks keys up one by one (it did for ranges under 100,000 keys). Rows withoutORDER BYcome back in id order (1, 2, 10), not as text (1, 10, 2). Tables made before keep their keys as they are. - People still see and type
t/7everywhere: diffs, conflicts,UNDOmessages,ONLY KEYS, the shell, the HTTP API, MCP,search()and the key-value API (db.get("t/7"); a key is written as its number, sot/007is refused, as before). - A big statement's parts in key order go straight into the new tree, instead of through sorted spill files first: a load in id order, and an
UPDATEof values (it reads in key order). A binary COPY of 76,424 × 1,536 embeddings writes 526 MB instead of 1,057 MB (1,816 MB before 0.1.0's streaming COPY), with 6–8 s of server CPU instead of 9–22 s, in 8–15 s instead of 13–23 s (four runs each on a cloud VM whose disk varies).